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
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import * as Common from '../common/common.js';
|
|
6
6
|
import * as Root from '../root/root.js';
|
|
7
7
|
|
|
8
|
+
import * as DispatchHttpRequestClient from './DispatchHttpRequestClient.js';
|
|
8
9
|
import {InspectorFrontendHostInstance} from './InspectorFrontendHost.js';
|
|
9
10
|
import type {AidaClientResult, AidaCodeCompleteResult, SyncInformation} from './InspectorFrontendHostAPI.js';
|
|
10
11
|
import {bindOutputStream} from './ResourceLoader.js';
|
|
@@ -213,6 +214,24 @@ export interface CompleteCodeOptions {
|
|
|
213
214
|
}
|
|
214
215
|
/* eslint-enable @typescript-eslint/naming-convention */
|
|
215
216
|
|
|
217
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
218
|
+
export interface GenerateCodeOptions {
|
|
219
|
+
temperature?: number;
|
|
220
|
+
model_id?: string;
|
|
221
|
+
inference_language?: AidaInferenceLanguage;
|
|
222
|
+
expect_code_output?: boolean;
|
|
223
|
+
}
|
|
224
|
+
/* eslint-enable @typescript-eslint/naming-convention */
|
|
225
|
+
|
|
226
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
227
|
+
export interface ContextFile {
|
|
228
|
+
path: string;
|
|
229
|
+
full_content: string;
|
|
230
|
+
selected_content?: string;
|
|
231
|
+
programming_language: AidaInferenceLanguage;
|
|
232
|
+
}
|
|
233
|
+
/* eslint-enable @typescript-eslint/naming-convention */
|
|
234
|
+
|
|
216
235
|
export enum EditType {
|
|
217
236
|
// Unknown edit type
|
|
218
237
|
EDIT_TYPE_UNSPECIFIED = 0,
|
|
@@ -252,6 +271,12 @@ export enum Reason {
|
|
|
252
271
|
}
|
|
253
272
|
|
|
254
273
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
274
|
+
export interface AdditionalFile {
|
|
275
|
+
path: string;
|
|
276
|
+
content: string;
|
|
277
|
+
included_reason: Reason;
|
|
278
|
+
}
|
|
279
|
+
|
|
255
280
|
export interface CompletionRequest {
|
|
256
281
|
client: string;
|
|
257
282
|
prefix: string;
|
|
@@ -259,11 +284,28 @@ export interface CompletionRequest {
|
|
|
259
284
|
options?: CompleteCodeOptions;
|
|
260
285
|
metadata: RequestMetadata;
|
|
261
286
|
last_user_action?: EditType;
|
|
262
|
-
additional_files?:
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
287
|
+
additional_files?: AdditionalFile[];
|
|
288
|
+
}
|
|
289
|
+
/* eslint-enable @typescript-eslint/naming-convention */
|
|
290
|
+
|
|
291
|
+
export enum UseCase {
|
|
292
|
+
// Unspecified usecase.
|
|
293
|
+
USE_CASE_UNSPECIFIED = 0,
|
|
294
|
+
|
|
295
|
+
// Code generation use case is expected to generate code from scratch
|
|
296
|
+
CODE_GENERATION = 1,
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
300
|
+
export interface GenerateCodeRequest {
|
|
301
|
+
client: string;
|
|
302
|
+
preamble: string;
|
|
303
|
+
current_message: Content;
|
|
304
|
+
options?: GenerateCodeOptions;
|
|
305
|
+
context_files?: ContextFile[];
|
|
306
|
+
use_case: UseCase;
|
|
307
|
+
metadata: RequestMetadata;
|
|
308
|
+
client_feature?: ClientFeature;
|
|
267
309
|
}
|
|
268
310
|
/* eslint-enable @typescript-eslint/naming-convention */
|
|
269
311
|
|
|
@@ -363,6 +405,11 @@ export interface CompletionResponse {
|
|
|
363
405
|
metadata: ResponseMetadata;
|
|
364
406
|
}
|
|
365
407
|
|
|
408
|
+
export interface GenerateCodeResponse {
|
|
409
|
+
samples: GenerationSample[];
|
|
410
|
+
metadata: ResponseMetadata;
|
|
411
|
+
}
|
|
412
|
+
|
|
366
413
|
export interface GenerationSample {
|
|
367
414
|
generationString: string;
|
|
368
415
|
score: number;
|
|
@@ -416,6 +463,7 @@ const AidaLanguageToMarkdown: Record<AidaInferenceLanguage, string> = {
|
|
|
416
463
|
};
|
|
417
464
|
|
|
418
465
|
export const CLIENT_NAME = 'CHROME_DEVTOOLS';
|
|
466
|
+
export const SERVICE_NAME = 'aidaService';
|
|
419
467
|
|
|
420
468
|
const CODE_CHUNK_SEPARATOR = (lang = ''): string => ('\n`````' + lang + '\n');
|
|
421
469
|
|
|
@@ -657,6 +705,17 @@ export class AidaClient {
|
|
|
657
705
|
|
|
658
706
|
return {generatedSamples, metadata};
|
|
659
707
|
}
|
|
708
|
+
|
|
709
|
+
async generateCode(request: GenerateCodeRequest): Promise<GenerateCodeResponse|null> {
|
|
710
|
+
const response = await DispatchHttpRequestClient.makeHttpRequest<GenerateCodeResponse>({
|
|
711
|
+
service: SERVICE_NAME,
|
|
712
|
+
path: '/v1/aida:generateCode',
|
|
713
|
+
method: 'POST',
|
|
714
|
+
body: JSON.stringify(request),
|
|
715
|
+
});
|
|
716
|
+
|
|
717
|
+
return response;
|
|
718
|
+
}
|
|
660
719
|
}
|
|
661
720
|
|
|
662
721
|
export function convertToUserTierEnum(userTier: string|undefined): UserTier {
|
|
@@ -0,0 +1,62 @@
|
|
|
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 {InspectorFrontendHostInstance} from './InspectorFrontendHost.js';
|
|
6
|
+
import type {DispatchHttpRequestRequest, DispatchHttpRequestResult} from './InspectorFrontendHostAPI.js';
|
|
7
|
+
|
|
8
|
+
export enum ErrorType {
|
|
9
|
+
HTTP_RESPONSE_UNAVAILABLE = 'HTTP_RESPONSE_UNAVAILABLE',
|
|
10
|
+
NOT_FOUND = 'NOT_FOUND',
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class DispatchHttpRequestError extends Error {
|
|
14
|
+
constructor(readonly type: ErrorType, options?: ErrorOptions) {
|
|
15
|
+
super(undefined, options);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function makeHttpRequest<R>(request: DispatchHttpRequestRequest): Promise<R> {
|
|
20
|
+
const response = await new Promise<DispatchHttpRequestResult>(resolve => {
|
|
21
|
+
InspectorFrontendHostInstance.dispatchHttpRequest(request, resolve);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
debugLog({request, response});
|
|
25
|
+
if (response.statusCode === 404) {
|
|
26
|
+
throw new DispatchHttpRequestError(ErrorType.NOT_FOUND);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if ('response' in response && response.statusCode === 200) {
|
|
30
|
+
try {
|
|
31
|
+
return JSON.parse(response.response) as R;
|
|
32
|
+
} catch (err) {
|
|
33
|
+
throw new DispatchHttpRequestError(ErrorType.HTTP_RESPONSE_UNAVAILABLE, {cause: err});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
throw new DispatchHttpRequestError(ErrorType.HTTP_RESPONSE_UNAVAILABLE);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function isDebugMode(): boolean {
|
|
41
|
+
return Boolean(localStorage.getItem('debugDispatchHttpRequestEnabled'));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function debugLog(...log: unknown[]): void {
|
|
45
|
+
if (!isDebugMode()) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// eslint-disable-next-line no-console
|
|
50
|
+
console.log('debugLog', ...log);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function setDebugDispatchHttpRequestEnabled(enabled: boolean): void {
|
|
54
|
+
if (enabled) {
|
|
55
|
+
localStorage.setItem('debugDispatchHttpRequestEnabled', 'true');
|
|
56
|
+
} else {
|
|
57
|
+
localStorage.removeItem('debugDispatchHttpRequestEnabled');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// @ts-expect-error
|
|
62
|
+
globalThis.setDebugDispatchHttpRequestEnabled = setDebugDispatchHttpRequestEnabled;
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Root from '../root/root.js';
|
|
6
6
|
|
|
7
|
-
import
|
|
8
|
-
import type {DispatchHttpRequestRequest
|
|
7
|
+
import * as DispatchHttpRequestClient from './DispatchHttpRequestClient.js';
|
|
8
|
+
import type {DispatchHttpRequestRequest} from './InspectorFrontendHostAPI.js';
|
|
9
9
|
|
|
10
10
|
export enum SubscriptionStatus {
|
|
11
11
|
ENABLED = 'SUBSCRIPTION_STATE_ENABLED',
|
|
@@ -73,17 +73,6 @@ export interface GetProfileResponse {
|
|
|
73
73
|
isEligible: boolean;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
export enum GdpErrorType {
|
|
77
|
-
HTTP_RESPONSE_UNAVAILABLE = 'HTTP_RESPONSE_UNAVAILABLE',
|
|
78
|
-
NOT_FOUND = 'NOT_FOUND',
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
class GdpError extends Error {
|
|
82
|
-
constructor(readonly type: GdpErrorType, options?: ErrorOptions) {
|
|
83
|
-
super(undefined, options);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
76
|
/**
|
|
88
77
|
* The `batchGet` awards endpoint returns badge names with an
|
|
89
78
|
* obfuscated user ID (e.g., `profiles/12345/awards/badge-name`).
|
|
@@ -99,27 +88,12 @@ export const GOOGLE_DEVELOPER_PROGRAM_PROFILE_LINK = 'https://developers.google.
|
|
|
99
88
|
|
|
100
89
|
async function makeHttpRequest<R>(request: DispatchHttpRequestRequest): Promise<R> {
|
|
101
90
|
if (!isGdpProfilesAvailable()) {
|
|
102
|
-
throw new
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const response = await new Promise<DispatchHttpRequestResult>(resolve => {
|
|
106
|
-
InspectorFrontendHostInstance.dispatchHttpRequest(request, resolve);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
debugLog({request, response});
|
|
110
|
-
if (response.statusCode === 404) {
|
|
111
|
-
throw new GdpError(GdpErrorType.NOT_FOUND);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if ('response' in response && response.statusCode === 200) {
|
|
115
|
-
try {
|
|
116
|
-
return JSON.parse(response.response) as R;
|
|
117
|
-
} catch (err) {
|
|
118
|
-
throw new GdpError(GdpErrorType.HTTP_RESPONSE_UNAVAILABLE, {cause: err});
|
|
119
|
-
}
|
|
91
|
+
throw new DispatchHttpRequestClient.DispatchHttpRequestError(
|
|
92
|
+
DispatchHttpRequestClient.ErrorType.HTTP_RESPONSE_UNAVAILABLE);
|
|
120
93
|
}
|
|
121
94
|
|
|
122
|
-
|
|
95
|
+
const response = await DispatchHttpRequestClient.makeHttpRequest(request) as R;
|
|
96
|
+
return response;
|
|
123
97
|
}
|
|
124
98
|
|
|
125
99
|
const SERVICE_NAME = 'gdpService';
|
|
@@ -158,7 +132,8 @@ export class GdpClient {
|
|
|
158
132
|
isEligible: true,
|
|
159
133
|
};
|
|
160
134
|
} catch (err: unknown) {
|
|
161
|
-
if (err instanceof
|
|
135
|
+
if (err instanceof DispatchHttpRequestClient.DispatchHttpRequestError &&
|
|
136
|
+
err.type === DispatchHttpRequestClient.ErrorType.HTTP_RESPONSE_UNAVAILABLE) {
|
|
162
137
|
return null;
|
|
163
138
|
}
|
|
164
139
|
}
|
|
@@ -265,27 +240,6 @@ export class GdpClient {
|
|
|
265
240
|
}
|
|
266
241
|
}
|
|
267
242
|
|
|
268
|
-
function isDebugMode(): boolean {
|
|
269
|
-
return Boolean(localStorage.getItem('debugGdpIntegrationEnabled'));
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
function debugLog(...log: unknown[]): void {
|
|
273
|
-
if (!isDebugMode()) {
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
// eslint-disable-next-line no-console
|
|
278
|
-
console.log('debugLog', ...log);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
function setDebugGdpIntegrationEnabled(enabled: boolean): void {
|
|
282
|
-
if (enabled) {
|
|
283
|
-
localStorage.setItem('debugGdpIntegrationEnabled', 'true');
|
|
284
|
-
} else {
|
|
285
|
-
localStorage.removeItem('debugGdpIntegrationEnabled');
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
243
|
export function isGdpProfilesAvailable(): boolean {
|
|
290
244
|
const isBaseFeatureEnabled = Boolean(Root.Runtime.hostConfig.devToolsGdpProfiles?.enabled);
|
|
291
245
|
const isBrandedBuild = Boolean(Root.Runtime.hostConfig.devToolsGdpProfilesAvailability?.enabled);
|
|
@@ -311,6 +265,3 @@ export function isBadgesEnabled(): boolean {
|
|
|
311
265
|
export function isStarterBadgeEnabled(): boolean {
|
|
312
266
|
return Boolean(Root.Runtime.hostConfig.devToolsGdpProfiles?.starterBadgeEnabled);
|
|
313
267
|
}
|
|
314
|
-
|
|
315
|
-
// @ts-expect-error
|
|
316
|
-
globalThis.setDebugGdpIntegrationEnabled = setDebugGdpIntegrationEnabled;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// found in the LICENSE file.
|
|
4
4
|
|
|
5
5
|
import * as AidaClient from './AidaClient.js';
|
|
6
|
+
import * as DispatchHttpRequestClient from './DispatchHttpRequestClient.js';
|
|
6
7
|
import * as GdpClient from './GdpClient.js';
|
|
7
8
|
import * as InspectorFrontendHost from './InspectorFrontendHost.js';
|
|
8
9
|
import * as InspectorFrontendHostAPI from './InspectorFrontendHostAPI.js';
|
|
@@ -12,6 +13,7 @@ import * as UserMetrics from './UserMetrics.js';
|
|
|
12
13
|
|
|
13
14
|
export {
|
|
14
15
|
AidaClient,
|
|
16
|
+
DispatchHttpRequestClient,
|
|
15
17
|
GdpClient,
|
|
16
18
|
InspectorFrontendHost,
|
|
17
19
|
InspectorFrontendHostAPI,
|
|
@@ -41,17 +41,19 @@ export const enum CDPErrorStatus {
|
|
|
41
41
|
SESSION_NOT_FOUND = SERVER_ERROR - 1,
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
export interface CDPError
|
|
44
|
+
export interface CDPError {
|
|
45
|
+
code: CDPErrorStatus;
|
|
46
|
+
message: string;
|
|
47
|
+
data?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface CDPErrorMessage extends CDPBaseMessage {
|
|
45
51
|
id?: number;
|
|
46
|
-
error:
|
|
47
|
-
code: CDPErrorStatus,
|
|
48
|
-
message: string,
|
|
49
|
-
data?: string,
|
|
50
|
-
};
|
|
52
|
+
error: CDPError;
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
-
export type CDPMessage = CDPCommandRequest<any>|CDPCommandResponse<any>|CDPEvent<any>|
|
|
56
|
+
export type CDPMessage = CDPCommandRequest<any>|CDPCommandResponse<any>|CDPEvent<any>|CDPErrorMessage;
|
|
55
57
|
|
|
56
58
|
/**
|
|
57
59
|
* Allows the sending and receiving of CDP commands and the notification of CDP events to observers.
|
|
@@ -62,7 +64,7 @@ export type CDPMessage = CDPCommandRequest<any>|CDPCommandResponse<any>|CDPEvent
|
|
|
62
64
|
*/
|
|
63
65
|
export interface CDPConnection {
|
|
64
66
|
send<T extends keyof ProtocolMapping.Commands>(method: T, params: CommandParams<T>, sessionId: string|undefined):
|
|
65
|
-
Promise<CommandResult<T
|
|
67
|
+
Promise<{result: CommandResult<T>}|{error: CDPError}>;
|
|
66
68
|
|
|
67
69
|
observe(observer: CDPConnectionObserver): void;
|
|
68
70
|
unobserve(observer: CDPConnectionObserver): void;
|
|
@@ -67,9 +67,13 @@ interface CommandParameter {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
type Callback = (error: MessageError|null, arg1: Object|null) => void;
|
|
70
|
+
interface ResponseWithError {
|
|
71
|
+
error: MessageError|null;
|
|
72
|
+
result: Object|null;
|
|
73
|
+
}
|
|
70
74
|
|
|
71
75
|
interface CallbackWithDebugInfo {
|
|
72
|
-
|
|
76
|
+
resolve: (response: ResponseWithError) => void;
|
|
73
77
|
method: string;
|
|
74
78
|
}
|
|
75
79
|
|
|
@@ -241,8 +245,15 @@ export class SessionRouter {
|
|
|
241
245
|
if (!session) {
|
|
242
246
|
return;
|
|
243
247
|
}
|
|
244
|
-
for (const
|
|
245
|
-
|
|
248
|
+
for (const {resolve, method} of session.callbacks.values()) {
|
|
249
|
+
resolve({
|
|
250
|
+
result: null,
|
|
251
|
+
error: {
|
|
252
|
+
message: `Session is unregistering, can\'t dispatch pending call to ${method}`,
|
|
253
|
+
code: ConnectionClosedErrorCode,
|
|
254
|
+
data: null,
|
|
255
|
+
}
|
|
256
|
+
});
|
|
246
257
|
}
|
|
247
258
|
this.#sessions.delete(sessionId);
|
|
248
259
|
}
|
|
@@ -255,7 +266,8 @@ export class SessionRouter {
|
|
|
255
266
|
return this.#connection;
|
|
256
267
|
}
|
|
257
268
|
|
|
258
|
-
sendMessage(sessionId: string, domain: string, method: QualifiedName, params: Object|null
|
|
269
|
+
sendMessage(sessionId: string, domain: string, method: QualifiedName, params: Object|null):
|
|
270
|
+
Promise<ResponseWithError> {
|
|
259
271
|
const messageId = this.nextMessageId();
|
|
260
272
|
const messageObject: Message = {
|
|
261
273
|
id: messageId,
|
|
@@ -285,16 +297,19 @@ export class SessionRouter {
|
|
|
285
297
|
|
|
286
298
|
const session = this.#sessions.get(sessionId);
|
|
287
299
|
if (!session) {
|
|
288
|
-
return;
|
|
300
|
+
return Promise.resolve({error: null, result: null});
|
|
289
301
|
}
|
|
290
|
-
|
|
291
|
-
|
|
302
|
+
|
|
303
|
+
return new Promise(resolve => {
|
|
304
|
+
session.callbacks.set(messageId, {resolve, method});
|
|
305
|
+
this.#connection.sendRawMessage(JSON.stringify(messageObject));
|
|
306
|
+
});
|
|
292
307
|
}
|
|
293
308
|
|
|
294
309
|
private sendRawMessageForTesting(method: QualifiedName, params: Object|null, callback: Callback|null, sessionId = ''):
|
|
295
310
|
void {
|
|
296
311
|
const domain = method.split('.')[0];
|
|
297
|
-
this.sendMessage(sessionId, domain, method, params,
|
|
312
|
+
void this.sendMessage(sessionId, domain, method, params).then(({error, result}) => callback?.(error, result));
|
|
298
313
|
}
|
|
299
314
|
|
|
300
315
|
private onMessage(message: string|Object): void {
|
|
@@ -357,7 +372,7 @@ export class SessionRouter {
|
|
|
357
372
|
return;
|
|
358
373
|
}
|
|
359
374
|
|
|
360
|
-
callback.
|
|
375
|
+
callback.resolve({error: messageObject.error || null, result: messageObject.result || null});
|
|
361
376
|
--this.#pendingResponsesCount;
|
|
362
377
|
this.#pendingLongPollingMessageIds.delete(messageObject.id);
|
|
363
378
|
|
|
@@ -403,24 +418,6 @@ export class SessionRouter {
|
|
|
403
418
|
}
|
|
404
419
|
}
|
|
405
420
|
}
|
|
406
|
-
|
|
407
|
-
static dispatchConnectionError(callback: Callback, method: string): void {
|
|
408
|
-
const error = {
|
|
409
|
-
message: `Connection is closed, can\'t dispatch pending call to ${method}`,
|
|
410
|
-
code: ConnectionClosedErrorCode,
|
|
411
|
-
data: null,
|
|
412
|
-
};
|
|
413
|
-
window.setTimeout(() => callback(error, null), 0);
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
static dispatchUnregisterSessionError({callback, method}: CallbackWithDebugInfo): void {
|
|
417
|
-
const error = {
|
|
418
|
-
message: `Session is unregistering, can\'t dispatch pending call to ${method}`,
|
|
419
|
-
code: ConnectionClosedErrorCode,
|
|
420
|
-
data: null,
|
|
421
|
-
};
|
|
422
|
-
window.setTimeout(() => callback(error, null), 0);
|
|
423
|
-
}
|
|
424
421
|
}
|
|
425
422
|
|
|
426
423
|
/**
|
|
@@ -878,23 +875,20 @@ class AgentPrototype {
|
|
|
878
875
|
}
|
|
879
876
|
|
|
880
877
|
private invoke(method: QualifiedName, request: Object|null): Promise<Protocol.ProtocolResponseWithError> {
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
const errorMessage = error?.message;
|
|
889
|
-
fulfill({...result, getError: () => errorMessage});
|
|
890
|
-
};
|
|
878
|
+
const router = this.target.router();
|
|
879
|
+
if (!router) {
|
|
880
|
+
return Promise.resolve(
|
|
881
|
+
{result: null, getError: () => `Connection is closed, can\'t dispatch pending call to ${method}`});
|
|
882
|
+
}
|
|
891
883
|
|
|
892
|
-
|
|
893
|
-
if (!
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
router.sendMessage(this.target.sessionId, this.domain, method, request, callback);
|
|
884
|
+
return router.sendMessage(this.target.sessionId, this.domain, method, request).then(({error, result}) => {
|
|
885
|
+
if (error && !test.suppressRequestErrors && error.code !== DevToolsStubErrorCode &&
|
|
886
|
+
error.code !== GenericErrorCode && error.code !== ConnectionClosedErrorCode) {
|
|
887
|
+
console.error('Request ' + method + ' failed. ' + JSON.stringify(error));
|
|
897
888
|
}
|
|
889
|
+
|
|
890
|
+
const errorMessage = error?.message;
|
|
891
|
+
return {...result, getError: () => errorMessage};
|
|
898
892
|
});
|
|
899
893
|
}
|
|
900
894
|
}
|
|
@@ -8,7 +8,7 @@ import type * as Platform from '../platform/platform.js';
|
|
|
8
8
|
import {UserVisibleError} from '../platform/platform.js';
|
|
9
9
|
|
|
10
10
|
import type {
|
|
11
|
-
HydratingDataPerTarget, RehydratingExecutionContext, RehydratingScript, RehydratingTarget} from
|
|
11
|
+
HydratingDataPerTarget, RehydratingExecutionContext, RehydratingResource, RehydratingScript, RehydratingTarget} from
|
|
12
12
|
'./RehydratingObject.js';
|
|
13
13
|
import type {SourceMapV3} from './SourceMap.js';
|
|
14
14
|
import type {TraceObject} from './TraceObject.js';
|
|
@@ -142,6 +142,7 @@ export class EnhancedTracesParser {
|
|
|
142
142
|
#targets: RehydratingTarget[] = [];
|
|
143
143
|
#executionContexts: RehydratingExecutionContext[] = [];
|
|
144
144
|
#scripts: RehydratingScript[] = [];
|
|
145
|
+
#resources: RehydratingResource[] = [];
|
|
145
146
|
static readonly enhancedTraceVersion: number = 1;
|
|
146
147
|
|
|
147
148
|
constructor(trace: TraceObject) {
|
|
@@ -319,7 +320,10 @@ export class EnhancedTracesParser {
|
|
|
319
320
|
this.resolveSourceMap(script);
|
|
320
321
|
}
|
|
321
322
|
|
|
322
|
-
|
|
323
|
+
this.#resources = this.#trace.metadata.resources ?? [];
|
|
324
|
+
|
|
325
|
+
return this.groupContextsAndScriptsUnderTarget(
|
|
326
|
+
this.#targets, this.#executionContexts, this.#scripts, this.#resources);
|
|
323
327
|
}
|
|
324
328
|
|
|
325
329
|
private resolveSourceMap(script: RehydratingScript): void {
|
|
@@ -411,8 +415,8 @@ export class EnhancedTracesParser {
|
|
|
411
415
|
}
|
|
412
416
|
|
|
413
417
|
private groupContextsAndScriptsUnderTarget(
|
|
414
|
-
targets: RehydratingTarget[], executionContexts: RehydratingExecutionContext[],
|
|
415
|
-
|
|
418
|
+
targets: RehydratingTarget[], executionContexts: RehydratingExecutionContext[], scripts: RehydratingScript[],
|
|
419
|
+
resources: RehydratingResource[]): HydratingDataPerTarget[] {
|
|
416
420
|
const data: HydratingDataPerTarget[] = [];
|
|
417
421
|
const targetIds = new Set<Protocol.Target.TargetID>();
|
|
418
422
|
const targetToExecutionContexts: Map<string, RehydratingExecutionContext[]> =
|
|
@@ -424,12 +428,15 @@ export class EnhancedTracesParser {
|
|
|
424
428
|
const targetToScripts: Map<Protocol.Target.TargetID, RehydratingScript[]> =
|
|
425
429
|
new Map<Protocol.Target.TargetID, RehydratingScript[]>();
|
|
426
430
|
const orphanScripts: RehydratingScript[] = [];
|
|
431
|
+
const targetToResources: Map<Protocol.Target.TargetID, RehydratingResource[]> =
|
|
432
|
+
new Map<Protocol.Target.TargetID, RehydratingResource[]>();
|
|
427
433
|
|
|
428
434
|
// Initialize all the mapping needed
|
|
429
435
|
for (const target of targets) {
|
|
430
436
|
targetIds.add(target.targetId);
|
|
431
437
|
targetToExecutionContexts.set(target.targetId, []);
|
|
432
438
|
targetToScripts.set(target.targetId, []);
|
|
439
|
+
targetToResources.set(target.targetId, []);
|
|
433
440
|
}
|
|
434
441
|
|
|
435
442
|
// Put all of the known execution contexts under respective targets
|
|
@@ -485,12 +492,20 @@ export class EnhancedTracesParser {
|
|
|
485
492
|
}
|
|
486
493
|
}
|
|
487
494
|
|
|
495
|
+
for (const resource of resources) {
|
|
496
|
+
const frameId = resource.frame as Protocol.Target.TargetID;
|
|
497
|
+
if (targetIds.has(frameId)) {
|
|
498
|
+
targetToResources.get(frameId)?.push(resource);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
488
502
|
// Now all the scripts are linked to a target, we want to make sure all the scripts are pointing to a valid
|
|
489
503
|
// execution context. If not, we will create an artificial execution context for the script
|
|
490
504
|
for (const target of targets) {
|
|
491
505
|
const targetId = target.targetId;
|
|
492
506
|
const executionContexts = targetToExecutionContexts.get(targetId) || [];
|
|
493
507
|
const scripts = targetToScripts.get(targetId) || [];
|
|
508
|
+
const resources = targetToResources.get(targetId) || [];
|
|
494
509
|
for (const script of scripts) {
|
|
495
510
|
if (!executionContexts.find(context => context.id === script.executionContextId)) {
|
|
496
511
|
const artificialContext: RehydratingExecutionContext = {
|
|
@@ -511,7 +526,7 @@ export class EnhancedTracesParser {
|
|
|
511
526
|
}
|
|
512
527
|
|
|
513
528
|
// Finally, we put all the information into the data structure we want to return as.
|
|
514
|
-
data.push({target, executionContexts, scripts});
|
|
529
|
+
data.push({target, executionContexts, scripts, resources});
|
|
515
530
|
}
|
|
516
531
|
|
|
517
532
|
return data;
|