@memlab/core 1.1.11 → 1.1.14

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 (122) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2 -2
  3. package/dist/__tests__/parser/HeapParser.test.d.ts +1 -1
  4. package/dist/__tests__/parser/HeapParser.test.js +2 -2
  5. package/dist/__tests__/parser/NodeHeap.test.d.ts +1 -1
  6. package/dist/__tests__/parser/NodeHeap.test.js +1 -1
  7. package/dist/__tests__/parser/StringNode.test.d.ts +1 -1
  8. package/dist/__tests__/parser/StringNode.test.js +1 -1
  9. package/dist/__tests__/parser/traverse/HeapNodeTraverse.test.d.ts +1 -1
  10. package/dist/__tests__/parser/traverse/HeapNodeTraverse.test.js +1 -1
  11. package/dist/__tests__/utils/utils.test.d.ts +1 -1
  12. package/dist/__tests__/utils/utils.test.js +1 -1
  13. package/dist/index.d.ts +3 -1
  14. package/dist/index.js +5 -2
  15. package/dist/lib/BaseOption.d.ts +1 -1
  16. package/dist/lib/BaseOption.js +1 -1
  17. package/dist/lib/BrowserInfo.d.ts +1 -1
  18. package/dist/lib/BrowserInfo.js +1 -1
  19. package/dist/lib/Config.d.ts +7 -2
  20. package/dist/lib/Config.js +27 -3
  21. package/dist/lib/Console.d.ts +1 -1
  22. package/dist/lib/Console.js +1 -1
  23. package/dist/lib/Constant.d.ts +1 -1
  24. package/dist/lib/Constant.js +2 -3
  25. package/dist/lib/FileManager.d.ts +5 -3
  26. package/dist/lib/FileManager.js +13 -5
  27. package/dist/lib/HeapAnalyzer.d.ts +1 -1
  28. package/dist/lib/HeapAnalyzer.js +1 -1
  29. package/dist/lib/HeapParser.d.ts +1 -1
  30. package/dist/lib/HeapParser.js +1 -1
  31. package/dist/lib/InternalValueSetter.d.ts +1 -1
  32. package/dist/lib/InternalValueSetter.js +1 -1
  33. package/dist/lib/NodeHeap.d.ts +1 -1
  34. package/dist/lib/NodeHeap.js +1 -1
  35. package/dist/lib/PackageInfoLoader.js +1 -1
  36. package/dist/lib/ProcessManager.d.ts +1 -1
  37. package/dist/lib/ProcessManager.js +1 -1
  38. package/dist/lib/Serializer.d.ts +2 -1
  39. package/dist/lib/Serializer.js +25 -8
  40. package/dist/lib/StringLoader.d.ts +1 -1
  41. package/dist/lib/StringLoader.js +1 -1
  42. package/dist/lib/Types.d.ts +36 -4
  43. package/dist/lib/Types.js +1 -1
  44. package/dist/lib/Utils.d.ts +3 -1
  45. package/dist/lib/Utils.js +53 -2
  46. package/dist/lib/heap-data/HeapEdge.d.ts +1 -1
  47. package/dist/lib/heap-data/HeapEdge.js +1 -1
  48. package/dist/lib/heap-data/HeapLocation.d.ts +3 -2
  49. package/dist/lib/heap-data/HeapLocation.js +8 -1
  50. package/dist/lib/heap-data/HeapNode.d.ts +1 -1
  51. package/dist/lib/heap-data/HeapNode.js +2 -2
  52. package/dist/lib/heap-data/HeapSnapshot.d.ts +1 -1
  53. package/dist/lib/heap-data/HeapSnapshot.js +1 -1
  54. package/dist/lib/heap-data/HeapStringNode.d.ts +1 -1
  55. package/dist/lib/heap-data/HeapStringNode.js +1 -1
  56. package/dist/lib/heap-data/HeapUtils.d.ts +1 -1
  57. package/dist/lib/heap-data/HeapUtils.js +1 -1
  58. package/dist/lib/heap-data/MemLabTagStore.d.ts +1 -1
  59. package/dist/lib/heap-data/MemLabTagStore.js +1 -1
  60. package/dist/lib/leak-filters/BaseLeakFilter.rule.d.ts +1 -1
  61. package/dist/lib/leak-filters/BaseLeakFilter.rule.js +1 -1
  62. package/dist/lib/leak-filters/LeakFilterRuleList.d.ts +1 -1
  63. package/dist/lib/leak-filters/LeakFilterRuleList.js +1 -1
  64. package/dist/lib/leak-filters/LeakObjectFilter.d.ts +1 -1
  65. package/dist/lib/leak-filters/LeakObjectFilter.js +1 -1
  66. package/dist/lib/leak-filters/rules/FilterByExternalFilter.rule.d.ts +1 -1
  67. package/dist/lib/leak-filters/rules/FilterByExternalFilter.rule.js +1 -1
  68. package/dist/lib/leak-filters/rules/FilterDetachedDOMElement.rule.d.ts +1 -1
  69. package/dist/lib/leak-filters/rules/FilterDetachedDOMElement.rule.js +1 -1
  70. package/dist/lib/leak-filters/rules/FilterHermesNode.rule.d.ts +1 -1
  71. package/dist/lib/leak-filters/rules/FilterHermesNode.rule.js +1 -1
  72. package/dist/lib/leak-filters/rules/FilterOverSizedNodeAsLeak.rule.d.ts +1 -1
  73. package/dist/lib/leak-filters/rules/FilterOverSizedNodeAsLeak.rule.js +1 -1
  74. package/dist/lib/leak-filters/rules/FilterStackTraceFrame.rule.d.ts +1 -1
  75. package/dist/lib/leak-filters/rules/FilterStackTraceFrame.rule.js +1 -1
  76. package/dist/lib/leak-filters/rules/FilterTrivialNode.rule.d.ts +1 -1
  77. package/dist/lib/leak-filters/rules/FilterTrivialNode.rule.js +1 -1
  78. package/dist/lib/leak-filters/rules/FilterUnmountedFiberNode.rule.d.ts +1 -1
  79. package/dist/lib/leak-filters/rules/FilterUnmountedFiberNode.rule.js +1 -1
  80. package/dist/logger/LeakClusterLogger.d.ts +1 -1
  81. package/dist/logger/LeakClusterLogger.js +1 -1
  82. package/dist/logger/LeakTraceDetailsLogger.d.ts +1 -1
  83. package/dist/logger/LeakTraceDetailsLogger.js +1 -1
  84. package/dist/modes/BaseMode.d.ts +1 -1
  85. package/dist/modes/BaseMode.js +1 -1
  86. package/dist/modes/InteractionTestMode.d.ts +1 -1
  87. package/dist/modes/InteractionTestMode.js +1 -1
  88. package/dist/modes/MeasureMode.d.ts +1 -1
  89. package/dist/modes/MeasureMode.js +1 -1
  90. package/dist/modes/RunningModes.d.ts +1 -1
  91. package/dist/modes/RunningModes.js +1 -1
  92. package/dist/paths/TraceFinder.d.ts +1 -1
  93. package/dist/paths/TraceFinder.js +1 -1
  94. package/dist/trace-cluster/ClusterUtils.d.ts +1 -1
  95. package/dist/trace-cluster/ClusterUtils.js +1 -1
  96. package/dist/trace-cluster/ClusterUtilsHelper.d.ts +1 -1
  97. package/dist/trace-cluster/ClusterUtilsHelper.js +1 -1
  98. package/dist/trace-cluster/ClusteringHeuristics.d.ts +1 -1
  99. package/dist/trace-cluster/ClusteringHeuristics.js +1 -1
  100. package/dist/trace-cluster/EvalutationMetric.d.ts +1 -1
  101. package/dist/trace-cluster/EvalutationMetric.js +1 -1
  102. package/dist/trace-cluster/SequentialClustering.d.ts +1 -1
  103. package/dist/trace-cluster/SequentialClustering.js +1 -1
  104. package/dist/trace-cluster/TraceBucket.d.ts +1 -1
  105. package/dist/trace-cluster/TraceBucket.js +1 -1
  106. package/dist/trace-cluster/TraceElement.d.ts +1 -1
  107. package/dist/trace-cluster/TraceElement.js +1 -1
  108. package/dist/trace-cluster/strategies/MLTraceSimilarityStrategy.d.ts +1 -1
  109. package/dist/trace-cluster/strategies/MLTraceSimilarityStrategy.js +1 -1
  110. package/dist/trace-cluster/strategies/TraceAsClusterStrategy.d.ts +1 -1
  111. package/dist/trace-cluster/strategies/TraceAsClusterStrategy.js +1 -1
  112. package/dist/trace-cluster/strategies/TraceSimilarityStrategy.d.ts +1 -1
  113. package/dist/trace-cluster/strategies/TraceSimilarityStrategy.js +1 -1
  114. package/dist/trace-cluster/strategies/machine-learning/DistanceMatrix.d.ts +1 -1
  115. package/dist/trace-cluster/strategies/machine-learning/DistanceMatrix.js +1 -1
  116. package/dist/trace-cluster/strategies/machine-learning/HAC.d.ts +1 -1
  117. package/dist/trace-cluster/strategies/machine-learning/HAC.js +1 -1
  118. package/dist/trace-cluster/strategies/machine-learning/Ngram.d.ts +1 -1
  119. package/dist/trace-cluster/strategies/machine-learning/Ngram.js +1 -1
  120. package/dist/trace-cluster/strategies/machine-learning/TfidfVectorizer.d.ts +1 -1
  121. package/dist/trace-cluster/strategies/machine-learning/TfidfVectorizer.js +1 -1
  122. package/package.json +6 -5
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -136,11 +136,18 @@ function JSONifyNodeOneLevel(node) {
136
136
  });
137
137
  return info;
138
138
  }
139
- function JSONifyNodeShallow(node) {
139
+ // double check when you try to call JSONify methods
140
+ // other than JSONifyNodeShallow and JSONifyNodeInShort inside this method
141
+ // as it may trigger infinite recursion
142
+ function JSONifyNodeShallow(node, options = {}) {
140
143
  const info = Object.create(null);
144
+ options.processedNodeId = options.processedNodeId || new Set();
145
+ options.processedNodeId.add(node.id);
141
146
  iterateSelectedEdges(node, (edge) => {
147
+ var _a;
142
148
  const key = JSONifyEdgeNameAndType(edge);
143
- if (objectNodeUsefulProps.has(edge.name_or_index)) {
149
+ if (!((_a = options.processedNodeId) === null || _a === void 0 ? void 0 : _a.has(edge.toNode.id)) &&
150
+ objectNodeUsefulProps.has(edge.name_or_index)) {
144
151
  info[key] = JSONifyNodeShallow(edge.toNode);
145
152
  }
146
153
  else {
@@ -148,6 +155,7 @@ function JSONifyNodeShallow(node) {
148
155
  }
149
156
  return null;
150
157
  });
158
+ options.processedNodeId.delete(node.id);
151
159
  return info;
152
160
  }
153
161
  const fiberNodeUsefulProps = new Set([
@@ -324,9 +332,15 @@ function JSONifyNode(node, args, options) {
324
332
  return {};
325
333
  }
326
334
  let info;
335
+ // defense against infinite recursion
336
+ if (options.processedNodeId.has(node.id)) {
337
+ info = JSONifyNodeShallow(node);
338
+ return info;
339
+ }
340
+ options.processedNodeId.add(node.id);
327
341
  const depths = options.forceJSONifyDepth;
328
342
  if (Utils_1.default.isDetachedDOMNode(node) && depths !== 0) {
329
- info = JSONifyDetachedHTMLElement(node, args, EMPTY_JSONIFY_OPTIONS);
343
+ info = JSONifyDetachedHTMLElement(node, args, Object.assign(Object.assign({}, EMPTY_JSONIFY_OPTIONS), { processedNodeId: options.processedNodeId }));
330
344
  }
331
345
  else if (Utils_1.default.isFiberNode(node) && depths !== 0) {
332
346
  info = JSONifyFiberNode(node, args, options);
@@ -349,6 +363,7 @@ function JSONifyNode(node, args, options) {
349
363
  else {
350
364
  info = JSONifyOrdinaryValue(node, args, options);
351
365
  }
366
+ options.processedNodeId.delete(node.id);
352
367
  if (node.location) {
353
368
  info[`${filterJSONPropName('allocation location (extra)')}`] = {
354
369
  script_id: node.location.script_id,
@@ -376,7 +391,7 @@ function JSONifyPath(path, _snapshot, args) {
376
391
  let idx = 0;
377
392
  let encounterDetachedNode = false;
378
393
  ret['$tabsOrder:' + JSONifyTabsOrder()] = '';
379
- ret[`${idx++}: ${getNodeNameInJSON(path.node, args)}`] = JSONifyNode(path.node, args, EMPTY_JSONIFY_OPTIONS);
394
+ ret[`${idx++}: ${getNodeNameInJSON(path.node, args)}`] = JSONifyNode(path.node, args, Object.assign(Object.assign({}, EMPTY_JSONIFY_OPTIONS), { processedNodeId: new Set() }));
380
395
  let pathItem = path;
381
396
  while (pathItem === null || pathItem === void 0 ? void 0 : pathItem.edge) {
382
397
  const edge = pathItem.edge;
@@ -386,7 +401,7 @@ function JSONifyPath(path, _snapshot, args) {
386
401
  nextNode.highlight = true;
387
402
  }
388
403
  const edgeRetainSize = pathItem.edgeRetainSize;
389
- ret[`${idx++}: ${getEdgeNameInJSON(edge, edgeRetainSize)}${getNodeNameInJSON(nextNode, args)}`] = JSONifyNode(nextNode, args, EMPTY_JSONIFY_OPTIONS);
404
+ ret[`${idx++}: ${getEdgeNameInJSON(edge, edgeRetainSize)}${getNodeNameInJSON(nextNode, args)}`] = JSONifyNode(nextNode, args, Object.assign(Object.assign({}, EMPTY_JSONIFY_OPTIONS), { processedNodeId: new Set() }));
390
405
  pathItem = pathItem.next;
391
406
  }
392
407
  return ret;
@@ -553,15 +568,17 @@ function summarizeNodeShape(node, options = {}) {
553
568
  return summarizeObjectShape(node, options);
554
569
  }
555
570
  function summarizeUnboundedObjects(unboundedObjects, options = {}) {
556
- const sizeSep = options.color ? chalk_1.default.grey(' > ') : ' > ';
571
+ const historySeparator = options.color ? chalk_1.default.grey(' > ') : ' > ';
557
572
  const prefix = options.color ? chalk_1.default.grey('· ') : '· ';
558
573
  const opt = Object.assign({ compact: true }, options);
559
574
  return unboundedObjects
560
575
  .map(item => {
576
+ var _a;
561
577
  const id = options.color ? chalk_1.default.grey(`@${item.id}`) : `@${item.id}`;
562
578
  const name = summarizeNodeShape(item.node, opt);
579
+ const formatter = (_a = item.historyNumberFormatter) !== null && _a !== void 0 ? _a : Utils_1.default.getReadableBytes.bind(Utils_1.default);
563
580
  return (`${prefix}${name} [${item.type}](${id}): ` +
564
- item.history.map(v => Utils_1.default.getReadableBytes(v)).join(sizeSep));
581
+ item.history.map(v => formatter(v)).join(historySeparator));
565
582
  })
566
583
  .join('\n');
567
584
  }
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @format
8
8
  * @lightSyntaxTransform
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  /// <reference types="node" />
12
12
  declare type ReadFileOptions = {
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @format
8
8
  * @lightSyntaxTransform
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  'use strict';
12
12
  var __importDefault = (this && this.__importDefault) || function (mod) {
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import { ParsedArgs } from 'minimist';
11
11
  import type { LaunchOptions, Page } from 'puppeteer';
@@ -361,7 +361,7 @@ export declare type InteractionsCallback = (page: Page, args?: OperationArgs) =>
361
361
  * ```
362
362
  *
363
363
  * The test scenario instance can also be passed to the
364
- * [`run` API](../modules/api_src#run) exported by `@memlab/api`.
364
+ * {@link run} API exported by `@memlab/api`.
365
365
  * ```typescript
366
366
  * const {run} = require('@memlab/api');
367
367
  *
@@ -413,6 +413,34 @@ export interface IScenario {
413
413
  * ```
414
414
  */
415
415
  cookies?: () => Cookies;
416
+ /**
417
+ * `beforeInitialPageLoad` is the callback function that will be called only
418
+ * once before the initial page load. This callback can be used to set up
419
+ * the HTTP headers or to prepare data before loading the web page.
420
+ *
421
+ * * **Parameters**:
422
+ * * page: `Page` | the puppeteer [`Page`](https://pptr.dev/api/puppeteer.page)
423
+ * object, which provides APIs to interact with the web browser
424
+ *
425
+ * * **Examples**:
426
+ * ```typescript
427
+ * const scenario = {
428
+ * url: () => 'https://www.npmjs.com/',
429
+ * beforeInitialPageLoad: async (page) => {
430
+ * // before the initial page load
431
+ * },
432
+ * action: async (page) => {
433
+ * await page.click('a[href="/link"]');
434
+ * },
435
+ * back: async (page) => {
436
+ * await page.click('a[href="/back"]');
437
+ * },
438
+ * }
439
+ *
440
+ * module.exports = scenario;
441
+ * ```
442
+ */
443
+ beforeInitialPageLoad?: InteractionsCallback;
416
444
  /**
417
445
  * String value of the initial url of the page.
418
446
  *
@@ -924,7 +952,7 @@ export interface IHeapSnapshot {
924
952
  /**
925
953
  * Search for the heap and check if there is any JS object instance with
926
954
  * a specified constructor name.
927
- * @param className The contructor name of the object instance
955
+ * @param className The constructor name of the object instance
928
956
  * @returns `true` if there is at least one such object in the heap
929
957
  *
930
958
  * * **Examples**: you can write a jest unit test with memory assertions:
@@ -963,7 +991,7 @@ export interface IHeapSnapshot {
963
991
  /**
964
992
  * Search for the heap and get one of the JS object instances with
965
993
  * a specified constructor name (if there is any).
966
- * @param className The contructor name of the object instance
994
+ * @param className The constructor name of the object instance
967
995
  * @returns a handle pointing to any one of the object instances, returns
968
996
  * `null` if no such object exists in the heap.
969
997
  *
@@ -1092,6 +1120,10 @@ export interface IHeapLocation {
1092
1120
  * get the {@link IHeapSnapshot} containing this location instance
1093
1121
  */
1094
1122
  snapshot: IHeapSnapshot;
1123
+ /**
1124
+ * get the heap object this location this location represents
1125
+ */
1126
+ node: Nullable<IHeapNode>;
1095
1127
  /**
1096
1128
  * get the script ID of the source file
1097
1129
  */
package/dist/lib/Types.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  /* eslint-disable @typescript-eslint/no-explicit-any */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { HaltOrThrowOptions } from './Types';
11
11
  import type { Browser, Page } from 'puppeteer';
@@ -121,6 +121,7 @@ declare function haltOrThrow(errorInfo: string | Error, options?: HaltOrThrowOpt
121
121
  declare function getError(maybeError: unknown): Error;
122
122
  declare function isNodeDominatedByDeletionsArray(node: IHeapNode): boolean;
123
123
  declare function getUniqueID(): string;
124
+ declare function getClosureSourceUrl(node: IHeapNode): Nullable<string>;
124
125
  declare const _default: {
125
126
  applyToNodes: typeof applyToNodes;
126
127
  callAsync: typeof callAsync;
@@ -136,6 +137,7 @@ declare const _default: {
136
137
  extractHTMLElementNodeInfo: typeof extractHTMLElementNodeInfo;
137
138
  filterNodesInPlace: typeof filterNodesInPlace;
138
139
  getAllDominators: typeof getAllDominators;
140
+ getClosureSourceUrl: typeof getClosureSourceUrl;
139
141
  getConditionalDominatorIds: typeof getConditionalDominatorIds;
140
142
  getError: typeof getError;
141
143
  getEdgeByNameAndType: typeof getEdgeByNameAndType;
package/dist/lib/Utils.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
12
  if (k2 === undefined) k2 = k;
@@ -484,7 +484,10 @@ function checkScenarioInstance(s) {
484
484
  (s.repeat && typeof s.repeat !== 'function') ||
485
485
  (s.isPageLoaded && typeof s.isPageLoaded !== 'function') ||
486
486
  (s.leakFilter && typeof s.leakFilter !== 'function') ||
487
- (s.beforeLeakFilter && typeof s.beforeLeakFilter !== 'function')) {
487
+ (s.beforeLeakFilter && typeof s.beforeLeakFilter !== 'function') ||
488
+ (s.beforeInitialPageLoad &&
489
+ typeof s.beforeInitialPageLoad !== 'function') ||
490
+ (s.setup && typeof s.setup !== 'function')) {
488
491
  throw new Error('Invalid senario');
489
492
  }
490
493
  return s;
@@ -886,6 +889,11 @@ function isInterestingPath(p) {
886
889
  if (Config_1.default.hideBrowserLeak && styleEngineRetainsDetachedElement(p)) {
887
890
  return false;
888
891
  }
892
+ // if the path has pattern: Pending activitiies -> DetachedElement
893
+ if (Config_1.default.hideBrowserLeak &&
894
+ pendingActivitiesRetainsDetachedElementChain(p)) {
895
+ return false;
896
+ }
889
897
  return true;
890
898
  }
891
899
  // return true if the heap node represents JS object or closure
@@ -965,6 +973,29 @@ function styleEngineRetainsDetachedElement(path) {
965
973
  // check if the InternalNode is pointing to a detached element
966
974
  return !!p && isDetachedDOMNode(p.node);
967
975
  }
976
+ function pendingActivitiesRetainsDetachedElementChain(path) {
977
+ let p = path;
978
+ // find the Pending activities
979
+ while (p && p.node && !isPendingActivityNode(p.node)) {
980
+ p = p.next;
981
+ if (!p) {
982
+ return false;
983
+ }
984
+ }
985
+ p = p.next;
986
+ if (!p || !p.node) {
987
+ return false;
988
+ }
989
+ // all the following reference chain is detached DOM elements
990
+ // pointing to other detached DOM elements
991
+ while (p && p.node) {
992
+ if (!isDetachedDOMNode(p.node)) {
993
+ return false;
994
+ }
995
+ p = p.next;
996
+ }
997
+ return true;
998
+ }
968
999
  function pathHasDetachedHTMLNode(path) {
969
1000
  if (!path) {
970
1001
  return false;
@@ -1695,6 +1726,25 @@ let uindex = 1;
1695
1726
  function getUniqueID() {
1696
1727
  return `${process_1.default.pid}-${Date.now()}-${uindex++}`;
1697
1728
  }
1729
+ // try to get the url that defines the closure function
1730
+ // this is particular to heap snapshot taken from V8 in Chromium
1731
+ function getClosureSourceUrl(node) {
1732
+ var _a, _b;
1733
+ if (node.type !== 'closure') {
1734
+ return null;
1735
+ }
1736
+ const shared = node.getReferenceNode('shared', 'internal');
1737
+ if (!shared) {
1738
+ return null;
1739
+ }
1740
+ const debug = shared.getReferenceNode('script_or_debug_info', 'internal');
1741
+ if (!debug) {
1742
+ return null;
1743
+ }
1744
+ const urlNode = debug.getReferenceNode('name', 'internal');
1745
+ const url = (_b = (_a = urlNode === null || urlNode === void 0 ? void 0 : urlNode.toStringNode()) === null || _a === void 0 ? void 0 : _a.stringValue) !== null && _b !== void 0 ? _b : null;
1746
+ return url;
1747
+ }
1698
1748
  exports.default = {
1699
1749
  applyToNodes,
1700
1750
  callAsync,
@@ -1710,6 +1760,7 @@ exports.default = {
1710
1760
  extractHTMLElementNodeInfo,
1711
1761
  filterNodesInPlace,
1712
1762
  getAllDominators,
1763
+ getClosureSourceUrl,
1713
1764
  getConditionalDominatorIds,
1714
1765
  getError,
1715
1766
  getEdgeByNameAndType,
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @format
8
8
  * @lightSyntaxTransform
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  import type { IHeapEdge } from '../Types';
12
12
  import type HeapSnapshot from './HeapSnapshot';
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @format
8
8
  * @lightSyntaxTransform
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  'use strict';
12
12
  var __importDefault = (this && this.__importDefault) || function (mod) {
@@ -6,15 +6,16 @@
6
6
  *
7
7
  * @format
8
8
  * @lightSyntaxTransform
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
- import type { IHeapLocation } from '../Types';
11
+ import type { IHeapLocation, IHeapNode, Nullable } from '../Types';
12
12
  import type HeapSnapshot from './HeapSnapshot';
13
13
  export default class HeapLocation implements IHeapLocation {
14
14
  private heapSnapshot;
15
15
  private idx;
16
16
  constructor(heapSnapshot: HeapSnapshot, idx: number);
17
17
  get snapshot(): HeapSnapshot;
18
+ get node(): Nullable<IHeapNode>;
18
19
  get script_id(): number;
19
20
  get line(): number;
20
21
  get column(): number;
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @format
8
8
  * @lightSyntaxTransform
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  'use strict';
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -18,6 +18,13 @@ class HeapLocation {
18
18
  get snapshot() {
19
19
  return this.heapSnapshot;
20
20
  }
21
+ get node() {
22
+ const heapSnapshot = this.heapSnapshot;
23
+ const locations = heapSnapshot.snapshot.locations;
24
+ const locationFieldsCount = heapSnapshot._locationFieldsCount;
25
+ const objectIndex = locations[this.idx * locationFieldsCount + heapSnapshot._locationObjectIndexOffset];
26
+ return heapSnapshot.nodes.get(objectIndex);
27
+ }
21
28
  get script_id() {
22
29
  const heapSnapshot = this.heapSnapshot;
23
30
  const locations = heapSnapshot.snapshot.locations;
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @format
8
8
  * @lightSyntaxTransform
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  import type { IHeapNode, IHeapEdge, Nullable, EdgeIterationCallback, Predicator, IHeapStringNode } from '../Types';
12
12
  import type HeapSnapshot from './HeapSnapshot';
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @format
8
8
  * @lightSyntaxTransform
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  'use strict';
12
12
  var __importDefault = (this && this.__importDefault) || function (mod) {
@@ -257,7 +257,7 @@ class HeapNode {
257
257
  get location() {
258
258
  const heapSnapshot = this.heapSnapshot;
259
259
  const locationIdx = heapSnapshot._nodeIdx2LocationIdx[this.idx];
260
- if (locationIdx === undefined) {
260
+ if (locationIdx == null) {
261
261
  return null;
262
262
  }
263
263
  return new HeapLocation_1.default(heapSnapshot, locationIdx);
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @format
8
8
  * @lightSyntaxTransform
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  import type { IHeapNode, IHeapNodes, IHeapEdges, IHeapSnapshot, HeapNodeTypes, HeapEdgeTypes, HeapSnapshotMeta, RawHeapSnapshot, NumericDictionary, Nullable } from '../Types';
12
12
  import HeapNode from './HeapNode';
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @format
8
8
  * @lightSyntaxTransform
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  'use strict';
12
12
  var __importDefault = (this && this.__importDefault) || function (mod) {
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @format
8
8
  * @lightSyntaxTransform
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  import type { IHeapStringNode } from '../Types';
12
12
  import type HeapSnapshot from './HeapSnapshot';
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @format
8
8
  * @lightSyntaxTransform
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  'use strict';
12
12
  var __importDefault = (this && this.__importDefault) || function (mod) {
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @format
8
8
  * @lightSyntaxTransform
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  export declare const NodeDetachState: {
12
12
  Unknown: number;
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @format
8
8
  * @lightSyntaxTransform
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  'use strict';
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { AnyValue, IHeapSnapshot } from '../Types';
11
11
  declare type AnyObject = Record<AnyValue, AnyValue>;
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const __1 = require("../..");
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { MemLabConfig } from '../Config';
11
11
  import type { HeapNodeIdSet, IHeapNode, IHeapSnapshot } from '../Types';
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.LeakDecision = void 0;
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import { ILeakObjectFilterRule } from './BaseLeakFilter.rule';
11
11
  declare const _default: ILeakObjectFilterRule[];
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { MemLabConfig } from '../Config';
11
11
  import type { HeapNodeIdSet, IHeapNode, IHeapSnapshot } from '../Types';
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { MemLabConfig } from '../../Config';
11
11
  import type { HeapNodeIdSet, IHeapNode, IHeapSnapshot } from '../../Types';
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.FilterByExternalFilterRule = void 0;
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { MemLabConfig } from '../../Config';
11
11
  import type { IHeapNode } from '../../Types';
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { MemLabConfig } from '../../Config';
11
11
  import type { IHeapNode } from '../../Types';
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { MemLabConfig } from '../../Config';
11
11
  import type { IHeapNode } from '../../Types';
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.FilterOverSizedNodeAsLeakRule = void 0;
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { MemLabConfig } from '../../Config';
11
11
  import type { IHeapNode } from '../../Types';