@@ -14,6 +14,7 @@ import 'package:dwds/src/debugging/instance.dart';
14
14
import 'package:dwds/src/debugging/libraries.dart' ;
15
15
import 'package:dwds/src/debugging/location.dart' ;
16
16
import 'package:dwds/src/debugging/remote_debugger.dart' ;
17
+ import 'package:dwds/src/loaders/ddc_library_bundle.dart' ;
17
18
import 'package:dwds/src/readers/asset_reader.dart' ;
18
19
import 'package:dwds/src/utilities/conversions.dart' ;
19
20
import 'package:dwds/src/utilities/dart_uri.dart' ;
@@ -301,11 +302,17 @@ class AppInspector implements AppInspectorInterface {
301
302
String selector,
302
303
List <RemoteObject > arguments,
303
304
) {
304
- return _evaluateInLibrary (
305
- library,
306
- 'function () { return this.$selector .apply(this, arguments);}' ,
307
- arguments,
308
- );
305
+ return globalToolConfiguration.loadStrategy is DdcLibraryBundleStrategy
306
+ ? _evaluateLibraryMethodWithDdcLibraryBundle (
307
+ library,
308
+ selector,
309
+ arguments,
310
+ )
311
+ : _evaluateInLibrary (
312
+ library,
313
+ 'function () { return this.$selector .apply(this, arguments); }' ,
314
+ arguments,
315
+ );
309
316
}
310
317
311
318
/// Evaluate [expression] by calling Chrome's Runtime.evaluate.
@@ -340,19 +347,31 @@ class AppInspector implements AppInspectorInterface {
340
347
if (libraryUri == null ) {
341
348
throwInvalidParam ('invoke' , 'library uri is null' );
342
349
}
343
- final findLibrary = '''
344
- (function() {
345
- const sdk = ${globalToolConfiguration .loadStrategy .loadModuleSnippet }('dart_sdk');
346
- const dart = sdk.dart;
347
- const library = dart.getLibrary('$libraryUri ');
348
- if (!library) throw 'cannot find library for $libraryUri ';
349
- return library;
350
- })();
351
- ''' ;
352
- final remoteLibrary = await jsEvaluate (findLibrary);
350
+ final findLibraryJsExpression = globalToolConfiguration
351
+ .loadStrategy.dartRuntimeDebugger
352
+ .callLibraryMethodJsExpression (libraryUri, jsFunction);
353
+
354
+ final remoteLibrary = await jsEvaluate (findLibraryJsExpression);
353
355
return jsCallFunctionOn (remoteLibrary, jsFunction, arguments);
354
356
}
355
357
358
+ /// Evaluates the specified top-level method [methodName] within [library]
359
+ /// using the Dart Development Compiler (DDC) library bundle strategy with
360
+ /// the given [arguments] .
361
+ Future <RemoteObject > _evaluateLibraryMethodWithDdcLibraryBundle (
362
+ Library library,
363
+ String methodName,
364
+ List <RemoteObject > arguments,
365
+ ) {
366
+ final libraryUri = library.uri;
367
+ if (libraryUri == null ) {
368
+ throwInvalidParam ('invoke' , 'library uri is null' );
369
+ }
370
+ final expression = globalToolConfiguration.loadStrategy.dartRuntimeDebugger
371
+ .callLibraryMethodJsExpression (libraryUri, methodName);
372
+ return _jsCallFunction (expression, arguments);
373
+ }
374
+
356
375
/// Call [function] with objects referred by [argumentIds] as arguments.
357
376
@override
358
377
Future <RemoteObject > callFunction (
0 commit comments