@memlab/core 1.1.10 → 1.1.12
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/LICENSE +21 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -1
- package/dist/lib/Constant.js +1 -2
- package/dist/lib/NodeHeap.js +1 -1
- package/dist/lib/Serializer.d.ts +1 -0
- package/dist/lib/Serializer.js +4 -2
- package/dist/lib/Types.d.ts +35 -4
- package/package.json +3 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
CHANGED
|
@@ -49,4 +49,6 @@ export { default as EvaluationMetric } from './trace-cluster/EvalutationMetric';
|
|
|
49
49
|
export * from './lib/PackageInfoLoader';
|
|
50
50
|
/** @internal */
|
|
51
51
|
export { default as SequentialClustering } from './trace-cluster/SequentialClustering';
|
|
52
|
+
/** @internal */
|
|
53
|
+
export { default as TraceFinder } from './paths/TraceFinder';
|
|
52
54
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -35,7 +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.SequentialClustering = 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 = exports.registerPackage = void 0;
|
|
38
|
+
exports.TraceFinder = exports.SequentialClustering = 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 = exports.registerPackage = void 0;
|
|
39
39
|
const path_1 = __importDefault(require("path"));
|
|
40
40
|
const PackageInfoLoader_1 = require("./lib/PackageInfoLoader");
|
|
41
41
|
/** @internal */
|
|
@@ -100,3 +100,6 @@ __exportStar(require("./lib/PackageInfoLoader"), exports);
|
|
|
100
100
|
/** @internal */
|
|
101
101
|
var SequentialClustering_1 = require("./trace-cluster/SequentialClustering");
|
|
102
102
|
Object.defineProperty(exports, "SequentialClustering", { enumerable: true, get: function () { return __importDefault(SequentialClustering_1).default; } });
|
|
103
|
+
/** @internal */
|
|
104
|
+
var TraceFinder_1 = require("./paths/TraceFinder");
|
|
105
|
+
Object.defineProperty(exports, "TraceFinder", { enumerable: true, get: function () { return __importDefault(TraceFinder_1).default; } });
|
package/dist/lib/Constant.js
CHANGED
|
@@ -18,8 +18,7 @@ const constants = {
|
|
|
18
18
|
supportedBrowsers: Object.create(null),
|
|
19
19
|
internalDir: 'fb-internal',
|
|
20
20
|
monoRepoDir: '',
|
|
21
|
-
defaultUserAgent: '
|
|
22
|
-
' AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.0 Safari/537.36',
|
|
21
|
+
defaultUserAgent: 'default',
|
|
23
22
|
V8SyntheticRoots: [
|
|
24
23
|
'(GC roots)',
|
|
25
24
|
'(Internalized strings)',
|
package/dist/lib/NodeHeap.js
CHANGED
|
@@ -93,7 +93,7 @@ exports.tagObject = tagObject;
|
|
|
93
93
|
* ```
|
|
94
94
|
*/
|
|
95
95
|
function dumpNodeHeapSnapshot() {
|
|
96
|
-
const randomID =
|
|
96
|
+
const randomID = `${Math.random()}`.replace('0.', '');
|
|
97
97
|
const file = path_1.default.join(FileManager_1.default.generateTmpHeapDir(), `nodejs-${randomID}.heapsnapshot`);
|
|
98
98
|
if (fs_extra_1.default.existsSync(file)) {
|
|
99
99
|
fs_extra_1.default.removeSync(file);
|
package/dist/lib/Serializer.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ declare type UnboundedObjectInfo = {
|
|
|
28
28
|
node: IHeapNode;
|
|
29
29
|
type: string;
|
|
30
30
|
history: number[];
|
|
31
|
+
historyNumberFormatter?: (n: number) => string;
|
|
31
32
|
};
|
|
32
33
|
declare function summarizeUnboundedObjects(unboundedObjects: UnboundedObjectInfo[], options?: SummarizeOptions): string;
|
|
33
34
|
declare function summarizeUnboundedObjectsToCSV(unboundedObjects: UnboundedObjectInfo[]): string;
|
package/dist/lib/Serializer.js
CHANGED
|
@@ -553,15 +553,17 @@ function summarizeNodeShape(node, options = {}) {
|
|
|
553
553
|
return summarizeObjectShape(node, options);
|
|
554
554
|
}
|
|
555
555
|
function summarizeUnboundedObjects(unboundedObjects, options = {}) {
|
|
556
|
-
const
|
|
556
|
+
const historySeparator = options.color ? chalk_1.default.grey(' > ') : ' > ';
|
|
557
557
|
const prefix = options.color ? chalk_1.default.grey('· ') : '· ';
|
|
558
558
|
const opt = Object.assign({ compact: true }, options);
|
|
559
559
|
return unboundedObjects
|
|
560
560
|
.map(item => {
|
|
561
|
+
var _a;
|
|
561
562
|
const id = options.color ? chalk_1.default.grey(`@${item.id}`) : `@${item.id}`;
|
|
562
563
|
const name = summarizeNodeShape(item.node, opt);
|
|
564
|
+
const formatter = (_a = item.historyNumberFormatter) !== null && _a !== void 0 ? _a : Utils_1.default.getReadableBytes.bind(Utils_1.default);
|
|
563
565
|
return (`${prefix}${name} [${item.type}](${id}): ` +
|
|
564
|
-
item.history.map(v =>
|
|
566
|
+
item.history.map(v => formatter(v)).join(historySeparator));
|
|
565
567
|
})
|
|
566
568
|
.join('\n');
|
|
567
569
|
}
|
package/dist/lib/Types.d.ts
CHANGED
|
@@ -361,7 +361,7 @@ export declare type InteractionsCallback = (page: Page, args?: OperationArgs) =>
|
|
|
361
361
|
* ```
|
|
362
362
|
*
|
|
363
363
|
* The test scenario instance can also be passed to the
|
|
364
|
-
*
|
|
364
|
+
* {@link run} API exported by `@memlab/api`.
|
|
365
365
|
* ```typescript
|
|
366
366
|
* const {run} = require('@memlab/api');
|
|
367
367
|
*
|
|
@@ -431,6 +431,35 @@ export interface IScenario {
|
|
|
431
431
|
* for memory leak filtering.
|
|
432
432
|
*/
|
|
433
433
|
url: () => string;
|
|
434
|
+
/**
|
|
435
|
+
* `setup` is the callback function that will be called only once
|
|
436
|
+
* after the initial page load. This callback can be used to log in
|
|
437
|
+
* if you have to (we recommend using {@link cookies})
|
|
438
|
+
* or to prepare data before the {@link action} call.
|
|
439
|
+
*
|
|
440
|
+
* * **Parameters**:
|
|
441
|
+
* * page: `Page` | the puppeteer [`Page`](https://pptr.dev/api/puppeteer.page)
|
|
442
|
+
* object, which provides APIs to interact with the web browser
|
|
443
|
+
*
|
|
444
|
+
* * **Examples**:
|
|
445
|
+
* ```typescript
|
|
446
|
+
* const scenario = {
|
|
447
|
+
* url: () => 'https://www.npmjs.com/',
|
|
448
|
+
* setup: async (page) => {
|
|
449
|
+
* // log in or prepare data for the interaction
|
|
450
|
+
* },
|
|
451
|
+
* action: async (page) => {
|
|
452
|
+
* await page.click('a[href="/link"]');
|
|
453
|
+
* },
|
|
454
|
+
* back: async (page) => {
|
|
455
|
+
* await page.click('a[href="/back"]');
|
|
456
|
+
* },
|
|
457
|
+
* }
|
|
458
|
+
*
|
|
459
|
+
* module.exports = scenario;
|
|
460
|
+
* ```
|
|
461
|
+
*/
|
|
462
|
+
setup?: InteractionsCallback;
|
|
434
463
|
/**
|
|
435
464
|
* `action` is the callback function that defines the interaction
|
|
436
465
|
* where you want to trigger memory leaks after the initial page load.
|
|
@@ -473,7 +502,7 @@ export interface IScenario {
|
|
|
473
502
|
* }
|
|
474
503
|
*
|
|
475
504
|
* module.exports = scenario;
|
|
476
|
-
```
|
|
505
|
+
* ```
|
|
477
506
|
*/
|
|
478
507
|
action?: InteractionsCallback;
|
|
479
508
|
/**
|
|
@@ -728,10 +757,12 @@ export interface IE2EScenarioVisitPlan {
|
|
|
728
757
|
numOfWarmup: number;
|
|
729
758
|
dataBuilder: Optional<IDataBuilder>;
|
|
730
759
|
isPageLoaded?: CheckPageLoadCallback;
|
|
760
|
+
scenario?: IScenario;
|
|
731
761
|
}
|
|
732
762
|
/** @internal */
|
|
733
763
|
export declare type OperationArgs = {
|
|
734
764
|
isPageLoaded?: CheckPageLoadCallback;
|
|
765
|
+
scenario?: Optional<IScenario>;
|
|
735
766
|
showProgress?: boolean;
|
|
736
767
|
failedURLs?: AnyRecord;
|
|
737
768
|
pageHistoryLength?: number[];
|
|
@@ -893,7 +924,7 @@ export interface IHeapSnapshot {
|
|
|
893
924
|
/**
|
|
894
925
|
* Search for the heap and check if there is any JS object instance with
|
|
895
926
|
* a specified constructor name.
|
|
896
|
-
* @param className The
|
|
927
|
+
* @param className The constructor name of the object instance
|
|
897
928
|
* @returns `true` if there is at least one such object in the heap
|
|
898
929
|
*
|
|
899
930
|
* * **Examples**: you can write a jest unit test with memory assertions:
|
|
@@ -932,7 +963,7 @@ export interface IHeapSnapshot {
|
|
|
932
963
|
/**
|
|
933
964
|
* Search for the heap and get one of the JS object instances with
|
|
934
965
|
* a specified constructor name (if there is any).
|
|
935
|
-
* @param className The
|
|
966
|
+
* @param className The constructor name of the object instance
|
|
936
967
|
* @returns a handle pointing to any one of the object instances, returns
|
|
937
968
|
* `null` if no such object exists in the heap.
|
|
938
969
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memlab/core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.12",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "memlab core libraries",
|
|
6
6
|
"author": "Liang Gong <lgong@fb.com>",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
"dist",
|
|
27
|
-
"static"
|
|
27
|
+
"static",
|
|
28
|
+
"LICENSE"
|
|
28
29
|
],
|
|
29
30
|
"engines": {
|
|
30
31
|
"node": ">= 12.6.0"
|