diff --git a/dwds/CHANGELOG.md b/dwds/CHANGELOG.md index 9f24df85c..0d00e8192 100644 --- a/dwds/CHANGELOG.md +++ b/dwds/CHANGELOG.md @@ -1,3 +1,7 @@ +## 24.3.6-dev + +- Bump minimum sdk version to 3.7.0 + ## 24.3.5 - Allow clients to specify the `packageConfigPath` in `LoadStrategy` class and associated providers. diff --git a/dwds/analysis_options.yaml b/dwds/analysis_options.yaml index 9427bb2e1..25d27d995 100644 --- a/dwds/analysis_options.yaml +++ b/dwds/analysis_options.yaml @@ -10,4 +10,3 @@ analyzer: linter: rules: - always_use_package_imports - - require_trailing_commas diff --git a/dwds/debug_extension/tool/build_extension.dart b/dwds/debug_extension/tool/build_extension.dart index a3cdbf2df..418c24567 100644 --- a/dwds/debug_extension/tool/build_extension.dart +++ b/dwds/debug_extension/tool/build_extension.dart @@ -20,27 +20,28 @@ import 'package:path/path.dart' as p; const _prodFlag = 'prod'; void main(List arguments) async { - final parser = ArgParser() - ..addFlag(_prodFlag, negatable: true, defaultsTo: false); + final parser = + ArgParser()..addFlag(_prodFlag, negatable: true, defaultsTo: false); final argResults = parser.parse(arguments); - exitCode = await run( - isProd: argResults[_prodFlag] as bool, - ); + exitCode = await run(isProd: argResults[_prodFlag] as bool); if (exitCode != 0) { _logWarning('Run terminated unexpectedly with exit code: $exitCode'); } } Future run({required bool isProd}) async { - _logInfo( - 'Building extension for ${isProd ? 'prod' : 'dev'}', - ); + _logInfo('Building extension for ${isProd ? 'prod' : 'dev'}'); _logInfo('Compiling extension with dart2js to /compiled directory'); - final compileStep = await Process.start( - 'dart', - ['run', 'build_runner', 'build', 'web', '--output', 'build', '--release'], - ); + final compileStep = await Process.start('dart', [ + 'run', + 'build_runner', + 'build', + 'web', + '--output', + 'build', + '--release', + ]); final compileExitCode = await _handleProcess(compileStep); // Terminate early if compilation failed: if (compileExitCode != 0) { @@ -48,9 +49,9 @@ Future run({required bool isProd}) async { } _logInfo('Copying manifest.json to /compiled directory'); try { - File(p.join('web', 'manifest.json')).copySync( - p.join('compiled', 'manifest.json'), - ); + File( + p.join('web', 'manifest.json'), + ).copySync(p.join('compiled', 'manifest.json')); } catch (error) { _logWarning('Copying manifest file failed: $error'); // Return non-zero exit code to indicate failure: @@ -60,10 +61,9 @@ Future run({required bool isProd}) async { if (isProd) return 0; // Update manifest.json for dev: _logInfo('Updating manifest.json in /compiled directory.'); - final updateStep = await Process.start( - 'dart', - [p.join('tool', 'update_dev_files.dart')], - ); + final updateStep = await Process.start('dart', [ + p.join('tool', 'update_dev_files.dart'), + ]); final updateExitCode = await _handleProcess(updateStep); // Return exit code (0 indicates success): return updateExitCode; diff --git a/dwds/debug_extension/tool/copy_builder.dart b/dwds/debug_extension/tool/copy_builder.dart index 112898818..648f6e565 100644 --- a/dwds/debug_extension/tool/copy_builder.dart +++ b/dwds/debug_extension/tool/copy_builder.dart @@ -10,12 +10,12 @@ Builder copyBuilder(_) => _CopyBuilder(); class _CopyBuilder extends Builder { @override Map> get buildExtensions => { - 'web/{{}}.dart.js': ['compiled/{{}}.dart.js'], - 'web/static_assets/{{}}.png': ['compiled/static_assets/{{}}.png'], - 'web/static_assets/{{}}.html': ['compiled/static_assets/{{}}.html'], - 'web/static_assets/{{}}.css': ['compiled/static_assets/{{}}.css'], - 'web/manifest.json': ['compiled/manifest.json'], - }; + 'web/{{}}.dart.js': ['compiled/{{}}.dart.js'], + 'web/static_assets/{{}}.png': ['compiled/static_assets/{{}}.png'], + 'web/static_assets/{{}}.html': ['compiled/static_assets/{{}}.html'], + 'web/static_assets/{{}}.css': ['compiled/static_assets/{{}}.css'], + 'web/manifest.json': ['compiled/manifest.json'], + }; @override Future build(BuildStep buildStep) async { diff --git a/dwds/debug_extension/tool/update_dev_files.dart b/dwds/debug_extension/tool/update_dev_files.dart index cc1bc1756..24c4bdfad 100644 --- a/dwds/debug_extension/tool/update_dev_files.dart +++ b/dwds/debug_extension/tool/update_dev_files.dart @@ -12,9 +12,10 @@ void main() async { Future _updateManifestJson() async { final manifestJson = File('compiled/manifest.json'); final extensionKeyTxt = File('extension_key.txt'); - final extensionKey = await extensionKeyTxt.exists() - ? await extensionKeyTxt.readAsString() - : null; + final extensionKey = + await extensionKeyTxt.exists() + ? await extensionKeyTxt.readAsString() + : null; return _transformDevFile(manifestJson, (line) { if (_matchesKey(line: line, key: 'name')) { return [ @@ -24,11 +25,7 @@ Future _updateManifestJson() async { newValue: '[DEV] Dart Debug Extension', ), if (extensionKey != null) - _newKeyValue( - oldLine: line, - newKey: 'key', - newValue: extensionKey, - ), + _newKeyValue(oldLine: line, newKey: 'key', newValue: extensionKey), ]; } else if (_matchesKey(line: line, key: 'default_icon')) { return [ diff --git a/dwds/debug_extension/web/background.dart b/dwds/debug_extension/web/background.dart index fe421352c..e112b16be 100644 --- a/dwds/debug_extension/web/background.dart +++ b/dwds/debug_extension/web/background.dart @@ -6,6 +6,8 @@ library; import 'package:dwds/data/debug_info.dart'; +// TODO: https://github.com/dart-lang/webdev/issues/2508 +// ignore: deprecated_member_use import 'package:js/js.dart'; import 'chrome_api.dart'; @@ -23,9 +25,7 @@ void main() { } void _registerListeners() { - chrome.runtime.onMessage.addListener( - allowInterop(_handleRuntimeMessages), - ); + chrome.runtime.onMessage.addListener(allowInterop(_handleRuntimeMessages)); // The only extension allowed to send messages to this extension is the // AngularDart DevTools extension. Its permission is set in the manifest.json // externally_connectable field. @@ -34,8 +34,9 @@ void _registerListeners() { ); // The only external service that sends messages to the Dart Debug Extension // is Cider. - chrome.runtime.onConnectExternal - .addListener(allowInterop(handleCiderConnectRequest)); + chrome.runtime.onConnectExternal.addListener( + allowInterop(handleCiderConnectRequest), + ); // Update the extension icon on tab navigation: chrome.tabs.onActivated.addListener( allowInterop((ActiveInfo info) async { @@ -50,11 +51,13 @@ void _registerListeners() { } }), ); - chrome.webNavigation.onCommitted - .addListener(allowInterop(_detectNavigationAwayFromDartApp)); + chrome.webNavigation.onCommitted.addListener( + allowInterop(_detectNavigationAwayFromDartApp), + ); - chrome.commands.onCommand - .addListener(allowInterop(_maybeSendCopyAppIdRequest)); + chrome.commands.onCommand.addListener( + allowInterop(_maybeSendCopyAppIdRequest), + ); } Future _handleRuntimeMessages( @@ -214,19 +217,20 @@ bool _isInternalNavigation(NavigationInfo navigationInfo) { DebugInfo _addTabInfo(DebugInfo debugInfo, {required Tab tab}) { return DebugInfo( - (b) => b - ..appEntrypointPath = debugInfo.appEntrypointPath - ..appId = debugInfo.appId - ..appInstanceId = debugInfo.appInstanceId - ..appOrigin = debugInfo.appOrigin - ..appUrl = debugInfo.appUrl - ..authUrl = debugInfo.authUrl - ..extensionUrl = debugInfo.extensionUrl - ..isInternalBuild = debugInfo.isInternalBuild - ..isFlutterApp = debugInfo.isFlutterApp - ..workspaceName = debugInfo.workspaceName - ..tabUrl = tab.url - ..tabId = tab.id, + (b) => + b + ..appEntrypointPath = debugInfo.appEntrypointPath + ..appId = debugInfo.appId + ..appInstanceId = debugInfo.appInstanceId + ..appOrigin = debugInfo.appOrigin + ..appUrl = debugInfo.appUrl + ..authUrl = debugInfo.authUrl + ..extensionUrl = debugInfo.extensionUrl + ..isInternalBuild = debugInfo.isInternalBuild + ..isFlutterApp = debugInfo.isFlutterApp + ..workspaceName = debugInfo.workspaceName + ..tabUrl = tab.url + ..tabId = tab.id, ); } @@ -279,9 +283,7 @@ void _setDefaultIcon(int tabId) { final iconPath = isDevMode ? 'static_assets/dart_dev.png' : 'static_assets/dart_grey.png'; setExtensionIcon(IconInfo(path: iconPath)); - setExtensionPopup( - PopupDetails(popup: '', tabId: tabId), - ); + setExtensionPopup(PopupDetails(popup: '', tabId: tabId)); } Future _fetchDebugInfo(int tabId) { diff --git a/dwds/debug_extension/web/chrome_api.dart b/dwds/debug_extension/web/chrome_api.dart index 3e004446f..f69faea26 100644 --- a/dwds/debug_extension/web/chrome_api.dart +++ b/dwds/debug_extension/web/chrome_api.dart @@ -6,6 +6,8 @@ // ignore: deprecated_member_use import 'dart:html'; +// TODO: https://github.com/dart-lang/webdev/issues/2508 +// ignore: deprecated_member_use import 'package:js/js.dart'; @JS() @@ -158,9 +160,7 @@ class Notifications { @JS() @anonymous class OnClickedHandler { - external void addListener( - void Function(String) callback, - ); + external void addListener(void Function(String) callback); } @JS() @@ -233,9 +233,7 @@ class Port { @JS() @anonymous class OnPortMessageHandler { - external void addListener( - void Function(dynamic, Port) callback, - ); + external void addListener(void Function(dynamic, Port) callback); } @JS() diff --git a/dwds/debug_extension/web/cider_connection.dart b/dwds/debug_extension/web/cider_connection.dart index 6c90eb9e2..88a46adaf 100644 --- a/dwds/debug_extension/web/cider_connection.dart +++ b/dwds/debug_extension/web/cider_connection.dart @@ -10,6 +10,8 @@ import 'dart:convert'; // ignore: deprecated_member_use import 'dart:js_util'; +// TODO: https://github.com/dart-lang/webdev/issues/2508 +// ignore: deprecated_member_use import 'package:js/js.dart'; import 'chrome_api.dart'; @@ -44,11 +46,7 @@ enum CiderMessageType { /// /// The types must match those defined by ChromeExtensionErrorType in the /// Cider extension. -enum CiderErrorType { - internalError, - invalidRequest, - noAppId, -} +enum CiderErrorType { internalError, invalidRequest, noAppId } const _ciderPortName = 'cider'; Port? _ciderPort; @@ -62,9 +60,7 @@ void handleCiderConnectRequest(Port port) { debugLog('Received connect request from Cider', verbose: true); _ciderPort = port; - port.onMessage.addListener( - allowInterop(_handleMessageFromCider), - ); + port.onMessage.addListener(allowInterop(_handleMessageFromCider)); sendMessageToCider(messageType: CiderMessageType.connected); } @@ -99,10 +95,7 @@ void sendErrorMessageToCider({ } void _sendMessageToCider(String json) { - final message = { - 'key': _ciderDartMessageKey, - 'json': json, - }; + final message = {'key': _ciderDartMessageKey, 'json': json}; _ciderPort!.postMessage(jsify(message)); } @@ -177,7 +170,8 @@ Future _sendInspectorUrl({String? appId}) async { if (!alreadyDebugging) { sendErrorMessageToCider( errorType: CiderErrorType.invalidRequest, - errorDetails: 'Cannot send the inspector URL before ' + errorDetails: + 'Cannot send the inspector URL before ' 'the debugger has been attached.', ); return; @@ -195,10 +189,7 @@ Future _sendInspectorUrl({String? appId}) async { } final inspectorUrl = addQueryParameters( devToolsUri, - queryParameters: { - 'embed': 'true', - 'page': 'inspector', - }, + queryParameters: {'embed': 'true', 'page': 'inspector'}, ); sendMessageToCider( messageType: CiderMessageType.inspectorUrlResponse, diff --git a/dwds/debug_extension/web/copier.dart b/dwds/debug_extension/web/copier.dart index 0134cb21c..961a11e2b 100644 --- a/dwds/debug_extension/web/copier.dart +++ b/dwds/debug_extension/web/copier.dart @@ -9,6 +9,8 @@ library; // ignore: deprecated_member_use import 'dart:html'; +// TODO: https://github.com/dart-lang/webdev/issues/2508 +// ignore: deprecated_member_use import 'package:js/js.dart'; import 'chrome_api.dart'; @@ -19,9 +21,7 @@ void main() { } void _registerListeners() { - chrome.runtime.onMessage.addListener( - allowInterop(_handleRuntimeMessages), - ); + chrome.runtime.onMessage.addListener(allowInterop(_handleRuntimeMessages)); } void _handleRuntimeMessages( @@ -49,8 +49,8 @@ void _copyAppId(String appId) { } Future _notifyCopiedSuccess(String appId) => sendRuntimeMessage( - type: MessageType.appId, - body: appId, - sender: Script.copier, - recipient: Script.background, - ); + type: MessageType.appId, + body: appId, + sender: Script.copier, + recipient: Script.background, +); diff --git a/dwds/debug_extension/web/cross_extension_communication.dart b/dwds/debug_extension/web/cross_extension_communication.dart index 0f01de827..da8677917 100644 --- a/dwds/debug_extension/web/cross_extension_communication.dart +++ b/dwds/debug_extension/web/cross_extension_communication.dart @@ -5,6 +5,8 @@ @JS() library; +// TODO: https://github.com/dart-lang/webdev/issues/2508 +// ignore: deprecated_member_use import 'package:js/js.dart'; import 'chrome_api.dart'; @@ -56,9 +58,10 @@ void maybeForwardMessageToAngularDartDevTools({ }) { if (!_eventsForAngularDartDevTools.contains(method)) return; - final message = method.startsWith('dwds') - ? _dwdsEventMessage(method: method, params: params, tabId: tabId) - : _debugEventMessage(method: method, params: params, tabId: tabId); + final message = + method.startsWith('dwds') + ? _dwdsEventMessage(method: method, params: params, tabId: tabId) + : _debugEventMessage(method: method, params: params, tabId: tabId); _forwardMessageToAngularDartDevTools(message); } @@ -87,9 +90,7 @@ void _respondWithChromeResult(Object? chromeResult, Function sendResponse) { if (chromeResult == null) { sendResponse( ErrorResponse() - ..error = JSON.stringify( - chrome.runtime.lastError ?? 'Unknown error.', - ), + ..error = JSON.stringify(chrome.runtime.lastError ?? 'Unknown error.'), ); } else { sendResponse(chromeResult); @@ -126,23 +127,17 @@ ExternalExtensionMessage _debugEventMessage({ required String method, required dynamic params, required int tabId, -}) => - ExternalExtensionMessage( - name: 'chrome.debugger.event', - tabId: tabId, - options: DebugEvent(method: method, params: params), - ); +}) => ExternalExtensionMessage( + name: 'chrome.debugger.event', + tabId: tabId, + options: DebugEvent(method: method, params: params), +); ExternalExtensionMessage _dwdsEventMessage({ required String method, required dynamic params, required int tabId, -}) => - ExternalExtensionMessage( - name: method, - tabId: tabId, - options: params, - ); +}) => ExternalExtensionMessage(name: method, tabId: tabId, options: params); // This message is used for cross-extension communication between this extension // and the AngularDart DevTools extension. diff --git a/dwds/debug_extension/web/data_serializers.g.dart b/dwds/debug_extension/web/data_serializers.g.dart index 5040b84d6..dd746a8d5 100644 --- a/dwds/debug_extension/web/data_serializers.g.dart +++ b/dwds/debug_extension/web/data_serializers.g.dart @@ -6,20 +6,22 @@ part of 'data_serializers.dart'; // BuiltValueGenerator // ************************************************************************** -Serializers _$serializers = (new Serializers().toBuilder() - ..add(BatchedEvents.serializer) - ..add(ConnectFailure.serializer) - ..add(DebugInfo.serializer) - ..add(DebugStateChange.serializer) - ..add(DevToolsOpener.serializer) - ..add(DevToolsRequest.serializer) - ..add(DevToolsUrl.serializer) - ..add(ExtensionEvent.serializer) - ..add(ExtensionRequest.serializer) - ..add(ExtensionResponse.serializer) - ..addBuilderFactory( - const FullType(BuiltList, const [const FullType(ExtensionEvent)]), - () => new ListBuilder())) - .build(); +Serializers _$serializers = + (new Serializers().toBuilder() + ..add(BatchedEvents.serializer) + ..add(ConnectFailure.serializer) + ..add(DebugInfo.serializer) + ..add(DebugStateChange.serializer) + ..add(DevToolsOpener.serializer) + ..add(DevToolsRequest.serializer) + ..add(DevToolsUrl.serializer) + ..add(ExtensionEvent.serializer) + ..add(ExtensionRequest.serializer) + ..add(ExtensionResponse.serializer) + ..addBuilderFactory( + const FullType(BuiltList, const [const FullType(ExtensionEvent)]), + () => new ListBuilder(), + )) + .build(); // ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/dwds/debug_extension/web/data_types.g.dart b/dwds/debug_extension/web/data_types.g.dart index dbc60df08..831d48344 100644 --- a/dwds/debug_extension/web/data_types.g.dart +++ b/dwds/debug_extension/web/data_types.g.dart @@ -22,8 +22,11 @@ class _$ConnectFailureSerializer final String wireName = 'ConnectFailure'; @override - Iterable serialize(Serializers serializers, ConnectFailure object, - {FullType specifiedType = FullType.unspecified}) { + Iterable serialize( + Serializers serializers, + ConnectFailure object, { + FullType specifiedType = FullType.unspecified, + }) { final result = [ 'tabId', serializers.serialize(object.tabId, specifiedType: const FullType(int)), @@ -33,16 +36,19 @@ class _$ConnectFailureSerializer if (value != null) { result ..add('reason') - ..add(serializers.serialize(value, - specifiedType: const FullType(String))); + ..add( + serializers.serialize(value, specifiedType: const FullType(String)), + ); } return result; } @override ConnectFailure deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { final result = new ConnectFailureBuilder(); final iterator = serialized.iterator; @@ -52,12 +58,20 @@ class _$ConnectFailureSerializer final Object? value = iterator.current; switch (key) { case 'tabId': - result.tabId = serializers.deserialize(value, - specifiedType: const FullType(int))! as int; + result.tabId = + serializers.deserialize( + value, + specifiedType: const FullType(int), + )! + as int; break; case 'reason': - result.reason = serializers.deserialize(value, - specifiedType: const FullType(String)) as String?; + result.reason = + serializers.deserialize( + value, + specifiedType: const FullType(String), + ) + as String?; break; } } @@ -74,12 +88,17 @@ class _$DevToolsOpenerSerializer final String wireName = 'DevToolsOpener'; @override - Iterable serialize(Serializers serializers, DevToolsOpener object, - {FullType specifiedType = FullType.unspecified}) { + Iterable serialize( + Serializers serializers, + DevToolsOpener object, { + FullType specifiedType = FullType.unspecified, + }) { final result = [ 'newWindow', - serializers.serialize(object.newWindow, - specifiedType: const FullType(bool)), + serializers.serialize( + object.newWindow, + specifiedType: const FullType(bool), + ), ]; return result; @@ -87,8 +106,10 @@ class _$DevToolsOpenerSerializer @override DevToolsOpener deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { final result = new DevToolsOpenerBuilder(); final iterator = serialized.iterator; @@ -98,8 +119,12 @@ class _$DevToolsOpenerSerializer final Object? value = iterator.current; switch (key) { case 'newWindow': - result.newWindow = serializers.deserialize(value, - specifiedType: const FullType(bool))! as bool; + result.newWindow = + serializers.deserialize( + value, + specifiedType: const FullType(bool), + )! + as bool; break; } } @@ -115,8 +140,11 @@ class _$DevToolsUrlSerializer implements StructuredSerializer { final String wireName = 'DevToolsUrl'; @override - Iterable serialize(Serializers serializers, DevToolsUrl object, - {FullType specifiedType = FullType.unspecified}) { + Iterable serialize( + Serializers serializers, + DevToolsUrl object, { + FullType specifiedType = FullType.unspecified, + }) { final result = [ 'tabId', serializers.serialize(object.tabId, specifiedType: const FullType(int)), @@ -128,8 +156,11 @@ class _$DevToolsUrlSerializer implements StructuredSerializer { } @override - DevToolsUrl deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { + DevToolsUrl deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { final result = new DevToolsUrlBuilder(); final iterator = serialized.iterator; @@ -139,12 +170,20 @@ class _$DevToolsUrlSerializer implements StructuredSerializer { final Object? value = iterator.current; switch (key) { case 'tabId': - result.tabId = serializers.deserialize(value, - specifiedType: const FullType(int))! as int; + result.tabId = + serializers.deserialize( + value, + specifiedType: const FullType(int), + )! + as int; break; case 'url': - result.url = serializers.deserialize(value, - specifiedType: const FullType(String))! as String; + result.url = + serializers.deserialize( + value, + specifiedType: const FullType(String), + )! + as String; break; } } @@ -161,30 +200,38 @@ class _$DebugStateChangeSerializer final String wireName = 'DebugStateChange'; @override - Iterable serialize(Serializers serializers, DebugStateChange object, - {FullType specifiedType = FullType.unspecified}) { + Iterable serialize( + Serializers serializers, + DebugStateChange object, { + FullType specifiedType = FullType.unspecified, + }) { final result = [ 'tabId', serializers.serialize(object.tabId, specifiedType: const FullType(int)), 'newState', - serializers.serialize(object.newState, - specifiedType: const FullType(String)), + serializers.serialize( + object.newState, + specifiedType: const FullType(String), + ), ]; Object? value; value = object.reason; if (value != null) { result ..add('reason') - ..add(serializers.serialize(value, - specifiedType: const FullType(String))); + ..add( + serializers.serialize(value, specifiedType: const FullType(String)), + ); } return result; } @override DebugStateChange deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { final result = new DebugStateChangeBuilder(); final iterator = serialized.iterator; @@ -194,16 +241,28 @@ class _$DebugStateChangeSerializer final Object? value = iterator.current; switch (key) { case 'tabId': - result.tabId = serializers.deserialize(value, - specifiedType: const FullType(int))! as int; + result.tabId = + serializers.deserialize( + value, + specifiedType: const FullType(int), + )! + as int; break; case 'newState': - result.newState = serializers.deserialize(value, - specifiedType: const FullType(String))! as String; + result.newState = + serializers.deserialize( + value, + specifiedType: const FullType(String), + )! + as String; break; case 'reason': - result.reason = serializers.deserialize(value, - specifiedType: const FullType(String)) as String?; + result.reason = + serializers.deserialize( + value, + specifiedType: const FullType(String), + ) + as String?; break; } } @@ -298,11 +357,16 @@ class ConnectFailureBuilder ConnectFailure build() => _build(); _$ConnectFailure _build() { - final _$result = _$v ?? + final _$result = + _$v ?? new _$ConnectFailure._( - tabId: BuiltValueNullFieldError.checkNotNull( - tabId, r'ConnectFailure', 'tabId'), - reason: reason); + tabId: BuiltValueNullFieldError.checkNotNull( + tabId, + r'ConnectFailure', + 'tabId', + ), + reason: reason, + ); replace(_$result); return _$result; } @@ -317,7 +381,10 @@ class _$DevToolsOpener extends DevToolsOpener { _$DevToolsOpener._({required this.newWindow}) : super._() { BuiltValueNullFieldError.checkNotNull( - newWindow, r'DevToolsOpener', 'newWindow'); + newWindow, + r'DevToolsOpener', + 'newWindow', + ); } @override @@ -345,8 +412,7 @@ class _$DevToolsOpener extends DevToolsOpener { @override String toString() { return (newBuiltValueToStringHelper(r'DevToolsOpener') - ..add('newWindow', newWindow)) - .toString(); + ..add('newWindow', newWindow)).toString(); } } @@ -384,10 +450,15 @@ class DevToolsOpenerBuilder DevToolsOpener build() => _build(); _$DevToolsOpener _build() { - final _$result = _$v ?? + final _$result = + _$v ?? new _$DevToolsOpener._( - newWindow: BuiltValueNullFieldError.checkNotNull( - newWindow, r'DevToolsOpener', 'newWindow')); + newWindow: BuiltValueNullFieldError.checkNotNull( + newWindow, + r'DevToolsOpener', + 'newWindow', + ), + ); replace(_$result); return _$result; } @@ -476,12 +547,20 @@ class DevToolsUrlBuilder implements Builder { DevToolsUrl build() => _build(); _$DevToolsUrl _build() { - final _$result = _$v ?? + final _$result = + _$v ?? new _$DevToolsUrl._( - tabId: BuiltValueNullFieldError.checkNotNull( - tabId, r'DevToolsUrl', 'tabId'), - url: BuiltValueNullFieldError.checkNotNull( - url, r'DevToolsUrl', 'url')); + tabId: BuiltValueNullFieldError.checkNotNull( + tabId, + r'DevToolsUrl', + 'tabId', + ), + url: BuiltValueNullFieldError.checkNotNull( + url, + r'DevToolsUrl', + 'url', + ), + ); replace(_$result); return _$result; } @@ -495,16 +574,21 @@ class _$DebugStateChange extends DebugStateChange { @override final String? reason; - factory _$DebugStateChange( - [void Function(DebugStateChangeBuilder)? updates]) => - (new DebugStateChangeBuilder()..update(updates))._build(); + factory _$DebugStateChange([ + void Function(DebugStateChangeBuilder)? updates, + ]) => (new DebugStateChangeBuilder()..update(updates))._build(); - _$DebugStateChange._( - {required this.tabId, required this.newState, this.reason}) - : super._() { + _$DebugStateChange._({ + required this.tabId, + required this.newState, + this.reason, + }) : super._() { BuiltValueNullFieldError.checkNotNull(tabId, r'DebugStateChange', 'tabId'); BuiltValueNullFieldError.checkNotNull( - newState, r'DebugStateChange', 'newState'); + newState, + r'DebugStateChange', + 'newState', + ); } @override @@ -588,13 +672,21 @@ class DebugStateChangeBuilder DebugStateChange build() => _build(); _$DebugStateChange _build() { - final _$result = _$v ?? + final _$result = + _$v ?? new _$DebugStateChange._( - tabId: BuiltValueNullFieldError.checkNotNull( - tabId, r'DebugStateChange', 'tabId'), - newState: BuiltValueNullFieldError.checkNotNull( - newState, r'DebugStateChange', 'newState'), - reason: reason); + tabId: BuiltValueNullFieldError.checkNotNull( + tabId, + r'DebugStateChange', + 'tabId', + ), + newState: BuiltValueNullFieldError.checkNotNull( + newState, + r'DebugStateChange', + 'newState', + ), + reason: reason, + ); replace(_$result); return _$result; } diff --git a/dwds/debug_extension/web/debug_info.dart b/dwds/debug_extension/web/debug_info.dart index f8e5943ff..611ac966a 100644 --- a/dwds/debug_extension/web/debug_info.dart +++ b/dwds/debug_extension/web/debug_info.dart @@ -15,6 +15,8 @@ import 'dart:js'; import 'package:dwds/data/debug_info.dart'; import 'package:dwds/data/serializers.dart'; +// TODO: https://github.com/dart-lang/webdev/issues/2508 +// ignore: deprecated_member_use import 'package:js/js.dart'; void main() { @@ -28,15 +30,17 @@ String _readDartDebugInfo() { return jsonEncode( serializers.serialize( DebugInfo( - (b) => b - ..appEntrypointPath = windowContext['\$dartEntrypointPath'] as String? - ..appId = windowContext['\$dartAppId'] as String? - ..appInstanceId = windowContext['\$dartAppInstanceId'] as String? - ..appOrigin = window.location.origin - ..appUrl = window.location.href - ..extensionUrl = windowContext['\$dartExtensionUri'] as String? - ..isInternalBuild = windowContext['\$isInternalBuild'] as bool? - ..isFlutterApp = windowContext['\$isFlutterApp'] as bool?, + (b) => + b + ..appEntrypointPath = + windowContext['\$dartEntrypointPath'] as String? + ..appId = windowContext['\$dartAppId'] as String? + ..appInstanceId = windowContext['\$dartAppInstanceId'] as String? + ..appOrigin = window.location.origin + ..appUrl = window.location.href + ..extensionUrl = windowContext['\$dartExtensionUri'] as String? + ..isInternalBuild = windowContext['\$isInternalBuild'] as bool? + ..isFlutterApp = windowContext['\$isFlutterApp'] as bool?, ), ), ); diff --git a/dwds/debug_extension/web/debug_session.dart b/dwds/debug_extension/web/debug_session.dart index 2f4f5ad2c..717d08019 100644 --- a/dwds/debug_extension/web/debug_session.dart +++ b/dwds/debug_extension/web/debug_session.dart @@ -15,7 +15,11 @@ import 'package:dwds/data/devtools_request.dart'; import 'package:dwds/data/extension_request.dart'; import 'package:dwds/shared/batched_stream.dart'; import 'package:dwds/src/sockets.dart'; +// TODO: https://github.com/dart-lang/webdev/issues/2508 +// ignore: deprecated_member_use import 'package:js/js.dart'; +// TODO: https://github.com/dart-lang/webdev/issues/2508 +// ignore: deprecated_member_use import 'package:js/js_util.dart' as js_util; import 'package:sse/client/sse_client.dart'; import 'package:web_socket_channel/web_socket_channel.dart'; @@ -31,7 +35,8 @@ import 'storage.dart'; import 'utils.dart'; import 'web_api.dart'; -const _notADartAppAlert = 'No Dart application detected.' +const _notADartAppAlert = + 'No Dart application detected.' ' Are you trying to debug an application that includes a Chrome hosted app' ' (an application listed in chrome://apps)? If so, debugging is disabled.' ' You can fix this by removing the application from chrome://apps. Please' @@ -68,10 +73,7 @@ enum ConnectFailureReason { } } -enum TabType { - dartApp, - devTools, -} +enum TabType { dartApp, devTools } enum Trigger { angularDartDevTools, @@ -80,11 +82,11 @@ enum Trigger { extensionIcon; String get clientName => switch (this) { - Trigger.angularDartDevTools => 'acx-devtools', - Trigger.cider => 'cider', - Trigger.extensionPanel => 'embedded-devtools', - Trigger.extensionIcon => 'devtools' - }; + Trigger.angularDartDevTools => 'acx-devtools', + Trigger.cider => 'cider', + Trigger.extensionPanel => 'embedded-devtools', + Trigger.extensionIcon => 'devtools', + }; } enum DebuggerLocation { @@ -94,11 +96,11 @@ enum DebuggerLocation { ide; String get displayName => switch (this) { - DebuggerLocation.angularDartDevTools => 'AngularDart DevTools', - DebuggerLocation.chromeDevTools => 'Chrome DevTools', - DebuggerLocation.dartDevTools => 'a Dart DevTools tab', - DebuggerLocation.ide => 'an IDE' - }; + DebuggerLocation.angularDartDevTools => 'AngularDart DevTools', + DebuggerLocation.chromeDevTools => 'Chrome DevTools', + DebuggerLocation.dartDevTools => 'a Dart DevTools tab', + DebuggerLocation.ide => 'an IDE', + }; } bool get existsActiveDebugSession => _debugSessions.isNotEmpty; @@ -122,9 +124,7 @@ Future attachDebugger( chrome.debugger.attach( Debuggee(tabId: dartAppTabId), '1.3', - allowInterop( - () => _enableExecutionContextReporting(dartAppTabId), - ), + allowInterop(() => _enableExecutionContextReporting(dartAppTabId)), ); } @@ -190,10 +190,7 @@ Future _validateTabIsDebuggable( tabId: dartAppTabId, ); if (debugInfo == null) { - await _showWarning( - 'Not a Dart app.', - forwardToCider: forwardErrorsToCider, - ); + await _showWarning('Not a Dart app.', forwardToCider: forwardErrorsToCider); return false; } // Determine if there are multiple apps in the tab: @@ -217,10 +214,7 @@ void _registerDebugEventListeners() { chrome.debugger.onEvent.addListener(allowInterop(_onDebuggerEvent)); chrome.debugger.onDetach.addListener( allowInterop((source, _) async { - await _handleDebuggerDetach( - source, - DetachReason.canceledByUser, - ); + await _handleDebuggerDetach(source, DetachReason.canceledByUser); }), ); chrome.tabs.onRemoved.addListener( @@ -319,7 +313,8 @@ Future _isDartFrame({required int tabId, required int contextId}) { Debuggee(tabId: tabId), 'Runtime.evaluate', _InjectedParams( - expression: '[window.\$dartAppId, ' + expression: + '[window.\$dartAppId, ' 'window.\$dartAppInstanceId, ' 'window.\$dwdsVersion]', returnByValue: true, @@ -356,9 +351,12 @@ Future _connectToDwds({ } final uri = Uri.parse(extensionUrl); // Start the client connection with DWDS: - final client = uri.isScheme('ws') || uri.isScheme('wss') - ? WebSocketClient(WebSocketChannel.connect(uri)) - : SseSocketClient(SseClient(uri.toString(), debugKey: 'DebugExtension')); + final client = + uri.isScheme('ws') || uri.isScheme('wss') + ? WebSocketClient(WebSocketChannel.connect(uri)) + : SseSocketClient( + SseClient(uri.toString(), debugKey: 'DebugExtension'), + ); final trigger = _tabIdToTrigger[dartAppTabId]; debugLog('Connecting to DWDS...', verbose: true); final debugSession = _DebugSession( @@ -388,13 +386,14 @@ Future _connectToDwds({ final tabUrl = await _getTabUrl(dartAppTabId); debugSession.sendEvent( DevToolsRequest( - (b) => b - ..appId = debugInfo.appId - ..instanceId = debugInfo.appInstanceId - ..contextId = dartAppContextId - ..tabUrl = tabUrl - ..uriOnly = true - ..client = trigger?.clientName ?? 'unknown', + (b) => + b + ..appId = debugInfo.appId + ..instanceId = debugInfo.appInstanceId + ..contextId = dartAppContextId + ..tabUrl = tabUrl + ..uriOnly = true + ..client = trigger?.clientName ?? 'unknown', ), ); return true; @@ -446,9 +445,10 @@ void _forwardDwdsEventToChromeDebugger( ) { try { final messageParams = message.commandParams; - final params = messageParams == null - ? {} - : BuiltMap(json.decode(messageParams)).toMap(); + final params = + messageParams == null + ? {} + : BuiltMap(json.decode(messageParams)).toMap(); chrome.debugger.sendCommand( Debuggee(tabId: tabId), @@ -461,10 +461,11 @@ void _forwardDwdsEventToChromeDebugger( jsonEncode( serializers.serialize( ExtensionResponse( - (b) => b - ..id = message.id - ..success = false - ..result = JSON.stringify(chrome.runtime.lastError), + (b) => + b + ..id = message.id + ..success = false + ..result = JSON.stringify(chrome.runtime.lastError), ), ), ), @@ -474,10 +475,11 @@ void _forwardDwdsEventToChromeDebugger( jsonEncode( serializers.serialize( ExtensionResponse( - (b) => b - ..id = message.id - ..success = true - ..result = JSON.stringify(e), + (b) => + b + ..id = message.id + ..success = true + ..result = JSON.stringify(e), ), ), ), @@ -498,8 +500,9 @@ void _forwardChromeDebuggerEventToDwds( String method, dynamic params, ) { - final debugSession = _debugSessions - .firstWhereOrNull((session) => session.appTabId == source.tabId); + final debugSession = _debugSessions.firstWhereOrNull( + (session) => session.appTabId == source.tabId, + ); if (debugSession == null) return; final event = _extensionEventFor(method, params); if (method == 'Debugger.scriptParsed') { @@ -538,9 +541,7 @@ Future _openDevTools( final devToolsTab = await createTab( addQueryParameters( devToolsUri, - queryParameters: { - 'ide': 'DebugExtension', - }, + queryParameters: {'ide': 'DebugExtension'}, ), inNewWindow: devToolsOpener?.newWindow ?? false, ); @@ -578,14 +579,8 @@ Future _maybeCloseDevTools(int? devToolsTabId) async { Future _removeDebugSessionDataInStorage(int tabId) async { // Remove the DevTools URI, encoded URI, and multiple apps info from storage: - await removeStorageObject( - type: StorageObject.devToolsUri, - tabId: tabId, - ); - await removeStorageObject( - type: StorageObject.encodedUri, - tabId: tabId, - ); + await removeStorageObject(type: StorageObject.devToolsUri, tabId: tabId); + await removeStorageObject(type: StorageObject.encodedUri, tabId: tabId); await removeStorageObject( type: StorageObject.multipleAppsDetected, tabId: tabId, @@ -598,8 +593,10 @@ void _removeDebugSession(_DebugSession debugSession) { // DWDS that we should close the connection, instead of relying on the done // event sent when the client is closed. See details: // https://github.com/dart-lang/webdev/pull/1595#issuecomment-1116773378 - final event = - _extensionEventFor('DebugExtension.detached', js_util.jsify({})); + final event = _extensionEventFor( + 'DebugExtension.detached', + js_util.jsify({}), + ); debugSession.sendEvent(event); debugSession.close(); final removed = _debugSessions.remove(debugSession); @@ -615,9 +612,10 @@ Future _sendConnectFailureMessage( final json = jsonEncode( serializers.serialize( ConnectFailure( - (b) => b - ..tabId = dartAppTabId - ..reason = reason.name, + (b) => + b + ..tabId = dartAppTabId + ..reason = reason.name, ), ), ); @@ -636,10 +634,11 @@ Future _sendStopDebuggingMessage( final json = jsonEncode( serializers.serialize( DebugStateChange( - (b) => b - ..tabId = dartAppTabId - ..reason = reason.name - ..newState = DebugStateChange.stopDebugging, + (b) => + b + ..tabId = dartAppTabId + ..reason = reason.name + ..newState = DebugStateChange.stopDebugging, ), ), ); @@ -653,10 +652,12 @@ Future _sendStopDebuggingMessage( _DebugSession? _debugSessionForTab(int tabId, {required TabType type}) { return switch (type) { - TabType.dartApp => - _debugSessions.firstWhereOrNull((session) => session.appTabId == tabId), - TabType.devTools => _debugSessions - .firstWhereOrNull((session) => session.devToolsTabId == tabId) + TabType.dartApp => _debugSessions.firstWhereOrNull( + (session) => session.appTabId == tabId, + ), + TabType.devTools => _debugSessions.firstWhereOrNull( + (session) => session.devToolsTabId == tabId, + ), }; } @@ -703,10 +704,7 @@ Future _sendAuthRequest(String authUrl) async { return responseBody.contains('Dart Debug Authentication Success!'); } -Future _showWarning( - String message, { - bool forwardToCider = false, -}) { +Future _showWarning(String message, {bool forwardToCider = false}) { if (forwardToCider) { sendErrorMessageToCider( errorType: CiderErrorType.invalidRequest, @@ -739,18 +737,20 @@ DebuggerLocation? _debuggerLocation(int dartAppTabId) { Trigger.angularDartDevTools => DebuggerLocation.angularDartDevTools, Trigger.cider => DebuggerLocation.ide, Trigger.extensionPanel => DebuggerLocation.chromeDevTools, - Trigger.extensionIcon => debugSession.devToolsTabId != null - ? DebuggerLocation.dartDevTools - : DebuggerLocation.ide, + Trigger.extensionIcon => + debugSession.devToolsTabId != null + ? DebuggerLocation.dartDevTools + : DebuggerLocation.ide, }; } /// Construct an [ExtensionEvent] from [method] and [params]. ExtensionEvent _extensionEventFor(String method, dynamic params) { return ExtensionEvent( - (b) => b - ..params = jsonEncode(json.decode(JSON.stringify(params))) - ..method = jsonEncode(method), + (b) => + b + ..params = jsonEncode(json.decode(JSON.stringify(params))) + ..method = jsonEncode(method), ); } @@ -782,8 +782,9 @@ class _DebugSession { int? devToolsTabId; // Collect events into batches to be send periodically to the server. - final _batchController = - BatchedStreamController(delay: _batchDelayMilliseconds); + final _batchController = BatchedStreamController( + delay: _batchDelayMilliseconds, + ); late final StreamSubscription> _batchSubscription; _DebugSession({ @@ -874,7 +875,7 @@ String? _authUrl(String? extensionUrl) { return switch (authUrl.scheme) { 'ws' => authUrl.replace(scheme: 'http').toString(), 'wss' => authUrl.replace(scheme: 'https').toString(), - _ => authUrl.toString() + _ => authUrl.toString(), }; } diff --git a/dwds/debug_extension/web/detector.dart b/dwds/debug_extension/web/detector.dart index 1d1ec0f68..4c482de26 100644 --- a/dwds/debug_extension/web/detector.dart +++ b/dwds/debug_extension/web/detector.dart @@ -14,6 +14,8 @@ import 'dart:html'; import 'dart:js_util'; import 'package:dwds/data/debug_info.dart'; +// TODO: https://github.com/dart-lang/webdev/issues/2508 +// ignore: deprecated_member_use import 'package:js/js.dart'; import 'chrome_api.dart'; @@ -70,8 +72,9 @@ void _detectMultipleDartApps() { return; } - final multipleAppsObserver = - MutationObserver(_detectMultipleDartAppsCallback); + final multipleAppsObserver = MutationObserver( + _detectMultipleDartAppsCallback, + ); multipleAppsObserver.observe( documentElement, attributeFilter: [_multipleAppsAttribute], @@ -94,7 +97,8 @@ void _detectMultipleDartAppsCallback( } bool _isMultipleAppsMutation(dynamic mutation) { - final isAttributeMutation = hasProperty(mutation, 'type') && + final isAttributeMutation = + hasProperty(mutation, 'type') && getProperty(mutation, 'type') == 'attributes'; if (isAttributeMutation) { return hasProperty(mutation, 'attributeName') && diff --git a/dwds/debug_extension/web/devtools.dart b/dwds/debug_extension/web/devtools.dart index 6318ddffa..f429c186e 100644 --- a/dwds/debug_extension/web/devtools.dart +++ b/dwds/debug_extension/web/devtools.dart @@ -10,6 +10,8 @@ library; import 'dart:html'; import 'package:dwds/data/debug_info.dart'; +// TODO: https://github.com/dart-lang/webdev/issues/2508 +// ignore: deprecated_member_use import 'package:js/js.dart'; import 'chrome_api.dart'; @@ -26,10 +28,7 @@ void main() async { void _registerListeners() { chrome.storage.onChanged.addListener( - allowInterop(( - Object _, - String storageArea, - ) { + allowInterop((Object _, String storageArea) { _maybeCreatePanels(); }), ); diff --git a/dwds/debug_extension/web/logger.dart b/dwds/debug_extension/web/logger.dart index 69e02190f..809ca2dda 100644 --- a/dwds/debug_extension/web/logger.dart +++ b/dwds/debug_extension/web/logger.dart @@ -5,37 +5,23 @@ @JS() library; +// TODO: https://github.com/dart-lang/webdev/issues/2508 +// ignore: deprecated_member_use import 'package:js/js.dart'; import 'utils.dart'; -enum _LogLevel { - info, - warn, - error, -} +enum _LogLevel { info, warn, error } -void debugLog( - String msg, { - String? prefix, - bool verbose = false, -}) { +void debugLog(String msg, {String? prefix, bool verbose = false}) { _log(msg, prefix: prefix, verbose: verbose); } -void debugWarn( - String msg, { - String? prefix, - bool verbose = false, -}) { +void debugWarn(String msg, {String? prefix, bool verbose = false}) { _log(msg, prefix: prefix, level: _LogLevel.warn, verbose: verbose); } -void debugError( - String msg, { - String? prefix, - bool verbose = false, -}) { +void debugError(String msg, {String? prefix, bool verbose = false}) { _log(msg, prefix: prefix, level: _LogLevel.error, verbose: verbose); } diff --git a/dwds/debug_extension/web/messaging.dart b/dwds/debug_extension/web/messaging.dart index 7a4d139b5..dad8d4545 100644 --- a/dwds/debug_extension/web/messaging.dart +++ b/dwds/debug_extension/web/messaging.dart @@ -11,6 +11,8 @@ import 'dart:convert'; // ignore: deprecated_member_use import 'dart:js_util'; +// TODO: https://github.com/dart-lang/webdev/issues/2508 +// ignore: deprecated_member_use import 'package:js/js.dart'; import 'chrome_api.dart'; @@ -128,12 +130,7 @@ Future sendRuntimeMessage({ required Script sender, required Script recipient, }) => - _sendMessage( - type: type, - body: body, - sender: sender, - recipient: recipient, - ); + _sendMessage(type: type, body: body, sender: sender, recipient: recipient); /// Send a message using the chrome.tabs.sendMessage API. Future sendTabsMessage({ @@ -142,14 +139,13 @@ Future sendTabsMessage({ required String body, required Script sender, required Script recipient, -}) => - _sendMessage( - tabId: tabId, - type: type, - body: body, - sender: sender, - recipient: recipient, - ); +}) => _sendMessage( + tabId: tabId, + type: type, + body: body, + sender: sender, + recipient: recipient, +); Future _sendMessage({ required MessageType type, @@ -158,12 +154,8 @@ Future _sendMessage({ required Script recipient, int? tabId, }) { - final message = Message( - to: recipient, - from: sender, - type: type, - body: body, - ).toJSON(); + final message = + Message(to: recipient, from: sender, type: type, body: body).toJSON(); final completer = Completer(); void responseHandler([dynamic _]) { final error = chrome.runtime.lastError; @@ -203,7 +195,8 @@ bool _isLegitimateSender(MessageSender sender) { final senderUri = Uri.parse(sender.origin ?? ''); final senderHost = senderUri.host; - final isDartAppHost = senderHost == 'localhost' || + final isDartAppHost = + senderHost == 'localhost' || senderHost == '127.0.0.1' || _isGoogleHost(senderHost); final isExtensionOrigin = diff --git a/dwds/debug_extension/web/panel.dart b/dwds/debug_extension/web/panel.dart index 2c1b6ffbf..c78600a72 100644 --- a/dwds/debug_extension/web/panel.dart +++ b/dwds/debug_extension/web/panel.dart @@ -12,6 +12,8 @@ import 'dart:convert'; import 'dart:html'; import 'package:dwds/data/debug_info.dart'; +// TODO: https://github.com/dart-lang/webdev/issues/2508 +// ignore: deprecated_member_use import 'package:js/js.dart'; import 'chrome_api.dart'; @@ -188,10 +190,7 @@ Future _maybeUpdateFileABugLink() async { if (isInternal) { final bugLink = document.getElementById(_bugLinkId); if (bugLink == null) return; - bugLink.setAttribute( - 'href', - 'http://go/dde-bug', - ); + bugLink.setAttribute('href', 'http://go/dde-bug'); } } @@ -277,9 +276,10 @@ Future _launchDebugConnection(Event _) async { final json = jsonEncode( serializers.serialize( DebugStateChange( - (b) => b - ..tabId = _tabId - ..newState = DebugStateChange.startDebugging, + (b) => + b + ..tabId = _tabId + ..newState = DebugStateChange.startDebugging, ), ), ); diff --git a/dwds/debug_extension/web/popup.dart b/dwds/debug_extension/web/popup.dart index de6fbed08..7432ca783 100644 --- a/dwds/debug_extension/web/popup.dart +++ b/dwds/debug_extension/web/popup.dart @@ -12,6 +12,8 @@ import 'dart:convert'; import 'dart:html'; import 'package:dwds/data/debug_info.dart'; +// TODO: https://github.com/dart-lang/webdev/issues/2508 +// ignore: deprecated_member_use import 'package:js/js.dart'; import 'data_serializers.dart'; @@ -107,9 +109,10 @@ Future _insertAppId() async { Future _openIssueTracker(Event _) async { final debugInfo = await _fetchDebugInfo(await _tabId); final isInternalBuild = debugInfo?.isInternalBuild ?? false; - final issueTrackerLink = isInternalBuild - ? 'http://b/issues/new?component=775375&template=1791321' - : 'https://github.com/dart-lang/webdev/issues/new?labels=dart-debug-extension&projects=&template=dart_debug_extension.md'; + final issueTrackerLink = + isInternalBuild + ? 'http://b/issues/new?component=775375&template=1791321' + : 'https://github.com/dart-lang/webdev/issues/new?labels=dart-debug-extension&projects=&template=dart_debug_extension.md'; await createTab(issueTrackerLink); } @@ -118,9 +121,10 @@ Future _launchDevTools(Event _) async { final json = jsonEncode( serializers.serialize( DebugStateChange( - (b) => b - ..tabId = tabId - ..newState = DebugStateChange.startDebugging, + (b) => + b + ..tabId = tabId + ..newState = DebugStateChange.startDebugging, ), ), ); @@ -154,9 +158,7 @@ Future _saveSettingsToStorage(String? devToolsOpener) async { if (devToolsOpener == null) return; await setStorageObject( type: StorageObject.devToolsOpener, - value: DevToolsOpener( - (b) => b..newWindow = devToolsOpener == 'window', - ), + value: DevToolsOpener((b) => b..newWindow = devToolsOpener == 'window'), ); } diff --git a/dwds/debug_extension/web/storage.dart b/dwds/debug_extension/web/storage.dart index 52dd65faa..0b79b3655 100644 --- a/dwds/debug_extension/web/storage.dart +++ b/dwds/debug_extension/web/storage.dart @@ -11,6 +11,8 @@ import 'dart:convert'; // ignore: deprecated_member_use import 'dart:js_util'; +// TODO: https://github.com/dart-lang/webdev/issues/2508 +// ignore: deprecated_member_use import 'package:js/js.dart'; import 'chrome_api.dart'; @@ -27,19 +29,16 @@ enum StorageObject { multipleAppsDetected; Persistence get persistence => switch (this) { - StorageObject.debugInfo => Persistence.sessionOnly, - StorageObject.devToolsOpener => Persistence.acrossSessions, - StorageObject.devToolsUri => Persistence.sessionOnly, - StorageObject.encodedUri => Persistence.sessionOnly, - StorageObject.isAuthenticated => Persistence.sessionOnly, - StorageObject.multipleAppsDetected => Persistence.sessionOnly - }; + StorageObject.debugInfo => Persistence.sessionOnly, + StorageObject.devToolsOpener => Persistence.acrossSessions, + StorageObject.devToolsUri => Persistence.sessionOnly, + StorageObject.encodedUri => Persistence.sessionOnly, + StorageObject.isAuthenticated => Persistence.sessionOnly, + StorageObject.multipleAppsDetected => Persistence.sessionOnly, + }; } -enum Persistence { - sessionOnly, - acrossSessions; -} +enum Persistence { sessionOnly, acrossSessions } Future setStorageObject({ required StorageObject type, @@ -174,7 +173,7 @@ StorageArea _getStorageArea(Persistence persistence) { return switch (persistence) { Persistence.acrossSessions => chrome.storage.local, - Persistence.sessionOnly => chrome.storage.session + Persistence.sessionOnly => chrome.storage.session, }; } diff --git a/dwds/debug_extension/web/utils.dart b/dwds/debug_extension/web/utils.dart index 9ef92887f..d6be21a80 100644 --- a/dwds/debug_extension/web/utils.dart +++ b/dwds/debug_extension/web/utils.dart @@ -10,6 +10,8 @@ import 'dart:async'; // ignore: deprecated_member_use import 'dart:js_util'; +// TODO: https://github.com/dart-lang/webdev/issues/2508 +// ignore: deprecated_member_use import 'package:js/js.dart'; import 'chrome_api.dart'; @@ -19,18 +21,13 @@ Future createTab(String url, {bool inNewWindow = false}) { if (inNewWindow) { chrome.windows.create( WindowInfo(focused: true, url: url), - allowInterop( - (WindowObj windowObj) { - completer.complete(windowObj.tabs.first); - }, - ), + allowInterop((WindowObj windowObj) { + completer.complete(windowObj.tabs.first); + }), ); } else { chrome.tabs.create( - TabInfo( - active: true, - url: url, - ), + TabInfo(active: true, url: url), allowInterop(completer.complete), ); } @@ -137,10 +134,7 @@ String addQueryParameters( final originalUri = Uri.parse(uri); final newUri = originalUri.replace( path: '', // Replace the /debugger path so that the inspector url works. - queryParameters: { - ...originalUri.queryParameters, - ...queryParameters, - }, + queryParameters: {...originalUri.queryParameters, ...queryParameters}, ); return newUri.toString(); } diff --git a/dwds/debug_extension/web/web_api.dart b/dwds/debug_extension/web/web_api.dart index 1a7d61664..677959a4f 100644 --- a/dwds/debug_extension/web/web_api.dart +++ b/dwds/debug_extension/web/web_api.dart @@ -9,6 +9,8 @@ import 'dart:html'; // ignore: deprecated_member_use import 'dart:js_util' as js_util; +// TODO: https://github.com/dart-lang/webdev/issues/2508 +// ignore: deprecated_member_use import 'package:js/js.dart'; @JS() @@ -29,12 +31,10 @@ external Object _nativeJsFetch(String resourceUrl, FetchOptions options); Future fetchRequest(String resourceUrl) async { try { - final options = FetchOptions( - method: 'GET', - credentials: 'include', + final options = FetchOptions(method: 'GET', credentials: 'include'); + final response = await promiseToFuture( + _nativeJsFetch(resourceUrl, options), ); - final response = - await promiseToFuture(_nativeJsFetch(resourceUrl, options)); final body = await promiseToFuture( js_util.callMethod(response, 'text', []), ); @@ -64,9 +64,5 @@ class FetchResponse { final bool ok; final String? body; - FetchResponse({ - required this.status, - required this.ok, - required this.body, - }); + FetchResponse({required this.status, required this.ok, required this.body}); } diff --git a/dwds/lib/dart_web_debug_service.dart b/dwds/lib/dart_web_debug_service.dart index 18b3ef83a..c3b63d9bb 100644 --- a/dwds/lib/dart_web_debug_service.dart +++ b/dwds/lib/dart_web_debug_service.dart @@ -74,21 +74,24 @@ class Dwds { Future? extensionUri; ExtensionBackend? extensionBackend; if (debugSettings.enableDebugExtension) { - final handler = debugSettings.useSseForDebugBackend - ? SseSocketHandler( - SseHandler( - Uri.parse('/\$debug'), - // Proxy servers may actively kill long standing connections. - // Allow for clients to reconnect in a short window. Making the - // window too long may cause issues if the user closes a debug - // session and initiates a new one during the keepAlive window. - keepAlive: const Duration(seconds: 5), - ), - ) - : WebSocketSocketHandler(); - - extensionBackend = - await ExtensionBackend.start(handler, appMetadata.hostname); + final handler = + debugSettings.useSseForDebugBackend + ? SseSocketHandler( + SseHandler( + Uri.parse('/\$debug'), + // Proxy servers may actively kill long standing connections. + // Allow for clients to reconnect in a short window. Making the + // window too long may cause issues if the user closes a debug + // session and initiates a new one during the keepAlive window. + keepAlive: const Duration(seconds: 5), + ), + ) + : WebSocketSocketHandler(); + + extensionBackend = await ExtensionBackend.start( + handler, + appMetadata.hostname, + ); extensionUri = Future.value( Uri( scheme: debugSettings.useSseForDebugBackend ? 'http' : 'ws', @@ -106,14 +109,15 @@ class Dwds { final devToolsLauncher = debugSettings.devToolsLauncher; if (devToolsLauncher != null) { devTools = await devToolsLauncher(appMetadata.hostname); - final uri = - Uri(scheme: 'http', host: devTools.hostname, port: devTools.port); + final uri = Uri( + scheme: 'http', + host: devTools.hostname, + port: devTools.port, + ); _logger.info('Serving DevTools at $uri\n'); } - final injected = DwdsInjector( - extensionUri: extensionUri, - ); + final injected = DwdsInjector(extensionUri: extensionUri); final devHandler = DevHandler( chromeConnection, diff --git a/dwds/lib/data/build_result.g.dart b/dwds/lib/data/build_result.g.dart index 2d119ab98..1b7087249 100644 --- a/dwds/lib/data/build_result.g.dart +++ b/dwds/lib/data/build_result.g.dart @@ -23,12 +23,9 @@ BuildStatus _$valueOf(String name) { } } -final BuiltSet _$values = - new BuiltSet(const [ - _$started, - _$succeeded, - _$failed, -]); +final BuiltSet _$values = new BuiltSet( + const [_$started, _$succeeded, _$failed], +); Serializer _$buildStatusSerializer = new _$BuildStatusSerializer(); Serializer _$buildResultSerializer = new _$BuildResultSerializer(); @@ -40,14 +37,18 @@ class _$BuildStatusSerializer implements PrimitiveSerializer { final String wireName = 'BuildStatus'; @override - Object serialize(Serializers serializers, BuildStatus object, - {FullType specifiedType = FullType.unspecified}) => - object.name; + Object serialize( + Serializers serializers, + BuildStatus object, { + FullType specifiedType = FullType.unspecified, + }) => object.name; @override - BuildStatus deserialize(Serializers serializers, Object serialized, - {FullType specifiedType = FullType.unspecified}) => - BuildStatus.valueOf(serialized as String); + BuildStatus deserialize( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + }) => BuildStatus.valueOf(serialized as String); } class _$BuildResultSerializer implements StructuredSerializer { @@ -57,20 +58,28 @@ class _$BuildResultSerializer implements StructuredSerializer { final String wireName = 'BuildResult'; @override - Iterable serialize(Serializers serializers, BuildResult object, - {FullType specifiedType = FullType.unspecified}) { + Iterable serialize( + Serializers serializers, + BuildResult object, { + FullType specifiedType = FullType.unspecified, + }) { final result = [ 'status', - serializers.serialize(object.status, - specifiedType: const FullType(BuildStatus)), + serializers.serialize( + object.status, + specifiedType: const FullType(BuildStatus), + ), ]; return result; } @override - BuildResult deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { + BuildResult deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { final result = new BuildResultBuilder(); final iterator = serialized.iterator; @@ -80,8 +89,12 @@ class _$BuildResultSerializer implements StructuredSerializer { final Object? value = iterator.current; switch (key) { case 'status': - result.status = serializers.deserialize(value, - specifiedType: const FullType(BuildStatus))! as BuildStatus; + result.status = + serializers.deserialize( + value, + specifiedType: const FullType(BuildStatus), + )! + as BuildStatus; break; } } @@ -124,8 +137,8 @@ class _$BuildResult extends BuildResult { @override String toString() { - return (newBuiltValueToStringHelper(r'BuildResult')..add('status', status)) - .toString(); + return (newBuiltValueToStringHelper(r'BuildResult') + ..add('status', status)).toString(); } } @@ -162,10 +175,15 @@ class BuildResultBuilder implements Builder { BuildResult build() => _build(); _$BuildResult _build() { - final _$result = _$v ?? + final _$result = + _$v ?? new _$BuildResult._( - status: BuiltValueNullFieldError.checkNotNull( - status, r'BuildResult', 'status')); + status: BuiltValueNullFieldError.checkNotNull( + status, + r'BuildResult', + 'status', + ), + ); replace(_$result); return _$result; } diff --git a/dwds/lib/data/connect_request.g.dart b/dwds/lib/data/connect_request.g.dart index ab1ff180b..d4b06d811 100644 --- a/dwds/lib/data/connect_request.g.dart +++ b/dwds/lib/data/connect_request.g.dart @@ -17,18 +17,27 @@ class _$ConnectRequestSerializer final String wireName = 'ConnectRequest'; @override - Iterable serialize(Serializers serializers, ConnectRequest object, - {FullType specifiedType = FullType.unspecified}) { + Iterable serialize( + Serializers serializers, + ConnectRequest object, { + FullType specifiedType = FullType.unspecified, + }) { final result = [ 'appId', - serializers.serialize(object.appId, - specifiedType: const FullType(String)), + serializers.serialize( + object.appId, + specifiedType: const FullType(String), + ), 'instanceId', - serializers.serialize(object.instanceId, - specifiedType: const FullType(String)), + serializers.serialize( + object.instanceId, + specifiedType: const FullType(String), + ), 'entrypointPath', - serializers.serialize(object.entrypointPath, - specifiedType: const FullType(String)), + serializers.serialize( + object.entrypointPath, + specifiedType: const FullType(String), + ), ]; return result; @@ -36,8 +45,10 @@ class _$ConnectRequestSerializer @override ConnectRequest deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { final result = new ConnectRequestBuilder(); final iterator = serialized.iterator; @@ -47,16 +58,28 @@ class _$ConnectRequestSerializer final Object? value = iterator.current; switch (key) { case 'appId': - result.appId = serializers.deserialize(value, - specifiedType: const FullType(String))! as String; + result.appId = + serializers.deserialize( + value, + specifiedType: const FullType(String), + )! + as String; break; case 'instanceId': - result.instanceId = serializers.deserialize(value, - specifiedType: const FullType(String))! as String; + result.instanceId = + serializers.deserialize( + value, + specifiedType: const FullType(String), + )! + as String; break; case 'entrypointPath': - result.entrypointPath = serializers.deserialize(value, - specifiedType: const FullType(String))! as String; + result.entrypointPath = + serializers.deserialize( + value, + specifiedType: const FullType(String), + )! + as String; break; } } @@ -76,16 +99,22 @@ class _$ConnectRequest extends ConnectRequest { factory _$ConnectRequest([void Function(ConnectRequestBuilder)? updates]) => (new ConnectRequestBuilder()..update(updates))._build(); - _$ConnectRequest._( - {required this.appId, - required this.instanceId, - required this.entrypointPath}) - : super._() { + _$ConnectRequest._({ + required this.appId, + required this.instanceId, + required this.entrypointPath, + }) : super._() { BuiltValueNullFieldError.checkNotNull(appId, r'ConnectRequest', 'appId'); BuiltValueNullFieldError.checkNotNull( - instanceId, r'ConnectRequest', 'instanceId'); + instanceId, + r'ConnectRequest', + 'instanceId', + ); BuiltValueNullFieldError.checkNotNull( - entrypointPath, r'ConnectRequest', 'entrypointPath'); + entrypointPath, + r'ConnectRequest', + 'entrypointPath', + ); } @override @@ -170,14 +199,25 @@ class ConnectRequestBuilder ConnectRequest build() => _build(); _$ConnectRequest _build() { - final _$result = _$v ?? + final _$result = + _$v ?? new _$ConnectRequest._( - appId: BuiltValueNullFieldError.checkNotNull( - appId, r'ConnectRequest', 'appId'), - instanceId: BuiltValueNullFieldError.checkNotNull( - instanceId, r'ConnectRequest', 'instanceId'), - entrypointPath: BuiltValueNullFieldError.checkNotNull( - entrypointPath, r'ConnectRequest', 'entrypointPath')); + appId: BuiltValueNullFieldError.checkNotNull( + appId, + r'ConnectRequest', + 'appId', + ), + instanceId: BuiltValueNullFieldError.checkNotNull( + instanceId, + r'ConnectRequest', + 'instanceId', + ), + entrypointPath: BuiltValueNullFieldError.checkNotNull( + entrypointPath, + r'ConnectRequest', + 'entrypointPath', + ), + ); replace(_$result); return _$result; } diff --git a/dwds/lib/data/debug_event.g.dart b/dwds/lib/data/debug_event.g.dart index b8f239e1d..a4a316be1 100644 --- a/dwds/lib/data/debug_event.g.dart +++ b/dwds/lib/data/debug_event.g.dart @@ -17,25 +17,35 @@ class _$DebugEventSerializer implements StructuredSerializer { final String wireName = 'DebugEvent'; @override - Iterable serialize(Serializers serializers, DebugEvent object, - {FullType specifiedType = FullType.unspecified}) { + Iterable serialize( + Serializers serializers, + DebugEvent object, { + FullType specifiedType = FullType.unspecified, + }) { final result = [ 'kind', serializers.serialize(object.kind, specifiedType: const FullType(String)), 'eventData', - serializers.serialize(object.eventData, - specifiedType: const FullType(String)), + serializers.serialize( + object.eventData, + specifiedType: const FullType(String), + ), 'timestamp', - serializers.serialize(object.timestamp, - specifiedType: const FullType(int)), + serializers.serialize( + object.timestamp, + specifiedType: const FullType(int), + ), ]; return result; } @override - DebugEvent deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { + DebugEvent deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { final result = new DebugEventBuilder(); final iterator = serialized.iterator; @@ -45,16 +55,28 @@ class _$DebugEventSerializer implements StructuredSerializer { final Object? value = iterator.current; switch (key) { case 'kind': - result.kind = serializers.deserialize(value, - specifiedType: const FullType(String))! as String; + result.kind = + serializers.deserialize( + value, + specifiedType: const FullType(String), + )! + as String; break; case 'eventData': - result.eventData = serializers.deserialize(value, - specifiedType: const FullType(String))! as String; + result.eventData = + serializers.deserialize( + value, + specifiedType: const FullType(String), + )! + as String; break; case 'timestamp': - result.timestamp = serializers.deserialize(value, - specifiedType: const FullType(int))! as int; + result.timestamp = + serializers.deserialize( + value, + specifiedType: const FullType(int), + )! + as int; break; } } @@ -72,13 +94,18 @@ class _$BatchedDebugEventsSerializer @override Iterable serialize( - Serializers serializers, BatchedDebugEvents object, - {FullType specifiedType = FullType.unspecified}) { + Serializers serializers, + BatchedDebugEvents object, { + FullType specifiedType = FullType.unspecified, + }) { final result = [ 'events', - serializers.serialize(object.events, - specifiedType: - const FullType(BuiltList, const [const FullType(DebugEvent)])), + serializers.serialize( + object.events, + specifiedType: const FullType(BuiltList, const [ + const FullType(DebugEvent), + ]), + ), ]; return result; @@ -86,8 +113,10 @@ class _$BatchedDebugEventsSerializer @override BatchedDebugEvents deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { final result = new BatchedDebugEventsBuilder(); final iterator = serialized.iterator; @@ -97,10 +126,15 @@ class _$BatchedDebugEventsSerializer final Object? value = iterator.current; switch (key) { case 'events': - result.events.replace(serializers.deserialize(value, - specifiedType: const FullType( - BuiltList, const [const FullType(DebugEvent)]))! - as BuiltList); + result.events.replace( + serializers.deserialize( + value, + specifiedType: const FullType(BuiltList, const [ + const FullType(DebugEvent), + ]), + )! + as BuiltList, + ); break; } } @@ -120,14 +154,22 @@ class _$DebugEvent extends DebugEvent { factory _$DebugEvent([void Function(DebugEventBuilder)? updates]) => (new DebugEventBuilder()..update(updates))._build(); - _$DebugEvent._( - {required this.kind, required this.eventData, required this.timestamp}) - : super._() { + _$DebugEvent._({ + required this.kind, + required this.eventData, + required this.timestamp, + }) : super._() { BuiltValueNullFieldError.checkNotNull(kind, r'DebugEvent', 'kind'); BuiltValueNullFieldError.checkNotNull( - eventData, r'DebugEvent', 'eventData'); + eventData, + r'DebugEvent', + 'eventData', + ); BuiltValueNullFieldError.checkNotNull( - timestamp, r'DebugEvent', 'timestamp'); + timestamp, + r'DebugEvent', + 'timestamp', + ); } @override @@ -209,14 +251,25 @@ class DebugEventBuilder implements Builder { DebugEvent build() => _build(); _$DebugEvent _build() { - final _$result = _$v ?? + final _$result = + _$v ?? new _$DebugEvent._( - kind: BuiltValueNullFieldError.checkNotNull( - kind, r'DebugEvent', 'kind'), - eventData: BuiltValueNullFieldError.checkNotNull( - eventData, r'DebugEvent', 'eventData'), - timestamp: BuiltValueNullFieldError.checkNotNull( - timestamp, r'DebugEvent', 'timestamp')); + kind: BuiltValueNullFieldError.checkNotNull( + kind, + r'DebugEvent', + 'kind', + ), + eventData: BuiltValueNullFieldError.checkNotNull( + eventData, + r'DebugEvent', + 'eventData', + ), + timestamp: BuiltValueNullFieldError.checkNotNull( + timestamp, + r'DebugEvent', + 'timestamp', + ), + ); replace(_$result); return _$result; } @@ -226,19 +279,22 @@ class _$BatchedDebugEvents extends BatchedDebugEvents { @override final BuiltList events; - factory _$BatchedDebugEvents( - [void Function(BatchedDebugEventsBuilder)? updates]) => - (new BatchedDebugEventsBuilder()..update(updates))._build(); + factory _$BatchedDebugEvents([ + void Function(BatchedDebugEventsBuilder)? updates, + ]) => (new BatchedDebugEventsBuilder()..update(updates))._build(); _$BatchedDebugEvents._({required this.events}) : super._() { BuiltValueNullFieldError.checkNotNull( - events, r'BatchedDebugEvents', 'events'); + events, + r'BatchedDebugEvents', + 'events', + ); } @override BatchedDebugEvents rebuild( - void Function(BatchedDebugEventsBuilder) updates) => - (toBuilder()..update(updates)).build(); + void Function(BatchedDebugEventsBuilder) updates, + ) => (toBuilder()..update(updates)).build(); @override BatchedDebugEventsBuilder toBuilder() => @@ -261,8 +317,7 @@ class _$BatchedDebugEvents extends BatchedDebugEvents { @override String toString() { return (newBuiltValueToStringHelper(r'BatchedDebugEvents') - ..add('events', events)) - .toString(); + ..add('events', events)).toString(); } } @@ -311,7 +366,10 @@ class BatchedDebugEventsBuilder events.build(); } catch (e) { throw new BuiltValueNestedFieldError( - r'BatchedDebugEvents', _$failedField, e.toString()); + r'BatchedDebugEvents', + _$failedField, + e.toString(), + ); } rethrow; } diff --git a/dwds/lib/data/debug_info.g.dart b/dwds/lib/data/debug_info.g.dart index e4ccd3ee5..15e5cab5f 100644 --- a/dwds/lib/data/debug_info.g.dart +++ b/dwds/lib/data/debug_info.g.dart @@ -15,93 +15,108 @@ class _$DebugInfoSerializer implements StructuredSerializer { final String wireName = 'DebugInfo'; @override - Iterable serialize(Serializers serializers, DebugInfo object, - {FullType specifiedType = FullType.unspecified}) { + Iterable serialize( + Serializers serializers, + DebugInfo object, { + FullType specifiedType = FullType.unspecified, + }) { final result = []; Object? value; value = object.appEntrypointPath; if (value != null) { result ..add('appEntrypointPath') - ..add(serializers.serialize(value, - specifiedType: const FullType(String))); + ..add( + serializers.serialize(value, specifiedType: const FullType(String)), + ); } value = object.appId; if (value != null) { result ..add('appId') - ..add(serializers.serialize(value, - specifiedType: const FullType(String))); + ..add( + serializers.serialize(value, specifiedType: const FullType(String)), + ); } value = object.appInstanceId; if (value != null) { result ..add('appInstanceId') - ..add(serializers.serialize(value, - specifiedType: const FullType(String))); + ..add( + serializers.serialize(value, specifiedType: const FullType(String)), + ); } value = object.appOrigin; if (value != null) { result ..add('appOrigin') - ..add(serializers.serialize(value, - specifiedType: const FullType(String))); + ..add( + serializers.serialize(value, specifiedType: const FullType(String)), + ); } value = object.appUrl; if (value != null) { result ..add('appUrl') - ..add(serializers.serialize(value, - specifiedType: const FullType(String))); + ..add( + serializers.serialize(value, specifiedType: const FullType(String)), + ); } value = object.authUrl; if (value != null) { result ..add('authUrl') - ..add(serializers.serialize(value, - specifiedType: const FullType(String))); + ..add( + serializers.serialize(value, specifiedType: const FullType(String)), + ); } value = object.dwdsVersion; if (value != null) { result ..add('dwdsVersion') - ..add(serializers.serialize(value, - specifiedType: const FullType(String))); + ..add( + serializers.serialize(value, specifiedType: const FullType(String)), + ); } value = object.extensionUrl; if (value != null) { result ..add('extensionUrl') - ..add(serializers.serialize(value, - specifiedType: const FullType(String))); + ..add( + serializers.serialize(value, specifiedType: const FullType(String)), + ); } value = object.isInternalBuild; if (value != null) { result ..add('isInternalBuild') ..add( - serializers.serialize(value, specifiedType: const FullType(bool))); + serializers.serialize(value, specifiedType: const FullType(bool)), + ); } value = object.isFlutterApp; if (value != null) { result ..add('isFlutterApp') ..add( - serializers.serialize(value, specifiedType: const FullType(bool))); + serializers.serialize(value, specifiedType: const FullType(bool)), + ); } value = object.workspaceName; if (value != null) { result ..add('workspaceName') - ..add(serializers.serialize(value, - specifiedType: const FullType(String))); + ..add( + serializers.serialize(value, specifiedType: const FullType(String)), + ); } value = object.tabUrl; if (value != null) { result ..add('tabUrl') - ..add(serializers.serialize(value, - specifiedType: const FullType(String))); + ..add( + serializers.serialize(value, specifiedType: const FullType(String)), + ); } value = object.tabId; if (value != null) { @@ -113,8 +128,11 @@ class _$DebugInfoSerializer implements StructuredSerializer { } @override - DebugInfo deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { + DebugInfo deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { final result = new DebugInfoBuilder(); final iterator = serialized.iterator; @@ -124,56 +142,105 @@ class _$DebugInfoSerializer implements StructuredSerializer { final Object? value = iterator.current; switch (key) { case 'appEntrypointPath': - result.appEntrypointPath = serializers.deserialize(value, - specifiedType: const FullType(String)) as String?; + result.appEntrypointPath = + serializers.deserialize( + value, + specifiedType: const FullType(String), + ) + as String?; break; case 'appId': - result.appId = serializers.deserialize(value, - specifiedType: const FullType(String)) as String?; + result.appId = + serializers.deserialize( + value, + specifiedType: const FullType(String), + ) + as String?; break; case 'appInstanceId': - result.appInstanceId = serializers.deserialize(value, - specifiedType: const FullType(String)) as String?; + result.appInstanceId = + serializers.deserialize( + value, + specifiedType: const FullType(String), + ) + as String?; break; case 'appOrigin': - result.appOrigin = serializers.deserialize(value, - specifiedType: const FullType(String)) as String?; + result.appOrigin = + serializers.deserialize( + value, + specifiedType: const FullType(String), + ) + as String?; break; case 'appUrl': - result.appUrl = serializers.deserialize(value, - specifiedType: const FullType(String)) as String?; + result.appUrl = + serializers.deserialize( + value, + specifiedType: const FullType(String), + ) + as String?; break; case 'authUrl': - result.authUrl = serializers.deserialize(value, - specifiedType: const FullType(String)) as String?; + result.authUrl = + serializers.deserialize( + value, + specifiedType: const FullType(String), + ) + as String?; break; case 'dwdsVersion': - result.dwdsVersion = serializers.deserialize(value, - specifiedType: const FullType(String)) as String?; + result.dwdsVersion = + serializers.deserialize( + value, + specifiedType: const FullType(String), + ) + as String?; break; case 'extensionUrl': - result.extensionUrl = serializers.deserialize(value, - specifiedType: const FullType(String)) as String?; + result.extensionUrl = + serializers.deserialize( + value, + specifiedType: const FullType(String), + ) + as String?; break; case 'isInternalBuild': - result.isInternalBuild = serializers.deserialize(value, - specifiedType: const FullType(bool)) as bool?; + result.isInternalBuild = + serializers.deserialize( + value, + specifiedType: const FullType(bool), + ) + as bool?; break; case 'isFlutterApp': - result.isFlutterApp = serializers.deserialize(value, - specifiedType: const FullType(bool)) as bool?; + result.isFlutterApp = + serializers.deserialize( + value, + specifiedType: const FullType(bool), + ) + as bool?; break; case 'workspaceName': - result.workspaceName = serializers.deserialize(value, - specifiedType: const FullType(String)) as String?; + result.workspaceName = + serializers.deserialize( + value, + specifiedType: const FullType(String), + ) + as String?; break; case 'tabUrl': - result.tabUrl = serializers.deserialize(value, - specifiedType: const FullType(String)) as String?; + result.tabUrl = + serializers.deserialize( + value, + specifiedType: const FullType(String), + ) + as String?; break; case 'tabId': - result.tabId = serializers.deserialize(value, - specifiedType: const FullType(int)) as int?; + result.tabId = + serializers.deserialize(value, specifiedType: const FullType(int)) + as int?; break; } } @@ -213,21 +280,21 @@ class _$DebugInfo extends DebugInfo { factory _$DebugInfo([void Function(DebugInfoBuilder)? updates]) => (new DebugInfoBuilder()..update(updates))._build(); - _$DebugInfo._( - {this.appEntrypointPath, - this.appId, - this.appInstanceId, - this.appOrigin, - this.appUrl, - this.authUrl, - this.dwdsVersion, - this.extensionUrl, - this.isInternalBuild, - this.isFlutterApp, - this.workspaceName, - this.tabUrl, - this.tabId}) - : super._(); + _$DebugInfo._({ + this.appEntrypointPath, + this.appId, + this.appInstanceId, + this.appOrigin, + this.appUrl, + this.authUrl, + this.dwdsVersion, + this.extensionUrl, + this.isInternalBuild, + this.isFlutterApp, + this.workspaceName, + this.tabUrl, + this.tabId, + }) : super._(); @override DebugInfo rebuild(void Function(DebugInfoBuilder) updates) => @@ -392,21 +459,23 @@ class DebugInfoBuilder implements Builder { DebugInfo build() => _build(); _$DebugInfo _build() { - final _$result = _$v ?? + final _$result = + _$v ?? new _$DebugInfo._( - appEntrypointPath: appEntrypointPath, - appId: appId, - appInstanceId: appInstanceId, - appOrigin: appOrigin, - appUrl: appUrl, - authUrl: authUrl, - dwdsVersion: dwdsVersion, - extensionUrl: extensionUrl, - isInternalBuild: isInternalBuild, - isFlutterApp: isFlutterApp, - workspaceName: workspaceName, - tabUrl: tabUrl, - tabId: tabId); + appEntrypointPath: appEntrypointPath, + appId: appId, + appInstanceId: appInstanceId, + appOrigin: appOrigin, + appUrl: appUrl, + authUrl: authUrl, + dwdsVersion: dwdsVersion, + extensionUrl: extensionUrl, + isInternalBuild: isInternalBuild, + isFlutterApp: isFlutterApp, + workspaceName: workspaceName, + tabUrl: tabUrl, + tabId: tabId, + ); replace(_$result); return _$result; } diff --git a/dwds/lib/data/devtools_request.g.dart b/dwds/lib/data/devtools_request.g.dart index dd875b076..10f6ea35c 100644 --- a/dwds/lib/data/devtools_request.g.dart +++ b/dwds/lib/data/devtools_request.g.dart @@ -19,15 +19,22 @@ class _$DevToolsRequestSerializer final String wireName = 'DevToolsRequest'; @override - Iterable serialize(Serializers serializers, DevToolsRequest object, - {FullType specifiedType = FullType.unspecified}) { + Iterable serialize( + Serializers serializers, + DevToolsRequest object, { + FullType specifiedType = FullType.unspecified, + }) { final result = [ 'appId', - serializers.serialize(object.appId, - specifiedType: const FullType(String)), + serializers.serialize( + object.appId, + specifiedType: const FullType(String), + ), 'instanceId', - serializers.serialize(object.instanceId, - specifiedType: const FullType(String)), + serializers.serialize( + object.instanceId, + specifiedType: const FullType(String), + ), ]; Object? value; value = object.contextId; @@ -40,30 +47,35 @@ class _$DevToolsRequestSerializer if (value != null) { result ..add('tabUrl') - ..add(serializers.serialize(value, - specifiedType: const FullType(String))); + ..add( + serializers.serialize(value, specifiedType: const FullType(String)), + ); } value = object.uriOnly; if (value != null) { result ..add('uriOnly') ..add( - serializers.serialize(value, specifiedType: const FullType(bool))); + serializers.serialize(value, specifiedType: const FullType(bool)), + ); } value = object.client; if (value != null) { result ..add('client') - ..add(serializers.serialize(value, - specifiedType: const FullType(String))); + ..add( + serializers.serialize(value, specifiedType: const FullType(String)), + ); } return result; } @override DevToolsRequest deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { final result = new DevToolsRequestBuilder(); final iterator = serialized.iterator; @@ -73,28 +85,49 @@ class _$DevToolsRequestSerializer final Object? value = iterator.current; switch (key) { case 'appId': - result.appId = serializers.deserialize(value, - specifiedType: const FullType(String))! as String; + result.appId = + serializers.deserialize( + value, + specifiedType: const FullType(String), + )! + as String; break; case 'instanceId': - result.instanceId = serializers.deserialize(value, - specifiedType: const FullType(String))! as String; + result.instanceId = + serializers.deserialize( + value, + specifiedType: const FullType(String), + )! + as String; break; case 'contextId': - result.contextId = serializers.deserialize(value, - specifiedType: const FullType(int)) as int?; + result.contextId = + serializers.deserialize(value, specifiedType: const FullType(int)) + as int?; break; case 'tabUrl': - result.tabUrl = serializers.deserialize(value, - specifiedType: const FullType(String)) as String?; + result.tabUrl = + serializers.deserialize( + value, + specifiedType: const FullType(String), + ) + as String?; break; case 'uriOnly': - result.uriOnly = serializers.deserialize(value, - specifiedType: const FullType(bool)) as bool?; + result.uriOnly = + serializers.deserialize( + value, + specifiedType: const FullType(bool), + ) + as bool?; break; case 'client': - result.client = serializers.deserialize(value, - specifiedType: const FullType(String)) as String?; + result.client = + serializers.deserialize( + value, + specifiedType: const FullType(String), + ) + as String?; break; } } @@ -111,31 +144,41 @@ class _$DevToolsResponseSerializer final String wireName = 'DevToolsResponse'; @override - Iterable serialize(Serializers serializers, DevToolsResponse object, - {FullType specifiedType = FullType.unspecified}) { + Iterable serialize( + Serializers serializers, + DevToolsResponse object, { + FullType specifiedType = FullType.unspecified, + }) { final result = [ 'success', - serializers.serialize(object.success, - specifiedType: const FullType(bool)), + serializers.serialize( + object.success, + specifiedType: const FullType(bool), + ), 'promptExtension', - serializers.serialize(object.promptExtension, - specifiedType: const FullType(bool)), + serializers.serialize( + object.promptExtension, + specifiedType: const FullType(bool), + ), ]; Object? value; value = object.error; if (value != null) { result ..add('error') - ..add(serializers.serialize(value, - specifiedType: const FullType(String))); + ..add( + serializers.serialize(value, specifiedType: const FullType(String)), + ); } return result; } @override DevToolsResponse deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { final result = new DevToolsResponseBuilder(); final iterator = serialized.iterator; @@ -145,16 +188,28 @@ class _$DevToolsResponseSerializer final Object? value = iterator.current; switch (key) { case 'success': - result.success = serializers.deserialize(value, - specifiedType: const FullType(bool))! as bool; + result.success = + serializers.deserialize( + value, + specifiedType: const FullType(bool), + )! + as bool; break; case 'promptExtension': - result.promptExtension = serializers.deserialize(value, - specifiedType: const FullType(bool))! as bool; + result.promptExtension = + serializers.deserialize( + value, + specifiedType: const FullType(bool), + )! + as bool; break; case 'error': - result.error = serializers.deserialize(value, - specifiedType: const FullType(String)) as String?; + result.error = + serializers.deserialize( + value, + specifiedType: const FullType(String), + ) + as String?; break; } } @@ -180,17 +235,20 @@ class _$DevToolsRequest extends DevToolsRequest { factory _$DevToolsRequest([void Function(DevToolsRequestBuilder)? updates]) => (new DevToolsRequestBuilder()..update(updates))._build(); - _$DevToolsRequest._( - {required this.appId, - required this.instanceId, - this.contextId, - this.tabUrl, - this.uriOnly, - this.client}) - : super._() { + _$DevToolsRequest._({ + required this.appId, + required this.instanceId, + this.contextId, + this.tabUrl, + this.uriOnly, + this.client, + }) : super._() { BuiltValueNullFieldError.checkNotNull(appId, r'DevToolsRequest', 'appId'); BuiltValueNullFieldError.checkNotNull( - instanceId, r'DevToolsRequest', 'instanceId'); + instanceId, + r'DevToolsRequest', + 'instanceId', + ); } @override @@ -298,16 +356,24 @@ class DevToolsRequestBuilder DevToolsRequest build() => _build(); _$DevToolsRequest _build() { - final _$result = _$v ?? + final _$result = + _$v ?? new _$DevToolsRequest._( - appId: BuiltValueNullFieldError.checkNotNull( - appId, r'DevToolsRequest', 'appId'), - instanceId: BuiltValueNullFieldError.checkNotNull( - instanceId, r'DevToolsRequest', 'instanceId'), - contextId: contextId, - tabUrl: tabUrl, - uriOnly: uriOnly, - client: client); + appId: BuiltValueNullFieldError.checkNotNull( + appId, + r'DevToolsRequest', + 'appId', + ), + instanceId: BuiltValueNullFieldError.checkNotNull( + instanceId, + r'DevToolsRequest', + 'instanceId', + ), + contextId: contextId, + tabUrl: tabUrl, + uriOnly: uriOnly, + client: client, + ); replace(_$result); return _$result; } @@ -321,17 +387,25 @@ class _$DevToolsResponse extends DevToolsResponse { @override final String? error; - factory _$DevToolsResponse( - [void Function(DevToolsResponseBuilder)? updates]) => - (new DevToolsResponseBuilder()..update(updates))._build(); + factory _$DevToolsResponse([ + void Function(DevToolsResponseBuilder)? updates, + ]) => (new DevToolsResponseBuilder()..update(updates))._build(); - _$DevToolsResponse._( - {required this.success, required this.promptExtension, this.error}) - : super._() { + _$DevToolsResponse._({ + required this.success, + required this.promptExtension, + this.error, + }) : super._() { BuiltValueNullFieldError.checkNotNull( - success, r'DevToolsResponse', 'success'); + success, + r'DevToolsResponse', + 'success', + ); BuiltValueNullFieldError.checkNotNull( - promptExtension, r'DevToolsResponse', 'promptExtension'); + promptExtension, + r'DevToolsResponse', + 'promptExtension', + ); } @override @@ -416,13 +490,21 @@ class DevToolsResponseBuilder DevToolsResponse build() => _build(); _$DevToolsResponse _build() { - final _$result = _$v ?? + final _$result = + _$v ?? new _$DevToolsResponse._( - success: BuiltValueNullFieldError.checkNotNull( - success, r'DevToolsResponse', 'success'), - promptExtension: BuiltValueNullFieldError.checkNotNull( - promptExtension, r'DevToolsResponse', 'promptExtension'), - error: error); + success: BuiltValueNullFieldError.checkNotNull( + success, + r'DevToolsResponse', + 'success', + ), + promptExtension: BuiltValueNullFieldError.checkNotNull( + promptExtension, + r'DevToolsResponse', + 'promptExtension', + ), + error: error, + ); replace(_$result); return _$result; } diff --git a/dwds/lib/data/error_response.g.dart b/dwds/lib/data/error_response.g.dart index f4a4f64d9..ad9bef755 100644 --- a/dwds/lib/data/error_response.g.dart +++ b/dwds/lib/data/error_response.g.dart @@ -16,15 +16,22 @@ class _$ErrorResponseSerializer implements StructuredSerializer { final String wireName = 'ErrorResponse'; @override - Iterable serialize(Serializers serializers, ErrorResponse object, - {FullType specifiedType = FullType.unspecified}) { + Iterable serialize( + Serializers serializers, + ErrorResponse object, { + FullType specifiedType = FullType.unspecified, + }) { final result = [ 'error', - serializers.serialize(object.error, - specifiedType: const FullType(String)), + serializers.serialize( + object.error, + specifiedType: const FullType(String), + ), 'stackTrace', - serializers.serialize(object.stackTrace, - specifiedType: const FullType(String)), + serializers.serialize( + object.stackTrace, + specifiedType: const FullType(String), + ), ]; return result; @@ -32,8 +39,10 @@ class _$ErrorResponseSerializer implements StructuredSerializer { @override ErrorResponse deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { final result = new ErrorResponseBuilder(); final iterator = serialized.iterator; @@ -43,12 +52,20 @@ class _$ErrorResponseSerializer implements StructuredSerializer { final Object? value = iterator.current; switch (key) { case 'error': - result.error = serializers.deserialize(value, - specifiedType: const FullType(String))! as String; + result.error = + serializers.deserialize( + value, + specifiedType: const FullType(String), + )! + as String; break; case 'stackTrace': - result.stackTrace = serializers.deserialize(value, - specifiedType: const FullType(String))! as String; + result.stackTrace = + serializers.deserialize( + value, + specifiedType: const FullType(String), + )! + as String; break; } } @@ -67,10 +84,13 @@ class _$ErrorResponse extends ErrorResponse { (new ErrorResponseBuilder()..update(updates))._build(); _$ErrorResponse._({required this.error, required this.stackTrace}) - : super._() { + : super._() { BuiltValueNullFieldError.checkNotNull(error, r'ErrorResponse', 'error'); BuiltValueNullFieldError.checkNotNull( - stackTrace, r'ErrorResponse', 'stackTrace'); + stackTrace, + r'ErrorResponse', + 'stackTrace', + ); } @override @@ -145,12 +165,20 @@ class ErrorResponseBuilder ErrorResponse build() => _build(); _$ErrorResponse _build() { - final _$result = _$v ?? + final _$result = + _$v ?? new _$ErrorResponse._( - error: BuiltValueNullFieldError.checkNotNull( - error, r'ErrorResponse', 'error'), - stackTrace: BuiltValueNullFieldError.checkNotNull( - stackTrace, r'ErrorResponse', 'stackTrace')); + error: BuiltValueNullFieldError.checkNotNull( + error, + r'ErrorResponse', + 'error', + ), + stackTrace: BuiltValueNullFieldError.checkNotNull( + stackTrace, + r'ErrorResponse', + 'stackTrace', + ), + ); replace(_$result); return _$result; } diff --git a/dwds/lib/data/extension_request.g.dart b/dwds/lib/data/extension_request.g.dart index d5bf59189..98a8a8da2 100644 --- a/dwds/lib/data/extension_request.g.dart +++ b/dwds/lib/data/extension_request.g.dart @@ -23,30 +23,38 @@ class _$ExtensionRequestSerializer final String wireName = 'ExtensionRequest'; @override - Iterable serialize(Serializers serializers, ExtensionRequest object, - {FullType specifiedType = FullType.unspecified}) { + Iterable serialize( + Serializers serializers, + ExtensionRequest object, { + FullType specifiedType = FullType.unspecified, + }) { final result = [ 'id', serializers.serialize(object.id, specifiedType: const FullType(int)), 'command', - serializers.serialize(object.command, - specifiedType: const FullType(String)), + serializers.serialize( + object.command, + specifiedType: const FullType(String), + ), ]; Object? value; value = object.commandParams; if (value != null) { result ..add('commandParams') - ..add(serializers.serialize(value, - specifiedType: const FullType(String))); + ..add( + serializers.serialize(value, specifiedType: const FullType(String)), + ); } return result; } @override ExtensionRequest deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { final result = new ExtensionRequestBuilder(); final iterator = serialized.iterator; @@ -56,16 +64,28 @@ class _$ExtensionRequestSerializer final Object? value = iterator.current; switch (key) { case 'id': - result.id = serializers.deserialize(value, - specifiedType: const FullType(int))! as int; + result.id = + serializers.deserialize( + value, + specifiedType: const FullType(int), + )! + as int; break; case 'command': - result.command = serializers.deserialize(value, - specifiedType: const FullType(String))! as String; + result.command = + serializers.deserialize( + value, + specifiedType: const FullType(String), + )! + as String; break; case 'commandParams': - result.commandParams = serializers.deserialize(value, - specifiedType: const FullType(String)) as String?; + result.commandParams = + serializers.deserialize( + value, + specifiedType: const FullType(String), + ) + as String?; break; } } @@ -82,33 +102,43 @@ class _$ExtensionResponseSerializer final String wireName = 'ExtensionResponse'; @override - Iterable serialize(Serializers serializers, ExtensionResponse object, - {FullType specifiedType = FullType.unspecified}) { + Iterable serialize( + Serializers serializers, + ExtensionResponse object, { + FullType specifiedType = FullType.unspecified, + }) { final result = [ 'id', serializers.serialize(object.id, specifiedType: const FullType(int)), 'success', - serializers.serialize(object.success, - specifiedType: const FullType(bool)), + serializers.serialize( + object.success, + specifiedType: const FullType(bool), + ), 'result', - serializers.serialize(object.result, - specifiedType: const FullType(String)), + serializers.serialize( + object.result, + specifiedType: const FullType(String), + ), ]; Object? value; value = object.error; if (value != null) { result ..add('error') - ..add(serializers.serialize(value, - specifiedType: const FullType(String))); + ..add( + serializers.serialize(value, specifiedType: const FullType(String)), + ); } return result; } @override ExtensionResponse deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { final result = new ExtensionResponseBuilder(); final iterator = serialized.iterator; @@ -118,20 +148,36 @@ class _$ExtensionResponseSerializer final Object? value = iterator.current; switch (key) { case 'id': - result.id = serializers.deserialize(value, - specifiedType: const FullType(int))! as int; + result.id = + serializers.deserialize( + value, + specifiedType: const FullType(int), + )! + as int; break; case 'success': - result.success = serializers.deserialize(value, - specifiedType: const FullType(bool))! as bool; + result.success = + serializers.deserialize( + value, + specifiedType: const FullType(bool), + )! + as bool; break; case 'result': - result.result = serializers.deserialize(value, - specifiedType: const FullType(String))! as String; + result.result = + serializers.deserialize( + value, + specifiedType: const FullType(String), + )! + as String; break; case 'error': - result.error = serializers.deserialize(value, - specifiedType: const FullType(String)) as String?; + result.error = + serializers.deserialize( + value, + specifiedType: const FullType(String), + ) + as String?; break; } } @@ -148,15 +194,22 @@ class _$ExtensionEventSerializer final String wireName = 'ExtensionEvent'; @override - Iterable serialize(Serializers serializers, ExtensionEvent object, - {FullType specifiedType = FullType.unspecified}) { + Iterable serialize( + Serializers serializers, + ExtensionEvent object, { + FullType specifiedType = FullType.unspecified, + }) { final result = [ 'params', - serializers.serialize(object.params, - specifiedType: const FullType(String)), + serializers.serialize( + object.params, + specifiedType: const FullType(String), + ), 'method', - serializers.serialize(object.method, - specifiedType: const FullType(String)), + serializers.serialize( + object.method, + specifiedType: const FullType(String), + ), ]; return result; @@ -164,8 +217,10 @@ class _$ExtensionEventSerializer @override ExtensionEvent deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { final result = new ExtensionEventBuilder(); final iterator = serialized.iterator; @@ -175,12 +230,20 @@ class _$ExtensionEventSerializer final Object? value = iterator.current; switch (key) { case 'params': - result.params = serializers.deserialize(value, - specifiedType: const FullType(String))! as String; + result.params = + serializers.deserialize( + value, + specifiedType: const FullType(String), + )! + as String; break; case 'method': - result.method = serializers.deserialize(value, - specifiedType: const FullType(String))! as String; + result.method = + serializers.deserialize( + value, + specifiedType: const FullType(String), + )! + as String; break; } } @@ -196,13 +259,19 @@ class _$BatchedEventsSerializer implements StructuredSerializer { final String wireName = 'BatchedEvents'; @override - Iterable serialize(Serializers serializers, BatchedEvents object, - {FullType specifiedType = FullType.unspecified}) { + Iterable serialize( + Serializers serializers, + BatchedEvents object, { + FullType specifiedType = FullType.unspecified, + }) { final result = [ 'events', - serializers.serialize(object.events, - specifiedType: const FullType( - BuiltList, const [const FullType(ExtensionEvent)])), + serializers.serialize( + object.events, + specifiedType: const FullType(BuiltList, const [ + const FullType(ExtensionEvent), + ]), + ), ]; return result; @@ -210,8 +279,10 @@ class _$BatchedEventsSerializer implements StructuredSerializer { @override BatchedEvents deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { final result = new BatchedEventsBuilder(); final iterator = serialized.iterator; @@ -221,10 +292,15 @@ class _$BatchedEventsSerializer implements StructuredSerializer { final Object? value = iterator.current; switch (key) { case 'events': - result.events.replace(serializers.deserialize(value, - specifiedType: const FullType( - BuiltList, const [const FullType(ExtensionEvent)]))! - as BuiltList); + result.events.replace( + serializers.deserialize( + value, + specifiedType: const FullType(BuiltList, const [ + const FullType(ExtensionEvent), + ]), + )! + as BuiltList, + ); break; } } @@ -241,16 +317,21 @@ class _$ExtensionRequest extends ExtensionRequest { @override final String? commandParams; - factory _$ExtensionRequest( - [void Function(ExtensionRequestBuilder)? updates]) => - (new ExtensionRequestBuilder()..update(updates))._build(); + factory _$ExtensionRequest([ + void Function(ExtensionRequestBuilder)? updates, + ]) => (new ExtensionRequestBuilder()..update(updates))._build(); - _$ExtensionRequest._( - {required this.id, required this.command, this.commandParams}) - : super._() { + _$ExtensionRequest._({ + required this.id, + required this.command, + this.commandParams, + }) : super._() { BuiltValueNullFieldError.checkNotNull(id, r'ExtensionRequest', 'id'); BuiltValueNullFieldError.checkNotNull( - command, r'ExtensionRequest', 'command'); + command, + r'ExtensionRequest', + 'command', + ); } @override @@ -335,13 +416,21 @@ class ExtensionRequestBuilder ExtensionRequest build() => _build(); _$ExtensionRequest _build() { - final _$result = _$v ?? + final _$result = + _$v ?? new _$ExtensionRequest._( - id: BuiltValueNullFieldError.checkNotNull( - id, r'ExtensionRequest', 'id'), - command: BuiltValueNullFieldError.checkNotNull( - command, r'ExtensionRequest', 'command'), - commandParams: commandParams); + id: BuiltValueNullFieldError.checkNotNull( + id, + r'ExtensionRequest', + 'id', + ), + command: BuiltValueNullFieldError.checkNotNull( + command, + r'ExtensionRequest', + 'command', + ), + commandParams: commandParams, + ); replace(_$result); return _$result; } @@ -357,21 +446,27 @@ class _$ExtensionResponse extends ExtensionResponse { @override final String? error; - factory _$ExtensionResponse( - [void Function(ExtensionResponseBuilder)? updates]) => - (new ExtensionResponseBuilder()..update(updates))._build(); + factory _$ExtensionResponse([ + void Function(ExtensionResponseBuilder)? updates, + ]) => (new ExtensionResponseBuilder()..update(updates))._build(); - _$ExtensionResponse._( - {required this.id, - required this.success, - required this.result, - this.error}) - : super._() { + _$ExtensionResponse._({ + required this.id, + required this.success, + required this.result, + this.error, + }) : super._() { BuiltValueNullFieldError.checkNotNull(id, r'ExtensionResponse', 'id'); BuiltValueNullFieldError.checkNotNull( - success, r'ExtensionResponse', 'success'); + success, + r'ExtensionResponse', + 'success', + ); BuiltValueNullFieldError.checkNotNull( - result, r'ExtensionResponse', 'result'); + result, + r'ExtensionResponse', + 'result', + ); } @override @@ -463,15 +558,26 @@ class ExtensionResponseBuilder ExtensionResponse build() => _build(); _$ExtensionResponse _build() { - final _$result = _$v ?? + final _$result = + _$v ?? new _$ExtensionResponse._( - id: BuiltValueNullFieldError.checkNotNull( - id, r'ExtensionResponse', 'id'), - success: BuiltValueNullFieldError.checkNotNull( - success, r'ExtensionResponse', 'success'), - result: BuiltValueNullFieldError.checkNotNull( - result, r'ExtensionResponse', 'result'), - error: error); + id: BuiltValueNullFieldError.checkNotNull( + id, + r'ExtensionResponse', + 'id', + ), + success: BuiltValueNullFieldError.checkNotNull( + success, + r'ExtensionResponse', + 'success', + ), + result: BuiltValueNullFieldError.checkNotNull( + result, + r'ExtensionResponse', + 'result', + ), + error: error, + ); replace(_$result); return _$result; } @@ -564,12 +670,20 @@ class ExtensionEventBuilder ExtensionEvent build() => _build(); _$ExtensionEvent _build() { - final _$result = _$v ?? + final _$result = + _$v ?? new _$ExtensionEvent._( - params: BuiltValueNullFieldError.checkNotNull( - params, r'ExtensionEvent', 'params'), - method: BuiltValueNullFieldError.checkNotNull( - method, r'ExtensionEvent', 'method')); + params: BuiltValueNullFieldError.checkNotNull( + params, + r'ExtensionEvent', + 'params', + ), + method: BuiltValueNullFieldError.checkNotNull( + method, + r'ExtensionEvent', + 'method', + ), + ); replace(_$result); return _$result; } @@ -610,8 +724,7 @@ class _$BatchedEvents extends BatchedEvents { @override String toString() { return (newBuiltValueToStringHelper(r'BatchedEvents') - ..add('events', events)) - .toString(); + ..add('events', events)).toString(); } } @@ -660,7 +773,10 @@ class BatchedEventsBuilder events.build(); } catch (e) { throw new BuiltValueNestedFieldError( - r'BatchedEvents', _$failedField, e.toString()); + r'BatchedEvents', + _$failedField, + e.toString(), + ); } rethrow; } diff --git a/dwds/lib/data/isolate_events.g.dart b/dwds/lib/data/isolate_events.g.dart index 68eed3714..b6c99bfe9 100644 --- a/dwds/lib/data/isolate_events.g.dart +++ b/dwds/lib/data/isolate_events.g.dart @@ -17,14 +17,20 @@ class _$IsolateExitSerializer implements StructuredSerializer { final String wireName = 'IsolateExit'; @override - Iterable serialize(Serializers serializers, IsolateExit object, - {FullType specifiedType = FullType.unspecified}) { + Iterable serialize( + Serializers serializers, + IsolateExit object, { + FullType specifiedType = FullType.unspecified, + }) { return []; } @override - IsolateExit deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { + IsolateExit deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { return new IsolateExitBuilder().build(); } } @@ -36,15 +42,20 @@ class _$IsolateStartSerializer implements StructuredSerializer { final String wireName = 'IsolateStart'; @override - Iterable serialize(Serializers serializers, IsolateStart object, - {FullType specifiedType = FullType.unspecified}) { + Iterable serialize( + Serializers serializers, + IsolateStart object, { + FullType specifiedType = FullType.unspecified, + }) { return []; } @override IsolateStart deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { return new IsolateStartBuilder().build(); } } diff --git a/dwds/lib/data/register_event.g.dart b/dwds/lib/data/register_event.g.dart index 3fd21dadc..6674c8e5f 100644 --- a/dwds/lib/data/register_event.g.dart +++ b/dwds/lib/data/register_event.g.dart @@ -16,15 +16,22 @@ class _$RegisterEventSerializer implements StructuredSerializer { final String wireName = 'RegisterEvent'; @override - Iterable serialize(Serializers serializers, RegisterEvent object, - {FullType specifiedType = FullType.unspecified}) { + Iterable serialize( + Serializers serializers, + RegisterEvent object, { + FullType specifiedType = FullType.unspecified, + }) { final result = [ 'eventData', - serializers.serialize(object.eventData, - specifiedType: const FullType(String)), + serializers.serialize( + object.eventData, + specifiedType: const FullType(String), + ), 'timestamp', - serializers.serialize(object.timestamp, - specifiedType: const FullType(int)), + serializers.serialize( + object.timestamp, + specifiedType: const FullType(int), + ), ]; return result; @@ -32,8 +39,10 @@ class _$RegisterEventSerializer implements StructuredSerializer { @override RegisterEvent deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { final result = new RegisterEventBuilder(); final iterator = serialized.iterator; @@ -43,12 +52,20 @@ class _$RegisterEventSerializer implements StructuredSerializer { final Object? value = iterator.current; switch (key) { case 'eventData': - result.eventData = serializers.deserialize(value, - specifiedType: const FullType(String))! as String; + result.eventData = + serializers.deserialize( + value, + specifiedType: const FullType(String), + )! + as String; break; case 'timestamp': - result.timestamp = serializers.deserialize(value, - specifiedType: const FullType(int))! as int; + result.timestamp = + serializers.deserialize( + value, + specifiedType: const FullType(int), + )! + as int; break; } } @@ -67,11 +84,17 @@ class _$RegisterEvent extends RegisterEvent { (new RegisterEventBuilder()..update(updates))._build(); _$RegisterEvent._({required this.eventData, required this.timestamp}) - : super._() { + : super._() { BuiltValueNullFieldError.checkNotNull( - eventData, r'RegisterEvent', 'eventData'); + eventData, + r'RegisterEvent', + 'eventData', + ); BuiltValueNullFieldError.checkNotNull( - timestamp, r'RegisterEvent', 'timestamp'); + timestamp, + r'RegisterEvent', + 'timestamp', + ); } @override @@ -146,12 +169,20 @@ class RegisterEventBuilder RegisterEvent build() => _build(); _$RegisterEvent _build() { - final _$result = _$v ?? + final _$result = + _$v ?? new _$RegisterEvent._( - eventData: BuiltValueNullFieldError.checkNotNull( - eventData, r'RegisterEvent', 'eventData'), - timestamp: BuiltValueNullFieldError.checkNotNull( - timestamp, r'RegisterEvent', 'timestamp')); + eventData: BuiltValueNullFieldError.checkNotNull( + eventData, + r'RegisterEvent', + 'eventData', + ), + timestamp: BuiltValueNullFieldError.checkNotNull( + timestamp, + r'RegisterEvent', + 'timestamp', + ), + ); replace(_$result); return _$result; } diff --git a/dwds/lib/data/run_request.g.dart b/dwds/lib/data/run_request.g.dart index ed2202c55..a30ad26f4 100644 --- a/dwds/lib/data/run_request.g.dart +++ b/dwds/lib/data/run_request.g.dart @@ -15,14 +15,20 @@ class _$RunRequestSerializer implements StructuredSerializer { final String wireName = 'RunRequest'; @override - Iterable serialize(Serializers serializers, RunRequest object, - {FullType specifiedType = FullType.unspecified}) { + Iterable serialize( + Serializers serializers, + RunRequest object, { + FullType specifiedType = FullType.unspecified, + }) { return []; } @override - RunRequest deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { + RunRequest deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { return new RunRequestBuilder().build(); } } diff --git a/dwds/lib/data/serializers.g.dart b/dwds/lib/data/serializers.g.dart index 584ce7e34..985acd6f1 100644 --- a/dwds/lib/data/serializers.g.dart +++ b/dwds/lib/data/serializers.g.dart @@ -6,30 +6,33 @@ part of 'serializers.dart'; // BuiltValueGenerator // ************************************************************************** -Serializers _$serializers = (new Serializers().toBuilder() - ..add(BatchedDebugEvents.serializer) - ..add(BatchedEvents.serializer) - ..add(BuildResult.serializer) - ..add(BuildStatus.serializer) - ..add(ConnectRequest.serializer) - ..add(DebugEvent.serializer) - ..add(DebugInfo.serializer) - ..add(DevToolsRequest.serializer) - ..add(DevToolsResponse.serializer) - ..add(ErrorResponse.serializer) - ..add(ExtensionEvent.serializer) - ..add(ExtensionRequest.serializer) - ..add(ExtensionResponse.serializer) - ..add(IsolateExit.serializer) - ..add(IsolateStart.serializer) - ..add(RegisterEvent.serializer) - ..add(RunRequest.serializer) - ..addBuilderFactory( - const FullType(BuiltList, const [const FullType(DebugEvent)]), - () => new ListBuilder()) - ..addBuilderFactory( - const FullType(BuiltList, const [const FullType(ExtensionEvent)]), - () => new ListBuilder())) - .build(); +Serializers _$serializers = + (new Serializers().toBuilder() + ..add(BatchedDebugEvents.serializer) + ..add(BatchedEvents.serializer) + ..add(BuildResult.serializer) + ..add(BuildStatus.serializer) + ..add(ConnectRequest.serializer) + ..add(DebugEvent.serializer) + ..add(DebugInfo.serializer) + ..add(DevToolsRequest.serializer) + ..add(DevToolsResponse.serializer) + ..add(ErrorResponse.serializer) + ..add(ExtensionEvent.serializer) + ..add(ExtensionRequest.serializer) + ..add(ExtensionResponse.serializer) + ..add(IsolateExit.serializer) + ..add(IsolateStart.serializer) + ..add(RegisterEvent.serializer) + ..add(RunRequest.serializer) + ..addBuilderFactory( + const FullType(BuiltList, const [const FullType(DebugEvent)]), + () => new ListBuilder(), + ) + ..addBuilderFactory( + const FullType(BuiltList, const [const FullType(ExtensionEvent)]), + () => new ListBuilder(), + )) + .build(); // ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/dwds/lib/shared/batched_stream.dart b/dwds/lib/shared/batched_stream.dart index 7237246dc..b35592e46 100644 --- a/dwds/lib/shared/batched_stream.dart +++ b/dwds/lib/shared/batched_stream.dart @@ -24,12 +24,11 @@ class BatchedStreamController { /// /// Collects events from input [sink] and emits them in batches to the /// output [stream] every [delay] milliseconds. Keeps the original order. - BatchedStreamController({ - int delay = _defaultBatchDelayMilliseconds, - }) : _batchDelayMilliseconds = delay, - _checkDelayMilliseconds = max(delay ~/ 10, 1), - _inputController = StreamController(), - _outputController = StreamController>() { + BatchedStreamController({int delay = _defaultBatchDelayMilliseconds}) + : _batchDelayMilliseconds = delay, + _checkDelayMilliseconds = max(delay ~/ 10, 1), + _inputController = StreamController(), + _outputController = StreamController>() { _inputQueue = StreamQueue(_inputController.stream); safeUnawaited(_batchAndSendEvents()); } diff --git a/dwds/lib/src/connections/debug_connection.dart b/dwds/lib/src/connections/debug_connection.dart index 227404031..271331eb3 100644 --- a/dwds/lib/src/connections/debug_connection.dart +++ b/dwds/lib/src/connections/debug_connection.dart @@ -39,7 +39,8 @@ class DebugConnection { /// A client of the Dart VM Service with DWDS specific extensions. VmService get vmService => _appDebugServices.dwdsVmClient.client; - Future close() => _closed ??= () async { + Future close() => + _closed ??= () async { await _appDebugServices.chromeProxyService.remoteDebugger.close(); await _appDebugServices.close(); _onDoneCompleter.complete(); diff --git a/dwds/lib/src/debugging/classes.dart b/dwds/lib/src/debugging/classes.dart index 72d2f467d..b5b814661 100644 --- a/dwds/lib/src/debugging/classes.dart +++ b/dwds/lib/src/debugging/classes.dart @@ -141,9 +141,10 @@ class ClassHelper extends Domain { final superClassLibraryId = classDescriptor['superClassLibraryId']; final superClassName = classDescriptor['superClassName']; - final superClassRef = superClassName == null - ? null - : classRefFor(superClassLibraryId, superClassName); + final superClassRef = + superClassName == null + ? null + : classRefFor(superClassLibraryId, superClassName); // TODO: Implement the rest of these // https://github.com/dart-lang/webdev/issues/176. diff --git a/dwds/lib/src/debugging/dart_runtime_debugger.dart b/dwds/lib/src/debugging/dart_runtime_debugger.dart index bc0d79a9b..1f0f4582b 100644 --- a/dwds/lib/src/debugging/dart_runtime_debugger.dart +++ b/dwds/lib/src/debugging/dart_runtime_debugger.dart @@ -11,15 +11,14 @@ class DartRuntimeDebugger { DartRuntimeDebugger({ required LoadStrategy loadStrategy, required bool useLibraryBundleExpression, - }) : _loadStrategy = loadStrategy, - _useLibraryBundleExpression = useLibraryBundleExpression; + }) : _loadStrategy = loadStrategy, + _useLibraryBundleExpression = useLibraryBundleExpression; /// Generates a JS expression based on DDC module format. String _generateJsExpression( String ddcExpression, String libraryBundleExpression, - ) => - _useLibraryBundleExpression ? libraryBundleExpression : ddcExpression; + ) => _useLibraryBundleExpression ? libraryBundleExpression : ddcExpression; /// Wraps a JS function call with SDK loader logic. String _wrapWithSdkLoader(String args, String functionCall) { @@ -126,11 +125,7 @@ class DartRuntimeDebugger { /// Generates a JS expression for retrieving map elements. String getMapElementsJsExpression() { - return _buildExpression( - '', - 'getMapElements(this)', - 'getMapElements(this)', - ); + return _buildExpression('', 'getMapElements(this)', 'getMapElements(this)'); } /// Generates a JS expression for getting a property from a JS object. @@ -151,11 +146,7 @@ class DartRuntimeDebugger { /// Generates a JS expression for retrieving set elements. String getSetElementsJsExpression() { - return _buildExpression( - '', - 'getSetElements(this)', - 'getSetElements(this)', - ); + return _buildExpression('', 'getSetElements(this)', 'getSetElements(this)'); } /// Generates a JS expression for retrieving the fields of a record. @@ -206,10 +197,7 @@ class DartRuntimeDebugger { } /// Generates a JS expression for calling a library method. - String callLibraryMethodJsExpression( - String libraryUri, - String methodName, - ) { + String callLibraryMethodJsExpression(String libraryUri, String methodName) { final findLibraryExpression = ''' (function() { const sdk = ${_loadStrategy.loadModuleSnippet}('dart_sdk'); diff --git a/dwds/lib/src/debugging/dart_scope.dart b/dwds/lib/src/debugging/dart_scope.dart index 8183be19d..7be5ad229 100644 --- a/dwds/lib/src/debugging/dart_scope.dart +++ b/dwds/lib/src/debugging/dart_scope.dart @@ -13,20 +13,22 @@ import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart'; /// synthetic variables. /// Issue: https://github.com/dart-lang/sdk/issues/44262 final ddcTemporaryVariableRegExp = RegExp( - // Starts with t$ - r'^t\$' - // followed by anything - r'.*' - // or, - r'|' - // anything that contains the sequence '$35'. - r'.*\$35.*'); + // Starts with t$ + r'^t\$' + // followed by anything + r'.*' + // or, + r'|' + // anything that contains the sequence '$35'. + r'.*\$35.*', +); final ddcTemporaryTypeVariableRegExp = RegExp(r'^__t[\$\w*]+$'); /// Temporary variable regex before SDK changes for patterns. /// TODO(annagrin): remove after dart 3.0 is stable. -final previousDdcTemporaryVariableRegExp = - RegExp(r'^(t[0-9]+\$?[0-9]*|__t[\$\w*]+)$'); +final previousDdcTemporaryVariableRegExp = RegExp( + r'^(t[0-9]+\$?[0-9]*|__t[\$\w*]+)$', +); const ddcAsyncScope = 'asyncScope'; const ddcCapturedAsyncScope = 'capturedAsyncScope'; @@ -42,12 +44,7 @@ Future> visibleVariables({ final allProperties = []; if (frame.thisObject.type != 'undefined') { - allProperties.add( - Property({ - 'name': 'this', - 'value': frame.thisObject, - }), - ); + allProperties.add(Property({'name': 'this', 'value': frame.thisObject})); } // TODO: Try and populate all the property info for the scopes in one backend @@ -65,12 +62,7 @@ Future> visibleVariables({ } if (frame.returnValue != null && frame.returnValue!.type != 'undefined') { - allProperties.add( - Property({ - 'name': 'return', - 'value': frame.returnValue, - }), - ); + allProperties.add(Property({'name': 'return', 'value': frame.returnValue})); } // DDC's async lowering hoists variable declarations into scope objects. We @@ -82,8 +74,9 @@ Future> visibleVariables({ // available properties to recreate the Dart context at any given point. final capturedAsyncScopes = [ - ...allProperties - .where((p) => p.name?.startsWith(ddcCapturedAsyncScope) ?? false), + ...allProperties.where( + (p) => p.name?.startsWith(ddcCapturedAsyncScope) ?? false, + ), ]; if (capturedAsyncScopes.isNotEmpty) { @@ -142,8 +135,8 @@ Future> visibleVariables({ List filterScopes(WipCallFrame frame) { final scopes = frame.getScopeChain().toList(); // Remove outer scopes up to and including the Dart SDK. - while ( - scopes.isNotEmpty && !(scopes.last.name?.startsWith('load__') ?? false)) { + while (scopes.isNotEmpty && + !(scopes.last.name?.startsWith('load__') ?? false)) { scopes.removeLast(); } if (scopes.isNotEmpty) scopes.removeLast(); diff --git a/dwds/lib/src/debugging/debugger.dart b/dwds/lib/src/debugging/debugger.dart index 321357120..2a638dae7 100644 --- a/dwds/lib/src/debugging/debugger.dart +++ b/dwds/lib/src/debugging/debugger.dart @@ -63,10 +63,10 @@ class Debugger extends Domain { this._skipLists, root, ) : _breakpoints = _Breakpoints( - locations: _locations, - remoteDebugger: _remoteDebugger, - root: root, - ); + locations: _locations, + remoteDebugger: _remoteDebugger, + root: root, + ); /// The breakpoints we have set so far, indexable by either /// Dart or JS ID. @@ -79,9 +79,10 @@ class Debugger extends Domain { // DevTools is showing an overlay. Both cannot be shown at the same time: // bool _pausedOverlayVisible = false; - String get pauseState => _pauseModePauseStates.entries - .firstWhere((entry) => entry.value == _pauseState) - .key; + String get pauseState => + _pauseModePauseStates.entries + .firstWhere((entry) => entry.value == _pauseState) + .key; /// The JS frames at the current paused location. /// @@ -216,14 +217,17 @@ class Debugger extends Domain { // We must add a listener before enabling the debugger otherwise we will // miss events. // Allow a null debugger/connection for unit tests. - runZonedGuarded(() { - _remoteDebugger.onScriptParsed.listen(_scriptParsedHandler); - _remoteDebugger.onPaused.listen(_pauseHandler); - _remoteDebugger.onResumed.listen(_resumeHandler); - _remoteDebugger.onTargetCrashed.listen(_crashHandler); - }, (e, StackTrace s) { - logger.warning('Error handling Chrome event', e, s); - }); + runZonedGuarded( + () { + _remoteDebugger.onScriptParsed.listen(_scriptParsedHandler); + _remoteDebugger.onPaused.listen(_pauseHandler); + _remoteDebugger.onResumed.listen(_resumeHandler); + _remoteDebugger.onTargetCrashed.listen(_crashHandler); + }, + (e, StackTrace s) { + logger.warning('Error handling Chrome event', e, s); + }, + ); handleErrorIfPresent(await _remoteDebugger.enablePage()); await _remoteDebugger.enable(); @@ -232,9 +236,7 @@ class Debugger extends Domain { handleErrorIfPresent( await _remoteDebugger.sendCommand( 'Debugger.setAsyncCallStackDepth', - params: { - 'maxDepth': 128, - }, + params: {'maxDepth': 128}, ), ); } @@ -354,11 +356,11 @@ class Debugger extends Domain { /// The variables visible in a frame in Dart protocol [BoundVariable] form. Future> variablesFor(WipCallFrame frame) async { // TODO(alanknight): Can these be moved to dart_scope.dart? - final properties = - await visibleVariables(inspector: inspector, frame: frame); - final boundVariables = await Future.wait( - properties.map(_boundVariable), + final properties = await visibleVariables( + inspector: inspector, + frame: frame, ); + final boundVariables = await Future.wait(properties.map(_boundVariable)); // Filter out variables that do not come from dart code, such as native // JavaScript objects @@ -428,16 +430,19 @@ class Debugger extends Domain { final url = urlForScriptId(location.scriptId); if (url == null) { - logger.fine('Failed to create dart frame for ${frame.functionName}: ' - 'cannot find url for script ${location.scriptId}'); + logger.fine( + 'Failed to create dart frame for ${frame.functionName}: ' + 'cannot find url for script ${location.scriptId}', + ); return null; } final bestLocation = await _locations.locationForJs(url, line, column ?? 0); if (bestLocation == null) return null; - final script = - await inspector.scriptRefFor(bestLocation.dartLocation.uri.serverPath); + final script = await inspector.scriptRefFor( + bestLocation.dartLocation.uri.serverPath, + ); // We think we found a location, but for some reason we can't find the // script. Just drop the frame. // TODO(#700): Understand when this can happen and have a better fix. @@ -448,11 +453,7 @@ class Debugger extends Domain { final dartFrame = Frame( index: frameIndex, - code: CodeRef( - name: codeRefName, - kind: CodeKind.kDart, - id: createId(), - ), + code: CodeRef(name: codeRefName, kind: CodeKind.kDart, id: createId()), location: SourceLocation( line: bestLocation.dartLocation.line, column: bestLocation.dartLocation.column, @@ -516,15 +517,17 @@ class Debugger extends Domain { final timestamp = DateTime.now().millisecondsSinceEpoch; final jsBreakpointIds = e.hitBreakpoints ?? []; if (jsBreakpointIds.isNotEmpty) { - final breakpointIds = jsBreakpointIds - .map((id) => _breakpoints._dartIdByJsId[id]) - // In case the breakpoint was set in Chrome DevTools outside of - // package:dwds. - .where((entry) => entry != null) - .toSet(); - final pauseBreakpoints = isolate.breakpoints - ?.where((bp) => breakpointIds.contains(bp.id)) - .toList(); + final breakpointIds = + jsBreakpointIds + .map((id) => _breakpoints._dartIdByJsId[id]) + // In case the breakpoint was set in Chrome DevTools outside of + // package:dwds. + .where((entry) => entry != null) + .toSet(); + final pauseBreakpoints = + isolate.breakpoints + ?.where((bp) => breakpointIds.contains(bp.id)) + .toList(); event = Event( kind: EventKind.kPauseBreakpoint, timestamp: timestamp, @@ -541,8 +544,9 @@ class Debugger extends Domain { if (exception != null && inspector.isNativeJsError(exception)) { if (obj.description != null) { // Create a string exception object. - final description = - await inspector.mapExceptionStackTrace(obj.description!); + final description = await inspector.mapExceptionStackTrace( + obj.description!, + ); exception = await inspector.instanceRefFor(description); } else { exception = null; @@ -563,14 +567,18 @@ class Debugger extends Domain { if (_isStepping) { final scriptId = _frameScriptId(e); if (scriptId == null) { - logger.severe('Stepping failed: ' - 'cannot find script id for event $e'); + logger.severe( + 'Stepping failed: ' + 'cannot find script id for event $e', + ); throw StateError('Stepping failed on event $e'); } final url = urlForScriptId(scriptId); if (url == null) { - logger.severe('Stepping failed: ' - 'cannot find url for script $scriptId'); + logger.severe( + 'Stepping failed: ' + 'cannot find url for script $scriptId', + ); throw StateError('Stepping failed in script $scriptId'); } @@ -700,10 +708,7 @@ class Debugger extends Domain { try { return await _remoteDebugger.evaluateOnCallFrame(callFrameId, expression); } on ExceptionDetails catch (e) { - throw ChromeDebugException( - e.json, - evalContents: expression, - ); + throw ChromeDebugException(e.json, evalContents: expression); } } } @@ -769,30 +774,36 @@ class _Breakpoints extends Domain { } // TODO: Handle cases where a breakpoint can't be set exactly at that line. if (location == null) { - _logger.fine('Failed to set breakpoint $id ' - '($scriptId:$line:$column): ' - 'cannot find Dart location.'); + _logger.fine( + 'Failed to set breakpoint $id ' + '($scriptId:$line:$column): ' + 'cannot find Dart location.', + ); throw RPCError( - 'addBreakpoint', - 102, - 'The VM is unable to add a breakpoint $id ' - 'at the specified line or function: ($scriptId:$line:$column): ' - ' cannot find Dart location.'); + 'addBreakpoint', + 102, + 'The VM is unable to add a breakpoint $id ' + 'at the specified line or function: ($scriptId:$line:$column): ' + ' cannot find Dart location.', + ); } try { final dartBreakpoint = _dartBreakpoint(dartScript!, location, id); final jsBreakpointId = await _setJsBreakpoint(location); if (jsBreakpointId == null) { - _logger.fine('Failed to set breakpoint $id ' - '($scriptId:$line:$column): ' - 'cannot set JS breakpoint.'); + _logger.fine( + 'Failed to set breakpoint $id ' + '($scriptId:$line:$column): ' + 'cannot set JS breakpoint.', + ); throw RPCError( - 'addBreakpoint', - 102, - 'The VM is unable to add a breakpoint $id ' - 'at the specified line or function: ($scriptId:$line:$column): ' - 'cannot set JS breakpoint at $location'); + 'addBreakpoint', + 102, + 'The VM is unable to add a breakpoint $id ' + 'at the specified line or function: ($scriptId:$line:$column): ' + 'cannot set JS breakpoint at $location', + ); } _note(jsId: jsBreakpointId, bp: dartBreakpoint); return dartBreakpoint; diff --git a/dwds/lib/src/debugging/execution_context.dart b/dwds/lib/src/debugging/execution_context.dart index 978bd845e..9662b3914 100644 --- a/dwds/lib/src/debugging/execution_context.dart +++ b/dwds/lib/src/debugging/execution_context.dart @@ -84,22 +84,24 @@ class RemoteDebuggerExecutionContext extends ExecutionContext { _remoteDebugger .eventStream('Runtime.executionContextsCleared', (e) => e) .listen((_) => _id = null); - _remoteDebugger.eventStream('Runtime.executionContextCreated', (e) { - // Parse and add the context ID to the stream. - // If we cannot detect or parse the context ID, add `null` to the stream - // to indicate an error context - those will be skipped when trying to find - // the dart context, with a warning. - final id = e.params?['context']?['id']?.toString(); - final parsedId = id == null ? null : int.parse(id); - if (id == null) { - _logger.warning('Cannot find execution context id: $e'); - } else if (parsedId == null) { - _logger.warning('Cannot parse execution context id: $id'); - } - return parsedId; - }).listen((e) { - if (e != null) _contextController.add(e); - }); + _remoteDebugger + .eventStream('Runtime.executionContextCreated', (e) { + // Parse and add the context ID to the stream. + // If we cannot detect or parse the context ID, add `null` to the stream + // to indicate an error context - those will be skipped when trying to find + // the dart context, with a warning. + final id = e.params?['context']?['id']?.toString(); + final parsedId = id == null ? null : int.parse(id); + if (id == null) { + _logger.warning('Cannot find execution context id: $e'); + } else if (parsedId == null) { + _logger.warning('Cannot parse execution context id: $id'); + } + return parsedId; + }) + .listen((e) { + if (e != null) _contextController.add(e); + }); _contexts = StreamQueue(_contextController.stream); } } diff --git a/dwds/lib/src/debugging/frame_computer.dart b/dwds/lib/src/debugging/frame_computer.dart index ec642c669..2f76d2853 100644 --- a/dwds/lib/src/debugging/frame_computer.dart +++ b/dwds/lib/src/debugging/frame_computer.dart @@ -26,7 +26,7 @@ class FrameComputer { List? _asyncFramesToProcess; FrameComputer(this.debugger, this._callFrames, {StackTrace? asyncStackTrace}) - : _asyncStackTrace = asyncStackTrace; + : _asyncStackTrace = asyncStackTrace; /// Given a frame index, return the corresponding JS frame. WipCallFrame? jsFrameForIndex(int frameIndex) { @@ -63,8 +63,10 @@ class FrameComputer { if (limit != null && _computedFrames.length == limit) return; try { final callFrame = _callFrames[_frameIndex]; - final dartFrame = - await debugger.calculateDartFrameFor(callFrame, _frameIndex++); + final dartFrame = await debugger.calculateDartFrameFor( + callFrame, + _frameIndex++, + ); if (dartFrame != null) { _computedFrames.add(dartFrame); } @@ -90,10 +92,7 @@ class FrameComputer { if (_computedFrames.isNotEmpty && _computedFrames.last.kind != FrameKind.kAsyncSuspensionMarker) { _computedFrames.add( - Frame( - index: _frameIndex++, - kind: FrameKind.kAsyncSuspensionMarker, - ), + Frame(index: _frameIndex++, kind: FrameKind.kAsyncSuspensionMarker), ); } _asyncFramesToProcess = asyncStackTrace.callFrames; diff --git a/dwds/lib/src/debugging/inspector.dart b/dwds/lib/src/debugging/inspector.dart index a2209ca13..b2a8fcdd1 100644 --- a/dwds/lib/src/debugging/inspector.dart +++ b/dwds/lib/src/debugging/inspector.dart @@ -114,19 +114,17 @@ class AppInspector implements AppInspectorInterface { await DartUri.initialize(); DartUri.recordAbsoluteUris(libraries.map((lib) => lib.uri).nonNulls); - DartUri.recordAbsoluteUris( - scripts.map((script) => script.uri).nonNulls, - ); + DartUri.recordAbsoluteUris(scripts.map((script) => script.uri).nonNulls); isolate.extensionRPCs?.addAll(await _getExtensionRpcs()); } static IsolateRef _toIsolateRef(Isolate isolate) => IsolateRef( - id: isolate.id, - name: isolate.name, - number: isolate.number, - isSystemIsolate: isolate.isSystemIsolate, - ); + id: isolate.id, + name: isolate.name, + number: isolate.number, + isSystemIsolate: isolate.isSystemIsolate, + ); static Future create( AppConnection appConnection, @@ -238,8 +236,10 @@ class AppInspector implements AppInspectorInterface { 'returnByValue': returnByValue, }, ); - final result = - getResultOrHandleError(response, evalContents: evalExpression); + final result = getResultOrHandleError( + response, + evalContents: evalExpression, + ); return RemoteObject(result); } @@ -262,8 +262,10 @@ class AppInspector implements AppInspectorInterface { 'returnByValue': returnByValue, }, ); - final result = - getResultOrHandleError(response, evalContents: evalExpression); + final result = getResultOrHandleError( + response, + evalContents: evalExpression, + ); return RemoteObject(result); } @@ -308,15 +310,15 @@ class AppInspector implements AppInspectorInterface { } return globalToolConfiguration.loadStrategy is DdcLibraryBundleStrategy ? _evaluateLibraryMethodWithDdcLibraryBundle( - libraryUri, - selector, - arguments, - ) + libraryUri, + selector, + arguments, + ) : _evaluateInLibrary( - libraryUri, - 'function () { return this.$selector.apply(this, arguments); }', - arguments, - ); + libraryUri, + 'function () { return this.$selector.apply(this, arguments); }', + arguments, + ); } /// Evaluate [expression] by calling Chrome's Runtime.evaluate. @@ -348,7 +350,8 @@ class AppInspector implements AppInspectorInterface { List arguments, ) async { final findLibraryJsExpression = globalToolConfiguration - .loadStrategy.dartRuntimeDebugger + .loadStrategy + .dartRuntimeDebugger .callLibraryMethodJsExpression(libraryUri, jsFunction); final remoteLibrary = await jsEvaluate(findLibraryJsExpression); @@ -411,8 +414,11 @@ class AppInspector implements AppInspectorInterface { if (scriptRef != null) { return _getScript(scriptRef); } - final instance = await _instanceHelper - .instanceFor(remoteObjectFor(objectId), offset: offset, count: count); + final instance = await _instanceHelper.instanceFor( + remoteObjectFor(objectId), + offset: offset, + count: count, + ); if (instance != null) { return instance; } @@ -420,8 +426,10 @@ class AppInspector implements AppInspectorInterface { _logger.fine('getObject $objectId failed', e, s); rethrow; } - throw UnsupportedError('Only libraries, instances, classes, and scripts ' - 'are supported for getObject'); + throw UnsupportedError( + 'Only libraries, instances, classes, and scripts ' + 'are supported for getObject', + ); } Future