chrome-devtools-mcp 0.2.0 → 0.2.2

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.
Files changed (62) hide show
  1. package/README.md +27 -8
  2. package/build/node_modules/chrome-devtools-frontend/front_end/core/common/Progress.js +60 -53
  3. package/build/node_modules/chrome-devtools-frontend/front_end/core/host/GdpClient.js +1 -1
  4. package/build/node_modules/chrome-devtools-frontend/front_end/core/host/UserMetrics.js +5 -2
  5. package/build/node_modules/chrome-devtools-frontend/front_end/core/protocol_client/InspectorBackend.js +2 -0
  6. package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/CSSMatchedStyles.js +11 -10
  7. package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/CSSModel.js +1 -1
  8. package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/CSSPropertyParserMatchers.js +24 -4
  9. package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/DebuggerModel.js +1 -1
  10. package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/EnhancedTracesParser.js +29 -24
  11. package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/NetworkManager.js +1 -1
  12. package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/NetworkRequest.js +1 -1
  13. package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/RehydratingConnection.js +9 -15
  14. package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/RemoteObject.js +1 -1
  15. package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/ResourceTreeModel.js +1 -1
  16. package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/RuntimeModel.js +1 -1
  17. package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/ServiceWorkerManager.js +1 -1
  18. package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/SourceMap.js +4 -31
  19. package/build/node_modules/chrome-devtools-frontend/front_end/core/sdk/TraceObject.js +5 -2
  20. package/build/node_modules/chrome-devtools-frontend/front_end/models/ai_assistance/data_formatters/NetworkRequestFormatter.js +6 -4
  21. package/build/node_modules/chrome-devtools-frontend/front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.js +259 -179
  22. package/build/node_modules/chrome-devtools-frontend/front_end/models/ai_assistance/data_formatters/UnitFormatters.js +10 -1
  23. package/build/node_modules/chrome-devtools-frontend/front_end/models/ai_assistance/performance/AIContext.js +14 -3
  24. package/build/node_modules/chrome-devtools-frontend/front_end/models/bindings/ContentProviderBasedProject.js +6 -4
  25. package/build/node_modules/chrome-devtools-frontend/front_end/models/formatter/FormatterWorkerPool.js +2 -2
  26. package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/ModelImpl.js +4 -9
  27. package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/Processor.js +17 -9
  28. package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/handlers/AuctionWorkletsHandler.js +1 -1
  29. package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/handlers/FramesHandler.js +2 -2
  30. package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/handlers/LayoutShiftsHandler.js +3 -4
  31. package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/handlers/MetaHandler.js +10 -9
  32. package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/handlers/ScreenshotsHandler.js +0 -1
  33. package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/handlers/ScriptsHandler.js +4 -4
  34. package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/handlers/UserInteractionsHandler.js +2 -10
  35. package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/handlers/UserTimingsHandler.js +3 -4
  36. package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/helpers/SamplesIntegrator.js +8 -6
  37. package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/insights/CLSCulprits.js +1 -1
  38. package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/insights/DocumentLatency.js +3 -3
  39. package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/insights/DuplicatedJavaScript.js +1 -1
  40. package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/insights/INPBreakdown.js +1 -1
  41. package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/insights/ImageDelivery.js +1 -1
  42. package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/insights/LCPBreakdown.js +1 -1
  43. package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/insights/LCPDiscovery.js +1 -1
  44. package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/insights/ModernHTTP.js +1 -1
  45. package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/insights/NetworkDependencyTree.js +1 -1
  46. package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/insights/RenderBlocking.js +1 -1
  47. package/build/node_modules/chrome-devtools-frontend/front_end/models/trace/types/TraceEvents.js +21 -21
  48. package/build/node_modules/chrome-devtools-frontend/front_end/models/trace_source_maps_resolver/SourceMapsResolver.js +5 -3
  49. package/build/node_modules/chrome-devtools-frontend/front_end/models/trace_source_maps_resolver/trace_source_maps_resolver.js +1 -1
  50. package/build/src/McpContext.js +60 -10
  51. package/build/src/McpResponse.js +5 -4
  52. package/build/src/WaitForHelper.js +127 -0
  53. package/build/src/browser.js +12 -9
  54. package/build/src/index.js +20 -21
  55. package/build/src/logger.js +1 -0
  56. package/build/src/tools/input.js +5 -6
  57. package/build/src/tools/pages.js +2 -3
  58. package/build/src/tools/performance.js +16 -14
  59. package/build/src/tools/script.js +1 -2
  60. package/build/src/trace-processing/parse.js +23 -14
  61. package/package.json +15 -16
  62. package/build/src/waitForHelpers.js +0 -109
@@ -1,6 +1,7 @@
1
1
  // Copyright 2023 The Chromium Authors
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
+ var _a;
4
5
  import * as Handlers from './handlers/handlers.js';
5
6
  import * as Helpers from './helpers/helpers.js';
6
7
  import * as Insights from './insights/insights.js';
@@ -31,7 +32,7 @@ export class TraceProcessor extends EventTarget {
31
32
  #data = null;
32
33
  #insights = null;
33
34
  static createWithAllHandlers() {
34
- return new TraceProcessor(Handlers.ModelHandlers, Types.Configuration.defaults());
35
+ return new _a(Handlers.ModelHandlers, Types.Configuration.defaults());
35
36
  }
36
37
  /**
37
38
  * This function is kept for testing with `stub`.
@@ -111,6 +112,9 @@ export class TraceProcessor extends EventTarget {
111
112
  if (this.#status !== "IDLE" /* Status.IDLE */) {
112
113
  throw new Error(`Trace processor can't start parsing when not idle. Current state: ${this.#status}`);
113
114
  }
115
+ if (typeof options.isCPUProfile === 'undefined' && options.metadata) {
116
+ options.isCPUProfile = options.metadata.dataOrigin === "CPUProfile" /* Types.File.DataOrigin.CPU_PROFILE */;
117
+ }
114
118
  options.logger?.start('total');
115
119
  try {
116
120
  this.#status = "PARSING" /* Status.PARSING */;
@@ -345,7 +349,8 @@ export class TraceProcessor extends EventTarget {
345
349
  }
346
350
  insightSet.model = newModel;
347
351
  }
348
- #computeInsightSet(data, context, options) {
352
+ #computeInsightSet(data, context) {
353
+ const logger = context.options.logger;
349
354
  let id, urlString, navigation;
350
355
  if (context.navigation) {
351
356
  id = context.navigationId;
@@ -357,11 +362,11 @@ export class TraceProcessor extends EventTarget {
357
362
  urlString = data.Meta.finalDisplayUrlByNavigationId.get('') ?? data.Meta.mainFrameURL;
358
363
  }
359
364
  const insightSetModel = {};
360
- for (const [name, insight] of Object.entries(TraceProcessor.getInsightRunners())) {
365
+ for (const [name, insight] of Object.entries(_a.getInsightRunners())) {
361
366
  let model;
362
367
  try {
363
- options.logger?.start(`insights:${name}`);
364
- model = insight.generateInsight(data, context, options.insightTimeFormatters);
368
+ logger?.start(`insights:${name}`);
369
+ model = insight.generateInsight(data, context);
365
370
  model.frameId = context.frameId;
366
371
  const navId = context.navigation?.args.data?.navigationId;
367
372
  if (navId) {
@@ -376,7 +381,7 @@ export class TraceProcessor extends EventTarget {
376
381
  model = err;
377
382
  }
378
383
  finally {
379
- options.logger?.end(`insights:${name}`);
384
+ logger?.end(`insights:${name}`);
380
385
  }
381
386
  Object.assign(insightSetModel, { [name]: model });
382
387
  }
@@ -420,7 +425,7 @@ export class TraceProcessor extends EventTarget {
420
425
  this.#insights = new Map();
421
426
  }
422
427
  this.#insights.set(insightSet.id, insightSet);
423
- this.sortInsightSet(insightSet, options.metadata ?? null);
428
+ this.sortInsightSet(insightSet, context.options.metadata ?? null);
424
429
  }
425
430
  /**
426
431
  * Run all the insights and set the result to `#insights`.
@@ -449,11 +454,12 @@ export class TraceProcessor extends EventTarget {
449
454
  Helpers.Timing.traceWindowFromMicroSeconds(data.Meta.traceBounds.min, navigations[0].ts) :
450
455
  data.Meta.traceBounds;
451
456
  const context = {
457
+ options,
452
458
  bounds,
453
459
  frameId: data.Meta.mainFrameId,
454
460
  // No navigation or lantern context applies to this initial/no-navigation period.
455
461
  };
456
- this.#computeInsightSet(data, context, options);
462
+ this.#computeInsightSet(data, context);
457
463
  }
458
464
  /**
459
465
  * Computes insights for a specific navigation event.
@@ -497,15 +503,17 @@ export class TraceProcessor extends EventTarget {
497
503
  options.logger?.end('insights:createLanternContext');
498
504
  }
499
505
  const context = {
506
+ options,
500
507
  bounds,
501
508
  frameId,
502
509
  navigation,
503
510
  navigationId,
504
511
  lantern,
505
512
  };
506
- this.#computeInsightSet(data, context, options);
513
+ this.#computeInsightSet(data, context);
507
514
  }
508
515
  }
516
+ _a = TraceProcessor;
509
517
  /**
510
518
  * Some Handlers need data provided by others. Dependencies of a handler handler are
511
519
  * declared in the `deps` field.
@@ -157,6 +157,6 @@ export async function finalize() {
157
157
  }
158
158
  export function data() {
159
159
  return {
160
- worklets: new Map(createdSyntheticEvents),
160
+ worklets: createdSyntheticEvents,
161
161
  };
162
162
  }
@@ -67,8 +67,8 @@ export async function finalize() {
67
67
  }
68
68
  export function data() {
69
69
  return {
70
- frames: model ? Array.from(model.frames()) : [],
71
- framesById: model ? { ...model.framesById() } : {},
70
+ frames: model?.frames() ?? [],
71
+ framesById: model?.framesById() ?? {},
72
72
  };
73
73
  }
74
74
  export function deps() {
@@ -419,15 +419,14 @@ export function data() {
419
419
  prePaintEvents,
420
420
  layoutInvalidationEvents,
421
421
  scheduleStyleInvalidationEvents,
422
- styleRecalcInvalidationEvents: [],
422
+ styleRecalcInvalidationEvents,
423
423
  renderFrameImplCreateChildFrameEvents,
424
424
  domLoadingEvents,
425
425
  layoutImageUnsizedEvents,
426
426
  remoteFonts,
427
427
  scoreRecords,
428
- // TODO(crbug/41484172): change the type so no need to clone
429
- backendNodeIds: [...backendNodeIds],
430
- clustersByNavigationId: new Map(clustersByNavigationId),
428
+ backendNodeIds,
429
+ clustersByNavigationId,
431
430
  paintImageEvents,
432
431
  };
433
432
  }
@@ -21,11 +21,14 @@ let viewportRect = null;
21
21
  let devicePixelRatio = null;
22
22
  let processNames = new Map();
23
23
  let topLevelRendererIds = new Set();
24
- const traceBounds = {
25
- min: Types.Timing.Micro(Number.POSITIVE_INFINITY),
26
- max: Types.Timing.Micro(Number.NEGATIVE_INFINITY),
27
- range: Types.Timing.Micro(Number.POSITIVE_INFINITY),
28
- };
24
+ function makeNewTraceBounds() {
25
+ return {
26
+ min: Types.Timing.Micro(Number.POSITIVE_INFINITY),
27
+ max: Types.Timing.Micro(Number.NEGATIVE_INFINITY),
28
+ range: Types.Timing.Micro(Number.POSITIVE_INFINITY),
29
+ };
30
+ }
31
+ let traceBounds = makeNewTraceBounds();
29
32
  /**
30
33
  * These represent the user navigating. Values such as First Contentful Paint,
31
34
  * etc, are relative to the navigation.
@@ -84,9 +87,7 @@ export function reset() {
84
87
  threadsInProcess = new Map();
85
88
  rendererProcessesByFrameId = new Map();
86
89
  framesByProcessId = new Map();
87
- traceBounds.min = Types.Timing.Micro(Number.POSITIVE_INFINITY);
88
- traceBounds.max = Types.Timing.Micro(Number.NEGATIVE_INFINITY);
89
- traceBounds.range = Types.Timing.Micro(Number.POSITIVE_INFINITY);
90
+ traceBounds = makeNewTraceBounds();
90
91
  traceStartedTimeFromTracingStartedEvent = Types.Timing.Micro(-1);
91
92
  traceIsGeneric = true;
92
93
  }
@@ -377,7 +378,7 @@ export async function finalize() {
377
378
  }
378
379
  export function data() {
379
380
  return {
380
- traceBounds: { ...traceBounds },
381
+ traceBounds,
381
382
  browserProcessId,
382
383
  browserThreadId,
383
384
  processNames,
@@ -86,7 +86,6 @@ function getPresentationTimestamp(screenshotEvent) {
86
86
  // The last one is sometimes missing as because the trace terminates right before the associated PipelineReporter is emitted.
87
87
  return updatedTs ?? screenshotEvent.ts;
88
88
  }
89
- // TODO(crbug/41484172): should be readonly
90
89
  export function data() {
91
90
  return {
92
91
  legacySyntheticScreenshots: syntheticScreenshots.length ? syntheticScreenshots : null,
@@ -19,14 +19,14 @@ export function handleEvent(event) {
19
19
  const key = `${isolate}.${scriptId}`;
20
20
  return Platform.MapUtilities.getWithDefault(scriptById, key, () => ({ isolate, scriptId, frame: '', ts: 0 }));
21
21
  };
22
- if (Types.Events.isTargetRundownEvent(event) && event.args.data) {
22
+ if (Types.Events.isRundownScriptCompiled(event) && event.args.data) {
23
23
  const { isolate, scriptId, frame } = event.args.data;
24
24
  const script = getOrMakeScript(isolate, scriptId);
25
25
  script.frame = frame;
26
26
  script.ts = event.ts;
27
27
  return;
28
28
  }
29
- if (Types.Events.isV8SourceRundownEvent(event)) {
29
+ if (Types.Events.isRundownScript(event)) {
30
30
  const { isolate, scriptId, url, sourceUrl, sourceMapUrl, sourceMapUrlElided } = event.args.data;
31
31
  const script = getOrMakeScript(isolate, scriptId);
32
32
  script.url = url;
@@ -46,13 +46,13 @@ export function handleEvent(event) {
46
46
  }
47
47
  return;
48
48
  }
49
- if (Types.Events.isV8SourceRundownSourcesScriptCatchupEvent(event)) {
49
+ if (Types.Events.isRundownScriptSource(event)) {
50
50
  const { isolate, scriptId, sourceText } = event.args.data;
51
51
  const script = getOrMakeScript(isolate, scriptId);
52
52
  script.content = sourceText;
53
53
  return;
54
54
  }
55
- if (Types.Events.isV8SourceRundownSourcesLargeScriptCatchupEvent(event)) {
55
+ if (Types.Events.isRundownScriptSourceLarge(event)) {
56
56
  const { isolate, scriptId, sourceText } = event.args.data;
57
57
  const script = getOrMakeScript(isolate, scriptId);
58
58
  script.content = (script.content ?? '') + sourceText;
@@ -4,13 +4,8 @@
4
4
  import * as Helpers from '../helpers/helpers.js';
5
5
  import * as Types from '../types/types.js';
6
6
  import { data as metaHandlerData } from './MetaHandler.js';
7
- // This handler serves two purposes. It generates a list of events that are
8
- // used to show user clicks in the timeline. It is also used to gather
9
- // EventTimings into Interactions, which we use to show interactions and
10
- // highlight long interactions to the user, along with INP.
11
- // We don't need to know which process / thread these events occurred in,
12
- // because they are effectively global, so we just track all that we find.
13
- let allEvents = [];
7
+ // This handler gathers EventTimings into Interactions, which we use to show
8
+ // interactions and highlight long interactions to the user, along with INP.
14
9
  let beginCommitCompositorFrameEvents = [];
15
10
  let parseMetaViewportEvents = [];
16
11
  export const LONG_INTERACTION_THRESHOLD = Helpers.Timing.milliToMicro(Types.Timing.Milli(200));
@@ -22,7 +17,6 @@ let interactionEventsWithNoNesting = [];
22
17
  let eventTimingEndEventsById = new Map();
23
18
  let eventTimingStartEventsForInteractions = [];
24
19
  export function reset() {
25
- allEvents = [];
26
20
  beginCommitCompositorFrameEvents = [];
27
21
  parseMetaViewportEvents = [];
28
22
  interactionEvents = [];
@@ -47,7 +41,6 @@ export function handleEvent(event) {
47
41
  // Store the end event; for each start event that is an interaction, we need the matching end event to calculate the duration correctly.
48
42
  eventTimingEndEventsById.set(event.id, event);
49
43
  }
50
- allEvents.push(event);
51
44
  // From this point on we want to find events that represent interactions.
52
45
  // These events are always start events - those are the ones that contain all
53
46
  // the metadata about the interaction.
@@ -268,7 +261,6 @@ export async function finalize() {
268
261
  }
269
262
  export function data() {
270
263
  return {
271
- allEvents,
272
264
  beginCommitCompositorFrameEvents,
273
265
  parseMetaViewportEvents,
274
266
  interactionEvents,
@@ -176,9 +176,8 @@ export function data() {
176
176
  return {
177
177
  performanceMeasures: syntheticEvents.filter(e => e.cat === 'blink.user_timing'),
178
178
  consoleTimings: syntheticEvents.filter(e => e.cat === 'blink.console'),
179
- // TODO(crbug/41484172): UserTimingsHandler.test.ts fails if this is not copied.
180
- performanceMarks: [...performanceMarkEvents],
181
- timestampEvents: [...timestampEvents],
182
- measureTraceByTraceId: new Map(measureTraceByTraceId),
179
+ performanceMarks: performanceMarkEvents,
180
+ timestampEvents,
181
+ measureTraceByTraceId,
183
182
  };
184
183
  }
@@ -1,6 +1,7 @@
1
1
  // Copyright 2023 The Chromium Authors
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
+ var _a;
4
5
  import * as Types from '../types/types.js';
5
6
  import { milliToMicro } from './Timing.js';
6
7
  import { extractSampleTraceId, makeProfileCall, mergeEventsInOrder, sortTraceEventsInPlace } from './Trace.js';
@@ -310,7 +311,7 @@ export class SamplesIntegrator {
310
311
  if (maybeCallForTraceId) {
311
312
  stackTrace = maybeCallForTraceId;
312
313
  }
313
- SamplesIntegrator.filterStackFrames(stackTrace, this.#engineConfig);
314
+ _a.filterStackFrames(stackTrace, this.#engineConfig);
314
315
  const endTime = event.ts + (event.dur || 0);
315
316
  const minFrames = Math.min(stackTrace.length, this.#currentJSStack.length);
316
317
  let i;
@@ -332,7 +333,7 @@ export class SamplesIntegrator {
332
333
  for (i = this.#lockedJsStackDepth.at(-1) || 0; i < minFrames; ++i) {
333
334
  const newFrame = stackTrace[i].callFrame;
334
335
  const oldFrame = this.#currentJSStack[i].callFrame;
335
- if (!SamplesIntegrator.framesAreEqual(newFrame, oldFrame)) {
336
+ if (!_a.framesAreEqual(newFrame, oldFrame)) {
336
337
  break;
337
338
  }
338
339
  // Scoot the right edge of this callFrame to the right
@@ -418,7 +419,7 @@ export class SamplesIntegrator {
418
419
  frame1.lineNumber === frame2.lineNumber;
419
420
  }
420
421
  static showNativeName(name, runtimeCallStatsEnabled) {
421
- return runtimeCallStatsEnabled && Boolean(SamplesIntegrator.nativeGroup(name));
422
+ return runtimeCallStatsEnabled && Boolean(_a.nativeGroup(name));
422
423
  }
423
424
  static nativeGroup(nativeName) {
424
425
  if (nativeName.startsWith('Parse')) {
@@ -441,12 +442,12 @@ export class SamplesIntegrator {
441
442
  let j = 0;
442
443
  for (let i = 0; i < stack.length; ++i) {
443
444
  const frame = stack[i].callFrame;
444
- const nativeRuntimeFrame = SamplesIntegrator.isNativeRuntimeFrame(frame);
445
+ const nativeRuntimeFrame = _a.isNativeRuntimeFrame(frame);
445
446
  if (nativeRuntimeFrame &&
446
- !SamplesIntegrator.showNativeName(frame.functionName, engineConfig.includeRuntimeCallStats)) {
447
+ !_a.showNativeName(frame.functionName, engineConfig.includeRuntimeCallStats)) {
447
448
  continue;
448
449
  }
449
- const nativeFrameName = nativeRuntimeFrame ? SamplesIntegrator.nativeGroup(frame.functionName) : null;
450
+ const nativeFrameName = nativeRuntimeFrame ? _a.nativeGroup(frame.functionName) : null;
450
451
  if (previousNativeFrameName && previousNativeFrameName === nativeFrameName) {
451
452
  continue;
452
453
  }
@@ -491,3 +492,4 @@ export class SamplesIntegrator {
491
492
  return profile;
492
493
  }
493
494
  }
495
+ _a = SamplesIntegrator;
@@ -325,7 +325,7 @@ function getUnsizedImageRootCauses(unsizedImageEvents, paintImageEvents, shiftsB
325
325
  });
326
326
  return rootCausesByShift;
327
327
  }
328
- export function isCLSCulprits(insight) {
328
+ export function isCLSCulpritsInsight(insight) {
329
329
  return insight.insightKey === "CLSCulprits" /* InsightKeys.CLS_CULPRITS */;
330
330
  }
331
331
  /**
@@ -64,7 +64,7 @@ const TOO_SLOW_THRESHOLD_MS = 600;
64
64
  const TARGET_MS = 100;
65
65
  // Threshold for compression savings.
66
66
  const IGNORE_THRESHOLD_IN_BYTES = 1400;
67
- export function isDocumentLatency(x) {
67
+ export function isDocumentLatencyInsight(x) {
68
68
  return x.insightKey === 'DocumentLatency';
69
69
  }
70
70
  function getServerResponseTime(request, context) {
@@ -153,11 +153,11 @@ function finalize(partialModel) {
153
153
  ...partialModel,
154
154
  };
155
155
  }
156
- export function generateInsight(data, context, timeFormatters) {
156
+ export function generateInsight(data, context) {
157
157
  if (!context.navigation) {
158
158
  return finalize({});
159
159
  }
160
- const millisToString = timeFormatters?.milli ?? i18n.TimeUtilities.millisToString;
160
+ const millisToString = context.options.insightTimeFormatters?.milli ?? i18n.TimeUtilities.millisToString;
161
161
  const documentRequest = data.NetworkRequests.byId.get(context.navigationId);
162
162
  if (!documentRequest) {
163
163
  return finalize({ warnings: [InsightWarning.NO_DOCUMENT_REQUEST] });
@@ -35,7 +35,7 @@ function finalize(partialModel) {
35
35
  ...partialModel,
36
36
  };
37
37
  }
38
- export function isDuplicatedJavaScript(model) {
38
+ export function isDuplicatedJavaScriptInsight(model) {
39
39
  return model.insightKey === "DuplicatedJavaScript" /* InsightKeys.DUPLICATE_JAVASCRIPT */;
40
40
  }
41
41
  export function generateInsight(data, context) {
@@ -41,7 +41,7 @@ export const UIStrings = {
41
41
  };
42
42
  const str_ = i18n.i18n.registerUIStrings('models/trace/insights/INPBreakdown.ts', UIStrings);
43
43
  export const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
44
- export function isINPBreakdown(insight) {
44
+ export function isINPBreakdownInsight(insight) {
45
45
  return insight.insightKey === "INPBreakdown" /* InsightKeys.INP_BREAKDOWN */;
46
46
  }
47
47
  function finalize(partialModel) {
@@ -85,7 +85,7 @@ export var ImageOptimizationType;
85
85
  ImageOptimizationType["VIDEO_FORMAT"] = "VIDEO_FORMAT";
86
86
  ImageOptimizationType["RESPONSIVE_SIZE"] = "RESPONSIVE_SIZE";
87
87
  })(ImageOptimizationType || (ImageOptimizationType = {}));
88
- export function isImageDelivery(model) {
88
+ export function isImageDeliveryInsight(model) {
89
89
  return model.insightKey === 'ImageDelivery';
90
90
  }
91
91
  export function getOptimizationMessage(optimization) {
@@ -52,7 +52,7 @@ export const UIStrings = {
52
52
  };
53
53
  const str_ = i18n.i18n.registerUIStrings('models/trace/insights/LCPBreakdown.ts', UIStrings);
54
54
  export const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
55
- export function isLCPBreakdown(model) {
55
+ export function isLCPBreakdownInsight(model) {
56
56
  return model.insightKey === 'LCPBreakdown';
57
57
  }
58
58
  function anyValuesNaN(...values) {
@@ -48,7 +48,7 @@ export const UIStrings = {
48
48
  };
49
49
  const str_ = i18n.i18n.registerUIStrings('models/trace/insights/LCPDiscovery.ts', UIStrings);
50
50
  export const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
51
- export function isLCPDiscovery(model) {
51
+ export function isLCPDiscoveryInsight(model) {
52
52
  return model.insightKey === 'LCPDiscovery';
53
53
  }
54
54
  function finalize(partialModel) {
@@ -30,7 +30,7 @@ export const UIStrings = {
30
30
  };
31
31
  const str_ = i18n.i18n.registerUIStrings('models/trace/insights/ModernHTTP.ts', UIStrings);
32
32
  export const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
33
- export function isModernHTTP(model) {
33
+ export function isModernHTTPInsight(model) {
34
34
  return model.insightKey === "ModernHTTP" /* InsightKeys.MODERN_HTTP */;
35
35
  }
36
36
  /**
@@ -500,7 +500,7 @@ export function generatePreconnectCandidates(data, context, contextRequests) {
500
500
  preconnectCandidates = preconnectCandidates.sort((a, b) => b.wastedMs - a.wastedMs);
501
501
  return preconnectCandidates.slice(0, TOO_MANY_PRECONNECTS_THRESHOLD);
502
502
  }
503
- export function isNetworkDependencyTree(model) {
503
+ export function isNetworkDependencyTreeInsight(model) {
504
504
  return model.insightKey === "NetworkDependencyTree" /* InsightKeys.NETWORK_DEPENDENCY_TREE */;
505
505
  }
506
506
  export function generateInsight(data, context) {
@@ -31,7 +31,7 @@ export const UIStrings = {
31
31
  };
32
32
  const str_ = i18n.i18n.registerUIStrings('models/trace/insights/RenderBlocking.ts', UIStrings);
33
33
  export const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
34
- export function isRenderBlocking(insight) {
34
+ export function isRenderBlockingInsight(insight) {
35
35
  return insight.insightKey === 'RenderBlocking';
36
36
  }
37
37
  // Because of the way we detect blocking stylesheets, asynchronously loaded
@@ -20,7 +20,7 @@ export function objectIsCallFrame(object) {
20
20
  ('url' in object && typeof object.url === 'string');
21
21
  }
22
22
  export function isRunTask(event) {
23
- return event.name === "RunTask" /* Name.RUN_TASK */;
23
+ return event.name === "RunTask" /* Name.RUN_TASK */ && event.ph === "X" /* Phase.COMPLETE */;
24
24
  }
25
25
  export function isAuctionWorkletRunningInProcess(event) {
26
26
  return event.name === 'AuctionWorkletRunningInProcess';
@@ -216,7 +216,7 @@ export function isEnd(event) {
216
216
  return event.ph === "E" /* Phase.END */;
217
217
  }
218
218
  export function isDispatch(event) {
219
- return event.name === 'EventDispatch';
219
+ return event.name === 'EventDispatch' && event.ph === "X" /* Phase.COMPLETE */;
220
220
  }
221
221
  export function isInstant(event) {
222
222
  return event.ph === "I" /* Phase.INSTANT */;
@@ -225,13 +225,13 @@ export function isRendererEvent(event) {
225
225
  return isInstant(event) || isComplete(event);
226
226
  }
227
227
  export function isFireIdleCallback(event) {
228
- return event.name === 'FireIdleCallback';
228
+ return event.name === 'FireIdleCallback' && event.ph === "X" /* Phase.COMPLETE */;
229
229
  }
230
230
  export function isSchedulePostMessage(event) {
231
231
  return event.name === "SchedulePostMessage" /* Name.SCHEDULE_POST_MESSAGE */;
232
232
  }
233
233
  export function isHandlePostMessage(event) {
234
- return event.name === "HandlePostMessage" /* Name.HANDLE_POST_MESSAGE */;
234
+ return event.name === "HandlePostMessage" /* Name.HANDLE_POST_MESSAGE */ && event.ph === "X" /* Phase.COMPLETE */;
235
235
  }
236
236
  export function isUpdateCounters(event) {
237
237
  return event.name === 'UpdateCounters';
@@ -314,7 +314,7 @@ export function isProfile(event) {
314
314
  return event.name === "Profile" /* Name.PROFILE */;
315
315
  }
316
316
  export function isSyntheticCpuProfile(event) {
317
- return event.name === "CpuProfile" /* Name.CPU_PROFILE */;
317
+ return event.name === "CpuProfile" /* Name.CPU_PROFILE */ && event.ph === "X" /* Phase.COMPLETE */;
318
318
  }
319
319
  export function isProfileChunk(event) {
320
320
  return event.name === "ProfileChunk" /* Name.PROFILE_CHUNK */;
@@ -362,7 +362,7 @@ export function isNavigationStart(event) {
362
362
  return event.name === 'navigationStart' && event.args?.data?.documentLoaderURL !== '';
363
363
  }
364
364
  export function isDidCommitSameDocumentNavigation(event) {
365
- return event.name === 'RenderFrameHostImpl::DidCommitSameDocumentNavigation';
365
+ return event.name === 'RenderFrameHostImpl::DidCommitSameDocumentNavigation' && event.ph === "X" /* Phase.COMPLETE */;
366
366
  }
367
367
  export function isMainFrameViewport(event) {
368
368
  return event.name === 'PaintTimingVisualizer::Viewport';
@@ -433,10 +433,10 @@ export function isPaint(event) {
433
433
  return event.name === "Paint" /* Name.PAINT */;
434
434
  }
435
435
  export function isPaintImage(event) {
436
- return event.name === "PaintImage" /* Name.PAINT_IMAGE */;
436
+ return event.name === "PaintImage" /* Name.PAINT_IMAGE */ && event.ph === "X" /* Phase.COMPLETE */;
437
437
  }
438
438
  export function isScrollLayer(event) {
439
- return event.name === "ScrollLayer" /* Name.SCROLL_LAYER */;
439
+ return event.name === "ScrollLayer" /* Name.SCROLL_LAYER */ && event.ph === "X" /* Phase.COMPLETE */;
440
440
  }
441
441
  export function isSetLayerId(event) {
442
442
  return event.name === "SetLayerTreeId" /* Name.SET_LAYER_TREE_ID */;
@@ -451,13 +451,13 @@ export function isLayerTreeHostImplSnapshot(event) {
451
451
  return event.name === "cc::LayerTreeHostImpl" /* Name.LAYER_TREE_HOST_IMPL_SNAPSHOT */;
452
452
  }
453
453
  export function isFireAnimationFrame(event) {
454
- return event.name === "FireAnimationFrame" /* Name.FIRE_ANIMATION_FRAME */;
454
+ return event.name === "FireAnimationFrame" /* Name.FIRE_ANIMATION_FRAME */ && event.ph === "X" /* Phase.COMPLETE */;
455
455
  }
456
456
  export function isTimerInstall(event) {
457
457
  return event.name === "TimerInstall" /* Name.TIMER_INSTALL */;
458
458
  }
459
459
  export function isTimerFire(event) {
460
- return event.name === "TimerFire" /* Name.TIMER_FIRE */;
460
+ return event.name === "TimerFire" /* Name.TIMER_FIRE */ && event.ph === "X" /* Phase.COMPLETE */;
461
461
  }
462
462
  export function isRequestIdleCallback(event) {
463
463
  return event.name === "RequestIdleCallback" /* Name.REQUEST_IDLE_CALLBACK */;
@@ -488,19 +488,19 @@ export function isWebSocketEvent(event) {
488
488
  return isWebSocketTraceEvent(event) || isSyntheticWebSocketConnection(event);
489
489
  }
490
490
  export function isV8Compile(event) {
491
- return event.name === "v8.compile" /* Name.COMPILE */;
491
+ return event.name === "v8.compile" /* Name.COMPILE */ && event.ph === "X" /* Phase.COMPLETE */;
492
492
  }
493
493
  export function isFunctionCall(event) {
494
- return event.name === "FunctionCall" /* Name.FUNCTION_CALL */;
494
+ return event.name === "FunctionCall" /* Name.FUNCTION_CALL */ && event.ph === "X" /* Phase.COMPLETE */;
495
495
  }
496
496
  export function isSchedulePostTaskCallback(event) {
497
497
  return event.name === "SchedulePostTaskCallback" /* Name.SCHEDULE_POST_TASK_CALLBACK */;
498
498
  }
499
499
  export function isRunPostTaskCallback(event) {
500
- return event.name === "RunPostTaskCallback" /* Name.RUN_POST_TASK_CALLBACK */;
500
+ return event.name === "RunPostTaskCallback" /* Name.RUN_POST_TASK_CALLBACK */ && event.ph === "X" /* Phase.COMPLETE */;
501
501
  }
502
502
  export function isAbortPostTaskCallback(event) {
503
- return event.name === "AbortPostTaskCallback" /* Name.ABORT_POST_TASK_CALLBACK */;
503
+ return event.name === "AbortPostTaskCallback" /* Name.ABORT_POST_TASK_CALLBACK */ && event.ph === "X" /* Phase.COMPLETE */;
504
504
  }
505
505
  /**
506
506
  * Generally, before JS is executed, a trace event is dispatched that
@@ -536,7 +536,7 @@ export function isFlowPhaseEvent(event) {
536
536
  return event.ph === "s" /* Phase.FLOW_START */ || event.ph === "t" /* Phase.FLOW_STEP */ || event.ph === "f" /* Phase.FLOW_END */;
537
537
  }
538
538
  export function isParseAuthorStyleSheetEvent(event) {
539
- return event.name === "ParseAuthorStyleSheet" /* Name.PARSE_AUTHOR_STYLE_SHEET */;
539
+ return event.name === "ParseAuthorStyleSheet" /* Name.PARSE_AUTHOR_STYLE_SHEET */ && event.ph === "X" /* Phase.COMPLETE */;
540
540
  }
541
541
  // NOT AN EXHAUSTIVE LIST: just some categories we use and refer
542
542
  // to in multiple places.
@@ -548,18 +548,18 @@ export const Categories = {
548
548
  export function isLegacyTimelineFrame(data) {
549
549
  return 'idle' in data && typeof data.idle === 'boolean';
550
550
  }
551
- export function isTargetRundownEvent(event) {
552
- return event.cat === 'disabled-by-default-devtools.target-rundown' && event.name === 'ScriptCompiled';
551
+ export function isRundownScriptCompiled(event) {
552
+ return event.cat === 'disabled-by-default-devtools.target-rundown';
553
553
  }
554
- export function isV8SourceRundownEvent(event) {
554
+ export function isRundownScript(event) {
555
555
  return event.cat === 'disabled-by-default-devtools.v8-source-rundown' && event.name === 'ScriptCatchup';
556
556
  }
557
- export function isV8SourceRundownSourcesScriptCatchupEvent(event) {
557
+ export function isRundownScriptSource(event) {
558
558
  return event.cat === 'disabled-by-default-devtools.v8-source-rundown-sources' && event.name === 'ScriptCatchup';
559
559
  }
560
- export function isV8SourceRundownSourcesLargeScriptCatchupEvent(event) {
560
+ export function isRundownScriptSourceLarge(event) {
561
561
  return event.cat === 'disabled-by-default-devtools.v8-source-rundown-sources' && event.name === 'LargeScriptCatchup';
562
562
  }
563
- export function isAnyScriptCatchupEvent(event) {
563
+ export function isAnyScriptSourceEvent(event) {
564
564
  return event.cat === 'disabled-by-default-devtools.v8-source-rundown-sources';
565
565
  }
@@ -1,6 +1,7 @@
1
1
  // Copyright 2023 The Chromium Authors
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
+ var _a;
4
5
  import * as SDK from '../../core/sdk/sdk.js';
5
6
  import * as Bindings from '../bindings/bindings.js';
6
7
  import * as SourceMapScopes from '../source_map_scopes/source_map_scopes.js';
@@ -65,10 +66,10 @@ export class SourceMapsResolver extends EventTarget {
65
66
  }
66
67
  callFrame = topCallFrame;
67
68
  }
68
- return SourceMapsResolver.resolvedCodeLocationForCallFrame(callFrame);
69
+ return _a.resolvedCodeLocationForCallFrame(callFrame);
69
70
  }
70
71
  static resolvedURLForEntry(parsedTrace, entry) {
71
- const resolvedCallFrameURL = SourceMapsResolver.resolvedCodeLocationForEntry(entry)?.devtoolsLocation?.uiSourceCode.url();
72
+ const resolvedCallFrameURL = _a.resolvedCodeLocationForEntry(entry)?.devtoolsLocation?.uiSourceCode.url();
72
73
  if (resolvedCallFrameURL) {
73
74
  return resolvedCallFrameURL;
74
75
  }
@@ -153,7 +154,7 @@ export class SourceMapsResolver extends EventTarget {
153
154
  // Update mappings for the related events of the entity.
154
155
  this.#entityMapper.updateSourceMapEntities(node.callFrame, uiLocation.uiSourceCode.url());
155
156
  }
156
- SourceMapsResolver.storeResolvedCodeDataForCallFrame(node.callFrame, { name: resolvedFunctionName, devtoolsLocation: uiLocation, script });
157
+ _a.storeResolvedCodeDataForCallFrame(node.callFrame, { name: resolvedFunctionName, devtoolsLocation: uiLocation, script });
157
158
  }
158
159
  }
159
160
  }
@@ -197,3 +198,4 @@ export class SourceMapsResolver extends EventTarget {
197
198
  this.#entityMapper?.updateExtensionEntitiesWithName(this.executionContextNamesByOrigin);
198
199
  }
199
200
  }
201
+ _a = SourceMapsResolver;
@@ -1,4 +1,4 @@
1
- // Copyright 2025 The Chromium Authors. All rights reserved.
1
+ // Copyright 2025 The Chromium Authors
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
  export * from './SourceMapsResolver.js';