@paulirish/trace_engine 0.0.45 → 0.0.47

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 (170) hide show
  1. package/.tmp/tsbuildinfo/models/trace/extras/polyfills.d.ts +4 -0
  2. package/.tmp/tsbuildinfo/models/trace/extras/polyfills.d.ts.map +1 -0
  3. package/.tmp/tsbuildinfo/tsconfig.tsbuildinfo +1 -1
  4. package/core/platform/Constructor.d.ts +3 -0
  5. package/core/platform/Constructor.js +5 -0
  6. package/core/platform/Constructor.js.map +1 -0
  7. package/core/platform/MapUtilities.js +1 -0
  8. package/core/platform/MapUtilities.js.map +1 -1
  9. package/core/platform/TypescriptUtilities.d.ts +7 -0
  10. package/core/platform/TypescriptUtilities.js.map +1 -1
  11. package/core/platform/platform-tsconfig.json +1 -0
  12. package/core/platform/platform.d.ts +2 -1
  13. package/core/platform/platform.js +2 -1
  14. package/core/platform/platform.js.map +1 -1
  15. package/generated/protocol.d.ts +214 -4
  16. package/locales/af.json +360 -0
  17. package/locales/am.json +360 -0
  18. package/locales/ar.json +360 -0
  19. package/locales/as.json +360 -0
  20. package/locales/az.json +360 -0
  21. package/locales/be.json +360 -0
  22. package/locales/bg.json +360 -0
  23. package/locales/bn.json +360 -0
  24. package/locales/bs.json +360 -0
  25. package/locales/ca.json +360 -0
  26. package/locales/cs.json +360 -0
  27. package/locales/cy.json +360 -0
  28. package/locales/da.json +360 -0
  29. package/locales/de.json +360 -0
  30. package/locales/el.json +360 -0
  31. package/locales/en-GB.json +360 -0
  32. package/locales/en-US.json +370 -10
  33. package/locales/en-XL.json +370 -10
  34. package/locales/es-419.json +360 -0
  35. package/locales/es.json +360 -0
  36. package/locales/et.json +360 -0
  37. package/locales/eu.json +360 -0
  38. package/locales/fa.json +360 -0
  39. package/locales/fi.json +360 -0
  40. package/locales/fil.json +360 -0
  41. package/locales/fr-CA.json +360 -0
  42. package/locales/fr.json +360 -0
  43. package/locales/gl.json +360 -0
  44. package/locales/gu.json +360 -0
  45. package/locales/he.json +360 -0
  46. package/locales/hi.json +360 -0
  47. package/locales/hr.json +360 -0
  48. package/locales/hu.json +360 -0
  49. package/locales/hy.json +360 -0
  50. package/locales/id.json +360 -0
  51. package/locales/is.json +360 -0
  52. package/locales/it.json +360 -0
  53. package/locales/ja.json +360 -0
  54. package/locales/ka.json +360 -0
  55. package/locales/kk.json +360 -0
  56. package/locales/km.json +360 -0
  57. package/locales/kn.json +360 -0
  58. package/locales/ko.json +360 -0
  59. package/locales/ky.json +360 -0
  60. package/locales/lo.json +360 -0
  61. package/locales/lt.json +360 -0
  62. package/locales/lv.json +360 -0
  63. package/locales/mk.json +360 -0
  64. package/locales/ml.json +360 -0
  65. package/locales/mn.json +360 -0
  66. package/locales/mr.json +360 -0
  67. package/locales/ms.json +360 -0
  68. package/locales/my.json +360 -0
  69. package/locales/ne.json +360 -0
  70. package/locales/nl.json +360 -0
  71. package/locales/no.json +360 -0
  72. package/locales/or.json +360 -0
  73. package/locales/pa.json +360 -0
  74. package/locales/pl.json +360 -0
  75. package/locales/pt-PT.json +360 -0
  76. package/locales/pt.json +360 -0
  77. package/locales/ro.json +360 -0
  78. package/locales/ru.json +360 -0
  79. package/locales/si.json +360 -0
  80. package/locales/sk.json +360 -0
  81. package/locales/sl.json +360 -0
  82. package/locales/sq.json +360 -0
  83. package/locales/sr-Latn.json +360 -0
  84. package/locales/sr.json +360 -0
  85. package/locales/sv.json +360 -0
  86. package/locales/sw.json +360 -0
  87. package/locales/ta.json +360 -0
  88. package/locales/te.json +360 -0
  89. package/locales/th.json +360 -0
  90. package/locales/tr.json +360 -0
  91. package/locales/uk.json +360 -0
  92. package/locales/ur.json +360 -0
  93. package/locales/uz.json +360 -0
  94. package/locales/vi.json +360 -0
  95. package/locales/zh-HK.json +360 -0
  96. package/locales/zh-TW.json +360 -0
  97. package/locales/zh.json +360 -0
  98. package/locales/zu.json +360 -0
  99. package/models/trace/Processor.d.ts +4 -1
  100. package/models/trace/Processor.js +10 -16
  101. package/models/trace/Processor.js.map +1 -1
  102. package/models/trace/extras/ScriptDuplication.d.ts +1 -1
  103. package/models/trace/extras/ScriptDuplication.js +2 -2
  104. package/models/trace/extras/ScriptDuplication.js.map +1 -1
  105. package/models/trace/extras/extras.d.ts +3798 -0
  106. package/models/trace/extras/extras.js +3798 -0
  107. package/models/trace/handlers/LayoutShiftsHandler.d.ts +7 -1
  108. package/models/trace/handlers/LayoutShiftsHandler.js +16 -5
  109. package/models/trace/handlers/LayoutShiftsHandler.js.map +1 -1
  110. package/models/trace/handlers/PageLoadMetricsHandler.d.ts +5 -0
  111. package/models/trace/handlers/PageLoadMetricsHandler.js +3 -0
  112. package/models/trace/handlers/PageLoadMetricsHandler.js.map +1 -1
  113. package/models/trace/handlers/ScriptsHandler.d.ts +5 -1
  114. package/models/trace/handlers/ScriptsHandler.js +24 -11
  115. package/models/trace/handlers/ScriptsHandler.js.map +1 -1
  116. package/models/trace/handlers/types.d.ts +1 -1
  117. package/models/trace/handlers/types.js.map +1 -1
  118. package/models/trace/insights/CLSCulprits.d.ts +5 -5
  119. package/models/trace/insights/CLSCulprits.js +1 -3
  120. package/models/trace/insights/CLSCulprits.js.map +1 -1
  121. package/models/trace/insights/DOMSize.d.ts +3 -3
  122. package/models/trace/insights/DOMSize.js +2 -4
  123. package/models/trace/insights/DOMSize.js.map +1 -1
  124. package/models/trace/insights/DocumentLatency.d.ts +3 -3
  125. package/models/trace/insights/DocumentLatency.js +4 -6
  126. package/models/trace/insights/DocumentLatency.js.map +1 -1
  127. package/models/trace/insights/DuplicateJavaScript.d.ts +3 -3
  128. package/models/trace/insights/DuplicateJavaScript.js +6 -9
  129. package/models/trace/insights/DuplicateJavaScript.js.map +1 -1
  130. package/models/trace/insights/FontDisplay.d.ts +12 -9
  131. package/models/trace/insights/FontDisplay.js +16 -15
  132. package/models/trace/insights/FontDisplay.js.map +1 -1
  133. package/models/trace/insights/ForcedReflow.d.ts +3 -3
  134. package/models/trace/insights/ForcedReflow.js +2 -4
  135. package/models/trace/insights/ForcedReflow.js.map +1 -1
  136. package/models/trace/insights/ImageDelivery.d.ts +7 -6
  137. package/models/trace/insights/ImageDelivery.js +27 -20
  138. package/models/trace/insights/ImageDelivery.js.map +1 -1
  139. package/models/trace/insights/InteractionToNextPaint.d.ts +3 -3
  140. package/models/trace/insights/InteractionToNextPaint.js +4 -4
  141. package/models/trace/insights/InteractionToNextPaint.js.map +1 -1
  142. package/models/trace/insights/LCPDiscovery.d.ts +4 -3
  143. package/models/trace/insights/LCPDiscovery.js +9 -6
  144. package/models/trace/insights/LCPDiscovery.js.map +1 -1
  145. package/models/trace/insights/LCPPhases.d.ts +4 -4
  146. package/models/trace/insights/LCPPhases.js +7 -6
  147. package/models/trace/insights/LCPPhases.js.map +1 -1
  148. package/models/trace/insights/NetworkDependencyTree.d.ts +9 -3
  149. package/models/trace/insights/NetworkDependencyTree.js +41 -10
  150. package/models/trace/insights/NetworkDependencyTree.js.map +1 -1
  151. package/models/trace/insights/RenderBlocking.d.ts +4 -3
  152. package/models/trace/insights/RenderBlocking.js +6 -3
  153. package/models/trace/insights/RenderBlocking.js.map +1 -1
  154. package/models/trace/insights/SlowCSSSelector.d.ts +3 -3
  155. package/models/trace/insights/SlowCSSSelector.js +1 -3
  156. package/models/trace/insights/SlowCSSSelector.js.map +1 -1
  157. package/models/trace/insights/ThirdParties.d.ts +3 -3
  158. package/models/trace/insights/ThirdParties.js +2 -4
  159. package/models/trace/insights/ThirdParties.js.map +1 -1
  160. package/models/trace/insights/Viewport.d.ts +3 -3
  161. package/models/trace/insights/Viewport.js +14 -9
  162. package/models/trace/insights/Viewport.js.map +1 -1
  163. package/models/trace/insights/types.d.ts +5 -9
  164. package/models/trace/insights/types.js.map +1 -1
  165. package/models/trace/types/File.d.ts +8 -0
  166. package/models/trace/types/File.js.map +1 -1
  167. package/models/trace/types/TraceEvents.d.ts +16 -1
  168. package/models/trace/types/TraceEvents.js +3 -0
  169. package/models/trace/types/TraceEvents.js.map +1 -1
  170. package/package.json +1 -1
@@ -1,5 +1,6 @@
1
+ import type * as Handlers from '../handlers/handlers.js';
1
2
  import * as Types from '../types/types.js';
2
- import { type InsightModel, type InsightSetContext, type RequiredData } from './types.js';
3
+ import { type InsightModel, type InsightSetContext } from './types.js';
3
4
  export declare const UIStrings: {
4
5
  /**
5
6
  *@description Title of an insight that provides details about slow CSS selectors.
@@ -35,7 +36,6 @@ export declare const UIStrings: {
35
36
  readonly enableSelectorData: "No CSS selector data was found. CSS selector stats need to be enabled in the performance panel settings.";
36
37
  };
37
38
  export declare const i18nString: (id: string, values?: Record<string, string> | undefined) => Record<string, string>;
38
- export declare function deps(): ['SelectorStats'];
39
39
  export type SlowCSSSelectorInsightModel = InsightModel<typeof UIStrings, {
40
40
  totalElapsedMs: Types.Timing.Milli;
41
41
  totalMatchAttempts: number;
@@ -43,4 +43,4 @@ export type SlowCSSSelectorInsightModel = InsightModel<typeof UIStrings, {
43
43
  topElapsedMs: Types.Events.SelectorTiming[];
44
44
  topMatchAttempts: Types.Events.SelectorTiming[];
45
45
  }>;
46
- export declare function generateInsight(parsedTrace: RequiredData<typeof deps>, context: InsightSetContext): SlowCSSSelectorInsightModel;
46
+ export declare function generateInsight(parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContext): SlowCSSSelectorInsightModel;
@@ -42,9 +42,6 @@ export const UIStrings = {
42
42
  };
43
43
  // const str_ = i18n.i18n.registerUIStrings('models/trace/insights/SlowCSSSelector.ts', UIStrings);
44
44
  export const i18nString = (i18nId, values) => ({i18nId, values}); // i18n.i18n.getLocalizedString.bind(undefined, str_);
45
- export function deps() {
46
- return ['SelectorStats'];
47
- }
48
45
  function aggregateSelectorStats(data, context) {
49
46
  const selectorMap = new Map();
50
47
  for (const [event, value] of data) {
@@ -105,6 +102,7 @@ export function generateInsight(parsedTrace, context) {
105
102
  return b[SelectorTimingsKey.MatchAttempts] - a[SelectorTimingsKey.MatchAttempts];
106
103
  });
107
104
  return finalize({
105
+ frameId: context.frameId,
108
106
  // TODO: should we identify UpdateLayout events as linked to this insight?
109
107
  relatedEvents: [],
110
108
  totalElapsedMs: Types.Timing.Milli(totalElapsedUs / 1000.0),
@@ -1 +1 @@
1
- {"version":3,"file":"SlowCSSSelector.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/SlowCSSSelector.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAsB,kBAAkB,EAAC,MAAM,yBAAyB,CAAC;AAChF,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EACL,eAAe,GAMhB,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB;;OAEG;IACH,KAAK,EAAE,oBAAoB;IAE3B;;OAEG;IACH,WAAW,EACP,yUAAyU;IAC7U;;OAEG;IACH,aAAa,EAAE,gBAAgB;IAC/B;;OAEG;IACH,UAAU,EAAE,aAAa;IACzB;;OAEG;IACH,OAAO,EAAE,cAAc;IACvB;;OAEG;IACH,YAAY,EAAE,eAAe;IAC7B;;OAEG;IACH,KAAK,EAAE,OAAO;IACd;;OAEG;IACH,kBAAkB,EACd,0GAA0G;CACtG,CAAC;AAEX,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,0CAA0C,EAAE,SAAS,CAAC,CAAC;AAChG,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AAE7E,MAAM,UAAU,IAAI;IAClB,OAAO,CAAC,eAAe,CAAC,CAAC;AAC3B,CAAC;AAUD,SAAS,sBAAsB,CAC3B,IAEE,EACF,OAA0B;IAC5B,MAAM,WAAW,GAAG,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,CAAC,kBAAkB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;IAEH,yBAAyB;IACzB,MAAM,mBAAmB,GAAG,CAAC,GAAG,eAAe,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAC7D,OAAO,CAAC,CAAC,kBAAkB,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC;IACnF,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;QACd,0EAA0E;QAC1E,aAAa,EAAE,EAAE;QACjB,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,GAAG,MAAM,CAAC;QAC3D,kBAAkB;QAClB,eAAe;QACf,YAAY,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;QACzC,gBAAgB,EAAE,mBAAmB,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;KAClD,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as i18n from '../../../core/i18n/i18n.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport {type SelectorTiming, SelectorTimingsKey} from '../types/TraceEvents.js';\nimport * as Types from '../types/types.js';\n\nimport {\n InsightCategory,\n InsightKeys,\n type InsightModel,\n type InsightSetContext,\n type PartialInsightModel,\n type RequiredData,\n} from './types.js';\n\nexport const UIStrings = {\n /**\n *@description Title of an insight that provides details about slow CSS selectors.\n */\n title: 'CSS Selector costs',\n\n /**\n * @description Text to describe how to improve the performance of CSS selectors.\n */\n description:\n 'If Recalculate Style costs remain high, selector optimization can reduce them. [Optimize the selectors](https://developer.chrome.com/docs/devtools/performance/selector-stats) with both high elapsed time and high slow-path %. Simpler selectors, fewer selectors, a smaller DOM, and a shallower DOM will all reduce matching costs.',\n /**\n *@description Column name for count of elements that the engine attempted to match against a style rule\n */\n matchAttempts: 'Match attempts',\n /**\n *@description Column name for count of elements that matched a style rule\n */\n matchCount: 'Match count',\n /**\n *@description Column name for elapsed time spent computing a style rule\n */\n elapsed: 'Elapsed time',\n /**\n *@description Column name for the selectors that took the longest amount of time/effort.\n */\n topSelectors: 'Top selectors',\n /**\n *@description Column name for a total sum.\n */\n total: 'Total',\n /**\n * @description Text status indicating that no CSS selector data was found.\n */\n enableSelectorData:\n 'No CSS selector data was found. CSS selector stats need to be enabled in the performance panel settings.',\n} as const;\n\nconst str_ = i18n.i18n.registerUIStrings('models/trace/insights/SlowCSSSelector.ts', UIStrings);\nexport const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);\n\nexport function deps(): ['SelectorStats'] {\n return ['SelectorStats'];\n}\n\nexport type SlowCSSSelectorInsightModel = InsightModel<typeof UIStrings, {\n totalElapsedMs: Types.Timing.Milli,\n totalMatchAttempts: number,\n totalMatchCount: number,\n topElapsedMs: Types.Events.SelectorTiming[],\n topMatchAttempts: Types.Events.SelectorTiming[],\n}>;\n\nfunction aggregateSelectorStats(\n data: Map<Types.Events.UpdateLayoutTree, {\n timings: Types.Events.SelectorTiming[],\n }>,\n context: InsightSetContext): SelectorTiming[] {\n const selectorMap = new Map<String, SelectorTiming>();\n\n for (const [event, value] of data) {\n if (event.args.beginData?.frame !== context.frameId) {\n continue;\n }\n if (!Helpers.Timing.eventIsInBounds(event, context.bounds)) {\n continue;\n }\n for (const timing of value.timings) {\n const key = timing[SelectorTimingsKey.Selector] + '_' + timing[SelectorTimingsKey.StyleSheetId];\n const findTiming = selectorMap.get(key);\n if (findTiming !== undefined) {\n findTiming[SelectorTimingsKey.Elapsed] += timing[SelectorTimingsKey.Elapsed];\n findTiming[SelectorTimingsKey.FastRejectCount] += timing[SelectorTimingsKey.FastRejectCount];\n findTiming[SelectorTimingsKey.MatchAttempts] += timing[SelectorTimingsKey.MatchAttempts];\n findTiming[SelectorTimingsKey.MatchCount] += timing[SelectorTimingsKey.MatchCount];\n } else {\n selectorMap.set(key, {...timing});\n }\n }\n }\n\n return [...selectorMap.values()];\n}\n\nfunction finalize(partialModel: PartialInsightModel<SlowCSSSelectorInsightModel>): SlowCSSSelectorInsightModel {\n return {\n insightKey: InsightKeys.SLOW_CSS_SELECTOR,\n strings: UIStrings,\n title: i18nString(UIStrings.title),\n description: i18nString(UIStrings.description),\n category: InsightCategory.ALL,\n state: partialModel.topElapsedMs.length !== 0 && partialModel.topMatchAttempts.length !== 0 ? 'informative' :\n 'pass',\n ...partialModel,\n };\n}\n\nexport function generateInsight(\n parsedTrace: RequiredData<typeof deps>, context: InsightSetContext): SlowCSSSelectorInsightModel {\n const selectorStatsData = parsedTrace.SelectorStats;\n\n if (!selectorStatsData) {\n throw new Error('no selector stats data');\n }\n\n const selectorTimings = aggregateSelectorStats(selectorStatsData.dataForUpdateLayoutEvent, context);\n\n let totalElapsedUs = 0;\n let totalMatchAttempts = 0;\n let totalMatchCount = 0;\n\n selectorTimings.map(timing => {\n totalElapsedUs += timing[SelectorTimingsKey.Elapsed];\n totalMatchAttempts += timing[SelectorTimingsKey.MatchAttempts];\n totalMatchCount += timing[SelectorTimingsKey.MatchCount];\n });\n\n // sort by elapsed time\n const sortByElapsedMs = [...selectorTimings].sort((a, b) => {\n return b[SelectorTimingsKey.Elapsed] - a[SelectorTimingsKey.Elapsed];\n });\n\n // sort by match attempts\n const sortByMatchAttempts = [...selectorTimings].sort((a, b) => {\n return b[SelectorTimingsKey.MatchAttempts] - a[SelectorTimingsKey.MatchAttempts];\n });\n\n return finalize({\n // TODO: should we identify UpdateLayout events as linked to this insight?\n relatedEvents: [],\n totalElapsedMs: Types.Timing.Milli(totalElapsedUs / 1000.0),\n totalMatchAttempts,\n totalMatchCount,\n topElapsedMs: sortByElapsedMs.slice(0, 3),\n topMatchAttempts: sortByMatchAttempts.slice(0, 3),\n });\n}\n"]}
1
+ {"version":3,"file":"SlowCSSSelector.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/SlowCSSSelector.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAC;AAEnD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAsB,kBAAkB,EAAC,MAAM,yBAAyB,CAAC;AAChF,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EACL,eAAe,GAKhB,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB;;OAEG;IACH,KAAK,EAAE,oBAAoB;IAE3B;;OAEG;IACH,WAAW,EACP,yUAAyU;IAC7U;;OAEG;IACH,aAAa,EAAE,gBAAgB;IAC/B;;OAEG;IACH,UAAU,EAAE,aAAa;IACzB;;OAEG;IACH,OAAO,EAAE,cAAc;IACvB;;OAEG;IACH,YAAY,EAAE,eAAe;IAC7B;;OAEG;IACH,KAAK,EAAE,OAAO;IACd;;OAEG;IACH,kBAAkB,EACd,0GAA0G;CACtG,CAAC;AAEX,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,0CAA0C,EAAE,SAAS,CAAC,CAAC;AAChG,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AAU7E,SAAS,sBAAsB,CAC3B,IAEE,EACF,OAA0B;IAC5B,MAAM,WAAW,GAAG,IAAI,GAAG,EAA0B,CAAC;IAEtD,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;QAClC,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC;YACpD,SAAS;QACX,CAAC;QACD,IAAI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EAAE;QAC7D,OAAO,CAAC,CAAC,kBAAkB,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC;IACnF,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;QACd,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,0EAA0E;QAC1E,aAAa,EAAE,EAAE;QACjB,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,GAAG,MAAM,CAAC;QAC3D,kBAAkB;QAClB,eAAe;QACf,YAAY,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;QACzC,gBAAgB,EAAE,mBAAmB,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;KAClD,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as i18n from '../../../core/i18n/i18n.js';\nimport type * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport {type SelectorTiming, SelectorTimingsKey} from '../types/TraceEvents.js';\nimport * as Types from '../types/types.js';\n\nimport {\n InsightCategory,\n InsightKeys,\n type InsightModel,\n type InsightSetContext,\n type PartialInsightModel,\n} from './types.js';\n\nexport const UIStrings = {\n /**\n *@description Title of an insight that provides details about slow CSS selectors.\n */\n title: 'CSS Selector costs',\n\n /**\n * @description Text to describe how to improve the performance of CSS selectors.\n */\n description:\n 'If Recalculate Style costs remain high, selector optimization can reduce them. [Optimize the selectors](https://developer.chrome.com/docs/devtools/performance/selector-stats) with both high elapsed time and high slow-path %. Simpler selectors, fewer selectors, a smaller DOM, and a shallower DOM will all reduce matching costs.',\n /**\n *@description Column name for count of elements that the engine attempted to match against a style rule\n */\n matchAttempts: 'Match attempts',\n /**\n *@description Column name for count of elements that matched a style rule\n */\n matchCount: 'Match count',\n /**\n *@description Column name for elapsed time spent computing a style rule\n */\n elapsed: 'Elapsed time',\n /**\n *@description Column name for the selectors that took the longest amount of time/effort.\n */\n topSelectors: 'Top selectors',\n /**\n *@description Column name for a total sum.\n */\n total: 'Total',\n /**\n * @description Text status indicating that no CSS selector data was found.\n */\n enableSelectorData:\n 'No CSS selector data was found. CSS selector stats need to be enabled in the performance panel settings.',\n} as const;\n\nconst str_ = i18n.i18n.registerUIStrings('models/trace/insights/SlowCSSSelector.ts', UIStrings);\nexport const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);\n\nexport type SlowCSSSelectorInsightModel = InsightModel<typeof UIStrings, {\n totalElapsedMs: Types.Timing.Milli,\n totalMatchAttempts: number,\n totalMatchCount: number,\n topElapsedMs: Types.Events.SelectorTiming[],\n topMatchAttempts: Types.Events.SelectorTiming[],\n}>;\n\nfunction aggregateSelectorStats(\n data: Map<Types.Events.UpdateLayoutTree, {\n timings: Types.Events.SelectorTiming[],\n }>,\n context: InsightSetContext): SelectorTiming[] {\n const selectorMap = new Map<String, SelectorTiming>();\n\n for (const [event, value] of data) {\n if (event.args.beginData?.frame !== context.frameId) {\n continue;\n }\n if (!Helpers.Timing.eventIsInBounds(event, context.bounds)) {\n continue;\n }\n for (const timing of value.timings) {\n const key = timing[SelectorTimingsKey.Selector] + '_' + timing[SelectorTimingsKey.StyleSheetId];\n const findTiming = selectorMap.get(key);\n if (findTiming !== undefined) {\n findTiming[SelectorTimingsKey.Elapsed] += timing[SelectorTimingsKey.Elapsed];\n findTiming[SelectorTimingsKey.FastRejectCount] += timing[SelectorTimingsKey.FastRejectCount];\n findTiming[SelectorTimingsKey.MatchAttempts] += timing[SelectorTimingsKey.MatchAttempts];\n findTiming[SelectorTimingsKey.MatchCount] += timing[SelectorTimingsKey.MatchCount];\n } else {\n selectorMap.set(key, {...timing});\n }\n }\n }\n\n return [...selectorMap.values()];\n}\n\nfunction finalize(partialModel: PartialInsightModel<SlowCSSSelectorInsightModel>): SlowCSSSelectorInsightModel {\n return {\n insightKey: InsightKeys.SLOW_CSS_SELECTOR,\n strings: UIStrings,\n title: i18nString(UIStrings.title),\n description: i18nString(UIStrings.description),\n category: InsightCategory.ALL,\n state: partialModel.topElapsedMs.length !== 0 && partialModel.topMatchAttempts.length !== 0 ? 'informative' :\n 'pass',\n ...partialModel,\n };\n}\n\nexport function generateInsight(\n parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContext): SlowCSSSelectorInsightModel {\n const selectorStatsData = parsedTrace.SelectorStats;\n\n if (!selectorStatsData) {\n throw new Error('no selector stats data');\n }\n\n const selectorTimings = aggregateSelectorStats(selectorStatsData.dataForUpdateLayoutEvent, context);\n\n let totalElapsedUs = 0;\n let totalMatchAttempts = 0;\n let totalMatchCount = 0;\n\n selectorTimings.map(timing => {\n totalElapsedUs += timing[SelectorTimingsKey.Elapsed];\n totalMatchAttempts += timing[SelectorTimingsKey.MatchAttempts];\n totalMatchCount += timing[SelectorTimingsKey.MatchCount];\n });\n\n // sort by elapsed time\n const sortByElapsedMs = [...selectorTimings].sort((a, b) => {\n return b[SelectorTimingsKey.Elapsed] - a[SelectorTimingsKey.Elapsed];\n });\n\n // sort by match attempts\n const sortByMatchAttempts = [...selectorTimings].sort((a, b) => {\n return b[SelectorTimingsKey.MatchAttempts] - a[SelectorTimingsKey.MatchAttempts];\n });\n\n return finalize({\n frameId: context.frameId,\n // TODO: should we identify UpdateLayout events as linked to this insight?\n relatedEvents: [],\n totalElapsedMs: Types.Timing.Milli(totalElapsedUs / 1000.0),\n totalMatchAttempts,\n totalMatchCount,\n topElapsedMs: sortByElapsedMs.slice(0, 3),\n topMatchAttempts: sortByMatchAttempts.slice(0, 3),\n });\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import * as Extras from '../extras/extras.js';
2
+ import * as Handlers from '../handlers/handlers.js';
2
3
  import type * as Types from '../types/types.js';
3
- import { type InsightModel, type InsightSetContext, type RequiredData } from './types.js';
4
+ import { type InsightModel, type InsightSetContext } from './types.js';
4
5
  export declare const UIStrings: {
5
6
  /** Title of an insight that provides details about the code on a web page that the user doesn't control (referred to as "third-party code"). */
6
7
  readonly title: "3rd parties";
@@ -21,7 +22,6 @@ export declare const UIStrings: {
21
22
  readonly noThirdParties: "No third parties found";
22
23
  };
23
24
  export declare const i18nString: (id: string, values?: Record<string, string> | undefined) => Record<string, string>;
24
- export declare function deps(): ['Meta', 'NetworkRequests', 'Renderer', 'ImagePainting'];
25
25
  export type ThirdPartiesInsightModel = InsightModel<typeof UIStrings, {
26
26
  eventsByEntity: Map<Extras.ThirdParties.Entity, Types.Events.Event[]>;
27
27
  summaryByEntity: Map<Extras.ThirdParties.Entity, Extras.ThirdParties.Summary>;
@@ -30,4 +30,4 @@ export type ThirdPartiesInsightModel = InsightModel<typeof UIStrings, {
30
30
  /** The entity for this navigation's URL. Any other entity is from a third party. */
31
31
  firstPartyEntity?: Extras.ThirdParties.Entity;
32
32
  }>;
33
- export declare function generateInsight(parsedTrace: RequiredData<typeof deps>, context: InsightSetContext): ThirdPartiesInsightModel;
33
+ export declare function generateInsight(parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContext): ThirdPartiesInsightModel;
@@ -6,7 +6,7 @@ import * as ThirdPartyWeb from '../../../third_party/third-party-web/third-party
6
6
  import * as Extras from '../extras/extras.js';
7
7
  import * as Handlers from '../handlers/handlers.js';
8
8
  import * as Helpers from '../helpers/helpers.js';
9
- import { InsightCategory } from './types.js';
9
+ import { InsightCategory, } from './types.js';
10
10
  export const UIStrings = {
11
11
  /** Title of an insight that provides details about the code on a web page that the user doesn't control (referred to as "third-party code"). */
12
12
  title: '3rd parties',
@@ -29,9 +29,6 @@ export const UIStrings = {
29
29
  };
30
30
  // const str_ = i18n.i18n.registerUIStrings('models/trace/insights/ThirdParties.ts', UIStrings);
31
31
  export const i18nString = (i18nId, values) => ({i18nId, values}); // i18n.i18n.getLocalizedString.bind(undefined, str_);
32
- export function deps() {
33
- return ['Meta', 'NetworkRequests', 'Renderer', 'ImagePainting'];
34
- }
35
32
  function getRelatedEvents(summaries, firstPartyEntity) {
36
33
  const relatedEvents = [];
37
34
  for (const [entity, events] of summaries.eventsByEntity.entries()) {
@@ -69,6 +66,7 @@ export function generateInsight(parsedTrace, context) {
69
66
  const firstPartyEntity = ThirdPartyWeb.ThirdPartyWeb.getEntity(firstPartyUrl) ||
70
67
  Handlers.Helpers.makeUpEntity(thirdPartySummary.madeUpEntityCache, firstPartyUrl);
71
68
  return finalize({
69
+ frameId: context.frameId,
72
70
  relatedEvents: getRelatedEvents(thirdPartySummary, firstPartyEntity),
73
71
  eventsByEntity: thirdPartySummary.eventsByEntity,
74
72
  summaryByEntity: thirdPartySummary.byEntity,
@@ -1 +1 @@
1
- {"version":3,"file":"ThirdParties.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/ThirdParties.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAC;AACnD,OAAO,KAAK,aAAa,MAAM,yDAAyD,CAAC;AACzF,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAC;AAC9C,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AAGjD,OAAO,EACL,eAAe,EAMhB,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,gJAAgJ;IAChJ,KAAK,EAAE,aAAa;IACpB;;;OAGG;IACH,WAAW,EAAE,4DAA4D;QACrE,4MAA4M;IAChN,iFAAiF;IACjF,gBAAgB,EAAE,WAAW;IAC7B,4GAA4G;IAC5G,kBAAkB,EAAE,eAAe;IACnC,wJAAwJ;IACxJ,oBAAoB,EAAE,kBAAkB;IACxC;;OAEG;IACH,cAAc,EAAE,wBAAwB;CAChC,CAAC;AAEX,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,uCAAuC,EAAE,SAAS,CAAC,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,OAAO,CAAC,UAAU,EAAE,CAAC;YACxB,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC;YAC9C,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;IAEH,MAAM,iBAAiB,GAAG,MAAM,CAAC,YAAY,CAAC,qBAAqB,CAC/D,WAAyC,EAAE,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAEhF,MAAM,aAAa,GAAG,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,EAAE,iBAAiB,IAAI,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC;IACxG,MAAM,gBAAgB,GAAG,aAAa,CAAC,aAAa,CAAC,SAAS,CAAC,aAAa,CAAC;QACzE,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC;IAEtF,OAAO,QAAQ,CAAC;QACd,aAAa,EAAE,gBAAgB,CAAC,iBAAiB,EAAE,gBAAgB,CAAC;QACpE,cAAc,EAAE,iBAAiB,CAAC,cAAc;QAChD,eAAe,EAAE,iBAAiB,CAAC,QAAQ;QAC3C,YAAY,EAAE,iBAAiB,CAAC,KAAK;QACrC,YAAY,EAAE,iBAAiB,CAAC,YAAY;QAC5C,gBAAgB;KACjB,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as i18n from '../../../core/i18n/i18n.js';\nimport * as ThirdPartyWeb from '../../../third_party/third-party-web/third-party-web.js';\nimport * as Extras from '../extras/extras.js';\nimport * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport type * as Types from '../types/types.js';\n\nimport {\n InsightCategory,\n InsightKeys,\n type InsightModel,\n type InsightSetContext,\n type PartialInsightModel,\n type RequiredData\n} from './types.js';\n\nexport const UIStrings = {\n /** Title of an insight that provides details about the code on a web page that the user doesn't control (referred to as \"third-party code\"). */\n title: '3rd parties',\n /**\n * @description Description of a DevTools insight that identifies the code on the page that the user doesn't control.\n * This is displayed after a user expands the section to see more. No character length limits.\n */\n description: '3rd party code can significantly impact load performance. ' +\n '[Reduce and defer loading of 3rd party code](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/loading-third-party-javascript/) to prioritize your page\\'s content.',\n /** Label for a table column that displays the name of a third-party provider. */\n columnThirdParty: '3rd party',\n /** Label for a column in a data table; entries will be the download size of a web resource in kilobytes. */\n columnTransferSize: 'Transfer size',\n /** Label for a table column that displays how much time each row spent running on the main thread, entries will be the number of milliseconds spent. */\n columnMainThreadTime: 'Main thread time',\n /**\n * @description Text block indicating that no third party content was detected on the page\n */\n noThirdParties: 'No third parties found',\n} as const;\n\nconst str_ = i18n.i18n.registerUIStrings('models/trace/insights/ThirdParties.ts', UIStrings);\nexport const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);\n\nexport function deps(): ['Meta', 'NetworkRequests', 'Renderer', 'ImagePainting'] {\n return ['Meta', 'NetworkRequests', 'Renderer', 'ImagePainting'];\n}\n\nexport type ThirdPartiesInsightModel = InsightModel<typeof UIStrings, {\n eventsByEntity: Map<Extras.ThirdParties.Entity, Types.Events.Event[]>,\n summaryByEntity: Map<Extras.ThirdParties.Entity, Extras.ThirdParties.Summary>,\n summaryByUrl: Map<string, Extras.ThirdParties.Summary>,\n urlsByEntity: Map<Extras.ThirdParties.Entity, Set<string>>,\n /** The entity for this navigation's URL. Any other entity is from a third party. */\n firstPartyEntity?: Extras.ThirdParties.Entity,\n}>;\n\nfunction getRelatedEvents(\n summaries: Extras.ThirdParties.ThirdPartySummary,\n firstPartyEntity: Extras.ThirdParties.Entity|undefined): Types.Events.Event[] {\n const relatedEvents = [];\n\n for (const [entity, events] of summaries.eventsByEntity.entries()) {\n if (entity !== firstPartyEntity) {\n relatedEvents.push(...events);\n }\n }\n\n return relatedEvents;\n}\n\nfunction finalize(partialModel: PartialInsightModel<ThirdPartiesInsightModel>): ThirdPartiesInsightModel {\n return {\n insightKey: InsightKeys.THIRD_PARTIES,\n strings: UIStrings,\n title: i18nString(UIStrings.title),\n description: i18nString(UIStrings.description),\n category: InsightCategory.ALL,\n state: [...partialModel.summaryByEntity.entries()].find(kv => kv[0] !== partialModel.firstPartyEntity) ?\n 'informative' :\n 'pass',\n ...partialModel,\n };\n}\n\nexport function generateInsight(\n parsedTrace: RequiredData<typeof deps>, context: InsightSetContext): ThirdPartiesInsightModel {\n const networkRequests = parsedTrace.NetworkRequests.byTime.filter(event => {\n if (!context.navigation) {\n return false;\n }\n\n if (event.args.data.frame !== context.frameId) {\n return false;\n }\n\n return Helpers.Timing.eventIsInBounds(event, context.bounds);\n });\n\n const thirdPartySummary = Extras.ThirdParties.summarizeThirdParties(\n parsedTrace as Handlers.Types.ParsedTrace, context.bounds, networkRequests);\n\n const firstPartyUrl = context.navigation?.args.data?.documentLoaderURL ?? parsedTrace.Meta.mainFrameURL;\n const firstPartyEntity = ThirdPartyWeb.ThirdPartyWeb.getEntity(firstPartyUrl) ||\n Handlers.Helpers.makeUpEntity(thirdPartySummary.madeUpEntityCache, firstPartyUrl);\n\n return finalize({\n relatedEvents: getRelatedEvents(thirdPartySummary, firstPartyEntity),\n eventsByEntity: thirdPartySummary.eventsByEntity,\n summaryByEntity: thirdPartySummary.byEntity,\n summaryByUrl: thirdPartySummary.byUrl,\n urlsByEntity: thirdPartySummary.urlsByEntity,\n firstPartyEntity,\n });\n}\n"]}
1
+ {"version":3,"file":"ThirdParties.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/ThirdParties.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE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,YAAY,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC;IAEtF,OAAO,QAAQ,CAAC;QACd,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,aAAa,EAAE,gBAAgB,CAAC,iBAAiB,EAAE,gBAAgB,CAAC;QACpE,cAAc,EAAE,iBAAiB,CAAC,cAAc;QAChD,eAAe,EAAE,iBAAiB,CAAC,QAAQ;QAC3C,YAAY,EAAE,iBAAiB,CAAC,KAAK;QACrC,YAAY,EAAE,iBAAiB,CAAC,YAAY;QAC5C,gBAAgB;KACjB,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as i18n from '../../../core/i18n/i18n.js';\nimport * as ThirdPartyWeb from '../../../third_party/third-party-web/third-party-web.js';\nimport * as Extras from '../extras/extras.js';\nimport * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport type * as Types from '../types/types.js';\n\nimport {\n InsightCategory,\n InsightKeys,\n type InsightModel,\n type InsightSetContext,\n type PartialInsightModel,\n} from './types.js';\n\nexport const UIStrings = {\n /** Title of an insight that provides details about the code on a web page that the user doesn't control (referred to as \"third-party code\"). */\n title: '3rd parties',\n /**\n * @description Description of a DevTools insight that identifies the code on the page that the user doesn't control.\n * This is displayed after a user expands the section to see more. No character length limits.\n */\n description: '3rd party code can significantly impact load performance. ' +\n '[Reduce and defer loading of 3rd party code](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/loading-third-party-javascript/) to prioritize your page\\'s content.',\n /** Label for a table column that displays the name of a third-party provider. */\n columnThirdParty: '3rd party',\n /** Label for a column in a data table; entries will be the download size of a web resource in kilobytes. */\n columnTransferSize: 'Transfer size',\n /** Label for a table column that displays how much time each row spent running on the main thread, entries will be the number of milliseconds spent. */\n columnMainThreadTime: 'Main thread time',\n /**\n * @description Text block indicating that no third party content was detected on the page\n */\n noThirdParties: 'No third parties found',\n} as const;\n\nconst str_ = i18n.i18n.registerUIStrings('models/trace/insights/ThirdParties.ts', UIStrings);\nexport const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);\n\nexport type ThirdPartiesInsightModel = InsightModel<typeof UIStrings, {\n eventsByEntity: Map<Extras.ThirdParties.Entity, Types.Events.Event[]>,\n summaryByEntity: Map<Extras.ThirdParties.Entity, Extras.ThirdParties.Summary>,\n summaryByUrl: Map<string, Extras.ThirdParties.Summary>,\n urlsByEntity: Map<Extras.ThirdParties.Entity, Set<string>>,\n /** The entity for this navigation's URL. Any other entity is from a third party. */\n firstPartyEntity?: Extras.ThirdParties.Entity,\n}>;\n\nfunction getRelatedEvents(\n summaries: Extras.ThirdParties.ThirdPartySummary,\n firstPartyEntity: Extras.ThirdParties.Entity|undefined): Types.Events.Event[] {\n const relatedEvents = [];\n\n for (const [entity, events] of summaries.eventsByEntity.entries()) {\n if (entity !== firstPartyEntity) {\n relatedEvents.push(...events);\n }\n }\n\n return relatedEvents;\n}\n\nfunction finalize(partialModel: PartialInsightModel<ThirdPartiesInsightModel>): ThirdPartiesInsightModel {\n return {\n insightKey: InsightKeys.THIRD_PARTIES,\n strings: UIStrings,\n title: i18nString(UIStrings.title),\n description: i18nString(UIStrings.description),\n category: InsightCategory.ALL,\n state: [...partialModel.summaryByEntity.entries()].find(kv => kv[0] !== partialModel.firstPartyEntity) ?\n 'informative' :\n 'pass',\n ...partialModel,\n };\n}\n\nexport function generateInsight(\n parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContext): ThirdPartiesInsightModel {\n const networkRequests = parsedTrace.NetworkRequests.byTime.filter(event => {\n if (!context.navigation) {\n return false;\n }\n\n if (event.args.data.frame !== context.frameId) {\n return false;\n }\n\n return Helpers.Timing.eventIsInBounds(event, context.bounds);\n });\n\n const thirdPartySummary = Extras.ThirdParties.summarizeThirdParties(\n parsedTrace as Handlers.Types.ParsedTrace, context.bounds, networkRequests);\n\n const firstPartyUrl = context.navigation?.args.data?.documentLoaderURL ?? parsedTrace.Meta.mainFrameURL;\n const firstPartyEntity = ThirdPartyWeb.ThirdPartyWeb.getEntity(firstPartyUrl) ||\n Handlers.Helpers.makeUpEntity(thirdPartySummary.madeUpEntityCache, firstPartyUrl);\n\n return finalize({\n frameId: context.frameId,\n relatedEvents: getRelatedEvents(thirdPartySummary, firstPartyEntity),\n eventsByEntity: thirdPartySummary.eventsByEntity,\n summaryByEntity: thirdPartySummary.byEntity,\n summaryByUrl: thirdPartySummary.byUrl,\n urlsByEntity: thirdPartySummary.urlsByEntity,\n firstPartyEntity,\n });\n}\n"]}
@@ -1,5 +1,6 @@
1
+ import type * as Handlers from '../handlers/handlers.js';
1
2
  import type * as Types from '../types/types.js';
2
- import { type InsightModel, type InsightSetContext, type RequiredData } from './types.js';
3
+ import { type InsightModel, type InsightSetContext } from './types.js';
3
4
  export declare const UIStrings: {
4
5
  /** Title of an insight that provides details about if the page's viewport is optimized for mobile viewing. */
5
6
  readonly title: "Optimize viewport for mobile";
@@ -9,9 +10,8 @@ export declare const UIStrings: {
9
10
  readonly description: "Tap interactions may be [delayed by up to 300 ms](https://developer.chrome.com/blog/300ms-tap-delay-gone-away/) if the viewport is not optimized for mobile.";
10
11
  };
11
12
  export declare const i18nString: (id: string, values?: Record<string, string> | undefined) => Record<string, string>;
12
- export declare function deps(): ['Meta', 'UserInteractions'];
13
13
  export type ViewportInsightModel = InsightModel<typeof UIStrings, {
14
14
  mobileOptimized: boolean | null;
15
15
  viewportEvent?: Types.Events.ParseMetaViewport;
16
16
  }>;
17
- export declare function generateInsight(parsedTrace: RequiredData<typeof deps>, context: InsightSetContext): ViewportInsightModel;
17
+ export declare function generateInsight(parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContext): ViewportInsightModel;
@@ -14,9 +14,6 @@ export const UIStrings = {
14
14
  };
15
15
  // const str_ = i18n.i18n.registerUIStrings('models/trace/insights/Viewport.ts', UIStrings);
16
16
  export const i18nString = (i18nId, values) => ({i18nId, values}); // i18n.i18n.getLocalizedString.bind(undefined, str_);
17
- export function deps() {
18
- return ['Meta', 'UserInteractions'];
19
- }
20
17
  function finalize(partialModel) {
21
18
  return {
22
19
  insightKey: "Viewport" /* InsightKeys.VIEWPORT */,
@@ -29,29 +26,36 @@ function finalize(partialModel) {
29
26
  };
30
27
  }
31
28
  export function generateInsight(parsedTrace, context) {
29
+ const viewportEvent = parsedTrace.UserInteractions.parseMetaViewportEvents.find(event => {
30
+ if (event.args.data.frame !== context.frameId) {
31
+ return false;
32
+ }
33
+ return Helpers.Timing.eventIsInBounds(event, context.bounds);
34
+ });
32
35
  const compositorEvents = parsedTrace.UserInteractions.beginCommitCompositorFrameEvents.filter(event => {
33
36
  if (event.args.frame !== context.frameId) {
34
37
  return false;
35
38
  }
39
+ // Commit compositor frame events can be emitted before the viewport tag is parsed.
40
+ // We shouldn't count these since the browser hasn't had time to make the viewport mobile optimized.
41
+ if (viewportEvent && event.ts < viewportEvent.ts) {
42
+ return false;
43
+ }
36
44
  return Helpers.Timing.eventIsInBounds(event, context.bounds);
37
45
  });
38
46
  if (!compositorEvents.length) {
39
47
  // Trace doesn't have the data we need.
40
48
  return finalize({
49
+ frameId: context.frameId,
41
50
  mobileOptimized: null,
42
51
  warnings: [InsightWarning.NO_LAYOUT],
43
52
  });
44
53
  }
45
- const viewportEvent = parsedTrace.UserInteractions.parseMetaViewportEvents.find(event => {
46
- if (event.args.data.frame !== context.frameId) {
47
- return false;
48
- }
49
- return Helpers.Timing.eventIsInBounds(event, context.bounds);
50
- });
51
54
  // Returns true only if all events are mobile optimized.
52
55
  for (const event of compositorEvents) {
53
56
  if (!event.args.is_mobile_optimized) {
54
57
  return finalize({
58
+ frameId: context.frameId,
55
59
  mobileOptimized: false,
56
60
  viewportEvent,
57
61
  metricSavings: { INP: 300 },
@@ -59,6 +63,7 @@ export function generateInsight(parsedTrace, context) {
59
63
  }
60
64
  }
61
65
  return finalize({
66
+ frameId: context.frameId,
62
67
  mobileOptimized: true,
63
68
  viewportEvent,
64
69
  });
@@ -1 +1 @@
1
- {"version":3,"file":"Viewport.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/Viewport.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AAGjD,OAAO,EACL,eAAe,EAIf,cAAc,GAGf,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,8GAA8G;IAC9G,KAAK,EAAE,8BAA8B;IACrC;;OAEG;IACH,WAAW,EACP,iKAAiK;CAC7J,CAAC;AAEX,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,mCAAmC,EAAE,SAAS,CAAC,CAAC;AACzF,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AAE7E,MAAM,UAAU,IAAI;IAClB,OAAO,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;AACtC,CAAC;AAOD,SAAS,QAAQ,CAAC,YAAuD;IACvE,OAAO;QACL,UAAU,uCAAsB;QAChC,OAAO,EAAE,SAAS;QAClB,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC;QAClC,WAAW,EAAE,UAAU,CAAC,SAAS,CAAC,WAAW,CAAC;QAC9C,QAAQ,EAAE,eAAe,CAAC,GAAG;QAC7B,KAAK,EAAE,YAAY,CAAC,eAAe,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;QAC/D,GAAG,YAAY;KAChB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAC3B,WAAsC,EAAE,OAA0B;IACpE,MAAM,gBAAgB,GAAG,WAAW,CAAC,gBAA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SD-style license that can be\n// found in the LICENSE file.\n\nimport * as i18n from '../../../core/i18n/i18n.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport type * as Types from '../types/types.js';\n\nimport {\n InsightCategory,\n InsightKeys,\n type InsightModel,\n type InsightSetContext,\n InsightWarning,\n type PartialInsightModel,\n type RequiredData,\n} from './types.js';\n\nexport const UIStrings = {\n /** Title of an insight that provides details about if the page's viewport is optimized for mobile viewing. */\n title: 'Optimize viewport for mobile',\n /**\n * @description Text to tell the user how a viewport meta element can improve performance. \\xa0 is a non-breaking space\n */\n description:\n 'Tap interactions may be [delayed by up to 300\\xA0ms](https://developer.chrome.com/blog/300ms-tap-delay-gone-away/) if the viewport is not optimized for mobile.',\n} as const;\n\nconst str_ = i18n.i18n.registerUIStrings('models/trace/insights/Viewport.ts', UIStrings);\nexport const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);\n\nexport function deps(): ['Meta', 'UserInteractions'] {\n return ['Meta', 'UserInteractions'];\n}\n\nexport type ViewportInsightModel = InsightModel<typeof UIStrings, {\n mobileOptimized: boolean | null,\n viewportEvent?: Types.Events.ParseMetaViewport,\n}>;\n\nfunction finalize(partialModel: PartialInsightModel<ViewportInsightModel>): ViewportInsightModel {\n return {\n insightKey: InsightKeys.VIEWPORT,\n strings: UIStrings,\n title: i18nString(UIStrings.title),\n description: i18nString(UIStrings.description),\n category: InsightCategory.INP,\n state: partialModel.mobileOptimized === false ? 'fail' : 'pass',\n ...partialModel,\n };\n}\n\nexport function generateInsight(\n parsedTrace: RequiredData<typeof deps>, context: InsightSetContext): ViewportInsightModel {\n const compositorEvents = parsedTrace.UserInteractions.beginCommitCompositorFrameEvents.filter(event => {\n if (event.args.frame !== context.frameId) {\n return false;\n }\n\n return Helpers.Timing.eventIsInBounds(event, context.bounds);\n });\n\n if (!compositorEvents.length) {\n // Trace doesn't have the data we need.\n return finalize({\n mobileOptimized: null,\n warnings: [InsightWarning.NO_LAYOUT],\n });\n }\n\n const viewportEvent = parsedTrace.UserInteractions.parseMetaViewportEvents.find(event => {\n if (event.args.data.frame !== context.frameId) {\n return false;\n }\n\n return Helpers.Timing.eventIsInBounds(event, context.bounds);\n });\n\n // Returns true only if all events are mobile optimized.\n for (const event of compositorEvents) {\n if (!event.args.is_mobile_optimized) {\n return finalize({\n mobileOptimized: false,\n viewportEvent,\n metricSavings: {INP: 300 as Types.Timing.Milli},\n });\n }\n }\n\n return finalize({\n mobileOptimized: true,\n viewportEvent,\n });\n}\n"]}
1
+ {"version":3,"file":"Viewport.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/Viewport.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAC;AAEnD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AAGjD,OAAO,EACL,eAAe,EAIf,cAAc,GAEf,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,8GAA8G;IAC9G,KAAK,EAAE,8BAA8B;IACrC;;OAEG;IACH,WAAW,EACP,iKAAiK;CAC7J,CAAC;AAEX,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,mCAAmC,EAAE,SAAS,CAAC,CAAC;AACzF,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AAO7E,SAAS,QAAQ,CAAC,YAAuD;IACvE,OAAO;QACL,UAAU,uCAAsB;QAChC,OAAO,EAAE,SAAS;QAClB,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC;QAClC,WAAW,EAAE,UAAU,CAAC,SAAS,CAAC,WAAW,CAAC;QAC9C,QAAQ,EAAE,eAAe,CAAC,GAAG;QAC7B,KAAK,EAAE,YAAY,CAAC,eAAe,KAAK,KAAK,CAAC,CAAC,CAAC,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AC,KAAK,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACpC,OAAO,QAAQ,CAAC;gBACd,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,eAAe,EAAE,KAAK;gBACtB,aAAa;gBACb,aAAa,EAAE,EAAC,GAAG,EAAE,GAAyB,EAAC;aAChD,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;QACd,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,eAAe,EAAE,IAAI;QACrB,aAAa;KACd,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as i18n from '../../../core/i18n/i18n.js';\nimport type * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport type * as Types from '../types/types.js';\n\nimport {\n InsightCategory,\n InsightKeys,\n type InsightModel,\n type InsightSetContext,\n InsightWarning,\n type PartialInsightModel,\n} from './types.js';\n\nexport const UIStrings = {\n /** Title of an insight that provides details about if the page's viewport is optimized for mobile viewing. */\n title: 'Optimize viewport for mobile',\n /**\n * @description Text to tell the user how a viewport meta element can improve performance. \\xa0 is a non-breaking space\n */\n description:\n 'Tap interactions may be [delayed by up to 300\\xA0ms](https://developer.chrome.com/blog/300ms-tap-delay-gone-away/) if the viewport is not optimized for mobile.',\n} as const;\n\nconst str_ = i18n.i18n.registerUIStrings('models/trace/insights/Viewport.ts', UIStrings);\nexport const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);\n\nexport type ViewportInsightModel = InsightModel<typeof UIStrings, {\n mobileOptimized: boolean | null,\n viewportEvent?: Types.Events.ParseMetaViewport,\n}>;\n\nfunction finalize(partialModel: PartialInsightModel<ViewportInsightModel>): ViewportInsightModel {\n return {\n insightKey: InsightKeys.VIEWPORT,\n strings: UIStrings,\n title: i18nString(UIStrings.title),\n description: i18nString(UIStrings.description),\n category: InsightCategory.INP,\n state: partialModel.mobileOptimized === false ? 'fail' : 'pass',\n ...partialModel,\n };\n}\n\nexport function generateInsight(\n parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContext): ViewportInsightModel {\n const viewportEvent = parsedTrace.UserInteractions.parseMetaViewportEvents.find(event => {\n if (event.args.data.frame !== context.frameId) {\n return false;\n }\n\n return Helpers.Timing.eventIsInBounds(event, context.bounds);\n });\n\n const compositorEvents = parsedTrace.UserInteractions.beginCommitCompositorFrameEvents.filter(event => {\n if (event.args.frame !== context.frameId) {\n return false;\n }\n\n // Commit compositor frame events can be emitted before the viewport tag is parsed.\n // We shouldn't count these since the browser hasn't had time to make the viewport mobile optimized.\n if (viewportEvent && event.ts < viewportEvent.ts) {\n return false;\n }\n\n return Helpers.Timing.eventIsInBounds(event, context.bounds);\n });\n\n if (!compositorEvents.length) {\n // Trace doesn't have the data we need.\n return finalize({\n frameId: context.frameId,\n mobileOptimized: null,\n warnings: [InsightWarning.NO_LAYOUT],\n });\n }\n\n // Returns true only if all events are mobile optimized.\n for (const event of compositorEvents) {\n if (!event.args.is_mobile_optimized) {\n return finalize({\n frameId: context.frameId,\n mobileOptimized: false,\n viewportEvent,\n metricSavings: {INP: 300 as Types.Timing.Milli},\n });\n }\n }\n\n return finalize({\n frameId: context.frameId,\n mobileOptimized: true,\n viewportEvent,\n });\n}\n"]}
@@ -1,6 +1,5 @@
1
1
  // import type * as Common from '../../../core/common/common.js';
2
2
  import type * as Protocol from '../../../generated/protocol.js';
3
- import type * as Handlers from '../handlers/handlers.js';
4
3
  import type * as Lantern from '../lantern/lantern.js';
5
4
  import type * as Types from '../types/types.js';
6
5
  import type * as Models from './Models.js';
@@ -58,16 +57,17 @@ export declare enum InsightCategory {
58
57
  }
59
58
  export type RelatedEventsMap = Map<Types.Events.Event, string[]>;
60
59
  export type Checklist<Keys extends string> = Record<Keys, {
61
- label: {i18nId: string, values: {[key: string]: string|number}, formattedDefault: string};
60
+ label: {i18nId: string, values: Record<string, string|number>, formattedDefault: string};
62
61
  value: boolean;
63
62
  }>;
64
- export type InsightModel<UIStrings extends Record<string, string>, R extends Record<string, unknown>> = R & {
63
+ export type InsightModel<UIStrings extends Record<string, string> = Record<string, string>, ExtraDetail extends Record<string, unknown> = Record<string, unknown>> = ExtraDetail & {
64
+ frameId: string;
65
65
  /** Used internally to identify the type of a model, not shown visibly to users **/
66
66
  insightKey: keyof InsightModelsType;
67
67
  /** Not used within DevTools - this is for external consumers (like Lighthouse). */
68
68
  strings: UIStrings;
69
- title: {i18nId: string, values: {[key: string]: string|number}, formattedDefault: string};
70
- description: {i18nId: string, values: {[key: string]: string|number}, formattedDefault: string};
69
+ title: {i18nId: string, values: Record<string, string|number>, formattedDefault: string};
70
+ description: {i18nId: string, values: Record<string, string|number>, formattedDefault: string};
71
71
  category: InsightCategory;
72
72
  state: 'pass' | 'fail' | 'informative';
73
73
  relatedEvents?: RelatedEventsMap | Types.Events.Event[];
@@ -107,10 +107,6 @@ export type InsightModels = {
107
107
  * navigation to map it to. In this case `Types.Events.NO_NAVIGATION` is used for the key.
108
108
  */
109
109
  export type TraceInsightSets = Map<Types.Events.NavigationId, InsightSet>;
110
- /**
111
- * Represents the narrow set of dependencies defined by an insight's `deps()` function. `Meta` is always included regardless of `deps()`.
112
- */
113
- export type RequiredData<D extends () => Array<keyof typeof Handlers.ModelHandlers>> = Handlers.Types.EnabledHandlerDataWithMeta<Pick<typeof Handlers.ModelHandlers, ReturnType<D>[number]>>;
114
110
  export declare const enum InsightKeys {
115
111
  LCP_PHASES = "LCPPhases",
116
112
  INTERACTION_TO_NEXT_PAINT = "InteractionToNextPaint",
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/types.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAkD7B,MAAM,CAAN,IAAY,cAMX;AAND,WAAY,cAAc;IACxB,iCAAe,CAAA;IACf,mCAAiB,CAAA;IACjB,uEAAuE;IACvE,6DAA2C,CAAA;IAC3C,yCAAuB,CAAA;AACzB,CAAC,EANW,cAAc,KAAd,cAAc,QAMzB;AAYD,MAAM,CAAN,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,8BAAW,CAAA;IACX,8BAAW,CAAA;IACX,8BAAW,CAAA;IACX,8BAAW,CAAA;AACb,CAAC,EALW,eAAe,KAAf,eAAe,QAK1B","sourcesContent":["// Copyright 2024 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport type * as Common from '../../../core/common/common.js';\nimport type * as Protocol from '../../../generated/protocol.js';\nimport type * as Handlers from '../handlers/handlers.js';\nimport type * as Lantern from '../lantern/lantern.js';\nimport type * as Types from '../types/types.js';\n\nimport type * as Models from './Models.js';\n\n/**\n * Context for the portion of the trace an insight should look at.\n */\nexport type InsightSetContext = InsightSetContextWithoutNavigation|InsightSetContextWithNavigation;\n\nexport interface InsightSetContextWithoutNavigation {\n bounds: Types.Timing.TraceWindowMicro;\n frameId: string;\n navigation?: never;\n}\n\nexport interface InsightSetContextWithNavigation {\n bounds: Types.Timing.TraceWindowMicro;\n frameId: string;\n navigation: Types.Events.NavigationStart;\n navigationId: string;\n lantern?: LanternContext;\n}\n\nexport interface LanternContext {\n graph: Lantern.Graph.Node<Types.Events.SyntheticNetworkRequest>;\n simulator: Lantern.Simulation.Simulator<Types.Events.SyntheticNetworkRequest>;\n metrics: Record<string, Lantern.Metrics.MetricResult>;\n}\n\nexport interface ForcedReflowAggregatedData {\n topLevelFunctionCall: Types.Events.CallFrame|Protocol.Runtime.CallFrame;\n totalReflowTime: number;\n bottomUpData: Set<string>;\n topLevelFunctionCallEvents: Types.Events.Event[];\n}\n\nexport interface BottomUpCallStack {\n bottomUpData: Types.Events.CallFrame|Protocol.Runtime.CallFrame;\n totalTime: number;\n relatedEvents: Types.Events.Event[];\n}\n\nexport type InsightModelsType = typeof Models;\n\nexport enum InsightWarning {\n NO_FP = 'NO_FP',\n NO_LCP = 'NO_LCP',\n // No network request could be identified as the primary HTML document.\n NO_DOCUMENT_REQUEST = 'NO_DOCUMENT_REQUEST',\n NO_LAYOUT = 'NO_LAYOUT',\n}\n\nexport interface MetricSavings {\n /* eslint-disable @typescript-eslint/naming-convention */\n FCP?: Types.Timing.Milli;\n LCP?: Types.Timing.Milli;\n TBT?: Types.Timing.Milli;\n CLS?: number;\n INP?: Types.Timing.Milli;\n /* eslint-enable @typescript-eslint/naming-convention */\n}\n\nexport enum InsightCategory {\n ALL = 'All',\n INP = 'INP',\n LCP = 'LCP',\n CLS = 'CLS',\n}\n\nexport type RelatedEventsMap = Map<Types.Events.Event, string[]>;\n\nexport type Checklist<Keys extends string> = Record<Keys, {label: Common.UIString.LocalizedString, value: boolean}>;\n\nexport type InsightModel<UIStrings extends Record<string, string>, R extends Record<string, unknown>> = R&{\n /** Used internally to identify the type of a model, not shown visibly to users **/\n insightKey: keyof InsightModelsType,\n /** Not used within DevTools - this is for external consumers (like Lighthouse). */\n strings: UIStrings,\n title: Common.UIString.LocalizedString,\n description: Common.UIString.LocalizedString,\n category: InsightCategory,\n state: 'pass' | 'fail' | 'informative',\n relatedEvents?: RelatedEventsMap | Types.Events.Event[],\n warnings?: InsightWarning[],\n metricSavings?: MetricSavings,\n /**\n * If this insight is attached to a navigation, this stores its ID.\n */\n navigationId?: string,\n};\n\nexport type PartialInsightModel<T> =\n Omit<T, 'strings'|'title'|'description'|'category'|'state'|'insightKey'|'navigationId'>;\n\n/**\n * Contains insights for a specific navigation. If a trace began after a navigation already started,\n * this could instead represent the duration from the beginning of the trace up to the first recorded\n * navigation (or the end of the trace).\n */\nexport interface InsightSet {\n /** If for a navigation, this is the navigationId. Else it is Trace.Types.Events.NO_NAVIGATION. */\n id: Types.Events.NavigationId;\n /** The URL to show in the accordion list. */\n url: URL;\n frameId: string;\n bounds: Types.Timing.TraceWindowMicro;\n model: InsightModels;\n navigation?: Types.Events.NavigationStart;\n}\n\n/**\n * Contains insights for a specific insight set.\n */\nexport type InsightModels = {\n [I in keyof InsightModelsType]: ReturnType<InsightModelsType[I]['generateInsight']>;\n};\n\n/**\n * Contains insights for the entire trace. Insights are mostly grouped by `navigationId`, with one exception:\n *\n * If the analyzed trace started after the navigation, and has meaningful work with that span, there is no\n * navigation to map it to. In this case `Types.Events.NO_NAVIGATION` is used for the key.\n */\nexport type TraceInsightSets = Map<Types.Events.NavigationId, InsightSet>;\n\n/**\n * Represents the narrow set of dependencies defined by an insight's `deps()` function. `Meta` is always included regardless of `deps()`.\n */\nexport type RequiredData<D extends() => Array<keyof typeof Handlers.ModelHandlers>> =\n Handlers.Types.EnabledHandlerDataWithMeta<Pick<typeof Handlers.ModelHandlers, ReturnType<D>[number]>>;\n\nexport const enum InsightKeys {\n LCP_PHASES = 'LCPPhases',\n INTERACTION_TO_NEXT_PAINT = 'InteractionToNextPaint',\n CLS_CULPRITS = 'CLSCulprits',\n THIRD_PARTIES = 'ThirdParties',\n DOCUMENT_LATENCY = 'DocumentLatency',\n DOM_SIZE = 'DOMSize',\n DUPLICATE_JAVASCRIPT = 'DuplicateJavaScript',\n FONT_DISPLAY = 'FontDisplay',\n FORCED_REFLOW = 'ForcedReflow',\n IMAGE_DELIVERY = 'ImageDelivery',\n LCP_DISCOVERY = 'LCPDiscovery',\n NETWORK_DEPENDENCY_TREE = 'NetworkDependencyTree',\n RENDER_BLOCKING = 'RenderBlocking',\n SLOW_CSS_SELECTOR = 'SlowCSSSelector',\n VIEWPORT = 'Viewport',\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/types.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAiD7B,MAAM,CAAN,IAAY,cAMX;AAND,WAAY,cAAc;IACxB,iCAAe,CAAA;IACf,mCAAiB,CAAA;IACjB,uEAAuE;IACvE,6DAA2C,CAAA;IAC3C,yCAAuB,CAAA;AACzB,CAAC,EANW,cAAc,KAAd,cAAc,QAMzB;AAYD,MAAM,CAAN,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,8BAAW,CAAA;IACX,8BAAW,CAAA;IACX,8BAAW,CAAA;IACX,8BAAW,CAAA;AACb,CAAC,EALW,eAAe,KAAf,eAAe,QAK1B","sourcesContent":["// Copyright 2024 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport type * as Common from '../../../core/common/common.js';\nimport type * as Protocol from '../../../generated/protocol.js';\nimport type * as Lantern from '../lantern/lantern.js';\nimport type * as Types from '../types/types.js';\n\nimport type * as Models from './Models.js';\n\n/**\n * Context for the portion of the trace an insight should look at.\n */\nexport type InsightSetContext = InsightSetContextWithoutNavigation|InsightSetContextWithNavigation;\n\nexport interface InsightSetContextWithoutNavigation {\n bounds: Types.Timing.TraceWindowMicro;\n frameId: string;\n navigation?: never;\n}\n\nexport interface InsightSetContextWithNavigation {\n bounds: Types.Timing.TraceWindowMicro;\n frameId: string;\n navigation: Types.Events.NavigationStart;\n navigationId: string;\n lantern?: LanternContext;\n}\n\nexport interface LanternContext {\n graph: Lantern.Graph.Node<Types.Events.SyntheticNetworkRequest>;\n simulator: Lantern.Simulation.Simulator<Types.Events.SyntheticNetworkRequest>;\n metrics: Record<string, Lantern.Metrics.MetricResult>;\n}\n\nexport interface ForcedReflowAggregatedData {\n topLevelFunctionCall: Types.Events.CallFrame|Protocol.Runtime.CallFrame;\n totalReflowTime: number;\n bottomUpData: Set<string>;\n topLevelFunctionCallEvents: Types.Events.Event[];\n}\n\nexport interface BottomUpCallStack {\n bottomUpData: Types.Events.CallFrame|Protocol.Runtime.CallFrame;\n totalTime: number;\n relatedEvents: Types.Events.Event[];\n}\n\nexport type InsightModelsType = typeof Models;\n\nexport enum InsightWarning {\n NO_FP = 'NO_FP',\n NO_LCP = 'NO_LCP',\n // No network request could be identified as the primary HTML document.\n NO_DOCUMENT_REQUEST = 'NO_DOCUMENT_REQUEST',\n NO_LAYOUT = 'NO_LAYOUT',\n}\n\nexport interface MetricSavings {\n /* eslint-disable @typescript-eslint/naming-convention */\n FCP?: Types.Timing.Milli;\n LCP?: Types.Timing.Milli;\n TBT?: Types.Timing.Milli;\n CLS?: number;\n INP?: Types.Timing.Milli;\n /* eslint-enable @typescript-eslint/naming-convention */\n}\n\nexport enum InsightCategory {\n ALL = 'All',\n INP = 'INP',\n LCP = 'LCP',\n CLS = 'CLS',\n}\n\nexport type RelatedEventsMap = Map<Types.Events.Event, string[]>;\n\nexport type Checklist<Keys extends string> = Record<Keys, {label: Common.UIString.LocalizedString, value: boolean}>;\n\nexport type InsightModel<UIStrings extends Record<string, string> = Record<string, string>,\n ExtraDetail extends Record<string, unknown> = Record<string, unknown>> =\n ExtraDetail&{\n frameId: string,\n /** Used internally to identify the type of a model, not shown visibly to users **/\n insightKey: keyof InsightModelsType,\n /** Not used within DevTools - this is for external consumers (like Lighthouse). */\n strings: UIStrings,\n title: Common.UIString.LocalizedString,\n description: Common.UIString.LocalizedString,\n category: InsightCategory,\n state: 'pass' | 'fail' | 'informative',\n relatedEvents?: RelatedEventsMap | Types.Events.Event[],\n warnings?: InsightWarning[],\n metricSavings?: MetricSavings,\n /**\n * If this insight is attached to a navigation, this stores its ID.\n */\n navigationId?: string,\n };\n\nexport type PartialInsightModel<T> =\n Omit<T, 'strings'|'title'|'description'|'category'|'state'|'insightKey'|'navigationId'>;\n\n/**\n * Contains insights for a specific navigation. If a trace began after a navigation already started,\n * this could instead represent the duration from the beginning of the trace up to the first recorded\n * navigation (or the end of the trace).\n */\nexport interface InsightSet {\n /** If for a navigation, this is the navigationId. Else it is Trace.Types.Events.NO_NAVIGATION. */\n id: Types.Events.NavigationId;\n /** The URL to show in the accordion list. */\n url: URL;\n frameId: string;\n bounds: Types.Timing.TraceWindowMicro;\n model: InsightModels;\n navigation?: Types.Events.NavigationStart;\n}\n\n/**\n * Contains insights for a specific insight set.\n */\nexport type InsightModels = {\n [I in keyof InsightModelsType]: ReturnType<InsightModelsType[I]['generateInsight']>;\n};\n\n/**\n * Contains insights for the entire trace. Insights are mostly grouped by `navigationId`, with one exception:\n *\n * If the analyzed trace started after the navigation, and has meaningful work with that span, there is no\n * navigation to map it to. In this case `Types.Events.NO_NAVIGATION` is used for the key.\n */\nexport type TraceInsightSets = Map<Types.Events.NavigationId, InsightSet>;\n\nexport const enum InsightKeys {\n LCP_PHASES = 'LCPPhases',\n INTERACTION_TO_NEXT_PAINT = 'InteractionToNextPaint',\n CLS_CULPRITS = 'CLSCulprits',\n THIRD_PARTIES = 'ThirdParties',\n DOCUMENT_LATENCY = 'DocumentLatency',\n DOM_SIZE = 'DOMSize',\n DUPLICATE_JAVASCRIPT = 'DuplicateJavaScript',\n FONT_DISPLAY = 'FontDisplay',\n FORCED_REFLOW = 'ForcedReflow',\n IMAGE_DELIVERY = 'ImageDelivery',\n LCP_DISCOVERY = 'LCPDiscovery',\n NETWORK_DEPENDENCY_TREE = 'NetworkDependencyTree',\n RENDER_BLOCKING = 'RenderBlocking',\n SLOW_CSS_SELECTOR = 'SlowCSSSelector',\n VIEWPORT = 'Viewport',\n}\n"]}
@@ -146,6 +146,14 @@ export interface MetaData {
146
146
  enhancedTraceVersion?: number;
147
147
  modifications?: Modifications;
148
148
  cruxFieldData?: any[];
149
+ /** Currently only stores JS maps, not CSS. This never stores data url source maps. */
150
+ sourceMaps?: MetadataSourceMap[];
151
+ }
152
+ interface MetadataSourceMap {
153
+ url: string;
154
+ sourceMapUrl: string;
155
+ sourceMap: any;
149
156
  }
150
157
  export type Contents = TraceFile | Event[];
151
158
  export declare function traceEventKeyToValues(key: SerializableKey): SerializableKeyValues;
159
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"File.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/types/File.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAgH7B,MAAM,UAAU,qBAAqB,CAAC,UAAsB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AAC,CAAC;IACvD,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2023 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport type * as SDK from '../../../core/sdk/sdk.js';\nimport type * as Protocol from '../../../generated/protocol.js';\nimport type * as CrUXManager from '../../../models/crux-manager/crux-manager.js';\n\nimport type {TraceWindowMicro} from './Timing.js';\nimport type {Event, LegacyTimelineFrame, ProcessID, SampleIndex, ThreadID} from './TraceEvents.js';\n\nexport interface TraceFile {\n traceEvents: readonly Event[];\n metadata: MetaData;\n}\n\nexport interface Breadcrumb {\n window: TraceWindowMicro;\n child: Breadcrumb|null;\n}\n\nexport const enum DataOrigin {\n CPU_PROFILE = 'CPUProfile',\n TRACE_EVENTS = 'TraceEvents',\n}\n\n/**\n * The Entries link can have 3 stated:\n * 1. The Link creation is not started yet, meaning only the button that needs to be clicked to start creating the link is visible.\n * 2. Pending to event - the creation is started, but the entry that the link points to has not been chosen yet\n * 3. Link connected - final state, both entries present\n */\nexport const enum EntriesLinkState {\n CREATION_NOT_STARTED = 'creation_not_started',\n PENDING_TO_EVENT = 'pending_to_event',\n CONNECTED = 'connected',\n}\n\nexport const enum EventKeyType {\n RAW_EVENT = 'r',\n SYNTHETIC_EVENT = 's',\n PROFILE_CALL = 'p',\n LEGACY_TIMELINE_FRAME = 'l',\n}\n\n/**\n * Represents an object that is saved in the file when user created annotations in the timeline.\n *\n * Expected to add more annotations.\n */\nexport interface SerializedAnnotations {\n entryLabels: EntryLabelAnnotationSerialized[];\n labelledTimeRanges: TimeRangeAnnotationSerialized[];\n linksBetweenEntries: EntriesLinkAnnotationSerialized[];\n}\n\n/**\n * Represents an object that is used to store the Entry Label annotation that is created when a user creates a label for an entry in the timeline.\n */\nexport interface EntryLabelAnnotation {\n type: 'ENTRY_LABEL';\n entry: Event|LegacyTimelineFrame;\n label: string;\n}\n\n/**\n * Represents an object that is used to store the Labelled Time Range Annotation that is created when a user creates a Time Range Selection in the timeline.\n */\nexport interface TimeRangeAnnotation {\n type: 'TIME_RANGE';\n label: string;\n bounds: TraceWindowMicro;\n}\n\nexport interface EntriesLinkAnnotation {\n type: 'ENTRIES_LINK';\n state: EntriesLinkState;\n entryFrom: Event;\n entryTo?: Event;\n}\n\n/**\n * Represents an object that is saved in the file when a user creates a label for an entry in the timeline.\n */\nexport interface EntryLabelAnnotationSerialized {\n entry: SerializableKey;\n label: string;\n}\n\n/**\n * Represents an object that is saved in the file when a user creates a time range with a label in the timeline.\n */\nexport interface TimeRangeAnnotationSerialized {\n bounds: TraceWindowMicro;\n label: string;\n}\n\n/**\n * Represents an object that is saved in the file when a user creates a link between entries in the timeline.\n */\nexport interface EntriesLinkAnnotationSerialized {\n entryFrom: SerializableKey;\n entryTo: SerializableKey;\n}\n\n/**\n * `Annotation` are the user-created annotations that are saved into the metadata.\n * Those annotations are rendered on the timeline by `Overlays.ts`\n *\n * TODO: Implement other OverlayAnnotations (annotated time ranges, links between entries).\n * TODO: Save/load overlay annotations to/from the trace file.\n */\nexport type Annotation = EntryLabelAnnotation|TimeRangeAnnotation|EntriesLinkAnnotation;\n\nexport function isTimeRangeAnnotation(annotation: Annotation): annotation is TimeRangeAnnotation {\n return annotation.type === 'TIME_RANGE';\n}\n\nexport function isEntryLabelAnnotation(annotation: Annotation): annotation is EntryLabelAnnotation {\n return annotation.type === 'ENTRY_LABEL';\n}\n\nexport function isEntriesLinkAnnotation(annotation: Annotation): annotation is EntriesLinkAnnotation {\n return annotation.type === 'ENTRIES_LINK';\n}\n\n// Serializable keys are created for trace events to be able to save\n// references to timeline events in a trace file. These keys enable\n// user modifications that can be saved. See go/cpq:event-data-json for\n// more details on the key format.\nexport type RawEventKey = `${EventKeyType.RAW_EVENT}-${number}`;\nexport type SyntheticEventKey = `${EventKeyType.SYNTHETIC_EVENT}-${number}`;\nexport type ProfileCallKey = `${EventKeyType.PROFILE_CALL}-${ProcessID}-${ThreadID}-${SampleIndex}-${Protocol.integer}`;\nexport type LegacyTimelineFrameKey = `${EventKeyType.LEGACY_TIMELINE_FRAME}-${number}`;\nexport type SerializableKey = RawEventKey|ProfileCallKey|SyntheticEventKey|LegacyTimelineFrameKey;\n\n// Serializable keys values objects contain data that maps the keys to original Trace Events\nexport interface RawEventKeyValues {\n type: EventKeyType.RAW_EVENT;\n rawIndex: number;\n}\n\nexport interface SyntheticEventKeyValues {\n type: EventKeyType.SYNTHETIC_EVENT;\n rawIndex: number;\n}\n\nexport interface ProfileCallKeyValues {\n type: EventKeyType.PROFILE_CALL;\n processID: ProcessID;\n threadID: ThreadID;\n sampleIndex: SampleIndex;\n protocol: Protocol.integer;\n}\n\nexport interface LegacyTimelineFrameKeyValues {\n type: EventKeyType.LEGACY_TIMELINE_FRAME;\n rawIndex: number;\n}\n\nexport type SerializableKeyValues =\n RawEventKeyValues|ProfileCallKeyValues|SyntheticEventKeyValues|LegacyTimelineFrameKeyValues;\n\nexport interface Modifications {\n entriesModifications: {\n // Entries hidden by the user\n hiddenEntries: SerializableKey[],\n // Entries that parent a hiddenEntry\n expandableEntries: SerializableKey[],\n };\n initialBreadcrumb: Breadcrumb;\n annotations: SerializedAnnotations;\n}\n\n/**\n * Trace metadata that we persist to the file. This will allow us to\n * store specifics for the trace, e.g., which tracks should be visible\n * on load.\n */\nexport interface MetaData {\n source?: 'DevTools';\n startTime?: string;\n emulatedDeviceTitle?: string;\n // Only set if network throttling is active.\n networkThrottling?: string;\n // Only set if network throttling is active.\n networkThrottlingConditions?: Omit<SDK.NetworkManager.Conditions, 'title'>;\n // Only set if CPU throttling is active.\n cpuThrottling?: number;\n hardwareConcurrency?: number;\n dataOrigin?: DataOrigin;\n enhancedTraceVersion?: number;\n modifications?: Modifications;\n cruxFieldData?: CrUXManager.PageResult[];\n}\n\nexport type Contents = TraceFile|Event[];\n\nexport function traceEventKeyToValues(key: SerializableKey): SerializableKeyValues {\n const parts = key.split('-');\n const type = parts[0];\n\n switch (type) {\n case EventKeyType.PROFILE_CALL:\n if (parts.length !== 5 ||\n !(parts.every((part, i) => i === 0 || typeof part === 'number' || !isNaN(parseInt(part, 10))))) {\n throw new Error(`Invalid ProfileCallKey: ${key}`);\n }\n return {\n type: parts[0],\n processID: parseInt(parts[1], 10),\n threadID: parseInt(parts[2], 10),\n sampleIndex: parseInt(parts[3], 10),\n protocol: parseInt(parts[4], 10),\n } as ProfileCallKeyValues;\n case EventKeyType.RAW_EVENT:\n if (parts.length !== 2 || !(typeof parts[1] === 'number' || !isNaN(parseInt(parts[1], 10)))) {\n throw new Error(`Invalid RawEvent Key: ${key}`);\n }\n return {\n type: parts[0],\n rawIndex: parseInt(parts[1], 10),\n } as RawEventKeyValues;\n case EventKeyType.SYNTHETIC_EVENT:\n if (parts.length !== 2 || !(typeof parts[1] === 'number' || !isNaN(parseInt(parts[1], 10)))) {\n throw new Error(`Invalid SyntheticEvent Key: ${key}`);\n }\n return {\n type: parts[0],\n rawIndex: parseInt(parts[1], 10),\n } as SyntheticEventKeyValues;\n case EventKeyType.LEGACY_TIMELINE_FRAME: {\n if (parts.length !== 2 || Number.isNaN(parseInt(parts[1], 10))) {\n throw new Error(`Invalid LegacyTimelineFrame Key: ${key}`);\n }\n return {\n type,\n rawIndex: parseInt(parts[1], 10),\n };\n }\n\n default:\n throw new Error(`Unknown trace event key: ${key}`);\n }\n}\n"]}
1
+ {"version":3,"file":"File.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/types/File.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAgH7B,MAAM,UAAU,qBAAqB,CAAC,UAAsB;IAC1D,OAAO,UAAU,CAAC,IAAI,KAAK,YAAY,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,UAAsB;IAC3D,OAAO,UAAU,CAAC,IAAI,KAAK,aAAa,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,UAAsB;IAC5D,OAAO,UAAU,CAAC,IAAI,KAAK,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gBACL,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;gBACd,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;aACZ,CAAC;QACzB;YACE,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC5F,MAAM,IAAI,KAAK,CAAC,+BAA+B,GAAG,EAAE,CAAC,CAAC;YACxD,CAAC;YACD,OAAO;gBACL,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;gBACd,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;aACN,CAAC;QAC/B,iDAAuC,CAAC,CAAC,CAAC;YACxC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC;gBAC/D,MAAM,IAAI,KAAK,CAAC,oCAAoC,GAAG,EAAE,CAAC,CAAC;YAC7D,CAAC;YACD,OAAO;gBACL,IAAI;gBACJ,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;aACjC,CAAC;QACJ,CAAC;QAED;YACE,MAAM,IAAI,KAAK,CAAC,4BAA4B,GAAG,EAAE,CAAC,CAAC;IACvD,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2023 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport type * as SDK from '../../../core/sdk/sdk.js';\nimport type * as Protocol from '../../../generated/protocol.js';\nimport type * as CrUXManager from '../../../models/crux-manager/crux-manager.js';\n\nimport type {TraceWindowMicro} from './Timing.js';\nimport type {Event, LegacyTimelineFrame, ProcessID, SampleIndex, ThreadID} from './TraceEvents.js';\n\nexport interface TraceFile {\n traceEvents: readonly Event[];\n metadata: MetaData;\n}\n\nexport interface Breadcrumb {\n window: TraceWindowMicro;\n child: Breadcrumb|null;\n}\n\nexport const enum DataOrigin {\n CPU_PROFILE = 'CPUProfile',\n TRACE_EVENTS = 'TraceEvents',\n}\n\n/**\n * The Entries link can have 3 stated:\n * 1. The Link creation is not started yet, meaning only the button that needs to be clicked to start creating the link is visible.\n * 2. Pending to event - the creation is started, but the entry that the link points to has not been chosen yet\n * 3. Link connected - final state, both entries present\n */\nexport const enum EntriesLinkState {\n CREATION_NOT_STARTED = 'creation_not_started',\n PENDING_TO_EVENT = 'pending_to_event',\n CONNECTED = 'connected',\n}\n\nexport const enum EventKeyType {\n RAW_EVENT = 'r',\n SYNTHETIC_EVENT = 's',\n PROFILE_CALL = 'p',\n LEGACY_TIMELINE_FRAME = 'l',\n}\n\n/**\n * Represents an object that is saved in the file when user created annotations in the timeline.\n *\n * Expected to add more annotations.\n */\nexport interface SerializedAnnotations {\n entryLabels: EntryLabelAnnotationSerialized[];\n labelledTimeRanges: TimeRangeAnnotationSerialized[];\n linksBetweenEntries: EntriesLinkAnnotationSerialized[];\n}\n\n/**\n * Represents an object that is used to store the Entry Label annotation that is created when a user creates a label for an entry in the timeline.\n */\nexport interface EntryLabelAnnotation {\n type: 'ENTRY_LABEL';\n entry: Event|LegacyTimelineFrame;\n label: string;\n}\n\n/**\n * Represents an object that is used to store the Labelled Time Range Annotation that is created when a user creates a Time Range Selection in the timeline.\n */\nexport interface TimeRangeAnnotation {\n type: 'TIME_RANGE';\n label: string;\n bounds: TraceWindowMicro;\n}\n\nexport interface EntriesLinkAnnotation {\n type: 'ENTRIES_LINK';\n state: EntriesLinkState;\n entryFrom: Event;\n entryTo?: Event;\n}\n\n/**\n * Represents an object that is saved in the file when a user creates a label for an entry in the timeline.\n */\nexport interface EntryLabelAnnotationSerialized {\n entry: SerializableKey;\n label: string;\n}\n\n/**\n * Represents an object that is saved in the file when a user creates a time range with a label in the timeline.\n */\nexport interface TimeRangeAnnotationSerialized {\n bounds: TraceWindowMicro;\n label: string;\n}\n\n/**\n * Represents an object that is saved in the file when a user creates a link between entries in the timeline.\n */\nexport interface EntriesLinkAnnotationSerialized {\n entryFrom: SerializableKey;\n entryTo: SerializableKey;\n}\n\n/**\n * `Annotation` are the user-created annotations that are saved into the metadata.\n * Those annotations are rendered on the timeline by `Overlays.ts`\n *\n * TODO: Implement other OverlayAnnotations (annotated time ranges, links between entries).\n * TODO: Save/load overlay annotations to/from the trace file.\n */\nexport type Annotation = EntryLabelAnnotation|TimeRangeAnnotation|EntriesLinkAnnotation;\n\nexport function isTimeRangeAnnotation(annotation: Annotation): annotation is TimeRangeAnnotation {\n return annotation.type === 'TIME_RANGE';\n}\n\nexport function isEntryLabelAnnotation(annotation: Annotation): annotation is EntryLabelAnnotation {\n return annotation.type === 'ENTRY_LABEL';\n}\n\nexport function isEntriesLinkAnnotation(annotation: Annotation): annotation is EntriesLinkAnnotation {\n return annotation.type === 'ENTRIES_LINK';\n}\n\n// Serializable keys are created for trace events to be able to save\n// references to timeline events in a trace file. These keys enable\n// user modifications that can be saved. See go/cpq:event-data-json for\n// more details on the key format.\nexport type RawEventKey = `${EventKeyType.RAW_EVENT}-${number}`;\nexport type SyntheticEventKey = `${EventKeyType.SYNTHETIC_EVENT}-${number}`;\nexport type ProfileCallKey = `${EventKeyType.PROFILE_CALL}-${ProcessID}-${ThreadID}-${SampleIndex}-${Protocol.integer}`;\nexport type LegacyTimelineFrameKey = `${EventKeyType.LEGACY_TIMELINE_FRAME}-${number}`;\nexport type SerializableKey = RawEventKey|ProfileCallKey|SyntheticEventKey|LegacyTimelineFrameKey;\n\n// Serializable keys values objects contain data that maps the keys to original Trace Events\nexport interface RawEventKeyValues {\n type: EventKeyType.RAW_EVENT;\n rawIndex: number;\n}\n\nexport interface SyntheticEventKeyValues {\n type: EventKeyType.SYNTHETIC_EVENT;\n rawIndex: number;\n}\n\nexport interface ProfileCallKeyValues {\n type: EventKeyType.PROFILE_CALL;\n processID: ProcessID;\n threadID: ThreadID;\n sampleIndex: SampleIndex;\n protocol: Protocol.integer;\n}\n\nexport interface LegacyTimelineFrameKeyValues {\n type: EventKeyType.LEGACY_TIMELINE_FRAME;\n rawIndex: number;\n}\n\nexport type SerializableKeyValues =\n RawEventKeyValues|ProfileCallKeyValues|SyntheticEventKeyValues|LegacyTimelineFrameKeyValues;\n\nexport interface Modifications {\n entriesModifications: {\n // Entries hidden by the user\n hiddenEntries: SerializableKey[],\n // Entries that parent a hiddenEntry\n expandableEntries: SerializableKey[],\n };\n initialBreadcrumb: Breadcrumb;\n annotations: SerializedAnnotations;\n}\n\n/**\n * Trace metadata that we persist to the file. This will allow us to\n * store specifics for the trace, e.g., which tracks should be visible\n * on load.\n */\nexport interface MetaData {\n source?: 'DevTools';\n startTime?: string;\n emulatedDeviceTitle?: string;\n // Only set if network throttling is active.\n networkThrottling?: string;\n // Only set if network throttling is active.\n networkThrottlingConditions?: Omit<SDK.NetworkManager.Conditions, 'title'>;\n // Only set if CPU throttling is active.\n cpuThrottling?: number;\n hardwareConcurrency?: number;\n dataOrigin?: DataOrigin;\n enhancedTraceVersion?: number;\n modifications?: Modifications;\n cruxFieldData?: CrUXManager.PageResult[];\n /** Currently only stores JS maps, not CSS. This never stores data url source maps. */\n sourceMaps?: MetadataSourceMap[];\n}\n\ninterface MetadataSourceMap {\n url: string;\n sourceMapUrl: string;\n sourceMap: SDK.SourceMap.SourceMapV3;\n}\n\nexport type Contents = TraceFile|Event[];\n\nexport function traceEventKeyToValues(key: SerializableKey): SerializableKeyValues {\n const parts = key.split('-');\n const type = parts[0];\n\n switch (type) {\n case EventKeyType.PROFILE_CALL:\n if (parts.length !== 5 ||\n !(parts.every((part, i) => i === 0 || typeof part === 'number' || !isNaN(parseInt(part, 10))))) {\n throw new Error(`Invalid ProfileCallKey: ${key}`);\n }\n return {\n type: parts[0],\n processID: parseInt(parts[1], 10),\n threadID: parseInt(parts[2], 10),\n sampleIndex: parseInt(parts[3], 10),\n protocol: parseInt(parts[4], 10),\n } as ProfileCallKeyValues;\n case EventKeyType.RAW_EVENT:\n if (parts.length !== 2 || !(typeof parts[1] === 'number' || !isNaN(parseInt(parts[1], 10)))) {\n throw new Error(`Invalid RawEvent Key: ${key}`);\n }\n return {\n type: parts[0],\n rawIndex: parseInt(parts[1], 10),\n } as RawEventKeyValues;\n case EventKeyType.SYNTHETIC_EVENT:\n if (parts.length !== 2 || !(typeof parts[1] === 'number' || !isNaN(parseInt(parts[1], 10)))) {\n throw new Error(`Invalid SyntheticEvent Key: ${key}`);\n }\n return {\n type: parts[0],\n rawIndex: parseInt(parts[1], 10),\n } as SyntheticEventKeyValues;\n case EventKeyType.LEGACY_TIMELINE_FRAME: {\n if (parts.length !== 2 || Number.isNaN(parseInt(parts[1], 10))) {\n throw new Error(`Invalid LegacyTimelineFrame Key: ${key}`);\n }\n return {\n type,\n rawIndex: parseInt(parts[1], 10),\n };\n }\n\n default:\n throw new Error(`Unknown trace event key: ${key}`);\n }\n}\n"]}
@@ -66,7 +66,7 @@ export interface CallFrame {
66
66
  lineNumber: number;
67
67
  url: string;
68
68
  }
69
- export declare function objectIsCallFrame(object: {}): object is CallFrame;
69
+ export declare function objectIsCallFrame(object: object): object is CallFrame;
70
70
  export interface TraceFrame {
71
71
  frame: string;
72
72
  name: string;
@@ -1092,6 +1092,14 @@ export interface BeginRemoteFontLoad extends UserTiming {
1092
1092
  args: Args & {
1093
1093
  display: string;
1094
1094
  id: number;
1095
+ url?: string;
1096
+ };
1097
+ }
1098
+ export interface RemoteFontLoaded extends UserTiming {
1099
+ name: Name.REMOTE_FONT_LOADED;
1100
+ args: Args & {
1101
+ url: string;
1102
+ name: string;
1095
1103
  };
1096
1104
  }
1097
1105
  export type PairableUserTiming = UserTiming & PairableAsync;
@@ -1606,6 +1614,7 @@ export declare function isSyntheticConsoleTiming(event: Event): event is Synthet
1606
1614
  export declare function isUserTiming(event: Event): event is UserTiming;
1607
1615
  export declare function isDomLoading(event: Event): event is DomLoading;
1608
1616
  export declare function isBeginRemoteFontLoad(event: Event): event is BeginRemoteFontLoad;
1617
+ export declare function isRemoteFontLoaded(event: Event): event is RemoteFontLoaded;
1609
1618
  export declare function isPerformanceMeasure(event: Event): event is PerformanceMeasure;
1610
1619
  export declare function isPerformanceMeasureBegin(event: Event): event is PerformanceMeasureBegin;
1611
1620
  export declare function isPerformanceMark(event: Event): event is PerformanceMark;
@@ -1639,10 +1648,15 @@ export interface PaintImage extends Complete {
1639
1648
  width: number;
1640
1649
  x: number;
1641
1650
  y: number;
1651
+ isCSS: boolean;
1652
+ isPicture?: boolean;
1653
+ loadingAttribute?: string;
1654
+ srcsetAttribute?: string;
1642
1655
  url?: string;
1643
1656
  srcHeight: number;
1644
1657
  srcWidth: number;
1645
1658
  nodeId?: Protocol.DOM.BackendNodeId;
1659
+ frame?: string;
1646
1660
  };
1647
1661
  };
1648
1662
  }
@@ -2152,6 +2166,7 @@ export declare const enum Name {
2152
2166
  LAYOUT_IMAGE_UNSIZED = "LayoutImageUnsized",
2153
2167
  DOM_LOADING = "domLoading",
2154
2168
  BEGIN_REMOTE_FONT_LOAD = "BeginRemoteFontLoad",
2169
+ REMOTE_FONT_LOADED = "RemoteFontLoaded",
2155
2170
  ANIMATION_FRAME = "AnimationFrame",
2156
2171
  ANIMATION_FRAME_PRESENTATION = "AnimationFrame::Presentation",
2157
2172
  SYNTHETIC_NETWORK_REQUEST = "SyntheticNetworkRequest",
@@ -406,6 +406,9 @@ export function isDomLoading(event) {
406
406
  export function isBeginRemoteFontLoad(event) {
407
407
  return event.name === "BeginRemoteFontLoad" /* Name.BEGIN_REMOTE_FONT_LOAD */;
408
408
  }
409
+ export function isRemoteFontLoaded(event) {
410
+ return event.name === "RemoteFontLoaded" /* Name.REMOTE_FONT_LOADED */;
411
+ }
409
412
  export function isPerformanceMeasure(event) {
410
413
  return isUserTiming(event) && isPhaseAsync(event.ph);
411
414
  }