chrome-devtools-frontend 1.0.1536371 → 1.0.1537860
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/.env.template +9 -0
- package/docs/get_the_code.md +27 -0
- package/front_end/core/common/SettingRegistration.ts +10 -7
- package/front_end/core/common/Settings.ts +3 -0
- 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/core/sdk/sdk-meta.ts +8 -2
- package/front_end/entrypoints/inspector_main/RenderingOptions.ts +4 -3
- package/front_end/generated/SupportedCSSProperties.js +1 -0
- package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +23 -7
- package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.snapshot.txt +110 -5
- package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.ts +50 -45
- package/front_end/models/cpu_profile/ProfileTreeModel.ts +7 -7
- package/front_end/models/javascript_metadata/NativeFunctions.js +1 -1
- package/front_end/models/trace/types/File.ts +9 -0
- package/front_end/models/trace_source_maps_resolver/SourceMapsResolver.ts +1 -1
- 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/StorageView.ts +3 -2
- package/front_end/panels/application/components/BackForwardCacheView.ts +96 -108
- package/front_end/panels/application/components/FrameDetailsView.ts +8 -11
- package/front_end/panels/application/components/OriginTrialTreeView.ts +136 -137
- package/front_end/panels/application/components/backForwardCacheView.css +8 -0
- package/front_end/panels/application/components/badge.css +9 -1
- package/front_end/panels/application/preloading/components/PreloadingGrid.ts +2 -2
- package/front_end/panels/application/preloading/components/PreloadingString.ts +27 -0
- package/front_end/panels/autofill/AutofillView.ts +1 -1
- package/front_end/panels/browser_debugger/CategorizedBreakpointsSidebarPane.ts +44 -53
- package/front_end/panels/console/ConsoleView.ts +11 -9
- package/front_end/panels/coverage/CoverageView.ts +1 -2
- package/front_end/panels/css_overview/CSSOverviewSidebarPanel.ts +1 -1
- package/front_end/panels/developer_resources/DeveloperResourcesView.ts +1 -1
- package/front_end/panels/elements/ElementStatePaneWidget.ts +1 -1
- package/front_end/panels/elements/EventListenersWidget.ts +1 -2
- package/front_end/panels/elements/PropertiesWidget.ts +1 -1
- package/front_end/panels/network/NetworkConfigView.ts +2 -1
- package/front_end/panels/network/NetworkPanel.ts +5 -4
- package/front_end/panels/network/RequestCookiesView.ts +2 -1
- package/front_end/panels/profiler/HeapSnapshotView.ts +3 -2
- package/front_end/panels/recorder/RecorderController.ts +1 -2
- package/front_end/panels/recorder/components/CreateRecordingView.ts +153 -129
- package/front_end/panels/sensors/SensorsView.ts +4 -3
- package/front_end/panels/settings/AISettingsTab.ts +162 -171
- package/front_end/panels/settings/FrameworkIgnoreListSettingsTab.ts +8 -6
- package/front_end/panels/settings/KeybindsSettingsTab.ts +3 -2
- package/front_end/panels/settings/SettingsScreen.ts +5 -8
- package/front_end/panels/settings/WorkspaceSettingsTab.ts +1 -1
- 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/sources/AiCodeCompletionPlugin.ts +2 -1
- package/front_end/panels/sources/SourcesPanel.ts +2 -1
- package/front_end/panels/sources/sources-meta.ts +8 -1
- package/front_end/panels/timeline/TimelinePanel.ts +64 -14
- package/front_end/panels/timeline/TimelineUIUtils.ts +4 -20
- package/front_end/panels/timeline/components/ExportTraceOptions.ts +33 -34
- package/front_end/panels/timeline/components/LiveMetricsView.ts +1 -0
- package/front_end/panels/timeline/components/SidebarAnnotationsTab.ts +2 -0
- 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/adorners/Adorner.ts +2 -1
- package/front_end/ui/components/buttons/Button.docs.ts +195 -0
- package/front_end/ui/components/settings/SettingCheckbox.ts +49 -14
- package/front_end/ui/components/settings/settingCheckbox.css +6 -1
- package/front_end/ui/components/spinners/Spinners.docs.ts +13 -0
- 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.docs.ts +76 -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/FilterBar.ts +1 -2
- package/front_end/ui/legacy/RadioButton.docs.ts +41 -0
- package/front_end/ui/legacy/SelectMenu.docs.ts +98 -0
- package/front_end/ui/legacy/Toolbar.ts +4 -6
- package/front_end/ui/legacy/UIUtils.ts +114 -1
- package/front_end/ui/legacy/Widget.ts +62 -34
- 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/settings_ui/SettingsUI.ts +125 -0
- package/front_end/ui/legacy/components/settings_ui/settings_ui.ts +8 -0
- package/front_end/ui/legacy/components/utils/Linkifier.ts +9 -3
- package/front_end/ui/legacy/legacy.ts +0 -2
- package/front_end/ui/visual_logging/KnownContextValues.ts +4 -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/models/trace/lantern/testing/MetricTestUtils.ts +0 -62
- package/front_end/models/trace/lantern/testing/testing.ts +0 -5
- 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
- package/front_end/ui/components/docs/button/basic.html +0 -44
- package/front_end/ui/components/docs/button/basic.ts +0 -175
- package/front_end/ui/components/docs/radio_button/basic.html +0 -23
- package/front_end/ui/components/docs/radio_button/basic.ts +0 -50
- package/front_end/ui/components/docs/select_menu/basic.html +0 -19
- package/front_end/ui/components/docs/select_menu/basic.ts +0 -95
- package/front_end/ui/components/docs/select_menu/wide-option.html +0 -38
- package/front_end/ui/components/docs/select_menu/wide-option.ts +0 -43
- package/front_end/ui/components/docs/spinners/basic.html +0 -17
- package/front_end/ui/components/docs/spinners/basic.ts +0 -22
- package/front_end/ui/components/docs/tooltip/basic.html +0 -20
- package/front_end/ui/components/docs/tooltip/basic.ts +0 -82
- package/front_end/ui/legacy/SettingsUI.ts +0 -254
|
@@ -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
|
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import type * as Platform from '../../../core/platform/platform.js';
|
|
7
7
|
import {html, render} from '../../../ui/lit/lit.js';
|
|
8
|
+
import * as UI from '../../legacy/legacy.js';
|
|
8
9
|
import * as VisualElements from '../../visual_logging/visual_logging.js';
|
|
9
10
|
|
|
10
11
|
import adornerStyles from './adorner.css.js';
|
|
@@ -37,7 +38,7 @@ export class Adorner extends HTMLElement {
|
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
override cloneNode(deep?: boolean): Node {
|
|
40
|
-
const node =
|
|
41
|
+
const node = UI.UIUtils.cloneCustomElement(this, deep);
|
|
41
42
|
node.data = {name: this.name, content: this.#content, jslogContext: this.#jslogContext};
|
|
42
43
|
return node;
|
|
43
44
|
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
// Copyright 2021 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 {Button, FloatingButton} from './buttons.js';
|
|
6
|
+
|
|
7
|
+
export async function render(container: HTMLElement) {
|
|
8
|
+
const style = document.createElement('style');
|
|
9
|
+
style.textContent = `
|
|
10
|
+
#container > div {
|
|
11
|
+
width: 80%;
|
|
12
|
+
padding: var(--sys-size-11);
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
flex-wrap: wrap;
|
|
16
|
+
gap: var(--sys-size-5);
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
19
|
+
container.appendChild(style);
|
|
20
|
+
|
|
21
|
+
const appendSection = (headerText: string, sectionElement: HTMLElement) => {
|
|
22
|
+
const header = document.createElement('header');
|
|
23
|
+
header.textContent = headerText;
|
|
24
|
+
container.appendChild(header);
|
|
25
|
+
container.appendChild(sectionElement);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const buttonsSection = document.createElement('div');
|
|
29
|
+
const primarySection = document.createElement('div');
|
|
30
|
+
const tonalSection = document.createElement('div');
|
|
31
|
+
const outlineSection = document.createElement('div');
|
|
32
|
+
const textSection = document.createElement('div');
|
|
33
|
+
const iconSection = document.createElement('div');
|
|
34
|
+
const floatingSection = document.createElement('div');
|
|
35
|
+
|
|
36
|
+
appendSection('Buttons', buttonsSection);
|
|
37
|
+
appendSection('Primary buttons', primarySection);
|
|
38
|
+
appendSection('Tonal buttons', tonalSection);
|
|
39
|
+
appendSection('Outlined buttons', outlineSection);
|
|
40
|
+
appendSection('Text buttons', textSection);
|
|
41
|
+
appendSection('Icon buttons', iconSection);
|
|
42
|
+
appendSection('Floating buttons', floatingSection);
|
|
43
|
+
|
|
44
|
+
const DEFAULT_TEXT = 'Default';
|
|
45
|
+
const WITH_ICON_TEXT = 'With icon';
|
|
46
|
+
const MICRO_TEXT = 'Micro';
|
|
47
|
+
// Buttons
|
|
48
|
+
{
|
|
49
|
+
const primaryButton = new Button.Button();
|
|
50
|
+
primaryButton.data = {
|
|
51
|
+
variant: Button.Variant.PRIMARY,
|
|
52
|
+
};
|
|
53
|
+
primaryButton.innerText = 'Primary button';
|
|
54
|
+
buttonsSection.appendChild(primaryButton);
|
|
55
|
+
|
|
56
|
+
const tonalButton = new Button.Button();
|
|
57
|
+
tonalButton.data = {
|
|
58
|
+
variant: Button.Variant.TONAL,
|
|
59
|
+
};
|
|
60
|
+
tonalButton.innerText = 'Tonal button';
|
|
61
|
+
buttonsSection.appendChild(tonalButton);
|
|
62
|
+
|
|
63
|
+
const outlinedButton = new Button.Button();
|
|
64
|
+
outlinedButton.data = {
|
|
65
|
+
variant: Button.Variant.OUTLINED,
|
|
66
|
+
};
|
|
67
|
+
outlinedButton.innerText = 'Outlined button';
|
|
68
|
+
buttonsSection.appendChild(outlinedButton);
|
|
69
|
+
|
|
70
|
+
const textButton = new Button.Button();
|
|
71
|
+
textButton.data = {
|
|
72
|
+
variant: Button.Variant.TEXT,
|
|
73
|
+
};
|
|
74
|
+
textButton.innerText = 'Text button';
|
|
75
|
+
buttonsSection.appendChild(textButton);
|
|
76
|
+
|
|
77
|
+
const iconButton = new Button.Button();
|
|
78
|
+
iconButton.data = {
|
|
79
|
+
variant: Button.Variant.ICON,
|
|
80
|
+
iconName: 'gear',
|
|
81
|
+
};
|
|
82
|
+
buttonsSection.appendChild(iconButton);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Primary buttons
|
|
86
|
+
{
|
|
87
|
+
const primaryDefault = new Button.Button();
|
|
88
|
+
primaryDefault.data = {
|
|
89
|
+
variant: Button.Variant.PRIMARY,
|
|
90
|
+
};
|
|
91
|
+
primaryDefault.innerText = DEFAULT_TEXT;
|
|
92
|
+
primarySection.appendChild(primaryDefault);
|
|
93
|
+
|
|
94
|
+
const primaryWithIcon = new Button.Button();
|
|
95
|
+
primaryWithIcon.innerText = WITH_ICON_TEXT;
|
|
96
|
+
primaryWithIcon.data = {
|
|
97
|
+
variant: Button.Variant.PRIMARY,
|
|
98
|
+
iconName: 'plus',
|
|
99
|
+
};
|
|
100
|
+
primarySection.appendChild(primaryWithIcon);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Tonal buttons
|
|
104
|
+
{
|
|
105
|
+
const tonalDefault = new Button.Button();
|
|
106
|
+
tonalDefault.data = {
|
|
107
|
+
variant: Button.Variant.TONAL,
|
|
108
|
+
};
|
|
109
|
+
tonalDefault.innerText = DEFAULT_TEXT;
|
|
110
|
+
tonalSection.appendChild(tonalDefault);
|
|
111
|
+
|
|
112
|
+
const tonalWithIcon = new Button.Button();
|
|
113
|
+
tonalWithIcon.innerText = WITH_ICON_TEXT;
|
|
114
|
+
|
|
115
|
+
tonalWithIcon.data = {
|
|
116
|
+
variant: Button.Variant.PRIMARY,
|
|
117
|
+
iconName: 'plus',
|
|
118
|
+
};
|
|
119
|
+
tonalSection.appendChild(tonalWithIcon);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Outlined buttons
|
|
123
|
+
{
|
|
124
|
+
const outlinedDefault = new Button.Button();
|
|
125
|
+
outlinedDefault.data = {
|
|
126
|
+
variant: Button.Variant.OUTLINED,
|
|
127
|
+
};
|
|
128
|
+
outlinedDefault.innerText = DEFAULT_TEXT;
|
|
129
|
+
outlineSection.appendChild(outlinedDefault);
|
|
130
|
+
|
|
131
|
+
const outlinedWithIcon = new Button.Button();
|
|
132
|
+
outlinedWithIcon.innerText = WITH_ICON_TEXT;
|
|
133
|
+
outlinedWithIcon.data = {
|
|
134
|
+
variant: Button.Variant.OUTLINED,
|
|
135
|
+
iconName: 'plus',
|
|
136
|
+
};
|
|
137
|
+
outlineSection.appendChild(outlinedWithIcon);
|
|
138
|
+
|
|
139
|
+
const outlinedMicro = new Button.Button();
|
|
140
|
+
outlinedMicro.innerText = MICRO_TEXT;
|
|
141
|
+
outlinedMicro.data = {
|
|
142
|
+
variant: Button.Variant.OUTLINED,
|
|
143
|
+
size: Button.Size.MICRO,
|
|
144
|
+
};
|
|
145
|
+
outlineSection.appendChild(outlinedMicro);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Text buttons
|
|
149
|
+
{
|
|
150
|
+
const textDefault = new Button.Button();
|
|
151
|
+
textDefault.innerText = DEFAULT_TEXT;
|
|
152
|
+
textDefault.data = {
|
|
153
|
+
variant: Button.Variant.TEXT,
|
|
154
|
+
};
|
|
155
|
+
textSection.appendChild(textDefault);
|
|
156
|
+
|
|
157
|
+
const textWithIcon = new Button.Button();
|
|
158
|
+
textWithIcon.innerText = WITH_ICON_TEXT;
|
|
159
|
+
|
|
160
|
+
textWithIcon.data = {
|
|
161
|
+
variant: Button.Variant.TEXT,
|
|
162
|
+
iconName: 'plus',
|
|
163
|
+
};
|
|
164
|
+
textSection.appendChild(textWithIcon);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Icon buttons
|
|
168
|
+
{
|
|
169
|
+
const iconDefault = new Button.Button();
|
|
170
|
+
iconDefault.data = {
|
|
171
|
+
variant: Button.Variant.ICON,
|
|
172
|
+
iconName: 'gear',
|
|
173
|
+
};
|
|
174
|
+
iconSection.appendChild(iconDefault);
|
|
175
|
+
|
|
176
|
+
const iconToggle = new Button.Button();
|
|
177
|
+
iconToggle.data = {
|
|
178
|
+
variant: Button.Variant.ICON_TOGGLE,
|
|
179
|
+
iconName: 'gear',
|
|
180
|
+
toggledIconName: 'gear',
|
|
181
|
+
toggled: true,
|
|
182
|
+
toggleType: Button.ToggleType.PRIMARY,
|
|
183
|
+
};
|
|
184
|
+
const toggledWithLabel = document.createElement('span');
|
|
185
|
+
toggledWithLabel.textContent = '(Toggle)';
|
|
186
|
+
iconSection.appendChild(iconToggle);
|
|
187
|
+
iconSection.appendChild(toggledWithLabel);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Floating buttons
|
|
191
|
+
{
|
|
192
|
+
const floatingButton = FloatingButton.create('smart-assistant', 'Ask AI!');
|
|
193
|
+
floatingSection.appendChild(floatingButton);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
// found in the LICENSE file.
|
|
4
4
|
/* eslint-disable @devtools/no-lit-render-outside-of-view */
|
|
5
5
|
|
|
6
|
+
import '../tooltips/tooltips.js';
|
|
6
7
|
import './SettingDeprecationWarning.js';
|
|
8
|
+
import '../../legacy/legacy.js';
|
|
7
9
|
|
|
8
10
|
import type * as Common from '../../../core/common/common.js';
|
|
9
11
|
import * as Host from '../../../core/host/host.js';
|
|
@@ -66,23 +68,56 @@ export class SettingCheckbox extends HTMLElement {
|
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
const learnMore = this.#setting.learnMore();
|
|
69
|
-
if (learnMore
|
|
70
|
-
const
|
|
71
|
+
if (learnMore) {
|
|
72
|
+
const jsLogContext = `${this.#setting.name}-documentation`;
|
|
71
73
|
const data: Buttons.Button.ButtonData = {
|
|
72
|
-
iconName: '
|
|
74
|
+
iconName: 'info',
|
|
73
75
|
variant: Buttons.Button.Variant.ICON,
|
|
74
76
|
size: Buttons.Button.Size.SMALL,
|
|
75
|
-
jslogContext:
|
|
76
|
-
title: i18nString(UIStrings.learnMore),
|
|
77
|
-
};
|
|
78
|
-
const handleClick = (event: MouseEvent): void => {
|
|
79
|
-
Host.InspectorFrontendHost.InspectorFrontendHostInstance.openInNewTab(url);
|
|
80
|
-
event.consume();
|
|
77
|
+
jslogContext: jsLogContext,
|
|
81
78
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
|
|
80
|
+
const url = learnMore.url;
|
|
81
|
+
if (learnMore.tooltip) {
|
|
82
|
+
const id = `${this.#setting.name}-information`;
|
|
83
|
+
// clang-format off
|
|
84
|
+
return html`
|
|
85
|
+
<devtools-button
|
|
86
|
+
class="info-icon"
|
|
87
|
+
aria-details=${id}
|
|
88
|
+
.data=${data}
|
|
89
|
+
></devtools-button>
|
|
90
|
+
<devtools-tooltip id=${id} variant="rich">
|
|
91
|
+
<span>${learnMore.tooltip()}</span><br />
|
|
92
|
+
${url
|
|
93
|
+
? html`<x-link
|
|
94
|
+
href=${url}
|
|
95
|
+
class="link"
|
|
96
|
+
jslog=${VisualLogging.link(jsLogContext).track({
|
|
97
|
+
click: true,
|
|
98
|
+
})}
|
|
99
|
+
>${i18nString(UIStrings.learnMore)}</x-link
|
|
100
|
+
>`
|
|
101
|
+
: Lit.nothing}
|
|
102
|
+
</devtools-tooltip>
|
|
103
|
+
`;
|
|
104
|
+
// clang-format on
|
|
105
|
+
}
|
|
106
|
+
if (url) {
|
|
107
|
+
const handleClick = (event: MouseEvent): void => {
|
|
108
|
+
Host.InspectorFrontendHost.InspectorFrontendHostInstance.openInNewTab(url);
|
|
109
|
+
event.consume();
|
|
110
|
+
};
|
|
111
|
+
data.iconName = 'help';
|
|
112
|
+
data.title = i18nString(UIStrings.learnMore);
|
|
113
|
+
// clang-format off
|
|
114
|
+
return html`<devtools-button
|
|
115
|
+
class="info-icon"
|
|
116
|
+
@click=${handleClick}
|
|
117
|
+
.data=${data}
|
|
118
|
+
></devtools-button>`;
|
|
119
|
+
// clang-format on
|
|
120
|
+
}
|
|
86
121
|
}
|
|
87
122
|
|
|
88
123
|
return undefined;
|
|
@@ -102,7 +137,7 @@ export class SettingCheckbox extends HTMLElement {
|
|
|
102
137
|
}
|
|
103
138
|
|
|
104
139
|
const icon = this.icon();
|
|
105
|
-
const title = `${this.#setting.learnMore() ? this.#setting.learnMore()?.tooltip() : ''}`;
|
|
140
|
+
const title = `${this.#setting.learnMore() ? this.#setting.learnMore()?.tooltip?.() : ''}`;
|
|
106
141
|
const disabledReasons = this.#setting.disabledReasons();
|
|
107
142
|
const reason = disabledReasons.length ?
|
|
108
143
|
html`
|
|
@@ -35,7 +35,7 @@ p {
|
|
|
35
35
|
height: var(--sys-size-9);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
.
|
|
38
|
+
.info-icon {
|
|
39
39
|
cursor: pointer;
|
|
40
40
|
position: relative;
|
|
41
41
|
margin-left: var(--sys-size-2);
|
|
@@ -43,3 +43,8 @@ p {
|
|
|
43
43
|
width: var(--sys-size-9);
|
|
44
44
|
height: var(--sys-size-9);
|
|
45
45
|
}
|
|
46
|
+
|
|
47
|
+
.link {
|
|
48
|
+
color: var(--text-link);
|
|
49
|
+
text-decoration: underline;
|
|
50
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
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 './spinners.js';
|
|
6
|
+
|
|
7
|
+
import * as Lit from '../../lit/lit.js';
|
|
8
|
+
|
|
9
|
+
const {html} = Lit;
|
|
10
|
+
|
|
11
|
+
export async function render(container: HTMLElement) {
|
|
12
|
+
Lit.render(html`<devtools-spinner></devtools-spinner>`, container);
|
|
13
|
+
}
|
|
@@ -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';
|