Skip to content

Commit 020e0fc

Browse files
authored
Merge branch 'main' into fix/upcoming-lint-fixes
2 parents c49579d + ab620d1 commit 020e0fc

18 files changed

+363
-199
lines changed

dwds/CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
## 24.2.0-wip
1+
## 24.2.1-wip
2+
3+
- Update to be forward compatible with changes to `package:shelf_web_socket`.
4+
5+
## 24.2.0
26

37
- Consolidate `FrontendServerDdcStrategyProvider` and `FrontendServerRequireStrategyProvider` under a shared parent class. - [#2517](https://github.com/dart-lang/webdev/issues/2517)
48
- Remove `build_daemon_ddc_and_canary_evaluate_test`. - [2512](https://github.com/dart-lang/webdev/issues/2512)
@@ -11,7 +15,9 @@
1115
to use the provided `name` in a `ModuleMetadata`. Metadata provided by DDC
1216
when using the library bundle format does not provide a useful bundle name.
1317
- Migrate to `package:web` v1.1.0.
14-
- Added support for some debugging APIs with the DDC library bundle format. - [#2488](https://github.com/dart-lang/webdev/issues/2488)
18+
- Added support for some debugging APIs with the DDC library bundle format. - [#2488](https://github.com/dart-lang/webdev/issues/2488), [#2534](https://github.com/dart-lang/webdev/issues/2534)
19+
- Update `package:vm_service` to '>=14.2.4 <16.0.0'.
20+
- Update `package:vm_service_interface` to '2.0.1'.
1521

1622
## 24.1.0
1723

dwds/lib/src/debugging/classes.dart

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,8 @@ class ClassHelper extends Domain {
7777

7878
if (libraryUri == null || classId == null || className == null) return null;
7979

80-
final expression = '''
81-
(function() {
82-
const sdk = ${globalToolConfiguration.loadStrategy.loadModuleSnippet}('dart_sdk');
83-
const dart = sdk.dart;
84-
return dart.getClassMetadata('$libraryUri', '$className');
85-
})()
86-
''';
87-
80+
final expression = globalToolConfiguration.loadStrategy.dartRuntimeDebugger
81+
.getClassMetadataJsExpression(libraryUri, className);
8882
RemoteObject result;
8983
try {
9084
result = await inspector.remoteDebugger.evaluate(

dwds/lib/src/debugging/dart_runtime_debugger.dart

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class DartRuntimeDebugger {
1414
}) : _loadStrategy = loadStrategy,
1515
_useLibraryBundleExpression = useLibraryBundleExpression;
1616

17+
/// Generates a JS expression based on DDC module format.
1718
String _generateJsExpression(
1819
String ddcExpression,
1920
String libraryBundleExpression,
@@ -23,16 +24,18 @@ class DartRuntimeDebugger {
2324
: ddcExpression;
2425
}
2526

27+
/// Wraps a JS function call with SDK loader logic.
2628
String _wrapWithSdkLoader(String args, String functionCall) {
2729
return '''
2830
function($args) {
29-
const sdk = ${_loadStrategy.loadModuleSnippet}("dart_sdk");
31+
const sdk = ${_loadStrategy.loadModuleSnippet}('dart_sdk');
3032
const dart = sdk.dart;
3133
return dart.$functionCall;
3234
}
3335
''';
3436
}
3537

38+
/// Wraps a JS function call with DDC library bundle loader logic.
3639
String _wrapWithBundleLoader(String args, String functionCall) {
3740
return '''
3841
function($args) {
@@ -41,6 +44,12 @@ class DartRuntimeDebugger {
4144
''';
4245
}
4346

47+
/// Wraps an expression in an Immediately Invoked Function Expression (IIFE).
48+
String _wrapInIIFE(String expression) {
49+
return '($expression)()';
50+
}
51+
52+
/// Builds a JS expression based on the loading strategy.
4453
String _buildExpression(
4554
String args,
4655
String ddcFunction,
@@ -52,6 +61,7 @@ class DartRuntimeDebugger {
5261
);
5362
}
5463

64+
/// Generates a JS expression for retrieving object metadata.
5565
String getObjectMetadataJsExpression() {
5666
return _buildExpression(
5767
'arg',
@@ -60,6 +70,7 @@ class DartRuntimeDebugger {
6070
);
6171
}
6272

73+
/// Generates a JS expression for retrieving object field names.
6374
String getObjectFieldNamesJsExpression() {
6475
return _buildExpression(
6576
'',
@@ -68,6 +79,7 @@ class DartRuntimeDebugger {
6879
);
6980
}
7081

82+
/// Generates a JS expression for retrieving function metadata.
7183
String getFunctionMetadataJsExpression() {
7284
return _buildExpression(
7385
'',
@@ -76,11 +88,23 @@ class DartRuntimeDebugger {
7688
);
7789
}
7890

91+
/// Generates a JS expression for retrieving a subrange of elements.
7992
String getSubRangeJsExpression() {
8093
return _buildExpression(
8194
'offset, count',
8295
'getSubRange(this, offset, count)',
8396
'getSubRange(this, offset, count)',
8497
);
8598
}
99+
100+
/// Generates a JS expression for retrieving class metadata.
101+
String getClassMetadataJsExpression(String libraryUri, String className) {
102+
final expression = _buildExpression(
103+
'',
104+
"getClassMetadata('$libraryUri', '$className')",
105+
"getClassMetadata('$libraryUri', '$className')",
106+
);
107+
// Use the helper method to wrap this in an IIFE
108+
return _wrapInIIFE(expression);
109+
}
86110
}

dwds/lib/src/handlers/socket_connections.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class WebSocketSocketHandler extends SocketHandler {
104104

105105
WebSocketSocketHandler() {
106106
_handler = webSocketHandler(
107-
(WebSocketChannel channel) =>
107+
(WebSocketChannel channel, _) =>
108108
_connectionsStream.add(WebSocketConnection(channel)),
109109
);
110110
}

dwds/lib/src/injected/client.js

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

dwds/lib/src/services/debug_service.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ int _clientsConnected = 0;
3434

3535
Logger _logger = Logger('DebugService');
3636

37-
void Function(WebSocketChannel) _createNewConnectionHandler(
37+
void Function(WebSocketChannel, String?) _createNewConnectionHandler(
3838
ChromeProxyService chromeProxyService,
3939
ServiceExtensionRegistry serviceExtensionRegistry, {
4040
void Function(Map<String, Object>)? onRequest,
4141
void Function(Map<String, Object?>)? onResponse,
4242
}) {
43-
return (webSocket) {
43+
return (webSocket, subprotocol) {
4444
final responseController = StreamController<Map<String, Object?>>();
4545
webSocket.sink.addStream(
4646
responseController.stream.map((response) {

dwds/lib/src/version.dart

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dwds/pubspec.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: dwds
22
# Every time this changes you need to run `dart run build_runner build`.
3-
version: 24.2.0-wip
3+
version: 24.2.1-wip
44
description: >-
55
A service that proxies between the Chrome debug protocol and the Dart VM
66
service protocol.
@@ -15,7 +15,7 @@ dependencies:
1515
collection: ^1.15.0
1616
crypto: ^3.0.2
1717
dds: ^4.2.5
18-
file: ">=6.1.4 <8.0.0"
18+
file: '>=6.1.4 <8.0.0'
1919
http: ^1.0.0
2020
http_multi_server: ^3.2.0
2121
logging: ^1.0.2
@@ -33,8 +33,8 @@ dependencies:
3333
stack_trace: ^1.10.0
3434
sse: ^4.1.2
3535
uuid: ^4.0.0
36-
vm_service: ^14.2.4
37-
vm_service_interface: 1.1.0
36+
vm_service: '>=14.2.4 <16.0.0'
37+
vm_service_interface: 2.0.1
3838
web_socket_channel: '>=2.2.0 <4.0.0'
3939
web: ^1.1.0
4040
webkit_inspection_protocol: ^1.0.1
@@ -52,7 +52,7 @@ dev_dependencies:
5252
graphs: ^2.1.0
5353
frontend_server_common:
5454
path: ../frontend_server_common
55-
js: ">=0.6.4 <0.8.0"
55+
js: '>=0.6.4 <0.8.0'
5656
lints: ^4.0.0
5757
pubspec_parse: ^1.2.0
5858
puppeteer: ^3.1.1

dwds/pubspec_overrides.yaml

Lines changed: 0 additions & 9 deletions
This file was deleted.

dwds/test/build/ensure_version_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ void main() {
1818
expect(
1919
Version.parse(packageVersion),
2020
pubspec.version,
21-
reason: 'Please run `pub run build_runner build '
21+
reason: 'Please run `dart run build_runner build '
2222
'--build-filter=lib/src/version.dart` to update the version.',
2323
);
2424
});

0 commit comments

Comments
 (0)