Skip to content

Commit 07d1034

Browse files
author
Anna Gringauze
authored
Fixed issues discovered in integration (#1469)
- some scenarios require libraries.json to be a different path from the SDK installation directory, update DartUri and ExpressionCompilerService to allow for that. - Fix a bug where `dartEmitDebugEvents` was set as a `String` instead of `bool` in the injected client.
1 parent 98d69bb commit 07d1034

File tree

5 files changed

+17
-8
lines changed

5 files changed

+17
-8
lines changed

dwds/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55
- Make `ExpressionCompilerService` infer location of `libraries.json` from
66
`sdkDir` parameter.
77
- Show an alert in the Dart Debug Extension for a multi-app scenario.
8+
- Fix a bug where `dartEmitDebugEvents` was set as a `String` instead of `bool`
9+
in the injected client.
810

911
**Breaking changes:**
1012

11-
- Add `sdkDir` argument to `Dwds.start` to help file resolution for sdk uris.
13+
- Add `sdkDir` and `librariesPath` arguments to `Dwds.start` to help file
14+
resolution for sdk uris.
1215
- Add `emitDebugEvents` argument to `Dwds.start` to suppress emitting debug
1316
events from the injected client.
17+
- Replace `sdkRoot` parameter by `sdkDir` in `ExpressionCompilerService`.
1418

1519
## 11.5.1
1620

dwds/lib/dwds.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ class Dwds {
113113
bool enableDevtoolsLaunch,
114114
DevtoolsLauncher devtoolsLauncher,
115115
Uri sdkDir,
116+
Uri librariesPath,
116117
bool emitDebugEvents,
117118
}) async {
118119
hostname ??= 'localhost';
@@ -126,7 +127,7 @@ class Dwds {
126127
globalLoadStrategy = loadStrategy;
127128
emitDebugEvents ??= true;
128129

129-
await DartUri.initialize(sdkDir: sdkDir);
130+
await DartUri.initialize(sdkDir: sdkDir, librariesPath: librariesPath);
130131

131132
DevTools devTools;
132133
Future<String> extensionUri;

dwds/lib/src/handlers/injector.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ String _injectedClientSnippet(
205205
'window.\$dwdsDevHandlerPath = "$devHandlerPath";\n'
206206
'window.\$dwdsEnableDevtoolsLaunch = $enableDevtoolsLaunch;\n'
207207
'window.\$dartEntrypointPath = "$entrypointPath";\n'
208-
'window.\$dartEmitDebugEvents = "$emitDebugEvents";\n'
208+
'window.\$dartEmitDebugEvents = $emitDebugEvents;\n'
209209
'${loadStrategy.loadClientSnippet(_clientScript)}';
210210
if (extensionUri != null) {
211211
injectedBody += 'window.\$dartExtensionUri = "$extensionUri";\n';

dwds/lib/src/services/expression_compiler_service.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ class _Compiler {
237237
///
238238
/// [_sdkDir] is the path to the SDK installation directory.
239239
/// [_workerPath] is the path to the DDC worker snapshot.
240+
/// [_librariesPath] is the path to the libraries.json spec.
240241
///
241242
/// Users need to stop the service by calling [stop].
242243
class ExpressionCompilerService implements ExpressionCompiler {
@@ -248,12 +249,14 @@ class ExpressionCompilerService implements ExpressionCompiler {
248249

249250
final String _sdkDir;
250251
final String _workerPath;
252+
final String _librariesPath;
251253

252254
ExpressionCompilerService(
253255
this._address, this._port, this._assetHandler, this._verbose,
254-
{String sdkDir, String workerPath})
256+
{String sdkDir, String workerPath, String librariesPath})
255257
: _sdkDir = sdkDir,
256-
_workerPath = workerPath;
258+
_workerPath = workerPath,
259+
_librariesPath = librariesPath;
257260

258261
@override
259262
Future<ExpressionCompilationResult> compileExpressionToJs(
@@ -280,7 +283,8 @@ class ExpressionCompilerService implements ExpressionCompiler {
280283
var sdkSummaryPath = soundNullSafety
281284
? p.join(sdkSummaryRoot, 'ddc_outline_sound.dill')
282285
: p.join(sdkSummaryRoot, 'ddc_sdk.dill');
283-
var librariesPath = p.join(sdkDir, 'lib', 'libraries.json');
286+
var librariesPath =
287+
_librariesPath ?? p.join(sdkDir, 'lib', 'libraries.json');
284288
var workerPath =
285289
_workerPath ?? p.join(binDir, 'snapshots', 'dartdevc.dart.snapshot');
286290

dwds/lib/src/utilities/dart_uri.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ class DartUri {
154154
static String currentDirectoryUri = '${p.toUri(currentDirectory)}';
155155

156156
/// Record library and script uris to enable resolving library and script paths.
157-
static Future<void> initialize({Uri sdkDir}) async {
157+
static Future<void> initialize({Uri sdkDir, Uri librariesPath}) async {
158158
_sdkDir =
159159
sdkDir ?? p.toUri(p.dirname(p.dirname(Platform.resolvedExecutable)));
160160

161-
var librariesPath =
161+
librariesPath ??=
162162
p.toUri(p.join(_sdkDir.toFilePath(), 'lib', 'libraries.json'));
163163
var packagesUri = p.toUri(p.join(currentDirectory, '.packages'));
164164

0 commit comments

Comments
 (0)