Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixed linting errors
  • Loading branch information
jyameo committed Dec 3, 2025
commit ef49d384706ad1f6027b7aa8e71d22f59c5697cb
2 changes: 1 addition & 1 deletion dwds/debug_extension/web/background.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Future<void> _handleRuntimeMessages(
},
);

sendResponse(defaultResponse);
(sendResponse as void Function(Object?))(defaultResponse);
}

Future<void> _detectNavigationAwayFromDartApp(
Expand Down
2 changes: 1 addition & 1 deletion dwds/debug_extension/web/copier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void _handleRuntimeMessages(
messageHandler: _copyAppId,
);

sendResponse(defaultResponse);
(sendResponse as void Function(Object?))(defaultResponse);
}

void _copyAppId(String appId) {
Expand Down
12 changes: 6 additions & 6 deletions dwds/debug_extension/web/cross_extension_communication.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ Future<void> handleMessagesFromAngularDartDevTools(
await _respondWithEncodedUri(message.tabId, sendResponse);
} else if (message.name == 'dwds.startDebugging') {
await attachDebugger(message.tabId, trigger: Trigger.angularDartDevTools);
sendResponse(true);
(sendResponse as void Function(Object?))(true);
} else {
sendResponse(
(sendResponse as void Function(Object?))(
ErrorResponse()..error = 'Unknown message name: ${message.name}',
);
}
Expand Down Expand Up @@ -80,19 +80,19 @@ void _forwardCommandToChromeDebugger(
),
);
} catch (e) {
sendResponse(ErrorResponse()..error = '$e');
(sendResponse as void Function(Object?))(ErrorResponse()..error = '$e');
}
}

void _respondWithChromeResult(Object? chromeResult, Function sendResponse) {
// No result indicates that an error occurred.
if (chromeResult == null) {
sendResponse(
(sendResponse as void Function(Object?))(
ErrorResponse()
..error = JSON.stringify(chrome.runtime.lastError ?? 'Unknown error.'),
);
} else {
sendResponse(chromeResult);
(sendResponse as void Function(Object?))(chromeResult);
}
}

Expand All @@ -101,7 +101,7 @@ Future<void> _respondWithEncodedUri(int tabId, Function sendResponse) async {
type: StorageObject.encodedUri,
tabId: tabId,
);
sendResponse(encodedUri ?? '');
(sendResponse as void Function(Object?))(encodedUri ?? '');
}

void _forwardMessageToAngularDartDevTools(ExternalExtensionMessage message) {
Expand Down
3 changes: 2 additions & 1 deletion dwds/debug_extension/web/debug_session.dart
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ Future<void> _onDebuggerEvent(
}

Future<void> _maybeConnectToDwds(int tabId, Object? params) async {
final context = json.decode(JSON.stringify(params))['context'];
final decoded = json.decode(JSON.stringify(params)) as Map<String, dynamic>;
final context = decoded['context'] as Map<String, dynamic>;
final contextOrigin = context['origin'] as String?;
if (contextOrigin == null) return;
if (contextOrigin.contains('chrome-extension:')) return;
Expand Down
2 changes: 1 addition & 1 deletion dwds/debug_extension/web/messaging.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import 'utils.dart';
//
// Prevents the message port from closing. See:
// https://developer.chrome.com/docs/extensions/mv3/messaging/#simple
final defaultResponse = jsify({'response': 'received'});
final defaultResponse = jsify({'response': 'received'}) as Object;

enum Script {
background,
Expand Down
6 changes: 3 additions & 3 deletions dwds/lib/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
export 'src/config/tool_configuration.dart'
show
AppMetadata,
ToolConfiguration,
UrlEncoder,
DebugSettings,
DevToolsLauncher,
DebugSettings;
ToolConfiguration,
UrlEncoder;
3 changes: 2 additions & 1 deletion dwds/lib/src/debugging/chrome_inspector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ class ChromeAppInspector extends AppInspector {
if (namedArgs.isNotEmpty) {
throw UnsupportedError('Named arguments are not yet supported');
}
// We use the JS pseudo-variable 'arguments' to get the list of all arguments.
// We use the JS pseudo-variable 'arguments' to get the list of all
// arguments.
final send = globalToolConfiguration.loadStrategy.dartRuntimeDebugger
.callInstanceMethodJsExpression(methodName);
final remote = await jsCallFunctionOn(receiver, send, positionalArgs);
Expand Down
28 changes: 15 additions & 13 deletions dwds/lib/src/debugging/classes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,31 +95,33 @@ class ChromeAppClassHelper {
final classDescriptor = _mapify(result.value);
final methodRefs = <FuncRef>[];
final methodDescriptors = _mapify(classDescriptor['methods']);
methodDescriptors.forEach((name, descriptor) {
methodDescriptors.forEach((name, dynamic descriptor) {
final typedDescriptor = descriptor as Map<String, dynamic>;
final methodId = 'methods|$classId|$name';
methodRefs.add(
FuncRef(
id: methodId,
name: name,
owner: classRef,
isConst: descriptor['isConst'] as bool? ?? false,
isStatic: descriptor['isStatic'] as bool? ?? false,
implicit: descriptor['isImplicit'] as bool? ?? false,
isAbstract: descriptor['isAbstract'] as bool? ?? false,
isGetter: descriptor['isGetter'] as bool? ?? false,
isSetter: descriptor['isSetter'] as bool? ?? false,
isConst: typedDescriptor['isConst'] as bool? ?? false,
isStatic: typedDescriptor['isStatic'] as bool? ?? false,
implicit: typedDescriptor['isImplicit'] as bool? ?? false,
isAbstract: typedDescriptor['isAbstract'] as bool? ?? false,
isGetter: typedDescriptor['isGetter'] as bool? ?? false,
isSetter: typedDescriptor['isSetter'] as bool? ?? false,
),
);
});
final fieldRefs = <FieldRef>[];

final fieldDescriptors = _mapify(classDescriptor['fields']);
fieldDescriptors.forEach((name, descriptor) {
fieldDescriptors.forEach((name, dynamic descriptor) {
final typedDescriptor = descriptor as Map<String, dynamic>;
final classMetaData = ClassMetaData(
runtimeKind: RuntimeObjectKind.type,
classRef: classRefFor(
descriptor['classLibraryId'],
descriptor['className'],
typedDescriptor['classLibraryId'],
typedDescriptor['className'],
),
);

Expand All @@ -133,9 +135,9 @@ class ChromeAppClassHelper {
kind: classMetaData.kind,
classRef: classMetaData.classRef,
),
isConst: descriptor['isConst'] as bool? ?? false,
isFinal: descriptor['isFinal'] as bool? ?? false,
isStatic: descriptor['isStatic'] as bool? ?? false,
isConst: typedDescriptor['isConst'] as bool? ?? false,
isFinal: typedDescriptor['isFinal'] as bool? ?? false,
isStatic: typedDescriptor['isStatic'] as bool? ?? false,
id: createId(),
),
);
Expand Down
9 changes: 6 additions & 3 deletions dwds/lib/src/debugging/debugger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,10 @@ class Debugger {
// Renders the paused at breakpoint overlay over the application.
// void _showPausedOverlay() async {
// if (_pausedOverlayVisible) return;
// handleErrorIfPresent(await _remoteDebugger?.sendCommand('DOM.enable'));
// handleErrorIfPresent(await _remoteDebugger?.sendCommand('Overlay.enable'));
// handleErrorIfPresent(
// await _remoteDebugger?.sendCommand('DOM.enable'));
// handleErrorIfPresent(
// await _remoteDebugger?.sendCommand('Overlay.enable'));
// handleErrorIfPresent(await _remoteDebugger
// ?.sendCommand('Overlay.setPausedInDebuggerMessage', params: {
// 'message': 'Paused',
Expand All @@ -437,7 +439,8 @@ class Debugger {
// Removes the paused at breakpoint overlay from the application.
// void _hidePausedOverlay() async {
// if (!_pausedOverlayVisible) return;
// handleErrorIfPresent(await _remoteDebugger?.sendCommand('Overlay.disable'));
// handleErrorIfPresent(
// await _remoteDebugger?.sendCommand('Overlay.disable'));
// _pausedOverlayVisible = false;
// }

Expand Down
13 changes: 7 additions & 6 deletions dwds/lib/src/debugging/libraries.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
// BSD-style license that can be found in the LICENSE file.

import 'package:collection/collection.dart';
import 'package:dwds/src/config/tool_configuration.dart';
import 'package:dwds/src/debugging/chrome_inspector.dart';
import 'package:dwds/src/debugging/inspector.dart';
import 'package:dwds/src/debugging/metadata/class.dart';
import 'package:dwds/src/debugging/metadata/provider.dart';
import 'package:dwds/src/services/chrome/chrome_debug_exception.dart';
import 'package:logging/logging.dart';
import 'package:meta/meta.dart';
import 'package:vm_service/vm_service.dart';
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart';

import '../config/tool_configuration.dart';
import '../services/chrome/chrome_debug_exception.dart';
import 'chrome_inspector.dart';
import 'inspector.dart';
import 'metadata/class.dart';
import 'metadata/provider.dart';

/// Keeps track of Dart libraries available in the running application.
class LibraryHelper<T extends AppInspector> {
final Logger _logger = Logger('LibraryHelper');
Expand Down
45 changes: 27 additions & 18 deletions dwds/lib/src/handlers/dev_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,19 @@ class DevHandler {
try {
injectedConnection.sink.add(jsonEncode(serializers.serialize(request)));
successfulSends++;
} on StateError catch (e) {
// The sink has already closed (app is disconnected), or another StateError occurred.
} catch (e, s) {
// The sink has already closed (app is disconnected).
_logger.warning(
'Failed to send request to client, connection likely closed. Error: $e',
'Failed to send request to client, '
'connection likely closed. Error: $e',
e,
s,
);
} catch (e, s) {
// Catch any other potential errors during sending.
_logger.severe('Error sending request to client: $e', e, s);
}
}
_logger.fine(
'Sent request to $successfulSends clients out of ${_injectedConnections.length} total connections',
'Sent request to $successfulSends clients out of '
'${_injectedConnections.length} total connections',
);
return successfulSends;
}
Expand Down Expand Up @@ -203,7 +204,9 @@ class DevHandler {
'expression': r'window["$dartAppInstanceId"];',
'contextId': contextId,
});
final evaluatedAppId = result.result?['result']?['value'];
final resultMap = result.result;
final innerResult = resultMap?['result'] as Map<String, dynamic>?;
final evaluatedAppId = innerResult?['value'];
if (evaluatedAppId == appInstanceId) {
appTab = tab;
executionContext = RemoteDebuggerExecutionContext(
Expand Down Expand Up @@ -376,7 +379,7 @@ class DevHandler {
),
),
);
} on StateError catch (_) {
} catch (_) {
// The sink has already closed (app is disconnected), swallow the
// error.
}
Expand All @@ -390,7 +393,8 @@ class DevHandler {
if (connection != null) {
final appId = connection.request.appId;
final services = _servicesByAppId[appId];
// WebSocket mode doesn't need this because WebSocketProxyService handles connection tracking and cleanup
// WebSocket mode doesn't need this because WebSocketProxyService
// handles connection tracking and cleanup
if (!useWebSocketConnection) {
_appConnectionByAppId.remove(appId);
}
Expand Down Expand Up @@ -442,7 +446,8 @@ class DevHandler {
? 'WebSocket'
: 'Chrome';
throw UnsupportedError(
'Message type ${message.runtimeType} is not supported in $serviceType mode',
'Message type ${message.runtimeType} is not supported in $serviceType '
'mode',
);
}
}
Expand Down Expand Up @@ -562,7 +567,8 @@ class DevHandler {
final proxyService = appDebugServices.proxyService;
if (proxyService is! WebSocketProxyService) {
throw StateError(
'Expected WebSocketProxyService but got ${proxyService.runtimeType}. ',
'Expected WebSocketProxyService but got '
'${proxyService.runtimeType}. ',
);
}
await proxyService.isInitialized;
Expand Down Expand Up @@ -711,7 +717,8 @@ class DevHandler {
// New browser window or initial connection: run main() immediately
readyToRunMainCompleter.complete();

// For WebSocket mode, we need to proactively create and emit a debug connection
// For WebSocket mode, we need to proactively create and emit a debug
// connection
try {
// Initialize the WebSocket service and create debug connection
final debugConnection = await createDebugConnectionForWebSocket(
Expand Down Expand Up @@ -803,7 +810,8 @@ class DevHandler {
}
}

/// Handles isolate start events for both WebSocket and Chrome-based debugging.
/// Handles isolate start events for both WebSocket and Chrome-based
/// debugging.
Future<void> _handleIsolateStart(AppConnection appConnection) async {
final appId = appConnection.request.appId;

Expand All @@ -827,10 +835,11 @@ class DevHandler {
if (!_sseHandlers.containsKey(uri.path)) {
final handler = _useSseForInjectedClient
? SseSocketHandler(
// We provide an essentially indefinite keep alive duration because
// the underlying connection could be lost while the application
// is paused. The connection will get re-established after a resume
// or cleaned up on a full page refresh.
// We provide an essentially indefinite keep alive duration
// because the underlying connection could be lost while the
// application is paused. The connection will get
// re-established after a resume or cleaned up on a full page
// refresh.
SseHandler(uri, keepAlive: const Duration(days: 3000)),
)
: WebSocketSocketHandler();
Expand Down
3 changes: 2 additions & 1 deletion dwds/lib/src/services/chrome/chrome_proxy_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,8 @@ final class ChromeProxyService extends ProxyService<ChromeAppInspector> {

Map<String, RemoteObject> _fetchAbbreviatedLogParams(Map? logObject) {
final logParams = <String, RemoteObject>{};
final properties = logObject?['preview']?['properties'] as List? ?? [];
final preview = logObject?['preview'] as Map<String, dynamic>?;
final properties = preview?['properties'] as List? ?? [];
for (final dynamic property in properties) {
if (property is Map<String, dynamic> && property['name'] != null) {
logParams[property['name'] as String] = RemoteObject(property);
Expand Down
3 changes: 2 additions & 1 deletion dwds/lib/src/services/debug_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ abstract class DebugService<T extends ProxyService> {
required this.useSse,
});

/// The URI pointing to the VM service implementation hosted by the [DebugService].
/// The URI pointing to the VM service implementation hosted by the
/// [DebugService].
String get uri => _uri.toString();

Uri get _uri => _cachedUri ??= () {
Expand Down
9 changes: 5 additions & 4 deletions dwds/test/fixtures/context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ class TestContext {

/// Internal VM service.
///
/// Prefer using [vmService] instead in tests when possible, to include testing
/// of the VmServerConnection (bypassed when using [service]).
/// Prefer using [vmService] instead in tests when possible, to include
/// testing of the VmServerConnection (bypassed when using [service]).
ChromeProxyService get service => fetchChromeProxyService(debugConnection);

/// External VM service.
Expand Down Expand Up @@ -320,7 +320,7 @@ class TestContext {
final entry = p.toUri(
p.join(project.webAssetsPath, project.dartEntryFileName),
);
frontendServerFileSystem = LocalFileSystem();
frontendServerFileSystem = const LocalFileSystem();
final packageUriMapper = await PackageUriMapper.create(
frontendServerFileSystem,
project.packageConfigFile,
Expand Down Expand Up @@ -382,7 +382,8 @@ class TestContext {
() async => {},
buildSettings,
reloadedSourcesUri: Uri.parse(
'http://localhost:$port/${WebDevFS.reloadedSourcesFileName}',
'http://localhost:$port/'
'${WebDevFS.reloadedSourcesFileName}',
),
).strategy
: FrontendServerDdcStrategyProvider(
Expand Down
4 changes: 2 additions & 2 deletions dwds/test/fixtures/debugger_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ List<Map<String, dynamic>> frames1Json = [
/// elements of a scope chain.
///
/// It has two variables named 'a' and 'b' in the first scope.
var variables1 = [
List<WipResponse> variables1 = [
WipResponse({
'id': 1,
'result': {'result': <Map<String, dynamic>>[]},
Expand Down Expand Up @@ -137,7 +137,7 @@ var variables1 = [
];

/// Sample data for a Debugger.scriptParsed event
var scriptParsedParams = {
Map<String, Object> scriptParsedParams = {
"endColumn": 0,
"endLine": 53,
"executionContextAuxData": {
Expand Down
Loading
Loading