@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
@@ -0,0 +1,344 @@
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
+ 'use strict';
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const chalk_1 = __importDefault(require("chalk"));
16
+ const fs_1 = __importDefault(require("fs"));
17
+ const readline_1 = __importDefault(require("readline"));
18
+ const string_width_1 = __importDefault(require("string-width"));
19
+ const stdout = process.stdout;
20
+ const TABLE_MAX_WIDTH = 50;
21
+ const prevLine = '\x1b[F';
22
+ const eraseLine = '\x1b[K';
23
+ const barComplete = chalk_1.default.green('\u2588');
24
+ const barIncomplete = chalk_1.default.grey('\u2591');
25
+ function formatTableArg(arg) {
26
+ if (!Array.isArray(arg)) {
27
+ return arg;
28
+ }
29
+ arg.forEach(obj => {
30
+ if (typeof obj !== 'object') {
31
+ return;
32
+ }
33
+ for (const key of Object.keys(obj)) {
34
+ const value = obj[key];
35
+ if (typeof value !== 'string') {
36
+ continue;
37
+ }
38
+ if (value.length <= TABLE_MAX_WIDTH) {
39
+ continue;
40
+ }
41
+ obj[key] = value.substring(0, TABLE_MAX_WIDTH) + '...';
42
+ }
43
+ });
44
+ }
45
+ class MemLabConsole {
46
+ constructor() {
47
+ this.config = {};
48
+ this.log = [];
49
+ this.styles = {
50
+ top: (msg) => msg,
51
+ high: chalk_1.default.dim.bind(chalk_1.default),
52
+ mid: chalk_1.default.yellow.bind(chalk_1.default),
53
+ low: chalk_1.default.grey.bind(chalk_1.default),
54
+ success: chalk_1.default.green.bind(chalk_1.default),
55
+ error: chalk_1.default.red.bind(chalk_1.default),
56
+ warning: chalk_1.default.yellow.bind(chalk_1.default),
57
+ };
58
+ this.sections = {
59
+ dict: Object.create(null),
60
+ arr: [{ name: 'header', msgs: [] }],
61
+ };
62
+ this.init();
63
+ }
64
+ static getInstance() {
65
+ if (MemLabConsole.singleton) {
66
+ return MemLabConsole.singleton;
67
+ }
68
+ const inst = new MemLabConsole();
69
+ MemLabConsole.singleton = inst;
70
+ // clean up output
71
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
72
+ process.on('exit', (_code) => {
73
+ inst.flushLog();
74
+ inst.clearPrevOverwriteMsg();
75
+ });
76
+ return inst;
77
+ }
78
+ style(msg, name) {
79
+ if (Object.prototype.hasOwnProperty.call(this.styles, name)) {
80
+ return this.styles[name](msg);
81
+ }
82
+ return this.styles.low(msg);
83
+ }
84
+ init() {
85
+ this.beginSection('main-section-DO-NOT-USE');
86
+ }
87
+ getLastSection() {
88
+ const list = this.sections.arr;
89
+ return list[list.length - 1];
90
+ }
91
+ getLastMsg() {
92
+ const lastSection = this.getLastSection();
93
+ if (!lastSection || !lastSection.msgs) {
94
+ return null;
95
+ }
96
+ const msgs = lastSection.msgs;
97
+ return msgs.length === 0 ? null : msgs[msgs.length - 1];
98
+ }
99
+ logMsg(msg) {
100
+ // remove control characters
101
+ const rawMsg = msg
102
+ // eslint-disable-next-line no-control-regex
103
+ .replace(/[\u0000-\u001F\u007F-\u009F]/g, '')
104
+ .replace(/\[\d{1,3}m/g, '');
105
+ this.log.push(rawMsg);
106
+ if (this.log.length > 20) {
107
+ this.flushLog();
108
+ }
109
+ }
110
+ flushLog() {
111
+ const str = this.log.join('\n');
112
+ if (str.length > 0) {
113
+ const file = this.config.consoleLogFile;
114
+ fs_1.default.appendFile(file, str + '\n', 'UTF-8', () => {
115
+ // NOOP
116
+ });
117
+ }
118
+ this.log = [];
119
+ }
120
+ pushMsg(msg, options = {}) {
121
+ const len = this.sections.arr.length;
122
+ if (this.config.isContinuousTest || len === 0) {
123
+ return;
124
+ }
125
+ // calculate each line's visible width
126
+ const lines = msg.split('\n').map(line => (0, string_width_1.default)(line));
127
+ const section = this.getLastSection();
128
+ section === null || section === void 0 ? void 0 : section.msgs.push({ lines, options });
129
+ this.logMsg(msg);
130
+ }
131
+ clearPrevMsgInLastSection() {
132
+ const lastSection = this.getLastSection();
133
+ this.clearPrevMsgInSection(lastSection);
134
+ }
135
+ clearPrevMsgInSection(section) {
136
+ var _a;
137
+ if (this.config.isContinuousTest) {
138
+ return;
139
+ }
140
+ if (!section || section.msgs.length === 0) {
141
+ return;
142
+ }
143
+ stdout.write(eraseLine);
144
+ const msg = section.msgs.pop();
145
+ if (!msg) {
146
+ return;
147
+ }
148
+ const lines = msg.lines;
149
+ while (lines.length > 0) {
150
+ const line = (_a = lines.pop()) !== null && _a !== void 0 ? _a : 0;
151
+ const width = stdout.columns;
152
+ let n = line === 0 ? 1 : Math.ceil(line / width);
153
+ while (n-- > 0) {
154
+ stdout.write(prevLine + eraseLine);
155
+ }
156
+ }
157
+ }
158
+ clearPrevSection() {
159
+ var _a;
160
+ if (this.config.isContinuousTest) {
161
+ return;
162
+ }
163
+ const lastSection = this.getLastSection();
164
+ if (!lastSection) {
165
+ return;
166
+ }
167
+ while (((_a = lastSection === null || lastSection === void 0 ? void 0 : lastSection.msgs) === null || _a === void 0 ? void 0 : _a.length) > 0) {
168
+ this.clearPrevMsgInSection(lastSection);
169
+ }
170
+ this.sections.arr.pop();
171
+ delete this.sections.dict[lastSection.name];
172
+ }
173
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
174
+ shouldBeConcise(_msgType) {
175
+ if (!this.config || !this.config.runningMode) {
176
+ return false;
177
+ }
178
+ return this.config.runningMode.shouldUseConciseConsole();
179
+ }
180
+ clearPrevOverwriteMsg() {
181
+ var _a;
182
+ if (this.config.isContinuousTest) {
183
+ return;
184
+ }
185
+ const lastMsg = this.getLastMsg();
186
+ if (!lastMsg || !((_a = lastMsg.options) === null || _a === void 0 ? void 0 : _a.isOverwrite)) {
187
+ return;
188
+ }
189
+ this.clearPrevMsgInLastSection();
190
+ }
191
+ printStr(msg, options = {}) {
192
+ if (this.config.isTest || this.config.muteConsole) {
193
+ return;
194
+ }
195
+ console.log(msg);
196
+ this.pushMsg(msg, options);
197
+ }
198
+ beginSection(name) {
199
+ if (this.config.isContinuousTest) {
200
+ return;
201
+ }
202
+ this.clearPrevOverwriteMsg();
203
+ if (this.sections.dict[name]) {
204
+ this.endSection(name);
205
+ }
206
+ const section = { name, msgs: [] };
207
+ this.sections.dict[name] = section;
208
+ this.sections.arr.push(section);
209
+ }
210
+ endSection(name) {
211
+ if (this.config.isContinuousTest || this.sections.arr.length === 0) {
212
+ return;
213
+ }
214
+ if (!this.sections.dict[name]) {
215
+ return;
216
+ }
217
+ let section;
218
+ do {
219
+ section = this.getLastSection();
220
+ this.clearPrevSection();
221
+ } while ((section === null || section === void 0 ? void 0 : section.name) !== name);
222
+ }
223
+ setConfig(config) {
224
+ this.config = config;
225
+ }
226
+ table(...args) {
227
+ if (this.shouldBeConcise('table') ||
228
+ this.config.isTest ||
229
+ this.config.muteConsole) {
230
+ return;
231
+ }
232
+ this.clearPrevOverwriteMsg();
233
+ // make sure the values are not too big
234
+ formatTableArg(args[0]);
235
+ if (args[0].length === 0) {
236
+ return;
237
+ }
238
+ console.table(...args);
239
+ }
240
+ trace() {
241
+ if (this.config.isTest || this.config.muteConsole) {
242
+ return;
243
+ }
244
+ console.trace();
245
+ }
246
+ topLevel(msg) {
247
+ if (this.shouldBeConcise('topLevel')) {
248
+ return this.overwrite(msg);
249
+ }
250
+ this.clearPrevOverwriteMsg();
251
+ this.printStr(this.style(msg, 'top'));
252
+ }
253
+ highLevel(msg) {
254
+ if (this.shouldBeConcise('highLevel')) {
255
+ return this.overwrite(msg);
256
+ }
257
+ this.clearPrevOverwriteMsg();
258
+ this.printStr(this.style(msg, 'high'));
259
+ }
260
+ midLevel(msg) {
261
+ if (this.shouldBeConcise('midLevel')) {
262
+ return this.overwrite(msg);
263
+ }
264
+ this.clearPrevOverwriteMsg();
265
+ this.printStr(this.style(msg, 'mid'));
266
+ }
267
+ lowLevel(msg) {
268
+ if (this.shouldBeConcise('lowLevel')) {
269
+ return this.overwrite(msg);
270
+ }
271
+ this.clearPrevOverwriteMsg();
272
+ this.printStr(this.style(msg, 'low'));
273
+ }
274
+ success(msg) {
275
+ if (this.shouldBeConcise('success')) {
276
+ return this.overwrite(msg);
277
+ }
278
+ this.clearPrevOverwriteMsg();
279
+ this.printStr(this.style(msg, 'success'));
280
+ }
281
+ // top level error, only used before halting the execution
282
+ criticalError(msg) {
283
+ this.clearPrevOverwriteMsg();
284
+ this.logMsg(msg);
285
+ console.error(msg);
286
+ }
287
+ error(msg) {
288
+ this.clearPrevOverwriteMsg();
289
+ this.printStr(this.style(msg, 'error'));
290
+ }
291
+ warning(msg) {
292
+ this.clearPrevOverwriteMsg();
293
+ this.printStr(this.style(msg, 'warning'));
294
+ }
295
+ nextLine() {
296
+ if (this.shouldBeConcise('nextLine')) {
297
+ return this.overwrite('');
298
+ }
299
+ this.clearPrevOverwriteMsg();
300
+ this.printStr('');
301
+ }
302
+ overwrite(msg, options = {}) {
303
+ if (this.config.isTest || this.config.muteConsole) {
304
+ return;
305
+ }
306
+ if (this.config.isContinuousTest) {
307
+ return console.log(msg);
308
+ }
309
+ this.clearPrevOverwriteMsg();
310
+ const str = this.style(msg, options.level || 'low');
311
+ this.printStr(str, { isOverwrite: true });
312
+ }
313
+ waitForConsole(query) {
314
+ const rl = readline_1.default.createInterface({
315
+ input: process.stdin,
316
+ output: process.stdout,
317
+ });
318
+ this.pushMsg(query);
319
+ return new Promise(resolve => rl.question(query, ans => {
320
+ rl.close();
321
+ resolve(ans);
322
+ }));
323
+ }
324
+ progress(cur, total, options = {}) {
325
+ let width = Math.floor(stdout.columns * 0.8);
326
+ width = Math.min(width, 80);
327
+ const messageMaxWidth = Math.floor(width * 0.3);
328
+ let message = options.message || '';
329
+ const messageWidth = Math.min(message.length, messageMaxWidth);
330
+ message = message.substring(0, messageWidth);
331
+ // calculate progress bar
332
+ const barWidth = width - messageWidth - 1;
333
+ const barBodyWidth = barWidth - 2;
334
+ const changeIndex = Math.floor((cur / total) * barBodyWidth);
335
+ let bar = '';
336
+ for (let i = 0; i < barBodyWidth; ++i) {
337
+ bar += i < changeIndex ? barComplete : barIncomplete;
338
+ }
339
+ const percent = Math.floor((cur / total) * 100);
340
+ const progress = `${message}: |${bar}| ${percent}/100`;
341
+ this.overwrite(progress, { level: 'top' });
342
+ }
343
+ }
344
+ exports.default = MemLabConsole.getInstance();
@@ -0,0 +1,38 @@
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
+ declare const constants: {
11
+ isFB: boolean;
12
+ isFRL: boolean;
13
+ defaultEngine: string;
14
+ supportedEngines: string[];
15
+ supportedBrowsers: any;
16
+ internalDir: string;
17
+ monoRepoDir: string;
18
+ defaultUserAgent: string;
19
+ V8SyntheticRoots: string[];
20
+ namePrefixForScenarioFromFile: string;
21
+ unset: string;
22
+ };
23
+ export declare type Constants = typeof constants;
24
+ declare const _default: {
25
+ isFB: boolean;
26
+ isFRL: boolean;
27
+ defaultEngine: string;
28
+ supportedEngines: string[];
29
+ supportedBrowsers: any;
30
+ internalDir: string;
31
+ monoRepoDir: string;
32
+ defaultUserAgent: string;
33
+ V8SyntheticRoots: string[];
34
+ namePrefixForScenarioFromFile: string;
35
+ unset: string;
36
+ };
37
+ export default _default;
38
+ //# sourceMappingURL=Constant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Constant.d.ts","sourceRoot":"","sources":["../../src/lib/Constant.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,QAAA,MAAM,SAAS;;;;;;;;;;;;CAyCd,CAAC;AAOF,oBAAY,SAAS,GAAG,OAAO,SAAS,CAAC;;;;;;;;;;;;;;AACzC,wBAA8E"}
@@ -0,0 +1,58 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const InternalValueSetter_1 = require("./InternalValueSetter");
13
+ const constants = {
14
+ isFB: false,
15
+ isFRL: false,
16
+ defaultEngine: 'v8',
17
+ supportedEngines: ['v8', 'hermes'],
18
+ supportedBrowsers: Object.create(null),
19
+ internalDir: 'fb-internal',
20
+ monoRepoDir: '',
21
+ defaultUserAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2)' +
22
+ ' AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.0 Safari/537.36',
23
+ V8SyntheticRoots: [
24
+ '(GC roots)',
25
+ '(Internalized strings)',
26
+ '(External strings)',
27
+ '(Read-only roots)',
28
+ '(Strong roots)',
29
+ '(Smi roots)',
30
+ '(Bootstrapper)',
31
+ '(Stack roots)',
32
+ '(Relocatable)',
33
+ '(Debugger)',
34
+ '(Compilation cache)',
35
+ '(Handle scope)',
36
+ '(Builtins)',
37
+ '(Global handles)',
38
+ '(Eternal handles)',
39
+ '(Thread manager)',
40
+ '(Strong roots)',
41
+ '(Extensions)',
42
+ '(Code flusher)',
43
+ '(Startup object cache)',
44
+ '(Read-only object cache)',
45
+ '(Weak collections)',
46
+ '(Wrapper tracing)',
47
+ '(Write barrier)',
48
+ '(Retain maps)',
49
+ '(Unknown)',
50
+ ],
51
+ namePrefixForScenarioFromFile: '',
52
+ unset: 'UNSET',
53
+ };
54
+ Object.assign(constants.supportedBrowsers, {
55
+ chromium: 'chrome',
56
+ chrome: 'google-chrome',
57
+ });
58
+ exports.default = (0, InternalValueSetter_1.setInternalValue)(constants, __filename, constants.internalDir);
@@ -0,0 +1,69 @@
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 { MemLabConfig } from './Config';
11
+ import type { AnyValue, Optional } from './Types';
12
+ export declare type FileOption = {
13
+ workDir?: Optional<string>;
14
+ clear?: boolean;
15
+ transcient?: boolean;
16
+ };
17
+ export declare class FileManager {
18
+ getDefaultWorkDir(): string;
19
+ generateTmpHeapDir(): string;
20
+ private static transcientInstanceIdx;
21
+ getWorkDir(options?: FileOption): string;
22
+ getChromeBinaryZipFile(): string;
23
+ getChromeBinaryTimeStampFile(): string;
24
+ getChromeBinaryDir(): string;
25
+ clearUserDataDir(options: FileOption): void;
26
+ getDataBaseDir(options: FileOption): string;
27
+ getCodeDataDir(): string;
28
+ getClusterSampleDataDir(): string;
29
+ getUserDataDir(options: FileOption): string;
30
+ getCurDataDir(options: FileOption): string;
31
+ getPersistDataDir(options: FileOption): string;
32
+ getLoggerOutDir(options?: FileOption): string;
33
+ getTraceClustersDir(options?: FileOption): string;
34
+ getTraceJSONDir(options?: FileOption): string;
35
+ getUnclassifiedTraceClusterDir(options?: FileOption): string;
36
+ getUniqueTraceClusterDir(options?: FileOption): string;
37
+ getNewUniqueTraceClusterDir(options?: FileOption): string;
38
+ getStaleUniqueTraceClusterDir(options?: FileOption): string;
39
+ getAllClusterSummaryFile(options?: FileOption): string;
40
+ getExistingUniqueTraceClusterDir(options?: FileOption): string;
41
+ getAllFilesInDir(dir: string): string[];
42
+ getDataOutDir(options?: FileOption): string;
43
+ getCoreProjectBaseDir(): string;
44
+ getReportOutDir(options?: FileOption): string;
45
+ getPreviewReportDir(options?: FileOption): string;
46
+ getLeakSummaryFile(options?: FileOption): string;
47
+ getInputDataDir(): string;
48
+ getAllFilesInSubDirs(dir: string): string[];
49
+ getTmpDir(): string;
50
+ rmDir(dir: string): void;
51
+ getExperimentsDir(): string;
52
+ initExperimentDir(experimentId: string): {
53
+ controlWorkDir: string;
54
+ testWorkDir: string;
55
+ };
56
+ getAndInitTSCompileIntermediateDir(): string;
57
+ clearDataDirs(options?: FileOption): void;
58
+ emptyDirIfExists(dir: string): void;
59
+ emptyTraceLogDataDir(options?: FileOption): void;
60
+ resetBrowserDir(): void;
61
+ isDirectory(file: string): boolean;
62
+ iterateAllFiles(dir: string, callback: (filepath: string) => AnyValue): void;
63
+ rmWorkDir(options?: FileOption): void;
64
+ isWithinInternalDirectory(filePath: string): boolean;
65
+ initDirs(config: MemLabConfig, options?: FileOption): void;
66
+ }
67
+ declare const _default: FileManager;
68
+ export default _default;
69
+ //# sourceMappingURL=FileManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileManager.d.ts","sourceRoot":"","sources":["../../src/lib/FileManager.ts"],"names":[],"mappings":"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"}