@memlab/core 1.0.0

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 (130) hide show
  1. package/README.md +11 -0
  2. package/dist/__tests__/parser/HeapParser.test.d.ts +11 -0
  3. package/dist/__tests__/parser/HeapParser.test.d.ts.map +1 -0
  4. package/dist/__tests__/parser/HeapParser.test.js +54 -0
  5. package/dist/__tests__/parser/NodeHeap.test.d.ts +11 -0
  6. package/dist/__tests__/parser/NodeHeap.test.d.ts.map +1 -0
  7. package/dist/__tests__/parser/NodeHeap.test.js +96 -0
  8. package/dist/__tests__/parser/StringNode.test.d.ts +11 -0
  9. package/dist/__tests__/parser/StringNode.test.d.ts.map +1 -0
  10. package/dist/__tests__/parser/StringNode.test.js +61 -0
  11. package/dist/__tests__/parser/traverse/HeapNodeTraverse.test.d.ts +16 -0
  12. package/dist/__tests__/parser/traverse/HeapNodeTraverse.test.d.ts.map +1 -0
  13. package/dist/__tests__/parser/traverse/HeapNodeTraverse.test.js +140 -0
  14. package/dist/__tests__/utils/utils.test.d.ts +11 -0
  15. package/dist/__tests__/utils/utils.test.d.ts.map +1 -0
  16. package/dist/__tests__/utils/utils.test.js +81 -0
  17. package/dist/index.d.ts +29 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +62 -0
  20. package/dist/lib/BaseOption.d.ts +31 -0
  21. package/dist/lib/BaseOption.d.ts.map +1 -0
  22. package/dist/lib/BaseOption.js +109 -0
  23. package/dist/lib/BrowserInfo.d.ts +33 -0
  24. package/dist/lib/BrowserInfo.d.ts.map +1 -0
  25. package/dist/lib/BrowserInfo.js +117 -0
  26. package/dist/lib/Config.d.ts +203 -0
  27. package/dist/lib/Config.d.ts.map +1 -0
  28. package/dist/lib/Config.js +427 -0
  29. package/dist/lib/Console.d.ts +67 -0
  30. package/dist/lib/Console.d.ts.map +1 -0
  31. package/dist/lib/Console.js +344 -0
  32. package/dist/lib/Constant.d.ts +38 -0
  33. package/dist/lib/Constant.d.ts.map +1 -0
  34. package/dist/lib/Constant.js +58 -0
  35. package/dist/lib/FileManager.d.ts +69 -0
  36. package/dist/lib/FileManager.d.ts.map +1 -0
  37. package/dist/lib/FileManager.js +309 -0
  38. package/dist/lib/HeapAnalyzer.d.ts +51 -0
  39. package/dist/lib/HeapAnalyzer.d.ts.map +1 -0
  40. package/dist/lib/HeapAnalyzer.js +719 -0
  41. package/dist/lib/HeapParser.d.ts +19 -0
  42. package/dist/lib/HeapParser.d.ts.map +1 -0
  43. package/dist/lib/HeapParser.js +128 -0
  44. package/dist/lib/InternalValueSetter.d.ts +14 -0
  45. package/dist/lib/InternalValueSetter.d.ts.map +1 -0
  46. package/dist/lib/InternalValueSetter.js +43 -0
  47. package/dist/lib/NodeHeap.d.ts +16 -0
  48. package/dist/lib/NodeHeap.d.ts.map +1 -0
  49. package/dist/lib/NodeHeap.js +62 -0
  50. package/dist/lib/ProcessManager.d.ts +25 -0
  51. package/dist/lib/ProcessManager.d.ts.map +1 -0
  52. package/dist/lib/ProcessManager.js +67 -0
  53. package/dist/lib/Serializer.d.ts +49 -0
  54. package/dist/lib/Serializer.d.ts.map +1 -0
  55. package/dist/lib/Serializer.js +702 -0
  56. package/dist/lib/StringLoader.d.ts +26 -0
  57. package/dist/lib/StringLoader.d.ts.map +1 -0
  58. package/dist/lib/StringLoader.js +290 -0
  59. package/dist/lib/Types.d.ts +432 -0
  60. package/dist/lib/Types.d.ts.map +1 -0
  61. package/dist/lib/Types.js +11 -0
  62. package/dist/lib/Utils.d.ts +223 -0
  63. package/dist/lib/Utils.d.ts.map +1 -0
  64. package/dist/lib/Utils.js +1736 -0
  65. package/dist/lib/heap-data/HeapEdge.d.ts +27 -0
  66. package/dist/lib/heap-data/HeapEdge.d.ts.map +1 -0
  67. package/dist/lib/heap-data/HeapEdge.js +75 -0
  68. package/dist/lib/heap-data/HeapLocation.d.ts +22 -0
  69. package/dist/lib/heap-data/HeapLocation.d.ts.map +1 -0
  70. package/dist/lib/heap-data/HeapLocation.js +40 -0
  71. package/dist/lib/heap-data/HeapNode.d.ts +55 -0
  72. package/dist/lib/heap-data/HeapNode.d.ts.map +1 -0
  73. package/dist/lib/heap-data/HeapNode.js +344 -0
  74. package/dist/lib/heap-data/HeapSnapshot.d.ts +85 -0
  75. package/dist/lib/heap-data/HeapSnapshot.d.ts.map +1 -0
  76. package/dist/lib/heap-data/HeapSnapshot.js +462 -0
  77. package/dist/lib/heap-data/HeapStringNode.d.ts +18 -0
  78. package/dist/lib/heap-data/HeapStringNode.d.ts.map +1 -0
  79. package/dist/lib/heap-data/HeapStringNode.js +43 -0
  80. package/dist/lib/heap-data/HeapUtils.d.ts +17 -0
  81. package/dist/lib/heap-data/HeapUtils.d.ts.map +1 -0
  82. package/dist/lib/heap-data/HeapUtils.js +25 -0
  83. package/dist/logger/LeakClusterLogger.d.ts +40 -0
  84. package/dist/logger/LeakClusterLogger.d.ts.map +1 -0
  85. package/dist/logger/LeakClusterLogger.js +228 -0
  86. package/dist/logger/LeakTraceDetailsLogger.d.ts +19 -0
  87. package/dist/logger/LeakTraceDetailsLogger.d.ts.map +1 -0
  88. package/dist/logger/LeakTraceDetailsLogger.js +50 -0
  89. package/dist/modes/BaseMode.d.ts +30 -0
  90. package/dist/modes/BaseMode.d.ts.map +1 -0
  91. package/dist/modes/BaseMode.js +95 -0
  92. package/dist/modes/InteractionTestMode.d.ts +23 -0
  93. package/dist/modes/InteractionTestMode.d.ts.map +1 -0
  94. package/dist/modes/InteractionTestMode.js +46 -0
  95. package/dist/modes/MeasureMode.d.ts +23 -0
  96. package/dist/modes/MeasureMode.d.ts.map +1 -0
  97. package/dist/modes/MeasureMode.js +58 -0
  98. package/dist/modes/RunningModes.d.ts +15 -0
  99. package/dist/modes/RunningModes.d.ts.map +1 -0
  100. package/dist/modes/RunningModes.js +40 -0
  101. package/dist/paths/TraceFinder.d.ts +31 -0
  102. package/dist/paths/TraceFinder.d.ts.map +1 -0
  103. package/dist/paths/TraceFinder.js +537 -0
  104. package/dist/trace-cluster/ClusterUtils.d.ts +14 -0
  105. package/dist/trace-cluster/ClusterUtils.d.ts.map +1 -0
  106. package/dist/trace-cluster/ClusterUtils.js +17 -0
  107. package/dist/trace-cluster/ClusterUtilsHelper.d.ts +38 -0
  108. package/dist/trace-cluster/ClusterUtilsHelper.d.ts.map +1 -0
  109. package/dist/trace-cluster/ClusterUtilsHelper.js +373 -0
  110. package/dist/trace-cluster/ClusteringHeuristics.d.ts +22 -0
  111. package/dist/trace-cluster/ClusteringHeuristics.d.ts.map +1 -0
  112. package/dist/trace-cluster/ClusteringHeuristics.js +23 -0
  113. package/dist/trace-cluster/EvalutationMetric.d.ts +22 -0
  114. package/dist/trace-cluster/EvalutationMetric.d.ts.map +1 -0
  115. package/dist/trace-cluster/EvalutationMetric.js +158 -0
  116. package/dist/trace-cluster/TraceBucket.d.ts +36 -0
  117. package/dist/trace-cluster/TraceBucket.d.ts.map +1 -0
  118. package/dist/trace-cluster/TraceBucket.js +238 -0
  119. package/dist/trace-cluster/TraceElement.d.ts +71 -0
  120. package/dist/trace-cluster/TraceElement.d.ts.map +1 -0
  121. package/dist/trace-cluster/TraceElement.js +182 -0
  122. package/dist/trace-cluster/strategies/TraceAsClusterStrategy.d.ts +15 -0
  123. package/dist/trace-cluster/strategies/TraceAsClusterStrategy.d.ts.map +1 -0
  124. package/dist/trace-cluster/strategies/TraceAsClusterStrategy.js +37 -0
  125. package/dist/trace-cluster/strategies/TraceSimilarityStrategy.d.ts +15 -0
  126. package/dist/trace-cluster/strategies/TraceSimilarityStrategy.d.ts.map +1 -0
  127. package/dist/trace-cluster/strategies/TraceSimilarityStrategy.js +60 -0
  128. package/package.json +60 -0
  129. package/static/run-meta.json +10 -0
  130. package/static/visit-order.json +27 -0
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # `@memlab/core`
2
+
3
+ > TODO: description
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ const core = require('core');
9
+
10
+ // TODO: DEMONSTRATE API
11
+ ```
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @emails oncall+ws_labs
8
+ * @format
9
+ */
10
+ export {};
11
+ //# sourceMappingURL=HeapParser.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HeapParser.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/parser/HeapParser.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ *
8
+ * @emails oncall+ws_labs
9
+ * @format
10
+ */
11
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
+ return new (P || (P = Promise))(function (resolve, reject) {
14
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
18
+ });
19
+ };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ const Config_1 = __importDefault(require("../../lib/Config"));
25
+ const NodeHeap_1 = require("../../lib/NodeHeap");
26
+ beforeEach(() => {
27
+ Config_1.default.isTest = true;
28
+ });
29
+ const timeout = 5 * 60 * 1000;
30
+ test('Capture inserted object', () => __awaiter(void 0, void 0, void 0, function* () {
31
+ class TestObject {
32
+ constructor() {
33
+ this.arr1 = [1, 2, 3];
34
+ this.arr2 = ['1', '2', '3'];
35
+ }
36
+ }
37
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
38
+ const injected = new TestObject();
39
+ const heap = yield (0, NodeHeap_1.getCurrentNodeHeap)();
40
+ expect(heap.hasObjectWithClassName('TestObject')).toBe(true);
41
+ }), timeout);
42
+ test('Does not capture transcient object', () => __awaiter(void 0, void 0, void 0, function* () {
43
+ class TestObject {
44
+ constructor() {
45
+ this.arr1 = [1, 2, 3];
46
+ this.arr2 = ['1', '2', '3'];
47
+ }
48
+ }
49
+ let injected = new TestObject();
50
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
51
+ injected = null;
52
+ const heap = yield (0, NodeHeap_1.getCurrentNodeHeap)();
53
+ expect(heap.hasObjectWithClassName('TestObject')).toBe(false);
54
+ }), timeout);
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @emails oncall+ws_labs
8
+ * @format
9
+ */
10
+ export {};
11
+ //# sourceMappingURL=NodeHeap.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NodeHeap.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/parser/NodeHeap.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ *
8
+ * @emails oncall+ws_labs
9
+ * @format
10
+ */
11
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
+ return new (P || (P = Promise))(function (resolve, reject) {
14
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
18
+ });
19
+ };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ const Config_1 = __importDefault(require("../../lib/Config"));
25
+ const NodeHeap_1 = require("../../lib/NodeHeap");
26
+ beforeEach(() => {
27
+ Config_1.default.isTest = true;
28
+ });
29
+ const timeout = 5 * 60 * 1000;
30
+ test('Capture current node heap snapshot', () => __awaiter(void 0, void 0, void 0, function* () {
31
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
32
+ const object = { 'memlab-test-heap-property': 'memlab-test-heap-value' };
33
+ const heap = yield (0, NodeHeap_1.getCurrentNodeHeap)();
34
+ expect(heap.hasObjectWithPropertyName('memlab-test-heap-property')).toBe(true);
35
+ }), timeout);
36
+ test('Nullified Object should not exist in heap', () => __awaiter(void 0, void 0, void 0, function* () {
37
+ let object = {
38
+ 'memlab-test-heap-property': 'memlab-test-heap-value',
39
+ };
40
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
41
+ object = null;
42
+ const heap = yield (0, NodeHeap_1.getCurrentNodeHeap)();
43
+ expect(heap.hasObjectWithPropertyName('memlab-test-heap-property')).toBe(false);
44
+ }), timeout);
45
+ test('Strongly referenced object should exist in heap', () => __awaiter(void 0, void 0, void 0, function* () {
46
+ class TestClass2 {
47
+ constructor() {
48
+ this.p1 = 'memlab-property-value-3';
49
+ }
50
+ }
51
+ class TestClass1 {
52
+ constructor(o) {
53
+ this.set = new Set();
54
+ this.set.add(o);
55
+ }
56
+ }
57
+ function buildTest() {
58
+ return new TestClass1(new TestClass2());
59
+ }
60
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
61
+ const object = buildTest();
62
+ const heap = yield (0, NodeHeap_1.getCurrentNodeHeap)();
63
+ expect(heap.hasObjectWithClassName('TestClass1')).toBe(true);
64
+ expect(heap.hasObjectWithClassName('TestClass2')).toBe(true);
65
+ }), timeout);
66
+ test('Weakly referenced object should not exist in heap', () => __awaiter(void 0, void 0, void 0, function* () {
67
+ class TestClass4 {
68
+ constructor() {
69
+ this.p1 = 'memlab-property-value-3';
70
+ }
71
+ }
72
+ class TestClass3 {
73
+ constructor(o) {
74
+ this.set = new WeakSet();
75
+ this.set.add(o);
76
+ }
77
+ }
78
+ function buildTest() {
79
+ return new TestClass3(new TestClass4());
80
+ }
81
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
82
+ const object = buildTest();
83
+ const heap = yield (0, NodeHeap_1.getCurrentNodeHeap)();
84
+ expect(heap.hasObjectWithClassName('TestClass3')).toBe(true);
85
+ expect(heap.hasObjectWithClassName('TestClass4')).toBe(false);
86
+ }), timeout);
87
+ test('Check annotated objects', () => __awaiter(void 0, void 0, void 0, function* () {
88
+ const o1 = {};
89
+ let o2 = {};
90
+ (0, NodeHeap_1.tagObject)(o1, 'memlab-mark-1');
91
+ (0, NodeHeap_1.tagObject)(o2, 'memlab-mark-2');
92
+ o2 = null;
93
+ const heap = yield (0, NodeHeap_1.getCurrentNodeHeap)();
94
+ expect(heap.hasObjectWithTag('memlab-mark-1')).toBe(true);
95
+ expect(heap.hasObjectWithTag('memlab-mark-2')).toBe(false);
96
+ }), timeout);
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @emails oncall+ws_labs
8
+ * @format
9
+ */
10
+ export {};
11
+ //# sourceMappingURL=StringNode.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StringNode.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/parser/StringNode.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ *
8
+ * @emails oncall+ws_labs
9
+ * @format
10
+ */
11
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
+ return new (P || (P = Promise))(function (resolve, reject) {
14
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
18
+ });
19
+ };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ const Config_1 = __importDefault(require("../../lib/Config"));
25
+ const NodeHeap_1 = require("../../lib/NodeHeap");
26
+ beforeEach(() => {
27
+ Config_1.default.isTest = true;
28
+ });
29
+ const timeout = 5 * 60 * 1000;
30
+ test('String heap object APIs work', () => __awaiter(void 0, void 0, void 0, function* () {
31
+ var _a, _b, _c;
32
+ class TestObject {
33
+ constructor() {
34
+ this.originalString = 'test';
35
+ this.concatedString = 'prefix_';
36
+ this.complexConcatString = 'prefix_';
37
+ }
38
+ }
39
+ const injected = new TestObject();
40
+ injected.concatedString += 'suffix';
41
+ injected.complexConcatString += 'value_';
42
+ injected.complexConcatString += 123;
43
+ injected.complexConcatString += '_suffix';
44
+ const heap = yield (0, NodeHeap_1.getCurrentNodeHeap)();
45
+ const testObject = heap.getAnyObjectWithClassName('TestObject');
46
+ expect(testObject).not.toBe(null);
47
+ // testObject.originalString === 'test'
48
+ const originalString = testObject === null || testObject === void 0 ? void 0 : testObject.getReferenceNode('originalString');
49
+ expect(originalString === null || originalString === void 0 ? void 0 : originalString.isString).toBe(true);
50
+ expect((_a = originalString === null || originalString === void 0 ? void 0 : originalString.toStringNode()) === null || _a === void 0 ? void 0 : _a.stringValue).toBe('test');
51
+ // testObject.concatedString === 'prefix_suffix';
52
+ const concatString = testObject === null || testObject === void 0 ? void 0 : testObject.getReferenceNode('concatedString');
53
+ expect(concatString === null || concatString === void 0 ? void 0 : concatString.type).toBe('concatenated string');
54
+ expect(concatString === null || concatString === void 0 ? void 0 : concatString.isString).toBe(true);
55
+ expect((_b = concatString === null || concatString === void 0 ? void 0 : concatString.toStringNode()) === null || _b === void 0 ? void 0 : _b.stringValue).toBe('prefix_suffix');
56
+ // testObject.complexConcatString === 'prefix_value_123_suffix';
57
+ const complexConcatString = testObject === null || testObject === void 0 ? void 0 : testObject.getReferenceNode('complexConcatString');
58
+ expect(complexConcatString === null || complexConcatString === void 0 ? void 0 : complexConcatString.type).toBe('concatenated string');
59
+ expect(complexConcatString === null || complexConcatString === void 0 ? void 0 : complexConcatString.isString).toBe(true);
60
+ expect((_c = complexConcatString === null || complexConcatString === void 0 ? void 0 : complexConcatString.toStringNode()) === null || _c === void 0 ? void 0 : _c.stringValue).toBe('prefix_value_123_suffix');
61
+ }), timeout);
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @emails oncall+ws_labs
8
+ * @format
9
+ */
10
+ import type { AnyValue } from '../../../lib/Types';
11
+ declare global {
12
+ interface Window {
13
+ injected: AnyValue;
14
+ }
15
+ }
16
+ //# sourceMappingURL=HeapNodeTraverse.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HeapNodeTraverse.test.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/parser/traverse/HeapNodeTraverse.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,QAAQ,EAA2B,MAAM,oBAAoB,CAAC;AAI3E,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,QAAQ,EAAE,QAAQ,CAAC;KACpB;CACF"}
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ *
8
+ * @emails oncall+ws_labs
9
+ * @format
10
+ */
11
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
+ return new (P || (P = Promise))(function (resolve, reject) {
14
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
18
+ });
19
+ };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ const Config_1 = __importDefault(require("../../../lib/Config"));
25
+ const NodeHeap_1 = require("../../../lib/NodeHeap");
26
+ beforeEach(() => {
27
+ Config_1.default.isTest = true;
28
+ });
29
+ const timeout = 5 * 60 * 1000;
30
+ test('Check getReference and getReferenceNode', () => __awaiter(void 0, void 0, void 0, function* () {
31
+ class TestObject {
32
+ constructor() {
33
+ this.property1 = { property2: 'test' };
34
+ }
35
+ }
36
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
37
+ const injected = new TestObject();
38
+ const checker = (heap) => {
39
+ let detected = false;
40
+ heap.nodes.forEach((node) => {
41
+ if (node.name !== 'TestObject' || node.type !== 'object') {
42
+ return;
43
+ }
44
+ // check testObject.property1 reference
45
+ if (node.getReference('property1') == null) {
46
+ return;
47
+ }
48
+ // check testObject.property1 reference with edge type
49
+ if (node.getReference('property1', 'property') == null) {
50
+ return;
51
+ }
52
+ // check testObject.property1 reference with edge type
53
+ if (node.getReference('property1', 'internal') != null) {
54
+ return;
55
+ }
56
+ // check testObject.property1 referenced node
57
+ if (node.getReferenceNode('property1') == null) {
58
+ return;
59
+ }
60
+ // check testObject.property1 referenced node with edge type
61
+ if (node.getReferenceNode('property1', 'property') == null) {
62
+ return;
63
+ }
64
+ // check testObject.property1 referenced node with edge type
65
+ if (node.getReferenceNode('property1', 'internal') != null) {
66
+ return;
67
+ }
68
+ // check testObject.property1.property2 referenced node
69
+ const referencedNode = node.getReferenceNode('property1');
70
+ if ((referencedNode === null || referencedNode === void 0 ? void 0 : referencedNode.getReferenceNode('property2')) == null) {
71
+ return;
72
+ }
73
+ detected = true;
74
+ });
75
+ return detected;
76
+ };
77
+ const heap = yield (0, NodeHeap_1.getCurrentNodeHeap)();
78
+ expect(checker(heap)).toBe(true);
79
+ }), timeout);
80
+ test('Check getReferrers and getReferrerNodes', () => __awaiter(void 0, void 0, void 0, function* () {
81
+ const leakInjector = () => {
82
+ const obj = { p1: { p2: { p3: 'test' } } };
83
+ class TestObject {
84
+ constructor() {
85
+ this.prop = obj;
86
+ this._p = obj;
87
+ }
88
+ }
89
+ return [new TestObject(), new TestObject()];
90
+ };
91
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
92
+ const injected = leakInjector();
93
+ const checker = (heap) => {
94
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
95
+ const testObjects = [];
96
+ // get all TestObjects
97
+ heap.nodes.forEach((node) => {
98
+ if (node.name === 'TestObject' && node.type === 'object') {
99
+ testObjects.push(node);
100
+ }
101
+ });
102
+ // there should be exactly 2 TestObjects
103
+ if (testObjects.length !== 2) {
104
+ return false;
105
+ }
106
+ // testObject.prop.p1.p2.p3 should be a string
107
+ const strNode = (_d = (_c = (_b = (_a = testObjects[0]) === null || _a === void 0 ? void 0 : _a.getReferenceNode('prop')) === null || _b === void 0 ? void 0 : _b.getReferenceNode('p1')) === null || _c === void 0 ? void 0 : _c.getReferenceNode('p2')) === null || _d === void 0 ? void 0 : _d.getReferenceNode('p3');
108
+ if (!strNode || strNode.type !== 'string') {
109
+ return false;
110
+ }
111
+ // testObject.prop should have 2 referrering edges with name 'prop'
112
+ let edges = (_e = testObjects[0].getReferenceNode('prop')) === null || _e === void 0 ? void 0 : _e.getReferrers('prop');
113
+ if (!edges || edges.length !== 2) {
114
+ return false;
115
+ }
116
+ // testObject.prop should have 2 referrering edges with name '_p'
117
+ edges = (_f = testObjects[0].getReferenceNode('_p')) === null || _f === void 0 ? void 0 : _f.getReferrers('_p');
118
+ if (!edges || edges.length !== 2) {
119
+ return false;
120
+ }
121
+ // testObject.prop should have 2 unique referring nodes
122
+ const nodes = (_g = testObjects[0]
123
+ .getReferenceNode('prop')) === null || _g === void 0 ? void 0 : _g.getReferrerNodes('_p');
124
+ if (!nodes || nodes.length !== 2) {
125
+ return false;
126
+ }
127
+ // trace back to testObject from testObject.prop.p1.p2.p3
128
+ const to = (_k = (_j = (_h = strNode
129
+ .getReferrerNodes('p3')[0]) === null || _h === void 0 ? void 0 : _h.getReferrerNodes('p2')[0]) === null || _j === void 0 ? void 0 : _j.getReferrerNodes('p1')[0]) === null || _k === void 0 ? void 0 : _k.getReferrerNodes('prop')[0];
130
+ if (!to || to.name !== 'TestObject') {
131
+ return false;
132
+ }
133
+ if (!testObjects.some(o => o.id === to.id)) {
134
+ return false;
135
+ }
136
+ return true;
137
+ };
138
+ const heap = yield (0, NodeHeap_1.getCurrentNodeHeap)();
139
+ expect(checker(heap)).toBe(true);
140
+ }), timeout);
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @emails oncall+ws_labs
8
+ * @format
9
+ */
10
+ export {};
11
+ //# sourceMappingURL=utils.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/utils/utils.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ *
8
+ * @emails oncall+ws_labs
9
+ * @format
10
+ */
11
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
+ return new (P || (P = Promise))(function (resolve, reject) {
14
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
18
+ });
19
+ };
20
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ const Config_1 = __importDefault(require("../../lib/Config"));
25
+ const Utils_1 = __importDefault(require("../../lib/Utils"));
26
+ beforeEach(() => {
27
+ Config_1.default.isTest = true;
28
+ });
29
+ const strackTraceFrameNodeMock = {
30
+ type: 'hidden',
31
+ name: 'system / StackTraceFrame',
32
+ };
33
+ const oddBallNodeMock = { name: 'system / Oddball' };
34
+ const detachedFiberNodeMock = {
35
+ type: 'object',
36
+ name: 'Detached FiberNode',
37
+ };
38
+ const fiberNodeMock = { type: 'object', name: 'FiberNode' };
39
+ const weakMapEdgeMock = {
40
+ type: 'internal',
41
+ name_or_index: '4 / part of key Object @474899 -> value Object @474901 pair in WeakMap table @654951',
42
+ };
43
+ const edgeMock = {
44
+ type: 'property',
45
+ name_or_index: 'intersectionObserver',
46
+ };
47
+ test('Check getReadableBytes', () => __awaiter(void 0, void 0, void 0, function* () {
48
+ expect(Utils_1.default.getReadableBytes(0)).toBe('0 byte');
49
+ expect(Utils_1.default.getReadableBytes(1)).toBe('1 byte');
50
+ expect(Utils_1.default.getReadableBytes(2)).toBe('2 bytes');
51
+ expect(Utils_1.default.getReadableBytes(10)).toBe('10 bytes');
52
+ expect(Utils_1.default.getReadableBytes(1000)).toBe('1KB');
53
+ expect(Utils_1.default.getReadableBytes(1010)).toBe('1KB');
54
+ expect(Utils_1.default.getReadableBytes(1130)).toBe('1.1KB');
55
+ expect(Utils_1.default.getReadableBytes(1200000)).toBe('1.2MB');
56
+ expect(Utils_1.default.getReadableBytes(980000000)).toBe('980MB');
57
+ expect(Utils_1.default.getReadableBytes(2212312313)).toBe('2.2GB');
58
+ expect(Utils_1.default.getReadableBytes(5432212312313)).toBe('5.4TB');
59
+ }));
60
+ test('Check isStackTraceFrame', () => __awaiter(void 0, void 0, void 0, function* () {
61
+ expect(Utils_1.default.isStackTraceFrame(strackTraceFrameNodeMock)).toBe(true);
62
+ expect(Utils_1.default.isStackTraceFrame(oddBallNodeMock)).toBe(false);
63
+ expect(Utils_1.default.isStackTraceFrame(detachedFiberNodeMock)).toBe(false);
64
+ expect(Utils_1.default.isStackTraceFrame(fiberNodeMock)).toBe(false);
65
+ }));
66
+ test('Check isDetachedFiberNode', () => __awaiter(void 0, void 0, void 0, function* () {
67
+ expect(Utils_1.default.isDetachedFiberNode(detachedFiberNodeMock)).toBe(true);
68
+ expect(Utils_1.default.isDetachedFiberNode(fiberNodeMock)).toBe(false);
69
+ expect(Utils_1.default.isDetachedFiberNode(strackTraceFrameNodeMock)).toBe(false);
70
+ expect(Utils_1.default.isDetachedFiberNode(oddBallNodeMock)).toBe(false);
71
+ }));
72
+ test('Check isFiberNode', () => __awaiter(void 0, void 0, void 0, function* () {
73
+ expect(Utils_1.default.isFiberNode(detachedFiberNodeMock)).toBe(true);
74
+ expect(Utils_1.default.isFiberNode(fiberNodeMock)).toBe(true);
75
+ expect(Utils_1.default.isFiberNode(strackTraceFrameNodeMock)).toBe(false);
76
+ expect(Utils_1.default.isFiberNode(oddBallNodeMock)).toBe(false);
77
+ }));
78
+ test('Check isWeakMapEdge', () => __awaiter(void 0, void 0, void 0, function* () {
79
+ expect(Utils_1.default.isWeakMapEdge(weakMapEdgeMock)).toBe(true);
80
+ expect(Utils_1.default.isWeakMapEdge(edgeMock)).toBe(false);
81
+ }));
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @emails oncall+ws_labs
8
+ * @format
9
+ */
10
+ export * from './lib/Types';
11
+ export { default as config } from './lib/Config';
12
+ export * from './lib/InternalValueSetter';
13
+ export * from './lib/Config';
14
+ export { default as info } from './lib/Console';
15
+ export { default as BaseOption } from './lib/BaseOption';
16
+ export { default as utils } from './lib/Utils';
17
+ export { default as fileManager } from './lib/FileManager';
18
+ export * from './lib/FileManager';
19
+ export { default as serializer } from './lib/Serializer';
20
+ export { default as browserInfo } from './lib/BrowserInfo';
21
+ export { default as analysis } from './lib/HeapAnalyzer';
22
+ export { default as constant } from './lib/Constant';
23
+ export { default as modes } from './modes/RunningModes';
24
+ export { default as ProcessManager } from './lib/ProcessManager';
25
+ export { default as leakClusterLogger } from './logger/LeakClusterLogger';
26
+ export { default as NormalizedTrace } from './trace-cluster/TraceBucket';
27
+ export { default as EvaluationMetric } from './trace-cluster/EvalutationMetric';
28
+ export * from './lib/NodeHeap';
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAC,OAAO,IAAI,MAAM,EAAC,MAAM,cAAc,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAC,OAAO,IAAI,IAAI,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAC,OAAO,IAAI,UAAU,EAAC,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAC,OAAO,IAAI,KAAK,EAAC,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,mBAAmB,CAAC;AACzD,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAC,OAAO,IAAI,UAAU,EAAC,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAC,OAAO,IAAI,KAAK,EAAC,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAC,OAAO,IAAI,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,mCAAmC,CAAC;AAC9E,cAAc,gBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ *
8
+ * @emails oncall+ws_labs
9
+ * @format
10
+ */
11
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ var desc = Object.getOwnPropertyDescriptor(m, k);
14
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15
+ desc = { enumerable: true, get: function() { return m[k]; } };
16
+ }
17
+ Object.defineProperty(o, k2, desc);
18
+ }) : (function(o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ o[k2] = m[k];
21
+ }));
22
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
23
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.EvaluationMetric = exports.NormalizedTrace = exports.leakClusterLogger = exports.ProcessManager = exports.modes = exports.constant = exports.analysis = exports.browserInfo = exports.serializer = exports.fileManager = exports.utils = exports.BaseOption = exports.info = exports.config = void 0;
30
+ __exportStar(require("./lib/Types"), exports);
31
+ var Config_1 = require("./lib/Config");
32
+ Object.defineProperty(exports, "config", { enumerable: true, get: function () { return __importDefault(Config_1).default; } });
33
+ __exportStar(require("./lib/InternalValueSetter"), exports);
34
+ __exportStar(require("./lib/Config"), exports);
35
+ var Console_1 = require("./lib/Console");
36
+ Object.defineProperty(exports, "info", { enumerable: true, get: function () { return __importDefault(Console_1).default; } });
37
+ var BaseOption_1 = require("./lib/BaseOption");
38
+ Object.defineProperty(exports, "BaseOption", { enumerable: true, get: function () { return __importDefault(BaseOption_1).default; } });
39
+ var Utils_1 = require("./lib/Utils");
40
+ Object.defineProperty(exports, "utils", { enumerable: true, get: function () { return __importDefault(Utils_1).default; } });
41
+ var FileManager_1 = require("./lib/FileManager");
42
+ Object.defineProperty(exports, "fileManager", { enumerable: true, get: function () { return __importDefault(FileManager_1).default; } });
43
+ __exportStar(require("./lib/FileManager"), exports);
44
+ var Serializer_1 = require("./lib/Serializer");
45
+ Object.defineProperty(exports, "serializer", { enumerable: true, get: function () { return __importDefault(Serializer_1).default; } });
46
+ var BrowserInfo_1 = require("./lib/BrowserInfo");
47
+ Object.defineProperty(exports, "browserInfo", { enumerable: true, get: function () { return __importDefault(BrowserInfo_1).default; } });
48
+ var HeapAnalyzer_1 = require("./lib/HeapAnalyzer");
49
+ Object.defineProperty(exports, "analysis", { enumerable: true, get: function () { return __importDefault(HeapAnalyzer_1).default; } });
50
+ var Constant_1 = require("./lib/Constant");
51
+ Object.defineProperty(exports, "constant", { enumerable: true, get: function () { return __importDefault(Constant_1).default; } });
52
+ var RunningModes_1 = require("./modes/RunningModes");
53
+ Object.defineProperty(exports, "modes", { enumerable: true, get: function () { return __importDefault(RunningModes_1).default; } });
54
+ var ProcessManager_1 = require("./lib/ProcessManager");
55
+ Object.defineProperty(exports, "ProcessManager", { enumerable: true, get: function () { return __importDefault(ProcessManager_1).default; } });
56
+ var LeakClusterLogger_1 = require("./logger/LeakClusterLogger");
57
+ Object.defineProperty(exports, "leakClusterLogger", { enumerable: true, get: function () { return __importDefault(LeakClusterLogger_1).default; } });
58
+ var TraceBucket_1 = require("./trace-cluster/TraceBucket");
59
+ Object.defineProperty(exports, "NormalizedTrace", { enumerable: true, get: function () { return __importDefault(TraceBucket_1).default; } });
60
+ var EvalutationMetric_1 = require("./trace-cluster/EvalutationMetric");
61
+ Object.defineProperty(exports, "EvaluationMetric", { enumerable: true, get: function () { return __importDefault(EvalutationMetric_1).default; } });
62
+ __exportStar(require("./lib/NodeHeap"), exports);