chrome-devtools-frontend 1.0.1536371 → 1.0.1537268
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/front_end/core/host/AidaClient.ts +64 -5
- package/front_end/core/host/DispatchHttpRequestClient.ts +62 -0
- package/front_end/core/host/GdpClient.ts +8 -57
- package/front_end/core/host/host.ts +2 -0
- package/front_end/core/protocol_client/CDPConnection.ts +10 -8
- package/front_end/core/protocol_client/InspectorBackend.ts +36 -42
- package/front_end/core/sdk/EnhancedTracesParser.ts +20 -5
- package/front_end/core/sdk/RehydratingConnection.ts +112 -4
- package/front_end/core/sdk/RehydratingObject.ts +8 -0
- package/front_end/core/sdk/TraceObject.ts +5 -1
- package/front_end/models/javascript_metadata/NativeFunctions.js +1 -1
- package/front_end/models/trace/types/File.ts +9 -0
- package/front_end/panels/ai_assistance/AiAssistancePanel.ts +5 -9
- package/front_end/panels/ai_assistance/components/ChatView.ts +58 -70
- package/front_end/panels/application/BackForwardCacheTreeElement.ts +2 -6
- package/front_end/panels/application/components/BackForwardCacheView.ts +74 -69
- package/front_end/panels/application/components/FrameDetailsView.ts +8 -11
- package/front_end/panels/application/components/OriginTrialTreeView.ts +65 -69
- package/front_end/panels/application/components/backForwardCacheView.css +4 -0
- package/front_end/panels/application/components/badge.css +1 -1
- package/front_end/panels/browser_debugger/CategorizedBreakpointsSidebarPane.ts +44 -53
- package/front_end/panels/recorder/RecorderController.ts +1 -2
- package/front_end/panels/recorder/components/CreateRecordingView.ts +153 -129
- package/front_end/panels/settings/AISettingsTab.ts +162 -171
- package/front_end/panels/settings/SettingsScreen.ts +3 -7
- package/front_end/panels/settings/aiSettingsTab.css +151 -148
- package/front_end/panels/settings/settings-meta.ts +1 -2
- package/front_end/panels/sources/AddSourceMapURLDialog.ts +23 -26
- package/front_end/panels/timeline/TimelinePanel.ts +60 -11
- package/front_end/panels/timeline/components/ExportTraceOptions.ts +33 -34
- package/front_end/third_party/chromium/README.chromium +2 -2
- package/front_end/third_party/puppeteer/README.chromium +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Browser.d.ts +9 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Browser.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Browser.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/BrowserContext.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/BrowserContext.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/BrowserContext.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Page.d.ts +13 -1
- 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/bidi/BrowserContext.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/BrowserContext.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/BrowserContext.js +5 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/BrowserContext.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/Page.d.ts +2 -2
- 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 +3 -1
- 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/Realm.d.ts +1 -12
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/Realm.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Accessibility.d.ts +6 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Accessibility.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Accessibility.js +1 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Accessibility.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Browser.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Browser.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Browser.js +6 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Browser.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/BrowserContext.d.ts +2 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/BrowserContext.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/BrowserContext.js +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/BrowserContext.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Page.d.ts +2 -2
- 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 -1
- 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/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/disposable.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/disposable.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/disposable.js +3 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/disposable.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/util.d.ts +1 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/util.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/util.js +1 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/util.js.map +1 -1
- 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 +28 -3
- package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.js +21 -10
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Browser.d.ts +9 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Browser.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Browser.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/BrowserContext.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/BrowserContext.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/BrowserContext.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Input.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Input.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Page.d.ts +13 -1
- 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/bidi/BrowserContext.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/BrowserContext.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/BrowserContext.js +5 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/BrowserContext.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/Page.d.ts +2 -2
- 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 +3 -1
- 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/Realm.d.ts +1 -12
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/Realm.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Accessibility.d.ts +6 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Accessibility.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Accessibility.js +1 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Accessibility.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Browser.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Browser.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Browser.js +6 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Browser.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/BrowserContext.d.ts +2 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/BrowserContext.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/BrowserContext.js +2 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/BrowserContext.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Page.d.ts +2 -2
- 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 -1
- 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/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/disposable.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/disposable.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/disposable.js +2 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/disposable.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/util.d.ts +1 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/util.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/util.js +1 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/util.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 +28 -3
- package/front_end/third_party/puppeteer/package/package.json +2 -2
- package/front_end/third_party/puppeteer/package/src/api/Browser.ts +13 -1
- package/front_end/third_party/puppeteer/package/src/api/BrowserContext.ts +7 -2
- package/front_end/third_party/puppeteer/package/src/api/Page.ts +14 -1
- package/front_end/third_party/puppeteer/package/src/bidi/BrowserContext.ts +8 -5
- package/front_end/third_party/puppeteer/package/src/bidi/Page.ts +5 -2
- package/front_end/third_party/puppeteer/package/src/cdp/Accessibility.ts +8 -0
- package/front_end/third_party/puppeteer/package/src/cdp/Browser.ts +11 -2
- package/front_end/third_party/puppeteer/package/src/cdp/BrowserContext.ts +3 -2
- package/front_end/third_party/puppeteer/package/src/cdp/Page.ts +5 -5
- package/front_end/third_party/puppeteer/package/src/revisions.ts +3 -3
- package/front_end/third_party/puppeteer/package/src/util/disposable.ts +2 -2
- package/front_end/third_party/puppeteer/package/src/util/util.ts +1 -0
- package/front_end/third_party/puppeteer/package/src/util/version.ts +1 -1
- package/front_end/ui/components/text_editor/AiCodeCompletionProvider.ts +280 -0
- package/front_end/ui/components/text_editor/text_editor.ts +1 -0
- package/front_end/ui/components/tooltips/Tooltip.ts +1 -1
- package/front_end/ui/legacy/Dialog.ts +0 -1
- package/front_end/ui/legacy/SettingsUI.ts +0 -14
- package/front_end/ui/legacy/XLink.ts +0 -3
- package/front_end/ui/legacy/components/data_grid/DataGridElement.ts +9 -0
- package/front_end/ui/legacy/components/utils/Linkifier.ts +9 -3
- package/front_end/ui/visual_logging/KnownContextValues.ts +1 -1
- package/mcp/mcp.ts +5 -0
- package/package.json +1 -1
- package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatterBounds.snapshot.txt +0 -4
- package/front_end/ui/components/docs/breadcrumbs_perf/initial-breadcrumb-perf.html +0 -20
- package/front_end/ui/components/docs/breadcrumbs_perf/initial-breadcrumb-perf.ts +0 -25
- package/front_end/ui/components/docs/breadcrumbs_perf/nested-breadcrumbs-perf.html +0 -20
- package/front_end/ui/components/docs/breadcrumbs_perf/nested-breadcrumbs-perf.ts +0 -36
|
@@ -254,7 +254,7 @@ export declare abstract class Browser extends EventEmitter<BrowserEvents> {
|
|
|
254
254
|
* Creates a new {@link Page | page} in the
|
|
255
255
|
* {@link Browser.defaultBrowserContext | default browser context}.
|
|
256
256
|
*/
|
|
257
|
-
abstract newPage(): Promise<Page>;
|
|
257
|
+
abstract newPage(options?: CreatePageOptions): Promise<Page>;
|
|
258
258
|
/**
|
|
259
259
|
* Gets all active {@link Target | targets}.
|
|
260
260
|
*
|
|
@@ -513,7 +513,7 @@ export declare abstract class BrowserContext extends EventEmitter<BrowserContext
|
|
|
513
513
|
* Creates a new {@link Page | page} in this
|
|
514
514
|
* {@link BrowserContext | browser context}.
|
|
515
515
|
*/
|
|
516
|
-
abstract newPage(): Promise<Page>;
|
|
516
|
+
abstract newPage(options?: CreatePageOptions): Promise<Page>;
|
|
517
517
|
/**
|
|
518
518
|
* Gets the {@link Browser | browser} associated with this
|
|
519
519
|
* {@link BrowserContext | browser context}.
|
|
@@ -1497,6 +1497,15 @@ export declare interface CoverageEntry {
|
|
|
1497
1497
|
}>;
|
|
1498
1498
|
}
|
|
1499
1499
|
|
|
1500
|
+
/**
|
|
1501
|
+
* @public
|
|
1502
|
+
*/
|
|
1503
|
+
export declare type CreatePageOptions = {
|
|
1504
|
+
type: 'tab';
|
|
1505
|
+
} | {
|
|
1506
|
+
type: 'window';
|
|
1507
|
+
};
|
|
1508
|
+
|
|
1500
1509
|
/**
|
|
1501
1510
|
* @public
|
|
1502
1511
|
*/
|
|
@@ -5449,7 +5458,7 @@ export declare abstract class Page extends EventEmitter<PageEvents> {
|
|
|
5449
5458
|
* multiple redirects, the navigation will resolve with the response of the
|
|
5450
5459
|
* last redirect.
|
|
5451
5460
|
*/
|
|
5452
|
-
abstract reload(options?:
|
|
5461
|
+
abstract reload(options?: ReloadOptions): Promise<HTTPResponse | null>;
|
|
5453
5462
|
/**
|
|
5454
5463
|
* Waits for the page to navigate to a new URL or to reload. It is useful when
|
|
5455
5464
|
* you run code that will indirectly cause the page to navigate.
|
|
@@ -6895,6 +6904,7 @@ declare namespace Puppeteer_2 {
|
|
|
6895
6904
|
BrowserEvent,
|
|
6896
6905
|
BrowserEvents,
|
|
6897
6906
|
DebugInfo,
|
|
6907
|
+
CreatePageOptions,
|
|
6898
6908
|
Browser,
|
|
6899
6909
|
BrowserContextEvent,
|
|
6900
6910
|
BrowserContextEvents,
|
|
@@ -6961,6 +6971,7 @@ declare namespace Puppeteer_2 {
|
|
|
6961
6971
|
PageEvent,
|
|
6962
6972
|
PageEvents,
|
|
6963
6973
|
NewDocumentScriptEvaluation,
|
|
6974
|
+
ReloadOptions,
|
|
6964
6975
|
Page,
|
|
6965
6976
|
TargetType,
|
|
6966
6977
|
Target,
|
|
@@ -7259,6 +7270,19 @@ export declare interface QueryOptions {
|
|
|
7259
7270
|
isolate: boolean;
|
|
7260
7271
|
}
|
|
7261
7272
|
|
|
7273
|
+
/**
|
|
7274
|
+
* @public
|
|
7275
|
+
*/
|
|
7276
|
+
export declare interface ReloadOptions extends WaitForOptions {
|
|
7277
|
+
/**
|
|
7278
|
+
* If set to true, the browser caches are ignored for the page reload.
|
|
7279
|
+
*
|
|
7280
|
+
* @defaultValue true
|
|
7281
|
+
* @public
|
|
7282
|
+
*/
|
|
7283
|
+
ignoreCache?: boolean;
|
|
7284
|
+
}
|
|
7285
|
+
|
|
7262
7286
|
/**
|
|
7263
7287
|
* @public
|
|
7264
7288
|
*/
|
|
@@ -7581,6 +7605,7 @@ export declare interface SerializedAXNode {
|
|
|
7581
7605
|
* Children of this node, if there are any.
|
|
7582
7606
|
*/
|
|
7583
7607
|
children?: SerializedAXNode[];
|
|
7608
|
+
|
|
7584
7609
|
/**
|
|
7585
7610
|
* Get an ElementHandle for this AXNode if available.
|
|
7586
7611
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "puppeteer-core",
|
|
3
|
-
"version": "24.
|
|
3
|
+
"version": "24.27.0",
|
|
4
4
|
"description": "A high-level API to control headless Chrome over the DevTools Protocol",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"puppeteer",
|
|
@@ -152,7 +152,7 @@
|
|
|
152
152
|
"@puppeteer/browsers": "2.10.12",
|
|
153
153
|
"chromium-bidi": "10.5.1",
|
|
154
154
|
"debug": "^4.4.3",
|
|
155
|
-
"devtools-protocol": "0.0.
|
|
155
|
+
"devtools-protocol": "0.0.1521046",
|
|
156
156
|
"typed-query-selector": "^2.12.0",
|
|
157
157
|
"webdriver-bidi-protocol": "0.3.8",
|
|
158
158
|
"ws": "^8.18.3"
|
|
@@ -210,6 +210,18 @@ export interface DebugInfo {
|
|
|
210
210
|
pendingProtocolErrors: Error[];
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
+
/**
|
|
214
|
+
* @public
|
|
215
|
+
*/
|
|
216
|
+
export type CreatePageOptions =
|
|
217
|
+
| {
|
|
218
|
+
type: 'tab';
|
|
219
|
+
}
|
|
220
|
+
| {
|
|
221
|
+
type: 'window';
|
|
222
|
+
// TODO: window-specific params will be added here.
|
|
223
|
+
};
|
|
224
|
+
|
|
213
225
|
/**
|
|
214
226
|
* {@link Browser} represents a browser instance that is either:
|
|
215
227
|
*
|
|
@@ -324,7 +336,7 @@ export abstract class Browser extends EventEmitter<BrowserEvents> {
|
|
|
324
336
|
* Creates a new {@link Page | page} in the
|
|
325
337
|
* {@link Browser.defaultBrowserContext | default browser context}.
|
|
326
338
|
*/
|
|
327
|
-
abstract newPage(): Promise<Page>;
|
|
339
|
+
abstract newPage(options?: CreatePageOptions): Promise<Page>;
|
|
328
340
|
|
|
329
341
|
/**
|
|
330
342
|
* Gets all active {@link Target | targets}.
|
|
@@ -25,7 +25,12 @@ import {
|
|
|
25
25
|
import {asyncDisposeSymbol, disposeSymbol} from '../util/disposable.js';
|
|
26
26
|
import {Mutex} from '../util/Mutex.js';
|
|
27
27
|
|
|
28
|
-
import type {
|
|
28
|
+
import type {
|
|
29
|
+
Browser,
|
|
30
|
+
CreatePageOptions,
|
|
31
|
+
Permission,
|
|
32
|
+
WaitForTargetOptions,
|
|
33
|
+
} from './Browser.js';
|
|
29
34
|
import type {Page} from './Page.js';
|
|
30
35
|
import type {Target} from './Target.js';
|
|
31
36
|
|
|
@@ -230,7 +235,7 @@ export abstract class BrowserContext extends EventEmitter<BrowserContextEvents>
|
|
|
230
235
|
* Creates a new {@link Page | page} in this
|
|
231
236
|
* {@link BrowserContext | browser context}.
|
|
232
237
|
*/
|
|
233
|
-
abstract newPage(): Promise<Page>;
|
|
238
|
+
abstract newPage(options?: CreatePageOptions): Promise<Page>;
|
|
234
239
|
|
|
235
240
|
/**
|
|
236
241
|
* Gets the {@link Browser | browser} associated with this
|
|
@@ -633,6 +633,19 @@ export function setDefaultScreenshotOptions(options: ScreenshotOptions): void {
|
|
|
633
633
|
options.captureBeyondViewport ??= true;
|
|
634
634
|
}
|
|
635
635
|
|
|
636
|
+
/**
|
|
637
|
+
* @public
|
|
638
|
+
*/
|
|
639
|
+
export interface ReloadOptions extends WaitForOptions {
|
|
640
|
+
/**
|
|
641
|
+
* If set to true, the browser caches are ignored for the page reload.
|
|
642
|
+
*
|
|
643
|
+
* @defaultValue true
|
|
644
|
+
* @public
|
|
645
|
+
*/
|
|
646
|
+
ignoreCache?: boolean;
|
|
647
|
+
}
|
|
648
|
+
|
|
636
649
|
/**
|
|
637
650
|
* Page provides methods to interact with a single tab or
|
|
638
651
|
* {@link https://developer.chrome.com/extensions/background_pages | extension background page}
|
|
@@ -1743,7 +1756,7 @@ export abstract class Page extends EventEmitter<PageEvents> {
|
|
|
1743
1756
|
* multiple redirects, the navigation will resolve with the response of the
|
|
1744
1757
|
* last redirect.
|
|
1745
1758
|
*/
|
|
1746
|
-
abstract reload(options?:
|
|
1759
|
+
abstract reload(options?: ReloadOptions): Promise<HTTPResponse | null>;
|
|
1747
1760
|
|
|
1748
1761
|
/**
|
|
1749
1762
|
* Waits for the page to navigate to a new URL or to reload. It is useful when
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import * as Bidi from 'webdriver-bidi-protocol';
|
|
8
8
|
|
|
9
|
-
import type {Permission} from '../api/Browser.js';
|
|
9
|
+
import type {CreatePageOptions, Permission} from '../api/Browser.js';
|
|
10
10
|
import {WEB_PERMISSION_TO_PROTOCOL_PERMISSION} from '../api/Browser.js';
|
|
11
11
|
import type {BrowserContextEvents} from '../api/BrowserContext.js';
|
|
12
12
|
import {BrowserContext, BrowserContextEvent} from '../api/BrowserContext.js';
|
|
@@ -181,12 +181,15 @@ export class BidiBrowserContext extends BrowserContext {
|
|
|
181
181
|
});
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
override async newPage(): Promise<Page> {
|
|
184
|
+
override async newPage(options?: CreatePageOptions): Promise<Page> {
|
|
185
185
|
using _guard = await this.waitForScreenshotOperations();
|
|
186
186
|
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
187
|
+
const type =
|
|
188
|
+
options?.type === 'window'
|
|
189
|
+
? Bidi.BrowsingContext.CreateType.Window
|
|
190
|
+
: Bidi.BrowsingContext.CreateType.Tab;
|
|
191
|
+
|
|
192
|
+
const context = await this.userContext.createBrowsingContext(type);
|
|
190
193
|
const page = this.#pages.get(context)!;
|
|
191
194
|
if (!page) {
|
|
192
195
|
throw new Error('Page is not found');
|
|
@@ -17,6 +17,7 @@ import type {
|
|
|
17
17
|
GeolocationOptions,
|
|
18
18
|
MediaFeature,
|
|
19
19
|
PageEvents,
|
|
20
|
+
ReloadOptions,
|
|
20
21
|
WaitTimeoutOptions,
|
|
21
22
|
} from '../api/Page.js';
|
|
22
23
|
import {
|
|
@@ -332,11 +333,13 @@ export class BidiPage extends Page {
|
|
|
332
333
|
}
|
|
333
334
|
|
|
334
335
|
override async reload(
|
|
335
|
-
options:
|
|
336
|
+
options: ReloadOptions = {},
|
|
336
337
|
): Promise<BidiHTTPResponse | null> {
|
|
337
338
|
const [response] = await Promise.all([
|
|
338
339
|
this.#frame.waitForNavigation(options),
|
|
339
|
-
this.#frame.browsingContext.reload(
|
|
340
|
+
this.#frame.browsingContext.reload({
|
|
341
|
+
ignoreCache: options.ignoreCache ? true : undefined,
|
|
342
|
+
}),
|
|
340
343
|
]).catch(
|
|
341
344
|
rewriteNavigationError(
|
|
342
345
|
this.url(),
|
|
@@ -86,6 +86,13 @@ export interface SerializedAXNode {
|
|
|
86
86
|
*/
|
|
87
87
|
children?: SerializedAXNode[];
|
|
88
88
|
|
|
89
|
+
/**
|
|
90
|
+
* CDP-specifc ID to reference the DOM node.
|
|
91
|
+
*
|
|
92
|
+
* @internal
|
|
93
|
+
*/
|
|
94
|
+
backendNodeId?: number;
|
|
95
|
+
|
|
89
96
|
/**
|
|
90
97
|
* Get an ElementHandle for this AXNode if available.
|
|
91
98
|
*
|
|
@@ -539,6 +546,7 @@ class AXNode {
|
|
|
539
546
|
return node.nodeType === Node.TEXT_NODE ? node.parentElement : node;
|
|
540
547
|
})) as ElementHandle<Element>;
|
|
541
548
|
},
|
|
549
|
+
backendNodeId: this.payload.backendDOMNodeId,
|
|
542
550
|
};
|
|
543
551
|
|
|
544
552
|
type UserStringProperty =
|
|
@@ -8,7 +8,7 @@ import type {ChildProcess} from 'node:child_process';
|
|
|
8
8
|
|
|
9
9
|
import type {Protocol} from 'devtools-protocol';
|
|
10
10
|
|
|
11
|
-
import type {DebugInfo} from '../api/Browser.js';
|
|
11
|
+
import type {CreatePageOptions, DebugInfo} from '../api/Browser.js';
|
|
12
12
|
import {
|
|
13
13
|
Browser as BrowserBase,
|
|
14
14
|
BrowserEvent,
|
|
@@ -347,10 +347,19 @@ export class CdpBrowser extends BrowserBase {
|
|
|
347
347
|
return await this.#defaultContext.newPage();
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
-
async _createPageInContext(
|
|
350
|
+
async _createPageInContext(
|
|
351
|
+
contextId?: string,
|
|
352
|
+
options?: CreatePageOptions,
|
|
353
|
+
): Promise<Page> {
|
|
354
|
+
const hasTargets =
|
|
355
|
+
this.targets().filter(t => {
|
|
356
|
+
return t.browserContext().id === contextId;
|
|
357
|
+
}).length > 0;
|
|
351
358
|
const {targetId} = await this.#connection.send('Target.createTarget', {
|
|
352
359
|
url: 'about:blank',
|
|
353
360
|
browserContextId: contextId || undefined,
|
|
361
|
+
// Works around crbug.com/454825274.
|
|
362
|
+
newWindow: hasTargets && options?.type === 'window' ? true : undefined,
|
|
354
363
|
});
|
|
355
364
|
const target = (await this.waitForTarget(t => {
|
|
356
365
|
return (t as CdpTarget)._targetId === targetId;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import type {CreatePageOptions} from '../api/Browser.js';
|
|
7
8
|
import {
|
|
8
9
|
WEB_PERMISSION_TO_PROTOCOL_PERMISSION,
|
|
9
10
|
type Permission,
|
|
@@ -88,9 +89,9 @@ export class CdpBrowserContext extends BrowserContext {
|
|
|
88
89
|
});
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
override async newPage(): Promise<Page> {
|
|
92
|
+
override async newPage(options?: CreatePageOptions): Promise<Page> {
|
|
92
93
|
using _guard = await this.waitForScreenshotOperations();
|
|
93
|
-
return await this.#browser._createPageInContext(this.#id);
|
|
94
|
+
return await this.#browser._createPageInContext(this.#id, options);
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
override browser(): CdpBrowser {
|
|
@@ -14,7 +14,7 @@ import type {ElementHandle} from '../api/ElementHandle.js';
|
|
|
14
14
|
import type {Frame, WaitForOptions} from '../api/Frame.js';
|
|
15
15
|
import type {HTTPResponse} from '../api/HTTPResponse.js';
|
|
16
16
|
import type {JSHandle} from '../api/JSHandle.js';
|
|
17
|
-
import type {Credentials} from '../api/Page.js';
|
|
17
|
+
import type {Credentials, ReloadOptions} from '../api/Page.js';
|
|
18
18
|
import {
|
|
19
19
|
Page,
|
|
20
20
|
PageEvent,
|
|
@@ -898,15 +898,15 @@ export class CdpPage extends Page {
|
|
|
898
898
|
this.emit(PageEvent.Dialog, dialog);
|
|
899
899
|
}
|
|
900
900
|
|
|
901
|
-
override async reload(
|
|
902
|
-
options?: WaitForOptions,
|
|
903
|
-
): Promise<HTTPResponse | null> {
|
|
901
|
+
override async reload(options?: ReloadOptions): Promise<HTTPResponse | null> {
|
|
904
902
|
const [result] = await Promise.all([
|
|
905
903
|
this.waitForNavigation({
|
|
906
904
|
...options,
|
|
907
905
|
ignoreSameDocumentNavigation: true,
|
|
908
906
|
}),
|
|
909
|
-
this.#primaryTargetClient.send('Page.reload'
|
|
907
|
+
this.#primaryTargetClient.send('Page.reload', {
|
|
908
|
+
ignoreCache: options?.ignoreCache ?? false,
|
|
909
|
+
}),
|
|
910
910
|
]);
|
|
911
911
|
|
|
912
912
|
return result;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
10
10
|
export const PUPPETEER_REVISIONS = Object.freeze({
|
|
11
|
-
chrome: '
|
|
12
|
-
'chrome-headless-shell': '
|
|
13
|
-
firefox: 'stable_144.0',
|
|
11
|
+
chrome: '142.0.7444.59',
|
|
12
|
+
'chrome-headless-shell': '142.0.7444.59',
|
|
13
|
+
firefox: 'stable_144.0.2',
|
|
14
14
|
});
|
|
@@ -45,7 +45,7 @@ export const asyncDisposeSymbol: typeof Symbol.asyncDispose =
|
|
|
45
45
|
/**
|
|
46
46
|
* @internal
|
|
47
47
|
*/
|
|
48
|
-
class DisposableStackPolyfill {
|
|
48
|
+
export class DisposableStackPolyfill {
|
|
49
49
|
#disposed = false;
|
|
50
50
|
#stack: Disposable[] = [];
|
|
51
51
|
|
|
@@ -194,7 +194,7 @@ export const DisposableStack: typeof DisposableStackPolyfill =
|
|
|
194
194
|
/**
|
|
195
195
|
* @internal
|
|
196
196
|
*/
|
|
197
|
-
class AsyncDisposableStackPolyfill {
|
|
197
|
+
export class AsyncDisposableStackPolyfill {
|
|
198
198
|
#disposed = false;
|
|
199
199
|
#stack: AsyncDisposable[] = [];
|
|
200
200
|
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
// Copyright 2025 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 Common from '../../../core/common/common.js';
|
|
6
|
+
import * as Host from '../../../core/host/host.js';
|
|
7
|
+
import * as i18n from '../../../core/i18n/i18n.js';
|
|
8
|
+
import * as Root from '../../../core/root/root.js';
|
|
9
|
+
import * as PanelCommon from '../../../panels/common/common.js';
|
|
10
|
+
import * as CodeMirror from '../../../third_party/codemirror.next/codemirror.next.js';
|
|
11
|
+
import * as UI from '../../legacy/legacy.js';
|
|
12
|
+
import * as VisualLogging from '../../visual_logging/visual_logging.js';
|
|
13
|
+
|
|
14
|
+
import {AiCodeCompletionTeaserPlaceholder} from './AiCodeCompletionTeaserPlaceholder.js';
|
|
15
|
+
import {
|
|
16
|
+
aiAutoCompleteSuggestion,
|
|
17
|
+
aiAutoCompleteSuggestionState,
|
|
18
|
+
setAiAutoCompleteSuggestion,
|
|
19
|
+
} from './config.js';
|
|
20
|
+
import type {TextEditor} from './TextEditor.js';
|
|
21
|
+
|
|
22
|
+
export enum AiCodeCompletionTeaserMode {
|
|
23
|
+
OFF = 'off',
|
|
24
|
+
ON = 'on',
|
|
25
|
+
ONLY_SHOW_ON_EMPTY = 'onlyShowOnEmpty',
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const setAiCodeCompletionTeaserMode = CodeMirror.StateEffect.define<AiCodeCompletionTeaserMode>();
|
|
29
|
+
|
|
30
|
+
export const aiCodeCompletionTeaserModeState = CodeMirror.StateField.define<AiCodeCompletionTeaserMode>({
|
|
31
|
+
create: () => AiCodeCompletionTeaserMode.OFF,
|
|
32
|
+
update(value, tr) {
|
|
33
|
+
return tr.effects.find(effect => effect.is(setAiCodeCompletionTeaserMode))?.value ?? value;
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export interface AiCodeCompletionConfig {
|
|
38
|
+
completionContext: {
|
|
39
|
+
additionalFiles?: Host.AidaClient.AdditionalFile[],
|
|
40
|
+
inferenceLanguage?: Host.AidaClient.AidaInferenceLanguage,
|
|
41
|
+
getPrefix?: () => string,
|
|
42
|
+
stopSequences?: string[],
|
|
43
|
+
};
|
|
44
|
+
onFeatureEnabled: () => void;
|
|
45
|
+
onFeatureDisabled: () => void;
|
|
46
|
+
onSuggestionAccepted: () => void;
|
|
47
|
+
onRequestTriggered: () => void;
|
|
48
|
+
onResponseReceived: (citations: Host.AidaClient.Citation[]) => void;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const DELAY_BEFORE_SHOWING_RESPONSE_MS = 500;
|
|
52
|
+
export const AIDA_REQUEST_DEBOUNCE_TIMEOUT_MS = 200;
|
|
53
|
+
|
|
54
|
+
// TODO(samiyac): Add code relevant to AiCodeCompletion and for triggering requests
|
|
55
|
+
export class AiCodeCompletionProvider {
|
|
56
|
+
#aidaClient?: Host.AidaClient.AidaClient;
|
|
57
|
+
#aiCodeCompletionSetting = Common.Settings.Settings.instance().createSetting('ai-code-completion-enabled', false);
|
|
58
|
+
#aiCodeCompletionTeaserDismissedSetting =
|
|
59
|
+
Common.Settings.Settings.instance().createSetting('ai-code-completion-teaser-dismissed', false);
|
|
60
|
+
#teaserCompartment = new CodeMirror.Compartment();
|
|
61
|
+
#teaser?: PanelCommon.AiCodeCompletionTeaser;
|
|
62
|
+
#suggestionRenderingTimeout?: number;
|
|
63
|
+
#editor?: TextEditor;
|
|
64
|
+
#aiCodeCompletionConfig?: AiCodeCompletionConfig;
|
|
65
|
+
|
|
66
|
+
#boundOnUpdateAiCodeCompletionState = this.#updateAiCodeCompletionState.bind(this);
|
|
67
|
+
|
|
68
|
+
constructor(aiCodeCompletionConfig: AiCodeCompletionConfig) {
|
|
69
|
+
if (!this.#isAiCodeCompletionEnabled()) {
|
|
70
|
+
throw new Error('AI code completion feature is not enabled.');
|
|
71
|
+
}
|
|
72
|
+
this.#aiCodeCompletionConfig = aiCodeCompletionConfig;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
extension(): CodeMirror.Extension[] {
|
|
76
|
+
return [
|
|
77
|
+
this.#teaserCompartment.of([]),
|
|
78
|
+
aiAutoCompleteSuggestion,
|
|
79
|
+
aiCodeCompletionTeaserModeState,
|
|
80
|
+
aiAutoCompleteSuggestionState,
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
dispose(): void {
|
|
85
|
+
this.#detachTeaser();
|
|
86
|
+
this.#teaser = undefined;
|
|
87
|
+
this.#aiCodeCompletionSetting.removeChangeListener(this.#boundOnUpdateAiCodeCompletionState);
|
|
88
|
+
Host.AidaClient.HostConfigTracker.instance().removeEventListener(
|
|
89
|
+
Host.AidaClient.Events.AIDA_AVAILABILITY_CHANGED, this.#boundOnUpdateAiCodeCompletionState);
|
|
90
|
+
this.#cleanupAiCodeCompletion();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
editorInitialized(editor: TextEditor): void {
|
|
94
|
+
this.#editor = editor;
|
|
95
|
+
if (!this.#aiCodeCompletionSetting.get() && !this.#aiCodeCompletionTeaserDismissedSetting.get()) {
|
|
96
|
+
this.#teaser = new PanelCommon.AiCodeCompletionTeaser({
|
|
97
|
+
onDetach: () => this.#detachTeaser.bind(this),
|
|
98
|
+
});
|
|
99
|
+
this.#editor.editor.dispatch(
|
|
100
|
+
{effects: this.#teaserCompartment.reconfigure([aiCodeCompletionTeaserExtension(this.#teaser)])});
|
|
101
|
+
}
|
|
102
|
+
Host.AidaClient.HostConfigTracker.instance().addEventListener(
|
|
103
|
+
Host.AidaClient.Events.AIDA_AVAILABILITY_CHANGED, this.#boundOnUpdateAiCodeCompletionState);
|
|
104
|
+
this.#aiCodeCompletionSetting.addChangeListener(this.#boundOnUpdateAiCodeCompletionState);
|
|
105
|
+
void this.#updateAiCodeCompletionState();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
#setupAiCodeCompletion(): void {
|
|
109
|
+
if (!this.#editor || !this.#aiCodeCompletionConfig) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (!this.#aidaClient) {
|
|
113
|
+
this.#aidaClient = new Host.AidaClient.AidaClient();
|
|
114
|
+
}
|
|
115
|
+
this.#aiCodeCompletionConfig.onFeatureEnabled();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
#cleanupAiCodeCompletion(): void {
|
|
119
|
+
if (this.#suggestionRenderingTimeout) {
|
|
120
|
+
clearTimeout(this.#suggestionRenderingTimeout);
|
|
121
|
+
this.#suggestionRenderingTimeout = undefined;
|
|
122
|
+
}
|
|
123
|
+
this.#editor?.dispatch({
|
|
124
|
+
effects: setAiAutoCompleteSuggestion.of(null),
|
|
125
|
+
});
|
|
126
|
+
this.#aiCodeCompletionConfig?.onFeatureDisabled();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async #updateAiCodeCompletionState(): Promise<void> {
|
|
130
|
+
const aidaAvailability = await Host.AidaClient.AidaClient.checkAccessPreconditions();
|
|
131
|
+
const isAvailable = aidaAvailability === Host.AidaClient.AidaAccessPreconditions.AVAILABLE;
|
|
132
|
+
const isEnabled = this.#aiCodeCompletionSetting.get();
|
|
133
|
+
if (isAvailable && isEnabled) {
|
|
134
|
+
this.#detachTeaser();
|
|
135
|
+
this.#setupAiCodeCompletion();
|
|
136
|
+
} else if (isAvailable && !isEnabled) {
|
|
137
|
+
if (this.#teaser && !this.#aiCodeCompletionTeaserDismissedSetting.get()) {
|
|
138
|
+
this.#editor?.editor.dispatch(
|
|
139
|
+
{effects: this.#teaserCompartment.reconfigure([aiCodeCompletionTeaserExtension(this.#teaser)])});
|
|
140
|
+
}
|
|
141
|
+
this.#cleanupAiCodeCompletion();
|
|
142
|
+
} else if (!isAvailable) {
|
|
143
|
+
this.#detachTeaser();
|
|
144
|
+
this.#cleanupAiCodeCompletion();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
#detachTeaser(): void {
|
|
149
|
+
if (!this.#teaser) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
this.#editor?.editor.dispatch({effects: this.#teaserCompartment.reconfigure([])});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// TODO(samiyac): Define static method in AiCodeCompletion and use that instead
|
|
156
|
+
#isAiCodeCompletionEnabled(): boolean {
|
|
157
|
+
const devtoolsLocale = i18n.DevToolsLocale.DevToolsLocale.instance();
|
|
158
|
+
const aidaAvailability = Root.Runtime.hostConfig.aidaAvailability;
|
|
159
|
+
if (!devtoolsLocale.locale.startsWith('en-')) {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
if (!aidaAvailability || aidaAvailability.blockedByGeo || aidaAvailability.blockedByAge ||
|
|
163
|
+
aidaAvailability.blockedByEnterprisePolicy) {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
return Boolean(aidaAvailability.enabled && Root.Runtime.hostConfig.devToolsAiCodeCompletion?.enabled);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function aiCodeCompletionTeaserExtension(teaser: PanelCommon.AiCodeCompletionTeaser): CodeMirror.Extension {
|
|
171
|
+
return CodeMirror.ViewPlugin.fromClass(class {
|
|
172
|
+
teaser: PanelCommon.AiCodeCompletionTeaser;
|
|
173
|
+
#teaserDecoration: CodeMirror.DecorationSet = CodeMirror.Decoration.none;
|
|
174
|
+
#teaserMode: AiCodeCompletionTeaserMode;
|
|
175
|
+
#teaserDisplayTimeout?: number;
|
|
176
|
+
|
|
177
|
+
constructor(readonly view: CodeMirror.EditorView) {
|
|
178
|
+
this.teaser = teaser;
|
|
179
|
+
this.#teaserMode = view.state.field(aiCodeCompletionTeaserModeState);
|
|
180
|
+
this.#setupDecoration();
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
destroy(): void {
|
|
184
|
+
window.clearTimeout(this.#teaserDisplayTimeout);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
update(update: CodeMirror.ViewUpdate): void {
|
|
188
|
+
const currentTeaserMode = update.state.field(aiCodeCompletionTeaserModeState);
|
|
189
|
+
if (currentTeaserMode !== this.#teaserMode) {
|
|
190
|
+
this.#teaserMode = currentTeaserMode;
|
|
191
|
+
this.#setupDecoration();
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (this.#teaserMode === AiCodeCompletionTeaserMode.ONLY_SHOW_ON_EMPTY && update.docChanged) {
|
|
195
|
+
this.#updateTeaserDecorationForOnlyShowOnEmptyMode();
|
|
196
|
+
} else if (this.#teaserMode === AiCodeCompletionTeaserMode.ON) {
|
|
197
|
+
if (update.docChanged) {
|
|
198
|
+
this.#teaserDecoration = CodeMirror.Decoration.none;
|
|
199
|
+
window.clearTimeout(this.#teaserDisplayTimeout);
|
|
200
|
+
this.#updateTeaserDecorationForOnMode();
|
|
201
|
+
} else if (update.selectionSet && update.state.doc.length > 0) {
|
|
202
|
+
this.#teaserDecoration = CodeMirror.Decoration.none;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
get decorations(): CodeMirror.DecorationSet {
|
|
208
|
+
return this.#teaserDecoration;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
#setupDecoration(): void {
|
|
212
|
+
switch (this.#teaserMode) {
|
|
213
|
+
case AiCodeCompletionTeaserMode.ON:
|
|
214
|
+
this.#updateTeaserDecorationForOnModeImmediately();
|
|
215
|
+
return;
|
|
216
|
+
case AiCodeCompletionTeaserMode.ONLY_SHOW_ON_EMPTY:
|
|
217
|
+
this.#updateTeaserDecorationForOnlyShowOnEmptyMode();
|
|
218
|
+
return;
|
|
219
|
+
case AiCodeCompletionTeaserMode.OFF:
|
|
220
|
+
this.#teaserDecoration = CodeMirror.Decoration.none;
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
#updateTeaserDecorationForOnlyShowOnEmptyMode(): void {
|
|
226
|
+
if (this.view.state.doc.length === 0) {
|
|
227
|
+
this.#addTeaserWidget(0);
|
|
228
|
+
} else {
|
|
229
|
+
this.#teaserDecoration = CodeMirror.Decoration.none;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
#updateTeaserDecorationForOnMode = Common.Debouncer.debounce(() => {
|
|
234
|
+
this.#teaserDisplayTimeout = window.setTimeout(() => {
|
|
235
|
+
this.#updateTeaserDecorationForOnModeImmediately();
|
|
236
|
+
this.view.dispatch({});
|
|
237
|
+
}, DELAY_BEFORE_SHOWING_RESPONSE_MS);
|
|
238
|
+
}, AIDA_REQUEST_DEBOUNCE_TIMEOUT_MS);
|
|
239
|
+
|
|
240
|
+
#updateTeaserDecorationForOnModeImmediately(): void {
|
|
241
|
+
const cursorPosition = this.view.state.selection.main.head;
|
|
242
|
+
const line = this.view.state.doc.lineAt(cursorPosition);
|
|
243
|
+
if (cursorPosition >= line.to) {
|
|
244
|
+
this.#addTeaserWidget(cursorPosition);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
#addTeaserWidget(pos: number): void {
|
|
249
|
+
this.#teaserDecoration = CodeMirror.Decoration.set([
|
|
250
|
+
CodeMirror.Decoration.widget({widget: new AiCodeCompletionTeaserPlaceholder(this.teaser), side: 1}).range(pos),
|
|
251
|
+
]);
|
|
252
|
+
}
|
|
253
|
+
}, {
|
|
254
|
+
decorations: v => v.decorations,
|
|
255
|
+
eventHandlers: {
|
|
256
|
+
mousedown(event: MouseEvent): boolean {
|
|
257
|
+
// Required for mouse click to propagate to the "Don't show again" span in teaser.
|
|
258
|
+
return (event.target instanceof Node && teaser.contentElement.contains(event.target));
|
|
259
|
+
},
|
|
260
|
+
keydown(event: KeyboardEvent): boolean {
|
|
261
|
+
if (!UI.KeyboardShortcut.KeyboardShortcut.eventHasCtrlEquivalentKey(event) || !teaser.isShowing()) {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
if (event.key === 'i') {
|
|
265
|
+
event.consume(true);
|
|
266
|
+
void VisualLogging.logKeyDown(event.currentTarget, event, 'ai-code-completion-teaser.fre');
|
|
267
|
+
void this.teaser.onAction(event);
|
|
268
|
+
return true;
|
|
269
|
+
}
|
|
270
|
+
if (event.key === 'x') {
|
|
271
|
+
event.consume(true);
|
|
272
|
+
void VisualLogging.logKeyDown(event.currentTarget, event, 'ai-code-completion-teaser.dismiss');
|
|
273
|
+
this.teaser.onDismiss(event);
|
|
274
|
+
return true;
|
|
275
|
+
}
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
});
|
|
280
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Use of this source code is governed by a BSD-style license that can be
|
|
3
3
|
// found in the LICENSE file.
|
|
4
4
|
|
|
5
|
+
export * as AiCodeCompletionProvider from './AiCodeCompletionProvider.js';
|
|
5
6
|
export * as AiCodeCompletionTeaserPlaceholder from './AiCodeCompletionTeaserPlaceholder.js';
|
|
6
7
|
export * as AutocompleteHistory from './AutocompleteHistory.js';
|
|
7
8
|
export * as Config from './config.js';
|