Skip to content

Add a new workspaceName parameter to DWDS on start up #2237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions dwds/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
## 22.0.0-wip

- Update the interface for ChromeProxyService.getSourceReport to match the VM service. - [#2235](https://github.com/dart-lang/webdev/pull/2235)

**Breaking changes**

- Refactor the parameters to `Dwds.start`. - [#2231](https://github.com/dart-lang/webdev/pull/2231).

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

## 21.0.0

Expand Down
2 changes: 2 additions & 0 deletions dwds/lib/src/config/tool_configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ ToolConfiguration get globalToolConfiguration => _globalToolConfiguration;
class AppMetadata {
final String hostname;
final bool isInternalBuild;
final String? workspaceName;
Future<bool> Function() isFlutterApp;

AppMetadata({
this.hostname = 'localhost',
this.isInternalBuild = false,
this.workspaceName,
Future<bool> Function()? isFlutterApp,
}) : isFlutterApp = isFlutterApp ?? (() => Future.value(true));
}
Expand Down
4 changes: 4 additions & 0 deletions dwds/lib/src/handlers/injector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -200,5 +200,9 @@ Future<String> _injectedClientSnippet(
if (extensionUri != null) {
injectedBody += 'window.\$dartExtensionUri = "$extensionUri";\n';
}
final workspaceName = globalToolConfiguration.appMetadata.workspaceName;
if (workspaceName != null) {
injectedBody += 'window.\$dartWorkspaceName = "$workspaceName";\n';
}
return injectedBody;
}
2 changes: 2 additions & 0 deletions dwds/lib/src/injected/client.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions dwds/test/fixtures/context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ class TestContext {
bool isInternalBuild = false,
List<String> experiments = const <String>[],
bool canaryFeatures = false,
String? workspaceName,
}) async {
final sdkLayout = sdkConfigurationProvider.sdkLayout;
final toolConfiguration = createToolConfiguration(
Expand All @@ -171,6 +172,7 @@ class TestContext {
hostname: hostname,
isInternalBuild: isInternalBuild,
isFlutterApp: () => Future.value(isFlutterApp),
workspaceName: workspaceName,
),
);
setGlobalsForTesting(toolConfiguration: toolConfiguration);
Expand Down Expand Up @@ -427,6 +429,7 @@ class TestContext {
ddcService,
isFlutterApp,
isInternalBuild,
workspaceName,
sdkLayout,
);

Expand Down
2 changes: 2 additions & 0 deletions dwds/test/fixtures/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class TestServer {
ExpressionCompilerService? ddcService,
bool isFlutterApp,
bool isInternalBuild,
String? workspaceName,
TestSdkLayout sdkLayout,
) async {
var pipeline = const Pipeline();
Expand Down Expand Up @@ -132,6 +133,7 @@ class TestServer {
hostname: hostname,
isInternalBuild: isInternalBuild,
isFlutterApp: () => Future.value(isFlutterApp),
workspaceName: workspaceName,
);

final toolConfiguration = ToolConfiguration(
Expand Down
2 changes: 2 additions & 0 deletions dwds/test/puppeteer/extension_common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ void testAll({
extensionPath: extensionPath,
serveDevTools: true,
useSse: useSse,
workspaceName: 'test-workspace',
);

if (isMV3) {
Expand Down Expand Up @@ -111,6 +112,7 @@ void testAll({
expect(debugInfo.appUrl, isNotNull);
expect(debugInfo.isInternalBuild, isNotNull);
expect(debugInfo.isFlutterApp, isNotNull);
expect(debugInfo.workspaceName, isNotNull);
await appTab.close();
});

Expand Down
2 changes: 2 additions & 0 deletions dwds/test/puppeteer/test_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Future<Browser> setUpExtensionTest(
bool isInternalBuild = false,
bool isFlutterApp = false,
bool openChromeDevTools = false,
String? workspaceName,
}) async {
// TODO(elliette): Only start a TestServer, that way we can get rid of the
// launchChrome parameter: https://github.com/dart-lang/webdev/issues/1779
Expand All @@ -52,6 +53,7 @@ Future<Browser> setUpExtensionTest(
enableDebugExtension: true,
isInternalBuild: isInternalBuild,
isFlutterApp: isFlutterApp,
workspaceName: workspaceName,
);
return await puppeteer.launch(
devTools: openChromeDevTools,
Expand Down
6 changes: 5 additions & 1 deletion dwds/web/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ void _launchCommunicationWithDebugExtension() {
..authUrl = _authUrl
..extensionUrl = _extensionUrl
..isInternalBuild = _isInternalBuild
..isFlutterApp = _isFlutterApp,
..isFlutterApp = _isFlutterApp
..workspaceName = dartWorkspaceName,
),
),
);
Expand Down Expand Up @@ -358,6 +359,9 @@ external bool get isInternalBuild;
@JS(r'$isFlutterApp')
external bool get isFlutterApp;

@JS(r'$dartWorkspaceName')
external String? get dartWorkspaceName;

bool get _isChromium => window.navigator.vendor.contains('Google');

JsObject get _windowContext => JsObject.fromBrowserObject(window);
Expand Down