@@ -302,14 +302,18 @@ class AppInspector implements AppInspectorInterface {
302
302
String selector,
303
303
List <RemoteObject > arguments,
304
304
) {
305
+ final libraryUri = library.uri;
306
+ if (libraryUri == null ) {
307
+ throwInvalidParam ('invoke' , 'library uri is null' );
308
+ }
305
309
return globalToolConfiguration.loadStrategy is DdcLibraryBundleStrategy
306
310
? _evaluateLibraryMethodWithDdcLibraryBundle (
307
- library ,
311
+ libraryUri ,
308
312
selector,
309
313
arguments,
310
314
)
311
315
: _evaluateInLibrary (
312
- library ,
316
+ libraryUri ,
313
317
'function () { return this.$selector .apply(this, arguments); }' ,
314
318
arguments,
315
319
);
@@ -337,16 +341,12 @@ class AppInspector implements AppInspectorInterface {
337
341
}
338
342
339
343
/// Evaluate the JS function with source [jsFunction] in the context of
340
- /// [ library] with [arguments] .
344
+ /// the library identified by [libraryUri ] with [arguments] .
341
345
Future <RemoteObject > _evaluateInLibrary (
342
- Library library ,
346
+ String libraryUri ,
343
347
String jsFunction,
344
348
List <RemoteObject > arguments,
345
349
) async {
346
- final libraryUri = library.uri;
347
- if (libraryUri == null ) {
348
- throwInvalidParam ('invoke' , 'library uri is null' );
349
- }
350
350
final findLibraryJsExpression = globalToolConfiguration
351
351
.loadStrategy.dartRuntimeDebugger
352
352
.callLibraryMethodJsExpression (libraryUri, jsFunction);
@@ -355,23 +355,63 @@ class AppInspector implements AppInspectorInterface {
355
355
return jsCallFunctionOn (remoteLibrary, jsFunction, arguments);
356
356
}
357
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] .
358
+ /// Evaluates the specified top-level method [methodName] within the library
359
+ /// identified by [libraryUri] using the Dart Development Compiler (DDC)
360
+ /// library bundle strategy with the given [arguments] .
361
361
Future <RemoteObject > _evaluateLibraryMethodWithDdcLibraryBundle (
362
- Library library ,
362
+ String libraryUri ,
363
363
String methodName,
364
364
List <RemoteObject > arguments,
365
365
) {
366
- final libraryUri = library.uri;
367
- if (libraryUri == null ) {
368
- throwInvalidParam ('invoke' , 'library uri is null' );
369
- }
370
366
final expression = globalToolConfiguration.loadStrategy.dartRuntimeDebugger
371
367
.callLibraryMethodJsExpression (libraryUri, methodName);
372
368
return _jsCallFunction (expression, arguments);
373
369
}
374
370
371
+ /// Evaluates the specified top-level variable [variableName] within the
372
+ /// library identified by [libraryName] and [libraryUri] using the
373
+ /// RequireStrategy.
374
+ Future <RemoteObject > _evaluateLibraryVariable (
375
+ String libraryUri,
376
+ String libraryName,
377
+ String variableName,
378
+ ) {
379
+ return jsEvaluate (
380
+ globalToolConfiguration.loadStrategy.dartRuntimeDebugger
381
+ .getLibraryVariableJsExpression (
382
+ libraryName,
383
+ libraryUri,
384
+ variableName,
385
+ ),
386
+ );
387
+ }
388
+
389
+ /// Retrieves a reference to a library variable or method by evaluating
390
+ /// the specified [variableName] or invoking the provided [methodName] .
391
+ /// The evaluation method is determined based on the current load strategy.
392
+ ///
393
+ /// If the load strategy uses `DdcLibraryBundleStrategy` , it evaluates the
394
+ /// method with the given [libraryUri] and [methodName] . Otherwise, it
395
+ /// evaluates the variable using [libraryUri] , [libraryName] , and [variableName] .
396
+ Future <RemoteObject > getLibraryReference (
397
+ String libraryUri,
398
+ String libraryName,
399
+ String variableName,
400
+ String methodName,
401
+ ) {
402
+ return globalToolConfiguration.loadStrategy is DdcLibraryBundleStrategy
403
+ ? _evaluateLibraryMethodWithDdcLibraryBundle (
404
+ libraryUri,
405
+ methodName,
406
+ [],
407
+ )
408
+ : _evaluateLibraryVariable (
409
+ libraryUri,
410
+ libraryName,
411
+ variableName,
412
+ );
413
+ }
414
+
375
415
/// Call [function] with objects referred by [argumentIds] as arguments.
376
416
@override
377
417
Future <RemoteObject > callFunction (
0 commit comments