Skip to content

Commit 48fc725

Browse files
authored
Add a new workspaceName parameter to DWDS on start up (#2237)
1 parent d2dae56 commit 48fc725

File tree

9 files changed

+25
-3
lines changed

9 files changed

+25
-3
lines changed

dwds/CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
## 22.0.0-wip
22

3+
- Update the interface for ChromeProxyService.getSourceReport to match the VM service. - [#2235](https://github.com/dart-lang/webdev/pull/2235)
4+
35
**Breaking changes**
46

57
- Refactor the parameters to `Dwds.start`. - [#2231](https://github.com/dart-lang/webdev/pull/2231).
6-
7-
- Update the interface for ChromeProxyService.getSourceReport to match the VM service. - [#2235](https://github.com/dart-lang/webdev/pull/2235)
8+
- Add a new parameter `workspaceName` to the `ToolConfiguration` passed to `Dwds.start`. - [#2237](https://github.com/dart-lang/webdev/pull/2237)
89

910
## 21.0.0
1011

dwds/lib/src/config/tool_configuration.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@ ToolConfiguration get globalToolConfiguration => _globalToolConfiguration;
3636
class AppMetadata {
3737
final String hostname;
3838
final bool isInternalBuild;
39+
final String? workspaceName;
3940
Future<bool> Function() isFlutterApp;
4041

4142
AppMetadata({
4243
this.hostname = 'localhost',
4344
this.isInternalBuild = false,
45+
this.workspaceName,
4446
Future<bool> Function()? isFlutterApp,
4547
}) : isFlutterApp = isFlutterApp ?? (() => Future.value(true));
4648
}

dwds/lib/src/handlers/injector.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,5 +200,9 @@ Future<String> _injectedClientSnippet(
200200
if (extensionUri != null) {
201201
injectedBody += 'window.\$dartExtensionUri = "$extensionUri";\n';
202202
}
203+
final workspaceName = globalToolConfiguration.appMetadata.workspaceName;
204+
if (workspaceName != null) {
205+
injectedBody += 'window.\$dartWorkspaceName = "$workspaceName";\n';
206+
}
203207
return injectedBody;
204208
}

dwds/lib/src/injected/client.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dwds/test/fixtures/context.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ class TestContext {
154154
bool isInternalBuild = false,
155155
List<String> experiments = const <String>[],
156156
bool canaryFeatures = false,
157+
String? workspaceName,
157158
}) async {
158159
final sdkLayout = sdkConfigurationProvider.sdkLayout;
159160
final toolConfiguration = createToolConfiguration(
@@ -171,6 +172,7 @@ class TestContext {
171172
hostname: hostname,
172173
isInternalBuild: isInternalBuild,
173174
isFlutterApp: () => Future.value(isFlutterApp),
175+
workspaceName: workspaceName,
174176
),
175177
);
176178
setGlobalsForTesting(toolConfiguration: toolConfiguration);
@@ -427,6 +429,7 @@ class TestContext {
427429
ddcService,
428430
isFlutterApp,
429431
isInternalBuild,
432+
workspaceName,
430433
sdkLayout,
431434
);
432435

dwds/test/fixtures/server.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class TestServer {
8282
ExpressionCompilerService? ddcService,
8383
bool isFlutterApp,
8484
bool isInternalBuild,
85+
String? workspaceName,
8586
TestSdkLayout sdkLayout,
8687
) async {
8788
var pipeline = const Pipeline();
@@ -132,6 +133,7 @@ class TestServer {
132133
hostname: hostname,
133134
isInternalBuild: isInternalBuild,
134135
isFlutterApp: () => Future.value(isFlutterApp),
136+
workspaceName: workspaceName,
135137
);
136138

137139
final toolConfiguration = ToolConfiguration(

dwds/test/puppeteer/extension_common.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ void testAll({
5959
extensionPath: extensionPath,
6060
serveDevTools: true,
6161
useSse: useSse,
62+
workspaceName: 'test-workspace',
6263
);
6364

6465
if (isMV3) {
@@ -111,6 +112,7 @@ void testAll({
111112
expect(debugInfo.appUrl, isNotNull);
112113
expect(debugInfo.isInternalBuild, isNotNull);
113114
expect(debugInfo.isFlutterApp, isNotNull);
115+
expect(debugInfo.workspaceName, isNotNull);
114116
await appTab.close();
115117
});
116118

dwds/test/puppeteer/test_utils.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Future<Browser> setUpExtensionTest(
4242
bool isInternalBuild = false,
4343
bool isFlutterApp = false,
4444
bool openChromeDevTools = false,
45+
String? workspaceName,
4546
}) async {
4647
// TODO(elliette): Only start a TestServer, that way we can get rid of the
4748
// launchChrome parameter: https://github.com/dart-lang/webdev/issues/1779
@@ -52,6 +53,7 @@ Future<Browser> setUpExtensionTest(
5253
enableDebugExtension: true,
5354
isInternalBuild: isInternalBuild,
5455
isFlutterApp: isFlutterApp,
56+
workspaceName: workspaceName,
5557
);
5658
return await puppeteer.launch(
5759
devTools: openChromeDevTools,

dwds/web/client.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,8 @@ void _launchCommunicationWithDebugExtension() {
271271
..authUrl = _authUrl
272272
..extensionUrl = _extensionUrl
273273
..isInternalBuild = _isInternalBuild
274-
..isFlutterApp = _isFlutterApp,
274+
..isFlutterApp = _isFlutterApp
275+
..workspaceName = dartWorkspaceName,
275276
),
276277
),
277278
);
@@ -358,6 +359,9 @@ external bool get isInternalBuild;
358359
@JS(r'$isFlutterApp')
359360
external bool get isFlutterApp;
360361

362+
@JS(r'$dartWorkspaceName')
363+
external String? get dartWorkspaceName;
364+
361365
bool get _isChromium => window.navigator.vendor.contains('Google');
362366

363367
JsObject get _windowContext => JsObject.fromBrowserObject(window);

0 commit comments

Comments
 (0)