chrome-devtools-frontend 1.0.1733843 → 1.0.1736236
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/rules/tests/test-view-and-presenter-isolation.md +4 -4
- package/.agents/rules/ui-and-widgets/ui-declarative-tree-and-prompt-patterns.md +61 -0
- package/.agents/rules/ui-and-widgets/ui-lit-declarative-templates-and-directives.md +11 -7
- package/.agents/rules/ui-and-widgets/ui-modern-component-and-encapsulation-standards.md +13 -4
- package/.agents/rules/ui-and-widgets/ui-pure-view-and-presenter-separation.md +31 -2
- package/.agents/rules/ui-and-widgets/ui-reactive-widget-update-lifecycle.md +23 -4
- package/.agents/rules/ui-and-widgets/ui-widget-dom-and-listener-lifecycle.md +34 -3
- package/.agents/skills/code-review/SKILL.md +27 -0
- package/.agents/skills/devtools-uistrings/SKILL.md +147 -0
- package/.agents/skills/ui-eng-vision-local-lit-renderer/SKILL.md +27 -1
- package/.agents/skills/ui-eng-vision-orchestrator/SKILL.md +100 -0
- package/.agents/skills/ui-eng-vision-test-scaffolder/SKILL.md +16 -0
- package/.agents/skills/ui-eng-vision-widget-promoter/SKILL.md +13 -2
- package/.agents/skills/ui-widgets/SKILL.md +25 -25
- package/DIR_METADATA +8 -1
- package/docs/cookbook/localization.md +1 -1
- package/docs/ui_engineering.md +24 -0
- package/eslint.config.mjs +0 -1
- package/front_end/application_tokens.css +1 -1
- package/front_end/core/host/AidaClient.ts +147 -202
- package/front_end/core/host/AidaClientTypes.ts +9 -0
- package/front_end/core/host/AidaErrors.ts +416 -0
- package/front_end/core/host/AidaGcaTranslation.ts +11 -0
- package/front_end/core/host/InspectorFrontendHostAPI.ts +9 -2
- package/front_end/core/host/UserMetrics.ts +25 -0
- package/front_end/core/host/UserMetricsEnums.ts +25 -0
- package/front_end/core/host/host.ts +3 -1
- package/front_end/core/i18n/collect-ui-strings.js +20 -0
- package/front_end/core/root/Runtime.ts +12 -0
- package/front_end/core/sdk/CPUThrottlingManager.ts +3 -0
- package/front_end/core/sdk/EnhancedTracesParser.ts +8 -4
- package/front_end/core/sdk/NetworkManager.ts +0 -6
- package/front_end/core/sdk/OverlayModel.ts +0 -6
- package/front_end/core/sdk/PreloadingModel.ts +30 -13
- package/front_end/core/sdk/PrivateVerificationTokensModel.ts +0 -18
- package/front_end/core/sdk/RehydratingConnection.ts +5 -2
- package/front_end/core/sdk/ResourceTreeModel.ts +0 -42
- package/front_end/core/sdk/ScreenCaptureModel.ts +0 -84
- package/front_end/core/sdk/ServiceWorkerCacheModel.ts +0 -15
- package/front_end/core/sdk/StorageBucketsModel.ts +0 -15
- package/front_end/devtools_compatibility.js +57 -2
- package/front_end/entrypoints/formatter_worker/ScopeParser.ts +4 -2
- package/front_end/entrypoints/inspector_main/RenderingOptions.ts +203 -127
- package/front_end/entrypoints/inspector_main/renderingOptions.css +5 -0
- package/front_end/entrypoints/node_app/app/NodeMain.ts +0 -9
- package/front_end/entrypoints/node_app/app/nodeConnectionsPanel.css +0 -22
- package/front_end/generated/InspectorBackendCommands.ts +1 -1
- package/front_end/generated/SupportedCSSProperties.ts +0 -136
- package/front_end/generated/protocol-proxy-api.d.ts +231 -231
- package/front_end/generated/protocol.ts +1 -0
- package/front_end/models/ai_assistance/AiAgent2.ts +4 -1
- package/front_end/models/ai_assistance/ChangeManager.ts +3 -1
- package/front_end/models/ai_assistance/DOMHelpers.ts +118 -3
- package/front_end/models/ai_assistance/ExtensionScope.ts +31 -24
- package/front_end/models/ai_assistance/agents/AiAgent.ts +6 -0
- package/front_end/models/ai_assistance/agents/PerformanceAgent.snapshot.txt +13 -13
- package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +1 -1
- package/front_end/models/ai_assistance/ai_assistance.ts +2 -0
- package/front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.snapshot.txt +18 -8
- package/front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.ts +2 -2
- package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.snapshot.txt +103 -81
- package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.ts +15 -203
- package/front_end/models/ai_assistance/injected.ts +6 -1
- package/front_end/models/ai_assistance/skills/lighthouse.md +1 -1
- package/front_end/models/ai_assistance/skills/styling.md +8 -10
- package/front_end/models/ai_assistance/tools/GetTraceEventByKey.ts +1 -1
- package/front_end/models/ai_assistance/tools/SetElementStyles.ts +288 -0
- package/front_end/models/ai_assistance/tools/Tool.ts +1 -0
- package/front_end/models/ai_assistance/tools/ToolRegistry.ts +3 -0
- package/front_end/models/bindings/ResourceScriptMapping.ts +64 -16
- package/front_end/models/comment_manager/CD4ABridge.ts +12 -2
- package/front_end/models/comment_manager/CommentManager.ts +24 -4
- package/front_end/models/javascript_metadata/NativeFunctions.ts +41 -1
- package/front_end/models/project_settings/ProjectSettingsModel.ts +1 -1
- package/front_end/models/trace/handlers/FlowsHandler.ts +10 -0
- package/front_end/models/trace/handlers/SamplesHandler.ts +3 -2
- package/front_end/models/trace/handlers/ScriptsHandler.ts +25 -26
- package/front_end/models/trace/helpers/TreeHelpers.ts +4 -0
- package/front_end/models/trace/insights/DuplicatedJavaScript.ts +1 -2
- package/front_end/models/trace/types/TraceEvents.ts +21 -22
- package/front_end/panels/ai_assistance/components/ChatMessage.ts +9 -1
- package/front_end/panels/ai_assistance/components/chatInput.css +4 -4
- package/front_end/panels/animation/AnimationTimeline.ts +3 -3
- package/front_end/panels/animation/animationTimeline.css +6 -4
- package/front_end/panels/application/IndexedDBModel.ts +0 -15
- package/front_end/panels/application/appManifestView.css +2 -5
- package/front_end/panels/application/components/backForwardCacheView.css +1 -5
- package/front_end/panels/application/components/serviceWorkerRouterView.css +2 -2
- package/front_end/panels/application/preloading/components/PreloadingString.ts +7 -0
- package/front_end/panels/comments/CommentsPane.ts +12 -7
- package/front_end/panels/comments/commentsPane.css +16 -2
- package/front_end/panels/common/CommentsOverlayWidget.ts +16 -10
- package/front_end/panels/common/CommentsStatusBarPill.ts +12 -5
- package/front_end/panels/common/commentsOverlay.css +7 -1
- package/front_end/panels/common/commentsStatusBarPill.css +30 -0
- package/front_end/panels/console/consolePrompt.css +0 -12
- package/front_end/panels/console/consoleView.css +2 -2
- package/front_end/panels/developer_resources/developerResourcesView.css +4 -3
- package/front_end/panels/elements/DOMTreeWidget.ts +29 -9
- package/front_end/panels/elements/StylePropertyTreeElement.ts +2 -1
- package/front_end/panels/elements/components/CSSHintDetailsView.ts +12 -5
- package/front_end/panels/elements/components/cssVariableValueView.css +1 -1
- package/front_end/panels/elements/components/elementsBreadcrumbs.css +2 -2
- package/front_end/panels/elements/domTreeWidget.css +6 -1
- package/front_end/panels/elements/elementsPanel.css +0 -6
- package/front_end/panels/elements/layoutPane.css +1 -1
- package/front_end/panels/elements/metricsSidebarPane.css +1 -1
- package/front_end/panels/elements/platformFontsWidget.css +1 -1
- package/front_end/panels/elements/stylesSidebarPane.css +0 -10
- package/front_end/panels/emulation/deviceModeView.css +6 -7
- package/front_end/panels/explain/components/consoleInsight.css +4 -4
- package/front_end/panels/issues/issuesTree.css +1 -26
- package/front_end/panels/lighthouse/lighthouseStartView.css +2 -2
- package/front_end/panels/linear_memory_inspector/components/linearMemoryInspector.css +1 -1
- package/front_end/panels/media/TickingFlameChart.ts +20 -3
- package/front_end/panels/media/playerMessagesView.css +2 -2
- package/front_end/panels/mobile_throttling/ThrottlingSettingsTab.ts +24 -5
- package/front_end/panels/mobile_throttling/throttlingSettingsTab.css +1 -6
- package/front_end/panels/network/networkLogView.css +2 -2
- package/front_end/panels/network/networkTimingTable.css +1 -1
- package/front_end/panels/performance_monitor/performanceMonitor.css +0 -4
- package/front_end/panels/protocol_monitor/JSONEditor.css +1 -1
- package/front_end/panels/protocol_monitor/JSONEditor.ts +4 -2
- package/front_end/panels/recorder/recorderPanel.css +3 -3
- package/front_end/panels/recorder/recordingListView.css +1 -1
- package/front_end/panels/screencast/screencastView.css +1 -1
- package/front_end/panels/search/searchResultsPane.css +1 -1
- package/front_end/panels/security/SecurityModel.ts +0 -6
- package/front_end/panels/security/SecurityPanel.ts +120 -108
- package/front_end/panels/security/originView.css +1 -1
- package/front_end/panels/sensors/locationsSettingsTab.css +3 -3
- package/front_end/panels/settings/EditFileSystemView.ts +159 -104
- package/front_end/panels/settings/editFileSystemView.css +30 -4
- package/front_end/panels/settings/emulation/devicesSettingsTab.css +0 -52
- package/front_end/panels/settings/settingsScreen.css +0 -7
- package/front_end/panels/sources/CallStackSidebarPane.ts +339 -221
- package/front_end/panels/sources/NavigatorView.ts +95 -8
- package/front_end/panels/sources/ThreadsSidebarPane.ts +8 -4
- package/front_end/panels/sources/breakpointsView.css +1 -3
- package/front_end/panels/sources/callStackSidebarPane.css +4 -0
- package/front_end/panels/sources/components/HeadersView.ts +15 -2
- package/front_end/panels/sources/watchExpressionsSidebarPane.css +0 -1
- package/front_end/panels/timeline/CountersGraph.ts +0 -4
- package/front_end/panels/timeline/TimelineLoader.ts +16 -6
- package/front_end/panels/timeline/TimelinePanel.ts +20 -12
- package/front_end/panels/timeline/TimelineUIUtils.ts +1 -1
- package/front_end/panels/timeline/components/DetailsView.ts +2 -1
- package/front_end/panels/timeline/components/cwvMetrics.css +1 -1
- package/front_end/panels/timeline/components/metricCard.css +1 -1
- package/front_end/panels/timeline/components/sidebarAnnotationsTab.css +4 -4
- package/front_end/panels/timeline/timelineFlameChartView.css +1 -1
- package/front_end/panels/webauthn/WebauthnPane.ts +13 -14
- package/front_end/panels/webauthn/webauthnPane.css +1 -1
- package/front_end/third_party/chromium/README.chromium +1 -1
- package/front_end/ui/comments/CommentOverlayManager.ts +34 -18
- package/front_end/ui/components/icon_button/FileSourceIcon.ts +6 -0
- package/front_end/ui/components/input/textInput.css +1 -1
- package/front_end/ui/components/panel_introduction_steps/panelIntroductionSteps.css +6 -4
- package/front_end/ui/components/suggestion_input/suggestionInput.css +2 -2
- package/front_end/ui/components/text_editor/AiCodeGenerationTeaser.ts +14 -2
- package/front_end/ui/legacy/DockController.ts +17 -4
- package/front_end/ui/legacy/Treeoutline.ts +2 -2
- package/front_end/ui/legacy/UIUtils.ts +148 -10
- package/front_end/ui/legacy/components/inline_editor/bezierEditor.css +3 -2
- package/front_end/ui/legacy/components/perf_ui/chartViewport.css +2 -2
- package/front_end/ui/legacy/components/perf_ui/filmStripView.css +2 -2
- package/front_end/ui/legacy/components/perf_ui/pieChart.css +1 -1
- package/front_end/ui/legacy/components/quick_open/filteredListWidget.css +5 -4
- package/front_end/ui/legacy/components/source_frame/imageView.css +1 -1
- package/front_end/ui/legacy/components/utils/TargetDetachedDialog.ts +0 -3
- package/front_end/ui/legacy/components/utils/imagePreview.css +1 -1
- package/front_end/ui/legacy/inspectorCommon.css +1 -14
- package/front_end/ui/legacy/inspectorDrawerTabbedPane.css +3 -2
- package/front_end/ui/legacy/listWidget.css +0 -18
- package/front_end/ui/legacy/theme_support/ThemeSupport.ts +44 -9
- package/front_end/ui/lit/strip-whitespace.ts +1 -1
- package/front_end/ui/visual_logging/KnownContextValues.ts +1 -0
- package/package.json +3 -3
- package/front_end/generated/Deprecation.ts +0 -471
- package/front_end/panels/accessibility/axBreadcrumbs.css +0 -155
- package/front_end/panels/network/requestHeadersTree.css +0 -226
- package/front_end/panels/recorder/startView.css +0 -38
- package/front_end/panels/security/ipProtectionView.css +0 -141
- package/front_end/ui/legacy/components/inline_editor/animationNameSwatch.css +0 -27
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
// Copyright 2026 The Chromium Authors
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
import * as Host from '../../../core/host/host.js';
|
|
6
|
+
import * as Platform from '../../../core/platform/platform.js';
|
|
7
|
+
import * as SDK from '../../../core/sdk/sdk.js';
|
|
8
|
+
import type * as Protocol from '../../../generated/protocol.js';
|
|
9
|
+
import type {FunctionHandlerOptions} from '../agents/AiAgent.js';
|
|
10
|
+
import type {ChangeManager} from '../ChangeManager.js';
|
|
11
|
+
import {
|
|
12
|
+
adoptStyleSheetInShadowRoot,
|
|
13
|
+
removeInlineStyleProperties,
|
|
14
|
+
sanitizeStyleChanges,
|
|
15
|
+
} from '../DOMHelpers.js';
|
|
16
|
+
import {ExtensionScope} from '../ExtensionScope.js';
|
|
17
|
+
import {AI_ASSISTANCE_CSS_CLASS_NAME} from '../injected.js';
|
|
18
|
+
|
|
19
|
+
import {
|
|
20
|
+
type BaseToolCapability,
|
|
21
|
+
type DataHandlerResult,
|
|
22
|
+
type DataTool,
|
|
23
|
+
isOriginAllowedByLock,
|
|
24
|
+
type OriginLockCapability,
|
|
25
|
+
PermissionPrompt,
|
|
26
|
+
type StyleMutationCapability,
|
|
27
|
+
type TargetCapability,
|
|
28
|
+
type ToolArgs,
|
|
29
|
+
ToolName,
|
|
30
|
+
} from './Tool.js';
|
|
31
|
+
|
|
32
|
+
export interface StylePropertyChange {
|
|
33
|
+
name: string;
|
|
34
|
+
value: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface SetElementStylesArgs extends ToolArgs {
|
|
38
|
+
elements: number[];
|
|
39
|
+
styleProperties: StylePropertyChange[];
|
|
40
|
+
explanation: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* V2 SDK-based equivalent of the page-injected `setElementStyles` function
|
|
45
|
+
* used by V1 `StylingAgent` (see `injected.ts` and
|
|
46
|
+
* `ExtensionScope#bindingCalled`, tracked for removal in b/581814240).
|
|
47
|
+
*
|
|
48
|
+
* This tool is designed to be behaviorally identical to the V1 `execJs`
|
|
49
|
+
* implementation—computing the element selector, sanitizing declarations,
|
|
50
|
+
* assigning an `ai-style-change-<id>` class, stripping overridden inline
|
|
51
|
+
* styles, registering the rule in `ChangeManager`, and adopting the stylesheet
|
|
52
|
+
* in any enclosing `ShadowRoot`—while operating through `DOMModel`, `CSSModel`,
|
|
53
|
+
* and `ChangeManager` without `execJs` or an `ExtensionScope` isolated world.
|
|
54
|
+
* Any behavioral changes here must stay in sync with V1 until b/581814240
|
|
55
|
+
* lands.
|
|
56
|
+
*/
|
|
57
|
+
export class SetElementStylesTool implements DataTool<
|
|
58
|
+
SetElementStylesArgs, string, BaseToolCapability&TargetCapability&OriginLockCapability&StyleMutationCapability> {
|
|
59
|
+
readonly name: ToolName = ToolName.SET_ELEMENT_STYLES;
|
|
60
|
+
readonly permissionPrompt: PermissionPrompt = PermissionPrompt.NEVER;
|
|
61
|
+
readonly description: string =
|
|
62
|
+
'Applies CSS style declarations to one or more elements on the inspected page identified by their backend node IDs (uids). Prefer this tool over executeJavaScript whenever modifying or testing CSS styles on elements.';
|
|
63
|
+
|
|
64
|
+
readonly parameters: Host.AidaClient.FunctionObjectParam<keyof SetElementStylesArgs> = {
|
|
65
|
+
type: Host.AidaClient.ParametersTypes.OBJECT,
|
|
66
|
+
description: '',
|
|
67
|
+
nullable: false,
|
|
68
|
+
properties: {
|
|
69
|
+
explanation: {
|
|
70
|
+
type: Host.AidaClient.ParametersTypes.STRING,
|
|
71
|
+
description: 'Explain why you want to apply these style changes to the elements.',
|
|
72
|
+
nullable: false,
|
|
73
|
+
},
|
|
74
|
+
elements: {
|
|
75
|
+
type: Host.AidaClient.ParametersTypes.ARRAY,
|
|
76
|
+
description:
|
|
77
|
+
'A list of element uids (backend node IDs) to apply the styles to. These are numbers, not CSS selectors.',
|
|
78
|
+
nullable: false,
|
|
79
|
+
items: {
|
|
80
|
+
type: Host.AidaClient.ParametersTypes.INTEGER,
|
|
81
|
+
description: 'An element uid.',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
styleProperties: {
|
|
85
|
+
type: Host.AidaClient.ParametersTypes.ARRAY,
|
|
86
|
+
description:
|
|
87
|
+
'One or more CSS style declarations (property name and value pairs) to apply to the specified elements.',
|
|
88
|
+
nullable: false,
|
|
89
|
+
items: {
|
|
90
|
+
type: Host.AidaClient.ParametersTypes.OBJECT,
|
|
91
|
+
description: 'A CSS property name and value pair.',
|
|
92
|
+
properties: {
|
|
93
|
+
name: {
|
|
94
|
+
type: Host.AidaClient.ParametersTypes.STRING,
|
|
95
|
+
description:
|
|
96
|
+
'The CSS property name in kebab-case (for example, \'background-color\' or \'justify-content\').',
|
|
97
|
+
nullable: false,
|
|
98
|
+
},
|
|
99
|
+
value: {
|
|
100
|
+
type: Host.AidaClient.ParametersTypes.STRING,
|
|
101
|
+
description: 'The CSS property value to set (for example, \'flex\' or \'16px\').',
|
|
102
|
+
nullable: false,
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
required: ['name', 'value'],
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
required: ['explanation', 'elements', 'styleProperties'],
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
displayInfoFromArgs(params: SetElementStylesArgs): {
|
|
113
|
+
title: string,
|
|
114
|
+
thought: string,
|
|
115
|
+
action: string,
|
|
116
|
+
} {
|
|
117
|
+
const styles = Object.fromEntries(params.styleProperties?.map(p => [p.name, p.value]) ?? []);
|
|
118
|
+
return {
|
|
119
|
+
title: 'Applying style changes',
|
|
120
|
+
thought: params.explanation,
|
|
121
|
+
action: `setElementStyles(${JSON.stringify(params.elements)}, ${JSON.stringify(styles)})`,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Handles applying CSS style declarations to specified elements.
|
|
127
|
+
*
|
|
128
|
+
* Resolves element backend node IDs using the primary page target, verifies
|
|
129
|
+
* security origin locks, sanitizes CSS declarations, and registers style
|
|
130
|
+
* rules via ChangeManager and DOM/CSS SDK models.
|
|
131
|
+
*/
|
|
132
|
+
async handler(
|
|
133
|
+
params: SetElementStylesArgs,
|
|
134
|
+
context: BaseToolCapability&TargetCapability&OriginLockCapability&StyleMutationCapability,
|
|
135
|
+
_options?: FunctionHandlerOptions,
|
|
136
|
+
): Promise<DataHandlerResult<string>> {
|
|
137
|
+
const target = context.getTarget();
|
|
138
|
+
if (!target) {
|
|
139
|
+
return {error: 'Error: Could not find the inspected page.'};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (!params.elements?.length) {
|
|
143
|
+
return {error: 'Error: No elements provided.'};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (!params.styleProperties?.length) {
|
|
147
|
+
return {error: 'Error: No style properties provided.'};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const styles = Platform.StringUtilities.toKebabCaseKeys(
|
|
151
|
+
Object.fromEntries(params.styleProperties.map(p => [p.name, p.value])),
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
const maybeResolvedNodes = await Promise.all(
|
|
155
|
+
params.elements.map(
|
|
156
|
+
uid => new SDK.DOMModel.DeferredDOMNode(target, uid as Protocol.DOM.BackendNodeId).resolvePromise()),
|
|
157
|
+
);
|
|
158
|
+
const resolvedNodes: SDK.DOMModel.DOMNode[] = [];
|
|
159
|
+
for (let i = 0; i < params.elements.length; i++) {
|
|
160
|
+
const resolved = maybeResolvedNodes[i];
|
|
161
|
+
if (!resolved) {
|
|
162
|
+
return {error: 'Error: Could not find the element with uid=' + params.elements[i]};
|
|
163
|
+
}
|
|
164
|
+
if (!isOriginAllowedByLock(context.getOriginLock(), resolved.securityOrigin())) {
|
|
165
|
+
return {error: 'Error: Node does not belong to the current origin.'};
|
|
166
|
+
}
|
|
167
|
+
resolvedNodes.push(resolved);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const appliedProperties = new Set<string>();
|
|
171
|
+
const ignoredProperties = new Set<string>();
|
|
172
|
+
try {
|
|
173
|
+
for (const resolvedNode of resolvedNodes) {
|
|
174
|
+
const nodeResult = await this.#applyStyleChangesToNode(resolvedNode, styles, context.changeManager);
|
|
175
|
+
if ('error' in nodeResult) {
|
|
176
|
+
return nodeResult;
|
|
177
|
+
}
|
|
178
|
+
for (const prop of nodeResult.applied) {
|
|
179
|
+
appliedProperties.add(prop);
|
|
180
|
+
}
|
|
181
|
+
for (const prop of nodeResult.ignored) {
|
|
182
|
+
ignoredProperties.add(prop);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
} catch (error) {
|
|
186
|
+
return {
|
|
187
|
+
error: error instanceof Error ? `Error: ${error.message}` : 'Error: Failed to apply element styles.',
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (ignoredProperties.size > 0) {
|
|
192
|
+
return {
|
|
193
|
+
result: `Successfully updated styles (${
|
|
194
|
+
[...appliedProperties].join(
|
|
195
|
+
', ')}). The following properties were ignored because they are invalid CSS or contain disallowed URL functions (url(), image-set(), src()): ${
|
|
196
|
+
[...ignoredProperties].join(', ')}.`,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return {result: 'Successfully updated styles.'};
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Applies style changes to a single resolved DOMNode using the same steps as
|
|
205
|
+
* `setElementStyles` (`injected.ts`) and `ExtensionScope#bindingCalled`.
|
|
206
|
+
*/
|
|
207
|
+
async #applyStyleChangesToNode(
|
|
208
|
+
resolvedNode: SDK.DOMModel.DOMNode,
|
|
209
|
+
styles: Record<string, string>,
|
|
210
|
+
changeManager: ChangeManager,
|
|
211
|
+
): Promise<{error: string}|{applied: string[], ignored: string[]}> {
|
|
212
|
+
const domModel = resolvedNode.domModel();
|
|
213
|
+
const cssModel = domModel.cssModel();
|
|
214
|
+
const frameId =
|
|
215
|
+
resolvedNode.frameId() ?? domModel.target().model(SDK.ResourceTreeModel.ResourceTreeModel)?.mainFrame?.id;
|
|
216
|
+
if (!frameId) {
|
|
217
|
+
return {error: 'Error: Main frame is not found for applying styles.'};
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Prefer extracting a selector from the element's existing matched CSS
|
|
221
|
+
// rules rather than a generic tag/class fallback so the injected nested
|
|
222
|
+
// rule (`selector&`) matches the specificity context of the element's
|
|
223
|
+
// primary existing rule.
|
|
224
|
+
let matchedStyles: SDK.CSSMatchedStyles.CSSMatchedStyles|null = null;
|
|
225
|
+
try {
|
|
226
|
+
matchedStyles = await cssModel.getMatchedStyles(resolvedNode.id);
|
|
227
|
+
} catch {
|
|
228
|
+
// Leave matchedStyles as null so getSelectorForElement falls back to a
|
|
229
|
+
// simple tag/id/class selector (`getSelectorForNode`).
|
|
230
|
+
}
|
|
231
|
+
const selector = ExtensionScope.getSelectorForElement(resolvedNode, matchedStyles);
|
|
232
|
+
|
|
233
|
+
const sanitizedStyles = await sanitizeStyleChanges(selector, styles);
|
|
234
|
+
const applied = Object.keys(sanitizedStyles);
|
|
235
|
+
if (applied.length === 0) {
|
|
236
|
+
return {
|
|
237
|
+
error:
|
|
238
|
+
'Error: None of the suggested CSS properties or their values for selector were considered valid or permitted (URL functions such as url(), image-set(), and src() are not allowed). Please ensure property names are correct and values match the expected format for those properties.',
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
const ignored = Object.keys(styles).filter(key => !(key in sanitizedStyles));
|
|
242
|
+
|
|
243
|
+
// Reuse an existing AI style class if present to prevent appending
|
|
244
|
+
// duplicates on successive tool calls against the same element.
|
|
245
|
+
const existingClasses = (resolvedNode.getAttribute('class') ?? '').split(/\s+/).filter(Boolean);
|
|
246
|
+
let className = existingClasses.find(cls => cls.startsWith(`${AI_ASSISTANCE_CSS_CLASS_NAME}-`));
|
|
247
|
+
if (!className) {
|
|
248
|
+
className = `${AI_ASSISTANCE_CSS_CLASS_NAME}-${resolvedNode.backendNodeId()}`;
|
|
249
|
+
await resolvedNode.setAttributeValuePromise('class', [...existingClasses, className].join(' '));
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Inline styles have higher specificity than the stylesheet rules injected
|
|
253
|
+
// by ChangeManager. Remove any inline properties being modified so the new
|
|
254
|
+
// rules take effect.
|
|
255
|
+
const inlineStyle = resolvedNode.getAttribute('style');
|
|
256
|
+
if (inlineStyle) {
|
|
257
|
+
const updatedInlineStyle = removeInlineStyleProperties(inlineStyle, sanitizedStyles);
|
|
258
|
+
if (updatedInlineStyle !== inlineStyle) {
|
|
259
|
+
await resolvedNode.setAttributeValuePromise('style', updatedInlineStyle);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const styleChanges = await changeManager.addChange(cssModel, frameId, {
|
|
264
|
+
selector,
|
|
265
|
+
className,
|
|
266
|
+
styles: sanitizedStyles,
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
// ChangeManager registers rules in the document-level inspector stylesheet,
|
|
270
|
+
// which does not penetrate Shadow DOM. When the target element is inside a
|
|
271
|
+
// shadow tree, adopt the generated stylesheet onto its enclosing ShadowRoot.
|
|
272
|
+
if (resolvedNode.isInShadowTree()) {
|
|
273
|
+
const remoteObject = await resolvedNode.resolveToObject('');
|
|
274
|
+
if (remoteObject) {
|
|
275
|
+
try {
|
|
276
|
+
await remoteObject.callFunction(adoptStyleSheetInShadowRoot, [
|
|
277
|
+
{value: AI_ASSISTANCE_CSS_CLASS_NAME},
|
|
278
|
+
{value: styleChanges},
|
|
279
|
+
]);
|
|
280
|
+
} finally {
|
|
281
|
+
remoteObject.release();
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
return {applied, ignored};
|
|
287
|
+
}
|
|
288
|
+
}
|
|
@@ -27,6 +27,7 @@ import {RecordPerformanceTraceTool} from './RecordPerformanceTrace.js';
|
|
|
27
27
|
import {ResolveDevtoolsNodePathTool} from './ResolveDevtoolsNodePath.js';
|
|
28
28
|
import {RunLighthouseTool} from './RunLighthouse.js';
|
|
29
29
|
import {SelectTraceEventByKeyTool} from './SelectTraceEventByKey.js';
|
|
30
|
+
import {SetElementStylesTool} from './SetElementStyles.js';
|
|
30
31
|
import {type AllToolsCapabilities, type Tool, type ToolArgs, ToolName} from './Tool.js';
|
|
31
32
|
|
|
32
33
|
export interface BaseToolsRegistryMap {
|
|
@@ -55,6 +56,7 @@ export interface BaseToolsRegistryMap {
|
|
|
55
56
|
[ToolName.GET_TRACE_RESOURCE_CONTENT]: GetTraceResourceContentTool;
|
|
56
57
|
[ToolName.GET_INSIGHT_DETAILS]: GetInsightDetailsTool;
|
|
57
58
|
[ToolName.GET_STORAGE_BREAKDOWN]: GetStorageBreakdownTool;
|
|
59
|
+
[ToolName.SET_ELEMENT_STYLES]: SetElementStylesTool;
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
export type ToolsRegistryMap = BaseToolsRegistryMap&{
|
|
@@ -90,6 +92,7 @@ export const TOOLS: BaseToolsRegistryMap = {
|
|
|
90
92
|
[ToolName.GET_TRACE_RESOURCE_CONTENT]: new GetTraceResourceContentTool(),
|
|
91
93
|
[ToolName.GET_INSIGHT_DETAILS]: new GetInsightDetailsTool(),
|
|
92
94
|
[ToolName.GET_STORAGE_BREAKDOWN]: new GetStorageBreakdownTool(),
|
|
95
|
+
[ToolName.SET_ELEMENT_STYLES]: new SetElementStylesTool(),
|
|
93
96
|
};
|
|
94
97
|
|
|
95
98
|
/**
|
|
@@ -60,15 +60,23 @@ export class ResourceScriptMapping implements DebuggerSourceMapping {
|
|
|
60
60
|
];
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
#
|
|
63
|
+
#projectId(script: SDK.Script.Script): string {
|
|
64
64
|
const prefix = script.isContentScript() ? 'js:extensions:' : 'js::';
|
|
65
|
-
const
|
|
65
|
+
const securityOrigin = script.securityOrigin();
|
|
66
|
+
// Put opaque scripts from the same frame into one project so each eval()
|
|
67
|
+
// does not make a new project and re-running a script replaces the old file.
|
|
68
|
+
const originPart = securityOrigin.isOpaque() ? '' : `:${securityOrigin.siteId()}`;
|
|
69
|
+
return `${prefix}${this.debuggerModel.target().id()}:${script.frameId}${originPart}`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
#project(script: SDK.Script.Script): ContentProviderBasedProject {
|
|
73
|
+
const projectId = this.#projectId(script);
|
|
66
74
|
let project = this.#projects.get(projectId);
|
|
67
75
|
if (!project) {
|
|
68
76
|
const projectType = script.isContentScript() ? Workspace.Workspace.projectTypes.ContentScripts :
|
|
69
77
|
Workspace.Workspace.projectTypes.Network;
|
|
70
78
|
project = new ContentProviderBasedProject(this.#workspace, projectId, projectType, '' /* displayName */,
|
|
71
|
-
false /* isServiceProject
|
|
79
|
+
false /* isServiceProject */, script.securityOrigin());
|
|
72
80
|
NetworkProject.setTargetForProject(project, this.debuggerModel.target());
|
|
73
81
|
this.#projects.set(projectId, project);
|
|
74
82
|
}
|
|
@@ -237,10 +245,9 @@ export class ResourceScriptMapping implements DebuggerSourceMapping {
|
|
|
237
245
|
return;
|
|
238
246
|
}
|
|
239
247
|
|
|
240
|
-
// Don't let a synthetic source evict the `UISourceCode` of a script
|
|
241
|
-
// actually fetched from the network under the same URL.
|
|
242
|
-
|
|
243
|
-
if (previousUISourceCode && !NetworkProject.isSourceURLSynthesized(previousUISourceCode)) {
|
|
248
|
+
// Don't let a synthetic source evict or shadow the `UISourceCode` of a script
|
|
249
|
+
// that was actually fetched from the network under the same URL.
|
|
250
|
+
if (this.#hasNetworkUISourceCode(url, script.isContentScript())) {
|
|
244
251
|
return;
|
|
245
252
|
}
|
|
246
253
|
} else {
|
|
@@ -258,17 +265,10 @@ export class ResourceScriptMapping implements DebuggerSourceMapping {
|
|
|
258
265
|
}
|
|
259
266
|
}
|
|
260
267
|
|
|
261
|
-
|
|
262
|
-
const project = this.#project(script);
|
|
263
|
-
const oldUISourceCode = project.uiSourceCodeForURL(url);
|
|
264
|
-
if (oldUISourceCode) {
|
|
265
|
-
const oldScriptFile = this.#uiSourceCodeToScriptFile.get(oldUISourceCode);
|
|
266
|
-
if (oldScriptFile?.script) {
|
|
267
|
-
this.#removeScripts([oldScriptFile.script]);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
268
|
+
this.#removePreviousUISourceCodes(script, url);
|
|
270
269
|
|
|
271
270
|
// Create UISourceCode.
|
|
271
|
+
const project = this.#project(script);
|
|
272
272
|
const originalContentProvider = script.originalContentProvider();
|
|
273
273
|
const uiSourceCode = project.createUISourceCode(url, originalContentProvider.contentType());
|
|
274
274
|
if (script.hasSourceURL) {
|
|
@@ -287,6 +287,27 @@ export class ResourceScriptMapping implements DebuggerSourceMapping {
|
|
|
287
287
|
void this.debuggerWorkspaceBinding.updateLocations(script);
|
|
288
288
|
}
|
|
289
289
|
|
|
290
|
+
#uiSourceCodesForURL(url: Platform.DevToolsPath.UrlString,
|
|
291
|
+
isContentScript: boolean): Workspace.UISourceCode.UISourceCode[] {
|
|
292
|
+
const projectType =
|
|
293
|
+
isContentScript ? Workspace.Workspace.projectTypes.ContentScripts : Workspace.Workspace.projectTypes.Network;
|
|
294
|
+
const result: Workspace.UISourceCode.UISourceCode[] = [];
|
|
295
|
+
for (const project of this.#projects.values()) {
|
|
296
|
+
if (project.type() === projectType) {
|
|
297
|
+
const uiSourceCode = project.uiSourceCodeForURL(url);
|
|
298
|
+
if (uiSourceCode) {
|
|
299
|
+
result.push(uiSourceCode);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return result;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
#hasNetworkUISourceCode(url: Platform.DevToolsPath.UrlString, isContentScript: boolean): boolean {
|
|
307
|
+
return this.#uiSourceCodesForURL(url, isContentScript)
|
|
308
|
+
.some(uiSourceCode => !NetworkProject.isSourceURLSynthesized(uiSourceCode));
|
|
309
|
+
}
|
|
310
|
+
|
|
290
311
|
/**
|
|
291
312
|
* Whether the (already resolved) `//# sourceURL=` annotation `url` of `script` may
|
|
292
313
|
* be used as-is.
|
|
@@ -324,6 +345,33 @@ export class ResourceScriptMapping implements DebuggerSourceMapping {
|
|
|
324
345
|
return this.#uiSourceCodeToScriptFile.get(uiSourceCode) || null;
|
|
325
346
|
}
|
|
326
347
|
|
|
348
|
+
#removePreviousUISourceCodes(script: SDK.Script.Script, url: Platform.DevToolsPath.UrlString): void {
|
|
349
|
+
const scriptsToRemove = new Set<SDK.Script.Script>();
|
|
350
|
+
|
|
351
|
+
// A genuine network script also evicts any synthetic `//# sourceURL=` entries that
|
|
352
|
+
// claimed `url` in other origin partitions before the network script arrived.
|
|
353
|
+
if (!script.hasSourceURL) {
|
|
354
|
+
for (const existing of this.#uiSourceCodesForURL(url, script.isContentScript())) {
|
|
355
|
+
if (NetworkProject.isSourceURLSynthesized(existing)) {
|
|
356
|
+
const oldScript = this.#uiSourceCodeToScriptFile.get(existing)?.script;
|
|
357
|
+
if (oldScript) {
|
|
358
|
+
scriptsToRemove.add(oldScript);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
const oldUISourceCode = this.#projects.get(this.#projectId(script))?.uiSourceCodeForURL(url);
|
|
365
|
+
const oldScript = oldUISourceCode ? this.#uiSourceCodeToScriptFile.get(oldUISourceCode)?.script : null;
|
|
366
|
+
if (oldScript) {
|
|
367
|
+
scriptsToRemove.add(oldScript);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
if (scriptsToRemove.size > 0) {
|
|
371
|
+
this.#removeScripts([...scriptsToRemove]);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
327
375
|
#removeScripts(scripts: SDK.Script.Script[]): void {
|
|
328
376
|
const uiSourceCodesByProject =
|
|
329
377
|
new Platform.MapUtilities.Multimap<ContentProviderBasedProject, Workspace.UISourceCode.UISourceCode>();
|
|
@@ -13,6 +13,11 @@ import * as CommentManager from './CommentManager.js';
|
|
|
13
13
|
export interface CommentThread {
|
|
14
14
|
id: string;
|
|
15
15
|
text: string;
|
|
16
|
+
/**
|
|
17
|
+
* True if an earlier call already transmitted this thread to the agent.
|
|
18
|
+
* Only set when `includeTransmitted` is requested.
|
|
19
|
+
*/
|
|
20
|
+
previouslyTransmitted?: boolean;
|
|
16
21
|
networkRequestId?: string;
|
|
17
22
|
node?: CommentManager.DOMNodeAnchorSignature;
|
|
18
23
|
}
|
|
@@ -124,13 +129,18 @@ export class CD4ABridge extends Common.ObjectWrapper.ObjectWrapper<EventTypes> {
|
|
|
124
129
|
return rawText ? `${rawText}\n\n${details.join('\n')}` : details.join('\n');
|
|
125
130
|
}
|
|
126
131
|
|
|
127
|
-
getCommentThreads(): CommentThread[] {
|
|
128
|
-
const
|
|
132
|
+
getCommentThreads(options?: CommentManager.TakeCommentsOptions): CommentThread[] {
|
|
133
|
+
const previouslyTransmittedIds =
|
|
134
|
+
new Set(this.#commentManager.getCommentThreads().filter(thread => thread.transmitted).map(thread => thread.id));
|
|
135
|
+
const threads = this.#commentManager.takeComments(options);
|
|
129
136
|
return threads.map(thread => {
|
|
130
137
|
const threadPayload: CommentThread = {
|
|
131
138
|
id: thread.id,
|
|
132
139
|
text: this.#formatCommentText(thread),
|
|
133
140
|
};
|
|
141
|
+
if (previouslyTransmittedIds.has(thread.id)) {
|
|
142
|
+
threadPayload.previouslyTransmitted = true;
|
|
143
|
+
}
|
|
134
144
|
if (thread.anchor.networkRequestId) {
|
|
135
145
|
threadPayload.networkRequestId = thread.anchor.networkRequestId;
|
|
136
146
|
}
|
|
@@ -40,6 +40,14 @@ export interface EventTypes {
|
|
|
40
40
|
[Events.AGENT_ATTACHED_CHANGED]: boolean;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
export interface TakeCommentsOptions {
|
|
44
|
+
/**
|
|
45
|
+
* Also return threads that were sent to the agent and already transmitted
|
|
46
|
+
* by an earlier call.
|
|
47
|
+
*/
|
|
48
|
+
includeTransmitted?: boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
43
51
|
/**
|
|
44
52
|
* Headless model managing comment thread data, CRUD operations, and comment mode.
|
|
45
53
|
*/
|
|
@@ -114,16 +122,28 @@ export class CommentManager extends Common.ObjectWrapper.ObjectWrapper<EventType
|
|
|
114
122
|
return Array.from(this.#commentThreads.values());
|
|
115
123
|
}
|
|
116
124
|
|
|
117
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Returns the threads that were sent to the agent and marks them as
|
|
127
|
+
* transmitted. By default, threads that were transmitted before are
|
|
128
|
+
* skipped.
|
|
129
|
+
*/
|
|
130
|
+
takeComments({includeTransmitted = false}: TakeCommentsOptions = {}): CommentThread[] {
|
|
118
131
|
const threads: CommentThread[] = [];
|
|
132
|
+
const newlyTransmitted: CommentThread[] = [];
|
|
119
133
|
for (const thread of this.#commentThreads.values()) {
|
|
120
|
-
if (thread.status
|
|
134
|
+
if (thread.status !== 'SENT_TO_AGENT') {
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (!thread.transmitted) {
|
|
121
138
|
thread.markTransmitted();
|
|
139
|
+
newlyTransmitted.push(thread);
|
|
140
|
+
threads.push(thread);
|
|
141
|
+
} else if (includeTransmitted) {
|
|
122
142
|
threads.push(thread);
|
|
123
143
|
}
|
|
124
144
|
}
|
|
125
|
-
const changeCount =
|
|
126
|
-
const commentCount =
|
|
145
|
+
const changeCount = newlyTransmitted.filter(thread => thread.isGeneratedComment).length;
|
|
146
|
+
const commentCount = newlyTransmitted.length - changeCount;
|
|
127
147
|
if (commentCount > 0) {
|
|
128
148
|
Host.userMetrics.commentSharedWithAgent(commentCount);
|
|
129
149
|
}
|
|
@@ -6675,7 +6675,7 @@ export const NativeFunctions: readonly NativeFunctionValue[] = [
|
|
|
6675
6675
|
},
|
|
6676
6676
|
{
|
|
6677
6677
|
name: "WebTransportError",
|
|
6678
|
-
signatures: [["?init"]]
|
|
6678
|
+
signatures: [["?message","?options"],["init","?legacyIgnored"]]
|
|
6679
6679
|
},
|
|
6680
6680
|
{
|
|
6681
6681
|
name: "CloseEvent",
|
|
@@ -8121,6 +8121,10 @@ export const NativeFunctions: readonly NativeFunctionValue[] = [
|
|
|
8121
8121
|
name: "ClipboardItem",
|
|
8122
8122
|
signatures: [["items"]]
|
|
8123
8123
|
},
|
|
8124
|
+
{
|
|
8125
|
+
name: "shapeText",
|
|
8126
|
+
signatures: [["text"]]
|
|
8127
|
+
},
|
|
8124
8128
|
{
|
|
8125
8129
|
name: "fillTextCluster",
|
|
8126
8130
|
signatures: [["textCluster","x","y","?options"]]
|
|
@@ -8129,6 +8133,22 @@ export const NativeFunctions: readonly NativeFunctionValue[] = [
|
|
|
8129
8133
|
name: "strokeTextCluster",
|
|
8130
8134
|
signatures: [["textCluster","x","y","?options"]]
|
|
8131
8135
|
},
|
|
8136
|
+
{
|
|
8137
|
+
name: "fillGlyphRun",
|
|
8138
|
+
signatures: [["glyphRun","x","y"]]
|
|
8139
|
+
},
|
|
8140
|
+
{
|
|
8141
|
+
name: "strokeGlyphRun",
|
|
8142
|
+
signatures: [["glyphRun","x","y"]]
|
|
8143
|
+
},
|
|
8144
|
+
{
|
|
8145
|
+
name: "fillGlyphRuns",
|
|
8146
|
+
signatures: [["glyphRuns","x","y"]]
|
|
8147
|
+
},
|
|
8148
|
+
{
|
|
8149
|
+
name: "strokeGlyphRuns",
|
|
8150
|
+
signatures: [["glyphRuns","x","y"]]
|
|
8151
|
+
},
|
|
8132
8152
|
{
|
|
8133
8153
|
name: "beginLayer",
|
|
8134
8154
|
signatures: [["?options"]]
|
|
@@ -8733,6 +8753,26 @@ export const NativeFunctions: readonly NativeFunctionValue[] = [
|
|
|
8733
8753
|
name: "ImageData",
|
|
8734
8754
|
signatures: [["sw","sh","?settings"],["data","sw","?sh","?settings"]]
|
|
8735
8755
|
},
|
|
8756
|
+
{
|
|
8757
|
+
name: "glyphClusters",
|
|
8758
|
+
signatures: [["?start","?end"]]
|
|
8759
|
+
},
|
|
8760
|
+
{
|
|
8761
|
+
name: "selectionRects",
|
|
8762
|
+
signatures: [["start","end"]]
|
|
8763
|
+
},
|
|
8764
|
+
{
|
|
8765
|
+
name: "actualBoundingBox",
|
|
8766
|
+
signatures: [["start","end"]]
|
|
8767
|
+
},
|
|
8768
|
+
{
|
|
8769
|
+
name: "advanceToPosition",
|
|
8770
|
+
signatures: [["advance"]]
|
|
8771
|
+
},
|
|
8772
|
+
{
|
|
8773
|
+
name: "positionToAdvance",
|
|
8774
|
+
signatures: [["position"]]
|
|
8775
|
+
},
|
|
8736
8776
|
{
|
|
8737
8777
|
name: "getIndexFromOffset",
|
|
8738
8778
|
signatures: [["x"]]
|
|
@@ -118,7 +118,7 @@ export class ProjectSettingsModel extends Common.ObjectWrapper.ObjectWrapper<Eve
|
|
|
118
118
|
this,
|
|
119
119
|
);
|
|
120
120
|
const target = this.#targetManager.primaryPageTarget();
|
|
121
|
-
if (target
|
|
121
|
+
if (target) {
|
|
122
122
|
this.#inspectedURLChanged({data: target});
|
|
123
123
|
}
|
|
124
124
|
}
|
|
@@ -55,6 +55,15 @@ let flows: Types.Events.Event[][] = [];
|
|
|
55
55
|
const ID_COMPONENT_SEPARATOR = '-$-';
|
|
56
56
|
export function reset(): void {
|
|
57
57
|
flows = [];
|
|
58
|
+
resetIntermediateState();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Resets the state that is only used while the flows are computed. data()
|
|
63
|
+
* exposes only `flows`, so finalize() calls this to release the rest
|
|
64
|
+
* (on traces with many flows, `boundFlowData` alone can be tens of MB).
|
|
65
|
+
*/
|
|
66
|
+
function resetIntermediateState(): void {
|
|
58
67
|
flowEvents = [];
|
|
59
68
|
nonFlowEvents = [];
|
|
60
69
|
flowDataByGroupToken = new Map();
|
|
@@ -174,6 +183,7 @@ export async function finalize(): Promise<void> {
|
|
|
174
183
|
.map(flowMapping => [...flowMapping.values()])
|
|
175
184
|
.map(flow => flow.filter(event => event !== undefined))
|
|
176
185
|
.filter(flow => flow.length > 1);
|
|
186
|
+
resetIntermediateState();
|
|
177
187
|
}
|
|
178
188
|
|
|
179
189
|
export function data(): {flows: Types.Events.Event[][]} {
|
|
@@ -86,7 +86,6 @@ function parseCPUProfileData(parseOptions: Types.Configuration.ParseOptions): vo
|
|
|
86
86
|
|
|
87
87
|
const selectedProfileId = chosen.id;
|
|
88
88
|
const finalizedData: ProfileData = {
|
|
89
|
-
rawProfile: chosenData.rawProfile,
|
|
90
89
|
parsedProfile: profileModel,
|
|
91
90
|
profileCalls: [],
|
|
92
91
|
profileTree,
|
|
@@ -250,6 +249,9 @@ export function handleEvent(event: Types.Events.Event): void {
|
|
|
250
249
|
|
|
251
250
|
export async function finalize(parseOptions: Types.Configuration.ParseOptions = {}): Promise<void> {
|
|
252
251
|
parseCPUProfileData(parseOptions);
|
|
252
|
+
// The raw profiles are only needed to build each CPUProfileDataModel.
|
|
253
|
+
// Release them now instead of at the next reset().
|
|
254
|
+
preprocessedData = new Map();
|
|
253
255
|
}
|
|
254
256
|
|
|
255
257
|
function assignProfileSourceIfKnown(profileData: PreprocessedData, source: unknown): void {
|
|
@@ -290,7 +292,6 @@ export interface SamplesHandlerData {
|
|
|
290
292
|
|
|
291
293
|
export interface ProfileData {
|
|
292
294
|
profileId: Types.Events.ProfileID;
|
|
293
|
-
rawProfile: CPUProfile.CPUProfileDataModel.ExtendedProfile;
|
|
294
295
|
parsedProfile: CPUProfile.CPUProfileDataModel.CPUProfileDataModel;
|
|
295
296
|
/**
|
|
296
297
|
* Contains the calls built from the CPU profile samples.
|