Skip to content

Format sources using the updated formatter #2662

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion _analysis_config/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: The shared analysis configuration for the webdev packages.
publish_to: none

environment:
sdk: ^3.1.0
sdk: ^3.8.0

dependencies:
lints: ^5.0.0
1 change: 1 addition & 0 deletions dwds/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## 24.4.2-wip

- Bump minimum SDK version to 3.8.0
- Update a call to the `package:shelf_web_socket` `webSocketHandler()` function.

## 24.4.1
Expand Down
2 changes: 1 addition & 1 deletion dwds/debug_extension/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: >-
A Chrome extension for Dart debugging.

environment:
sdk: ^3.5.0
sdk: ^3.8.0

dependencies:
built_value: ^8.9.0
Expand Down
4 changes: 2 additions & 2 deletions dwds/debug_extension/tool/build_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ 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);
Expand Down
7 changes: 3 additions & 4 deletions dwds/debug_extension/tool/update_dev_files.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ 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 Down
32 changes: 16 additions & 16 deletions dwds/debug_extension/web/background.dart
Original file line number Diff line number Diff line change
Expand Up @@ -217,20 +217,19 @@ 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 @@ -280,8 +279,9 @@ void _setWarningIcon(int tabId) {
}

void _setDefaultIcon(int tabId) {
final iconPath =
isDevMode ? 'static_assets/dart_dev.png' : 'static_assets/dart_grey.png';
final iconPath = isDevMode
? 'static_assets/dart_dev.png'
: 'static_assets/dart_grey.png';
setExtensionIcon(IconInfo(path: iconPath));
setExtensionPopup(PopupDetails(popup: '', tabId: tabId));
}
Expand Down
7 changes: 3 additions & 4 deletions dwds/debug_extension/web/cross_extension_communication.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@ 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);
}
Expand Down
5 changes: 3 additions & 2 deletions dwds/debug_extension/web/data_types.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 9 additions & 11 deletions dwds/debug_extension/web/debug_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,15 @@ 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?,
),
),
);
Expand Down
72 changes: 31 additions & 41 deletions dwds/debug_extension/web/debug_session.dart
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,9 @@ Future<bool> _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(
Expand Down Expand Up @@ -386,14 +383,13 @@ Future<bool> _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;
Expand Down Expand Up @@ -445,10 +441,9 @@ void _forwardDwdsEventToChromeDebugger(
) {
try {
final messageParams = message.commandParams;
final params =
messageParams == null
? <String, Object>{}
: BuiltMap<String, Object>(json.decode(messageParams)).toMap();
final params = messageParams == null
? <String, Object>{}
: BuiltMap<String, Object>(json.decode(messageParams)).toMap();

chrome.debugger.sendCommand(
Debuggee(tabId: tabId),
Expand All @@ -461,11 +456,10 @@ 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),
),
),
),
Expand All @@ -475,11 +469,10 @@ 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),
),
),
),
Expand Down Expand Up @@ -612,10 +605,9 @@ Future<bool> _sendConnectFailureMessage(
final json = jsonEncode(
serializers.serialize(
ConnectFailure(
(b) =>
b
..tabId = dartAppTabId
..reason = reason.name,
(b) => b
..tabId = dartAppTabId
..reason = reason.name,
),
),
);
Expand All @@ -634,11 +626,10 @@ Future<bool> _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,
),
),
);
Expand Down Expand Up @@ -747,10 +738,9 @@ DebuggerLocation? _debuggerLocation(int dartAppTabId) {
/// 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),
);
}

Expand Down
8 changes: 6 additions & 2 deletions dwds/debug_extension/web/messaging.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,12 @@ Future<bool> _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<bool>();
void responseHandler([dynamic _]) {
final error = chrome.runtime.lastError;
Expand Down
7 changes: 3 additions & 4 deletions dwds/debug_extension/web/panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,9 @@ Future<void> _launchDebugConnection(Event _) async {
final json = jsonEncode(
serializers.serialize(
DebugStateChange(
(b) =>
b
..tabId = _tabId
..newState = DebugStateChange.startDebugging,
(b) => b
..tabId = _tabId
..newState = DebugStateChange.startDebugging,
),
),
);
Expand Down
14 changes: 6 additions & 8 deletions dwds/debug_extension/web/popup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,9 @@ Future<bool> _insertAppId() async {
Future<void> _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);
}

Expand All @@ -121,10 +120,9 @@ Future<void> _launchDevTools(Event _) async {
final json = jsonEncode(
serializers.serialize(
DebugStateChange(
(b) =>
b
..tabId = tabId
..newState = DebugStateChange.startDebugging,
(b) => b
..tabId = tabId
..newState = DebugStateChange.startDebugging,
),
),
);
Expand Down
5 changes: 3 additions & 2 deletions dwds/debug_extension/web/storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ Future<bool> setStorageObject<T>({
void Function()? callback,
}) {
final storageKey = _createStorageKey(type, tabId);
final json =
value is String ? value : jsonEncode(serializers.serialize(value));
final json = value is String
? value
: jsonEncode(serializers.serialize(value));
final storageObj = <String, String>{storageKey: json};
final completer = Completer<bool>();
final storageArea = _getStorageArea(type.persistence);
Expand Down
5 changes: 3 additions & 2 deletions dwds/debug_extension/web/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ void displayNotification(
NotificationOptions(
title: '${isError ? '[Error] ' : ''}Dart Debug Extension',
message: message,
iconUrl:
isError ? 'static_assets/dart_warning.png' : 'static_assets/dart.png',
iconUrl: isError
? 'static_assets/dart_warning.png'
: 'static_assets/dart.png',
type: 'basic',
),
callback,
Expand Down
25 changes: 12 additions & 13 deletions dwds/lib/dart_web_debug_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,18 @@ class Dwds {
Future<String>? 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();
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,
Expand Down
Loading
Loading