Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into hotreload2
Browse files Browse the repository at this point in the history
  • Loading branch information
srujzs committed Jan 28, 2025
2 parents 9b6db74 + a7ea61f commit bc818e2
Show file tree
Hide file tree
Showing 7 changed files with 254 additions and 146 deletions.
2 changes: 1 addition & 1 deletion dwds/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## 24.3.4

- Added support for some debugging APIs with the DDC library bundle format. - [#2566](https://github.com/dart-lang/webdev/issues/2566)
- Added support for some debugging APIs with the DDC library bundle format. - [#2566](https://github.com/dart-lang/webdev/issues/2566), [#2573](https://github.com/dart-lang/webdev/issues/2573)
- Added support for hot reload using the DDC library bundle format.

## 24.3.3
Expand Down
40 changes: 18 additions & 22 deletions dwds/lib/src/debugging/inspector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,9 @@ class AppInspector implements AppInspectorInterface {
@override
Future<RemoteObject> invoke(
String targetId,
String selector,
List<dynamic> arguments,
) async {
String selector, [
List<dynamic> arguments = const [],
]) async {
final remoteArguments =
arguments.cast<String>().map(remoteObjectFor).toList();
// We special case the Dart library, where invokeMethod won't work because
Expand All @@ -302,14 +302,18 @@ class AppInspector implements AppInspectorInterface {
String selector,
List<RemoteObject> arguments,
) {
final libraryUri = library.uri;
if (libraryUri == null) {
throwInvalidParam('invoke', 'library uri is null');
}
return globalToolConfiguration.loadStrategy is DdcLibraryBundleStrategy
? _evaluateLibraryMethodWithDdcLibraryBundle(
library,
libraryUri,
selector,
arguments,
)
: _evaluateInLibrary(
library,
libraryUri,
'function () { return this.$selector.apply(this, arguments); }',
arguments,
);
Expand Down Expand Up @@ -337,16 +341,12 @@ class AppInspector implements AppInspectorInterface {
}

/// Evaluate the JS function with source [jsFunction] in the context of
/// [library] with [arguments].
/// the library identified by [libraryUri] with [arguments].
Future<RemoteObject> _evaluateInLibrary(
Library library,
String libraryUri,
String jsFunction,
List<RemoteObject> arguments,
) async {
final libraryUri = library.uri;
if (libraryUri == null) {
throwInvalidParam('invoke', 'library uri is null');
}
final findLibraryJsExpression = globalToolConfiguration
.loadStrategy.dartRuntimeDebugger
.callLibraryMethodJsExpression(libraryUri, jsFunction);
Expand All @@ -355,18 +355,14 @@ class AppInspector implements AppInspectorInterface {
return jsCallFunctionOn(remoteLibrary, jsFunction, arguments);
}

/// Evaluates the specified top-level method [methodName] within [library]
/// using the Dart Development Compiler (DDC) library bundle strategy with
/// the given [arguments].
/// Evaluates the specified top-level method [methodName] within the library
/// identified by [libraryUri] using the Dart Development Compiler (DDC)
/// library bundle strategy with the given optional [arguments].
Future<RemoteObject> _evaluateLibraryMethodWithDdcLibraryBundle(
Library library,
String methodName,
List<RemoteObject> arguments,
) {
final libraryUri = library.uri;
if (libraryUri == null) {
throwInvalidParam('invoke', 'library uri is null');
}
String libraryUri,
String methodName, [
List<RemoteObject> arguments = const [],
]) {
final expression = globalToolConfiguration.loadStrategy.dartRuntimeDebugger
.callLibraryMethodJsExpression(libraryUri, methodName);
return _jsCallFunction(expression, arguments);
Expand Down
Loading

0 comments on commit bc818e2

Please sign in to comment.