Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 1 addition & 5 deletions dwds/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
include: package:analysis_config/analysis_options.yaml
include: package:dart_flutter_team_lints/analysis_options.yaml

analyzer:
exclude:
# Ignore generated files
- "lib/data/*"
# Ignore debug extension builds
- "debug_extension/compiled/*"

linter:
rules:
- always_use_package_imports
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
5 changes: 4 additions & 1 deletion dwds/debug_extension/web/chrome_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,10 @@ class NavigationInfo {
@JS()
@anonymous
class Windows {
external dynamic create(WindowInfo? createData, Function(WindowObj) callback);
external dynamic create(
WindowInfo? createData,
void Function(WindowObj) callback,
);

external OnFocusChangedHandler get onFocusChanged;
}
Expand Down
6 changes: 3 additions & 3 deletions dwds/debug_extension/web/cider_connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ void sendErrorMessageToCider({

void _sendMessageToCider(String json) {
final message = {'key': _ciderDartMessageKey, 'json': json};
_ciderPort!.postMessage(jsify(message));
_ciderPort!.postMessage(jsify(message) as Object);
}

Future<void> _handleMessageFromCider(dynamic message, Port _) async {
final key = getProperty(message, 'key');
final json = getProperty(message, 'json');
final key = getProperty<String?>(message as Object, 'key');
final json = getProperty<String?>(message, 'json');
if (key != _ciderDartMessageKey || json is! String) {
sendErrorMessageToCider(
errorType: CiderErrorType.invalidRequest,
Expand Down
4 changes: 2 additions & 2 deletions dwds/debug_extension/web/copier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ void _handleRuntimeMessages(
Function sendResponse,
) {
interceptMessage<String>(
message: jsRequest,
message: jsRequest is String ? jsRequest : null,
expectedType: MessageType.appId,
expectedSender: Script.background,
expectedRecipient: Script.copier,
sender: sender,
messageHandler: _copyAppId,
);

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

void _copyAppId(String appId) {
Expand Down
16 changes: 8 additions & 8 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 @@ -76,23 +76,23 @@ void _forwardCommandToChromeDebugger(
options.method,
options.commandParams,
allowInterop(
([result]) => _respondWithChromeResult(result, sendResponse),
([Object? result]) => _respondWithChromeResult(result, sendResponse),
),
);
} 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 All @@ -110,7 +110,7 @@ void _forwardMessageToAngularDartDevTools(ExternalExtensionMessage message) {
message,
// options
null,
allowInterop(([result]) => _checkForErrors(result, message.name)),
allowInterop(([Object? result]) => _checkForErrors(result, message.name)),
);
}

Expand Down
5 changes: 3 additions & 2 deletions 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 Expand Up @@ -449,7 +450,7 @@ void _forwardDwdsEventToChromeDebugger(
Debuggee(tabId: tabId),
message.command,
js_util.jsify(params),
allowInterop(([e]) {
allowInterop(([Object? e]) {
// No arguments indicate that an error occurred.
if (e == null) {
client.sink.add(
Expand Down
7 changes: 4 additions & 3 deletions dwds/debug_extension/web/detector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,12 @@ void _detectMultipleDartAppsCallback(

bool _isMultipleAppsMutation(dynamic mutation) {
final isAttributeMutation =
hasProperty(mutation, 'type') &&
getProperty(mutation, 'type') == 'attributes';
hasProperty(mutation as Object, 'type') &&
getProperty<String?>(mutation, 'type') == 'attributes';
if (isAttributeMutation) {
return hasProperty(mutation, 'attributeName') &&
getProperty(mutation, 'attributeName') == _multipleAppsAttribute;
getProperty<String?>(mutation, 'attributeName') ==
_multipleAppsAttribute;
}
return false;
}
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/debug_extension/web/storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Future<bool> setStorageObject<T>({
final completer = Completer<bool>();
final storageArea = _getStorageArea(type.persistence);
storageArea.set(
jsify(storageObj),
jsify(storageObj) as Object,
allowInterop(() {
if (callback != null) {
callback();
Expand Down Expand Up @@ -151,8 +151,8 @@ void interceptStorageChange<T>({
final isExpected = hasProperty(storageObj, expectedStorageKey);
if (!isExpected) return;

final objProp = getProperty(storageObj, expectedStorageKey);
final json = getProperty(objProp, 'newValue') as String?;
final objProp = getProperty<Object?>(storageObj, expectedStorageKey);
final json = getProperty(objProp as Object, 'newValue') as String?;
T? decodedObj;
if (json == null || T == String) {
decodedObj = json as T?;
Expand Down
2 changes: 1 addition & 1 deletion dwds/debug_extension/web/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ final bool isDevMode = () {
final bool isMV3 = () {
final extensionManifest = chrome.runtime.getManifest();
final manifestVersion =
getProperty(extensionManifest, 'manifest_version') ?? 2;
getProperty<int?>(extensionManifest, 'manifest_version') ?? 2;
return manifestVersion == 3;
}();

Expand Down
2 changes: 1 addition & 1 deletion dwds/debug_extension/web/web_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ external Object _nativeJsFetch(String resourceUrl, FetchOptions options);
Future<FetchResponse> fetchRequest(String resourceUrl) async {
try {
final options = FetchOptions(method: 'GET', credentials: 'include');
final response = await promiseToFuture(
final response = await promiseToFuture<Object>(
_nativeJsFetch(resourceUrl, options),
);
final body = await promiseToFuture<String?>(
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;
28 changes: 15 additions & 13 deletions dwds/lib/dart_web_debug_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@

import 'dart:async';

import 'package:dwds/data/build_result.dart';
import 'package:dwds/src/config/tool_configuration.dart';
import 'package:dwds/src/connections/app_connection.dart';
import 'package:dwds/src/connections/debug_connection.dart';
import 'package:dwds/src/events.dart';
import 'package:dwds/src/handlers/dev_handler.dart';
import 'package:dwds/src/handlers/injector.dart';
import 'package:dwds/src/handlers/socket_connections.dart';
import 'package:dwds/src/readers/asset_reader.dart';
import 'package:dwds/src/servers/devtools.dart';
import 'package:dwds/src/servers/extension_backend.dart';
import 'package:logging/logging.dart';
import 'package:shelf/shelf.dart';
import 'package:sse/server/sse_handler.dart';
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart';

import 'data/build_result.dart';
import 'src/config/tool_configuration.dart';
import 'src/connections/app_connection.dart';
import 'src/connections/debug_connection.dart';
import 'src/events.dart';
import 'src/handlers/dev_handler.dart';
import 'src/handlers/injector.dart';
import 'src/handlers/socket_connections.dart';
import 'src/readers/asset_reader.dart';
import 'src/servers/devtools.dart';
import 'src/servers/extension_backend.dart';

typedef ConnectionProvider = Future<ChromeConnection> Function();

/// The Dart Web Debug Service.
Expand Down Expand Up @@ -145,8 +146,9 @@ class Dwds {
debugSettings.expressionCompiler,
injected,
DartDevelopmentServiceConfiguration(
// This technically isn't correct, but DartDevelopmentServiceConfiguration.enable
// is true by default, so this won't break unmigrated tools.
// This technically isn't correct, but
// DartDevelopmentServiceConfiguration.enable is true by default,
// so this won't break unmigrated tools.
// ignore: deprecated_member_use_from_same_package
enable: debugSettings.spawnDds && debugSettings.ddsConfiguration.enable,
// ignore: deprecated_member_use_from_same_package
Expand Down
18 changes: 9 additions & 9 deletions dwds/lib/dwds.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

export 'dart_web_debug_service.dart' show Dwds, ConnectionProvider;
export 'dart_web_debug_service.dart' show ConnectionProvider, Dwds;
export 'src/config/tool_configuration.dart'
show
AppMetadata,
UrlEncoder,
DartDevelopmentServiceConfiguration,
DevToolsLauncher,
DebugSettings,
ToolConfiguration;
DevToolsLauncher,
ToolConfiguration,
UrlEncoder;
export 'src/connections/app_connection.dart' show AppConnection;
export 'src/connections/debug_connection.dart' show DebugConnection;
export 'src/debugging/metadata/provider.dart'
show MetadataProvider, AbsoluteImportUriException;
show AbsoluteImportUriException, MetadataProvider;
export 'src/events.dart' show DwdsEvent;
export 'src/handlers/dev_handler.dart' show AppConnectionException;
export 'src/handlers/socket_connections.dart';
Expand All @@ -28,7 +28,7 @@ export 'src/loaders/frontend_server_strategy_provider.dart'
FrontendServerRequireStrategyProvider;
export 'src/loaders/require.dart' show RequireStrategy;
export 'src/loaders/strategy.dart'
show LoadStrategy, ReloadConfiguration, BuildSettings;
show BuildSettings, LoadStrategy, ReloadConfiguration;
export 'src/readers/asset_reader.dart' show AssetReader, PackageUriMapper;
export 'src/readers/frontend_server_asset_reader.dart'
show FrontendServerAssetReader;
Expand All @@ -38,12 +38,12 @@ export 'src/services/chrome/chrome_debug_exception.dart'
show ChromeDebugException;
export 'src/services/expression_compiler.dart'
show
CompilerOptions,
ExpressionCompilationResult,
ExpressionCompiler,
ModuleInfo,
CompilerOptions;
ModuleInfo;
export 'src/services/expression_compiler_service.dart'
show ExpressionCompilerService;
export 'src/utilities/ddc_names.dart';
export 'src/utilities/sdk_configuration.dart'
show SdkLayout, SdkConfiguration, SdkConfigurationProvider;
show SdkConfiguration, SdkConfigurationProvider, SdkLayout;
2 changes: 1 addition & 1 deletion dwds/lib/expression_compiler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

export 'src/services/expression_compiler.dart'
show
CompilerOptions,
ExpressionCompilationResult,
ExpressionCompiler,
CompilerOptions,
ModuleFormat,
ModuleInfo;
4 changes: 2 additions & 2 deletions dwds/lib/sdk_configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

export 'src/utilities/sdk_configuration.dart'
show
SdkLayout,
DefaultSdkConfigurationProvider,
SdkConfiguration,
SdkConfigurationProvider,
DefaultSdkConfigurationProvider;
SdkLayout;
2 changes: 1 addition & 1 deletion dwds/lib/shared/batched_stream.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import 'dart:async';
import 'dart:math';
import 'package:async/async.dart';
import 'package:dwds/src/utilities/shared.dart';
import '../src/utilities/shared.dart';

/// Stream controller allowing to batch events.
class BatchedStreamController<T> {
Expand Down
6 changes: 3 additions & 3 deletions dwds/lib/src/config/tool_configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:dwds/src/loaders/strategy.dart';
import 'package:dwds/src/servers/devtools.dart';
import 'package:dwds/src/services/expression_compiler.dart';
import '../loaders/strategy.dart';
import '../servers/devtools.dart';
import '../services/expression_compiler.dart';

/// Configuration about the app, debug settings, and file system.
///
Expand Down
10 changes: 5 additions & 5 deletions dwds/lib/src/connections/app_connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import 'dart:async';
import 'dart:convert';

import 'package:dwds/data/connect_request.dart';
import 'package:dwds/data/run_request.dart';
import 'package:dwds/data/serializers.dart';
import 'package:dwds/src/handlers/socket_connections.dart';
import 'package:dwds/src/utilities/shared.dart';
import '../../data/connect_request.dart';
import '../../data/run_request.dart';
import '../../data/serializers.dart';
import '../handlers/socket_connections.dart';
import '../utilities/shared.dart';

/// A connection between the application loaded in the browser and DWDS.
class AppConnection {
Expand Down
7 changes: 4 additions & 3 deletions dwds/lib/src/connections/debug_connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@

import 'dart:async';

import 'package:dwds/src/services/app_debug_services.dart';
import 'package:dwds/src/services/chrome/chrome_proxy_service.dart';
import 'package:vm_service/vm_service.dart';

import '../services/app_debug_services.dart';
import '../services/chrome/chrome_proxy_service.dart';

/// A debug connection between the application in the browser and DWDS.
///
/// Supports debugging your running application through the Dart VM Service
/// Protocol.
class DebugConnection {
final AppDebugServices _appDebugServices;
final _onDoneCompleter = Completer();
final _onDoneCompleter = Completer<void>();

/// Null until [close] is called.
///
Expand Down
Loading
Loading