@memlab/api 1.0.3 → 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 CHANGED
@@ -17,7 +17,10 @@ import BrowserInteractionResultReader from './result-reader/BrowserInteractionRe
17
17
  * Options for configuring browser interaction run, all fields are optional
18
18
  */
19
19
  export declare type RunOptions = {
20
- /** test scenario definition */
20
+ /**
21
+ * test scenario specifying how to interact with browser
22
+ * (for more details view {@link IScenario})
23
+ */
21
24
  scenario?: IScenario;
22
25
  /** the absolute path of cookies file */
23
26
  cookiesFile?: string;
@@ -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=example-1.d.ts.map
@@ -0,0 +1,37 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ const core_1 = require("@memlab/core");
22
+ class TestObject {
23
+ constructor() {
24
+ this.arr1 = [1, 2, 3];
25
+ this.arr2 = ['1', '2', '3'];
26
+ }
27
+ }
28
+ (function () {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
31
+ const obj = new TestObject();
32
+ // get a heap snapshot of the current program state
33
+ const heap = yield (0, core_1.getNodeInnocentHeap)();
34
+ const node = heap.getAnyObjectWithClassName('TestObject');
35
+ console.log(node === null || node === void 0 ? void 0 : node.name);
36
+ });
37
+ })();
@@ -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=example-2.d.ts.map
@@ -0,0 +1,33 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ const core_1 = require("@memlab/core");
22
+ const heap_analysis_1 = require("@memlab/heap-analysis");
23
+ (function () {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ const heapFile = (0, core_1.dumpNodeHeapSnapshot)();
26
+ const heap = yield (0, heap_analysis_1.getHeapFromFile)(heapFile);
27
+ // get the total number of heap objects
28
+ heap.nodes.length;
29
+ heap.nodes.forEach((node) => {
30
+ console.log(node.name);
31
+ });
32
+ });
33
+ })();
@@ -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=example-3.d.ts.map
@@ -0,0 +1,33 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ const core_1 = require("@memlab/core");
22
+ const heap_analysis_1 = require("@memlab/heap-analysis");
23
+ (function () {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ const heapFile = (0, core_1.dumpNodeHeapSnapshot)();
26
+ const heap = yield (0, heap_analysis_1.getHeapFromFile)(heapFile);
27
+ // get the total number of heap references
28
+ heap.edges.length;
29
+ heap.edges.forEach((edge) => {
30
+ console.log(edge.name_or_index);
31
+ });
32
+ });
33
+ })();
@@ -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=example-4.d.ts.map
@@ -0,0 +1,32 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ const core_1 = require("@memlab/core");
22
+ const heap_analysis_1 = require("@memlab/heap-analysis");
23
+ (function () {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ const heapFile = (0, core_1.dumpNodeHeapSnapshot)();
26
+ const heap = yield (0, heap_analysis_1.getHeapFromFile)(heapFile);
27
+ const node = heap.getNodeById(1);
28
+ if (node) {
29
+ console.log(node.id);
30
+ }
31
+ });
32
+ })();
@@ -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=example-5.test.d.ts.map
@@ -0,0 +1,41 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ const core_1 = require("@memlab/core");
22
+ class TestObject {
23
+ constructor() {
24
+ this.arr1 = [1, 2, 3];
25
+ this.arr2 = ['1', '2', '3'];
26
+ }
27
+ }
28
+ test('memory test', () => __awaiter(void 0, void 0, void 0, function* () {
29
+ core_1.config.muteConsole = true;
30
+ let obj = new TestObject();
31
+ // get a heap snapshot of the current program state
32
+ let heap = yield (0, core_1.getNodeInnocentHeap)();
33
+ // call some function that may add references to obj
34
+ // rabbitHole()
35
+ expect(heap.hasObjectWithClassName('TestObject')).toBe(true);
36
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
37
+ obj = null;
38
+ heap = yield (0, core_1.getNodeInnocentHeap)();
39
+ // if rabbitHole does not add new references, the obj can be GCed
40
+ expect(heap.hasObjectWithClassName('TestObject')).toBe(false);
41
+ }), 30000);
@@ -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=example-6.d.ts.map
@@ -0,0 +1,32 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ const core_1 = require("@memlab/core");
22
+ const heap_analysis_1 = require("@memlab/heap-analysis");
23
+ (function () {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
26
+ const object = { 'memlab-test-heap-property': 'memlab-test-heap-value' };
27
+ const heapFile = (0, core_1.dumpNodeHeapSnapshot)();
28
+ const heap = yield (0, heap_analysis_1.getHeapFromFile)(heapFile);
29
+ // should be true
30
+ console.log(heap.hasObjectWithPropertyName('memlab-test-heap-property'));
31
+ });
32
+ })();
@@ -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=example-7.test.d.ts.map
@@ -0,0 +1,36 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ const core_1 = require("@memlab/core");
22
+ test('memory test', () => __awaiter(void 0, void 0, void 0, function* () {
23
+ core_1.config.muteConsole = true;
24
+ const o1 = {};
25
+ let o2 = {};
26
+ // tag o1 with marker: "memlab-mark-1"
27
+ (0, core_1.tagObject)(o1, 'memlab-mark-1');
28
+ // tag o2 with marker: "memlab-mark-2"
29
+ (0, core_1.tagObject)(o2, 'memlab-mark-2');
30
+ o2 = null;
31
+ const heap = yield (0, core_1.getNodeInnocentHeap)();
32
+ // expect object with marker "memlab-mark-1" exists
33
+ expect(heap.hasObjectWithTag('memlab-mark-1')).toBe(true);
34
+ // expect object with marker "memlab-mark-2" can be GCed
35
+ expect(heap.hasObjectWithTag('memlab-mark-2')).toBe(false);
36
+ }), 30000);
package/dist/index.d.ts CHANGED
@@ -10,7 +10,7 @@
10
10
  export * from './API';
11
11
  export * from '@memlab/heap-analysis';
12
12
  export { default as BrowserInteractionResultReader } from './result-reader/BrowserInteractionResultReader';
13
- export { dumpNodeHeapSnapshot, getCurrentNodeHeap } from '@memlab/core';
13
+ export { dumpNodeHeapSnapshot, getNodeInnocentHeap } from '@memlab/core';
14
14
  /** @internal */
15
15
  export { config } from '@memlab/core';
16
16
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -26,14 +26,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.config = exports.getCurrentNodeHeap = exports.dumpNodeHeapSnapshot = exports.BrowserInteractionResultReader = void 0;
29
+ exports.config = exports.getNodeInnocentHeap = exports.dumpNodeHeapSnapshot = exports.BrowserInteractionResultReader = void 0;
30
30
  __exportStar(require("./API"), exports);
31
31
  __exportStar(require("@memlab/heap-analysis"), exports);
32
32
  var BrowserInteractionResultReader_1 = require("./result-reader/BrowserInteractionResultReader");
33
33
  Object.defineProperty(exports, "BrowserInteractionResultReader", { enumerable: true, get: function () { return __importDefault(BrowserInteractionResultReader_1).default; } });
34
34
  var core_1 = require("@memlab/core");
35
35
  Object.defineProperty(exports, "dumpNodeHeapSnapshot", { enumerable: true, get: function () { return core_1.dumpNodeHeapSnapshot; } });
36
- Object.defineProperty(exports, "getCurrentNodeHeap", { enumerable: true, get: function () { return core_1.getCurrentNodeHeap; } });
36
+ Object.defineProperty(exports, "getNodeInnocentHeap", { enumerable: true, get: function () { return core_1.getNodeInnocentHeap; } });
37
37
  /** @internal */
38
38
  var core_2 = require("@memlab/core");
39
39
  Object.defineProperty(exports, "config", { enumerable: true, get: function () { return core_2.config; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memlab/api",
3
- "version": "1.0.3",
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": {