@memlab/api 1.0.1 → 1.0.4
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.d.ts +142 -18
- package/dist/API.js +146 -17
- package/dist/__tests__/API/E2EDetachedDOMAnalysis.test.js +5 -6
- package/dist/__tests__/API/E2EDuplicateObjectAnalysis.test.js +5 -6
- package/dist/__tests__/API/E2EFindLeaks.example.d.ts +11 -0
- package/dist/__tests__/API/E2EFindLeaks.example.js +50 -0
- package/dist/__tests__/API/E2EFindMemoryLeaks.test.d.ts +11 -0
- package/dist/__tests__/API/E2EFindMemoryLeaks.test.js +72 -0
- package/dist/__tests__/API/E2EResultReader.test.d.ts +11 -0
- package/dist/__tests__/API/E2EResultReader.test.js +72 -0
- package/dist/__tests__/API/E2ERunSingleSnapshot.example.js +11 -12
- package/dist/__tests__/API/E2EShapeUnboundGrowthAnalysis.test.js +8 -17
- package/dist/__tests__/API/E2EStringAnalysis.test.js +19 -15
- package/dist/__tests__/heap/examples/example-1.d.ts +11 -0
- package/dist/__tests__/heap/examples/example-1.js +37 -0
- package/dist/__tests__/heap/examples/example-2.d.ts +11 -0
- package/dist/__tests__/heap/examples/example-2.js +33 -0
- package/dist/__tests__/heap/examples/example-3.d.ts +11 -0
- package/dist/__tests__/heap/examples/example-3.js +33 -0
- package/dist/__tests__/heap/examples/example-4.d.ts +11 -0
- package/dist/__tests__/heap/examples/example-4.js +32 -0
- package/dist/__tests__/heap/examples/example-5.test.d.ts +11 -0
- package/dist/__tests__/heap/examples/example-5.test.js +41 -0
- package/dist/__tests__/heap/examples/example-6.d.ts +11 -0
- package/dist/__tests__/heap/examples/example-6.js +32 -0
- package/dist/__tests__/heap/examples/example-7.test.d.ts +11 -0
- package/dist/__tests__/heap/examples/example-7.test.js +36 -0
- package/dist/__tests__/packages/heap-analysis.test.d.ts +11 -0
- package/dist/__tests__/packages/heap-analysis.test.js +82 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +11 -2
- package/dist/result-reader/BaseResultReader.d.ts +70 -0
- package/dist/result-reader/BaseResultReader.js +96 -0
- package/dist/result-reader/BrowserInteractionResultReader.d.ts +105 -0
- package/dist/result-reader/BrowserInteractionResultReader.js +136 -0
- package/package.json +2 -1
- package/dist/API.d.ts.map +0 -1
- package/dist/__tests__/API/E2EBasicAnalysis.test.d.ts.map +0 -1
- package/dist/__tests__/API/E2EDetachedDOMAnalysis.test.d.ts.map +0 -1
- package/dist/__tests__/API/E2EDuplicateObjectAnalysis.test.d.ts.map +0 -1
- package/dist/__tests__/API/E2ERunMultipleSnapshots.example.d.ts.map +0 -1
- package/dist/__tests__/API/E2ERunSingleSnapshot.example.d.ts.map +0 -1
- package/dist/__tests__/API/E2EShapeUnboundGrowthAnalysis.test.d.ts.map +0 -1
- package/dist/__tests__/API/E2EStringAnalysis.test.d.ts.map +0 -1
- package/dist/__tests__/API/lib/E2ETestSettings.d.ts.map +0 -1
- package/dist/__tests__/heap/E2EHeapParser.test.d.ts.map +0 -1
- package/dist/__tests__/heap/lib/HeapParserTestUtils.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/lib/APIUtils.d.ts.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -9,5 +9,8 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export * from './API';
|
|
11
11
|
export * from '@memlab/heap-analysis';
|
|
12
|
+
export { default as BrowserInteractionResultReader } from './result-reader/BrowserInteractionResultReader';
|
|
13
|
+
export { dumpNodeHeapSnapshot, getNodeInnocentHeap } from '@memlab/core';
|
|
14
|
+
/** @internal */
|
|
12
15
|
export { config } from '@memlab/core';
|
|
13
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -22,9 +22,18 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
22
22
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
23
23
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
24
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.config = void 0;
|
|
29
|
+
exports.config = exports.getNodeInnocentHeap = exports.dumpNodeHeapSnapshot = exports.BrowserInteractionResultReader = void 0;
|
|
27
30
|
__exportStar(require("./API"), exports);
|
|
28
31
|
__exportStar(require("@memlab/heap-analysis"), exports);
|
|
32
|
+
var BrowserInteractionResultReader_1 = require("./result-reader/BrowserInteractionResultReader");
|
|
33
|
+
Object.defineProperty(exports, "BrowserInteractionResultReader", { enumerable: true, get: function () { return __importDefault(BrowserInteractionResultReader_1).default; } });
|
|
29
34
|
var core_1 = require("@memlab/core");
|
|
30
|
-
Object.defineProperty(exports, "
|
|
35
|
+
Object.defineProperty(exports, "dumpNodeHeapSnapshot", { enumerable: true, get: function () { return core_1.dumpNodeHeapSnapshot; } });
|
|
36
|
+
Object.defineProperty(exports, "getNodeInnocentHeap", { enumerable: true, get: function () { return core_1.getNodeInnocentHeap; } });
|
|
37
|
+
/** @internal */
|
|
38
|
+
var core_2 = require("@memlab/core");
|
|
39
|
+
Object.defineProperty(exports, "config", { enumerable: true, get: function () { return core_2.config; } });
|
|
@@ -0,0 +1,70 @@
|
|
|
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 { FileManager } from '@memlab/core';
|
|
11
|
+
/**
|
|
12
|
+
* A utility entity to read all generated files from
|
|
13
|
+
* the directory holding the data and results from
|
|
14
|
+
* a memlab run
|
|
15
|
+
*/
|
|
16
|
+
export default class BaseResultReader {
|
|
17
|
+
protected workDir: string;
|
|
18
|
+
protected fileManager: FileManager;
|
|
19
|
+
private isValid;
|
|
20
|
+
/**
|
|
21
|
+
* build a result reader
|
|
22
|
+
* @param workDir absolute path of the directory where the data
|
|
23
|
+
* and generated files of the memlab run were stored
|
|
24
|
+
*/
|
|
25
|
+
protected constructor(workDir?: string);
|
|
26
|
+
protected check(): void;
|
|
27
|
+
/**
|
|
28
|
+
* internal
|
|
29
|
+
* @param workDir
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
static from(workDir?: string): BaseResultReader;
|
|
33
|
+
/**
|
|
34
|
+
* get the directory where the data and generated files of
|
|
35
|
+
* the memlab run were stored
|
|
36
|
+
* @returns absolute path of the directory
|
|
37
|
+
* * **Examples**:
|
|
38
|
+
* ```javascript
|
|
39
|
+
* const {takeSnapshots} = require('@memlab/api');
|
|
40
|
+
*
|
|
41
|
+
* (async function () {
|
|
42
|
+
* const scenario = { url: () => 'https://www.npmjs.com'};
|
|
43
|
+
* const result = await takeSnapshots({scenario});
|
|
44
|
+
*
|
|
45
|
+
* // get the directory that stores all the files
|
|
46
|
+
* // generated from the takeSnapshots call
|
|
47
|
+
* const dataDir = result.getRootDirectory();
|
|
48
|
+
* })();
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
getRootDirectory(): string;
|
|
52
|
+
/**
|
|
53
|
+
* clean up data/files generated from the memlab browser interaction run
|
|
54
|
+
* @returns no return value
|
|
55
|
+
* * **Examples**:
|
|
56
|
+
* ```javascript
|
|
57
|
+
* const {takeSnapshots} = require('@memlab/api');
|
|
58
|
+
*
|
|
59
|
+
* (async function () {
|
|
60
|
+
* const scenario = { url: () => 'https://www.npmjs.com'};
|
|
61
|
+
* const result = await takeSnapshots({scenario});
|
|
62
|
+
*
|
|
63
|
+
* // delete all data/files generated by takeSnapshots
|
|
64
|
+
* result.cleanup();
|
|
65
|
+
* })();
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
cleanup(): void;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=BaseResultReader.d.ts.map
|
|
@@ -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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const core_1 = require("@memlab/core");
|
|
16
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
17
|
+
/**
|
|
18
|
+
* A utility entity to read all generated files from
|
|
19
|
+
* the directory holding the data and results from
|
|
20
|
+
* a memlab run
|
|
21
|
+
*/
|
|
22
|
+
class BaseResultReader {
|
|
23
|
+
/**
|
|
24
|
+
* build a result reader
|
|
25
|
+
* @param workDir absolute path of the directory where the data
|
|
26
|
+
* and generated files of the memlab run were stored
|
|
27
|
+
*/
|
|
28
|
+
constructor(workDir = '') {
|
|
29
|
+
this.fileManager = new core_1.FileManager();
|
|
30
|
+
if (workDir === '') {
|
|
31
|
+
workDir = this.fileManager.getWorkDir();
|
|
32
|
+
}
|
|
33
|
+
this.workDir = workDir;
|
|
34
|
+
this.check();
|
|
35
|
+
}
|
|
36
|
+
check() {
|
|
37
|
+
this.isValid = fs_extra_1.default.existsSync(this.workDir);
|
|
38
|
+
if (!this.isValid) {
|
|
39
|
+
core_1.utils.haltOrThrow(`invalid/removed data directory: ${this.workDir}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* internal
|
|
44
|
+
* @param workDir
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
47
|
+
static from(workDir = '') {
|
|
48
|
+
return new BaseResultReader(workDir);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* get the directory where the data and generated files of
|
|
52
|
+
* the memlab run were stored
|
|
53
|
+
* @returns absolute path of the directory
|
|
54
|
+
* * **Examples**:
|
|
55
|
+
* ```javascript
|
|
56
|
+
* const {takeSnapshots} = require('@memlab/api');
|
|
57
|
+
*
|
|
58
|
+
* (async function () {
|
|
59
|
+
* const scenario = { url: () => 'https://www.npmjs.com'};
|
|
60
|
+
* const result = await takeSnapshots({scenario});
|
|
61
|
+
*
|
|
62
|
+
* // get the directory that stores all the files
|
|
63
|
+
* // generated from the takeSnapshots call
|
|
64
|
+
* const dataDir = result.getRootDirectory();
|
|
65
|
+
* })();
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
getRootDirectory() {
|
|
69
|
+
this.check();
|
|
70
|
+
return this.workDir;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* clean up data/files generated from the memlab browser interaction run
|
|
74
|
+
* @returns no return value
|
|
75
|
+
* * **Examples**:
|
|
76
|
+
* ```javascript
|
|
77
|
+
* const {takeSnapshots} = require('@memlab/api');
|
|
78
|
+
*
|
|
79
|
+
* (async function () {
|
|
80
|
+
* const scenario = { url: () => 'https://www.npmjs.com'};
|
|
81
|
+
* const result = await takeSnapshots({scenario});
|
|
82
|
+
*
|
|
83
|
+
* // delete all data/files generated by takeSnapshots
|
|
84
|
+
* result.cleanup();
|
|
85
|
+
* })();
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
cleanup() {
|
|
89
|
+
if (!this.isValid) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
fs_extra_1.default.removeSync(this.workDir);
|
|
93
|
+
this.isValid = false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.default = BaseResultReader;
|
|
@@ -0,0 +1,105 @@
|
|
|
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 { E2EStepInfo, RunMetaInfo } from '@memlab/core';
|
|
11
|
+
import BaseResultReader from './BaseResultReader';
|
|
12
|
+
/**
|
|
13
|
+
* A utility entity to read all generated files from
|
|
14
|
+
* the directory holding the data and results from the
|
|
15
|
+
* last browser interaction run
|
|
16
|
+
*/
|
|
17
|
+
export default class BrowserInteractionResultReader extends BaseResultReader {
|
|
18
|
+
/**
|
|
19
|
+
* build a result reader from a data directory where the data
|
|
20
|
+
* and generated files of a memlab run were stored
|
|
21
|
+
* @param workDir absolute path of the data directory
|
|
22
|
+
* @returns the ResultReader instance
|
|
23
|
+
*
|
|
24
|
+
* * **Examples**:
|
|
25
|
+
* ```javascript
|
|
26
|
+
* const {BrowserInteractionResultReader} = require('@memlab/api');
|
|
27
|
+
*
|
|
28
|
+
* const dataDir = '/tmp/memlab'; // where the last memlab run stores results
|
|
29
|
+
* const reader = BrowserInteractionResultReader.from(dataDir);
|
|
30
|
+
* reader.cleanup(); // clean up the results
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
static from(workDir?: string): BrowserInteractionResultReader;
|
|
34
|
+
/**
|
|
35
|
+
* get all snapshot files generated from last memlab browser interaction
|
|
36
|
+
* @returns an array of snapshot file's absolute path
|
|
37
|
+
* * **Examples**:
|
|
38
|
+
* ```javascript
|
|
39
|
+
* const {takeSnapshots} = require('@memlab/api');
|
|
40
|
+
*
|
|
41
|
+
* (async function () {
|
|
42
|
+
* const scenario = { url: () => 'https://www.npmjs.com'};
|
|
43
|
+
* const result = await takeSnapshots({scenario});
|
|
44
|
+
*
|
|
45
|
+
* // get absolute paths of all snapshot files
|
|
46
|
+
* const files = result.getSnapshotFiles();
|
|
47
|
+
* })();
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
getSnapshotFiles(): string[];
|
|
51
|
+
/**
|
|
52
|
+
* get the directory holding all snapshot files
|
|
53
|
+
* @returns the absolute path of the directory
|
|
54
|
+
* * **Examples**:
|
|
55
|
+
* ```javascript
|
|
56
|
+
* const {takeSnapshots} = require('@memlab/api');
|
|
57
|
+
*
|
|
58
|
+
* (async function () {
|
|
59
|
+
* const scenario = { url: () => 'https://www.npmjs.com'};
|
|
60
|
+
* const result = await takeSnapshots({scenario});
|
|
61
|
+
*
|
|
62
|
+
* // get the absolute path the directory holding all snapshot files
|
|
63
|
+
* const files = result.getSnapshotFileDir();
|
|
64
|
+
* })();
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
getSnapshotFileDir(): string;
|
|
68
|
+
/**
|
|
69
|
+
* browser interaction step sequence
|
|
70
|
+
* @returns an array of browser interaction step information
|
|
71
|
+
* * **Examples**:
|
|
72
|
+
* ```javascript
|
|
73
|
+
* const {takeSnapshots} = require('@memlab/api');
|
|
74
|
+
*
|
|
75
|
+
* (async function () {
|
|
76
|
+
* const scenario = { url: () => 'https://www.npmjs.com'};
|
|
77
|
+
* const result = await takeSnapshots({scenario});
|
|
78
|
+
*
|
|
79
|
+
* const steps = result.getInteractionSteps();
|
|
80
|
+
* // print each browser interaction's name and JavaScript heap size (in bytes)
|
|
81
|
+
* steps.forEach(step => console.log(step.name, step.JSHeapUsedSize))
|
|
82
|
+
* })();
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
getInteractionSteps(): E2EStepInfo[];
|
|
86
|
+
/**
|
|
87
|
+
* general meta data of the browser interaction run
|
|
88
|
+
* @returns meta data about the entire browser interaction
|
|
89
|
+
* * **Examples**:
|
|
90
|
+
* ```javascript
|
|
91
|
+
* const {takeSnapshots} = require('@memlab/api');
|
|
92
|
+
*
|
|
93
|
+
* (async function () {
|
|
94
|
+
* const scenario = { url: () => 'https://www.npmjs.com'};
|
|
95
|
+
* const result = await takeSnapshots({scenario});
|
|
96
|
+
*
|
|
97
|
+
* const metaInfo = result.getRunMetaInfo();
|
|
98
|
+
* // print all browser web console output
|
|
99
|
+
* console.log(metaInfo.browserInfo._consoleMessages.join('\n'));
|
|
100
|
+
* })();
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
getRunMetaInfo(): RunMetaInfo;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=BrowserInteractionResultReader.d.ts.map
|
|
@@ -0,0 +1,136 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const core_1 = require("@memlab/core");
|
|
16
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
17
|
+
const path_1 = __importDefault(require("path"));
|
|
18
|
+
const BaseResultReader_1 = __importDefault(require("./BaseResultReader"));
|
|
19
|
+
/**
|
|
20
|
+
* A utility entity to read all generated files from
|
|
21
|
+
* the directory holding the data and results from the
|
|
22
|
+
* last browser interaction run
|
|
23
|
+
*/
|
|
24
|
+
class BrowserInteractionResultReader extends BaseResultReader_1.default {
|
|
25
|
+
/**
|
|
26
|
+
* build a result reader from a data directory where the data
|
|
27
|
+
* and generated files of a memlab run were stored
|
|
28
|
+
* @param workDir absolute path of the data directory
|
|
29
|
+
* @returns the ResultReader instance
|
|
30
|
+
*
|
|
31
|
+
* * **Examples**:
|
|
32
|
+
* ```javascript
|
|
33
|
+
* const {BrowserInteractionResultReader} = require('@memlab/api');
|
|
34
|
+
*
|
|
35
|
+
* const dataDir = '/tmp/memlab'; // where the last memlab run stores results
|
|
36
|
+
* const reader = BrowserInteractionResultReader.from(dataDir);
|
|
37
|
+
* reader.cleanup(); // clean up the results
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
static from(workDir = '') {
|
|
41
|
+
return new BrowserInteractionResultReader(workDir);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* get all snapshot files generated from last memlab browser interaction
|
|
45
|
+
* @returns an array of snapshot file's absolute path
|
|
46
|
+
* * **Examples**:
|
|
47
|
+
* ```javascript
|
|
48
|
+
* const {takeSnapshots} = require('@memlab/api');
|
|
49
|
+
*
|
|
50
|
+
* (async function () {
|
|
51
|
+
* const scenario = { url: () => 'https://www.npmjs.com'};
|
|
52
|
+
* const result = await takeSnapshots({scenario});
|
|
53
|
+
*
|
|
54
|
+
* // get absolute paths of all snapshot files
|
|
55
|
+
* const files = result.getSnapshotFiles();
|
|
56
|
+
* })();
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
getSnapshotFiles() {
|
|
60
|
+
this.check();
|
|
61
|
+
const dataDir = this.fileManager.getCurDataDir({ workDir: this.workDir });
|
|
62
|
+
return fs_extra_1.default
|
|
63
|
+
.readdirSync(dataDir)
|
|
64
|
+
.filter(file => file.endsWith('heapsnapshot'))
|
|
65
|
+
.map(file => path_1.default.join(dataDir, file));
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* get the directory holding all snapshot files
|
|
69
|
+
* @returns the absolute path of the directory
|
|
70
|
+
* * **Examples**:
|
|
71
|
+
* ```javascript
|
|
72
|
+
* const {takeSnapshots} = require('@memlab/api');
|
|
73
|
+
*
|
|
74
|
+
* (async function () {
|
|
75
|
+
* const scenario = { url: () => 'https://www.npmjs.com'};
|
|
76
|
+
* const result = await takeSnapshots({scenario});
|
|
77
|
+
*
|
|
78
|
+
* // get the absolute path the directory holding all snapshot files
|
|
79
|
+
* const files = result.getSnapshotFileDir();
|
|
80
|
+
* })();
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
getSnapshotFileDir() {
|
|
84
|
+
this.check();
|
|
85
|
+
return this.fileManager.getCurDataDir({ workDir: this.workDir });
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* browser interaction step sequence
|
|
89
|
+
* @returns an array of browser interaction step information
|
|
90
|
+
* * **Examples**:
|
|
91
|
+
* ```javascript
|
|
92
|
+
* const {takeSnapshots} = require('@memlab/api');
|
|
93
|
+
*
|
|
94
|
+
* (async function () {
|
|
95
|
+
* const scenario = { url: () => 'https://www.npmjs.com'};
|
|
96
|
+
* const result = await takeSnapshots({scenario});
|
|
97
|
+
*
|
|
98
|
+
* const steps = result.getInteractionSteps();
|
|
99
|
+
* // print each browser interaction's name and JavaScript heap size (in bytes)
|
|
100
|
+
* steps.forEach(step => console.log(step.name, step.JSHeapUsedSize))
|
|
101
|
+
* })();
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
getInteractionSteps() {
|
|
105
|
+
this.check();
|
|
106
|
+
const metaFile = this.fileManager.getSnapshotSequenceMetaFile({
|
|
107
|
+
workDir: this.workDir,
|
|
108
|
+
});
|
|
109
|
+
return core_1.utils.loadTabsOrder(metaFile);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* general meta data of the browser interaction run
|
|
113
|
+
* @returns meta data about the entire browser interaction
|
|
114
|
+
* * **Examples**:
|
|
115
|
+
* ```javascript
|
|
116
|
+
* const {takeSnapshots} = require('@memlab/api');
|
|
117
|
+
*
|
|
118
|
+
* (async function () {
|
|
119
|
+
* const scenario = { url: () => 'https://www.npmjs.com'};
|
|
120
|
+
* const result = await takeSnapshots({scenario});
|
|
121
|
+
*
|
|
122
|
+
* const metaInfo = result.getRunMetaInfo();
|
|
123
|
+
* // print all browser web console output
|
|
124
|
+
* console.log(metaInfo.browserInfo._consoleMessages.join('\n'));
|
|
125
|
+
* })();
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
getRunMetaInfo() {
|
|
129
|
+
this.check();
|
|
130
|
+
const metaFile = this.fileManager.getRunMetaFile({
|
|
131
|
+
workDir: this.workDir,
|
|
132
|
+
});
|
|
133
|
+
return core_1.utils.loadRunMetaInfo(metaFile);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.default = BrowserInteractionResultReader;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memlab/api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "memlab API",
|
|
6
6
|
"author": "Liang Gong <lgong@fb.com>",
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
"scripts": {
|
|
58
58
|
"build-pkg": "tsc",
|
|
59
59
|
"test-pkg": "jest .",
|
|
60
|
+
"publish-patch": "npm version patch --force && npm publish",
|
|
60
61
|
"clean-pkg": "rm -rf ./dist && rm -rf ./node_modules && rm -f ./tsconfig.tsbuildinfo"
|
|
61
62
|
},
|
|
62
63
|
"bugs": {
|
package/dist/API.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"API.d.ts","sourceRoot":"","sources":["../src/API.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,IAAI,EAAU,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,SAAS,EACT,WAAW,EAGZ,MAAM,cAAc,CAAC;AAEtB,OAAO,EAKL,YAAY,EACb,MAAM,cAAc,CAAC;AACtB,OAAO,EAEL,WAAW,EAGZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AAGnD,aAAK,UAAU,GAAG;IAGhB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,0BAA0B,CAAC,EAAE,WAAW,CAAC;CAC1C,CAAC;AAEF,aAAK,UAAU,GAAG;IAChB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0BAA0B,CAAC,EAAE,WAAW,CAAC;IACzC,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,aAAK,SAAS,GAAG;IACf,MAAM,EAAE,YAAY,CAAC;IACrB,SAAS,EAAE,WAAW,EAAE,CAAC;IACzB,QAAQ,EAAE,WAAW,CAAC;CACvB,CAAC;AASF,wBAAsB,GAAG,CAAC,OAAO,GAAE,UAAe,GAAG,OAAO,CAAC,SAAS,CAAC,CActE;AAED,wBAAsB,aAAa,CACjC,OAAO,GAAE,UAAe,GACvB,OAAO,CAAC,SAAS,CAAC,CAapB;AAED,wBAAsB,OAAO,CAC3B,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,EAC1B,IAAI,GAAE,UAAoB,GACzB,OAAO,CAAC,IAAI,CAAC,CAEf;AAED,wBAAsB,MAAM,CAAC,OAAO,GAAE,UAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAuCpE;AAED,wBAAsB,SAAS,CAC7B,IAAI,EAAE,IAAI,EACV,OAAO,GAAE,UAAe,GACvB,OAAO,CAAC,IAAI,CAAC,CAoBf;AAyBD,wBAAsB,aAAa,CAAC,OAAO,GAAE,UAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAkD3E"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"E2EBasicAnalysis.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/API/E2EBasicAnalysis.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"E2EDetachedDOMAnalysis.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/API/E2EDetachedDOMAnalysis.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"E2EDuplicateObjectAnalysis.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/API/E2EDuplicateObjectAnalysis.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"E2ERunMultipleSnapshots.example.d.ts","sourceRoot":"","sources":["../../../src/__tests__/API/E2ERunMultipleSnapshots.example.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"E2ERunSingleSnapshot.example.d.ts","sourceRoot":"","sources":["../../../src/__tests__/API/E2ERunSingleSnapshot.example.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"E2EShapeUnboundGrowthAnalysis.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/API/E2EShapeUnboundGrowthAnalysis.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"E2EStringAnalysis.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/API/E2EStringAnalysis.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"E2EHeapParser.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/heap/E2EHeapParser.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,QAAQ,EAA2B,MAAM,cAAc,CAAC;AAOrE,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,QAAQ,EAAE,QAAQ,CAAC;KACpB;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HeapParserTestUtils.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/heap/lib/HeapParserTestUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAUhD,wBAAsB,kBAAkB,CACtC,YAAY,EAAE,MAAM,IAAI,EACxB,eAAe,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,OAAO,GACpD,OAAO,CAAC,IAAI,CAAC,CAGf"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,cAAc,OAAO,CAAC;AACtB,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"APIUtils.d.ts","sourceRoot":"","sources":["../../src/lib/APIUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,cAAc,CAAC;AAU/C,iBAAe,UAAU,CACvB,OAAO,GAAE;IAAC,MAAM,CAAC,EAAE,YAAY,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAM,GACtD,OAAO,CAAC,OAAO,CAAC,CAmBlB;;;;AAED,wBAEE"}
|