@memlab/core 1.1.5 → 1.1.9

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 (120) hide show
  1. package/dist/__tests__/parser/HeapParser.test.d.ts +1 -1
  2. package/dist/__tests__/parser/HeapParser.test.js +3 -3
  3. package/dist/__tests__/parser/NodeHeap.test.d.ts +1 -1
  4. package/dist/__tests__/parser/NodeHeap.test.js +6 -6
  5. package/dist/__tests__/parser/StringNode.test.d.ts +1 -1
  6. package/dist/__tests__/parser/StringNode.test.js +2 -2
  7. package/dist/__tests__/parser/traverse/HeapNodeTraverse.test.d.ts +1 -1
  8. package/dist/__tests__/parser/traverse/HeapNodeTraverse.test.js +3 -3
  9. package/dist/__tests__/utils/utils.test.d.ts +1 -1
  10. package/dist/__tests__/utils/utils.test.js +1 -1
  11. package/dist/index.d.ts +4 -2
  12. package/dist/index.js +6 -3
  13. package/dist/lib/BaseOption.d.ts +1 -1
  14. package/dist/lib/BaseOption.js +1 -1
  15. package/dist/lib/BrowserInfo.d.ts +1 -1
  16. package/dist/lib/BrowserInfo.js +1 -1
  17. package/dist/lib/Config.d.ts +11 -2
  18. package/dist/lib/Config.js +25 -5
  19. package/dist/lib/Console.d.ts +1 -1
  20. package/dist/lib/Console.js +1 -1
  21. package/dist/lib/Constant.d.ts +1 -1
  22. package/dist/lib/Constant.js +1 -1
  23. package/dist/lib/FileManager.d.ts +1 -1
  24. package/dist/lib/FileManager.js +5 -3
  25. package/dist/lib/HeapAnalyzer.d.ts +1 -1
  26. package/dist/lib/HeapAnalyzer.js +26 -10
  27. package/dist/lib/HeapParser.d.ts +2 -2
  28. package/dist/lib/HeapParser.js +2 -2
  29. package/dist/lib/InternalValueSetter.d.ts +1 -1
  30. package/dist/lib/InternalValueSetter.js +1 -1
  31. package/dist/lib/NodeHeap.d.ts +53 -10
  32. package/dist/lib/NodeHeap.js +73 -22
  33. package/dist/lib/PackageInfoLoader.js +2 -2
  34. package/dist/lib/ProcessManager.d.ts +1 -1
  35. package/dist/lib/ProcessManager.js +1 -1
  36. package/dist/lib/Serializer.d.ts +1 -1
  37. package/dist/lib/Serializer.js +49 -26
  38. package/dist/lib/StringLoader.d.ts +2 -2
  39. package/dist/lib/StringLoader.js +2 -2
  40. package/dist/lib/Types.d.ts +111 -36
  41. package/dist/lib/Types.js +1 -1
  42. package/dist/lib/Utils.d.ts +1 -1
  43. package/dist/lib/Utils.js +55 -31
  44. package/dist/lib/heap-data/HeapEdge.d.ts +2 -2
  45. package/dist/lib/heap-data/HeapEdge.js +2 -2
  46. package/dist/lib/heap-data/HeapLocation.d.ts +2 -2
  47. package/dist/lib/heap-data/HeapLocation.js +2 -2
  48. package/dist/lib/heap-data/HeapNode.d.ts +3 -2
  49. package/dist/lib/heap-data/HeapNode.js +6 -2
  50. package/dist/lib/heap-data/HeapSnapshot.d.ts +3 -2
  51. package/dist/lib/heap-data/HeapSnapshot.js +6 -33
  52. package/dist/lib/heap-data/HeapStringNode.d.ts +2 -2
  53. package/dist/lib/heap-data/HeapStringNode.js +4 -2
  54. package/dist/lib/heap-data/HeapUtils.d.ts +2 -2
  55. package/dist/lib/heap-data/HeapUtils.js +2 -2
  56. package/dist/lib/heap-data/MemLabTagStore.d.ts +23 -0
  57. package/dist/lib/heap-data/MemLabTagStore.js +110 -0
  58. package/dist/lib/leak-filters/BaseLeakFilter.rule.d.ts +1 -1
  59. package/dist/lib/leak-filters/BaseLeakFilter.rule.js +1 -1
  60. package/dist/lib/leak-filters/LeakFilterRuleList.d.ts +1 -1
  61. package/dist/lib/leak-filters/LeakFilterRuleList.js +1 -1
  62. package/dist/lib/leak-filters/LeakObjectFilter.d.ts +1 -1
  63. package/dist/lib/leak-filters/LeakObjectFilter.js +1 -1
  64. package/dist/lib/leak-filters/rules/FilterByExternalFilter.rule.d.ts +1 -1
  65. package/dist/lib/leak-filters/rules/FilterByExternalFilter.rule.js +1 -1
  66. package/dist/lib/leak-filters/rules/FilterDetachedDOMElement.rule.d.ts +1 -1
  67. package/dist/lib/leak-filters/rules/FilterDetachedDOMElement.rule.js +1 -1
  68. package/dist/lib/leak-filters/rules/FilterHermesNode.rule.d.ts +1 -1
  69. package/dist/lib/leak-filters/rules/FilterHermesNode.rule.js +1 -1
  70. package/dist/lib/leak-filters/rules/FilterOverSizedNodeAsLeak.rule.d.ts +1 -1
  71. package/dist/lib/leak-filters/rules/FilterOverSizedNodeAsLeak.rule.js +1 -1
  72. package/dist/lib/leak-filters/rules/FilterStackTraceFrame.rule.d.ts +1 -1
  73. package/dist/lib/leak-filters/rules/FilterStackTraceFrame.rule.js +1 -1
  74. package/dist/lib/leak-filters/rules/FilterTrivialNode.rule.d.ts +1 -1
  75. package/dist/lib/leak-filters/rules/FilterTrivialNode.rule.js +1 -1
  76. package/dist/lib/leak-filters/rules/FilterUnmountedFiberNode.rule.d.ts +1 -1
  77. package/dist/lib/leak-filters/rules/FilterUnmountedFiberNode.rule.js +1 -1
  78. package/dist/logger/LeakClusterLogger.d.ts +1 -1
  79. package/dist/logger/LeakClusterLogger.js +1 -1
  80. package/dist/logger/LeakTraceDetailsLogger.d.ts +1 -1
  81. package/dist/logger/LeakTraceDetailsLogger.js +1 -1
  82. package/dist/modes/BaseMode.d.ts +1 -1
  83. package/dist/modes/BaseMode.js +1 -1
  84. package/dist/modes/InteractionTestMode.d.ts +1 -1
  85. package/dist/modes/InteractionTestMode.js +1 -1
  86. package/dist/modes/MeasureMode.d.ts +1 -1
  87. package/dist/modes/MeasureMode.js +1 -1
  88. package/dist/modes/RunningModes.d.ts +1 -1
  89. package/dist/modes/RunningModes.js +1 -1
  90. package/dist/paths/TraceFinder.d.ts +1 -1
  91. package/dist/paths/TraceFinder.js +41 -42
  92. package/dist/trace-cluster/ClusterUtils.d.ts +1 -1
  93. package/dist/trace-cluster/ClusterUtils.js +1 -1
  94. package/dist/trace-cluster/ClusterUtilsHelper.d.ts +1 -1
  95. package/dist/trace-cluster/ClusterUtilsHelper.js +1 -1
  96. package/dist/trace-cluster/ClusteringHeuristics.d.ts +1 -1
  97. package/dist/trace-cluster/ClusteringHeuristics.js +1 -1
  98. package/dist/trace-cluster/EvalutationMetric.d.ts +1 -1
  99. package/dist/trace-cluster/EvalutationMetric.js +1 -1
  100. package/dist/trace-cluster/SequentialClustering.d.ts +17 -0
  101. package/dist/trace-cluster/SequentialClustering.js +47 -0
  102. package/dist/trace-cluster/TraceBucket.d.ts +2 -1
  103. package/dist/trace-cluster/TraceBucket.js +10 -2
  104. package/dist/trace-cluster/TraceElement.d.ts +3 -1
  105. package/dist/trace-cluster/TraceElement.js +7 -1
  106. package/dist/trace-cluster/strategies/MLTraceSimilarityStrategy.d.ts +15 -0
  107. package/dist/trace-cluster/strategies/MLTraceSimilarityStrategy.js +61 -0
  108. package/dist/trace-cluster/strategies/TraceAsClusterStrategy.d.ts +1 -1
  109. package/dist/trace-cluster/strategies/TraceAsClusterStrategy.js +1 -1
  110. package/dist/trace-cluster/strategies/TraceSimilarityStrategy.d.ts +1 -1
  111. package/dist/trace-cluster/strategies/TraceSimilarityStrategy.js +1 -1
  112. package/dist/trace-cluster/strategies/machine-learning/DistanceMatrix.d.ts +11 -0
  113. package/dist/trace-cluster/strategies/machine-learning/DistanceMatrix.js +54 -0
  114. package/dist/trace-cluster/strategies/machine-learning/HAC.d.ts +17 -0
  115. package/dist/trace-cluster/strategies/machine-learning/HAC.js +122 -0
  116. package/dist/trace-cluster/strategies/machine-learning/Ngram.d.ts +11 -0
  117. package/dist/trace-cluster/strategies/machine-learning/Ngram.js +22 -0
  118. package/dist/trace-cluster/strategies/machine-learning/TfidfVectorizer.d.ts +38 -0
  119. package/dist/trace-cluster/strategies/machine-learning/TfidfVectorizer.js +144 -0
  120. package/package.json +1 -1
@@ -4,8 +4,8 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
7
  * @format
8
+ * @oncall ws_labs
9
9
  */
10
10
  import type { IHeapSnapshot } from './Types';
11
11
  /**
@@ -22,7 +22,7 @@ import type { IHeapSnapshot } from './Types';
22
22
  * * **Examples**:
23
23
  * ```typescript
24
24
  * import type {IHeapSnapshot, AnyValue} from '@memlab/core';
25
- * import {config, getNodeInnocentHeap, tagObject} from '@memlab/core';
25
+ * import {config, takeNodeMinimalHeap, tagObject} from '@memlab/core';
26
26
  *
27
27
  * test('memory test', async () => {
28
28
  * config.muteConsole = true;
@@ -36,7 +36,7 @@ import type { IHeapSnapshot } from './Types';
36
36
  *
37
37
  * o2 = null;
38
38
  *
39
- * const heap: IHeapSnapshot = await getNodeInnocentHeap();
39
+ * const heap: IHeapSnapshot = await takeNodeMinimalHeap();
40
40
  *
41
41
  * // expect object with marker "memlab-mark-1" exists
42
42
  * expect(heap.hasObjectWithTag('memlab-mark-1')).toBe(true);
@@ -48,6 +48,26 @@ import type { IHeapSnapshot } from './Types';
48
48
  * ```
49
49
  */
50
50
  export declare function tagObject<T extends object>(o: T, tag: string): T;
51
+ /**
52
+ * Take a heap snapshot of the current program state and save it as a
53
+ * `.heapsnapshot` file under a randomly generated folder inside the system's
54
+ * temp folder.
55
+ *
56
+ * **Note**: All `.heapsnapshot` files could also be loaded by Chrome DevTools.
57
+ * @returns the absolute file path to the saved `.heapsnapshot` file.
58
+ *
59
+ * * **Examples**:
60
+ * ```typescript
61
+ * import type {IHeapSnapshot} from '@memlab/core';
62
+ * import {dumpNodeHeapSnapshot} from '@memlab/core';
63
+ * import {getFullHeapFromFile} from '@memlab/heap-analysis';
64
+ *
65
+ * (async function () {
66
+ * const heapFile = dumpNodeHeapSnapshot();
67
+ * const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);
68
+ * })();
69
+ * ```
70
+ */
51
71
  export declare function dumpNodeHeapSnapshot(): string;
52
72
  /**
53
73
  * Take a heap snapshot of the current program state
@@ -57,19 +77,42 @@ export declare function dumpNodeHeapSnapshot(): string;
57
77
  *
58
78
  * @returns heap representation without heap analysis meta data.
59
79
  *
60
- * If you need to get the heap snapshot with heap analysis meta data
61
- * use {@link dumpNodeHeapSnapshot} and {@link getHeapFromFile},
62
- * for example:
80
+ * @deprecated
81
+ * @internal
82
+ *
83
+ * If you need to get the heap snapshot with heap analysis meta data, please
84
+ * use {@link takeNodeFullHeap}.
85
+ * For example:
63
86
  * ```typescript
64
87
  * import type {IHeapSnapshot} from '@memlab/core';
65
- * import {dumpNodeHeapSnapshot} from '@memlab/core';
66
- * import {getHeapFromFile} from '@memlab/heap-analysis';
88
+ * import {takeNodeFullHeap} from '@memlab/heap-analysis';
67
89
  *
68
90
  * (async function () {
69
- * const heapFile = dumpNodeHeapSnapshot();
70
- * const heap: IHeapSnapshot = await getHeapFromFile(heapFile);
91
+ * const heap: IHeapSnapshot = await takeNodeFullHeap();
71
92
  * })();
72
93
  * ```
73
94
  */
74
95
  export declare function getNodeInnocentHeap(): Promise<IHeapSnapshot>;
96
+ /**
97
+ * Take a heap snapshot of the current program state
98
+ * and parse it as {@link IHeapSnapshot}. Notice that
99
+ * this API does not calculate some heap analysis meta data
100
+ * for heap analysis. But this also means faster heap parsing.
101
+ *
102
+ * @returns heap representation without heap analysis meta data.
103
+ *
104
+ * * **Examples:**
105
+ * ```typescript
106
+ * import type {IHeapSnapshot} from '@memlab/core';
107
+ * import {takeNodeMinimalHeap} from '@memlab/core';
108
+ *
109
+ * (async function () {
110
+ * const heap: IHeapSnapshot = await takeNodeMinimalHeap();
111
+ * })();
112
+ * ```
113
+ *
114
+ * If you need to get the heap snapshot with heap analysis meta data, please
115
+ * use {@link getFullHeapFromFile}.
116
+ */
117
+ export declare function takeNodeMinimalHeap(): Promise<IHeapSnapshot>;
75
118
  //# sourceMappingURL=NodeHeap.d.ts.map
@@ -5,8 +5,8 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
- * @emails oncall+ws_labs
9
8
  * @format
9
+ * @oncall ws_labs
10
10
  */
11
11
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
12
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -21,18 +21,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
21
21
  return (mod && mod.__esModule) ? mod : { "default": mod };
22
22
  };
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.getNodeInnocentHeap = exports.dumpNodeHeapSnapshot = exports.tagObject = void 0;
24
+ exports.takeNodeMinimalHeap = exports.getNodeInnocentHeap = exports.dumpNodeHeapSnapshot = exports.tagObject = void 0;
25
25
  const fs_extra_1 = __importDefault(require("fs-extra"));
26
26
  const path_1 = __importDefault(require("path"));
27
27
  const v8_1 = __importDefault(require("v8"));
28
28
  const FileManager_1 = __importDefault(require("./FileManager"));
29
29
  const Utils_1 = __importDefault(require("./Utils"));
30
- class MemLabTaggedStore {
31
- constructor() {
32
- this.taggedObjects = Object.create(null);
33
- }
34
- }
35
- const store = new MemLabTaggedStore();
30
+ const MemLabTagStore_1 = __importDefault(require("./heap-data/MemLabTagStore"));
36
31
  /**
37
32
  * Tags a string marker to an object instance, which can later be checked by
38
33
  * {@link hasObjectWithTag}. This API does not modify the object instance in
@@ -47,7 +42,7 @@ const store = new MemLabTaggedStore();
47
42
  * * **Examples**:
48
43
  * ```typescript
49
44
  * import type {IHeapSnapshot, AnyValue} from '@memlab/core';
50
- * import {config, getNodeInnocentHeap, tagObject} from '@memlab/core';
45
+ * import {config, takeNodeMinimalHeap, tagObject} from '@memlab/core';
51
46
  *
52
47
  * test('memory test', async () => {
53
48
  * config.muteConsole = true;
@@ -61,7 +56,7 @@ const store = new MemLabTaggedStore();
61
56
  *
62
57
  * o2 = null;
63
58
  *
64
- * const heap: IHeapSnapshot = await getNodeInnocentHeap();
59
+ * const heap: IHeapSnapshot = await takeNodeMinimalHeap();
65
60
  *
66
61
  * // expect object with marker "memlab-mark-1" exists
67
62
  * expect(heap.hasObjectWithTag('memlab-mark-1')).toBe(true);
@@ -73,15 +68,36 @@ const store = new MemLabTaggedStore();
73
68
  * ```
74
69
  */
75
70
  function tagObject(o, tag) {
76
- if (!store.taggedObjects[tag]) {
77
- store.taggedObjects[tag] = new WeakSet();
78
- }
79
- store.taggedObjects[tag].add(o);
71
+ MemLabTagStore_1.default.tagObject(o, tag);
80
72
  return o;
81
73
  }
82
74
  exports.tagObject = tagObject;
75
+ /**
76
+ * Take a heap snapshot of the current program state and save it as a
77
+ * `.heapsnapshot` file under a randomly generated folder inside the system's
78
+ * temp folder.
79
+ *
80
+ * **Note**: All `.heapsnapshot` files could also be loaded by Chrome DevTools.
81
+ * @returns the absolute file path to the saved `.heapsnapshot` file.
82
+ *
83
+ * * **Examples**:
84
+ * ```typescript
85
+ * import type {IHeapSnapshot} from '@memlab/core';
86
+ * import {dumpNodeHeapSnapshot} from '@memlab/core';
87
+ * import {getFullHeapFromFile} from '@memlab/heap-analysis';
88
+ *
89
+ * (async function () {
90
+ * const heapFile = dumpNodeHeapSnapshot();
91
+ * const heap: IHeapSnapshot = await getFullHeapFromFile(heapFile);
92
+ * })();
93
+ * ```
94
+ */
83
95
  function dumpNodeHeapSnapshot() {
84
- const file = path_1.default.join(FileManager_1.default.generateTmpHeapDir(), `nodejs.heapsnapshot`);
96
+ const randomID = `Math.random()`.replace('0.', '');
97
+ const file = path_1.default.join(FileManager_1.default.generateTmpHeapDir(), `nodejs-${randomID}.heapsnapshot`);
98
+ if (fs_extra_1.default.existsSync(file)) {
99
+ fs_extra_1.default.removeSync(file);
100
+ }
85
101
  v8_1.default.writeHeapSnapshot(file);
86
102
  return file;
87
103
  }
@@ -94,17 +110,18 @@ exports.dumpNodeHeapSnapshot = dumpNodeHeapSnapshot;
94
110
  *
95
111
  * @returns heap representation without heap analysis meta data.
96
112
  *
97
- * If you need to get the heap snapshot with heap analysis meta data
98
- * use {@link dumpNodeHeapSnapshot} and {@link getHeapFromFile},
99
- * for example:
113
+ * @deprecated
114
+ * @internal
115
+ *
116
+ * If you need to get the heap snapshot with heap analysis meta data, please
117
+ * use {@link takeNodeFullHeap}.
118
+ * For example:
100
119
  * ```typescript
101
120
  * import type {IHeapSnapshot} from '@memlab/core';
102
- * import {dumpNodeHeapSnapshot} from '@memlab/core';
103
- * import {getHeapFromFile} from '@memlab/heap-analysis';
121
+ * import {takeNodeFullHeap} from '@memlab/heap-analysis';
104
122
  *
105
123
  * (async function () {
106
- * const heapFile = dumpNodeHeapSnapshot();
107
- * const heap: IHeapSnapshot = await getHeapFromFile(heapFile);
124
+ * const heap: IHeapSnapshot = await takeNodeFullHeap();
108
125
  * })();
109
126
  * ```
110
127
  */
@@ -121,3 +138,37 @@ function getNodeInnocentHeap() {
121
138
  });
122
139
  }
123
140
  exports.getNodeInnocentHeap = getNodeInnocentHeap;
141
+ /**
142
+ * Take a heap snapshot of the current program state
143
+ * and parse it as {@link IHeapSnapshot}. Notice that
144
+ * this API does not calculate some heap analysis meta data
145
+ * for heap analysis. But this also means faster heap parsing.
146
+ *
147
+ * @returns heap representation without heap analysis meta data.
148
+ *
149
+ * * **Examples:**
150
+ * ```typescript
151
+ * import type {IHeapSnapshot} from '@memlab/core';
152
+ * import {takeNodeMinimalHeap} from '@memlab/core';
153
+ *
154
+ * (async function () {
155
+ * const heap: IHeapSnapshot = await takeNodeMinimalHeap();
156
+ * })();
157
+ * ```
158
+ *
159
+ * If you need to get the heap snapshot with heap analysis meta data, please
160
+ * use {@link getFullHeapFromFile}.
161
+ */
162
+ function takeNodeMinimalHeap() {
163
+ return __awaiter(this, void 0, void 0, function* () {
164
+ const file = dumpNodeHeapSnapshot();
165
+ const snapshot = yield Utils_1.default.getSnapshotFromFile(file, {
166
+ buildNodeIdIndex: true,
167
+ });
168
+ fs_extra_1.default.unlink(file, () => {
169
+ // do nothing
170
+ });
171
+ return snapshot;
172
+ });
173
+ }
174
+ exports.takeNodeMinimalHeap = takeNodeMinimalHeap;
@@ -19,8 +19,8 @@ exports.PackageInfoLoader = void 0;
19
19
  * This source code is licensed under the MIT license found in the
20
20
  * LICENSE file in the root directory of this source tree.
21
21
  *
22
- * @emails oncall+ws_labs
23
22
  * @format
23
+ * @oncall ws_labs
24
24
  */
25
25
  const fs_extra_1 = __importDefault(require("fs-extra"));
26
26
  const path_1 = __importDefault(require("path"));
@@ -57,7 +57,7 @@ class PackageInfoLoader {
57
57
  if (!PackageInfoLoader.registeredPackages.has(packageDirectory)) {
58
58
  PackageInfoLoader.registeredPackages.add(packageDirectory);
59
59
  const packageInfo = yield PackageInfoLoader.loadFrom(packageDirectory);
60
- Config_1.default._packageInfo.push(packageInfo);
60
+ Config_1.default.packageInfo.push(packageInfo);
61
61
  }
62
62
  });
63
63
  }
@@ -4,8 +4,8 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
7
  * @format
8
+ * @oncall ws_labs
9
9
  */
10
10
  import type { Command, Optional } from './Types';
11
11
  declare type Options = {
@@ -5,8 +5,8 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
- * @emails oncall+ws_labs
9
8
  * @format
9
+ * @oncall ws_labs
10
10
  */
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -4,8 +4,8 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
7
  * @format
8
+ * @oncall ws_labs
9
9
  */
10
10
  import { E2EStepInfo, HeapNodeIdSet, IHeapEdge, IHeapNode, IHeapSnapshot, ISerializedInfo, LeakTracePathItem, Nullable } from './Types';
11
11
  declare type JSONifyArgs = {
@@ -5,8 +5,8 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
- * @emails oncall+ws_labs
9
8
  * @format
9
+ * @oncall ws_labs
10
10
  */
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -99,7 +99,7 @@ function JSONifyDetachedHTMLElement(node, args, options) {
99
99
  // options for elem.__reactProps$xxx
100
100
  const propsOptions = Object.assign({}, options);
101
101
  propsOptions.forceJSONifyDepth = 1;
102
- for (const edge of node.references) {
102
+ iterateSelectedEdges(node, (edge) => {
103
103
  const key = JSONifyEdgeNameAndType(edge);
104
104
  if (Utils_1.default.isReactFiberEdge(edge)) {
105
105
  info[key] = JSONifyNode(edge.toNode, args, fiberOptions);
@@ -110,7 +110,8 @@ function JSONifyDetachedHTMLElement(node, args, options) {
110
110
  else {
111
111
  info[key] = JSONifyNodeInShort(edge.toNode);
112
112
  }
113
- }
113
+ return null;
114
+ });
114
115
  return info;
115
116
  }
116
117
  function calculateReturnTrace(node, cache) {
@@ -128,15 +129,16 @@ function calculateReturnTrace(node, cache) {
128
129
  const objectNodeUsefulProps = new Set(['_context']);
129
130
  function JSONifyNodeOneLevel(node) {
130
131
  const info = Object.create(null);
131
- for (const edge of node.references) {
132
+ iterateSelectedEdges(node, (edge) => {
132
133
  const key = JSONifyEdgeNameAndType(edge);
133
134
  info[key] = JSONifyNodeShallow(edge.toNode);
134
- }
135
+ return null;
136
+ });
135
137
  return info;
136
138
  }
137
139
  function JSONifyNodeShallow(node) {
138
140
  const info = Object.create(null);
139
- for (const edge of node.references) {
141
+ iterateSelectedEdges(node, (edge) => {
140
142
  const key = JSONifyEdgeNameAndType(edge);
141
143
  if (objectNodeUsefulProps.has(edge.name_or_index)) {
142
144
  info[key] = JSONifyNodeShallow(edge.toNode);
@@ -144,7 +146,8 @@ function JSONifyNodeShallow(node) {
144
146
  else {
145
147
  info[key] = JSONifyNodeInShort(edge.toNode);
146
148
  }
147
- }
149
+ return null;
150
+ });
148
151
  return info;
149
152
  }
150
153
  const fiberNodeUsefulProps = new Set([
@@ -154,15 +157,17 @@ const fiberNodeUsefulProps = new Set([
154
157
  ]);
155
158
  function JSONifyFiberNodeShallow(node) {
156
159
  const info = Object.create(null);
157
- for (const edge of node.references) {
160
+ iterateSelectedEdges(node, (edge) => {
158
161
  const key = JSONifyEdgeNameAndType(edge);
159
162
  if (fiberNodeUsefulProps.has(edge.name_or_index) &&
160
163
  Utils_1.default.isObjectNode(edge.toNode)) {
161
164
  info[key] = JSONifyNodeShallow(edge.toNode);
162
- continue;
163
165
  }
164
- info[key] = JSONifyNodeInShort(edge.toNode);
165
- }
166
+ else {
167
+ info[key] = JSONifyNodeInShort(edge.toNode);
168
+ }
169
+ return null;
170
+ });
166
171
  return info;
167
172
  }
168
173
  // calculate the summary of return chain of the FiberNode
@@ -187,7 +192,9 @@ function JSONifyFiberNodeReturnTrace(node, args, options) {
187
192
  }
188
193
  const parentInfo = getNodeNameInJSON(parent, args);
189
194
  key = `${key}: --return (property)---> ${parentInfo}`;
190
- const info = JSONifyFiberNodeShallow(parent);
195
+ const info = Config_1.default.includeObjectInfoInTraceReturnChain
196
+ ? JSONifyFiberNodeShallow(parent)
197
+ : Object.create(null);
191
198
  trace[key] = info;
192
199
  }
193
200
  return trace;
@@ -206,25 +213,27 @@ function JSONifyFiberNode(node, args, options) {
206
213
  propsOptions.forceJSONifyDepth = 1;
207
214
  }
208
215
  propsOptions.forceJSONifyDepth--;
209
- for (const edge of node.references) {
216
+ iterateSelectedEdges(node, (edge) => {
210
217
  const key = JSONifyEdgeNameAndType(edge);
211
218
  info[key] =
212
- propsOptions.forceJSONifyDepth >= 1
219
+ propsOptions.forceJSONifyDepth && propsOptions.forceJSONifyDepth >= 1
213
220
  ? JSONifyNode(edge.toNode, args, propsOptions)
214
221
  : JSONifyNodeInShort(edge.toNode);
215
- }
222
+ return null;
223
+ });
216
224
  return info;
217
225
  }
218
226
  function JSONifyClosure(node, args, options) {
219
227
  const info = Object.create(null);
220
- for (const edge of node.references) {
228
+ iterateSelectedEdges(node, (edge) => {
221
229
  if (edge.name_or_index === 'shared' ||
222
230
  edge.name_or_index === 'context' ||
223
231
  edge.name_or_index === 'displayName') {
224
232
  const key = filterJSONPropName(edge.name_or_index);
225
233
  info[key] = JSONifyNode(edge.toNode, args, options);
226
234
  }
227
- }
235
+ return null;
236
+ });
228
237
  return info;
229
238
  }
230
239
  function JSONifyNumberNode(node,
@@ -238,7 +247,7 @@ _options) {
238
247
  }
239
248
  function JSONifyCode(node, args, options) {
240
249
  const info = Object.create(null);
241
- for (const edge of node.references) {
250
+ iterateSelectedEdges(node, (edge) => {
242
251
  if (edge.name_or_index === 'name_or_scope_info' &&
243
252
  edge.toNode.name === '(function scope info)') {
244
253
  const key = 'variables with non-number values in closure scope chain';
@@ -251,14 +260,15 @@ function JSONifyCode(node, args, options) {
251
260
  const key = filterJSONPropName(edge.name_or_index);
252
261
  info[key] = JSONifyNode(edge.toNode, args, options);
253
262
  }
254
- }
263
+ return null;
264
+ });
255
265
  return info;
256
266
  }
257
267
  function JSONifyContext(node, args, options) {
258
268
  const info = Object.create(null);
259
269
  const key = 'variables in scope (used by nested closures)';
260
270
  const closure_vars = (info[key] = Object.create(null));
261
- for (const edge of node.references) {
271
+ iterateSelectedEdges(node, (edge) => {
262
272
  const key = filterJSONPropName(edge.name_or_index);
263
273
  if (edge.type === 'context') {
264
274
  closure_vars[key] = JSONifyNodeInShort(edge.toNode);
@@ -266,15 +276,27 @@ function JSONifyContext(node, args, options) {
266
276
  else if (edge.type === '') {
267
277
  info[key] = JSONifyNode(edge.toNode, args, options);
268
278
  }
269
- }
279
+ return null;
280
+ });
270
281
  return info;
271
282
  }
283
+ function iterateSelectedEdges(node, callback) {
284
+ let edgesProcessed = 0;
285
+ node.forEachReference((edge) => {
286
+ if (edge.type === 'internal') {
287
+ if (edge.name_or_index === 'map' || edge.is_index) {
288
+ return;
289
+ }
290
+ }
291
+ if (edgesProcessed++ > 100) {
292
+ return { stop: true };
293
+ }
294
+ return callback(edge);
295
+ });
296
+ }
272
297
  function JSONifyOrdinaryValue(node, args, options) {
273
298
  const info = Object.create(null);
274
- for (const edge of node.references) {
275
- if (edge.name_or_index === 'map' && edge.type === 'internal') {
276
- continue;
277
- }
299
+ iterateSelectedEdges(node, (edge) => {
278
300
  const key = JSONifyEdgeNameAndType(edge);
279
301
  const toNode = edge.toNode;
280
302
  const toNodeName = toNode.name;
@@ -293,7 +315,8 @@ function JSONifyOrdinaryValue(node, args, options) {
293
315
  else {
294
316
  info[key] = JSONifyNodeInShort(toNode);
295
317
  }
296
- }
318
+ return null;
319
+ });
297
320
  return info;
298
321
  }
299
322
  function JSONifyNode(node, args, options) {
@@ -4,9 +4,9 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
- * @lightSyntaxTransform
9
7
  * @format
8
+ * @lightSyntaxTransform
9
+ * @oncall ws_labs
10
10
  */
11
11
  /// <reference types="node" />
12
12
  declare type ReadFileOptions = {
@@ -4,9 +4,9 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
- * @lightSyntaxTransform
9
7
  * @format
8
+ * @lightSyntaxTransform
9
+ * @oncall ws_labs
10
10
  */
11
11
  'use strict';
12
12
  var __importDefault = (this && this.__importDefault) || function (mod) {