chrome-devtools-frontend 1.0.1547147 → 1.0.1547571
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/.stylelintrc.json +5 -1
- package/docs/contributing/infrastructure.md +2 -2
- package/eslint.config.mjs +3 -2
- package/front_end/Images/generate-css-vars.js +1 -1
- package/front_end/core/common/common.ts +0 -2
- package/front_end/core/i18n/collect-ui-strings.js +1 -1
- package/front_end/core/i18n/generate-locales-js.js +1 -1
- package/front_end/core/platform/HostRuntime.ts +14 -7
- package/front_end/core/platform/api/HostRuntime.ts +28 -3
- package/front_end/core/platform/browser/HostRuntime.ts +66 -5
- package/front_end/core/platform/node/HostRuntime.ts +76 -4
- package/front_end/core/sdk/AnimationModel.ts +1 -1
- package/front_end/core/sdk/CSSModel.ts +1 -1
- package/front_end/core/sdk/CSSProperty.ts +1 -1
- package/front_end/core/sdk/CSSPropertyParserMatchers.ts +1 -1
- package/front_end/core/sdk/ConsoleModel.ts +1 -1
- package/front_end/core/sdk/Cookie.ts +1 -1
- package/front_end/core/sdk/DOMModel.ts +2 -2
- package/front_end/core/sdk/DebuggerModel.ts +1 -1
- package/front_end/core/sdk/NetworkManager.ts +6 -0
- package/front_end/core/sdk/PreloadingModel.ts +1 -1
- package/front_end/core/sdk/RemoteObject.ts +1 -1
- package/front_end/core/sdk/ResourceTreeModel.ts +1 -1
- package/front_end/core/sdk/Script.ts +4 -4
- package/front_end/entrypoints/formatter_worker/HTMLFormatter.ts +2 -2
- package/front_end/entrypoints/formatter_worker/JavaScriptFormatter.ts +15 -18
- package/front_end/entrypoints/formatter_worker/formatter_worker-entrypoint.ts +8 -5
- package/front_end/entrypoints/main/ExecutionContextSelector.ts +1 -1
- package/front_end/entrypoints/main/MainImpl.ts +2 -2
- package/front_end/generated/Deprecation.ts +19 -0
- package/front_end/generated/InspectorBackendCommands.ts +4 -3
- package/front_end/generated/SupportedCSSProperties.js +13 -13
- package/front_end/generated/protocol-mapping.d.ts +2 -0
- package/front_end/generated/protocol-proxy-api.d.ts +4 -0
- package/front_end/generated/protocol.ts +16 -27
- package/front_end/models/ai_assistance/AiConversation.ts +104 -24
- package/front_end/models/ai_assistance/BuiltInAi.ts +131 -134
- package/front_end/models/ai_assistance/ChangeManager.ts +9 -0
- package/front_end/models/ai_assistance/ConversationHandler.ts +23 -48
- package/front_end/models/ai_assistance/agents/AiAgent.ts +8 -5
- package/front_end/models/ai_assistance/agents/StylingAgent.ts +0 -10
- package/front_end/models/formatter/FormatterWorkerPool.ts +9 -7
- package/front_end/models/har/Importer.ts +1 -1
- package/front_end/models/issues_manager/ContrastCheckTrigger.ts +1 -1
- package/front_end/models/persistence/AutomaticFileSystemManager.ts +1 -1
- package/front_end/panels/accessibility/AccessibilityNodeView.ts +1 -1
- package/front_end/panels/ai_assistance/AiAssistancePanel.ts +80 -153
- package/front_end/panels/ai_assistance/components/ChatView.ts +54 -31
- package/front_end/panels/application/ExtensionStorageModel.ts +1 -1
- package/front_end/panels/application/FrameDetailsView.ts +62 -34
- package/front_end/panels/application/ServiceWorkerCacheViews.ts +1 -1
- package/front_end/panels/application/components/components.ts +0 -2
- package/front_end/panels/console/ConsoleInsightTeaser.ts +166 -100
- package/front_end/panels/console/ConsolePrompt.ts +1 -1
- package/front_end/panels/console/ConsoleViewMessage.ts +77 -29
- package/front_end/panels/console/ConsoleViewport.ts +1 -1
- package/front_end/panels/console/consoleInsightTeaser.css +1 -0
- package/front_end/panels/coverage/CoverageModel.ts +2 -2
- package/front_end/panels/elements/ElementsPanel.ts +1 -1
- package/front_end/panels/elements/ElementsTreeOutline.ts +17 -7
- package/front_end/panels/elements/NodeStackTraceWidget.ts +6 -5
- package/front_end/panels/elements/StylePropertyTreeElement.ts +1 -2
- package/front_end/panels/explain/components/ConsoleInsight.ts +1 -1
- package/front_end/panels/network/RequestConditionsDrawer.ts +64 -20
- package/front_end/panels/profiler/HeapSnapshotGridNodes.ts +1 -1
- package/front_end/panels/profiler/HeapSnapshotProxy.ts +15 -14
- package/front_end/panels/recorder/components/StepEditor.ts +1 -1
- package/front_end/panels/security/SecurityPanelSidebar.ts +1 -3
- package/front_end/panels/settings/KeybindsSettingsTab.ts +1 -1
- package/front_end/panels/sources/CSSPlugin.ts +1 -1
- package/front_end/panels/sources/DebuggerPlugin.ts +2 -2
- package/front_end/panels/sources/NavigatorView.ts +1 -1
- package/front_end/panels/sources/SourcesSearchScope.ts +1 -1
- package/front_end/panels/sources/WatchExpressionsSidebarPane.ts +10 -2
- package/front_end/panels/timeline/TimelineFlameChartView.ts +1 -1
- package/front_end/panels/timeline/TimelinePanel.ts +7 -7
- package/front_end/panels/timeline/TimelineUIUtils.ts +3 -1
- package/front_end/panels/timeline/enable-easter-egg.js +1 -1
- package/front_end/panels/timeline/utils/Treemap.ts +1 -1
- package/front_end/third_party/chromium/README.chromium +1 -1
- package/front_end/third_party/puppeteer/README.chromium +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/DeviceRequestPrompt.d.ts +66 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/DeviceRequestPrompt.d.ts.map +1 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/DeviceRequestPrompt.js +57 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/DeviceRequestPrompt.js.map +1 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Frame.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Frame.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Frame.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Page.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Page.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Page.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/api.d.ts +1 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/api.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/api.js +1 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/api.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/HTTPRequest.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/HTTPRequest.js +1 -6
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/HTTPRequest.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/Page.d.ts +0 -4
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/Page.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/Page.js +18 -23
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/Page.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/BrowsingContext.d.ts +2 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/BrowsingContext.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/BrowsingContext.js +16 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/BrowsingContext.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/DeviceRequestPrompt.d.ts +4 -62
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/DeviceRequestPrompt.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/DeviceRequestPrompt.js +9 -73
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/DeviceRequestPrompt.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Frame.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Frame.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Frame.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Page.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Page.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Page.js +3 -3
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Page.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/ConsoleMessage.d.ts +8 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/ConsoleMessage.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/ConsoleMessage.js +11 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/ConsoleMessage.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/injected/injected.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.d.ts +3 -3
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js +3 -3
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/Mutex.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.d.ts +9 -10
- package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.js +80 -81
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/DeviceRequestPrompt.d.ts +66 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/DeviceRequestPrompt.d.ts.map +1 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/DeviceRequestPrompt.js +52 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/DeviceRequestPrompt.js.map +1 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Frame.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Frame.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Frame.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Page.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Page.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Page.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/api.d.ts +1 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/api.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/api.js +1 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/api.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/HTTPRequest.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/HTTPRequest.js +1 -6
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/HTTPRequest.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/Page.d.ts +0 -4
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/Page.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/Page.js +18 -23
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/Page.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/BrowsingContext.d.ts +2 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/BrowsingContext.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/BrowsingContext.js +16 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/BrowsingContext.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/DeviceRequestPrompt.d.ts +4 -62
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/DeviceRequestPrompt.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/DeviceRequestPrompt.js +6 -69
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/DeviceRequestPrompt.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Frame.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Frame.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Frame.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Page.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Page.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Page.js +3 -3
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Page.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/ConsoleMessage.d.ts +8 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/ConsoleMessage.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/ConsoleMessage.js +11 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/ConsoleMessage.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.d.ts +3 -3
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js +3 -3
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/types.d.ts +9 -10
- package/front_end/third_party/puppeteer/package/package.json +3 -3
- package/front_end/third_party/puppeteer/package/src/api/DeviceRequestPrompt.ts +79 -0
- package/front_end/third_party/puppeteer/package/src/api/Frame.ts +1 -1
- package/front_end/third_party/puppeteer/package/src/api/Page.ts +2 -2
- package/front_end/third_party/puppeteer/package/src/api/api.ts +1 -0
- package/front_end/third_party/puppeteer/package/src/bidi/HTTPRequest.ts +1 -9
- package/front_end/third_party/puppeteer/package/src/bidi/Page.ts +21 -31
- package/front_end/third_party/puppeteer/package/src/bidi/core/BrowsingContext.ts +18 -0
- package/front_end/third_party/puppeteer/package/src/cdp/DeviceRequestPrompt.ts +6 -72
- package/front_end/third_party/puppeteer/package/src/cdp/Frame.ts +2 -4
- package/front_end/third_party/puppeteer/package/src/cdp/Page.ts +7 -2
- package/front_end/third_party/puppeteer/package/src/common/ConsoleMessage.ts +14 -0
- package/front_end/third_party/puppeteer/package/src/revisions.ts +3 -3
- package/front_end/third_party/puppeteer/package/src/util/version.ts +1 -1
- package/front_end/third_party/puppeteer/puppeteer-tsconfig.json +1 -0
- package/front_end/ui/components/markdown_view/MarkdownLinksMap.ts +4 -0
- package/front_end/ui/components/text_editor/javascript.ts +1 -1
- package/front_end/ui/legacy/ListWidget.ts +51 -18
- package/front_end/ui/legacy/ReportView.ts +1 -1
- package/front_end/ui/legacy/TabbedPane.ts +3 -3
- package/front_end/ui/legacy/Treeoutline.ts +1 -1
- package/front_end/ui/legacy/components/color_picker/ContrastInfo.ts +1 -1
- package/front_end/ui/legacy/components/data_grid/DataGrid.ts +3 -2
- package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +87 -111
- package/front_end/ui/legacy/components/source_frame/SourceFrame.ts +1 -2
- package/front_end/ui/legacy/components/utils/JSPresentationUtils.ts +40 -11
- package/front_end/ui/legacy/components/utils/jsUtils.css +28 -0
- package/front_end/ui/visual_logging/KnownContextValues.ts +1 -0
- package/front_end/ui/visual_logging/LoggingConfig.ts +2 -1
- package/inspector_overlay/tool_window_controls.ts +4 -1
- package/mcp/mcp.ts +1 -1
- package/package.json +2 -3
- package/front_end/core/common/Worker.ts +0 -60
- package/front_end/panels/application/components/StackTrace.ts +0 -238
- package/front_end/panels/application/components/stackTraceLinkButton.css +0 -16
- package/front_end/panels/application/components/stackTraceRow.css +0 -50
|
@@ -32,7 +32,6 @@ import type {HTTPRequest} from '../api/HTTPRequest.js';
|
|
|
32
32
|
import type {HTTPResponse} from '../api/HTTPResponse.js';
|
|
33
33
|
import type {Accessibility} from '../cdp/Accessibility.js';
|
|
34
34
|
import type {Coverage} from '../cdp/Coverage.js';
|
|
35
|
-
import type {DeviceRequestPrompt} from '../cdp/DeviceRequestPrompt.js';
|
|
36
35
|
import type {NetworkConditions} from '../cdp/NetworkManager.js';
|
|
37
36
|
import type {Tracing} from '../cdp/Tracing.js';
|
|
38
37
|
import type {ConsoleMessage} from '../common/ConsoleMessage.js';
|
|
@@ -85,6 +84,7 @@ import {stringToTypedArray} from '../util/encoding.js';
|
|
|
85
84
|
import type {Browser} from './Browser.js';
|
|
86
85
|
import type {BrowserContext} from './BrowserContext.js';
|
|
87
86
|
import type {CDPSession} from './CDPSession.js';
|
|
87
|
+
import type {DeviceRequestPrompt} from './DeviceRequestPrompt.js';
|
|
88
88
|
import type {Dialog} from './Dialog.js';
|
|
89
89
|
import type {
|
|
90
90
|
BoundingBox,
|
|
@@ -306,7 +306,7 @@ export interface ScreenshotOptions {
|
|
|
306
306
|
* relative to current working directory. If no path is provided, the image
|
|
307
307
|
* won't be saved to the disk.
|
|
308
308
|
*/
|
|
309
|
-
path?:
|
|
309
|
+
path?: string;
|
|
310
310
|
/**
|
|
311
311
|
* Specifies the region of the page/element to clip.
|
|
312
312
|
*/
|
|
@@ -166,20 +166,13 @@ export class BidiHTTPRequest extends HTTPRequest {
|
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
get #hasInternalHeaderOverwrite(): boolean {
|
|
169
|
-
return Boolean(
|
|
170
|
-
Object.keys(this.#extraHTTPHeaders).length ||
|
|
171
|
-
Object.keys(this.#userAgentHeaders).length,
|
|
172
|
-
);
|
|
169
|
+
return Boolean(Object.keys(this.#extraHTTPHeaders).length);
|
|
173
170
|
}
|
|
174
171
|
|
|
175
172
|
get #extraHTTPHeaders(): Record<string, string> {
|
|
176
173
|
return this.#frame?.page()._extraHTTPHeaders ?? {};
|
|
177
174
|
}
|
|
178
175
|
|
|
179
|
-
get #userAgentHeaders(): Record<string, string> {
|
|
180
|
-
return this.#frame?.page()._userAgentHeaders ?? {};
|
|
181
|
-
}
|
|
182
|
-
|
|
183
176
|
override headers(): Record<string, string> {
|
|
184
177
|
// Callers should not be allowed to mutate internal structure.
|
|
185
178
|
const headers: Record<string, string> = {};
|
|
@@ -189,7 +182,6 @@ export class BidiHTTPRequest extends HTTPRequest {
|
|
|
189
182
|
return {
|
|
190
183
|
...headers,
|
|
191
184
|
...this.#extraHTTPHeaders,
|
|
192
|
-
...this.#userAgentHeaders,
|
|
193
185
|
};
|
|
194
186
|
}
|
|
195
187
|
|
|
@@ -138,9 +138,7 @@ export class BidiPage extends Page {
|
|
|
138
138
|
/**
|
|
139
139
|
* @internal
|
|
140
140
|
*/
|
|
141
|
-
|
|
142
|
-
#userAgentInterception?: string;
|
|
143
|
-
#userAgentPreloadScript?: string;
|
|
141
|
+
#overrideNavigatorPropertiesPreloadScript?: string;
|
|
144
142
|
override async setUserAgent(
|
|
145
143
|
userAgentOrOptions:
|
|
146
144
|
| string
|
|
@@ -186,26 +184,9 @@ export class BidiPage extends Page {
|
|
|
186
184
|
const enable = userAgent !== '';
|
|
187
185
|
userAgent = userAgent ?? (await this.#browserContext.browser().userAgent());
|
|
188
186
|
|
|
189
|
-
this.
|
|
190
|
-
? {
|
|
191
|
-
'User-Agent': userAgent,
|
|
192
|
-
}
|
|
193
|
-
: {};
|
|
194
|
-
|
|
195
|
-
this.#userAgentInterception = await this.#toggleInterception(
|
|
196
|
-
[Bidi.Network.InterceptPhase.BeforeRequestSent],
|
|
197
|
-
this.#userAgentInterception,
|
|
198
|
-
enable,
|
|
199
|
-
);
|
|
187
|
+
await this.#frame.browsingContext.setUserAgent(enable ? userAgent : null);
|
|
200
188
|
|
|
201
|
-
const overrideNavigatorProperties = (
|
|
202
|
-
userAgent: string,
|
|
203
|
-
platform: string | undefined,
|
|
204
|
-
) => {
|
|
205
|
-
Object.defineProperty(navigator, 'userAgent', {
|
|
206
|
-
value: userAgent,
|
|
207
|
-
configurable: true,
|
|
208
|
-
});
|
|
189
|
+
const overrideNavigatorProperties = (platform: string | undefined) => {
|
|
209
190
|
if (platform) {
|
|
210
191
|
Object.defineProperty(navigator, 'platform', {
|
|
211
192
|
value: platform,
|
|
@@ -219,16 +200,15 @@ export class BidiPage extends Page {
|
|
|
219
200
|
frames.push(...frame.childFrames());
|
|
220
201
|
}
|
|
221
202
|
|
|
222
|
-
if (this.#
|
|
203
|
+
if (this.#overrideNavigatorPropertiesPreloadScript) {
|
|
223
204
|
await this.removeScriptToEvaluateOnNewDocument(
|
|
224
|
-
this.#
|
|
205
|
+
this.#overrideNavigatorPropertiesPreloadScript,
|
|
225
206
|
);
|
|
226
207
|
}
|
|
227
208
|
const [evaluateToken] = await Promise.all([
|
|
228
209
|
enable
|
|
229
210
|
? this.evaluateOnNewDocument(
|
|
230
211
|
overrideNavigatorProperties,
|
|
231
|
-
userAgent,
|
|
232
212
|
platform || undefined,
|
|
233
213
|
)
|
|
234
214
|
: undefined,
|
|
@@ -237,12 +217,11 @@ export class BidiPage extends Page {
|
|
|
237
217
|
...frames.map(frame => {
|
|
238
218
|
return frame.evaluate(
|
|
239
219
|
overrideNavigatorProperties,
|
|
240
|
-
userAgent,
|
|
241
220
|
platform || undefined,
|
|
242
221
|
);
|
|
243
222
|
}),
|
|
244
223
|
]);
|
|
245
|
-
this.#
|
|
224
|
+
this.#overrideNavigatorPropertiesPreloadScript = evaluateToken?.identifier;
|
|
246
225
|
}
|
|
247
226
|
|
|
248
227
|
override async setBypassCSP(enabled: boolean): Promise<void> {
|
|
@@ -746,8 +725,7 @@ export class BidiPage extends Page {
|
|
|
746
725
|
return (
|
|
747
726
|
Boolean(this.#requestInterception) ||
|
|
748
727
|
Boolean(this.#extraHeadersInterception) ||
|
|
749
|
-
Boolean(this.#authInterception)
|
|
750
|
-
Boolean(this.#userAgentInterception)
|
|
728
|
+
Boolean(this.#authInterception)
|
|
751
729
|
);
|
|
752
730
|
}
|
|
753
731
|
|
|
@@ -828,7 +806,7 @@ export class BidiPage extends Page {
|
|
|
828
806
|
|
|
829
807
|
override async setOfflineMode(enabled: boolean): Promise<void> {
|
|
830
808
|
if (!this.#browserContext.browser().cdpSupported) {
|
|
831
|
-
|
|
809
|
+
return await this.#frame.browsingContext.setOfflineMode(enabled);
|
|
832
810
|
}
|
|
833
811
|
|
|
834
812
|
if (!this.#emulatedNetworkConditions) {
|
|
@@ -847,8 +825,20 @@ export class BidiPage extends Page {
|
|
|
847
825
|
networkConditions: NetworkConditions | null,
|
|
848
826
|
): Promise<void> {
|
|
849
827
|
if (!this.#browserContext.browser().cdpSupported) {
|
|
850
|
-
|
|
828
|
+
if (
|
|
829
|
+
!networkConditions?.offline &&
|
|
830
|
+
((networkConditions?.upload ?? -1) >= 0 ||
|
|
831
|
+
(networkConditions?.download ?? -1) >= 0 ||
|
|
832
|
+
(networkConditions?.latency ?? 0) > 0)
|
|
833
|
+
) {
|
|
834
|
+
// WebDriver BiDi supports only offline mode.
|
|
835
|
+
throw new UnsupportedOperation();
|
|
836
|
+
}
|
|
837
|
+
return await this.#frame.browsingContext.setOfflineMode(
|
|
838
|
+
networkConditions?.offline ?? false,
|
|
839
|
+
);
|
|
851
840
|
}
|
|
841
|
+
|
|
852
842
|
if (!this.#emulatedNetworkConditions) {
|
|
853
843
|
this.#emulatedNetworkConditions = {
|
|
854
844
|
offline: networkConditions?.offline ?? false,
|
|
@@ -739,4 +739,22 @@ export class BrowsingContext extends EventEmitter<{
|
|
|
739
739
|
isJavaScriptEnabled(): boolean {
|
|
740
740
|
return this.#emulationState.javaScriptEnabled;
|
|
741
741
|
}
|
|
742
|
+
|
|
743
|
+
async setUserAgent(userAgent: string | null): Promise<void> {
|
|
744
|
+
await this.#session.send('emulation.setUserAgentOverride', {
|
|
745
|
+
userAgent,
|
|
746
|
+
contexts: [this.id],
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
async setOfflineMode(enabled: boolean): Promise<void> {
|
|
751
|
+
await this.#session.send('emulation.setNetworkConditions', {
|
|
752
|
+
networkConditions: enabled
|
|
753
|
+
? {
|
|
754
|
+
type: 'offline',
|
|
755
|
+
}
|
|
756
|
+
: null,
|
|
757
|
+
contexts: [this.id],
|
|
758
|
+
});
|
|
759
|
+
}
|
|
742
760
|
}
|
|
@@ -7,59 +7,17 @@
|
|
|
7
7
|
import type Protocol from 'devtools-protocol';
|
|
8
8
|
|
|
9
9
|
import type {CDPSession} from '../api/CDPSession.js';
|
|
10
|
+
import {DeviceRequestPrompt} from '../api/DeviceRequestPrompt.js';
|
|
11
|
+
import {DeviceRequestPromptDevice} from '../api/DeviceRequestPrompt.js';
|
|
10
12
|
import type {WaitTimeoutOptions} from '../api/Page.js';
|
|
11
13
|
import type {TimeoutSettings} from '../common/TimeoutSettings.js';
|
|
12
14
|
import {assert} from '../util/assert.js';
|
|
13
15
|
import {Deferred} from '../util/Deferred.js';
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* @public
|
|
19
|
-
*/
|
|
20
|
-
export class DeviceRequestPromptDevice {
|
|
21
|
-
/**
|
|
22
|
-
* Device id during a prompt.
|
|
23
|
-
*/
|
|
24
|
-
id: string;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Device name as it appears in a prompt.
|
|
28
|
-
*/
|
|
29
|
-
name: string;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @internal
|
|
33
|
-
*/
|
|
34
|
-
constructor(id: string, name: string) {
|
|
35
|
-
this.id = id;
|
|
36
|
-
this.name = name;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Device request prompts let you respond to the page requesting for a device
|
|
42
|
-
* through an API like WebBluetooth.
|
|
43
|
-
*
|
|
44
|
-
* @remarks
|
|
45
|
-
* `DeviceRequestPrompt` instances are returned via the
|
|
46
|
-
* {@link Page.waitForDevicePrompt} method.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
*
|
|
50
|
-
* ```ts
|
|
51
|
-
* const [devicePrompt] = Promise.all([
|
|
52
|
-
* page.waitForDevicePrompt(),
|
|
53
|
-
* page.click('#connect-bluetooth'),
|
|
54
|
-
* ]);
|
|
55
|
-
* await devicePrompt.select(
|
|
56
|
-
* await devicePrompt.waitForDevice(({name}) => name.includes('My Device')),
|
|
57
|
-
* );
|
|
58
|
-
* ```
|
|
59
|
-
*
|
|
60
|
-
* @public
|
|
18
|
+
* @internal
|
|
61
19
|
*/
|
|
62
|
-
export class DeviceRequestPrompt {
|
|
20
|
+
export class CdpDeviceRequestPrompt extends DeviceRequestPrompt {
|
|
63
21
|
#client: CDPSession | null;
|
|
64
22
|
#timeoutSettings: TimeoutSettings;
|
|
65
23
|
#id: string;
|
|
@@ -70,19 +28,14 @@ export class DeviceRequestPrompt {
|
|
|
70
28
|
promise: Deferred<DeviceRequestPromptDevice>;
|
|
71
29
|
}>();
|
|
72
30
|
|
|
73
|
-
/**
|
|
74
|
-
* Current list of selectable devices.
|
|
75
|
-
*/
|
|
76
31
|
devices: DeviceRequestPromptDevice[] = [];
|
|
77
32
|
|
|
78
|
-
/**
|
|
79
|
-
* @internal
|
|
80
|
-
*/
|
|
81
33
|
constructor(
|
|
82
34
|
client: CDPSession,
|
|
83
35
|
timeoutSettings: TimeoutSettings,
|
|
84
36
|
firstEvent: Protocol.DeviceAccess.DeviceRequestPromptedEvent,
|
|
85
37
|
) {
|
|
38
|
+
super();
|
|
86
39
|
this.#client = client;
|
|
87
40
|
this.#timeoutSettings = timeoutSettings;
|
|
88
41
|
this.#id = firstEvent.id;
|
|
@@ -126,9 +79,6 @@ export class DeviceRequestPrompt {
|
|
|
126
79
|
}
|
|
127
80
|
}
|
|
128
81
|
|
|
129
|
-
/**
|
|
130
|
-
* Resolve to the first device in the prompt matching a filter.
|
|
131
|
-
*/
|
|
132
82
|
async waitForDevice(
|
|
133
83
|
filter: (device: DeviceRequestPromptDevice) => boolean,
|
|
134
84
|
options: WaitTimeoutOptions = {},
|
|
@@ -164,9 +114,6 @@ export class DeviceRequestPrompt {
|
|
|
164
114
|
}
|
|
165
115
|
}
|
|
166
116
|
|
|
167
|
-
/**
|
|
168
|
-
* Select a device in the prompt's list.
|
|
169
|
-
*/
|
|
170
117
|
async select(device: DeviceRequestPromptDevice): Promise<void> {
|
|
171
118
|
assert(
|
|
172
119
|
this.#client !== null,
|
|
@@ -188,9 +135,6 @@ export class DeviceRequestPrompt {
|
|
|
188
135
|
});
|
|
189
136
|
}
|
|
190
137
|
|
|
191
|
-
/**
|
|
192
|
-
* Cancel the prompt.
|
|
193
|
-
*/
|
|
194
138
|
async cancel(): Promise<void> {
|
|
195
139
|
assert(
|
|
196
140
|
this.#client !== null,
|
|
@@ -217,9 +161,6 @@ export class DeviceRequestPromptManager {
|
|
|
217
161
|
#timeoutSettings: TimeoutSettings;
|
|
218
162
|
#deviceRequestPromptDeferreds = new Set<Deferred<DeviceRequestPrompt>>();
|
|
219
163
|
|
|
220
|
-
/**
|
|
221
|
-
* @internal
|
|
222
|
-
*/
|
|
223
164
|
constructor(client: CDPSession, timeoutSettings: TimeoutSettings) {
|
|
224
165
|
this.#client = client;
|
|
225
166
|
this.#timeoutSettings = timeoutSettings;
|
|
@@ -232,10 +173,6 @@ export class DeviceRequestPromptManager {
|
|
|
232
173
|
});
|
|
233
174
|
}
|
|
234
175
|
|
|
235
|
-
/**
|
|
236
|
-
* Wait for device prompt created by an action like calling WebBluetooth's
|
|
237
|
-
* requestDevice.
|
|
238
|
-
*/
|
|
239
176
|
async waitForDevicePrompt(
|
|
240
177
|
options: WaitTimeoutOptions = {},
|
|
241
178
|
): Promise<DeviceRequestPrompt> {
|
|
@@ -277,9 +214,6 @@ export class DeviceRequestPromptManager {
|
|
|
277
214
|
}
|
|
278
215
|
}
|
|
279
216
|
|
|
280
|
-
/**
|
|
281
|
-
* @internal
|
|
282
|
-
*/
|
|
283
217
|
#onDeviceRequestPrompted(
|
|
284
218
|
event: Protocol.DeviceAccess.DeviceRequestPromptedEvent,
|
|
285
219
|
) {
|
|
@@ -288,7 +222,7 @@ export class DeviceRequestPromptManager {
|
|
|
288
222
|
}
|
|
289
223
|
|
|
290
224
|
assert(this.#client !== null);
|
|
291
|
-
const devicePrompt = new
|
|
225
|
+
const devicePrompt = new CdpDeviceRequestPrompt(
|
|
292
226
|
this.#client,
|
|
293
227
|
this.#timeoutSettings,
|
|
294
228
|
event,
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import type {Protocol} from 'devtools-protocol';
|
|
8
8
|
|
|
9
9
|
import type {CDPSession} from '../api/CDPSession.js';
|
|
10
|
+
import type {DeviceRequestPrompt} from '../api/DeviceRequestPrompt.js';
|
|
10
11
|
import type {ElementHandle} from '../api/ElementHandle.js';
|
|
11
12
|
import type {WaitForOptions} from '../api/Frame.js';
|
|
12
13
|
import {Frame, FrameEvent, throwIfDetached} from '../api/Frame.js';
|
|
@@ -21,10 +22,7 @@ import {isErrorLike} from '../util/ErrorLike.js';
|
|
|
21
22
|
import {Accessibility} from './Accessibility.js';
|
|
22
23
|
import type {Binding} from './Binding.js';
|
|
23
24
|
import type {CdpPreloadScript} from './CdpPreloadScript.js';
|
|
24
|
-
import type {
|
|
25
|
-
DeviceRequestPrompt,
|
|
26
|
-
DeviceRequestPromptManager,
|
|
27
|
-
} from './DeviceRequestPrompt.js';
|
|
25
|
+
import type {DeviceRequestPromptManager} from './DeviceRequestPrompt.js';
|
|
28
26
|
import type {FrameManager} from './FrameManager.js';
|
|
29
27
|
import {FrameManagerEvent} from './FrameManagerEvents.js';
|
|
30
28
|
import type {IsolatedWorldChart} from './IsolatedWorld.js';
|
|
@@ -10,6 +10,7 @@ import {firstValueFrom, from, raceWith} from '../../third_party/rxjs/rxjs.js';
|
|
|
10
10
|
import type {Browser} from '../api/Browser.js';
|
|
11
11
|
import type {BrowserContext} from '../api/BrowserContext.js';
|
|
12
12
|
import {CDPSessionEvent, type CDPSession} from '../api/CDPSession.js';
|
|
13
|
+
import type {DeviceRequestPrompt} from '../api/DeviceRequestPrompt.js';
|
|
13
14
|
import type {ElementHandle} from '../api/ElementHandle.js';
|
|
14
15
|
import type {Frame, WaitForOptions} from '../api/Frame.js';
|
|
15
16
|
import type {HTTPResponse} from '../api/HTTPResponse.js';
|
|
@@ -62,7 +63,6 @@ import type {CdpBrowser} from './Browser.js';
|
|
|
62
63
|
import {CdpCDPSession} from './CdpSession.js';
|
|
63
64
|
import {isTargetClosedError} from './Connection.js';
|
|
64
65
|
import {Coverage} from './Coverage.js';
|
|
65
|
-
import type {DeviceRequestPrompt} from './DeviceRequestPrompt.js';
|
|
66
66
|
import {CdpDialog} from './Dialog.js';
|
|
67
67
|
import {EmulationManager} from './EmulationManager.js';
|
|
68
68
|
import type {CdpFrame} from './Frame.js';
|
|
@@ -488,7 +488,8 @@ export class CdpPage extends Page {
|
|
|
488
488
|
}
|
|
489
489
|
|
|
490
490
|
#onLogEntryAdded(event: Protocol.Log.EntryAddedEvent): void {
|
|
491
|
-
const {level, text, args, source, url, lineNumber} =
|
|
491
|
+
const {level, text, args, source, url, lineNumber, stackTrace} =
|
|
492
|
+
event.entry;
|
|
492
493
|
if (args) {
|
|
493
494
|
args.map(arg => {
|
|
494
495
|
void releaseObject(this.#primaryTargetClient, arg);
|
|
@@ -502,6 +503,8 @@ export class CdpPage extends Page {
|
|
|
502
503
|
text,
|
|
503
504
|
[],
|
|
504
505
|
[{url, lineNumber}],
|
|
506
|
+
undefined,
|
|
507
|
+
stackTrace,
|
|
505
508
|
),
|
|
506
509
|
);
|
|
507
510
|
}
|
|
@@ -891,6 +894,8 @@ export class CdpPage extends Page {
|
|
|
891
894
|
textTokens.join(' '),
|
|
892
895
|
args,
|
|
893
896
|
stackTraceLocations,
|
|
897
|
+
undefined,
|
|
898
|
+
stackTrace,
|
|
894
899
|
);
|
|
895
900
|
this.emit(PageEvent.Console, message);
|
|
896
901
|
}
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import type {Protocol} from 'devtools-protocol';
|
|
8
|
+
|
|
7
9
|
import type {Frame} from '../api/Frame.js';
|
|
8
10
|
import type {JSHandle} from '../api/JSHandle.js';
|
|
9
11
|
|
|
@@ -62,6 +64,7 @@ export class ConsoleMessage {
|
|
|
62
64
|
#args: JSHandle[];
|
|
63
65
|
#stackTraceLocations: ConsoleMessageLocation[];
|
|
64
66
|
#frame?: Frame;
|
|
67
|
+
#rawStackTrace?: Protocol.Runtime.StackTrace;
|
|
65
68
|
|
|
66
69
|
/**
|
|
67
70
|
* @internal
|
|
@@ -72,12 +75,14 @@ export class ConsoleMessage {
|
|
|
72
75
|
args: JSHandle[],
|
|
73
76
|
stackTraceLocations: ConsoleMessageLocation[],
|
|
74
77
|
frame?: Frame,
|
|
78
|
+
rawStackTrace?: Protocol.Runtime.StackTrace,
|
|
75
79
|
) {
|
|
76
80
|
this.#type = type;
|
|
77
81
|
this.#text = text;
|
|
78
82
|
this.#args = args;
|
|
79
83
|
this.#stackTraceLocations = stackTraceLocations;
|
|
80
84
|
this.#frame = frame;
|
|
85
|
+
this.#rawStackTrace = rawStackTrace;
|
|
81
86
|
}
|
|
82
87
|
|
|
83
88
|
/**
|
|
@@ -117,4 +122,13 @@ export class ConsoleMessage {
|
|
|
117
122
|
stackTrace(): ConsoleMessageLocation[] {
|
|
118
123
|
return this.#stackTraceLocations;
|
|
119
124
|
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* The underlying protocol stack trace if available.
|
|
128
|
+
*
|
|
129
|
+
* @internal
|
|
130
|
+
*/
|
|
131
|
+
_rawStackTrace(): Protocol.Runtime.StackTrace | undefined {
|
|
132
|
+
return this.#rawStackTrace;
|
|
133
|
+
}
|
|
120
134
|
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
10
10
|
export const PUPPETEER_REVISIONS = Object.freeze({
|
|
11
|
-
chrome: '142.0.7444.
|
|
12
|
-
'chrome-headless-shell': '142.0.7444.
|
|
13
|
-
firefox: 'stable_145.0',
|
|
11
|
+
chrome: '142.0.7444.175',
|
|
12
|
+
'chrome-headless-shell': '142.0.7444.175',
|
|
13
|
+
firefox: 'stable_145.0.1',
|
|
14
14
|
});
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
"package/lib/esm/puppeteer/api/Browser.js",
|
|
7
7
|
"package/lib/esm/puppeteer/api/BrowserContext.js",
|
|
8
8
|
"package/lib/esm/puppeteer/api/CDPSession.js",
|
|
9
|
+
"package/lib/esm/puppeteer/api/DeviceRequestPrompt.js",
|
|
9
10
|
"package/lib/esm/puppeteer/api/Dialog.js",
|
|
10
11
|
"package/lib/esm/puppeteer/api/ElementHandle.js",
|
|
11
12
|
"package/lib/esm/puppeteer/api/ElementHandleSymbol.js",
|
|
@@ -70,6 +70,10 @@ export const markdownLinks = new Map<string, string>([
|
|
|
70
70
|
['storagePartitioningExplainer', 'https://developers.google.com/privacy-sandbox/cookies/storage-partitioning'],
|
|
71
71
|
['storageAccessAPI', 'https://developer.mozilla.org/en-US/docs/Web/API/StorageAccessHandle/createObjectURL'],
|
|
72
72
|
['https://goo.gle/ps-status', 'https://goo.gle/ps-status'],
|
|
73
|
+
[
|
|
74
|
+
'https://privacysandbox.com/news/update-on-plans-for-privacy-sandbox-technologies/',
|
|
75
|
+
'https://privacysandbox.com/news/update-on-plans-for-privacy-sandbox-technologies/'
|
|
76
|
+
],
|
|
73
77
|
]);
|
|
74
78
|
|
|
75
79
|
export const getMarkdownLink = (key: string): string => {
|
|
@@ -523,7 +523,7 @@ async function getArgumentsForExpression(
|
|
|
523
523
|
}
|
|
524
524
|
const expression = doc.sliceString(callee.from, callee.to);
|
|
525
525
|
const result = await evaluateExpression(context, expression, 'argumentsHint');
|
|
526
|
-
if (
|
|
526
|
+
if (result?.type !== 'function') {
|
|
527
527
|
return null;
|
|
528
528
|
}
|
|
529
529
|
const objGetter = async(): Promise<SDK.RemoteObject.RemoteObject|null> => {
|
|
@@ -56,12 +56,12 @@ export class ListWidget<T> extends VBox {
|
|
|
56
56
|
private readonly list: HTMLElement;
|
|
57
57
|
private lastSeparator: boolean;
|
|
58
58
|
private focusRestorer: ElementFocusRestorer|null;
|
|
59
|
-
|
|
59
|
+
#items: T[];
|
|
60
60
|
private editable: boolean[];
|
|
61
|
-
private elements:
|
|
61
|
+
private elements: HTMLElement[];
|
|
62
62
|
private editor: Editor<T>|null;
|
|
63
63
|
private editItem: T|null;
|
|
64
|
-
private editElement:
|
|
64
|
+
private editElement: HTMLElement|null;
|
|
65
65
|
private emptyPlaceholder: Element|null;
|
|
66
66
|
private isTable: boolean;
|
|
67
67
|
constructor(delegate: Delegate<T>, delegatesFocus = true, isTable = false) {
|
|
@@ -73,7 +73,7 @@ export class ListWidget<T> extends VBox {
|
|
|
73
73
|
|
|
74
74
|
this.lastSeparator = false;
|
|
75
75
|
this.focusRestorer = null;
|
|
76
|
-
this
|
|
76
|
+
this.#items = [];
|
|
77
77
|
this.editable = [];
|
|
78
78
|
this.elements = [];
|
|
79
79
|
this.editor = null;
|
|
@@ -90,8 +90,12 @@ export class ListWidget<T> extends VBox {
|
|
|
90
90
|
this.updatePlaceholder();
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
get items(): T[] {
|
|
94
|
+
return this.#items;
|
|
95
|
+
}
|
|
96
|
+
|
|
93
97
|
clear(): void {
|
|
94
|
-
this
|
|
98
|
+
this.#items = [];
|
|
95
99
|
this.editable = [];
|
|
96
100
|
this.elements = [];
|
|
97
101
|
this.lastSeparator = false;
|
|
@@ -100,8 +104,34 @@ export class ListWidget<T> extends VBox {
|
|
|
100
104
|
this.stopEditing();
|
|
101
105
|
}
|
|
102
106
|
|
|
103
|
-
|
|
104
|
-
|
|
107
|
+
updateItem(index: number, newItem: T, editable: boolean, focusable = true, controlLabels: {
|
|
108
|
+
edit?: string,
|
|
109
|
+
delete?: string,
|
|
110
|
+
} = {}): void {
|
|
111
|
+
if (index < 0 || index >= this.#items.length) {
|
|
112
|
+
this.appendItem(newItem, editable, focusable, controlLabels);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
this.#items[index] = newItem;
|
|
117
|
+
this.editable[index] = editable;
|
|
118
|
+
const element = this.elements[index];
|
|
119
|
+
const [content, controls] = element.children;
|
|
120
|
+
if (controls) {
|
|
121
|
+
element.removeChild(controls);
|
|
122
|
+
}
|
|
123
|
+
this.delegate.updateItem?.(content, newItem, editable, index);
|
|
124
|
+
element.classList.toggle('editable', editable);
|
|
125
|
+
if (editable) {
|
|
126
|
+
if (focusable) {
|
|
127
|
+
element.tabIndex = 0;
|
|
128
|
+
}
|
|
129
|
+
element.appendChild(this.createControls(newItem, element, controlLabels));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
appendItem(item: T, editable: boolean, focusable = true, controlLabels: {edit?: string, delete?: string} = {}): void {
|
|
134
|
+
if (this.lastSeparator && this.#items.length) {
|
|
105
135
|
const element = document.createElement('div');
|
|
106
136
|
element.classList.add('list-separator');
|
|
107
137
|
if (this.isTable) {
|
|
@@ -111,22 +141,24 @@ export class ListWidget<T> extends VBox {
|
|
|
111
141
|
}
|
|
112
142
|
this.lastSeparator = false;
|
|
113
143
|
|
|
114
|
-
this
|
|
144
|
+
this.#items.push(item);
|
|
115
145
|
this.editable.push(editable);
|
|
116
146
|
|
|
117
147
|
const element = this.list.createChild('div', 'list-item');
|
|
118
148
|
if (this.isTable) {
|
|
119
149
|
element.role = 'rowgroup';
|
|
120
150
|
}
|
|
121
|
-
const content = this.delegate.renderItem(item, editable, this
|
|
151
|
+
const content = this.delegate.renderItem(item, editable, this.#items.length - 1);
|
|
122
152
|
if (!content.hasAttribute('jslog')) {
|
|
123
153
|
element.setAttribute('jslog', `${VisualLogging.item()}`);
|
|
124
154
|
}
|
|
125
155
|
element.appendChild(content);
|
|
126
156
|
if (editable) {
|
|
127
157
|
element.classList.add('editable');
|
|
128
|
-
|
|
129
|
-
|
|
158
|
+
if (focusable) {
|
|
159
|
+
element.tabIndex = 0;
|
|
160
|
+
}
|
|
161
|
+
element.appendChild(this.createControls(item, element, controlLabels));
|
|
130
162
|
}
|
|
131
163
|
this.elements.push(element);
|
|
132
164
|
this.updatePlaceholder();
|
|
@@ -137,7 +169,7 @@ export class ListWidget<T> extends VBox {
|
|
|
137
169
|
}
|
|
138
170
|
|
|
139
171
|
removeItem(index: number): void {
|
|
140
|
-
if (this.editItem === this
|
|
172
|
+
if (this.editItem === this.#items[index]) {
|
|
141
173
|
this.stopEditing();
|
|
142
174
|
}
|
|
143
175
|
|
|
@@ -158,7 +190,7 @@ export class ListWidget<T> extends VBox {
|
|
|
158
190
|
element.remove();
|
|
159
191
|
|
|
160
192
|
this.elements.splice(index, 1);
|
|
161
|
-
this
|
|
193
|
+
this.#items.splice(index, 1);
|
|
162
194
|
this.editable.splice(index, 1);
|
|
163
195
|
this.updatePlaceholder();
|
|
164
196
|
}
|
|
@@ -172,7 +204,7 @@ export class ListWidget<T> extends VBox {
|
|
|
172
204
|
this.updatePlaceholder();
|
|
173
205
|
}
|
|
174
206
|
|
|
175
|
-
private createControls(item: T, element:
|
|
207
|
+
private createControls(item: T, element: HTMLElement, controlLabels: {edit?: string, delete?: string}): Element {
|
|
176
208
|
const controls = document.createElement('div');
|
|
177
209
|
controls.classList.add('controls-container');
|
|
178
210
|
controls.classList.add('fill');
|
|
@@ -185,13 +217,13 @@ export class ListWidget<T> extends VBox {
|
|
|
185
217
|
<devtools-button class=toolbar-button
|
|
186
218
|
.iconName=${'edit'}
|
|
187
219
|
.jslogContext=${'edit-item'}
|
|
188
|
-
.title=${i18nString(UIStrings.editString)}
|
|
220
|
+
.title=${controlLabels?.edit ?? i18nString(UIStrings.editString)}
|
|
189
221
|
.variant=${Buttons.Button.Variant.ICON}
|
|
190
222
|
@click=${onEditClicked}></devtools-button>
|
|
191
223
|
<devtools-button class=toolbar-button
|
|
192
224
|
.iconName=${'bin'}
|
|
193
225
|
.jslogContext=${'remove-item'}
|
|
194
|
-
.title=${i18nString(UIStrings.removeString)}
|
|
226
|
+
.title=${controlLabels?.delete ?? i18nString(UIStrings.removeString)}
|
|
195
227
|
.variant=${Buttons.Button.Variant.ICON}
|
|
196
228
|
@click=${onRemoveClicked}></devtools-button>
|
|
197
229
|
</devtools-toolbar>
|
|
@@ -209,7 +241,7 @@ export class ListWidget<T> extends VBox {
|
|
|
209
241
|
function onRemoveClicked(this: ListWidget<T>): void {
|
|
210
242
|
const index = this.elements.indexOf(element);
|
|
211
243
|
this.element.focus();
|
|
212
|
-
this.delegate.removeItemRequested(this
|
|
244
|
+
this.delegate.removeItemRequested(this.#items[index], index);
|
|
213
245
|
ARIAUtils.LiveAnnouncer.alert(i18nString(UIStrings.removedItem));
|
|
214
246
|
if (this.elements.length >= 1) {
|
|
215
247
|
// focus on the next item in the list, or the last item if we're removing the last item
|
|
@@ -235,7 +267,7 @@ export class ListWidget<T> extends VBox {
|
|
|
235
267
|
}
|
|
236
268
|
}
|
|
237
269
|
|
|
238
|
-
private startEditing(item: T, element:
|
|
270
|
+
private startEditing(item: T, element: HTMLElement|null, insertionPoint: Element|null): void {
|
|
239
271
|
if (element && this.editElement === element) {
|
|
240
272
|
return;
|
|
241
273
|
}
|
|
@@ -297,6 +329,7 @@ export class ListWidget<T> extends VBox {
|
|
|
297
329
|
}
|
|
298
330
|
|
|
299
331
|
export interface Delegate<T> {
|
|
332
|
+
updateItem?(content: Element, newItem: T, editable: boolean, index: number): void;
|
|
300
333
|
renderItem(item: T, editable: boolean, index: number): Element;
|
|
301
334
|
removeItemRequested(item: T, index: number): void;
|
|
302
335
|
beginEdit(item: T): Editor<T>;
|