@@ -14,6 +14,7 @@ import 'package:dwds/src/debugging/instance.dart';
1414import 'package:dwds/src/debugging/libraries.dart' ;
1515import 'package:dwds/src/debugging/location.dart' ;
1616import 'package:dwds/src/debugging/remote_debugger.dart' ;
17+ import 'package:dwds/src/loaders/ddc_library_bundle.dart' ;
1718import 'package:dwds/src/readers/asset_reader.dart' ;
1819import 'package:dwds/src/utilities/conversions.dart' ;
1920import 'package:dwds/src/utilities/dart_uri.dart' ;
@@ -212,7 +213,10 @@ class AppInspector implements AppInspectorInterface {
212213 // We use the JS pseudo-variable 'arguments' to get the list of all arguments.
213214 final send = globalToolConfiguration.loadStrategy.dartRuntimeDebugger
214215 .callInstanceMethodJsExpression (methodName);
216+ print (
217+ '***YJ_TEST: _invokeMethod: receiver: $receiver , methodName: $methodName , positionalArgs: $positionalArgs , send: $send ' );
215218 final remote = await jsCallFunctionOn (receiver, send, positionalArgs);
219+ print ('***YJ_TEST: _invokeMethod: remote: $remote ' );
216220 return remote;
217221 }
218222
@@ -251,6 +255,8 @@ class AppInspector implements AppInspectorInterface {
251255 List <Object > arguments, {
252256 bool returnByValue = false ,
253257 }) async {
258+ print (
259+ '**YJ_TEST: _jsCallFunction: evalExpression: $evalExpression , arguments: $arguments ' );
254260 final jsArguments = arguments.map (callArgumentFor).toList ();
255261 final response = await remoteDebugger.sendCommand (
256262 'Runtime.callFunctionOn' ,
@@ -279,6 +285,8 @@ class AppInspector implements AppInspectorInterface {
279285 String selector,
280286 List <dynamic > arguments,
281287 ) async {
288+ print (
289+ 'YJ_TEST: invoke: targetId: $targetId , selector: $selector , arguments: $arguments ' );
282290 final remoteArguments =
283291 arguments.cast <String >().map (remoteObjectFor).toList ();
284292 // We special case the Dart library, where invokeMethod won't work because
@@ -300,12 +308,16 @@ class AppInspector implements AppInspectorInterface {
300308 Library library,
301309 String selector,
302310 List <RemoteObject > arguments,
303- ) {
304- return _evaluateInLibrary (
311+ ) async {
312+ print (
313+ 'YJ_TEST: _invokeLibraryFunction: library: ${library .uri }, selector: $selector , arguments: $arguments ' ,
314+ );
315+ final result = await _evaluateInLibrary (
305316 library,
306317 'function () { return this.$selector .apply(this, arguments);}' ,
307318 arguments,
308319 );
320+ return result;
309321 }
310322
311323 /// Evaluate [expression] by calling Chrome's Runtime.evaluate.
@@ -340,27 +352,43 @@ class AppInspector implements AppInspectorInterface {
340352 if (libraryUri == null ) {
341353 throwInvalidParam ('invoke' , 'library uri is null' );
342354 }
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);
353- return jsCallFunctionOn (remoteLibrary, jsFunction, arguments);
355+ final expression = globalToolConfiguration.loadStrategy.dartRuntimeDebugger
356+ .callLibraryMethodJsExpression (libraryUri, jsFunction);
357+
358+ print ('YJ_TEST: Evaluating in library: $expression ' );
359+ if (globalToolConfiguration.loadStrategy is DdcLibraryBundleStrategy ) {
360+ print ('YJ_TEST-A-1: DdcLibraryBundleStrategy' );
361+ final result = await _jsCallFunction (jsFunction, arguments);
362+ print (
363+ 'YJ_TEST-A-2: result: $result ' ,
364+ );
365+ return result;
366+ } else {
367+ print ('YJ_TEST-B-1: ${globalToolConfiguration .loadStrategy }' );
368+ final remoteLibrary = await jsEvaluate (expression);
369+ print (
370+ 'YJ_TEST-B-2: remoteLibrary: ${remoteLibrary .objectId }, jsFunction: $jsFunction , arguments: $arguments ' ,
371+ );
372+ final result =
373+ await jsCallFunctionOn (remoteLibrary, jsFunction, arguments);
374+ print ('YJ_TEST-B-3: result: ${result .objectId }' );
375+ return result;
376+ }
354377 }
355378
356379 /// Call [function] with objects referred by [argumentIds] as arguments.
357380 @override
358381 Future <RemoteObject > callFunction (
359382 String function,
360383 Iterable <String > argumentIds,
361- ) {
384+ ) async {
385+ print (
386+ 'YJ_TEST-1: callFunction - function: $function , argumentIDs: $argumentIds ' ,
387+ );
362388 final arguments = argumentIds.map (remoteObjectFor).toList ();
363- return _jsCallFunction (function, arguments);
389+ print ('YJ_TEST-2: callFunction - arguments: $arguments ' );
390+ final result = await _jsCallFunction (function, arguments);
391+ return result;
364392 }
365393
366394 @override
0 commit comments