-
Notifications
You must be signed in to change notification settings - Fork 327
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
Add a server endpoint for serving devtools extensions #6094
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First pass.
packages/devtools_shared/lib/src/extensions/extension_manager.dart
Outdated
Show resolved
Hide resolved
packages/devtools_shared/lib/src/extensions/extension_manager.dart
Outdated
Show resolved
Hide resolved
packages/devtools_shared/lib/src/extensions/extension_manager.dart
Outdated
Show resolved
Hide resolved
packages/devtools_shared/lib/src/extensions/extension_manager.dart
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,74 @@ | |||
// Copyright 2023 The Chromium Authors. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just confirming, this is a straight move from package:devtools_app/src/extensions/embedded/extension_model.dart
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added dart doc to the members and some validation in the factory constructor so it should be re-reviewed. I also made the json parsing for the icon code point able to handle both strings and ints
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another pass.
packages/devtools_app/lib/src/shared/config_specific/server/_server_web.dart
Show resolved
Hide resolved
final extensions = <Extension>[]; | ||
for (final extension in extensions) { | ||
final config = extension.config; | ||
if (config is! Map) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If config
is always expected to be Map
, why don't we restrict it to Map<Object, Object?>
in Extension
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See discussion at dart-lang/tools#129 (comment)
packages/devtools_shared/lib/src/extensions/extension_manager.dart
Outdated
Show resolved
Hide resolved
packages/devtools_shared/lib/src/extensions/extension_manager.dart
Outdated
Show resolved
Hide resolved
packages/devtools_shared/lib/src/extensions/extension_manager.dart
Outdated
Show resolved
Hide resolved
packages/devtools_shared/lib/src/extensions/extension_manager.dart
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with one last suggestion.
codePoint = codePointFromJson as int? ?? defaultCodePoint; | ||
} | ||
|
||
final name = json[nameKey] as String?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use pattern matching here for JSON validation:
if (json
case {
nameKey: String name,
pathKey: String path,
issueTrackerKey: String issueTracker,
versionKey: String version,
}) {
return DevToolsExtensionConfig._(
name: name,
path: path,
issueTrackerLink: issueTrackerLink,
version: version,
materialIconCodePoint: codePoint,
);
}
throw StateError(
'missing required fields ${nullFields.toString()} in the extension '
'config.json',
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will address this comment as part of #6097.
This PR
extension_model.dart
topackages/devtools_shared
so that we can reuse this model from the devtools serverExtensionManager
that manages moving devtools extension assets tobuild/devtools_extensions
so that the server can serve them (implemented in https://dart-review.googlesource.com/c/sdk/+/305043)work towards #1632