chrome-devtools-frontend 1.0.1541552 → 1.0.1543082
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/docs/get_the_code.md +9 -0
- package/front_end/Tests.js +1 -0
- package/front_end/core/common/Settings.ts +38 -15
- package/front_end/core/host/InspectorFrontendHost.ts +0 -3
- package/front_end/core/host/UserMetrics.ts +5 -0
- package/front_end/core/root/Runtime.ts +0 -10
- package/front_end/core/sdk/IOModel.ts +1 -4
- package/front_end/core/sdk/NetworkManager.ts +0 -7
- package/front_end/core/sdk/NetworkRequest.ts +0 -10
- package/front_end/core/sdk/ServerSentEventsProtocol.ts +4 -0
- package/front_end/entrypoints/inspector_main/RenderingOptions.ts +5 -5
- package/front_end/entrypoints/main/MainImpl.ts +6 -3
- package/front_end/entrypoints/main/main-meta.ts +1 -5
- package/front_end/foundation/Universe.ts +2 -10
- package/front_end/generated/Deprecation.ts +0 -14
- package/front_end/generated/InspectorBackendCommands.ts +1 -1
- package/front_end/generated/SupportedCSSProperties.js +42 -42
- package/front_end/generated/protocol.ts +0 -1
- package/front_end/models/ai_assistance/BuiltInAi.ts +13 -7
- package/front_end/models/ai_code_completion/AiCodeCompletion.ts +72 -31
- package/front_end/models/bindings/CompilerScriptMapping.ts +3 -2
- package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +3 -1
- package/front_end/models/har/Importer.ts +14 -0
- package/front_end/models/issues_manager/IssuesManager.ts +0 -5
- package/front_end/models/javascript_metadata/NativeFunctions.js +0 -4
- package/front_end/models/trace/handlers/ScriptsHandler.ts +26 -0
- package/front_end/models/trace/types/TraceEvents.ts +1 -1
- package/front_end/panels/ai_assistance/AiAssistancePanel.ts +117 -103
- package/front_end/panels/ai_assistance/components/ChatView.ts +7 -31
- package/front_end/panels/ai_assistance/components/chatView.css +1 -1
- package/front_end/panels/application/components/BackForwardCacheView.ts +12 -9
- package/front_end/panels/console/ConsoleInsightTeaser.ts +5 -0
- package/front_end/panels/console/ConsolePrompt.ts +9 -2
- package/front_end/panels/console/ConsoleView.ts +3 -0
- package/front_end/panels/network/NetworkDataGridNode.ts +0 -7
- package/front_end/panels/network/NetworkLogView.ts +1 -45
- package/front_end/panels/security/SecurityPanel.ts +0 -2
- package/front_end/panels/security/SecurityPanelSidebar.ts +0 -16
- package/front_end/panels/security/security.ts +0 -2
- package/front_end/panels/sources/AiCodeCompletionPlugin.ts +17 -1
- package/front_end/third_party/chromium/README.chromium +1 -1
- package/front_end/ui/components/expandable_list/ExpandableList.docs.ts +30 -0
- package/front_end/ui/components/markdown_view/MarkdownLinksMap.ts +0 -4
- package/front_end/ui/components/markdown_view/MarkdownView.docs.ts +95 -0
- package/front_end/ui/components/text_editor/AiCodeCompletionProvider.ts +246 -13
- package/front_end/ui/components/text_editor/config.ts +1 -1
- package/front_end/ui/legacy/Widget.ts +13 -4
- package/front_end/ui/legacy/components/utils/Linkifier.ts +45 -1
- package/front_end/ui/visual_logging/KnownContextValues.ts +11 -0
- package/package.json +1 -1
- package/front_end/models/issues_manager/UserReidentificationIssue.ts +0 -72
- package/front_end/models/issues_manager/descriptions/userReidentificationBlocked.md +0 -5
- package/front_end/panels/security/IPProtectionTreeElement.ts +0 -21
- package/front_end/panels/security/IPProtectionView.ts +0 -287
- package/front_end/ui/components/docs/expandable_list/basic.html +0 -24
- package/front_end/ui/components/docs/expandable_list/basic.ts +0 -30
- package/front_end/ui/components/docs/markdown_image/basic.html +0 -19
- package/front_end/ui/components/docs/markdown_image/basic.ts +0 -38
- package/front_end/ui/components/docs/markdown_link/basic.html +0 -17
- package/front_end/ui/components/docs/markdown_link/basic.ts +0 -19
- package/front_end/ui/components/docs/markdown_view/basic.html +0 -25
- package/front_end/ui/components/docs/markdown_view/basic.ts +0 -67
- package/front_end/ui/components/docs/markdown_view/code-block.html +0 -30
- package/front_end/ui/components/docs/markdown_view/code-block.ts +0 -71
- package/front_end/ui/components/docs/text_prompt/basic.html +0 -35
- package/front_end/ui/components/docs/text_prompt/basic.ts +0 -19
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
import * as Common from '../../core/common/common.js';
|
|
6
6
|
import * as Host from '../../core/host/host.js';
|
|
7
7
|
import * as Root from '../../core/root/root.js';
|
|
8
|
-
import * as TextEditor from '../../ui/components/text_editor/text_editor.js';
|
|
9
8
|
|
|
10
9
|
import {debugLog} from './debug.js';
|
|
11
10
|
|
|
@@ -32,6 +31,20 @@ interface CachedRequest {
|
|
|
32
31
|
response: Host.AidaClient.CompletionResponse;
|
|
33
32
|
}
|
|
34
33
|
|
|
34
|
+
export interface Callbacks {
|
|
35
|
+
getSelectionHead: () => number;
|
|
36
|
+
getCompletionHint: () => string | undefined | null;
|
|
37
|
+
setAiAutoCompletion: (args: {
|
|
38
|
+
text: string,
|
|
39
|
+
from: number,
|
|
40
|
+
startTime: number,
|
|
41
|
+
onImpression: (rpcGlobalId: Host.AidaClient.RpcGlobalId, latency: number, sampleId?: number) => void,
|
|
42
|
+
clearCachedRequest: () => void,
|
|
43
|
+
rpcGlobalId?: Host.AidaClient.RpcGlobalId,
|
|
44
|
+
sampleId?: number,
|
|
45
|
+
}|null) => void;
|
|
46
|
+
}
|
|
47
|
+
|
|
35
48
|
/* clang-format off */
|
|
36
49
|
const consoleAdditionalContextFileContent = `/**
|
|
37
50
|
* This file describes the execution environment of the Chrome DevTools Console.
|
|
@@ -141,24 +154,24 @@ const console = {
|
|
|
141
154
|
* the suggestion is displayed.
|
|
142
155
|
*/
|
|
143
156
|
export class AiCodeCompletion extends Common.ObjectWrapper.ObjectWrapper<EventTypes> {
|
|
144
|
-
#editor: TextEditor.TextEditor.TextEditor;
|
|
145
157
|
#stopSequences: string[];
|
|
146
158
|
#renderingTimeout?: number;
|
|
147
159
|
#aidaRequestCache?: CachedRequest;
|
|
160
|
+
// TODO(b/445394511): Remove panel from the class
|
|
148
161
|
#panel: ContextFlavor;
|
|
162
|
+
#callbacks?: Callbacks;
|
|
149
163
|
|
|
150
164
|
readonly #sessionId: string = crypto.randomUUID();
|
|
151
165
|
readonly #aidaClient: Host.AidaClient.AidaClient;
|
|
152
166
|
readonly #serverSideLoggingEnabled: boolean;
|
|
153
167
|
|
|
154
|
-
constructor(
|
|
155
|
-
opts: AgentOptions, editor: TextEditor.TextEditor.TextEditor, panel: ContextFlavor, stopSequences?: string[]) {
|
|
168
|
+
constructor(opts: AgentOptions, panel: ContextFlavor, callbacks?: Callbacks, stopSequences?: string[]) {
|
|
156
169
|
super();
|
|
157
170
|
this.#aidaClient = opts.aidaClient;
|
|
158
171
|
this.#serverSideLoggingEnabled = opts.serverSideLoggingEnabled ?? false;
|
|
159
|
-
this.#editor = editor;
|
|
160
172
|
this.#panel = panel;
|
|
161
173
|
this.#stopSequences = stopSequences ?? [];
|
|
174
|
+
this.#callbacks = callbacks;
|
|
162
175
|
}
|
|
163
176
|
|
|
164
177
|
#debouncedRequestAidaSuggestion = Common.Debouncer.debounce(
|
|
@@ -171,8 +184,8 @@ export class AiCodeCompletion extends Common.ObjectWrapper.ObjectWrapper<EventTy
|
|
|
171
184
|
|
|
172
185
|
#buildRequest(
|
|
173
186
|
prefix: string, suffix: string,
|
|
174
|
-
inferenceLanguage: Host.AidaClient.AidaInferenceLanguage = Host.AidaClient.AidaInferenceLanguage.JAVASCRIPT
|
|
175
|
-
Host.AidaClient.CompletionRequest {
|
|
187
|
+
inferenceLanguage: Host.AidaClient.AidaInferenceLanguage = Host.AidaClient.AidaInferenceLanguage.JAVASCRIPT,
|
|
188
|
+
additionalFiles?: Host.AidaClient.AdditionalFile[]): Host.AidaClient.CompletionRequest {
|
|
176
189
|
const userTier = Host.AidaClient.convertToUserTierEnum(this.#userTier);
|
|
177
190
|
function validTemperature(temperature: number|undefined): number|undefined {
|
|
178
191
|
return typeof temperature === 'number' && temperature >= 0 ? temperature : undefined;
|
|
@@ -180,13 +193,15 @@ export class AiCodeCompletion extends Common.ObjectWrapper.ObjectWrapper<EventTy
|
|
|
180
193
|
// As a temporary fix for b/441221870 we are prepending a newline for each prefix.
|
|
181
194
|
prefix = '\n' + prefix;
|
|
182
195
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
196
|
+
let additionalContextFiles = additionalFiles ?? undefined;
|
|
197
|
+
if (!additionalContextFiles) {
|
|
198
|
+
additionalContextFiles = this.#panel === ContextFlavor.CONSOLE ? [{
|
|
199
|
+
path: 'devtools-console-context.js',
|
|
200
|
+
content: consoleAdditionalContextFileContent,
|
|
201
|
+
included_reason: Host.AidaClient.Reason.RELATED_FILE,
|
|
202
|
+
}] :
|
|
203
|
+
undefined;
|
|
204
|
+
}
|
|
190
205
|
return {
|
|
191
206
|
client: Host.AidaClient.CLIENT_NAME,
|
|
192
207
|
prefix,
|
|
@@ -203,7 +218,7 @@ export class AiCodeCompletion extends Common.ObjectWrapper.ObjectWrapper<EventTy
|
|
|
203
218
|
user_tier: userTier,
|
|
204
219
|
client_version: Root.Runtime.getChromeVersion(),
|
|
205
220
|
},
|
|
206
|
-
additional_files:
|
|
221
|
+
additional_files: additionalContextFiles,
|
|
207
222
|
};
|
|
208
223
|
}
|
|
209
224
|
|
|
@@ -239,7 +254,7 @@ export class AiCodeCompletion extends Common.ObjectWrapper.ObjectWrapper<EventTy
|
|
|
239
254
|
// `currentHint` is the portion of a standard autocomplete suggestion that the user has not yet typed.
|
|
240
255
|
// For example, if the user types `document.queryS` and the autocomplete suggests `document.querySelector`,
|
|
241
256
|
// the `currentHint` is `elector`.
|
|
242
|
-
const currentHintInMenu = this.#
|
|
257
|
+
const currentHintInMenu = this.#callbacks?.getCompletionHint();
|
|
243
258
|
// TODO(ergunsh): We should not do this check here. Instead, the AI code suggestions should be provided
|
|
244
259
|
// as it is to the view plugin. The view plugin should choose which one to use based on the completion hint
|
|
245
260
|
// and selected completion.
|
|
@@ -321,21 +336,19 @@ export class AiCodeCompletion extends Common.ObjectWrapper.ObjectWrapper<EventTy
|
|
|
321
336
|
} = sampleResponse;
|
|
322
337
|
const remainingDelay = Math.max(DELAY_BEFORE_SHOWING_RESPONSE_MS - (performance.now() - startTime), 0);
|
|
323
338
|
this.#renderingTimeout = window.setTimeout(() => {
|
|
324
|
-
const currentCursorPosition = this.#
|
|
339
|
+
const currentCursorPosition = this.#callbacks?.getSelectionHead();
|
|
325
340
|
if (currentCursorPosition !== cursorPositionAtRequest) {
|
|
326
341
|
this.dispatchEventToListeners(Events.RESPONSE_RECEIVED, {});
|
|
327
342
|
return;
|
|
328
343
|
}
|
|
329
|
-
this.#
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
clearCachedRequest: this.clearCachedRequest.bind(this),
|
|
338
|
-
})
|
|
344
|
+
this.#callbacks?.setAiAutoCompletion({
|
|
345
|
+
text: suggestionText,
|
|
346
|
+
from: cursorPositionAtRequest,
|
|
347
|
+
rpcGlobalId,
|
|
348
|
+
sampleId,
|
|
349
|
+
startTime,
|
|
350
|
+
onImpression: this.registerUserImpression.bind(this),
|
|
351
|
+
clearCachedRequest: this.clearCachedRequest.bind(this),
|
|
339
352
|
});
|
|
340
353
|
|
|
341
354
|
if (fromCache) {
|
|
@@ -417,7 +430,7 @@ export class AiCodeCompletion extends Common.ObjectWrapper.ObjectWrapper<EventTy
|
|
|
417
430
|
this.#aidaRequestCache = {request, response};
|
|
418
431
|
}
|
|
419
432
|
|
|
420
|
-
|
|
433
|
+
registerUserImpression(rpcGlobalId: Host.AidaClient.RpcGlobalId, latency: number, sampleId?: number): void {
|
|
421
434
|
const seconds = Math.floor(latency / 1_000);
|
|
422
435
|
const remainingMs = latency % 1_000;
|
|
423
436
|
const nanos = Math.floor(remainingMs * 1_000_000);
|
|
@@ -469,14 +482,42 @@ export class AiCodeCompletion extends Common.ObjectWrapper.ObjectWrapper<EventTy
|
|
|
469
482
|
this.#debouncedRequestAidaSuggestion(prefix, suffix, cursorPositionAtRequest, inferenceLanguage);
|
|
470
483
|
}
|
|
471
484
|
|
|
485
|
+
async completeCode(
|
|
486
|
+
prefix: string, suffix: string, cursorPositionAtRequest: number,
|
|
487
|
+
inferenceLanguage?: Host.AidaClient.AidaInferenceLanguage,
|
|
488
|
+
additionalFiles?: Host.AidaClient.AdditionalFile[]): Promise<{
|
|
489
|
+
response: Host.AidaClient.CompletionResponse | null,
|
|
490
|
+
fromCache: boolean,
|
|
491
|
+
}> {
|
|
492
|
+
const request = this.#buildRequest(prefix, suffix, inferenceLanguage, additionalFiles);
|
|
493
|
+
const {response, fromCache} = await this.#completeCodeCached(request);
|
|
494
|
+
|
|
495
|
+
debugLog('At cursor position', cursorPositionAtRequest, {request, response, fromCache});
|
|
496
|
+
if (!response) {
|
|
497
|
+
return {response: null, fromCache: false};
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
return {response, fromCache};
|
|
501
|
+
}
|
|
502
|
+
|
|
472
503
|
remove(): void {
|
|
473
504
|
if (this.#renderingTimeout) {
|
|
474
505
|
clearTimeout(this.#renderingTimeout);
|
|
475
506
|
this.#renderingTimeout = undefined;
|
|
476
507
|
}
|
|
477
|
-
this.#
|
|
478
|
-
|
|
479
|
-
|
|
508
|
+
this.#callbacks?.setAiAutoCompletion(null);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
static isAiCodeCompletionEnabled(locale: string): boolean {
|
|
512
|
+
if (!locale.startsWith('en-')) {
|
|
513
|
+
return false;
|
|
514
|
+
}
|
|
515
|
+
const aidaAvailability = Root.Runtime.hostConfig.aidaAvailability;
|
|
516
|
+
if (!aidaAvailability || aidaAvailability.blockedByGeo || aidaAvailability.blockedByAge ||
|
|
517
|
+
aidaAvailability.blockedByEnterprisePolicy) {
|
|
518
|
+
return false;
|
|
519
|
+
}
|
|
520
|
+
return Boolean(aidaAvailability.enabled && Root.Runtime.hostConfig.devToolsAiCodeCompletion?.enabled);
|
|
480
521
|
}
|
|
481
522
|
}
|
|
482
523
|
|
|
@@ -45,6 +45,7 @@ export class CompilerScriptMapping implements DebuggerSourceMapping {
|
|
|
45
45
|
readonly #uiSourceCodeToSourceMaps =
|
|
46
46
|
new Platform.MapUtilities.Multimap<Workspace.UISourceCode.UISourceCode, SDK.SourceMap.SourceMap>();
|
|
47
47
|
readonly #debuggerModel: SDK.DebuggerModel.DebuggerModel;
|
|
48
|
+
readonly #ignoreListManager: Workspace.IgnoreListManager.IgnoreListManager;
|
|
48
49
|
|
|
49
50
|
constructor(
|
|
50
51
|
debuggerModel: SDK.DebuggerModel.DebuggerModel, workspace: Workspace.Workspace.WorkspaceImpl,
|
|
@@ -52,6 +53,7 @@ export class CompilerScriptMapping implements DebuggerSourceMapping {
|
|
|
52
53
|
this.#sourceMapManager = debuggerModel.sourceMapManager();
|
|
53
54
|
this.#debuggerWorkspaceBinding = debuggerWorkspaceBinding;
|
|
54
55
|
this.#debuggerModel = debuggerModel;
|
|
56
|
+
this.#ignoreListManager = debuggerWorkspaceBinding.ignoreListManager;
|
|
55
57
|
|
|
56
58
|
this.#stubProject = new ContentProviderBasedProject(
|
|
57
59
|
workspace, 'jsSourceMaps:stub:' + debuggerModel.target().id(), Workspace.Workspace.projectTypes.Service, '',
|
|
@@ -362,8 +364,7 @@ export class CompilerScriptMapping implements DebuggerSourceMapping {
|
|
|
362
364
|
// Create stub UISourceCode for the time source mapping is being loaded.
|
|
363
365
|
this.addStubUISourceCode(script);
|
|
364
366
|
void this.#debuggerWorkspaceBinding.updateLocations(script);
|
|
365
|
-
if (
|
|
366
|
-
script.sourceURL, {isContentScript: script.isContentScript()})) {
|
|
367
|
+
if (this.#ignoreListManager.isUserIgnoreListedURL(script.sourceURL, {isContentScript: script.isContentScript()})) {
|
|
367
368
|
this.#sourceMapManager.cancelAttachSourceMap(script);
|
|
368
369
|
}
|
|
369
370
|
}
|
|
@@ -27,11 +27,13 @@ export class DebuggerWorkspaceBinding implements SDK.TargetManager.SDKModelObser
|
|
|
27
27
|
readonly #debuggerModelToData: Map<SDK.DebuggerModel.DebuggerModel, ModelData>;
|
|
28
28
|
readonly #liveLocationPromises: Set<Promise<void|Location|StackTraceTopFrameLocation|null>>;
|
|
29
29
|
readonly pluginManager: DebuggerLanguagePluginManager;
|
|
30
|
+
readonly ignoreListManager: Workspace.IgnoreListManager.IgnoreListManager;
|
|
30
31
|
|
|
31
32
|
private constructor(
|
|
32
33
|
resourceMapping: ResourceMapping, targetManager: SDK.TargetManager.TargetManager,
|
|
33
34
|
ignoreListManager: Workspace.IgnoreListManager.IgnoreListManager) {
|
|
34
35
|
this.resourceMapping = resourceMapping;
|
|
36
|
+
this.ignoreListManager = ignoreListManager;
|
|
35
37
|
|
|
36
38
|
this.#debuggerModelToData = new Map();
|
|
37
39
|
targetManager.addModelListener(
|
|
@@ -39,7 +41,7 @@ export class DebuggerWorkspaceBinding implements SDK.TargetManager.SDKModelObser
|
|
|
39
41
|
targetManager.addModelListener(
|
|
40
42
|
SDK.DebuggerModel.DebuggerModel, SDK.DebuggerModel.Events.DebuggerResumed, this.debuggerResumed, this);
|
|
41
43
|
targetManager.observeModels(SDK.DebuggerModel.DebuggerModel, this);
|
|
42
|
-
ignoreListManager.addEventListener(
|
|
44
|
+
this.ignoreListManager.addEventListener(
|
|
43
45
|
Workspace.IgnoreListManager.Events.IGNORED_SCRIPT_RANGES_UPDATED, event => this.updateLocations(event.data));
|
|
44
46
|
|
|
45
47
|
this.#liveLocationPromises = new Set();
|
|
@@ -137,6 +137,20 @@ export class Importer {
|
|
|
137
137
|
async () =>
|
|
138
138
|
new TextUtils.ContentData.ContentData(contentText ?? '', isBase64, mimeType ?? '', charset ?? undefined));
|
|
139
139
|
|
|
140
|
+
if (request.mimeType === Platform.MimeType.MimeType.EVENTSTREAM && contentText) {
|
|
141
|
+
const issueTime = entry.startedDateTime.getTime() / 1000;
|
|
142
|
+
const onEvent = (eventName: string, data: string, eventId: string): void => {
|
|
143
|
+
request.addEventSourceMessage(issueTime, eventName, eventId, data);
|
|
144
|
+
};
|
|
145
|
+
const parser = new SDK.ServerSentEventProtocol.ServerSentEventsParser(onEvent, charset ?? undefined);
|
|
146
|
+
let text = contentText;
|
|
147
|
+
if (isBase64) {
|
|
148
|
+
const bytes = Common.Base64.decode(contentText);
|
|
149
|
+
text = new TextDecoder(charset ?? undefined).decode(bytes);
|
|
150
|
+
}
|
|
151
|
+
parser.addTextChunk(text);
|
|
152
|
+
}
|
|
153
|
+
|
|
140
154
|
// Timing data.
|
|
141
155
|
Importer.setupTiming(request, issueTime, entry.time, entry.timings);
|
|
142
156
|
|
|
@@ -33,7 +33,6 @@ import {SourceFrameIssuesManager} from './SourceFrameIssuesManager.js';
|
|
|
33
33
|
import {SRIMessageSignatureIssue} from './SRIMessageSignatureIssue.js';
|
|
34
34
|
import {StylesheetLoadingIssue} from './StylesheetLoadingIssue.js';
|
|
35
35
|
import {UnencodedDigestIssue} from './UnencodedDigestIssue.js';
|
|
36
|
-
import {UserReidentificationIssue} from './UserReidentificationIssue.js';
|
|
37
36
|
|
|
38
37
|
export {Events} from './IssuesManagerEvents.js';
|
|
39
38
|
|
|
@@ -145,10 +144,6 @@ const issueCodeHandlers = new Map<
|
|
|
145
144
|
Protocol.Audits.InspectorIssueCode.UnencodedDigestIssue,
|
|
146
145
|
UnencodedDigestIssue.fromInspectorIssue,
|
|
147
146
|
],
|
|
148
|
-
[
|
|
149
|
-
Protocol.Audits.InspectorIssueCode.UserReidentificationIssue,
|
|
150
|
-
UserReidentificationIssue.fromInspectorIssue,
|
|
151
|
-
],
|
|
152
147
|
]);
|
|
153
148
|
|
|
154
149
|
/**
|
|
@@ -7617,10 +7617,6 @@ export const NativeFunctions = [
|
|
|
7617
7617
|
name: "drawElementImage",
|
|
7618
7618
|
signatures: [["element","x","y","?dwidth","?dheight"]]
|
|
7619
7619
|
},
|
|
7620
|
-
{
|
|
7621
|
-
name: "setHitTestRegions",
|
|
7622
|
-
signatures: [["hitTestRegions"]]
|
|
7623
|
-
},
|
|
7624
7620
|
{
|
|
7625
7621
|
name: "Path2D",
|
|
7626
7622
|
signatures: [["?path"]]
|
|
@@ -44,6 +44,7 @@ type GeneratedFileSizes = {
|
|
|
44
44
|
}|{files: Record<string, number>, unmappedBytes: number, totalBytes: number};
|
|
45
45
|
|
|
46
46
|
let scriptById = new Map<string, Script>();
|
|
47
|
+
let frameIdByIsolate = new Map<string, string>();
|
|
47
48
|
|
|
48
49
|
export function deps(): HandlerName[] {
|
|
49
50
|
return ['Meta', 'NetworkRequests'];
|
|
@@ -51,6 +52,7 @@ export function deps(): HandlerName[] {
|
|
|
51
52
|
|
|
52
53
|
export function reset(): void {
|
|
53
54
|
scriptById = new Map();
|
|
55
|
+
frameIdByIsolate = new Map();
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
export function handleEvent(event: Types.Events.Event): void {
|
|
@@ -73,6 +75,9 @@ export function handleEvent(event: Types.Events.Event): void {
|
|
|
73
75
|
if (Types.Events.isRundownScript(event)) {
|
|
74
76
|
const {isolate, scriptId, url, sourceUrl, sourceMapUrl, sourceMapUrlElided} = event.args.data;
|
|
75
77
|
const script = getOrMakeScript(isolate, scriptId);
|
|
78
|
+
if (!script.frame) {
|
|
79
|
+
script.frame = frameIdByIsolate.get(String(isolate)) ?? '';
|
|
80
|
+
}
|
|
76
81
|
script.url = url;
|
|
77
82
|
script.ts = event.ts;
|
|
78
83
|
if (sourceUrl) {
|
|
@@ -105,6 +110,27 @@ export function handleEvent(event: Types.Events.Event): void {
|
|
|
105
110
|
script.content = (script.content ?? '') + sourceText;
|
|
106
111
|
return;
|
|
107
112
|
}
|
|
113
|
+
|
|
114
|
+
// Setup frameIdByIsolate, which is used only in the case that we are missing
|
|
115
|
+
// rundown events for a script. We won't get a frame association from the rundown
|
|
116
|
+
// events if the recording started only after the script was first compiled. In
|
|
117
|
+
// that scenario, derive the frame via the isolate / FunctionCall events.
|
|
118
|
+
// TODO: ideally, we put the frame on ScriptCatchup event. So much easier. This approach has some
|
|
119
|
+
// issues.
|
|
120
|
+
if (Types.Events.isFunctionCall(event) && event.args.data?.isolate && event.args.data.frame) {
|
|
121
|
+
const {isolate, frame} = event.args.data;
|
|
122
|
+
const existingValue = frameIdByIsolate.get(isolate);
|
|
123
|
+
if (existingValue !== frame) {
|
|
124
|
+
frameIdByIsolate.set(isolate, frame);
|
|
125
|
+
|
|
126
|
+
// Update the scripts we discovered but without knowing their frame.
|
|
127
|
+
for (const script of scriptById.values()) {
|
|
128
|
+
if (!script.frame && script.isolate === isolate) {
|
|
129
|
+
script.frame = frame;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
108
134
|
}
|
|
109
135
|
|
|
110
136
|
function findFrame(meta: MetaHandlerData, frameId: string): Types.Events.TraceFrame|null {
|