@memlab/api 1.0.41 → 1.0.42

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.
package/dist/API.js CHANGED
@@ -21,14 +21,7 @@ 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.warmupAndTakeSnapshots = warmupAndTakeSnapshots;
25
- exports.run = run;
26
- exports.takeSnapshots = takeSnapshots;
27
- exports.findLeaks = findLeaks;
28
- exports.findLeaksBySnapshotFilePaths = findLeaksBySnapshotFilePaths;
29
- exports.analyze = analyze;
30
- exports.warmup = warmup;
31
- exports.testInBrowser = testInBrowser;
24
+ exports.testInBrowser = exports.warmup = exports.analyze = exports.findLeaksBySnapshotFilePaths = exports.findLeaks = exports.takeSnapshots = exports.run = exports.warmupAndTakeSnapshots = void 0;
32
25
  const core_1 = require("@memlab/core");
33
26
  const e2e_1 = require("@memlab/e2e");
34
27
  const APIUtils_1 = __importDefault(require("./lib/APIUtils"));
@@ -53,8 +46,8 @@ const APIStateManager_1 = __importDefault(require("./state/APIStateManager"));
53
46
  * })();
54
47
  * ```
55
48
  */
56
- function warmupAndTakeSnapshots() {
57
- return __awaiter(this, arguments, void 0, function* (options = {}) {
49
+ function warmupAndTakeSnapshots(options = {}) {
50
+ return __awaiter(this, void 0, void 0, function* () {
58
51
  const config = getConfigFromRunOptions(options);
59
52
  const state = APIStateManager_1.default.getAndUpdateState(config, options);
60
53
  const testPlanner = new e2e_1.TestPlanner({ config });
@@ -68,6 +61,7 @@ function warmupAndTakeSnapshots() {
68
61
  return ret;
69
62
  });
70
63
  }
64
+ exports.warmupAndTakeSnapshots = warmupAndTakeSnapshots;
71
65
  /**
72
66
  * This API runs browser interaction and find memory leaks triggered in browser
73
67
  * This is equivalent to running `memlab run` in CLI.
@@ -89,8 +83,8 @@ function warmupAndTakeSnapshots() {
89
83
  * })();
90
84
  * ```
91
85
  */
92
- function run() {
93
- return __awaiter(this, arguments, void 0, function* (options = {}) {
86
+ function run(options = {}) {
87
+ return __awaiter(this, void 0, void 0, function* () {
94
88
  const config = getConfigFromRunOptions(options);
95
89
  const state = APIStateManager_1.default.getAndUpdateState(config, options);
96
90
  const testPlanner = new e2e_1.TestPlanner({ config });
@@ -105,6 +99,7 @@ function run() {
105
99
  return { leaks, runResult };
106
100
  });
107
101
  }
102
+ exports.run = run;
108
103
  /**
109
104
  * This API runs E2E interaction and takes heap snapshots.
110
105
  * This is equivalent to running `memlab snapshot` in CLI.
@@ -123,8 +118,8 @@ function run() {
123
118
  * })();
124
119
  * ```
125
120
  */
126
- function takeSnapshots() {
127
- return __awaiter(this, arguments, void 0, function* (options = {}) {
121
+ function takeSnapshots(options = {}) {
122
+ return __awaiter(this, void 0, void 0, function* () {
128
123
  const config = getConfigFromRunOptions(options);
129
124
  const state = APIStateManager_1.default.getAndUpdateState(config, options);
130
125
  const testPlanner = new e2e_1.TestPlanner();
@@ -135,6 +130,7 @@ function takeSnapshots() {
135
130
  return ret;
136
131
  });
137
132
  }
133
+ exports.takeSnapshots = takeSnapshots;
138
134
  /**
139
135
  * This API finds memory leaks by analyzing heap snapshot(s).
140
136
  * This is equivalent to `memlab find-leaks` in CLI.
@@ -157,8 +153,8 @@ function takeSnapshots() {
157
153
  * })();
158
154
  * ```
159
155
  */
160
- function findLeaks(runResult_1) {
161
- return __awaiter(this, arguments, void 0, function* (runResult, options = {}) {
156
+ function findLeaks(runResult, options = {}) {
157
+ return __awaiter(this, void 0, void 0, function* () {
162
158
  const state = APIStateManager_1.default.getAndUpdateState(core_1.config, options);
163
159
  const workDir = runResult.getRootDirectory();
164
160
  core_1.fileManager.initDirs(core_1.config, { workDir });
@@ -168,6 +164,7 @@ function findLeaks(runResult_1) {
168
164
  return ret;
169
165
  });
170
166
  }
167
+ exports.findLeaks = findLeaks;
171
168
  /**
172
169
  * This API finds memory leaks by analyzing specified heap snapshots.
173
170
  * This is equivalent to `memlab find-leaks` with
@@ -183,8 +180,8 @@ function findLeaks(runResult_1) {
183
180
  * mode (see {@link ConsoleMode})
184
181
  * @returns leak traces detected and clustered from the browser interaction
185
182
  */
186
- function findLeaksBySnapshotFilePaths(baselineSnapshot_1, targetSnapshot_1, finalSnapshot_1) {
187
- return __awaiter(this, arguments, void 0, function* (baselineSnapshot, targetSnapshot, finalSnapshot, options = {}) {
183
+ function findLeaksBySnapshotFilePaths(baselineSnapshot, targetSnapshot, finalSnapshot, options = {}) {
184
+ return __awaiter(this, void 0, void 0, function* () {
188
185
  const state = APIStateManager_1.default.getAndUpdateState(core_1.config, options);
189
186
  core_1.config.useExternalSnapshot = true;
190
187
  core_1.config.externalSnapshotFilePaths = [
@@ -199,6 +196,7 @@ function findLeaksBySnapshotFilePaths(baselineSnapshot_1, targetSnapshot_1, fina
199
196
  return ret;
200
197
  });
201
198
  }
199
+ exports.findLeaksBySnapshotFilePaths = findLeaksBySnapshotFilePaths;
202
200
  /**
203
201
  * This API analyzes heap snapshot(s) with a specified heap analysis.
204
202
  * This is equivalent to `memlab analyze` in CLI.
@@ -223,13 +221,14 @@ function findLeaksBySnapshotFilePaths(baselineSnapshot_1, targetSnapshot_1, fina
223
221
  * })();
224
222
  * ```
225
223
  */
226
- function analyze(runResult_1, heapAnalyzer_1) {
227
- return __awaiter(this, arguments, void 0, function* (runResult, heapAnalyzer, args = { _: [] }) {
224
+ function analyze(runResult, heapAnalyzer, args = { _: [] }) {
225
+ return __awaiter(this, void 0, void 0, function* () {
228
226
  const workDir = runResult.getRootDirectory();
229
227
  core_1.fileManager.initDirs(core_1.config, { workDir });
230
228
  return yield heapAnalyzer.run({ args });
231
229
  });
232
230
  }
231
+ exports.analyze = analyze;
233
232
  /**
234
233
  * This warms up web server by sending web requests to the web sever.
235
234
  * This is equivalent to running `memlab warmup` in CLI.
@@ -237,9 +236,9 @@ function analyze(runResult_1, heapAnalyzer_1) {
237
236
  *
238
237
  * @param options configure browser interaction run
239
238
  */
240
- function warmup() {
241
- return __awaiter(this, arguments, void 0, function* (options = {}) {
242
- var _a, _b;
239
+ function warmup(options = {}) {
240
+ var _a, _b;
241
+ return __awaiter(this, void 0, void 0, function* () {
243
242
  const config = (_a = options.config) !== null && _a !== void 0 ? _a : core_1.config;
244
243
  if (config.verbose) {
245
244
  core_1.info.lowLevel(`Xvfb: ${config.useXVFB}`);
@@ -276,6 +275,7 @@ function warmup() {
276
275
  }
277
276
  });
278
277
  }
278
+ exports.warmup = warmup;
279
279
  function getConfigFromRunOptions(options) {
280
280
  let config = core_1.MemLabConfig.getInstance();
281
281
  if (options.workDir) {
@@ -297,9 +297,9 @@ function getConfigFromRunOptions(options) {
297
297
  config.isFullRun = !!options.snapshotForEachStep;
298
298
  return config;
299
299
  }
300
- function setupPage(page_1) {
301
- return __awaiter(this, arguments, void 0, function* (page, options = {}) {
302
- var _a, _b, _c;
300
+ function setupPage(page, options = {}) {
301
+ var _a, _b, _c;
302
+ return __awaiter(this, void 0, void 0, function* () {
303
303
  const config = (_a = options.config) !== null && _a !== void 0 ? _a : core_1.config;
304
304
  const testPlanner = (_b = options.testPlanner) !== null && _b !== void 0 ? _b : e2e_1.defaultTestPlanner;
305
305
  if (config.emulateDevice) {
@@ -321,9 +321,9 @@ function setupPage(page_1) {
321
321
  }));
322
322
  });
323
323
  }
324
- function initBrowserInfoInConfig(browser_1) {
325
- return __awaiter(this, arguments, void 0, function* (browser, options = {}) {
326
- var _a;
324
+ function initBrowserInfoInConfig(browser, options = {}) {
325
+ var _a;
326
+ return __awaiter(this, void 0, void 0, function* () {
327
327
  const config = (_a = options.config) !== null && _a !== void 0 ? _a : core_1.config;
328
328
  core_1.browserInfo.recordPuppeteerConfig(config.puppeteerConfig);
329
329
  const version = yield browser.version();
@@ -337,9 +337,9 @@ function initBrowserInfoInConfig(browser_1) {
337
337
  * Browser interaction API used by MemLab API and MemLab CLI
338
338
  * @internal
339
339
  */
340
- function testInBrowser() {
341
- return __awaiter(this, arguments, void 0, function* (options = {}) {
342
- var _a, _b;
340
+ function testInBrowser(options = {}) {
341
+ var _a, _b;
342
+ return __awaiter(this, void 0, void 0, function* () {
343
343
  const config = (_a = options.config) !== null && _a !== void 0 ? _a : core_1.config;
344
344
  if (config.verbose) {
345
345
  core_1.info.lowLevel(`Xvfb: ${config.useXVFB}`);
@@ -393,3 +393,4 @@ function testInBrowser() {
393
393
  }
394
394
  });
395
395
  }
396
+ exports.testInBrowser = testInBrowser;
@@ -1 +1 @@
1
- {"version":3,"file":"E2ETestSettings.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/API/lib/E2ETestSettings.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAGpC,eAAO,MAAM,WAAW,QAAgB,CAAC;AAEzC,eAAO,MAAM,mBAAmB;;;;CAAkB,CAAC;AAEnD,eAAO,MAAM,QAAQ;eACV,MAAM;eACN,MAAM;mBACM,IAAI,KAAG,OAAO,CAAC,IAAI,CAAC;CAE1C,CAAC;AAEF,eAAO,MAAM,SAAS,QAAO,IAK5B,CAAC;AAGF,wBAAgB,WAAW,IAAI,MAAM,CAEpC"}
1
+ {"version":3,"file":"E2ETestSettings.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/API/lib/E2ETestSettings.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAGpC,eAAO,MAAM,WAAW,QAAgB,CAAC;AAEzC,eAAO,MAAM,mBAAmB;;;;CAAkB,CAAC;AAEnD,eAAO,MAAM,QAAQ;eACV,MAAM;eACN,MAAM;mBACM,IAAI,KAAG,QAAQ,IAAI,CAAC;CAE1C,CAAC;AAEF,eAAO,MAAM,SAAS,QAAO,IAK5B,CAAC;AAGF,wBAAgB,WAAW,IAAI,MAAM,CAEpC"}
@@ -18,8 +18,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
18
18
  });
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.testSetup = exports.scenario = exports.defaultAnalysisArgs = exports.testTimeout = void 0;
22
- exports.getUniqueID = getUniqueID;
21
+ exports.getUniqueID = exports.testSetup = exports.scenario = exports.defaultAnalysisArgs = exports.testTimeout = void 0;
23
22
  const core_1 = require("@memlab/core");
24
23
  exports.testTimeout = 5 * 60 * 1000;
25
24
  exports.defaultAnalysisArgs = { args: { _: [] } };
@@ -39,3 +38,4 @@ let uindex = 1;
39
38
  function getUniqueID() {
40
39
  return `${process.pid}-${Date.now()}-${uindex++}`;
41
40
  }
41
+ exports.getUniqueID = getUniqueID;
@@ -21,7 +21,7 @@ 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.isExpectedSnapshot = isExpectedSnapshot;
24
+ exports.isExpectedSnapshot = void 0;
25
25
  const fs_1 = __importDefault(require("fs"));
26
26
  const path_1 = __importDefault(require("path"));
27
27
  const core_1 = require("@memlab/core");
@@ -34,6 +34,7 @@ function isExpectedSnapshot(leakInjector, checkSnapshotCb) {
34
34
  expect(checkSnapshotCb(snapshot)).toBe(true);
35
35
  });
36
36
  }
37
+ exports.isExpectedSnapshot = isExpectedSnapshot;
37
38
  function getHeapDirPrefix() {
38
39
  const dir = path_1.default.join(core_1.config.dataBaseDir, 'gen-files');
39
40
  if (!fs_1.default.existsSync(dir)) {
package/dist/index.js CHANGED
@@ -35,8 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
36
  };
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.config = exports.takeNodeMinimalHeap = exports.getNodeInnocentHeap = exports.dumpNodeHeapSnapshot = exports.SnapshotResultReader = exports.BrowserInteractionResultReader = void 0;
39
- exports.registerPackage = registerPackage;
38
+ exports.config = exports.takeNodeMinimalHeap = exports.getNodeInnocentHeap = exports.dumpNodeHeapSnapshot = exports.SnapshotResultReader = exports.BrowserInteractionResultReader = exports.registerPackage = void 0;
40
39
  const path_1 = __importDefault(require("path"));
41
40
  const core_1 = require("@memlab/core");
42
41
  /** @internal */
@@ -45,6 +44,7 @@ function registerPackage() {
45
44
  return core_1.PackageInfoLoader.registerPackage(path_1.default.join(__dirname, '..'));
46
45
  });
47
46
  }
47
+ exports.registerPackage = registerPackage;
48
48
  __exportStar(require("./API"), exports);
49
49
  __exportStar(require("@memlab/heap-analysis"), exports);
50
50
  __exportStar(require("./state/ConsoleModeManager"), exports);
@@ -24,9 +24,9 @@ const puppeteer = core_1.constant.isFRL
24
24
  : core_1.constant.isFB
25
25
  ? require('puppeteer-core')
26
26
  : require('puppeteer');
27
- function getBrowser() {
28
- return __awaiter(this, arguments, void 0, function* (options = {}) {
29
- var _a;
27
+ function getBrowser(options = {}) {
28
+ var _a;
29
+ return __awaiter(this, void 0, void 0, function* () {
30
30
  const runConfig = (_a = options.config) !== null && _a !== void 0 ? _a : core_1.config;
31
31
  let browser;
32
32
  core_1.utils.tryToMutePuppeteerWarning();
@@ -33,7 +33,7 @@ var ConsoleMode;
33
33
  * verbose mode, there could be terminal output overwrite and animation
34
34
  */
35
35
  ConsoleMode["VERBOSE"] = "VERBOSE";
36
- })(ConsoleMode || (exports.ConsoleMode = ConsoleMode = {}));
36
+ })(ConsoleMode = exports.ConsoleMode || (exports.ConsoleMode = {}));
37
37
  /**
38
38
  * Manage, save, and restore the current state of the Console modes.
39
39
  * @internal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memlab/api",
3
- "version": "1.0.41",
3
+ "version": "1.0.42",
4
4
  "license": "MIT",
5
5
  "description": "memlab API",
6
6
  "author": "Liang Gong <lgong@meta.com>",
@@ -27,9 +27,9 @@
27
27
  "access": "public"
28
28
  },
29
29
  "dependencies": {
30
- "@memlab/core": "^1.1.42",
31
- "@memlab/e2e": "^1.0.42",
32
- "@memlab/heap-analysis": "^1.0.39",
30
+ "@memlab/core": "^1.1.43",
31
+ "@memlab/e2e": "^1.0.43",
32
+ "@memlab/heap-analysis": "^1.0.40",
33
33
  "ansi": "^0.3.1",
34
34
  "babar": "^0.2.0",
35
35
  "chalk": "^4.0.0",