@atlaspack/graph 3.4.1-canary.26 → 3.4.1-canary.261
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 +201 -0
- package/benchmark/BitSet.js +37 -0
- package/lib/AdjacencyList.js +28 -4
- package/lib/BitSet.js +36 -5
- package/lib/ContentGraph.js +1 -5
- package/lib/Graph.js +11 -5
- package/lib/shared-buffer.js +5 -1
- package/lib/types/AdjacencyList.d.ts +607 -0
- package/lib/types/BitSet.d.ts +19 -0
- package/lib/types/ContentGraph.d.ts +23 -0
- package/lib/types/Graph.d.ts +91 -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 +17 -6
- package/src/{AdjacencyList.js → AdjacencyList.ts} +127 -101
- package/src/{BitSet.js → BitSet.ts} +31 -3
- package/src/{ContentGraph.js → ContentGraph.ts} +21 -20
- package/src/{Graph.js → Graph.ts} +89 -66
- 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 +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,206 @@
|
|
|
1
1
|
# @atlaspack/graph
|
|
2
2
|
|
|
3
|
+
## 3.5.19
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`7a52bab`](https://github.com/atlassian-labs/atlaspack/commit/7a52bab6281e8edbfa66af248eb6f872c6b4b7bd), [`eedcbc4`](https://github.com/atlassian-labs/atlaspack/commit/eedcbc408fc1e86a2a8e25f1a41c57146d8529e1), [`038e87a`](https://github.com/atlassian-labs/atlaspack/commit/038e87a7858d39556d59d3a2d17db534d45f62c6), [`f6532d7`](https://github.com/atlassian-labs/atlaspack/commit/f6532d7a4f7f007bd4e5e36af04dd466f0b9f572), [`602f8ed`](https://github.com/atlassian-labs/atlaspack/commit/602f8ed9d8381301df8b2cc82c1d5cf6f2f94fec)]:
|
|
8
|
+
- @atlaspack/feature-flags@2.25.0
|
|
9
|
+
- @atlaspack/types-internal@2.20.0
|
|
10
|
+
|
|
11
|
+
## 3.5.18
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [[`830261d`](https://github.com/atlassian-labs/atlaspack/commit/830261dcf4a40293090b61cab52fd75d5683c73f)]:
|
|
16
|
+
- @atlaspack/feature-flags@2.24.1
|
|
17
|
+
- @atlaspack/types-internal@2.19.5
|
|
18
|
+
|
|
19
|
+
## 3.5.17
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [[`f0349a6`](https://github.com/atlassian-labs/atlaspack/commit/f0349a6b9b04755088f121095ca6301a2ada3767), [`a5081c3`](https://github.com/atlassian-labs/atlaspack/commit/a5081c3f9207d28716ee4edd3841de1830ea4b80), [`f930003`](https://github.com/atlassian-labs/atlaspack/commit/f930003364fdc31e5487520ebe256f1a9389f579), [`f930003`](https://github.com/atlassian-labs/atlaspack/commit/f930003364fdc31e5487520ebe256f1a9389f579), [`8843980`](https://github.com/atlassian-labs/atlaspack/commit/88439807be20025fd3433380204ff1205079729e)]:
|
|
24
|
+
- @atlaspack/feature-flags@2.24.0
|
|
25
|
+
- @atlaspack/types-internal@2.19.4
|
|
26
|
+
|
|
27
|
+
## 3.5.16
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- Updated dependencies [[`3cfb7cf`](https://github.com/atlassian-labs/atlaspack/commit/3cfb7cfd90b78a5c48ce717e779ff789769825a3)]:
|
|
32
|
+
- @atlaspack/feature-flags@2.23.2
|
|
33
|
+
- @atlaspack/types-internal@2.19.3
|
|
34
|
+
|
|
35
|
+
## 3.5.15
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- [#742](https://github.com/atlassian-labs/atlaspack/pull/742) [`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd) Thanks [@yamadapc](https://github.com/yamadapc)! - Internal changes and bug fixes to environmentDeduplication flag
|
|
40
|
+
|
|
41
|
+
- Updated dependencies [[`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd)]:
|
|
42
|
+
- @atlaspack/types-internal@2.19.2
|
|
43
|
+
- @atlaspack/feature-flags@2.23.1
|
|
44
|
+
|
|
45
|
+
## 3.5.14
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- Updated dependencies [[`f6b3f22`](https://github.com/atlassian-labs/atlaspack/commit/f6b3f2276c7e417580b49c4879563aab51f156b1)]:
|
|
50
|
+
- @atlaspack/feature-flags@2.23.0
|
|
51
|
+
- @atlaspack/types-internal@2.19.1
|
|
52
|
+
|
|
53
|
+
## 3.5.13
|
|
54
|
+
|
|
55
|
+
### Patch Changes
|
|
56
|
+
|
|
57
|
+
- Updated dependencies [[`7f5841c`](https://github.com/atlassian-labs/atlaspack/commit/7f5841c39df049f9546cccbeea2a7337e0337b45), [`73dd7ba`](https://github.com/atlassian-labs/atlaspack/commit/73dd7baab69456ef2f6e4a0cc7dbb04f407eb148)]:
|
|
58
|
+
- @atlaspack/types-internal@2.19.0
|
|
59
|
+
- @atlaspack/feature-flags@2.22.0
|
|
60
|
+
|
|
61
|
+
## 3.5.12
|
|
62
|
+
|
|
63
|
+
### Patch Changes
|
|
64
|
+
|
|
65
|
+
- Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
|
|
66
|
+
- @atlaspack/feature-flags@2.21.0
|
|
67
|
+
|
|
68
|
+
## 3.5.11
|
|
69
|
+
|
|
70
|
+
### Patch Changes
|
|
71
|
+
|
|
72
|
+
- [#720](https://github.com/atlassian-labs/atlaspack/pull/720) [`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94) Thanks [@alshdavid](https://github.com/alshdavid)! - Migrate to TypeScript
|
|
73
|
+
|
|
74
|
+
- Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94), [`12bee0e`](https://github.com/atlassian-labs/atlaspack/commit/12bee0e23f0464d7f6bd3e24fbe0d19c126d587d)]:
|
|
75
|
+
- @atlaspack/feature-flags@2.20.1
|
|
76
|
+
|
|
77
|
+
## 3.5.10
|
|
78
|
+
|
|
79
|
+
### Patch Changes
|
|
80
|
+
|
|
81
|
+
- Updated dependencies [[`069de47`](https://github.com/atlassian-labs/atlaspack/commit/069de478e64fb5889f6f2ce023eb510782767fbd)]:
|
|
82
|
+
- @atlaspack/feature-flags@2.20.0
|
|
83
|
+
|
|
84
|
+
## 3.5.9
|
|
85
|
+
|
|
86
|
+
### Patch Changes
|
|
87
|
+
|
|
88
|
+
- Updated dependencies [[`1c7865a`](https://github.com/atlassian-labs/atlaspack/commit/1c7865a64451116d94015e248302435839d347c0), [`a0b959f`](https://github.com/atlassian-labs/atlaspack/commit/a0b959fbf61fc3f820ff03c7e8988945fe40a91a)]:
|
|
89
|
+
- @atlaspack/feature-flags@2.19.2
|
|
90
|
+
|
|
91
|
+
## 3.5.8
|
|
92
|
+
|
|
93
|
+
### Patch Changes
|
|
94
|
+
|
|
95
|
+
- Updated dependencies [[`13aef17`](https://github.com/atlassian-labs/atlaspack/commit/13aef177eea289a6e40d2113b5ec1ac9be18a33d)]:
|
|
96
|
+
- @atlaspack/feature-flags@2.19.1
|
|
97
|
+
|
|
98
|
+
## 3.5.7
|
|
99
|
+
|
|
100
|
+
### Patch Changes
|
|
101
|
+
|
|
102
|
+
- Updated dependencies [[`dbb4072`](https://github.com/atlassian-labs/atlaspack/commit/dbb40721ebeb45990a14ba04e6b44e7f836fb32d), [`becf977`](https://github.com/atlassian-labs/atlaspack/commit/becf977f625d5ee46dae3d4c679f173bf5f40cc0), [`c4415a4`](https://github.com/atlassian-labs/atlaspack/commit/c4415a455543d984ca28452c2cb87a794d22497c), [`f0f7c71`](https://github.com/atlassian-labs/atlaspack/commit/f0f7c7168a1d3d18c6f30d2daed611275692b7c5), [`18a57cf`](https://github.com/atlassian-labs/atlaspack/commit/18a57cf8a4789b2de5ad8e2676f317a26cc91417)]:
|
|
103
|
+
- @atlaspack/feature-flags@2.19.0
|
|
104
|
+
|
|
105
|
+
## 3.5.6
|
|
106
|
+
|
|
107
|
+
### Patch Changes
|
|
108
|
+
|
|
109
|
+
- Updated dependencies [[`e8a60ff`](https://github.com/atlassian-labs/atlaspack/commit/e8a60ffbea41caef265786bbf73349771760081c)]:
|
|
110
|
+
- @atlaspack/feature-flags@2.18.4
|
|
111
|
+
|
|
112
|
+
## 3.5.5
|
|
113
|
+
|
|
114
|
+
### Patch Changes
|
|
115
|
+
|
|
116
|
+
- Updated dependencies [[`5ded263`](https://github.com/atlassian-labs/atlaspack/commit/5ded263c7f11b866e8885b81c73e20dd060b25be)]:
|
|
117
|
+
- @atlaspack/feature-flags@2.18.3
|
|
118
|
+
|
|
119
|
+
## 3.5.4
|
|
120
|
+
|
|
121
|
+
### Patch Changes
|
|
122
|
+
|
|
123
|
+
- Updated dependencies [[`644b157`](https://github.com/atlassian-labs/atlaspack/commit/644b157dee72a871acc2d0facf0b87b8eea51956)]:
|
|
124
|
+
- @atlaspack/feature-flags@2.18.2
|
|
125
|
+
|
|
126
|
+
## 3.5.3
|
|
127
|
+
|
|
128
|
+
### Patch Changes
|
|
129
|
+
|
|
130
|
+
- Updated dependencies [[`26aa9c5`](https://github.com/atlassian-labs/atlaspack/commit/26aa9c599d2be45ce1438a74c5fa22f39b9b554b), [`0501255`](https://github.com/atlassian-labs/atlaspack/commit/05012550da35b05ce7d356a8cc29311e7f9afdca)]:
|
|
131
|
+
- @atlaspack/feature-flags@2.18.1
|
|
132
|
+
|
|
133
|
+
## 3.5.2
|
|
134
|
+
|
|
135
|
+
### Patch Changes
|
|
136
|
+
|
|
137
|
+
- Updated dependencies [[`10fbcfb`](https://github.com/atlassian-labs/atlaspack/commit/10fbcfbfa49c7a83da5d7c40983e36e87f524a75), [`85c52d3`](https://github.com/atlassian-labs/atlaspack/commit/85c52d3f7717b3c84a118d18ab98cfbfd71dcbd2)]:
|
|
138
|
+
- @atlaspack/feature-flags@2.18.0
|
|
139
|
+
|
|
140
|
+
## 3.5.1
|
|
141
|
+
|
|
142
|
+
### Patch Changes
|
|
143
|
+
|
|
144
|
+
- Updated dependencies [[`73ea3c4`](https://github.com/atlassian-labs/atlaspack/commit/73ea3c4d85d4401fdd15abcbf988237e890e7ad3), [`b1b3693`](https://github.com/atlassian-labs/atlaspack/commit/b1b369317c66f8a431c170df2ebba4fa5b2e38ef)]:
|
|
145
|
+
- @atlaspack/feature-flags@2.17.0
|
|
146
|
+
|
|
147
|
+
## 3.5.0
|
|
148
|
+
|
|
149
|
+
### Minor Changes
|
|
150
|
+
|
|
151
|
+
- [#600](https://github.com/atlassian-labs/atlaspack/pull/600) [`1b52b99`](https://github.com/atlassian-labs/atlaspack/commit/1b52b99db4298b04c1a6eb0f97994d75a2d436f9) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Add static intersect, size and equals methods to BitSet
|
|
152
|
+
|
|
153
|
+
## 3.4.7
|
|
154
|
+
|
|
155
|
+
### Patch Changes
|
|
156
|
+
|
|
157
|
+
- Updated dependencies [[`209692f`](https://github.com/atlassian-labs/atlaspack/commit/209692ffb11eae103a0d65c5e1118a5aa1625818), [`f4da1e1`](https://github.com/atlassian-labs/atlaspack/commit/f4da1e120e73eeb5e8b8927f05e88f04d6148c7b)]:
|
|
158
|
+
- @atlaspack/feature-flags@2.16.0
|
|
159
|
+
|
|
160
|
+
## 3.4.6
|
|
161
|
+
|
|
162
|
+
### Patch Changes
|
|
163
|
+
|
|
164
|
+
- Updated dependencies [[`30f6017`](https://github.com/atlassian-labs/atlaspack/commit/30f60175ba4d272c5fc193973c63bc298584775b)]:
|
|
165
|
+
- @atlaspack/feature-flags@2.15.1
|
|
166
|
+
|
|
167
|
+
## 3.4.5
|
|
168
|
+
|
|
169
|
+
### Patch Changes
|
|
170
|
+
|
|
171
|
+
- Updated dependencies [[`a1773d2`](https://github.com/atlassian-labs/atlaspack/commit/a1773d2a62d0ef7805ac7524621dcabcc1afe929)]:
|
|
172
|
+
- @atlaspack/feature-flags@2.15.0
|
|
173
|
+
|
|
174
|
+
## 3.4.4
|
|
175
|
+
|
|
176
|
+
### Patch Changes
|
|
177
|
+
|
|
178
|
+
- Updated dependencies [[`e0f5337`](https://github.com/atlassian-labs/atlaspack/commit/e0f533757bd1019dbd108a04952c87da15286e09)]:
|
|
179
|
+
- @atlaspack/feature-flags@2.14.4
|
|
180
|
+
|
|
181
|
+
## 3.4.3
|
|
182
|
+
|
|
183
|
+
### Patch Changes
|
|
184
|
+
|
|
185
|
+
- Updated dependencies [[`11d6f16`](https://github.com/atlassian-labs/atlaspack/commit/11d6f16b6397dee2f217167e5c98b39edb63f7a7)]:
|
|
186
|
+
- @atlaspack/feature-flags@2.14.3
|
|
187
|
+
|
|
188
|
+
## 3.4.2
|
|
189
|
+
|
|
190
|
+
### Patch Changes
|
|
191
|
+
|
|
192
|
+
- Updated dependencies [[`9b85d3e`](https://github.com/atlassian-labs/atlaspack/commit/9b85d3e645b10bd027eed2304afc970a5ba40062), [`17b9579`](https://github.com/atlassian-labs/atlaspack/commit/17b9579484eced0ed8f23e2aba6d23b3c7238c39), [`8f4e6c1`](https://github.com/atlassian-labs/atlaspack/commit/8f4e6c1b0e7c1fd48624afda48c1dcc599f1460f)]:
|
|
193
|
+
- @atlaspack/feature-flags@2.14.2
|
|
194
|
+
|
|
195
|
+
## 3.4.1
|
|
196
|
+
|
|
197
|
+
### Patch Changes
|
|
198
|
+
|
|
199
|
+
- [#478](https://github.com/atlassian-labs/atlaspack/pull/478) [`570493b`](https://github.com/atlassian-labs/atlaspack/commit/570493beaf754e7985aebc7daaaf6dfcfa8fe56b) Thanks [@yamadapc](https://github.com/yamadapc)! - The first attempt at Version Packages didn't include the built artifacts.
|
|
200
|
+
This has hopefully been fixed, so this change will force those packages to re-release.
|
|
201
|
+
- Updated dependencies [[`4aab060`](https://github.com/atlassian-labs/atlaspack/commit/4aab0605c0d4ee8e0dcc3ffa1162eae5b360b677), [`e1422ad`](https://github.com/atlassian-labs/atlaspack/commit/e1422ad0a801faaa4bc4f1023bed042ffe236e9b), [`570493b`](https://github.com/atlassian-labs/atlaspack/commit/570493beaf754e7985aebc7daaaf6dfcfa8fe56b)]:
|
|
202
|
+
- @atlaspack/feature-flags@2.14.1
|
|
203
|
+
|
|
3
204
|
## 3.4.0
|
|
4
205
|
|
|
5
206
|
### Minor Changes
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* BitSets are primarily used for performance reasons, so we want to be able to
|
|
3
|
+
* validate that changes we make to it are performace improvements.
|
|
4
|
+
*
|
|
5
|
+
* This file exists as a ready-made playground for benchmarking changes you may
|
|
6
|
+
* want to make to the BitSet implementation.
|
|
7
|
+
*
|
|
8
|
+
* Run with `yarn workspace @atlaspack/graph benchmark` from the root
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// Needed to make Flow work in the benchmarks
|
|
12
|
+
require('@atlaspack/babel-register');
|
|
13
|
+
|
|
14
|
+
const {BitSet} = require('../src/BitSet.js');
|
|
15
|
+
const b = require('benny');
|
|
16
|
+
|
|
17
|
+
function createBitSetWithEntries(capacity, entries) {
|
|
18
|
+
let bitSet = new BitSet(capacity);
|
|
19
|
+
for (const index of entries) {
|
|
20
|
+
bitSet.add(index);
|
|
21
|
+
}
|
|
22
|
+
return bitSet;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let bundleIndices = [4334, 348, 2145, 480, 747, 1446, 326, 2791, 2658, 1334];
|
|
26
|
+
|
|
27
|
+
let bundleBitSet = createBitSetWithEntries(5000, bundleIndices);
|
|
28
|
+
|
|
29
|
+
b.suite(
|
|
30
|
+
'BitSet - size',
|
|
31
|
+
b.add('Control', () => {
|
|
32
|
+
bundleBitSet.size();
|
|
33
|
+
}),
|
|
34
|
+
b.configure({minSamples: 100}),
|
|
35
|
+
b.cycle(),
|
|
36
|
+
b.complete(),
|
|
37
|
+
);
|
package/lib/AdjacencyList.js
CHANGED
|
@@ -23,9 +23,13 @@ var _types = require("./types");
|
|
|
23
23
|
var _Graph = require("./Graph");
|
|
24
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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,
|
|
31
35
|
unloadFactor: 0.3,
|
|
@@ -99,7 +103,10 @@ class AdjacencyList {
|
|
|
99
103
|
constructor(opts) {
|
|
100
104
|
let nodes;
|
|
101
105
|
let edges;
|
|
106
|
+
|
|
107
|
+
// @ts-expect-error TS2339
|
|
102
108
|
if (opts !== null && opts !== void 0 && opts.nodes) {
|
|
109
|
+
// @ts-expect-error TS2339
|
|
103
110
|
({
|
|
104
111
|
nodes,
|
|
105
112
|
edges
|
|
@@ -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
|
@@ -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
|
@@ -248,6 +248,7 @@ class Graph {
|
|
|
248
248
|
context: null
|
|
249
249
|
}];
|
|
250
250
|
while (queue.length !== 0) {
|
|
251
|
+
// @ts-expect-error TS2339
|
|
251
252
|
let {
|
|
252
253
|
nodeId,
|
|
253
254
|
context
|
|
@@ -257,7 +258,6 @@ class Graph {
|
|
|
257
258
|
skipped = false;
|
|
258
259
|
let newContext = visit(nodeId, context, actions);
|
|
259
260
|
if (typeof newContext !== 'undefined') {
|
|
260
|
-
// $FlowFixMe[reassign-const]
|
|
261
261
|
context = newContext;
|
|
262
262
|
}
|
|
263
263
|
if (skipped) {
|
|
@@ -324,6 +324,7 @@ class Graph {
|
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
326
|
this._visited = visited;
|
|
327
|
+
return;
|
|
327
328
|
}
|
|
328
329
|
|
|
329
330
|
/**
|
|
@@ -365,15 +366,18 @@ class Graph {
|
|
|
365
366
|
const enter = typeof visit === 'function' ? visit : visit.enter;
|
|
366
367
|
while (queue.length !== 0) {
|
|
367
368
|
const command = queue.pop();
|
|
369
|
+
|
|
370
|
+
// @ts-expect-error TS18048
|
|
368
371
|
if (command.exit != null) {
|
|
372
|
+
// @ts-expect-error TS2339
|
|
369
373
|
let {
|
|
370
374
|
nodeId,
|
|
371
375
|
context,
|
|
372
376
|
exit
|
|
373
377
|
} = command;
|
|
378
|
+
// @ts-expect-error TS18048
|
|
374
379
|
let newContext = exit(nodeId, command.context, actions);
|
|
375
380
|
if (typeof newContext !== 'undefined') {
|
|
376
|
-
// $FlowFixMe[reassign-const]
|
|
377
381
|
context = newContext;
|
|
378
382
|
}
|
|
379
383
|
if (skipped) {
|
|
@@ -384,6 +388,7 @@ class Graph {
|
|
|
384
388
|
return context;
|
|
385
389
|
}
|
|
386
390
|
} else {
|
|
391
|
+
// @ts-expect-error TS2339
|
|
387
392
|
let {
|
|
388
393
|
nodeId,
|
|
389
394
|
context
|
|
@@ -394,7 +399,6 @@ class Graph {
|
|
|
394
399
|
if (enter) {
|
|
395
400
|
let newContext = enter(nodeId, context, actions);
|
|
396
401
|
if (typeof newContext !== 'undefined') {
|
|
397
|
-
// $FlowFixMe[reassign-const]
|
|
398
402
|
context = newContext;
|
|
399
403
|
}
|
|
400
404
|
}
|
|
@@ -439,6 +443,8 @@ class Graph {
|
|
|
439
443
|
if (stop === true) {
|
|
440
444
|
return node;
|
|
441
445
|
}
|
|
446
|
+
|
|
447
|
+
// @ts-expect-error TS2345
|
|
442
448
|
for (let child of this.getNodeIdsConnectedFrom(node)) {
|
|
443
449
|
if (!visited.has(child)) {
|
|
444
450
|
visited.add(child);
|
|
@@ -506,7 +512,7 @@ class Graph {
|
|
|
506
512
|
exports.default = Graph;
|
|
507
513
|
function mapVisitor(filter, visit) {
|
|
508
514
|
function makeEnter(visit) {
|
|
509
|
-
return function (nodeId, context, actions) {
|
|
515
|
+
return function mappedEnter(nodeId, context, actions) {
|
|
510
516
|
let value = filter(nodeId, actions);
|
|
511
517
|
if (value != null) {
|
|
512
518
|
return visit(value, context, actions);
|
|
@@ -521,7 +527,7 @@ function mapVisitor(filter, visit) {
|
|
|
521
527
|
mapped.enter = makeEnter(visit.enter);
|
|
522
528
|
}
|
|
523
529
|
if (visit.exit != null) {
|
|
524
|
-
mapped.exit = function (nodeId, context, actions) {
|
|
530
|
+
mapped.exit = function mappedExit(nodeId, context, actions) {
|
|
525
531
|
let exit = visit.exit;
|
|
526
532
|
if (!exit) {
|
|
527
533
|
return;
|
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
|