@atlaspack/graph 3.4.1-canary.52 → 3.4.1-canary.521
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/CHANGELOG.md +432 -0
- package/benchmark/BitSet.js +37 -0
- package/dist/AdjacencyList.js +1348 -0
- package/dist/BitSet.js +108 -0
- package/dist/ContentGraph.js +70 -0
- package/dist/Graph.js +504 -0
- package/dist/index.js +17 -0
- package/dist/shared-buffer.js +24 -0
- package/dist/types.js +10 -0
- package/lib/AdjacencyList.js +35 -11
- package/lib/BitSet.js +36 -5
- package/lib/ContentGraph.js +2 -6
- package/lib/Graph.js +26 -13
- package/lib/index.js +2 -3
- package/lib/shared-buffer.js +5 -1
- package/lib/types/AdjacencyList.d.ts +609 -0
- package/lib/types/BitSet.d.ts +19 -0
- package/lib/types/ContentGraph.d.ts +23 -0
- package/lib/types/Graph.d.ts +92 -0
- package/lib/types/index.d.ts +7 -0
- package/lib/types/shared-buffer.d.ts +2 -0
- package/lib/types/types.d.ts +9 -0
- package/lib/types.js +1 -0
- package/package.json +16 -6
- package/src/{AdjacencyList.js → AdjacencyList.ts} +135 -107
- package/src/{BitSet.js → BitSet.ts} +31 -3
- package/src/{ContentGraph.js → ContentGraph.ts} +21 -20
- package/src/{Graph.js → Graph.ts} +104 -74
- package/src/{index.js → index.ts} +0 -2
- package/src/{shared-buffer.js → shared-buffer.ts} +6 -3
- package/src/{types.js → types.ts} +5 -7
- package/test/{AdjacencyList.test.js → AdjacencyList.test.ts} +21 -29
- package/test/{BitSet.test.js → BitSet.test.ts} +45 -5
- package/test/{ContentGraph.test.js → ContentGraph.test.ts} +2 -4
- package/test/{Graph.test.js → Graph.test.ts} +44 -36
- package/tsconfig.json +18 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SharedBuffer = void 0;
|
|
4
|
+
// @ts-expect-error TS2339
|
|
5
|
+
if (process.browser) {
|
|
6
|
+
exports.SharedBuffer = ArrayBuffer;
|
|
7
|
+
// Safari has removed the constructor
|
|
8
|
+
if (typeof SharedArrayBuffer !== 'undefined') {
|
|
9
|
+
let channel = new MessageChannel();
|
|
10
|
+
try {
|
|
11
|
+
// Firefox might throw when sending the Buffer over a MessagePort
|
|
12
|
+
channel.port1.postMessage(new SharedArrayBuffer(0));
|
|
13
|
+
exports.SharedBuffer = SharedArrayBuffer;
|
|
14
|
+
}
|
|
15
|
+
catch (_) {
|
|
16
|
+
// NOOP
|
|
17
|
+
}
|
|
18
|
+
channel.port1.close();
|
|
19
|
+
channel.port2.close();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
exports.SharedBuffer = SharedArrayBuffer;
|
|
24
|
+
}
|
package/dist/types.js
ADDED
package/lib/AdjacencyList.js
CHANGED
|
@@ -21,13 +21,21 @@ function _nullthrows() {
|
|
|
21
21
|
var _sharedBuffer = require("./shared-buffer");
|
|
22
22
|
var _types = require("./types");
|
|
23
23
|
var _Graph = require("./Graph");
|
|
24
|
-
function _interopRequireDefault(
|
|
24
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
25
25
|
/** The address of the node in the nodes map. */
|
|
26
|
+
|
|
26
27
|
/** The address of the edge in the edges map. */
|
|
28
|
+
|
|
27
29
|
// eslint-disable-next-line no-unused-vars
|
|
30
|
+
|
|
28
31
|
// eslint-disable-next-line no-unused-vars
|
|
32
|
+
|
|
29
33
|
const DEFAULT_PARAMS = {
|
|
30
34
|
initialCapacity: 2,
|
|
35
|
+
// TODO: Find a heuristic for right-sizing nodes.
|
|
36
|
+
// e.g., given an average ratio of `e` edges for every `n` nodes,
|
|
37
|
+
// init nodes with `capacity * n / e`.
|
|
38
|
+
initialNodeCapacity: 2,
|
|
31
39
|
unloadFactor: 0.3,
|
|
32
40
|
maxGrowFactor: 8,
|
|
33
41
|
minGrowFactor: 2,
|
|
@@ -99,7 +107,10 @@ class AdjacencyList {
|
|
|
99
107
|
constructor(opts) {
|
|
100
108
|
let nodes;
|
|
101
109
|
let edges;
|
|
110
|
+
|
|
111
|
+
// @ts-expect-error TS2339
|
|
102
112
|
if (opts !== null && opts !== void 0 && opts.nodes) {
|
|
113
|
+
// @ts-expect-error TS2339
|
|
103
114
|
({
|
|
104
115
|
nodes,
|
|
105
116
|
edges
|
|
@@ -116,13 +127,9 @@ class AdjacencyList {
|
|
|
116
127
|
...opts
|
|
117
128
|
};
|
|
118
129
|
let {
|
|
119
|
-
initialCapacity
|
|
130
|
+
initialCapacity,
|
|
131
|
+
initialNodeCapacity
|
|
120
132
|
} = this.#params;
|
|
121
|
-
|
|
122
|
-
// TODO: Find a heuristic for right-sizing nodes.
|
|
123
|
-
// e.g., given an average ratio of `e` edges for every `n` nodes,
|
|
124
|
-
// init nodes with `capacity * n / e`.
|
|
125
|
-
let initialNodeCapacity = 2;
|
|
126
133
|
NodeTypeMap.assertMaxCapacity(initialNodeCapacity);
|
|
127
134
|
EdgeTypeMap.assertMaxCapacity(initialCapacity);
|
|
128
135
|
this.#nodes = new NodeTypeMap(initialNodeCapacity);
|
|
@@ -152,6 +159,7 @@ class AdjacencyList {
|
|
|
152
159
|
get stats() {
|
|
153
160
|
let edgeTypes = new Set();
|
|
154
161
|
let buckets = new Map();
|
|
162
|
+
// @ts-expect-error TS2488
|
|
155
163
|
for (let {
|
|
156
164
|
from,
|
|
157
165
|
to,
|
|
@@ -224,13 +232,17 @@ class AdjacencyList {
|
|
|
224
232
|
|
|
225
233
|
// Copy the existing edges into the new array.
|
|
226
234
|
nodes.nextId = this.#nodes.nextId;
|
|
227
|
-
this.#edges.forEach(edge => void link(this.#edges.from(edge), this.#edges.to(edge), this.#edges.typeOf(edge),
|
|
235
|
+
this.#edges.forEach(edge => void link(this.#edges.from(edge), this.#edges.to(edge), this.#edges.typeOf(edge),
|
|
236
|
+
// @ts-expect-error TS2345
|
|
237
|
+
edges, nodes, this.#params.unloadFactor));
|
|
228
238
|
|
|
229
239
|
// We expect to preserve the same number of edges.
|
|
230
240
|
(0, _assert().default)(this.#edges.count === edges.count, `Edge mismatch! ${this.#edges.count} does not match ${edges.count}.`);
|
|
231
241
|
|
|
232
242
|
// Finally, copy the new data arrays over to this graph.
|
|
243
|
+
// @ts-expect-error TS2322
|
|
233
244
|
this.#nodes = nodes;
|
|
245
|
+
// @ts-expect-error TS2322
|
|
234
246
|
this.#edges = edges;
|
|
235
247
|
}
|
|
236
248
|
|
|
@@ -599,6 +611,7 @@ class SharedTypeMap {
|
|
|
599
611
|
static #TYPE = 1;
|
|
600
612
|
|
|
601
613
|
/** The largest possible capacity. */
|
|
614
|
+
// @ts-expect-error TS1094
|
|
602
615
|
static get MAX_CAPACITY() {
|
|
603
616
|
return Math.floor(
|
|
604
617
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_array_length#what_went_wrong
|
|
@@ -631,6 +644,7 @@ class SharedTypeMap {
|
|
|
631
644
|
|
|
632
645
|
/** The address of the first item in the map. */
|
|
633
646
|
get addressableLimit() {
|
|
647
|
+
// @ts-expect-error TS2339
|
|
634
648
|
return this.constructor.HEADER_SIZE + this.capacity;
|
|
635
649
|
}
|
|
636
650
|
|
|
@@ -653,7 +667,6 @@ class SharedTypeMap {
|
|
|
653
667
|
BYTES_PER_ELEMENT
|
|
654
668
|
} = Uint32Array;
|
|
655
669
|
let CAPACITY = SharedTypeMap.#CAPACITY;
|
|
656
|
-
// $FlowFixMe[incompatible-call]
|
|
657
670
|
this.data = new Uint32Array(new _sharedBuffer.SharedBuffer(this.getLength(capacityOrData) * BYTES_PER_ELEMENT));
|
|
658
671
|
this.data[CAPACITY] = capacityOrData;
|
|
659
672
|
} else {
|
|
@@ -670,6 +683,7 @@ class SharedTypeMap {
|
|
|
670
683
|
* and is expected to be of equal or smaller capacity to this map.
|
|
671
684
|
*/
|
|
672
685
|
set(data) {
|
|
686
|
+
// @ts-expect-error TS2339
|
|
673
687
|
let {
|
|
674
688
|
HEADER_SIZE,
|
|
675
689
|
ITEM_SIZE
|
|
@@ -720,6 +734,7 @@ class SharedTypeMap {
|
|
|
720
734
|
* get the length of the map, in bytes.
|
|
721
735
|
*/
|
|
722
736
|
getLength(capacity = this.capacity) {
|
|
737
|
+
// @ts-expect-error TS2339
|
|
723
738
|
let {
|
|
724
739
|
HEADER_SIZE,
|
|
725
740
|
ITEM_SIZE
|
|
@@ -729,6 +744,7 @@ class SharedTypeMap {
|
|
|
729
744
|
|
|
730
745
|
/** Get the next available address in the map. */
|
|
731
746
|
getNextAddress() {
|
|
747
|
+
// @ts-expect-error TS2339
|
|
732
748
|
let {
|
|
733
749
|
HEADER_SIZE,
|
|
734
750
|
ITEM_SIZE
|
|
@@ -738,6 +754,7 @@ class SharedTypeMap {
|
|
|
738
754
|
|
|
739
755
|
/** Get the address of the first item with the given hash. */
|
|
740
756
|
head(hash) {
|
|
757
|
+
// @ts-expect-error TS2339
|
|
741
758
|
let {
|
|
742
759
|
HEADER_SIZE
|
|
743
760
|
} = this.constructor;
|
|
@@ -763,6 +780,7 @@ class SharedTypeMap {
|
|
|
763
780
|
let COUNT = SharedTypeMap.#COUNT;
|
|
764
781
|
let NEXT = SharedTypeMap.#NEXT;
|
|
765
782
|
let TYPE = SharedTypeMap.#TYPE;
|
|
783
|
+
// @ts-expect-error TS2339
|
|
766
784
|
let {
|
|
767
785
|
HEADER_SIZE
|
|
768
786
|
} = this.constructor;
|
|
@@ -789,6 +807,7 @@ class SharedTypeMap {
|
|
|
789
807
|
let COUNT = SharedTypeMap.#COUNT;
|
|
790
808
|
let NEXT = SharedTypeMap.#NEXT;
|
|
791
809
|
let TYPE = SharedTypeMap.#TYPE;
|
|
810
|
+
// @ts-expect-error TS2339
|
|
792
811
|
let {
|
|
793
812
|
HEADER_SIZE
|
|
794
813
|
} = this.constructor;
|
|
@@ -801,6 +820,7 @@ class SharedTypeMap {
|
|
|
801
820
|
let candidate = head;
|
|
802
821
|
while (candidate !== null && candidate !== item) {
|
|
803
822
|
prev = candidate;
|
|
823
|
+
// @ts-expect-error TS2322
|
|
804
824
|
candidate = this.next(candidate);
|
|
805
825
|
}
|
|
806
826
|
if (prev !== null && next !== null) {
|
|
@@ -818,6 +838,7 @@ class SharedTypeMap {
|
|
|
818
838
|
forEach(cb) {
|
|
819
839
|
let max = this.count;
|
|
820
840
|
let len = this.length;
|
|
841
|
+
// @ts-expect-error TS2339
|
|
821
842
|
let {
|
|
822
843
|
ITEM_SIZE
|
|
823
844
|
} = this.constructor;
|
|
@@ -834,10 +855,10 @@ class SharedTypeMap {
|
|
|
834
855
|
// See https://github.com/facebook/flow/issues/1163#issuecomment-353523840
|
|
835
856
|
/*:: @@iterator(): Iterator<TAddress> { return ({}: any); } */
|
|
836
857
|
|
|
837
|
-
// $FlowFixMe[unsupported-syntax]
|
|
838
858
|
*[Symbol.iterator]() {
|
|
839
859
|
let max = this.count;
|
|
840
860
|
let len = this.length;
|
|
861
|
+
// @ts-expect-error TS2339
|
|
841
862
|
let {
|
|
842
863
|
ITEM_SIZE
|
|
843
864
|
} = this.constructor;
|
|
@@ -849,6 +870,7 @@ class SharedTypeMap {
|
|
|
849
870
|
}
|
|
850
871
|
}
|
|
851
872
|
inspect() {
|
|
873
|
+
// @ts-expect-error TS2339
|
|
852
874
|
const {
|
|
853
875
|
HEADER_SIZE
|
|
854
876
|
} = this.constructor;
|
|
@@ -1168,6 +1190,7 @@ class EdgeTypeMap extends SharedTypeMap {
|
|
|
1168
1190
|
|
|
1169
1191
|
/** Get the next available address in the map. */
|
|
1170
1192
|
getNextAddress() {
|
|
1193
|
+
// @ts-expect-error TS2339
|
|
1171
1194
|
let {
|
|
1172
1195
|
ITEM_SIZE
|
|
1173
1196
|
} = this.constructor;
|
|
@@ -1359,7 +1382,8 @@ function link(from, to, type, edges, nodes, unloadFactor = DEFAULT_PARAMS.unload
|
|
|
1359
1382
|
// Since the space occupied by deleted edges isn't reclaimed,
|
|
1360
1383
|
// we include them in our count to avoid overflowing the `edges` array.
|
|
1361
1384
|
let deletes = edges.deletes;
|
|
1362
|
-
|
|
1385
|
+
let total = count + deletes;
|
|
1386
|
+
if (edges.getLoad(total) >= 1) {
|
|
1363
1387
|
if (edges.getLoad(deletes) >= unloadFactor && edges.getLoad(count) < unloadFactor) {
|
|
1364
1388
|
// If we have a significant number of deletes, reclaim the space.
|
|
1365
1389
|
return LinkResult.TooManyDeletes;
|
package/lib/BitSet.js
CHANGED
|
@@ -9,7 +9,8 @@ function ctz32(n) {
|
|
|
9
9
|
if (n === 0) {
|
|
10
10
|
return 32;
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
let reversed = n & -n;
|
|
13
|
+
return 31 - Math.clz32(reversed);
|
|
13
14
|
}
|
|
14
15
|
class BitSet {
|
|
15
16
|
constructor(maxBits) {
|
|
@@ -25,17 +26,28 @@ class BitSet {
|
|
|
25
26
|
res.union(b);
|
|
26
27
|
return res;
|
|
27
28
|
}
|
|
29
|
+
static intersect(a, b) {
|
|
30
|
+
let res = a.clone();
|
|
31
|
+
res.intersect(b);
|
|
32
|
+
return res;
|
|
33
|
+
}
|
|
28
34
|
get capacity() {
|
|
29
35
|
return this.bits.length * 32;
|
|
30
36
|
}
|
|
31
37
|
add(bit) {
|
|
32
|
-
|
|
38
|
+
let i = bit >>> 5;
|
|
39
|
+
let b = bit & 31;
|
|
40
|
+
this.bits[i] |= 1 << b;
|
|
33
41
|
}
|
|
34
42
|
delete(bit) {
|
|
35
|
-
|
|
43
|
+
let i = bit >>> 5;
|
|
44
|
+
let b = bit & 31;
|
|
45
|
+
this.bits[i] &= ~(1 << b);
|
|
36
46
|
}
|
|
37
47
|
has(bit) {
|
|
38
|
-
|
|
48
|
+
let i = bit >>> 5;
|
|
49
|
+
let b = bit & 31;
|
|
50
|
+
return Boolean(this.bits[i] & 1 << b);
|
|
39
51
|
}
|
|
40
52
|
empty() {
|
|
41
53
|
for (let k = 0; k < this.bits.length; k++) {
|
|
@@ -63,6 +75,26 @@ class BitSet {
|
|
|
63
75
|
this.bits[i] &= ~other.bits[i];
|
|
64
76
|
}
|
|
65
77
|
}
|
|
78
|
+
size() {
|
|
79
|
+
let bits = this.bits;
|
|
80
|
+
let setBitsCount = 0;
|
|
81
|
+
for (let k = 0; k < bits.length; k++) {
|
|
82
|
+
let chunk = bits[k];
|
|
83
|
+
while (chunk !== 0) {
|
|
84
|
+
chunk &= chunk - 1; // Clear the least significant bit set
|
|
85
|
+
setBitsCount++;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return setBitsCount;
|
|
89
|
+
}
|
|
90
|
+
equals(other) {
|
|
91
|
+
for (let i = 0; i < this.bits.length; i++) {
|
|
92
|
+
if (this.bits[i] !== other.bits[i]) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
66
98
|
forEach(fn) {
|
|
67
99
|
// https://lemire.me/blog/2018/02/21/iterating-over-set-bits-quickly/
|
|
68
100
|
let bits = this.bits;
|
|
@@ -70,7 +102,6 @@ class BitSet {
|
|
|
70
102
|
let v = bits[k];
|
|
71
103
|
while (v !== 0) {
|
|
72
104
|
let t = (v & -v) >>> 0;
|
|
73
|
-
// $FlowFixMe
|
|
74
105
|
fn((k << 5) + ctz32(v));
|
|
75
106
|
v ^= t;
|
|
76
107
|
}
|
package/lib/ContentGraph.js
CHANGED
|
@@ -12,7 +12,7 @@ function _nullthrows() {
|
|
|
12
12
|
};
|
|
13
13
|
return data;
|
|
14
14
|
}
|
|
15
|
-
function _interopRequireDefault(
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
16
|
class ContentGraph extends _Graph.default {
|
|
17
17
|
constructor(opts) {
|
|
18
18
|
if (opts) {
|
|
@@ -30,18 +30,14 @@ class ContentGraph extends _Graph.default {
|
|
|
30
30
|
this._nodeIdToContentKey = new Map();
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
// $FlowFixMe[prop-missing]
|
|
35
33
|
static deserialize(opts) {
|
|
36
34
|
return new ContentGraph(opts);
|
|
37
35
|
}
|
|
38
|
-
|
|
39
|
-
// $FlowFixMe[prop-missing]
|
|
40
36
|
serialize() {
|
|
41
|
-
// $FlowFixMe[prop-missing]
|
|
42
37
|
return {
|
|
43
38
|
...super.serialize(),
|
|
44
39
|
_contentKeyToNodeId: this._contentKeyToNodeId,
|
|
40
|
+
// @ts-expect-error TS2353
|
|
45
41
|
_nodeIdToContentKey: this._nodeIdToContentKey
|
|
46
42
|
};
|
|
47
43
|
}
|
package/lib/Graph.js
CHANGED
|
@@ -15,7 +15,7 @@ function _nullthrows() {
|
|
|
15
15
|
};
|
|
16
16
|
return data;
|
|
17
17
|
}
|
|
18
|
-
function _interopRequireDefault(
|
|
18
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
19
|
const NULL_EDGE_TYPE = exports.NULL_EDGE_TYPE = 1;
|
|
20
20
|
const ALL_EDGE_TYPES = exports.ALL_EDGE_TYPES = -1;
|
|
21
21
|
|
|
@@ -29,13 +29,20 @@ const ALL_EDGE_TYPES = exports.ALL_EDGE_TYPES = -1;
|
|
|
29
29
|
|
|
30
30
|
class Graph {
|
|
31
31
|
constructor(opts) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
let {
|
|
33
|
+
nodes,
|
|
34
|
+
rootNodeId,
|
|
35
|
+
adjacencyList,
|
|
36
|
+
...adjacencyListOpts
|
|
37
|
+
} = opts ?? {};
|
|
38
|
+
this.nodes = nodes ?? [];
|
|
39
|
+
this.setRootNodeId(rootNodeId);
|
|
40
|
+
this.adjacencyList = adjacencyList ? adjacencyList instanceof _AdjacencyList.default ? adjacencyList : _AdjacencyList.default.deserialize(adjacencyList) : new _AdjacencyList.default(adjacencyListOpts);
|
|
41
|
+
if (opts !== null && opts !== void 0 && opts.nodes && !opts.adjacencyList) {
|
|
42
|
+
for (let i = 0; i < this.nodes.length; i++) {
|
|
43
|
+
this.adjacencyList.addNode();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
39
46
|
}
|
|
40
47
|
setRootNodeId(id) {
|
|
41
48
|
this.rootNodeId = id;
|
|
@@ -248,6 +255,7 @@ class Graph {
|
|
|
248
255
|
context: null
|
|
249
256
|
}];
|
|
250
257
|
while (queue.length !== 0) {
|
|
258
|
+
// @ts-expect-error TS2339
|
|
251
259
|
let {
|
|
252
260
|
nodeId,
|
|
253
261
|
context
|
|
@@ -257,7 +265,6 @@ class Graph {
|
|
|
257
265
|
skipped = false;
|
|
258
266
|
let newContext = visit(nodeId, context, actions);
|
|
259
267
|
if (typeof newContext !== 'undefined') {
|
|
260
|
-
// $FlowFixMe[reassign-const]
|
|
261
268
|
context = newContext;
|
|
262
269
|
}
|
|
263
270
|
if (skipped) {
|
|
@@ -324,6 +331,7 @@ class Graph {
|
|
|
324
331
|
}
|
|
325
332
|
}
|
|
326
333
|
this._visited = visited;
|
|
334
|
+
return;
|
|
327
335
|
}
|
|
328
336
|
|
|
329
337
|
/**
|
|
@@ -365,15 +373,18 @@ class Graph {
|
|
|
365
373
|
const enter = typeof visit === 'function' ? visit : visit.enter;
|
|
366
374
|
while (queue.length !== 0) {
|
|
367
375
|
const command = queue.pop();
|
|
376
|
+
|
|
377
|
+
// @ts-expect-error TS18048
|
|
368
378
|
if (command.exit != null) {
|
|
379
|
+
// @ts-expect-error TS2339
|
|
369
380
|
let {
|
|
370
381
|
nodeId,
|
|
371
382
|
context,
|
|
372
383
|
exit
|
|
373
384
|
} = command;
|
|
385
|
+
// @ts-expect-error TS18048
|
|
374
386
|
let newContext = exit(nodeId, command.context, actions);
|
|
375
387
|
if (typeof newContext !== 'undefined') {
|
|
376
|
-
// $FlowFixMe[reassign-const]
|
|
377
388
|
context = newContext;
|
|
378
389
|
}
|
|
379
390
|
if (skipped) {
|
|
@@ -384,6 +395,7 @@ class Graph {
|
|
|
384
395
|
return context;
|
|
385
396
|
}
|
|
386
397
|
} else {
|
|
398
|
+
// @ts-expect-error TS2339
|
|
387
399
|
let {
|
|
388
400
|
nodeId,
|
|
389
401
|
context
|
|
@@ -394,7 +406,6 @@ class Graph {
|
|
|
394
406
|
if (enter) {
|
|
395
407
|
let newContext = enter(nodeId, context, actions);
|
|
396
408
|
if (typeof newContext !== 'undefined') {
|
|
397
|
-
// $FlowFixMe[reassign-const]
|
|
398
409
|
context = newContext;
|
|
399
410
|
}
|
|
400
411
|
}
|
|
@@ -439,6 +450,8 @@ class Graph {
|
|
|
439
450
|
if (stop === true) {
|
|
440
451
|
return node;
|
|
441
452
|
}
|
|
453
|
+
|
|
454
|
+
// @ts-expect-error TS2345
|
|
442
455
|
for (let child of this.getNodeIdsConnectedFrom(node)) {
|
|
443
456
|
if (!visited.has(child)) {
|
|
444
457
|
visited.add(child);
|
|
@@ -506,7 +519,7 @@ class Graph {
|
|
|
506
519
|
exports.default = Graph;
|
|
507
520
|
function mapVisitor(filter, visit) {
|
|
508
521
|
function makeEnter(visit) {
|
|
509
|
-
return function (nodeId, context, actions) {
|
|
522
|
+
return function mappedEnter(nodeId, context, actions) {
|
|
510
523
|
let value = filter(nodeId, actions);
|
|
511
524
|
if (value != null) {
|
|
512
525
|
return visit(value, context, actions);
|
|
@@ -521,7 +534,7 @@ function mapVisitor(filter, visit) {
|
|
|
521
534
|
mapped.enter = makeEnter(visit.enter);
|
|
522
535
|
}
|
|
523
536
|
if (visit.exit != null) {
|
|
524
|
-
mapped.exit = function (nodeId, context, actions) {
|
|
537
|
+
mapped.exit = function mappedExit(nodeId, context, actions) {
|
|
525
538
|
let exit = visit.exit;
|
|
526
539
|
if (!exit) {
|
|
527
540
|
return;
|
package/lib/index.js
CHANGED
|
@@ -49,6 +49,5 @@ var _types = require("./types");
|
|
|
49
49
|
var _Graph = _interopRequireWildcard(require("./Graph"));
|
|
50
50
|
var _ContentGraph = _interopRequireDefault(require("./ContentGraph"));
|
|
51
51
|
var _BitSet = require("./BitSet");
|
|
52
|
-
function _interopRequireDefault(
|
|
53
|
-
function
|
|
54
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
52
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
53
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
package/lib/shared-buffer.js
CHANGED
|
@@ -4,10 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.SharedBuffer = void 0;
|
|
7
|
+
// flow-to-ts helpers
|
|
8
|
+
|
|
9
|
+
// /flow-to-ts helpers
|
|
10
|
+
|
|
7
11
|
// Copy from @atlaspack/utils to fix: https://github.com/stackblitz/core/issues/1855
|
|
8
12
|
let SharedBuffer = exports.SharedBuffer = void 0;
|
|
9
13
|
|
|
10
|
-
//
|
|
14
|
+
// @ts-expect-error TS2339
|
|
11
15
|
if (process.browser) {
|
|
12
16
|
exports.SharedBuffer = SharedBuffer = ArrayBuffer;
|
|
13
17
|
// Safari has removed the constructor
|