@@ -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' ;
@@ -212,7 +213,10 @@ class AppInspector implements AppInspectorInterface {
212
213
// We use the JS pseudo-variable 'arguments' to get the list of all arguments.
213
214
final send = globalToolConfiguration.loadStrategy.dartRuntimeDebugger
214
215
.callInstanceMethodJsExpression (methodName);
216
+ print (
217
+ '***YJ_TEST: _invokeMethod: receiver: $receiver , methodName: $methodName , positionalArgs: $positionalArgs , send: $send ' );
215
218
final remote = await jsCallFunctionOn (receiver, send, positionalArgs);
219
+ print ('***YJ_TEST: _invokeMethod: remote: $remote ' );
216
220
return remote;
217
221
}
218
222
@@ -251,6 +255,8 @@ class AppInspector implements AppInspectorInterface {
251
255
List <Object > arguments, {
252
256
bool returnByValue = false ,
253
257
}) async {
258
+ print (
259
+ '**YJ_TEST: _jsCallFunction: evalExpression: $evalExpression , arguments: $arguments ' );
254
260
final jsArguments = arguments.map (callArgumentFor).toList ();
255
261
final response = await remoteDebugger.sendCommand (
256
262
'Runtime.callFunctionOn' ,
@@ -279,6 +285,8 @@ class AppInspector implements AppInspectorInterface {
279
285
String selector,
280
286
List <dynamic > arguments,
281
287
) async {
288
+ print (
289
+ 'YJ_TEST: invoke: targetId: $targetId , selector: $selector , arguments: $arguments ' );
282
290
final remoteArguments =
283
291
arguments.cast <String >().map (remoteObjectFor).toList ();
284
292
// We special case the Dart library, where invokeMethod won't work because
@@ -300,12 +308,16 @@ class AppInspector implements AppInspectorInterface {
300
308
Library library,
301
309
String selector,
302
310
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 (
305
316
library,
306
317
'function () { return this.$selector .apply(this, arguments);}' ,
307
318
arguments,
308
319
);
320
+ return result;
309
321
}
310
322
311
323
/// Evaluate [expression] by calling Chrome's Runtime.evaluate.
@@ -340,27 +352,43 @@ class AppInspector implements AppInspectorInterface {
340
352
if (libraryUri == null ) {
341
353
throwInvalidParam ('invoke' , 'library uri is null' );
342
354
}
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
+ }
354
377
}
355
378
356
379
/// Call [function] with objects referred by [argumentIds] as arguments.
357
380
@override
358
381
Future <RemoteObject > callFunction (
359
382
String function,
360
383
Iterable <String > argumentIds,
361
- ) {
384
+ ) async {
385
+ print (
386
+ 'YJ_TEST-1: callFunction - function: $function , argumentIDs: $argumentIds ' ,
387
+ );
362
388
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;
364
392
}
365
393
366
394
@override
0 commit comments