Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 4 additions & 0 deletions dwds/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 24.3.6-wip

- Bump minimum sdk version to 3.7.0

## 24.3.5
- Allow clients to specify the `packageConfigPath` in `LoadStrategy` class and associated providers.

Expand Down
1 change: 0 additions & 1 deletion dwds/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ analyzer:
linter:
rules:
- always_use_package_imports
- require_trailing_commas
38 changes: 19 additions & 19 deletions dwds/debug_extension/tool/build_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,38 @@ import 'package:path/path.dart' as p;
const _prodFlag = 'prod';

void main(List<String> 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<int> 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) {
return compileExitCode;
}
_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:
Expand All @@ -60,10 +61,9 @@ Future<int> 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;
Expand Down
12 changes: 6 additions & 6 deletions dwds/debug_extension/tool/copy_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ Builder copyBuilder(_) => _CopyBuilder();
class _CopyBuilder extends Builder {
@override
Map<String, List<String>> 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<void> build(BuildStep buildStep) async {
Expand Down
13 changes: 5 additions & 8 deletions dwds/debug_extension/tool/update_dev_files.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ void main() async {
Future<void> _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 [
Expand All @@ -24,11 +25,7 @@ Future<void> _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 [
Expand Down
52 changes: 27 additions & 25 deletions dwds/debug_extension/web/background.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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.
Expand All @@ -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 {
Expand All @@ -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<void> _handleRuntimeMessages(
Expand Down Expand Up @@ -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,
);
}

Expand Down Expand Up @@ -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<DebugInfo?> _fetchDebugInfo(int tabId) {
Expand Down
10 changes: 4 additions & 6 deletions dwds/debug_extension/web/chrome_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
25 changes: 8 additions & 17 deletions dwds/debug_extension/web/cider_connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down Expand Up @@ -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));
}

Expand Down Expand Up @@ -177,7 +170,8 @@ Future<void> _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;
Expand All @@ -195,10 +189,7 @@ Future<void> _sendInspectorUrl({String? appId}) async {
}
final inspectorUrl = addQueryParameters(
devToolsUri,
queryParameters: {
'embed': 'true',
'page': 'inspector',
},
queryParameters: {'embed': 'true', 'page': 'inspector'},
);
sendMessageToCider(
messageType: CiderMessageType.inspectorUrlResponse,
Expand Down
16 changes: 8 additions & 8 deletions dwds/debug_extension/web/copier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -19,9 +21,7 @@ void main() {
}

void _registerListeners() {
chrome.runtime.onMessage.addListener(
allowInterop(_handleRuntimeMessages),
);
chrome.runtime.onMessage.addListener(allowInterop(_handleRuntimeMessages));
}

void _handleRuntimeMessages(
Expand Down Expand Up @@ -49,8 +49,8 @@ void _copyAppId(String appId) {
}

Future<bool> _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,
);
Loading