@paulirish/trace_engine 0.0.13 → 0.0.15

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 (36) hide show
  1. package/core/platform/devtools_entrypoint-bundle-typescript-tsconfig.json +1 -2
  2. package/core/platform/platform-tsconfig.json +1 -2
  3. package/generated/protocol.d.ts +7 -1
  4. package/models/cpu_profile/cpu_profile-tsconfig.json +1 -2
  5. package/models/cpu_profile/devtools_entrypoint-bundle-typescript-tsconfig.json +1 -2
  6. package/models/trace/EntriesFilter.d.ts +4 -0
  7. package/models/trace/EntriesFilter.js +29 -6
  8. package/models/trace/EntriesFilter.js.map +1 -1
  9. package/models/trace/ModelImpl.d.ts +2 -2
  10. package/models/trace/ModelImpl.js.map +1 -1
  11. package/models/trace/Processor.d.ts +1 -1
  12. package/models/trace/Processor.js +8 -2
  13. package/models/trace/Processor.js.map +1 -1
  14. package/models/trace/devtools_entrypoint-bundle-typescript-tsconfig.json +1 -2
  15. package/models/trace/extras/devtools_entrypoint-bundle-typescript-tsconfig.json +1 -2
  16. package/models/trace/extras/extras-tsconfig.json +1 -2
  17. package/models/trace/handlers/devtools_entrypoint-bundle-typescript-tsconfig.json +1 -2
  18. package/models/trace/handlers/handlers-tsconfig.json +1 -2
  19. package/models/trace/helpers/devtools_entrypoint-bundle-typescript-tsconfig.json +1 -2
  20. package/models/trace/helpers/helpers-tsconfig.json +1 -2
  21. package/models/trace/insights/RenderBlocking.d.ts +4 -4
  22. package/models/trace/insights/RenderBlocking.js +19 -4
  23. package/models/trace/insights/RenderBlocking.js.map +1 -1
  24. package/models/trace/insights/devtools_entrypoint-bundle-typescript-tsconfig.json +1 -2
  25. package/models/trace/insights/insights-tsconfig.json +1 -2
  26. package/models/trace/insights/types.d.ts +20 -8
  27. package/models/trace/insights/types.js +4 -1
  28. package/models/trace/insights/types.js.map +1 -1
  29. package/models/trace/root-causes/devtools_entrypoint-bundle-typescript-tsconfig.json +1 -2
  30. package/models/trace/root-causes/root-causes-tsconfig.json +1 -2
  31. package/models/trace/trace-tsconfig.json +1 -2
  32. package/models/trace/types/Timing.js +0 -3
  33. package/models/trace/types/Timing.js.map +1 -1
  34. package/models/trace/types/devtools_entrypoint-bundle-typescript-tsconfig.json +1 -2
  35. package/models/trace/types/types-tsconfig.json +1 -2
  36. package/package.json +1 -4
@@ -33,8 +33,7 @@
33
33
  "../../../../../../front_end/legacy/legacy-defs.d.ts",
34
34
  "../../../../../../front_end/global_typings/global_defs.d.ts",
35
35
  "../../../../../../front_end/global_typings/request_idle_callback.d.ts",
36
- "../../../../../../node_modules/@types/filesystem/index.d.ts",
37
- "../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
36
+ "../../../../../../node_modules/@types/filesystem/index.d.ts"
38
37
  ],
39
38
  "references": [
40
39
  {
@@ -48,7 +48,6 @@
48
48
  "../../../../../../front_end/legacy/legacy-defs.d.ts",
49
49
  "../../../../../../front_end/global_typings/global_defs.d.ts",
50
50
  "../../../../../../front_end/global_typings/request_idle_callback.d.ts",
51
- "../../../../../../node_modules/@types/filesystem/index.d.ts",
52
- "../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
51
+ "../../../../../../node_modules/@types/filesystem/index.d.ts"
53
52
  ]
54
53
  }
@@ -928,7 +928,12 @@ export declare namespace Audits {
928
928
  InvalidRegisterOsTriggerHeader = "InvalidRegisterOsTriggerHeader",
929
929
  WebAndOsHeaders = "WebAndOsHeaders",
930
930
  NoWebOrOsSupport = "NoWebOrOsSupport",
931
- NavigationRegistrationWithoutTransientUserActivation = "NavigationRegistrationWithoutTransientUserActivation"
931
+ NavigationRegistrationWithoutTransientUserActivation = "NavigationRegistrationWithoutTransientUserActivation",
932
+ InvalidInfoHeader = "InvalidInfoHeader",
933
+ NoRegisterSourceHeader = "NoRegisterSourceHeader",
934
+ NoRegisterTriggerHeader = "NoRegisterTriggerHeader",
935
+ NoRegisterOsSourceHeader = "NoRegisterOsSourceHeader",
936
+ NoRegisterOsTriggerHeader = "NoRegisterOsTriggerHeader"
932
937
  }
933
938
  /**
934
939
  * Details for issues around "Attribution Reporting API" usage.
@@ -11038,6 +11043,7 @@ export declare namespace Page {
11038
11043
  SmartCard = "SmartCard",
11039
11044
  LiveMediaStreamTrack = "LiveMediaStreamTrack",
11040
11045
  UnloadHandler = "UnloadHandler",
11046
+ ParserAborted = "ParserAborted",
11041
11047
  ContentSecurityHandler = "ContentSecurityHandler",
11042
11048
  ContentWebAuthenticationAPI = "ContentWebAuthenticationAPI",
11043
11049
  ContentFileChooser = "ContentFileChooser",
@@ -34,8 +34,7 @@
34
34
  "../../../../../../front_end/legacy/legacy-defs.d.ts",
35
35
  "../../../../../../front_end/global_typings/global_defs.d.ts",
36
36
  "../../../../../../front_end/global_typings/request_idle_callback.d.ts",
37
- "../../../../../../node_modules/@types/filesystem/index.d.ts",
38
- "../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
37
+ "../../../../../../node_modules/@types/filesystem/index.d.ts"
39
38
  ],
40
39
  "references": [
41
40
  {
@@ -33,8 +33,7 @@
33
33
  "../../../../../../front_end/legacy/legacy-defs.d.ts",
34
34
  "../../../../../../front_end/global_typings/global_defs.d.ts",
35
35
  "../../../../../../front_end/global_typings/request_idle_callback.d.ts",
36
- "../../../../../../node_modules/@types/filesystem/index.d.ts",
37
- "../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
36
+ "../../../../../../node_modules/@types/filesystem/index.d.ts"
38
37
  ],
39
38
  "references": [
40
39
  {
@@ -45,6 +45,10 @@ export declare class EntriesFilter {
45
45
  * Returns the set of entries that are invisible given the set of applied actions.
46
46
  **/
47
47
  invisibleEntries(): Types.TraceEvents.TraceEventData[];
48
+ /**
49
+ * Returns the array of entries that have a sign indicating that entries below are hidden.
50
+ **/
51
+ modifiedEntries(): Types.TraceEvents.TraceEventData[];
48
52
  /**
49
53
  * Applies an action to hide entries or removes entries
50
54
  * from hidden entries array depending on the action.
@@ -77,6 +77,12 @@ export class EntriesFilter {
77
77
  invisibleEntries() {
78
78
  return this.#invisibleEntries;
79
79
  }
80
+ /**
81
+ * Returns the array of entries that have a sign indicating that entries below are hidden.
82
+ **/
83
+ modifiedEntries() {
84
+ return this.#modifiedVisibleEntries;
85
+ }
80
86
  /**
81
87
  * Applies an action to hide entries or removes entries
82
88
  * from hidden entries array depending on the action.
@@ -98,7 +104,7 @@ export class EntriesFilter {
98
104
  const actionNode = this.#entryToNode.get(action.entry) || null;
99
105
  const parentNode = actionNode && this.#findNextVisibleParent(actionNode);
100
106
  if (parentNode) {
101
- this.#modifiedVisibleEntries.push(parentNode?.entry);
107
+ this.#addModifiedEntry(parentNode.entry);
102
108
  }
103
109
  break;
104
110
  }
@@ -111,10 +117,7 @@ export class EntriesFilter {
111
117
  }
112
118
  const allDescendants = this.#findAllDescendantsOfNode(entryNode);
113
119
  allDescendants.forEach(descendant => entriesToHide.add(descendant));
114
- // If there are any children to hide, add selected entry to modifiedVisibleEntries array to identify in the UI that children of the selected entry are modified.
115
- if (entriesToHide.size > 0) {
116
- this.#modifiedVisibleEntries.push(action.entry);
117
- }
120
+ this.#addModifiedEntry(action.entry);
118
121
  break;
119
122
  }
120
123
  case "COLLAPSE_REPEATING_DESCENDANTS" /* FilterAction.COLLAPSE_REPEATING_DESCENDANTS */: {
@@ -126,7 +129,7 @@ export class EntriesFilter {
126
129
  const allRepeatingDescendants = this.#findAllRepeatingDescendantsOfNext(entryNode);
127
130
  allRepeatingDescendants.forEach(descendant => entriesToHide.add(descendant));
128
131
  if (entriesToHide.size > 0) {
129
- this.#modifiedVisibleEntries.push(action.entry);
132
+ this.#addModifiedEntry(action.entry);
130
133
  }
131
134
  break;
132
135
  }
@@ -145,6 +148,26 @@ export class EntriesFilter {
145
148
  this.#invisibleEntries.push(...entriesToHide);
146
149
  return this.#invisibleEntries;
147
150
  }
151
+ /**
152
+ * Add an entry to the array of entries that have a sign indicating that entries below are hidden.
153
+ * Also, remove all of the child entries of the new modified entry from the modified array. Do that because
154
+ * to draw the initiator from the closest visible entry, we need to get the closest entry that is
155
+ * marked as modified and we do not want to get some that are hidden.
156
+ */
157
+ #addModifiedEntry(entry) {
158
+ this.#modifiedVisibleEntries.push(entry);
159
+ const entryNode = this.#entryToNode.get(entry);
160
+ if (!entryNode) {
161
+ // Invalid node was given, just ignore and move on.
162
+ return;
163
+ }
164
+ const allDescendants = this.#findAllDescendantsOfNode(entryNode);
165
+ if (allDescendants.length > 0) {
166
+ this.#modifiedVisibleEntries = this.#modifiedVisibleEntries.filter(entry => {
167
+ return !allDescendants.includes(entry);
168
+ });
169
+ }
170
+ }
148
171
  // The direct parent might be hidden by other actions, therefore we look for the next visible parent.
149
172
  #findNextVisibleParent(node) {
150
173
  let parent = node.parent;
@@ -1 +1 @@
1
- {"version":3,"file":"EntriesFilter.js","sourceRoot":"","sources":["../../../../../../front_end/models/trace/EntriesFilter.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAC7B,OAAO,KAAK,QAAQ,MAAM,iCAAiC,CAAC;AAC5D,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AA0B1C;;;;;;;;;IASI;AACJ,MAAM,OAAO,aAAa;IACxB,sEAAsE;IACtE,0EAA0E;IAC1E,oCAAoC;IACpC,YAAY,CAAiB;IAE7B,sCAAsC;IACtC,iBAAiB,GAAuC,EAAE,CAAC;IAC3D,oEAAoE;IACpE,yEAAyE;IACzE,uBAAuB,GAAuC,EAAE,CAAC;IACjE,kFAAkF;IAClF,oFAAoF;IACpF,sBAAsB,GAAgF,IAAI,GAAG,EAAE,CAAC;IAEhH,YAAY,WAA2B;QACrC,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;IAClC,CAAC;IAED;;;QAGI;IACJ,mBAAmB,CAAC,KAA4C;QAC9D,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;Q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,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC/C,IAAI,CAAC,SAAS,EAAE;YACd,mDAAmD;YACnD,OAAO;SACR;QACD,MAAM,WAAW,GAAG,IAAI,CAAC,yBAAyB,CAAC,SAAS,CAAC,CAAC;QAE9D;;;YAGI;QACJ,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;YAC7D,IAAI,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;gBAC/B,OAAO,KAAK,CAAC;aACd;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;QAEH;;;YAGI;QACJ,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE;YAC7E,IAAI,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,SAAS,KAAK,KAAK,EAAE;gBAC1D,OAAO,KAAK,CAAC;aACd;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC;IAED,eAAe,CAAC,KAAuC;QACrD,OAAO,IAAI,CAAC,uBAAuB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtD,CAAC;CACF","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.\nimport * as Platform from '../../core/platform/platform.js';\nimport * as Helpers from './helpers/helpers.js';\nimport * as Types from './types/types.js';\n\ntype EntryToNodeMap = Map<Types.TraceEvents.SyntheticTraceEntry, Helpers.TreeHelpers.TraceEntryNode>;\n\nexport const enum FilterAction {\n MERGE_FUNCTION = 'MERGE_FUNCTION',\n COLLAPSE_FUNCTION = 'COLLAPSE_FUNCTION',\n COLLAPSE_REPEATING_DESCENDANTS = 'COLLAPSE_REPEATING_DESCENDANTS',\n RESET_CHILDREN = 'RESET_CHILDREN',\n UNDO_ALL_ACTIONS = 'UNDO_ALL_ACTIONS',\n}\n\nexport interface UserFilterAction {\n type: FilterAction;\n entry: Types.TraceEvents.SyntheticTraceEntry;\n}\n\n// Object used to indicate to the Context Menu if an action is possible on the selected entry.\nexport interface PossibleFilterActions {\n [FilterAction.MERGE_FUNCTION]: boolean;\n [FilterAction.COLLAPSE_FUNCTION]: boolean;\n [FilterAction.COLLAPSE_REPEATING_DESCENDANTS]: boolean;\n [FilterAction.RESET_CHILDREN]: boolean;\n [FilterAction.UNDO_ALL_ACTIONS]: boolean;\n}\n\n/**\n * This class can take in a thread that has been generated by the\n * RendererHandler and apply certain actions to it in order to modify what is\n * shown to the user. These actions can be automatically applied by DevTools or\n * applied by the user.\n *\n * Once actions are applied, the invisibleEntries() method will return the\n * entries that are invisible, and this is the list of entries that should be\n * removed before rendering the resulting thread on the timeline.\n **/\nexport class EntriesFilter {\n // Maps from an individual TraceEvent entry to its representation as a\n // RendererEntryNode. We need this so we can then parse the tree structure\n // generated by the RendererHandler.\n #entryToNode: EntryToNodeMap;\n\n // Track the set of invisible entries.\n #invisibleEntries: Types.TraceEvents.TraceEventData[] = [];\n // List of entries whose children are modified. This list is used to\n // keep track of entries that should be identified in the UI as modified.\n #modifiedVisibleEntries: Types.TraceEvents.TraceEventData[] = [];\n // Cache for descendants of entry that have already been gathered. The descendants\n // will never change so we can avoid running the potentially expensive search again.\n #entryToDescendantsMap: Map<Helpers.TreeHelpers.TraceEntryNode, Types.TraceEvents.TraceEventData[]> = new Map();\n\n constructor(entryToNode: EntryToNodeMap) {\n this.#entryToNode = entryToNode;\n }\n\n /**\n * Checks which actions can be applied on an entry. This allows us to only show possible actions in the Context Menu.\n * For example, if an entry has no children, COLLAPSE_FUNCTION will not change the FlameChart, therefore there is no need to show this action as an option.\n **/\n findPossibleActions(entry: Types.TraceEvents.SyntheticTraceEntry): PossibleFilterActions {\n const entryNode = this.#entryToNode.get(entry);\n if (!entryNode) {\n // Invalid node was given, return no possible actions.\n return {\n [FilterAction.MERGE_FUNCTION]: false,\n [FilterAction.COLLAPSE_FUNCTION]: false,\n [FilterAction.COLLAPSE_REPEATING_DESCENDANTS]: false,\n [FilterAction.RESET_CHILDREN]: false,\n [FilterAction.UNDO_ALL_ACTIONS]: false,\n };\n }\n const entryParent = entryNode.parent;\n const allVisibleDescendants =\n this.#findAllDescendantsOfNode(entryNode).filter(descendant => !this.#invisibleEntries.includes(descendant));\n const allVisibleRepeatingDescendants = this.#findAllRepeatingDescendantsOfNext(entryNode).filter(\n descendant => !this.#invisibleEntries.includes(descendant));\n const allInVisibleDescendants =\n this.#findAllDescendantsOfNode(entryNode).filter(descendant => this.#invisibleEntries.includes(descendant));\n\n // If there are children to hide, indicate action as possible\n const possibleActions: PossibleFilterActions = {\n [FilterAction.MERGE_FUNCTION]: entryParent !== null,\n [FilterAction.COLLAPSE_FUNCTION]: allVisibleDescendants.length > 0,\n [FilterAction.COLLAPSE_REPEATING_DESCENDANTS]: allVisibleRepeatingDescendants.length > 0,\n [FilterAction.RESET_CHILDREN]: allInVisibleDescendants.length > 0,\n [FilterAction.UNDO_ALL_ACTIONS]: this.#invisibleEntries.length > 0,\n };\n return possibleActions;\n }\n\n /**\n * Returns the amount of entry descendants that belong to the hidden entries array.\n * **/\n findHiddenDescendantsAmount(entry: Types.TraceEvents.SyntheticTraceEntry): number {\n const entryNode = this.#entryToNode.get(entry);\n if (!entryNode) {\n return 0;\n }\n const allDescendants = this.#findAllDescendantsOfNode(entryNode);\n return allDescendants.filter(descendant => this.invisibleEntries().includes(descendant)).length;\n }\n\n /**\n * Returns the set of entries that are invisible given the set of applied actions.\n **/\n invisibleEntries(): Types.TraceEvents.TraceEventData[] {\n return this.#invisibleEntries;\n }\n\n /**\n * Applies an action to hide entries or removes entries\n * from hidden entries array depending on the action.\n **/\n applyFilterAction(action: UserFilterAction): Types.TraceEvents.TraceEventData[] {\n // We apply new user action to the set of all entries, and mark\n // any that should be hidden by adding them to this set.\n // Another approach would be to use splice() to remove items from the\n // array, but doing this would be a mutation of the arry for every hidden\n // event. Instead, we add entries to this set and return it as an array at the end.\n const entriesToHide = new Set<Types.TraceEvents.TraceEventData>();\n\n switch (action.type) {\n case FilterAction.MERGE_FUNCTION: {\n // The entry that was clicked on is merged into its parent. All its\n // children remain visible, so we just have to hide the entry that was\n // selected.\n entriesToHide.add(action.entry);\n // If parent node exists, add it to modifiedVisibleEntries, so it would be possible to uncollapse its' children.\n const actionNode = this.#entryToNode.get(action.entry) || null;\n const parentNode = actionNode && this.#findNextVisibleParent(actionNode);\n if (parentNode) {\n this.#modifiedVisibleEntries.push(parentNode?.entry);\n }\n break;\n }\n case FilterAction.COLLAPSE_FUNCTION: {\n // The entry itself remains visible, but all of its descendants are hidden.\n const entryNode = this.#entryToNode.get(action.entry);\n if (!entryNode) {\n // Invalid node was given, just ignore and move on.\n break;\n }\n const allDescendants = this.#findAllDescendantsOfNode(entryNode);\n allDescendants.forEach(descendant => entriesToHide.add(descendant));\n // If there are any children to hide, add selected entry to modifiedVisibleEntries array to identify in the UI that children of the selected entry are modified.\n if (entriesToHide.size > 0) {\n this.#modifiedVisibleEntries.push(action.entry);\n }\n break;\n }\n case FilterAction.COLLAPSE_REPEATING_DESCENDANTS: {\n const entryNode = this.#entryToNode.get(action.entry);\n if (!entryNode) {\n // Invalid node was given, just ignore and move on.\n break;\n }\n const allRepeatingDescendants = this.#findAllRepeatingDescendantsOfNext(entryNode);\n allRepeatingDescendants.forEach(descendant => entriesToHide.add(descendant));\n if (entriesToHide.size > 0) {\n this.#modifiedVisibleEntries.push(action.entry);\n }\n break;\n }\n case FilterAction.UNDO_ALL_ACTIONS: {\n this.#invisibleEntries = [];\n this.#modifiedVisibleEntries = [];\n break;\n }\n case FilterAction.RESET_CHILDREN: {\n this.#makeEntryChildrenVisible(action.entry);\n break;\n }\n default:\n Platform.assertNever(action.type, `Unknown EntriesFilter action: ${action.type}`);\n }\n\n this.#invisibleEntries.push(...entriesToHide);\n\n return this.#invisibleEntries;\n }\n\n // The direct parent might be hidden by other actions, therefore we look for the next visible parent.\n #findNextVisibleParent(node: Helpers.TreeHelpers.TraceEntryNode): Helpers.TreeHelpers.TraceEntryNode|null {\n let parent = node.parent;\n while (parent && this.#invisibleEntries.includes(parent.entry)) {\n parent = parent.parent;\n }\n return parent;\n }\n\n #findAllDescendantsOfNode(root: Helpers.TreeHelpers.TraceEntryNode): Types.TraceEvents.TraceEventData[] {\n const cachedDescendants = this.#entryToDescendantsMap.get(root);\n if (cachedDescendants) {\n return cachedDescendants;\n }\n\n const descendants: Types.TraceEvents.TraceEventData[] = [];\n\n // Walk through all the descendants, starting at the root node.\n const children: Helpers.TreeHelpers.TraceEntryNode[] = [...root.children];\n while (children.length > 0) {\n const childNode = children.shift();\n if (childNode) {\n descendants.push(childNode.entry);\n const childNodeCachedDescendants = this.#entryToDescendantsMap.get(childNode);\n // If the descendants of a child are cached, get them from the cache instead of iterating through them again\n if (childNodeCachedDescendants) {\n descendants.push(...childNodeCachedDescendants);\n } else {\n children.push(...childNode.children);\n }\n }\n }\n\n this.#entryToDescendantsMap.set(root, descendants);\n return descendants;\n }\n\n #findAllRepeatingDescendantsOfNext(root: Helpers.TreeHelpers.TraceEntryNode):\n Types.TraceEvents.SyntheticTraceEntry[] {\n // Walk through all the ancestors, starting at the root node.\n const children: Helpers.TreeHelpers.TraceEntryNode[] = [...root.children];\n const repeatingNodes: Types.TraceEvents.SyntheticTraceEntry[] = [];\n const rootIsProfileCall = Types.TraceEvents.isProfileCall(root.entry);\n\n while (children.length > 0) {\n const childNode = children.shift();\n if (childNode) {\n const childIsProfileCall = Types.TraceEvents.isProfileCall(childNode.entry);\n if (/* Handle SyntheticProfileCalls */ rootIsProfileCall && childIsProfileCall) {\n const rootNodeEntry = root.entry as Types.TraceEvents.SyntheticProfileCall;\n const childNodeEntry = childNode.entry as Types.TraceEvents.SyntheticProfileCall;\n\n if (Helpers.SamplesIntegrator.SamplesIntegrator.framesAreEqual(\n rootNodeEntry.callFrame, childNodeEntry.callFrame)) {\n repeatingNodes.push(childNode.entry);\n }\n } /* Handle SyntheticRendererEvents */ else if (!rootIsProfileCall && !childIsProfileCall) {\n if (root.entry.name === childNode.entry.name) {\n repeatingNodes.push(childNode.entry);\n }\n }\n children.push(...childNode.children);\n }\n }\n\n return repeatingNodes;\n }\n\n /**\n * Removes all of the entry children from the\n * invisible entries array to make them visible.\n **/\n #makeEntryChildrenVisible(entry: Types.TraceEvents.SyntheticTraceEntry): void {\n const entryNode = this.#entryToNode.get(entry);\n if (!entryNode) {\n // Invalid node was given, just ignore and move on.\n return;\n }\n const descendants = this.#findAllDescendantsOfNode(entryNode);\n\n /**\n * Filter out all descendant of the node\n * from the invisible entries list.\n **/\n this.#invisibleEntries = this.#invisibleEntries.filter(entry => {\n if (descendants.includes(entry)) {\n return false;\n }\n return true;\n });\n\n /**\n * Filter out all descentants and entry from modified entries\n * list to not show that some entries below those are hidden.\n **/\n this.#modifiedVisibleEntries = this.#modifiedVisibleEntries.filter(iterEntry => {\n if (descendants.includes(iterEntry) || iterEntry === entry) {\n return false;\n }\n return true;\n });\n }\n\n isEntryModified(event: Types.TraceEvents.TraceEventData): boolean {\n return this.#modifiedVisibleEntries.includes(event);\n }\n}\n"]}
1
+ {"version":3,"file":"EntriesFilter.js","sourceRoot":"","sources":["../../../../../../front_end/models/trace/EntriesFilter.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAC7B,OAAO,KAAK,QAAQ,MAAM,iCAAiC,CAAC;AAC5D,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AA0B1C;;;;;;;;;IASI;AACJ,MAAM,OAAO,aAAa;IACxB,sEAAsE;IACtE,0EAA0E;IAC1E,oCAAoC;IACpC,YAAY,CAAiB;IAE7B,sCAAsC;IACtC,iBAAiB,GAAuC,EAAE,CAAC;IAC3D,oEAAoE;IACpE,yEAAyE;IACzE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AC,CAAC,CAAC;QAEH;;;YAGI;QACJ,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE;YAC7E,IAAI,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,SAAS,KAAK,KAAK,EAAE;gBAC1D,OAAO,KAAK,CAAC;aACd;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC;IAED,eAAe,CAAC,KAAuC;QACrD,OAAO,IAAI,CAAC,uBAAuB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtD,CAAC;CACF","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.\nimport * as Platform from '../../core/platform/platform.js';\nimport * as Helpers from './helpers/helpers.js';\nimport * as Types from './types/types.js';\n\ntype EntryToNodeMap = Map<Types.TraceEvents.SyntheticTraceEntry, Helpers.TreeHelpers.TraceEntryNode>;\n\nexport const enum FilterAction {\n MERGE_FUNCTION = 'MERGE_FUNCTION',\n COLLAPSE_FUNCTION = 'COLLAPSE_FUNCTION',\n COLLAPSE_REPEATING_DESCENDANTS = 'COLLAPSE_REPEATING_DESCENDANTS',\n RESET_CHILDREN = 'RESET_CHILDREN',\n UNDO_ALL_ACTIONS = 'UNDO_ALL_ACTIONS',\n}\n\nexport interface UserFilterAction {\n type: FilterAction;\n entry: Types.TraceEvents.SyntheticTraceEntry;\n}\n\n// Object used to indicate to the Context Menu if an action is possible on the selected entry.\nexport interface PossibleFilterActions {\n [FilterAction.MERGE_FUNCTION]: boolean;\n [FilterAction.COLLAPSE_FUNCTION]: boolean;\n [FilterAction.COLLAPSE_REPEATING_DESCENDANTS]: boolean;\n [FilterAction.RESET_CHILDREN]: boolean;\n [FilterAction.UNDO_ALL_ACTIONS]: boolean;\n}\n\n/**\n * This class can take in a thread that has been generated by the\n * RendererHandler and apply certain actions to it in order to modify what is\n * shown to the user. These actions can be automatically applied by DevTools or\n * applied by the user.\n *\n * Once actions are applied, the invisibleEntries() method will return the\n * entries that are invisible, and this is the list of entries that should be\n * removed before rendering the resulting thread on the timeline.\n **/\nexport class EntriesFilter {\n // Maps from an individual TraceEvent entry to its representation as a\n // RendererEntryNode. We need this so we can then parse the tree structure\n // generated by the RendererHandler.\n #entryToNode: EntryToNodeMap;\n\n // Track the set of invisible entries.\n #invisibleEntries: Types.TraceEvents.TraceEventData[] = [];\n // List of entries whose children are modified. This list is used to\n // keep track of entries that should be identified in the UI as modified.\n #modifiedVisibleEntries: Types.TraceEvents.TraceEventData[] = [];\n // Cache for descendants of entry that have already been gathered. The descendants\n // will never change so we can avoid running the potentially expensive search again.\n #entryToDescendantsMap: Map<Helpers.TreeHelpers.TraceEntryNode, Types.TraceEvents.TraceEventData[]> = new Map();\n\n constructor(entryToNode: EntryToNodeMap) {\n this.#entryToNode = entryToNode;\n }\n\n /**\n * Checks which actions can be applied on an entry. This allows us to only show possible actions in the Context Menu.\n * For example, if an entry has no children, COLLAPSE_FUNCTION will not change the FlameChart, therefore there is no need to show this action as an option.\n **/\n findPossibleActions(entry: Types.TraceEvents.SyntheticTraceEntry): PossibleFilterActions {\n const entryNode = this.#entryToNode.get(entry);\n if (!entryNode) {\n // Invalid node was given, return no possible actions.\n return {\n [FilterAction.MERGE_FUNCTION]: false,\n [FilterAction.COLLAPSE_FUNCTION]: false,\n [FilterAction.COLLAPSE_REPEATING_DESCENDANTS]: false,\n [FilterAction.RESET_CHILDREN]: false,\n [FilterAction.UNDO_ALL_ACTIONS]: false,\n };\n }\n const entryParent = entryNode.parent;\n const allVisibleDescendants =\n this.#findAllDescendantsOfNode(entryNode).filter(descendant => !this.#invisibleEntries.includes(descendant));\n const allVisibleRepeatingDescendants = this.#findAllRepeatingDescendantsOfNext(entryNode).filter(\n descendant => !this.#invisibleEntries.includes(descendant));\n const allInVisibleDescendants =\n this.#findAllDescendantsOfNode(entryNode).filter(descendant => this.#invisibleEntries.includes(descendant));\n\n // If there are children to hide, indicate action as possible\n const possibleActions: PossibleFilterActions = {\n [FilterAction.MERGE_FUNCTION]: entryParent !== null,\n [FilterAction.COLLAPSE_FUNCTION]: allVisibleDescendants.length > 0,\n [FilterAction.COLLAPSE_REPEATING_DESCENDANTS]: allVisibleRepeatingDescendants.length > 0,\n [FilterAction.RESET_CHILDREN]: allInVisibleDescendants.length > 0,\n [FilterAction.UNDO_ALL_ACTIONS]: this.#invisibleEntries.length > 0,\n };\n return possibleActions;\n }\n\n /**\n * Returns the amount of entry descendants that belong to the hidden entries array.\n * **/\n findHiddenDescendantsAmount(entry: Types.TraceEvents.SyntheticTraceEntry): number {\n const entryNode = this.#entryToNode.get(entry);\n if (!entryNode) {\n return 0;\n }\n const allDescendants = this.#findAllDescendantsOfNode(entryNode);\n return allDescendants.filter(descendant => this.invisibleEntries().includes(descendant)).length;\n }\n\n /**\n * Returns the set of entries that are invisible given the set of applied actions.\n **/\n invisibleEntries(): Types.TraceEvents.TraceEventData[] {\n return this.#invisibleEntries;\n }\n\n /**\n * Returns the array of entries that have a sign indicating that entries below are hidden.\n **/\n modifiedEntries(): Types.TraceEvents.TraceEventData[] {\n return this.#modifiedVisibleEntries;\n }\n\n /**\n * Applies an action to hide entries or removes entries\n * from hidden entries array depending on the action.\n **/\n applyFilterAction(action: UserFilterAction): Types.TraceEvents.TraceEventData[] {\n // We apply new user action to the set of all entries, and mark\n // any that should be hidden by adding them to this set.\n // Another approach would be to use splice() to remove items from the\n // array, but doing this would be a mutation of the arry for every hidden\n // event. Instead, we add entries to this set and return it as an array at the end.\n const entriesToHide = new Set<Types.TraceEvents.TraceEventData>();\n\n switch (action.type) {\n case FilterAction.MERGE_FUNCTION: {\n // The entry that was clicked on is merged into its parent. All its\n // children remain visible, so we just have to hide the entry that was\n // selected.\n entriesToHide.add(action.entry);\n // If parent node exists, add it to modifiedVisibleEntries, so it would be possible to uncollapse its' children.\n const actionNode = this.#entryToNode.get(action.entry) || null;\n const parentNode = actionNode && this.#findNextVisibleParent(actionNode);\n if (parentNode) {\n this.#addModifiedEntry(parentNode.entry);\n }\n break;\n }\n case FilterAction.COLLAPSE_FUNCTION: {\n // The entry itself remains visible, but all of its descendants are hidden.\n const entryNode = this.#entryToNode.get(action.entry);\n if (!entryNode) {\n // Invalid node was given, just ignore and move on.\n break;\n }\n const allDescendants = this.#findAllDescendantsOfNode(entryNode);\n allDescendants.forEach(descendant => entriesToHide.add(descendant));\n this.#addModifiedEntry(action.entry);\n break;\n }\n case FilterAction.COLLAPSE_REPEATING_DESCENDANTS: {\n const entryNode = this.#entryToNode.get(action.entry);\n if (!entryNode) {\n // Invalid node was given, just ignore and move on.\n break;\n }\n const allRepeatingDescendants = this.#findAllRepeatingDescendantsOfNext(entryNode);\n allRepeatingDescendants.forEach(descendant => entriesToHide.add(descendant));\n if (entriesToHide.size > 0) {\n this.#addModifiedEntry(action.entry);\n }\n break;\n }\n case FilterAction.UNDO_ALL_ACTIONS: {\n this.#invisibleEntries = [];\n this.#modifiedVisibleEntries = [];\n break;\n }\n case FilterAction.RESET_CHILDREN: {\n this.#makeEntryChildrenVisible(action.entry);\n break;\n }\n default:\n Platform.assertNever(action.type, `Unknown EntriesFilter action: ${action.type}`);\n }\n\n this.#invisibleEntries.push(...entriesToHide);\n\n return this.#invisibleEntries;\n }\n\n /**\n * Add an entry to the array of entries that have a sign indicating that entries below are hidden.\n * Also, remove all of the child entries of the new modified entry from the modified array. Do that because\n * to draw the initiator from the closest visible entry, we need to get the closest entry that is\n * marked as modified and we do not want to get some that are hidden.\n */\n #addModifiedEntry(entry: Types.TraceEvents.TraceEventData): void {\n this.#modifiedVisibleEntries.push(entry);\n const entryNode = this.#entryToNode.get(entry);\n if (!entryNode) {\n // Invalid node was given, just ignore and move on.\n return;\n }\n const allDescendants = this.#findAllDescendantsOfNode(entryNode);\n if (allDescendants.length > 0) {\n this.#modifiedVisibleEntries = this.#modifiedVisibleEntries.filter(entry => {\n return !allDescendants.includes(entry);\n });\n }\n }\n\n // The direct parent might be hidden by other actions, therefore we look for the next visible parent.\n #findNextVisibleParent(node: Helpers.TreeHelpers.TraceEntryNode): Helpers.TreeHelpers.TraceEntryNode|null {\n let parent = node.parent;\n while (parent && this.#invisibleEntries.includes(parent.entry)) {\n parent = parent.parent;\n }\n return parent;\n }\n\n #findAllDescendantsOfNode(root: Helpers.TreeHelpers.TraceEntryNode): Types.TraceEvents.TraceEventData[] {\n const cachedDescendants = this.#entryToDescendantsMap.get(root);\n if (cachedDescendants) {\n return cachedDescendants;\n }\n\n const descendants: Types.TraceEvents.TraceEventData[] = [];\n\n // Walk through all the descendants, starting at the root node.\n const children: Helpers.TreeHelpers.TraceEntryNode[] = [...root.children];\n while (children.length > 0) {\n const childNode = children.shift();\n if (childNode) {\n descendants.push(childNode.entry);\n const childNodeCachedDescendants = this.#entryToDescendantsMap.get(childNode);\n // If the descendants of a child are cached, get them from the cache instead of iterating through them again\n if (childNodeCachedDescendants) {\n descendants.push(...childNodeCachedDescendants);\n } else {\n children.push(...childNode.children);\n }\n }\n }\n\n this.#entryToDescendantsMap.set(root, descendants);\n return descendants;\n }\n\n #findAllRepeatingDescendantsOfNext(root: Helpers.TreeHelpers.TraceEntryNode):\n Types.TraceEvents.SyntheticTraceEntry[] {\n // Walk through all the ancestors, starting at the root node.\n const children: Helpers.TreeHelpers.TraceEntryNode[] = [...root.children];\n const repeatingNodes: Types.TraceEvents.SyntheticTraceEntry[] = [];\n const rootIsProfileCall = Types.TraceEvents.isProfileCall(root.entry);\n\n while (children.length > 0) {\n const childNode = children.shift();\n if (childNode) {\n const childIsProfileCall = Types.TraceEvents.isProfileCall(childNode.entry);\n if (/* Handle SyntheticProfileCalls */ rootIsProfileCall && childIsProfileCall) {\n const rootNodeEntry = root.entry as Types.TraceEvents.SyntheticProfileCall;\n const childNodeEntry = childNode.entry as Types.TraceEvents.SyntheticProfileCall;\n\n if (Helpers.SamplesIntegrator.SamplesIntegrator.framesAreEqual(\n rootNodeEntry.callFrame, childNodeEntry.callFrame)) {\n repeatingNodes.push(childNode.entry);\n }\n } /* Handle SyntheticRendererEvents */ else if (!rootIsProfileCall && !childIsProfileCall) {\n if (root.entry.name === childNode.entry.name) {\n repeatingNodes.push(childNode.entry);\n }\n }\n children.push(...childNode.children);\n }\n }\n\n return repeatingNodes;\n }\n\n /**\n * Removes all of the entry children from the\n * invisible entries array to make them visible.\n **/\n #makeEntryChildrenVisible(entry: Types.TraceEvents.SyntheticTraceEntry): void {\n const entryNode = this.#entryToNode.get(entry);\n if (!entryNode) {\n // Invalid node was given, just ignore and move on.\n return;\n }\n const descendants = this.#findAllDescendantsOfNode(entryNode);\n\n /**\n * Filter out all descendant of the node\n * from the invisible entries list.\n **/\n this.#invisibleEntries = this.#invisibleEntries.filter(entry => {\n if (descendants.includes(entry)) {\n return false;\n }\n return true;\n });\n\n /**\n * Filter out all descentants and entry from modified entries\n * list to not show that some entries below those are hidden.\n **/\n this.#modifiedVisibleEntries = this.#modifiedVisibleEntries.filter(iterEntry => {\n if (descendants.includes(iterEntry) || iterEntry === entry) {\n return false;\n }\n return true;\n });\n }\n\n isEntryModified(event: Types.TraceEvents.TraceEventData): boolean {\n return this.#modifiedVisibleEntries.includes(event);\n }\n}\n"]}
@@ -63,7 +63,7 @@ export declare class Model<EnabledModelHandlers extends {
63
63
  * If no index is given, the last stored parsed data is returned.
64
64
  */
65
65
  traceParsedData(index?: number): Handlers.Types.EnabledHandlerDataWithMeta<EnabledModelHandlers> | null;
66
- traceInsights(index?: number): Insights.Types.TraceInsightData | null;
66
+ traceInsights(index?: number): Insights.Types.TraceInsightData<EnabledModelHandlers> | null;
67
67
  metadata(index: number): Types.File.MetaData | null;
68
68
  traceEvents(index: number): readonly Types.TraceEvents.TraceEventData[] | null;
69
69
  size(): number;
@@ -80,7 +80,7 @@ export type ParsedTraceFile<Handlers extends {
80
80
  [key: string]: Handlers.Types.TraceEventHandler;
81
81
  }> = Types.File.TraceFile & {
82
82
  traceParsedData: Handlers.Types.EnabledHandlerDataWithMeta<Handlers> | null;
83
- traceInsights: Insights.Types.TraceInsightData | null;
83
+ traceInsights: Insights.Types.TraceInsightData<Handlers> | null;
84
84
  };
85
85
  export declare const enum ModelUpdateType {
86
86
  COMPLETE = "COMPLETE",
@@ -1 +1 @@
1
- {"version":3,"file":"ModelImpl.js","sourceRoot":"","sources":["../../../../../../front_end/models/trace/ModelImpl.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,iCAAiC,CAAC;AAE5D,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAC,uBAAuB,EAAE,cAAc,EAAC,MAAM,gBAAgB,CAAC;AACvE,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAY1C;;;;;;;;;;;;IAYI;AACJ,MAAM,OAAO,KAAsF,SAAQ,WAAW;IAC3G,OAAO,GAA4C,EAAE,CAAC;IACtD,mBAAmB,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEhD,oBAAoB,GAAa,EAAE,CAAC;IAC7C,mBAAmB,GAAG,CAAC,CAAC;IACxB,UAAU,CAAwE;IAClF,OAAO,GAAsC,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC;IAEzE,MAAM,CAAC,qBAAqB,CAAC,MAA0C;QACrE,OAAO,IAAI,KAAK,CAAC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IACnD,CAAC;IAED,YAAY,QAA8B,EAAE,MAA0C;QACpF,KAAK,EAAE,CAAC;QACR,IAAI,MAAM,EAAE;YACV,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;SACvB;QACD,IAAI,CAAC,UAAU,GAAG,IAAI,cAAc,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/D,CAAC;IAED;;;;OAIG;IACH,mBAAmB,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K,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QADjB,SAAI,GAAJ,IAAI,CAAsB;IAE7C,CAAC;;AASH,MAAM,UAAU,yBAAyB,CAAC,SAA+B;IACvE,OAAO,SAAS,CAAC,IAAI,8CAA6B,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,SAA+B;IACvE,OAAO,SAAS,CAAC,IAAI,4DAAoC,CAAC;AAC5D,CAAC","sourcesContent":["// Copyright 2022 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 Platform from '../../core/platform/platform.js';\n\nimport * as Handlers from './handlers/handlers.js';\nimport * as Helpers from './helpers/helpers.js';\nimport type * as Insights from './insights/insights.js';\nimport {TraceParseProgressEvent, TraceProcessor} from './Processor.js';\nimport * as Types from './types/types.js';\n\n// Note: this model is implemented in a way that can support multiple trace\n// processors. Currently there is only one implemented, but you will see\n// references to \"processors\" plural because it can easily be extended in the future.\n\nexport interface ParseConfig {\n metadata?: Types.File.MetaData;\n // Unused but will eventually be consumed by UIUtils Linkifier, etc.\n isFreshRecording?: boolean;\n}\n\n/**\n * The new trace engine model we are migrating to. The Model is responsible for\n * parsing arrays of raw trace events and storing the resulting data. It can\n * store multiple traces at once, and can return the data for any of them.\n * Currently as we migrate from the old engine to this, we are turning on the\n * model handlers incrementally as we need the data, to save performance costs\n * of running handlers that we do not use. Therefore, when the model is\n * constructed we pass through a set of handlers that should be used. Once we\n * have migrated all tracks in the Performance Panel to this model, we can\n * remove this ability to run a subset of handlers, as we will need all handlers\n * to be used at that point. For tests, if you want to construct a model with\n * all handlers, you can use the static `Model.createWithAllHandlers` method.\n **/\nexport class Model<EnabledModelHandlers extends {[key: string]: Handlers.Types.TraceEventHandler}> extends EventTarget {\n readonly #traces: ParsedTraceFile<EnabledModelHandlers>[] = [];\n readonly #nextNumberByDomain = new Map<string, number>();\n\n readonly #recordingsAvailable: string[] = [];\n #lastRecordingIndex = 0;\n #processor: TraceProcessor<Handlers.Types.HandlersWithMeta<EnabledModelHandlers>>;\n #config: Types.Configuration.Configuration = Types.Configuration.DEFAULT;\n\n static createWithAllHandlers(config?: Types.Configuration.Configuration): Model<typeof Handlers.ModelHandlers> {\n return new Model(Handlers.ModelHandlers, config);\n }\n\n constructor(handlers: EnabledModelHandlers, config?: Types.Configuration.Configuration) {\n super();\n if (config) {\n this.#config = config;\n }\n this.#processor = new TraceProcessor(handlers, this.#config);\n }\n\n /**\n * Updates the configuration. Useful if a user changes a setting - this lets\n * us update the model without having to destroy it and recreate it with the\n * new settings.\n */\n updateConfiguration(config: Types.Configuration.Configuration): void {\n this.#config = config;\n this.#processor.updateConfiguration(config);\n }\n\n /**\n * Parses an array of trace events into a structured object containing all the\n * information parsed by the trace handlers.\n * You can `await` this function to pause execution until parsing is complete,\n * or instead rely on the `ModuleUpdateEvent` that is dispatched when the\n * parsing is finished.\n *\n * Once parsed, you then have to call the `traceParsedData` method, providing an\n * index of the trace you want to have the data for. This is because any model\n * can store a number of traces. Each trace is given an index, which starts at 0\n * and increments by one as a new trace is parsed.\n *\n * @example\n * // Awaiting the parse method() to block until parsing complete\n * await this.traceModel.parse(events);\n * const data = this.traceModel.traceParsedData(0)\n *\n * @example\n * // Using an event listener to be notified when tracing is complete.\n * this.traceModel.addEventListener(Trace.ModelUpdateEvent.eventName, (event) => {\n * if(event.data.data === 'done') {\n * // trace complete\n * const data = this.traceModel.traceParsedData(0);\n * }\n * });\n * void this.traceModel.parse(events);\n **/\n async parse(traceEvents: readonly Types.TraceEvents.TraceEventData[], config?: ParseConfig): Promise<void> {\n const metadata = config?.metadata || {};\n const isFreshRecording = config?.isFreshRecording || false;\n // During parsing, periodically update any listeners on each processors'\n // progress (if they have any updates).\n const onTraceUpdate = (event: Event): void => {\n const {data} = event as TraceParseProgressEvent;\n this.dispatchEvent(new ModelUpdateEvent({type: ModelUpdateType.PROGRESS_UPDATE, data: data}));\n };\n\n this.#processor.addEventListener(TraceParseProgressEvent.eventName, onTraceUpdate);\n\n // Create a parsed trace file. It will be populated with data from the processor.\n const file: ParsedTraceFile<EnabledModelHandlers> = {\n traceEvents,\n metadata,\n traceParsedData: null,\n traceInsights: null,\n };\n\n try {\n // Wait for all outstanding promises before finishing the async execution,\n // but perform all tasks in parallel.\n await this.#processor.parse(traceEvents, isFreshRecording);\n this.#storeParsedFileData(file, this.#processor.traceParsedData, this.#processor.insights);\n // We only push the file onto this.#traces here once we know it's valid\n // and there's been no errors in the parsing.\n this.#traces.push(file);\n } catch (e) {\n throw e;\n } finally {\n // All processors have finished parsing, no more updates are expected.\n this.#processor.removeEventListener(TraceParseProgressEvent.eventName, onTraceUpdate);\n // Finally, update any listeners that all processors are 'done'.\n this.dispatchEvent(new ModelUpdateEvent({type: ModelUpdateType.COMPLETE, data: 'done'}));\n }\n }\n\n #storeParsedFileData(\n file: ParsedTraceFile<EnabledModelHandlers>,\n data: Handlers.Types.EnabledHandlerDataWithMeta<EnabledModelHandlers>|null,\n insights: Insights.Types.TraceInsightData|null): void {\n file.traceParsedData = data;\n file.traceInsights = insights;\n this.#lastRecordingIndex++;\n let recordingName = `Trace ${this.#lastRecordingIndex}`;\n let origin: string|null = null;\n if (file.traceParsedData) {\n origin = Helpers.Trace.extractOriginFromTrace(file.traceParsedData.Meta.mainFrameURL);\n if (origin) {\n const nextSequenceForDomain = Platform.MapUtilities.getWithDefault(this.#nextNumberByDomain, origin, () => 1);\n recordingName = `${origin} (${nextSequenceForDomain})`;\n this.#nextNumberByDomain.set(origin, nextSequenceForDomain + 1);\n }\n }\n this.#recordingsAvailable.push(recordingName);\n }\n\n /**\n * Returns the parsed trace data indexed by the order in which it was stored.\n * If no index is given, the last stored parsed data is returned.\n */\n traceParsedData(index: number = this.#traces.length - 1):\n Handlers.Types.EnabledHandlerDataWithMeta<EnabledModelHandlers>|null {\n if (!this.#traces[index]) {\n return null;\n }\n\n return this.#traces[index].traceParsedData;\n }\n\n traceInsights(index: number = this.#traces.length - 1): Insights.Types.TraceInsightData|null {\n if (!this.#traces[index]) {\n return null;\n }\n\n return this.#traces[index].traceInsights;\n }\n\n metadata(index: number): Types.File.MetaData|null {\n if (!this.#traces[index]) {\n return null;\n }\n\n return this.#traces[index].metadata;\n }\n\n traceEvents(index: number): readonly Types.TraceEvents.TraceEventData[]|null {\n if (!this.#traces[index]) {\n return null;\n }\n\n return this.#traces[index].traceEvents;\n }\n\n size(): number {\n return this.#traces.length;\n }\n\n deleteTraceByIndex(recordingIndex: number): void {\n this.#traces.splice(recordingIndex, 1);\n this.#recordingsAvailable.splice(recordingIndex, 1);\n }\n\n getRecordingsAvailable(): string[] {\n return this.#recordingsAvailable;\n }\n\n resetProcessor(): void {\n this.#processor.reset();\n }\n}\n\n/**\n * This parsed trace file is used by the Model. It keeps multiple instances\n * of these so that the user can swap between them. The key is that it is\n * essentially the TraceFile plus whatever the model has parsed from it.\n */\nexport type ParsedTraceFile<Handlers extends {[key: string]: Handlers.Types.TraceEventHandler}> = Types.File.TraceFile&{\n traceParsedData: Handlers.Types.EnabledHandlerDataWithMeta<Handlers>| null,\n traceInsights: Insights.Types.TraceInsightData | null,\n};\n\nexport const enum ModelUpdateType {\n COMPLETE = 'COMPLETE',\n PROGRESS_UPDATE = 'PROGRESS_UPDATE',\n}\n\nexport type ModelUpdateEventData = ModelUpdateEventComplete|ModelUpdateEventProgress;\n\nexport type ModelUpdateEventComplete = {\n type: ModelUpdateType.COMPLETE,\n data: 'done',\n};\nexport type ModelUpdateEventProgress = {\n type: ModelUpdateType.PROGRESS_UPDATE,\n data: TraceParseEventProgressData,\n};\n\nexport type TraceParseEventProgressData = {\n index: number,\n total: number,\n};\n\nexport class ModelUpdateEvent extends Event {\n static readonly eventName = 'modelupdate';\n constructor(public data: ModelUpdateEventData) {\n super(ModelUpdateEvent.eventName);\n }\n}\n\ndeclare global {\n interface HTMLElementEventMap {\n [ModelUpdateEvent.eventName]: ModelUpdateEvent;\n }\n}\n\nexport function isModelUpdateDataComplete(eventData: ModelUpdateEventData): eventData is ModelUpdateEventComplete {\n return eventData.type === ModelUpdateType.COMPLETE;\n}\n\nexport function isModelUpdateDataProgress(eventData: ModelUpdateEventData): eventData is ModelUpdateEventProgress {\n return eventData.type === ModelUpdateType.PROGRESS_UPDATE;\n}\n"]}
1
+ {"version":3,"file":"ModelImpl.js","sourceRoot":"","sources":["../../../../../../front_end/models/trace/ModelImpl.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,iCAAiC,CAAC;AAE5D,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAC,uBAAuB,EAAE,cAAc,EAAC,MAAM,gBAAgB,CAAC;AACvE,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAY1C;;;;;;;;;;;;IAYI;AACJ,MAAM,OAAO,KAAsF,SAAQ,WAAW;IAC3G,OAAO,GAA4C,EAAE,CAAC;IACtD,mBAAmB,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEhD,oBAAoB,GAAa,EAAE,CAAC;IAC7C,mBAAmB,GAAG,CAAC,CAAC;IACxB,UAAU,CAAwE;IAClF,OAAO,GAAsC,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC;IAEzE,MAAM,CAAC,qBAAqB,CAAC,MAA0C;QACrE,OAAO,IAAI,KAAK,CAAC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IACnD,CAAC;IAED,YAAY,QAA8B,EAAE,MAA0C;QACpF,KAAK,EAAE,CAAC;QACR,IAAI,MAAM,EAAE;YACV,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;SACvB;QACD,IAAI,CAAC,UAAU,GAAG,IAAI,cAAc,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/D,CAAC;IAED;;;;OAIG;IACH,mBAAmB,CA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CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QADjB,SAAI,GAAJ,IAAI,CAAsB;IAE7C,CAAC;;AASH,MAAM,UAAU,yBAAyB,CAAC,SAA+B;IACvE,OAAO,SAAS,CAAC,IAAI,8CAA6B,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,SAA+B;IACvE,OAAO,SAAS,CAAC,IAAI,4DAAoC,CAAC;AAC5D,CAAC","sourcesContent":["// Copyright 2022 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 Platform from '../../core/platform/platform.js';\n\nimport * as Handlers from './handlers/handlers.js';\nimport * as Helpers from './helpers/helpers.js';\nimport type * as Insights from './insights/insights.js';\nimport {TraceParseProgressEvent, TraceProcessor} from './Processor.js';\nimport * as Types from './types/types.js';\n\n// Note: this model is implemented in a way that can support multiple trace\n// processors. Currently there is only one implemented, but you will see\n// references to \"processors\" plural because it can easily be extended in the future.\n\nexport interface ParseConfig {\n metadata?: Types.File.MetaData;\n // Unused but will eventually be consumed by UIUtils Linkifier, etc.\n isFreshRecording?: boolean;\n}\n\n/**\n * The new trace engine model we are migrating to. The Model is responsible for\n * parsing arrays of raw trace events and storing the resulting data. It can\n * store multiple traces at once, and can return the data for any of them.\n * Currently as we migrate from the old engine to this, we are turning on the\n * model handlers incrementally as we need the data, to save performance costs\n * of running handlers that we do not use. Therefore, when the model is\n * constructed we pass through a set of handlers that should be used. Once we\n * have migrated all tracks in the Performance Panel to this model, we can\n * remove this ability to run a subset of handlers, as we will need all handlers\n * to be used at that point. For tests, if you want to construct a model with\n * all handlers, you can use the static `Model.createWithAllHandlers` method.\n **/\nexport class Model<EnabledModelHandlers extends {[key: string]: Handlers.Types.TraceEventHandler}> extends EventTarget {\n readonly #traces: ParsedTraceFile<EnabledModelHandlers>[] = [];\n readonly #nextNumberByDomain = new Map<string, number>();\n\n readonly #recordingsAvailable: string[] = [];\n #lastRecordingIndex = 0;\n #processor: TraceProcessor<Handlers.Types.HandlersWithMeta<EnabledModelHandlers>>;\n #config: Types.Configuration.Configuration = Types.Configuration.DEFAULT;\n\n static createWithAllHandlers(config?: Types.Configuration.Configuration): Model<typeof Handlers.ModelHandlers> {\n return new Model(Handlers.ModelHandlers, config);\n }\n\n constructor(handlers: EnabledModelHandlers, config?: Types.Configuration.Configuration) {\n super();\n if (config) {\n this.#config = config;\n }\n this.#processor = new TraceProcessor(handlers, this.#config);\n }\n\n /**\n * Updates the configuration. Useful if a user changes a setting - this lets\n * us update the model without having to destroy it and recreate it with the\n * new settings.\n */\n updateConfiguration(config: Types.Configuration.Configuration): void {\n this.#config = config;\n this.#processor.updateConfiguration(config);\n }\n\n /**\n * Parses an array of trace events into a structured object containing all the\n * information parsed by the trace handlers.\n * You can `await` this function to pause execution until parsing is complete,\n * or instead rely on the `ModuleUpdateEvent` that is dispatched when the\n * parsing is finished.\n *\n * Once parsed, you then have to call the `traceParsedData` method, providing an\n * index of the trace you want to have the data for. This is because any model\n * can store a number of traces. Each trace is given an index, which starts at 0\n * and increments by one as a new trace is parsed.\n *\n * @example\n * // Awaiting the parse method() to block until parsing complete\n * await this.traceModel.parse(events);\n * const data = this.traceModel.traceParsedData(0)\n *\n * @example\n * // Using an event listener to be notified when tracing is complete.\n * this.traceModel.addEventListener(Trace.ModelUpdateEvent.eventName, (event) => {\n * if(event.data.data === 'done') {\n * // trace complete\n * const data = this.traceModel.traceParsedData(0);\n * }\n * });\n * void this.traceModel.parse(events);\n **/\n async parse(traceEvents: readonly Types.TraceEvents.TraceEventData[], config?: ParseConfig): Promise<void> {\n const metadata = config?.metadata || {};\n const isFreshRecording = config?.isFreshRecording || false;\n // During parsing, periodically update any listeners on each processors'\n // progress (if they have any updates).\n const onTraceUpdate = (event: Event): void => {\n const {data} = event as TraceParseProgressEvent;\n this.dispatchEvent(new ModelUpdateEvent({type: ModelUpdateType.PROGRESS_UPDATE, data: data}));\n };\n\n this.#processor.addEventListener(TraceParseProgressEvent.eventName, onTraceUpdate);\n\n // Create a parsed trace file. It will be populated with data from the processor.\n const file: ParsedTraceFile<EnabledModelHandlers> = {\n traceEvents,\n metadata,\n traceParsedData: null,\n traceInsights: null,\n };\n\n try {\n // Wait for all outstanding promises before finishing the async execution,\n // but perform all tasks in parallel.\n await this.#processor.parse(traceEvents, isFreshRecording);\n this.#storeParsedFileData(file, this.#processor.traceParsedData, this.#processor.insights);\n // We only push the file onto this.#traces here once we know it's valid\n // and there's been no errors in the parsing.\n this.#traces.push(file);\n } catch (e) {\n throw e;\n } finally {\n // All processors have finished parsing, no more updates are expected.\n this.#processor.removeEventListener(TraceParseProgressEvent.eventName, onTraceUpdate);\n // Finally, update any listeners that all processors are 'done'.\n this.dispatchEvent(new ModelUpdateEvent({type: ModelUpdateType.COMPLETE, data: 'done'}));\n }\n }\n\n #storeParsedFileData(\n file: ParsedTraceFile<EnabledModelHandlers>,\n data: Handlers.Types.EnabledHandlerDataWithMeta<EnabledModelHandlers>|null,\n insights: Insights.Types.TraceInsightData<EnabledModelHandlers>|null): void {\n file.traceParsedData = data;\n file.traceInsights = insights;\n this.#lastRecordingIndex++;\n let recordingName = `Trace ${this.#lastRecordingIndex}`;\n let origin: string|null = null;\n if (file.traceParsedData) {\n origin = Helpers.Trace.extractOriginFromTrace(file.traceParsedData.Meta.mainFrameURL);\n if (origin) {\n const nextSequenceForDomain = Platform.MapUtilities.getWithDefault(this.#nextNumberByDomain, origin, () => 1);\n recordingName = `${origin} (${nextSequenceForDomain})`;\n this.#nextNumberByDomain.set(origin, nextSequenceForDomain + 1);\n }\n }\n this.#recordingsAvailable.push(recordingName);\n }\n\n /**\n * Returns the parsed trace data indexed by the order in which it was stored.\n * If no index is given, the last stored parsed data is returned.\n */\n traceParsedData(index: number = this.#traces.length - 1):\n Handlers.Types.EnabledHandlerDataWithMeta<EnabledModelHandlers>|null {\n if (!this.#traces[index]) {\n return null;\n }\n\n return this.#traces[index].traceParsedData;\n }\n\n traceInsights(index: number = this.#traces.length - 1): Insights.Types.TraceInsightData<EnabledModelHandlers>|null {\n if (!this.#traces[index]) {\n return null;\n }\n\n return this.#traces[index].traceInsights;\n }\n\n metadata(index: number): Types.File.MetaData|null {\n if (!this.#traces[index]) {\n return null;\n }\n\n return this.#traces[index].metadata;\n }\n\n traceEvents(index: number): readonly Types.TraceEvents.TraceEventData[]|null {\n if (!this.#traces[index]) {\n return null;\n }\n\n return this.#traces[index].traceEvents;\n }\n\n size(): number {\n return this.#traces.length;\n }\n\n deleteTraceByIndex(recordingIndex: number): void {\n this.#traces.splice(recordingIndex, 1);\n this.#recordingsAvailable.splice(recordingIndex, 1);\n }\n\n getRecordingsAvailable(): string[] {\n return this.#recordingsAvailable;\n }\n\n resetProcessor(): void {\n this.#processor.reset();\n }\n}\n\n/**\n * This parsed trace file is used by the Model. It keeps multiple instances\n * of these so that the user can swap between them. The key is that it is\n * essentially the TraceFile plus whatever the model has parsed from it.\n */\nexport type ParsedTraceFile<Handlers extends {[key: string]: Handlers.Types.TraceEventHandler}> = Types.File.TraceFile&{\n traceParsedData: Handlers.Types.EnabledHandlerDataWithMeta<Handlers>| null,\n traceInsights: Insights.Types.TraceInsightData<Handlers>| null,\n};\n\nexport const enum ModelUpdateType {\n COMPLETE = 'COMPLETE',\n PROGRESS_UPDATE = 'PROGRESS_UPDATE',\n}\n\nexport type ModelUpdateEventData = ModelUpdateEventComplete|ModelUpdateEventProgress;\n\nexport type ModelUpdateEventComplete = {\n type: ModelUpdateType.COMPLETE,\n data: 'done',\n};\nexport type ModelUpdateEventProgress = {\n type: ModelUpdateType.PROGRESS_UPDATE,\n data: TraceParseEventProgressData,\n};\n\nexport type TraceParseEventProgressData = {\n index: number,\n total: number,\n};\n\nexport class ModelUpdateEvent extends Event {\n static readonly eventName = 'modelupdate';\n constructor(public data: ModelUpdateEventData) {\n super(ModelUpdateEvent.eventName);\n }\n}\n\ndeclare global {\n interface HTMLElementEventMap {\n [ModelUpdateEvent.eventName]: ModelUpdateEvent;\n }\n}\n\nexport function isModelUpdateDataComplete(eventData: ModelUpdateEventData): eventData is ModelUpdateEventComplete {\n return eventData.type === ModelUpdateType.COMPLETE;\n}\n\nexport function isModelUpdateDataProgress(eventData: ModelUpdateEventData): eventData is ModelUpdateEventProgress {\n return eventData.type === ModelUpdateType.PROGRESS_UPDATE;\n}\n"]}
@@ -25,7 +25,7 @@ export declare class TraceProcessor<EnabledModelHandlers extends {
25
25
  reset(): void;
26
26
  parse(traceEvents: readonly Types.TraceEvents.TraceEventData[], freshRecording?: boolean): Promise<void>;
27
27
  get traceParsedData(): Handlers.Types.EnabledHandlerDataWithMeta<EnabledModelHandlers> | null;
28
- get insights(): Insights.Types.TraceInsightData | null;
28
+ get insights(): Insights.Types.TraceInsightData<EnabledModelHandlers> | null;
29
29
  }
30
30
  /**
31
31
  * Some Handlers need data provided by others. Dependencies of a handler handler are
@@ -15,7 +15,6 @@ export class TraceParseProgressEvent extends Event {
15
15
  export class TraceProcessor extends EventTarget {
16
16
  // We force the Meta handler to be enabled, so the TraceHandlers type here is
17
17
  // the model handlers the user passes in and the Meta handler.
18
- // eslint-disable-next-line @typescript-eslint/naming-convention
19
18
  #traceHandlers;
20
19
  #status = "IDLE" /* Status.IDLE */;
21
20
  #modelConfiguration = Types.Configuration.DEFAULT;
@@ -179,7 +178,14 @@ export class TraceProcessor extends EventTarget {
179
178
  };
180
179
  const navInsightData = {};
181
180
  for (const [name, generateInsight] of Object.entries(enabledInsightRunners)) {
182
- Object.assign(navInsightData, { [name]: generateInsight(this.traceParsedData, context) });
181
+ let insightResult;
182
+ try {
183
+ insightResult = generateInsight(this.traceParsedData, context);
184
+ }
185
+ catch (err) {
186
+ insightResult = err;
187
+ }
188
+ Object.assign(navInsightData, { [name]: insightResult });
183
189
  }
184
190
  this.#insights.set(context.navigationId, navInsightData);
185
191
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Processor.js","sourceRoot":"","sources":["../../../../../../front_end/models/trace/Processor.ts"],"names":[],"mappings":"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AC;IAEF,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE;QACpD,YAAY,CAAC,WAAmD,CAAC,CAAC;KACnE;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAmBD,MAAM,kBAAkB;IAIV;IAAkE;IAClE;IAJZ,WAAW,CAAS;IAEpB,YACY,WAAwD,EAAU,aAAqB,EACvF,cAAsB;QADtB,gBAAW,GAAX,WAAW,CAA6C;QAAU,kBAAa,GAAb,aAAa,CAAQ;QACvF,mBAAc,GAAd,cAAc,CAAQ;QAChC,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,CAAE,CAAC,MAAM,CAAC,aAAa,CAAC;QAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;YACjE,iDAAiD;YACjD,IAAI,EAAE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,cAAc,KAAK,CAAC,EAAE;gBAClD,wDAAwD;gBACxD,MAAM,EAAC,IAAI,wCAAgC,EAAE,IAAI,EAAE,EAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAC,EAAC,CAAC;gBAC9E,sCAAsC;gBACtC,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;aACvE;YAED,MAAM,EAAC,IAAI,sCAA8B,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAC,CAAC;SACvE;IACH,CAAC;CACF","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.\nimport * as Handlers from './handlers/handlers.js';\nimport * as Insights from './insights/insights.js';\nimport * as Types from './types/types.js';\n\nconst enum Status {\n IDLE = 'IDLE',\n PARSING = 'PARSING',\n FINISHED_PARSING = 'FINISHED_PARSING',\n ERRORED_WHILE_PARSING = 'ERRORED_WHILE_PARSING',\n}\n\nexport type TraceParseEventProgressData = {\n index: number,\n total: number,\n};\n\nexport class TraceParseProgressEvent extends Event {\n static readonly eventName = 'traceparseprogress';\n constructor(public data: TraceParseEventProgressData, init: EventInit = {bubbles: true}) {\n super(TraceParseProgressEvent.eventName, init);\n }\n}\ndeclare global {\n interface HTMLElementEventMap {\n [TraceParseProgressEvent.eventName]: TraceParseProgressEvent;\n }\n}\n\nexport class TraceProcessor<EnabledModelHandlers extends {[key: string]: Handlers.Types.TraceEventHandler}> extends\n EventTarget {\n // We force the Meta handler to be enabled, so the TraceHandlers type here is\n // the model handlers the user passes in and the Meta handler.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n readonly #traceHandlers: Handlers.Types.HandlersWithMeta<EnabledModelHandlers>;\n #status = Status.IDLE;\n #modelConfiguration = Types.Configuration.DEFAULT;\n #insights: Insights.Types.TraceInsightData|null = null;\n\n static createWithAllHandlers(): TraceProcessor<typeof Handlers.ModelHandlers> {\n return new TraceProcessor(Handlers.ModelHandlers, Types.Configuration.DEFAULT);\n }\n\n constructor(traceHandlers: EnabledModelHandlers, modelConfiguration?: Types.Configuration.Configuration) {\n super();\n\n this.#verifyHandlers(traceHandlers);\n this.#traceHandlers = {\n Meta: Handlers.ModelHandlers.Meta,\n ...traceHandlers,\n };\n if (modelConfiguration) {\n this.#modelConfiguration = modelConfiguration;\n }\n this.#passConfigToHandlers();\n }\n\n updateConfiguration(config: Types.Configuration.Configuration): void {\n this.#modelConfiguration = config;\n this.#passConfigToHandlers();\n }\n\n #passConfigToHandlers(): void {\n for (const handler of Object.values(this.#traceHandlers)) {\n // Bit of an odd double check, but without this TypeScript refuses to let\n // you call the function as it thinks it might be undefined.\n if ('handleUserConfig' in handler && handler.handleUserConfig) {\n handler.handleUserConfig(this.#modelConfiguration);\n }\n }\n }\n\n /**\n * When the user passes in a set of handlers, we want to ensure that we have all\n * the required handlers. Handlers can depend on other handlers, so if the user\n * passes in FooHandler which depends on BarHandler, they must also pass in\n * BarHandler too. This method verifies that all dependencies are met, and\n * throws if not.\n **/\n #verifyHandlers(providedHandlers: EnabledModelHandlers): void {\n // Tiny optimisation: if the amount of provided handlers matches the amount\n // of handlers in the Handlers.ModelHandlers object, that means that the\n // user has passed in every handler we have. So therefore they cannot have\n // missed any, and there is no need to iterate through the handlers and\n // check the dependencies.\n if (Object.keys(providedHandlers).length === Object.keys(Handlers.ModelHandlers).length) {\n return;\n }\n const requiredHandlerKeys: Set<Handlers.Types.TraceEventHandlerName> = new Set();\n for (const [handlerName, handler] of Object.entries(providedHandlers)) {\n requiredHandlerKeys.add(handlerName as Handlers.Types.TraceEventHandlerName);\n for (const depName of (handler.deps?.() || [])) {\n requiredHandlerKeys.add(depName);\n }\n }\n\n const providedHandlerKeys = new Set(Object.keys(providedHandlers));\n // We always force the Meta handler to be enabled when creating the\n // Processor, so if it is missing from the set the user gave us that is OK,\n // as we will have enabled it anyway.\n requiredHandlerKeys.delete('Meta');\n\n for (const requiredKey of requiredHandlerKeys) {\n if (!providedHandlerKeys.has(requiredKey)) {\n throw new Error(`Required handler ${requiredKey} not provided.`);\n }\n }\n }\n\n reset(): void {\n if (this.#status === Status.PARSING) {\n throw new Error('Trace processor can\\'t reset while parsing.');\n }\n\n const handlers = Object.values(this.#traceHandlers);\n for (const handler of handlers) {\n handler.reset();\n }\n\n this.#insights = null;\n\n this.#status = Status.IDLE;\n }\n\n async parse(traceEvents: readonly Types.TraceEvents.TraceEventData[], freshRecording = false): Promise<void> {\n if (this.#status !== Status.IDLE) {\n throw new Error(`Trace processor can't start parsing when not idle. Current state: ${this.#status}`);\n }\n try {\n this.#status = Status.PARSING;\n await this.#parse(traceEvents, freshRecording);\n this.#status = Status.FINISHED_PARSING;\n } catch (e) {\n this.#status = Status.ERRORED_WHILE_PARSING;\n throw e;\n }\n }\n\n async #parse(traceEvents: readonly Types.TraceEvents.TraceEventData[], freshRecording: boolean): Promise<void> {\n // This iterator steps through all events, periodically yielding back to the\n // main thread to avoid blocking execution. It uses `dispatchEvent` to\n // provide status update events, and other various bits of config like the\n // pause duration and frequency.\n const {pauseDuration, eventsPerChunk} = this.#modelConfiguration.processing;\n const traceEventIterator = new TraceEventIterator(traceEvents, pauseDuration, eventsPerChunk);\n\n // Convert to array so that we are able to iterate all handlers multiple times.\n const sortedHandlers = [...sortHandlers(this.#traceHandlers).values()];\n // Reset.\n for (const handler of sortedHandlers) {\n handler.reset();\n }\n\n // Initialize.\n for (const handler of sortedHandlers) {\n handler.initialize?.(freshRecording);\n }\n\n // Handle each event.\n for await (const item of traceEventIterator) {\n if (item.kind === IteratorItemType.STATUS_UPDATE) {\n this.dispatchEvent(new TraceParseProgressEvent(item.data));\n continue;\n }\n for (const handler of sortedHandlers) {\n handler.handleEvent(item.data);\n }\n }\n\n // Finalize.\n for (const handler of sortedHandlers) {\n await handler.finalize?.();\n }\n }\n\n get traceParsedData(): Handlers.Types.EnabledHandlerDataWithMeta<EnabledModelHandlers>|null {\n if (this.#status !== Status.FINISHED_PARSING) {\n return null;\n }\n\n const traceParsedData = {};\n for (const [name, handler] of Object.entries(this.#traceHandlers)) {\n Object.assign(traceParsedData, {[name]: handler.data()});\n }\n\n return traceParsedData as Handlers.Types.EnabledHandlerDataWithMeta<EnabledModelHandlers>;\n }\n\n #getEnabledInsightRunners(traceParsedData: Handlers.Types.EnabledHandlerDataWithMeta<EnabledModelHandlers>):\n Insights.Types.EnabledInsightRunners<EnabledModelHandlers> {\n const enabledInsights = {} as Insights.Types.EnabledInsightRunners<EnabledModelHandlers>;\n for (const [name, insight] of Object.entries(Insights.InsightRunners)) {\n const deps = insight.deps();\n if (deps.some(dep => !traceParsedData[dep])) {\n continue;\n }\n Object.assign(enabledInsights, {[name]: insight.generateInsight});\n }\n return enabledInsights;\n }\n\n get insights(): Insights.Types.TraceInsightData|null {\n if (!this.traceParsedData) {\n return null;\n }\n\n if (this.#insights) {\n return this.#insights;\n }\n\n this.#insights = new Map();\n\n const enabledInsightRunners = this.#getEnabledInsightRunners(this.traceParsedData);\n\n for (const nav of this.traceParsedData.Meta.mainFrameNavigations) {\n if (!nav.args.frame || !nav.args.data?.navigationId) {\n continue;\n }\n\n const context = {\n frameId: nav.args.frame,\n navigationId: nav.args.data.navigationId,\n };\n\n const navInsightData = {} as Insights.Types.NavigationInsightData;\n for (const [name, generateInsight] of Object.entries(enabledInsightRunners)) {\n Object.assign(navInsightData, {[name]: generateInsight(this.traceParsedData, context)});\n }\n\n this.#insights.set(context.navigationId, navInsightData);\n }\n\n return this.#insights;\n }\n}\n\n/**\n * Some Handlers need data provided by others. Dependencies of a handler handler are\n * declared in the `deps` field.\n * @returns A map from trace event handler name to trace event hander whose entries\n * iterate in such a way that each handler is visited after its dependencies.\n */\nexport function sortHandlers(\n traceHandlers: Partial<{[key in Handlers.Types.TraceEventHandlerName]: Handlers.Types.TraceEventHandler}>):\n Map<Handlers.Types.TraceEventHandlerName, Handlers.Types.TraceEventHandler> {\n const sortedMap = new Map<Handlers.Types.TraceEventHandlerName, Handlers.Types.TraceEventHandler>();\n const visited = new Set<Handlers.Types.TraceEventHandlerName>();\n const visitHandler = (handlerName: Handlers.Types.TraceEventHandlerName): void => {\n if (sortedMap.has(handlerName)) {\n return;\n }\n if (visited.has(handlerName)) {\n let stackPath = '';\n for (const handler of visited) {\n if (stackPath || handler === handlerName) {\n stackPath += `${handler}->`;\n }\n }\n stackPath += handlerName;\n throw new Error(`Found dependency cycle in trace event handlers: ${stackPath}`);\n }\n visited.add(handlerName);\n const handler = traceHandlers[handlerName];\n if (!handler) {\n return;\n }\n const deps = handler.deps?.();\n if (deps) {\n deps.forEach(visitHandler);\n }\n sortedMap.set(handlerName, handler);\n };\n\n for (const handlerName of Object.keys(traceHandlers)) {\n visitHandler(handlerName as Handlers.Types.TraceEventHandlerName);\n }\n return sortedMap;\n}\n\nconst enum IteratorItemType {\n TRACE_EVENT = 1,\n STATUS_UPDATE = 2,\n}\n\ntype IteratorItem = IteratorTraceEventItem|IteratorStatusUpdateItem;\n\ntype IteratorTraceEventItem = {\n kind: IteratorItemType.TRACE_EVENT,\n data: Types.TraceEvents.TraceEventData,\n};\n\ntype IteratorStatusUpdateItem = {\n kind: IteratorItemType.STATUS_UPDATE,\n data: TraceParseEventProgressData,\n};\n\nclass TraceEventIterator {\n #eventCount: number;\n\n constructor(\n private traceEvents: readonly Types.TraceEvents.TraceEventData[], private pauseDuration: number,\n private eventsPerChunk: number) {\n this.#eventCount = 0;\n }\n\n async * [Symbol.asyncIterator](): AsyncGenerator<IteratorItem, void, void> {\n for (let i = 0, length = this.traceEvents.length; i < length; i++) {\n // Every so often we take a break just to render.\n if (++this.#eventCount % this.eventsPerChunk === 0) {\n // Take the opportunity to provide status update events.\n yield {kind: IteratorItemType.STATUS_UPDATE, data: {index: i, total: length}};\n // Wait for rendering before resuming.\n await new Promise(resolve => setTimeout(resolve, this.pauseDuration));\n }\n\n yield {kind: IteratorItemType.TRACE_EVENT, data: this.traceEvents[i]};\n }\n }\n}\n"]}
1
+ {"version":3,"file":"Processor.js","sourceRoot":"","sources":["../../../../../../front_end/models/trace/Processor.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAC7B,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAc1C,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAE7B;IADnB,MAAM,CAAU,SAAS,GAAG,oBAAoB,CAAC;IACjD,YAAmB,IAAiC,EAAE,OAAkB,EAAC,OAAO,EAAE,IAAI,EAAC;QACrF,KAAK,CAAC,uBAAuB,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAD9B,SAAI,GAAJ,IAAI,CAA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Ab,aAAa,CAAQ;QACvF,mBAAc,GAAd,cAAc,CAAQ;QAChC,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,CAAE,CAAC,MAAM,CAAC,aAAa,CAAC;QAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;YACjE,iDAAiD;YACjD,IAAI,EAAE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,cAAc,KAAK,CAAC,EAAE;gBAClD,wDAAwD;gBACxD,MAAM,EAAC,IAAI,wCAAgC,EAAE,IAAI,EAAE,EAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAC,EAAC,CAAC;gBAC9E,sCAAsC;gBACtC,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;aACvE;YAED,MAAM,EAAC,IAAI,sCAA8B,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAC,CAAC;SACvE;IACH,CAAC;CACF","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.\nimport * as Handlers from './handlers/handlers.js';\nimport * as Insights from './insights/insights.js';\nimport * as Types from './types/types.js';\n\nconst enum Status {\n IDLE = 'IDLE',\n PARSING = 'PARSING',\n FINISHED_PARSING = 'FINISHED_PARSING',\n ERRORED_WHILE_PARSING = 'ERRORED_WHILE_PARSING',\n}\n\nexport type TraceParseEventProgressData = {\n index: number,\n total: number,\n};\n\nexport class TraceParseProgressEvent extends Event {\n static readonly eventName = 'traceparseprogress';\n constructor(public data: TraceParseEventProgressData, init: EventInit = {bubbles: true}) {\n super(TraceParseProgressEvent.eventName, init);\n }\n}\ndeclare global {\n interface HTMLElementEventMap {\n [TraceParseProgressEvent.eventName]: TraceParseProgressEvent;\n }\n}\n\nexport class TraceProcessor<EnabledModelHandlers extends {[key: string]: Handlers.Types.TraceEventHandler}> extends\n EventTarget {\n // We force the Meta handler to be enabled, so the TraceHandlers type here is\n // the model handlers the user passes in and the Meta handler.\n readonly #traceHandlers: Handlers.Types.HandlersWithMeta<EnabledModelHandlers>;\n #status = Status.IDLE;\n #modelConfiguration = Types.Configuration.DEFAULT;\n #insights: Insights.Types.TraceInsightData<EnabledModelHandlers>|null = null;\n\n static createWithAllHandlers(): TraceProcessor<typeof Handlers.ModelHandlers> {\n return new TraceProcessor(Handlers.ModelHandlers, Types.Configuration.DEFAULT);\n }\n\n constructor(traceHandlers: EnabledModelHandlers, modelConfiguration?: Types.Configuration.Configuration) {\n super();\n\n this.#verifyHandlers(traceHandlers);\n this.#traceHandlers = {\n Meta: Handlers.ModelHandlers.Meta,\n ...traceHandlers,\n };\n if (modelConfiguration) {\n this.#modelConfiguration = modelConfiguration;\n }\n this.#passConfigToHandlers();\n }\n\n updateConfiguration(config: Types.Configuration.Configuration): void {\n this.#modelConfiguration = config;\n this.#passConfigToHandlers();\n }\n\n #passConfigToHandlers(): void {\n for (const handler of Object.values(this.#traceHandlers)) {\n // Bit of an odd double check, but without this TypeScript refuses to let\n // you call the function as it thinks it might be undefined.\n if ('handleUserConfig' in handler && handler.handleUserConfig) {\n handler.handleUserConfig(this.#modelConfiguration);\n }\n }\n }\n\n /**\n * When the user passes in a set of handlers, we want to ensure that we have all\n * the required handlers. Handlers can depend on other handlers, so if the user\n * passes in FooHandler which depends on BarHandler, they must also pass in\n * BarHandler too. This method verifies that all dependencies are met, and\n * throws if not.\n **/\n #verifyHandlers(providedHandlers: EnabledModelHandlers): void {\n // Tiny optimisation: if the amount of provided handlers matches the amount\n // of handlers in the Handlers.ModelHandlers object, that means that the\n // user has passed in every handler we have. So therefore they cannot have\n // missed any, and there is no need to iterate through the handlers and\n // check the dependencies.\n if (Object.keys(providedHandlers).length === Object.keys(Handlers.ModelHandlers).length) {\n return;\n }\n const requiredHandlerKeys: Set<Handlers.Types.TraceEventHandlerName> = new Set();\n for (const [handlerName, handler] of Object.entries(providedHandlers)) {\n requiredHandlerKeys.add(handlerName as Handlers.Types.TraceEventHandlerName);\n for (const depName of (handler.deps?.() || [])) {\n requiredHandlerKeys.add(depName);\n }\n }\n\n const providedHandlerKeys = new Set(Object.keys(providedHandlers));\n // We always force the Meta handler to be enabled when creating the\n // Processor, so if it is missing from the set the user gave us that is OK,\n // as we will have enabled it anyway.\n requiredHandlerKeys.delete('Meta');\n\n for (const requiredKey of requiredHandlerKeys) {\n if (!providedHandlerKeys.has(requiredKey)) {\n throw new Error(`Required handler ${requiredKey} not provided.`);\n }\n }\n }\n\n reset(): void {\n if (this.#status === Status.PARSING) {\n throw new Error('Trace processor can\\'t reset while parsing.');\n }\n\n const handlers = Object.values(this.#traceHandlers);\n for (const handler of handlers) {\n handler.reset();\n }\n\n this.#insights = null;\n\n this.#status = Status.IDLE;\n }\n\n async parse(traceEvents: readonly Types.TraceEvents.TraceEventData[], freshRecording = false): Promise<void> {\n if (this.#status !== Status.IDLE) {\n throw new Error(`Trace processor can't start parsing when not idle. Current state: ${this.#status}`);\n }\n try {\n this.#status = Status.PARSING;\n await this.#parse(traceEvents, freshRecording);\n this.#status = Status.FINISHED_PARSING;\n } catch (e) {\n this.#status = Status.ERRORED_WHILE_PARSING;\n throw e;\n }\n }\n\n async #parse(traceEvents: readonly Types.TraceEvents.TraceEventData[], freshRecording: boolean): Promise<void> {\n // This iterator steps through all events, periodically yielding back to the\n // main thread to avoid blocking execution. It uses `dispatchEvent` to\n // provide status update events, and other various bits of config like the\n // pause duration and frequency.\n const {pauseDuration, eventsPerChunk} = this.#modelConfiguration.processing;\n const traceEventIterator = new TraceEventIterator(traceEvents, pauseDuration, eventsPerChunk);\n\n // Convert to array so that we are able to iterate all handlers multiple times.\n const sortedHandlers = [...sortHandlers(this.#traceHandlers).values()];\n // Reset.\n for (const handler of sortedHandlers) {\n handler.reset();\n }\n\n // Initialize.\n for (const handler of sortedHandlers) {\n handler.initialize?.(freshRecording);\n }\n\n // Handle each event.\n for await (const item of traceEventIterator) {\n if (item.kind === IteratorItemType.STATUS_UPDATE) {\n this.dispatchEvent(new TraceParseProgressEvent(item.data));\n continue;\n }\n for (const handler of sortedHandlers) {\n handler.handleEvent(item.data);\n }\n }\n\n // Finalize.\n for (const handler of sortedHandlers) {\n await handler.finalize?.();\n }\n }\n\n get traceParsedData(): Handlers.Types.EnabledHandlerDataWithMeta<EnabledModelHandlers>|null {\n if (this.#status !== Status.FINISHED_PARSING) {\n return null;\n }\n\n const traceParsedData = {};\n for (const [name, handler] of Object.entries(this.#traceHandlers)) {\n Object.assign(traceParsedData, {[name]: handler.data()});\n }\n\n return traceParsedData as Handlers.Types.EnabledHandlerDataWithMeta<EnabledModelHandlers>;\n }\n\n #getEnabledInsightRunners(traceParsedData: Handlers.Types.EnabledHandlerDataWithMeta<EnabledModelHandlers>):\n Insights.Types.EnabledInsightRunners<EnabledModelHandlers> {\n const enabledInsights = {} as Insights.Types.EnabledInsightRunners<EnabledModelHandlers>;\n for (const [name, insight] of Object.entries(Insights.InsightRunners)) {\n const deps = insight.deps();\n if (deps.some(dep => !traceParsedData[dep])) {\n continue;\n }\n Object.assign(enabledInsights, {[name]: insight.generateInsight});\n }\n return enabledInsights;\n }\n\n get insights(): Insights.Types.TraceInsightData<EnabledModelHandlers>|null {\n if (!this.traceParsedData) {\n return null;\n }\n\n if (this.#insights) {\n return this.#insights;\n }\n\n this.#insights = new Map();\n\n const enabledInsightRunners = this.#getEnabledInsightRunners(this.traceParsedData);\n\n for (const nav of this.traceParsedData.Meta.mainFrameNavigations) {\n if (!nav.args.frame || !nav.args.data?.navigationId) {\n continue;\n }\n\n const context = {\n frameId: nav.args.frame,\n navigationId: nav.args.data.navigationId,\n };\n\n const navInsightData = {} as Insights.Types.NavigationInsightData<EnabledModelHandlers>;\n for (const [name, generateInsight] of Object.entries(enabledInsightRunners)) {\n let insightResult;\n try {\n insightResult = generateInsight(this.traceParsedData, context);\n } catch (err) {\n insightResult = err;\n }\n Object.assign(navInsightData, {[name]: insightResult});\n }\n\n this.#insights.set(context.navigationId, navInsightData);\n }\n\n return this.#insights;\n }\n}\n\n/**\n * Some Handlers need data provided by others. Dependencies of a handler handler are\n * declared in the `deps` field.\n * @returns A map from trace event handler name to trace event hander whose entries\n * iterate in such a way that each handler is visited after its dependencies.\n */\nexport function sortHandlers(\n traceHandlers: Partial<{[key in Handlers.Types.TraceEventHandlerName]: Handlers.Types.TraceEventHandler}>):\n Map<Handlers.Types.TraceEventHandlerName, Handlers.Types.TraceEventHandler> {\n const sortedMap = new Map<Handlers.Types.TraceEventHandlerName, Handlers.Types.TraceEventHandler>();\n const visited = new Set<Handlers.Types.TraceEventHandlerName>();\n const visitHandler = (handlerName: Handlers.Types.TraceEventHandlerName): void => {\n if (sortedMap.has(handlerName)) {\n return;\n }\n if (visited.has(handlerName)) {\n let stackPath = '';\n for (const handler of visited) {\n if (stackPath || handler === handlerName) {\n stackPath += `${handler}->`;\n }\n }\n stackPath += handlerName;\n throw new Error(`Found dependency cycle in trace event handlers: ${stackPath}`);\n }\n visited.add(handlerName);\n const handler = traceHandlers[handlerName];\n if (!handler) {\n return;\n }\n const deps = handler.deps?.();\n if (deps) {\n deps.forEach(visitHandler);\n }\n sortedMap.set(handlerName, handler);\n };\n\n for (const handlerName of Object.keys(traceHandlers)) {\n visitHandler(handlerName as Handlers.Types.TraceEventHandlerName);\n }\n return sortedMap;\n}\n\nconst enum IteratorItemType {\n TRACE_EVENT = 1,\n STATUS_UPDATE = 2,\n}\n\ntype IteratorItem = IteratorTraceEventItem|IteratorStatusUpdateItem;\n\ntype IteratorTraceEventItem = {\n kind: IteratorItemType.TRACE_EVENT,\n data: Types.TraceEvents.TraceEventData,\n};\n\ntype IteratorStatusUpdateItem = {\n kind: IteratorItemType.STATUS_UPDATE,\n data: TraceParseEventProgressData,\n};\n\nclass TraceEventIterator {\n #eventCount: number;\n\n constructor(\n private traceEvents: readonly Types.TraceEvents.TraceEventData[], private pauseDuration: number,\n private eventsPerChunk: number) {\n this.#eventCount = 0;\n }\n\n async * [Symbol.asyncIterator](): AsyncGenerator<IteratorItem, void, void> {\n for (let i = 0, length = this.traceEvents.length; i < length; i++) {\n // Every so often we take a break just to render.\n if (++this.#eventCount % this.eventsPerChunk === 0) {\n // Take the opportunity to provide status update events.\n yield {kind: IteratorItemType.STATUS_UPDATE, data: {index: i, total: length}};\n // Wait for rendering before resuming.\n await new Promise(resolve => setTimeout(resolve, this.pauseDuration));\n }\n\n yield {kind: IteratorItemType.TRACE_EVENT, data: this.traceEvents[i]};\n }\n }\n}\n"]}
@@ -33,8 +33,7 @@
33
33
  "../../../../../../front_end/legacy/legacy-defs.d.ts",
34
34
  "../../../../../../front_end/global_typings/global_defs.d.ts",
35
35
  "../../../../../../front_end/global_typings/request_idle_callback.d.ts",
36
- "../../../../../../node_modules/@types/filesystem/index.d.ts",
37
- "../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
36
+ "../../../../../../node_modules/@types/filesystem/index.d.ts"
38
37
  ],
39
38
  "references": [
40
39
  {
@@ -33,8 +33,7 @@
33
33
  "../../../../../../../front_end/legacy/legacy-defs.d.ts",
34
34
  "../../../../../../../front_end/global_typings/global_defs.d.ts",
35
35
  "../../../../../../../front_end/global_typings/request_idle_callback.d.ts",
36
- "../../../../../../../node_modules/@types/filesystem/index.d.ts",
37
- "../../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
36
+ "../../../../../../../node_modules/@types/filesystem/index.d.ts"
38
37
  ],
39
38
  "references": [
40
39
  {
@@ -36,8 +36,7 @@
36
36
  "../../../../../../../front_end/legacy/legacy-defs.d.ts",
37
37
  "../../../../../../../front_end/global_typings/global_defs.d.ts",
38
38
  "../../../../../../../front_end/global_typings/request_idle_callback.d.ts",
39
- "../../../../../../../node_modules/@types/filesystem/index.d.ts",
40
- "../../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
39
+ "../../../../../../../node_modules/@types/filesystem/index.d.ts"
41
40
  ],
42
41
  "references": [
43
42
  {
@@ -33,8 +33,7 @@
33
33
  "../../../../../../../front_end/legacy/legacy-defs.d.ts",
34
34
  "../../../../../../../front_end/global_typings/global_defs.d.ts",
35
35
  "../../../../../../../front_end/global_typings/request_idle_callback.d.ts",
36
- "../../../../../../../node_modules/@types/filesystem/index.d.ts",
37
- "../../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
36
+ "../../../../../../../node_modules/@types/filesystem/index.d.ts"
38
37
  ],
39
38
  "references": [
40
39
  {
@@ -56,8 +56,7 @@
56
56
  "../../../../../../../front_end/legacy/legacy-defs.d.ts",
57
57
  "../../../../../../../front_end/global_typings/global_defs.d.ts",
58
58
  "../../../../../../../front_end/global_typings/request_idle_callback.d.ts",
59
- "../../../../../../../node_modules/@types/filesystem/index.d.ts",
60
- "../../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
59
+ "../../../../../../../node_modules/@types/filesystem/index.d.ts"
61
60
  ],
62
61
  "references": [
63
62
  {
@@ -33,8 +33,7 @@
33
33
  "../../../../../../../front_end/legacy/legacy-defs.d.ts",
34
34
  "../../../../../../../front_end/global_typings/global_defs.d.ts",
35
35
  "../../../../../../../front_end/global_typings/request_idle_callback.d.ts",
36
- "../../../../../../../node_modules/@types/filesystem/index.d.ts",
37
- "../../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
36
+ "../../../../../../../node_modules/@types/filesystem/index.d.ts"
38
37
  ],
39
38
  "references": [
40
39
  {
@@ -36,8 +36,7 @@
36
36
  "../../../../../../../front_end/legacy/legacy-defs.d.ts",
37
37
  "../../../../../../../front_end/global_typings/global_defs.d.ts",
38
38
  "../../../../../../../front_end/global_typings/request_idle_callback.d.ts",
39
- "../../../../../../../node_modules/@types/filesystem/index.d.ts",
40
- "../../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
39
+ "../../../../../../../node_modules/@types/filesystem/index.d.ts"
41
40
  ],
42
41
  "references": [
43
42
  {
@@ -1,6 +1,6 @@
1
1
  import type * as Types from '../types/types.js';
2
- import { type NavigationInsightContext, type RequiredData } from './types.js';
3
- export declare function deps(): ['NetworkRequests', 'Meta'];
4
- export declare function generateInsight(traceParsedData: RequiredData<typeof deps>, context: NavigationInsightContext): {
2
+ import { type InsightResult, type NavigationInsightContext, type RequiredData } from './types.js';
3
+ export declare function deps(): ['NetworkRequests', 'PageLoadMetrics'];
4
+ export declare function generateInsight(traceParsedData: RequiredData<typeof deps>, context: NavigationInsightContext): InsightResult<{
5
5
  renderBlockingRequests: Types.TraceEvents.SyntheticNetworkRequest[];
6
- };
6
+ }>;
@@ -1,21 +1,36 @@
1
1
  // Copyright 2024 The Chromium Authors. All rights reserved.
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
+ import * as Handlers from '../handlers/handlers.js';
4
5
  import * as Helpers from '../helpers/helpers.js';
6
+ import { InsightWarning } from './types.js';
5
7
  export function deps() {
6
- return ['NetworkRequests', 'Meta'];
8
+ return ['NetworkRequests', 'PageLoadMetrics'];
7
9
  }
8
10
  export function generateInsight(traceParsedData, context) {
11
+ const firstPaintTs = traceParsedData.PageLoadMetrics.metricScoresByFrameId.get(context.frameId)
12
+ ?.get(context.navigationId)
13
+ ?.get("FP" /* Handlers.ModelHandlers.PageLoadMetrics.MetricName.FP */)
14
+ ?.event?.ts;
15
+ if (!firstPaintTs) {
16
+ return {
17
+ renderBlockingRequests: [],
18
+ warnings: [InsightWarning.NO_FP],
19
+ };
20
+ }
9
21
  const renderBlockingRequests = [];
10
22
  for (const req of traceParsedData.NetworkRequests.byTime) {
11
23
  if (req.args.data.frame !== context.frameId) {
12
24
  continue;
13
25
  }
14
- const navigation = Helpers.Trace.getNavigationForTraceEvent(req, context.frameId, traceParsedData.Meta.navigationsByFrameId);
15
- if (navigation?.args.data?.navigationId !== context.navigationId) {
26
+ if (req.args.data.renderBlocking !== 'blocking' && req.args.data.renderBlocking !== 'in_body_parser_blocking') {
16
27
  continue;
17
28
  }
18
- if (req.args.data.renderBlocking !== 'blocking') {
29
+ if (req.args.data.syntheticData.finishTime > firstPaintTs) {
30
+ continue;
31
+ }
32
+ const navigation = Helpers.Trace.getNavigationForTraceEvent(req, context.frameId, traceParsedData.Meta.navigationsByFrameId);
33
+ if (navigation?.args.data?.navigationId !== context.navigationId) {
19
34
  continue;
20
35
  }
21
36
  renderBlockingRequests.push(req);
@@ -1 +1 @@
1
- {"version":3,"file":"RenderBlocking.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/RenderBlocking.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AAKjD,MAAM,UAAU,IAAI;IAClB,OAAO,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,eAA0C,EAAE,OAAiC;IAE3G,MAAM,sBAAsB,GAAG,EAAE,CAAC;IAClC,KAAK,MAAM,GAAG,IAAI,eAAe,CAAC,eAAe,CAAC,MAAM,EAAE;QACxD,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,OAAO,CAAC,OAAO,EAAE;YAC3C,SAAS;SACV;QAED,MAAM,UAAU,GACZ,OAAO,CAAC,KAAK,CAAC,0BAA0B,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,eAAe,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAC9G,IAAI,UAAU,EAAE,IAAI,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,YAAY,EAAE;YAChE,SAAS;SACV;QAED,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,KAAK,UAAU,EAAE;YAC/C,SAAS;SACV;QAED,sBAAsB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KAClC;IAED,OAAO;QACL,sBAAsB;KACvB,CAAC;AACJ,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 Helpers from '../helpers/helpers.js';\nimport type * as Types from '../types/types.js';\n\nimport {type NavigationInsightContext, type RequiredData} from './types.js';\n\nexport function deps(): ['NetworkRequests', 'Meta'] {\n return ['NetworkRequests', 'Meta'];\n}\n\nexport function generateInsight(traceParsedData: RequiredData<typeof deps>, context: NavigationInsightContext):\n {renderBlockingRequests: Types.TraceEvents.SyntheticNetworkRequest[]} {\n const renderBlockingRequests = [];\n for (const req of traceParsedData.NetworkRequests.byTime) {\n if (req.args.data.frame !== context.frameId) {\n continue;\n }\n\n const navigation =\n Helpers.Trace.getNavigationForTraceEvent(req, context.frameId, traceParsedData.Meta.navigationsByFrameId);\n if (navigation?.args.data?.navigationId !== context.navigationId) {\n continue;\n }\n\n if (req.args.data.renderBlocking !== 'blocking') {\n continue;\n }\n\n renderBlockingRequests.push(req);\n }\n\n return {\n renderBlockingRequests,\n };\n}\n"]}
1
+ {"version":3,"file":"RenderBlocking.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/RenderBlocking.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AAGjD,OAAO,EAAqB,cAAc,EAAmD,MAAM,YAAY,CAAC;AAEhH,MAAM,UAAU,IAAI;IAClB,OAAO,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,eAA0C,EAAE,OAAiC;IAE3G,MAAM,YAAY,GAAG,eAAe,CAAC,eAAe,CAAC,qBAAqB,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC;QACtE,EAAE,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC;QAC3B,EAAE,GAAG,iEAAsD;QAC3D,EAAE,KAAK,EAAE,EAAE,CAAC;IACrC,IAAI,CAAC,YAAY,EAAE;QACjB,OAAO;YACL,sBAAsB,EAAE,EAAE;YAC1B,QAAQ,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC;SACjC,CAAC;KACH;IAED,MAAM,sBAAsB,GAAG,EAAE,CAAC;IAClC,KAAK,MAAM,GAAG,IAAI,eAAe,CAAC,eAAe,CAAC,MAAM,EAAE;QACxD,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,OAAO,CAAC,OAAO,EAAE;YAC3C,SAAS;SACV;QAED,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,KAAK,UAAU,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,KAAK,yBAAyB,EAAE;YAC7G,SAAS;SACV;QAED,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,GAAG,YAAY,EAAE;YACzD,SAAS;SACV;QAED,MAAM,UAAU,GACZ,OAAO,CAAC,KAAK,CAAC,0BAA0B,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,eAAe,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAC9G,IAAI,UAAU,EAAE,IAAI,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,YAAY,EAAE;YAChE,SAAS;SACV;QAED,sBAAsB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KAClC;IAED,OAAO;QACL,sBAAsB;KACvB,CAAC;AACJ,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 Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport type * as Types from '../types/types.js';\n\nimport {type InsightResult, InsightWarning, type NavigationInsightContext, type RequiredData} from './types.js';\n\nexport function deps(): ['NetworkRequests', 'PageLoadMetrics'] {\n return ['NetworkRequests', 'PageLoadMetrics'];\n}\n\nexport function generateInsight(traceParsedData: RequiredData<typeof deps>, context: NavigationInsightContext):\n InsightResult<{renderBlockingRequests: Types.TraceEvents.SyntheticNetworkRequest[]}> {\n const firstPaintTs = traceParsedData.PageLoadMetrics.metricScoresByFrameId.get(context.frameId)\n ?.get(context.navigationId)\n ?.get(Handlers.ModelHandlers.PageLoadMetrics.MetricName.FP)\n ?.event?.ts;\n if (!firstPaintTs) {\n return {\n renderBlockingRequests: [],\n warnings: [InsightWarning.NO_FP],\n };\n }\n\n const renderBlockingRequests = [];\n for (const req of traceParsedData.NetworkRequests.byTime) {\n if (req.args.data.frame !== context.frameId) {\n continue;\n }\n\n if (req.args.data.renderBlocking !== 'blocking' && req.args.data.renderBlocking !== 'in_body_parser_blocking') {\n continue;\n }\n\n if (req.args.data.syntheticData.finishTime > firstPaintTs) {\n continue;\n }\n\n const navigation =\n Helpers.Trace.getNavigationForTraceEvent(req, context.frameId, traceParsedData.Meta.navigationsByFrameId);\n if (navigation?.args.data?.navigationId !== context.navigationId) {\n continue;\n }\n\n renderBlockingRequests.push(req);\n }\n\n return {\n renderBlockingRequests,\n };\n}\n"]}
@@ -33,8 +33,7 @@
33
33
  "../../../../../../../front_end/legacy/legacy-defs.d.ts",
34
34
  "../../../../../../../front_end/global_typings/global_defs.d.ts",
35
35
  "../../../../../../../front_end/global_typings/request_idle_callback.d.ts",
36
- "../../../../../../../node_modules/@types/filesystem/index.d.ts",
37
- "../../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
36
+ "../../../../../../../node_modules/@types/filesystem/index.d.ts"
38
37
  ],
39
38
  "references": [
40
39
  {
@@ -35,8 +35,7 @@
35
35
  "../../../../../../../front_end/legacy/legacy-defs.d.ts",
36
36
  "../../../../../../../front_end/global_typings/global_defs.d.ts",
37
37
  "../../../../../../../front_end/global_typings/request_idle_callback.d.ts",
38
- "../../../../../../../node_modules/@types/filesystem/index.d.ts",
39
- "../../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
38
+ "../../../../../../../node_modules/@types/filesystem/index.d.ts"
40
39
  ],
41
40
  "references": [
42
41
  {
@@ -8,26 +8,38 @@ export interface NavigationInsightContext {
8
8
  navigationId: string;
9
9
  }
10
10
  type InsightRunnersType = typeof InsightsRunners;
11
+ export declare enum InsightWarning {
12
+ NO_FP = "NO_FP"
13
+ }
14
+ export type InsightResult<R extends Record<string, unknown>> = R & {
15
+ warnings?: InsightWarning[];
16
+ };
11
17
  /**
12
18
  * Contains insights for a specific navigation.
13
19
  */
14
- export type NavigationInsightData = {
15
- [I in keyof InsightRunnersType]?: ReturnType<InsightRunnersType[I]['generateInsight']>;
20
+ export type NavigationInsightData<H extends {
21
+ [key: string]: Handlers.Types.TraceEventHandler;
22
+ }> = {
23
+ [I in keyof EnabledInsightRunners<H>]: ReturnType<EnabledInsightRunners<H>[I]> | Error;
16
24
  };
17
25
  /**
18
26
  * Contains insights for the entire trace. Insights are grouped by `navigationId`.
19
27
  */
20
- export type TraceInsightData = Map<string, NavigationInsightData>;
28
+ export type TraceInsightData<H extends {
29
+ [key: string]: Handlers.Types.TraceEventHandler;
30
+ }> = Map<string, NavigationInsightData<H>>;
21
31
  /**
22
- * Maps each enabled insight name to its generate function. Insights that are disabled (i.e. missing one or more dependencies) will be unset/undefined.
32
+ * Maps each enabled insight name to its generate function. Insights that are disabled (i.e. missing one or more dependencies) will be unset.
23
33
  */
24
- export type EnabledInsightRunners<EnabledModelHandlers extends {
34
+ export type EnabledInsightRunners<H extends {
25
35
  [key: string]: Handlers.Types.TraceEventHandler;
26
36
  }> = {
27
- [I in keyof InsightRunnersType]?: (traceParsedData: Handlers.Types.EnabledHandlerDataWithMeta<EnabledModelHandlers>, context: NavigationInsightContext) => ReturnType<InsightRunnersType[I]['generateInsight']>;
37
+ [I in keyof InsightRunnersType]: [
38
+ Handlers.Types.EnabledHandlerDataWithMeta<H>
39
+ ] extends [Parameters<InsightRunnersType[I]['generateInsight']>[0]] ? (traceParsedData: Handlers.Types.EnabledHandlerDataWithMeta<H>, context: NavigationInsightContext) => ReturnType<InsightRunnersType[I]['generateInsight']> : never;
28
40
  };
29
41
  /**
30
- * Represents the narrow set of dependencies defined by an insight's `deps()` function.
42
+ * Represents the narrow set of dependencies defined by an insight's `deps()` function. `Meta` is always included regardless of `deps()`.
31
43
  */
32
- export type RequiredData<D extends () => Array<keyof typeof Handlers.ModelHandlers>> = Pick<Handlers.Types.EnabledHandlerDataWithMeta<typeof Handlers.ModelHandlers>, ReturnType<D>[number]>;
44
+ export type RequiredData<D extends () => Array<keyof typeof Handlers.ModelHandlers>> = Handlers.Types.EnabledHandlerDataWithMeta<Pick<typeof Handlers.ModelHandlers, ReturnType<D>[number]>>;
33
45
  export {};
@@ -1,5 +1,8 @@
1
1
  // Copyright 2024 The Chromium Authors. All rights reserved.
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
- export {};
4
+ export var InsightWarning;
5
+ (function (InsightWarning) {
6
+ InsightWarning["NO_FP"] = "NO_FP";
7
+ })(InsightWarning || (InsightWarning = {}));
5
8
  //# sourceMappingURL=types.js.map
@@ -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","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 Handlers from '../handlers/handlers.js';\n\nimport type * as InsightsRunners from './InsightRunners.js';\n\n/**\n * Context for which navigation an insight should look at.\n */\nexport interface NavigationInsightContext {\n frameId: string;\n navigationId: string;\n}\n\ntype InsightRunnersType = typeof InsightsRunners;\n\n/**\n * Contains insights for a specific navigation.\n */\nexport type NavigationInsightData = {\n [I in keyof InsightRunnersType]?: ReturnType<InsightRunnersType[I]['generateInsight']>;\n};\n\n/**\n * Contains insights for the entire trace. Insights are grouped by `navigationId`.\n */\nexport type TraceInsightData = Map<string, NavigationInsightData>;\n\n/**\n * Maps each enabled insight name to its generate function. Insights that are disabled (i.e. missing one or more dependencies) will be unset/undefined.\n */\nexport type EnabledInsightRunners<EnabledModelHandlers extends {[key: string]: Handlers.Types.TraceEventHandler}> = {\n [I in keyof InsightRunnersType]?: (\n traceParsedData: Handlers.Types.EnabledHandlerDataWithMeta<EnabledModelHandlers>,\n context: NavigationInsightContext) => ReturnType<InsightRunnersType[I]['generateInsight']>;\n};\n\n/**\n * Represents the narrow set of dependencies defined by an insight's `deps()` function.\n */\nexport type RequiredData<D extends() => Array<keyof typeof Handlers.ModelHandlers>> =\n Pick<Handlers.Types.EnabledHandlerDataWithMeta<typeof Handlers.ModelHandlers>, ReturnType<D>[number]>;\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/types.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAgB7B,MAAM,CAAN,IAAY,cAEX;AAFD,WAAY,cAAc;IACxB,iCAAe,CAAA;AACjB,CAAC,EAFW,cAAc,KAAd,cAAc,QAEzB","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 Handlers from '../handlers/handlers.js';\n\nimport type * as InsightsRunners from './InsightRunners.js';\n\n/**\n * Context for which navigation an insight should look at.\n */\nexport interface NavigationInsightContext {\n frameId: string;\n navigationId: string;\n}\n\ntype InsightRunnersType = typeof InsightsRunners;\n\nexport enum InsightWarning {\n NO_FP = 'NO_FP',\n}\n\nexport type InsightResult<R extends Record<string, unknown>> = R&{\n warnings?: InsightWarning[],\n};\n\n/**\n * Contains insights for a specific navigation.\n */\nexport type NavigationInsightData<H extends {[key: string]: Handlers.Types.TraceEventHandler}> = {\n [I in keyof EnabledInsightRunners<H>]: ReturnType<EnabledInsightRunners<H>[I]>|Error;\n};\n\n/**\n * Contains insights for the entire trace. Insights are grouped by `navigationId`.\n */\nexport type TraceInsightData<H extends {[key: string]: Handlers.Types.TraceEventHandler}> =\n Map<string, NavigationInsightData<H>>;\n\n/**\n * Maps each enabled insight name to its generate function. Insights that are disabled (i.e. missing one or more dependencies) will be unset.\n */\nexport type EnabledInsightRunners<H extends {[key: string]: Handlers.Types.TraceEventHandler}> = {\n [I in keyof InsightRunnersType]:\n [Handlers.Types.EnabledHandlerDataWithMeta<H>] extends [Parameters<InsightRunnersType[I]['generateInsight']>[0]] ?\n (traceParsedData: Handlers.Types.EnabledHandlerDataWithMeta<H>, context: NavigationInsightContext) =>\n ReturnType<InsightRunnersType[I]['generateInsight']>:\n never;\n};\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"]}
@@ -33,8 +33,7 @@
33
33
  "../../../../../../../front_end/legacy/legacy-defs.d.ts",
34
34
  "../../../../../../../front_end/global_typings/global_defs.d.ts",
35
35
  "../../../../../../../front_end/global_typings/request_idle_callback.d.ts",
36
- "../../../../../../../node_modules/@types/filesystem/index.d.ts",
37
- "../../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
36
+ "../../../../../../../node_modules/@types/filesystem/index.d.ts"
38
37
  ],
39
38
  "references": [
40
39
  {
@@ -34,8 +34,7 @@
34
34
  "../../../../../../../front_end/legacy/legacy-defs.d.ts",
35
35
  "../../../../../../../front_end/global_typings/global_defs.d.ts",
36
36
  "../../../../../../../front_end/global_typings/request_idle_callback.d.ts",
37
- "../../../../../../../node_modules/@types/filesystem/index.d.ts",
38
- "../../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
37
+ "../../../../../../../node_modules/@types/filesystem/index.d.ts"
39
38
  ],
40
39
  "references": [
41
40
  {
@@ -37,8 +37,7 @@
37
37
  "../../../../../../front_end/legacy/legacy-defs.d.ts",
38
38
  "../../../../../../front_end/global_typings/global_defs.d.ts",
39
39
  "../../../../../../front_end/global_typings/request_idle_callback.d.ts",
40
- "../../../../../../node_modules/@types/filesystem/index.d.ts",
41
- "../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
40
+ "../../../../../../node_modules/@types/filesystem/index.d.ts"
42
41
  ],
43
42
  "references": [
44
43
  {
@@ -1,15 +1,12 @@
1
1
  // Copyright 2022 The Chromium Authors. All rights reserved.
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
- // eslint-disable-next-line @typescript-eslint/naming-convention
5
4
  export function MicroSeconds(value) {
6
5
  return value;
7
6
  }
8
- // eslint-disable-next-line @typescript-eslint/naming-convention
9
7
  export function MilliSeconds(value) {
10
8
  return value;
11
9
  }
12
- // eslint-disable-next-line @typescript-eslint/naming-convention
13
10
  export function Seconds(value) {
14
11
  return value;
15
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Timing.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/types/Timing.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAK7B,gEAAgE;AAChE,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,KAAqB,CAAC;AAC/B,CAAC;AAGD,gEAAgE;AAChE,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,KAAqB,CAAC;AAC/B,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,OAAO,CAAC,KAAa;IACnC,OAAO,KAAgB,CAAC;AAC1B,CAAC","sourcesContent":["// Copyright 2022 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\n/* eslint-disable no-unused-private-class-members */\n\nexport type MicroSeconds = number&{_tag: 'MicroSeconds'};\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function MicroSeconds(value: number): MicroSeconds {\n return value as MicroSeconds;\n}\n\nexport type MilliSeconds = number&{_tag: 'MilliSeconds'};\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function MilliSeconds(value: number): MilliSeconds {\n return value as MilliSeconds;\n}\nexport type Seconds = number&{_tag: 'Seconds'};\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function Seconds(value: number): Seconds {\n return value as Seconds;\n}\n\nexport const enum TimeUnit {\n MICROSECONDS = 0,\n MILLISECONDS = 1,\n SECONDS = 2,\n MINUTES = 3,\n}\n\n// Other types.\n\nexport interface TraceWindow<TimeFormat extends MicroSeconds|MilliSeconds> {\n min: TimeFormat;\n max: TimeFormat;\n range: TimeFormat;\n}\n\nexport type TraceWindowMicroSeconds = TraceWindow<MicroSeconds>;\nexport type TraceWindowMilliSeconds = TraceWindow<MilliSeconds>;\n"]}
1
+ {"version":3,"file":"Timing.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/types/Timing.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAK7B,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,KAAqB,CAAC;AAC/B,CAAC;AAGD,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,KAAqB,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,KAAa;IACnC,OAAO,KAAgB,CAAC;AAC1B,CAAC","sourcesContent":["// Copyright 2022 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\n/* eslint-disable no-unused-private-class-members, @typescript-eslint/naming-convention */\n\nexport type MicroSeconds = number&{_tag: 'MicroSeconds'};\nexport function MicroSeconds(value: number): MicroSeconds {\n return value as MicroSeconds;\n}\n\nexport type MilliSeconds = number&{_tag: 'MilliSeconds'};\nexport function MilliSeconds(value: number): MilliSeconds {\n return value as MilliSeconds;\n}\nexport type Seconds = number&{_tag: 'Seconds'};\nexport function Seconds(value: number): Seconds {\n return value as Seconds;\n}\n\nexport const enum TimeUnit {\n MICROSECONDS = 0,\n MILLISECONDS = 1,\n SECONDS = 2,\n MINUTES = 3,\n}\n\n// Other types.\n\nexport interface TraceWindow<TimeFormat extends MicroSeconds|MilliSeconds> {\n min: TimeFormat;\n max: TimeFormat;\n range: TimeFormat;\n}\n\nexport type TraceWindowMicroSeconds = TraceWindow<MicroSeconds>;\nexport type TraceWindowMilliSeconds = TraceWindow<MilliSeconds>;\n"]}
@@ -33,8 +33,7 @@
33
33
  "../../../../../../../front_end/legacy/legacy-defs.d.ts",
34
34
  "../../../../../../../front_end/global_typings/global_defs.d.ts",
35
35
  "../../../../../../../front_end/global_typings/request_idle_callback.d.ts",
36
- "../../../../../../../node_modules/@types/filesystem/index.d.ts",
37
- "../../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
36
+ "../../../../../../../node_modules/@types/filesystem/index.d.ts"
38
37
  ],
39
38
  "references": [
40
39
  {
@@ -36,8 +36,7 @@
36
36
  "../../../../../../../front_end/legacy/legacy-defs.d.ts",
37
37
  "../../../../../../../front_end/global_typings/global_defs.d.ts",
38
38
  "../../../../../../../front_end/global_typings/request_idle_callback.d.ts",
39
- "../../../../../../../node_modules/@types/filesystem/index.d.ts",
40
- "../../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
39
+ "../../../../../../../node_modules/@types/filesystem/index.d.ts"
41
40
  ],
42
41
  "references": [
43
42
  {
package/package.json CHANGED
@@ -1,11 +1,8 @@
1
1
  {
2
2
  "name": "@paulirish/trace_engine",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "description": "",
5
5
  "main": "models/trace/trace.js",
6
- "scripts": {
7
- "test": "node test/test-trace-engine.mjs"
8
- },
9
6
  "type": "module",
10
7
  "keywords": [],
11
8
  "author": "",