@daneren2005/shared-memory-objects 0.0.21 → 1.1.0

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.
Files changed (59) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +167 -167
  3. package/dist/allocated-memory.js +38 -0
  4. package/dist/allocated-memory.js.map +1 -0
  5. package/dist/cached-item-list.js +76 -0
  6. package/dist/cached-item-list.js.map +1 -0
  7. package/dist/interfaces/pow2.js +2 -0
  8. package/dist/interfaces/pow2.js.map +1 -0
  9. package/dist/interfaces/typed-array-constructor.js +2 -0
  10. package/dist/interfaces/typed-array-constructor.js.map +1 -0
  11. package/dist/interfaces/typed-array.js +2 -0
  12. package/dist/interfaces/typed-array.js.map +1 -0
  13. package/dist/local-pool.js +95 -0
  14. package/dist/local-pool.js.map +1 -0
  15. package/dist/lock/read-write-lock.js +25 -0
  16. package/dist/lock/read-write-lock.js.map +1 -0
  17. package/dist/lock/simple-lock.js +14 -0
  18. package/dist/lock/simple-lock.js.map +1 -0
  19. package/dist/memory-buffer.js +327 -0
  20. package/dist/memory-buffer.js.map +1 -0
  21. package/dist/memory-heap.js +116 -0
  22. package/dist/memory-heap.js.map +1 -0
  23. package/dist/serialize-object.js +59 -0
  24. package/dist/serialize-object.js.map +1 -0
  25. package/dist/shared-list.js +165 -0
  26. package/dist/shared-list.js.map +1 -0
  27. package/dist/shared-map.js +140 -0
  28. package/dist/shared-map.js.map +1 -0
  29. package/dist/shared-pointer-list.js +50 -0
  30. package/dist/shared-pointer-list.js.map +1 -0
  31. package/dist/shared-pool.js +165 -0
  32. package/dist/shared-pool.js.map +1 -0
  33. package/dist/shared-string.js +79 -0
  34. package/dist/shared-string.js.map +1 -0
  35. package/dist/shared-vector.js +165 -0
  36. package/dist/shared-vector.js.map +1 -0
  37. package/dist/src/memory-heap.d.ts +0 -1
  38. package/dist/src/utils/atomic-math.d.ts +4 -4
  39. package/dist/src/utils/typedarray.d.ts +278 -278
  40. package/dist/utils/16-from-32-array.js +20 -0
  41. package/dist/utils/16-from-32-array.js.map +1 -0
  42. package/dist/utils/16-from-64-array.js +12 -0
  43. package/dist/utils/16-from-64-array.js.map +1 -0
  44. package/dist/utils/atomic-math.js +36 -0
  45. package/dist/utils/atomic-math.js.map +1 -0
  46. package/dist/utils/float32-atomics.js +28 -0
  47. package/dist/utils/float32-atomics.js.map +1 -0
  48. package/dist/utils/float64-atomics.js +28 -0
  49. package/dist/utils/float64-atomics.js.map +1 -0
  50. package/dist/utils/pointer.js +44 -0
  51. package/dist/utils/pointer.js.map +1 -0
  52. package/dist/utils/typedarray.js +46 -0
  53. package/dist/utils/typedarray.js.map +1 -0
  54. package/package.json +65 -72
  55. package/dist/shared-memory-objects.js +0 -1674
  56. package/dist/shared-memory-objects.js.map +0 -1
  57. package/dist/shared-memory-objects.umd.cjs +0 -2
  58. package/dist/shared-memory-objects.umd.cjs.map +0 -1
  59. package/dist/src/main.d.ts +0 -22
@@ -1,1674 +0,0 @@
1
- const he = 20, ce = 12, et = Math.pow(2, 20), rt = Math.pow(2, 12);
2
- function c(i, t = 0) {
3
- return B(Atomics.load(i, t));
4
- }
5
- function O(i, t = 0) {
6
- return Atomics.load(i, t);
7
- }
8
- function k(i, t = 0, e, r) {
9
- Atomics.store(i, t, L(e, r));
10
- }
11
- function x(i, t = 0, e) {
12
- Atomics.store(i, t, e);
13
- }
14
- function ue(i, t, e, r, s, o) {
15
- let a = L(s, o);
16
- return Atomics.compareExchange(i, t, a, L(e, r)) === a;
17
- }
18
- function V(i, t, e, r) {
19
- return Atomics.compareExchange(i, t, r, e) === r;
20
- }
21
- function B(i) {
22
- return {
23
- bufferPosition: i & 4095,
24
- bufferByteOffset: i >>> 12
25
- };
26
- }
27
- function L(i, t) {
28
- return i + (t << 12);
29
- }
30
- class h {
31
- memory;
32
- bufferPosition;
33
- get bufferByteOffset() {
34
- return this.data.byteOffset;
35
- }
36
- get pointer() {
37
- return L(this.bufferPosition, this.bufferByteOffset);
38
- }
39
- buffer;
40
- data;
41
- constructor(t, e) {
42
- this.memory = t, "buffer" in e ? (this.data = e.data, this.buffer = e.buffer, this.bufferPosition = this.memory.buffers.indexOf(e.buffer)) : (this.bufferPosition = e.bufferPosition, this.buffer = t.buffers[e.bufferPosition], this.data = new Uint32Array(this.buffer.buf, e.bufferByteOffset));
43
- }
44
- getArray(t, e, r) {
45
- return new t(this.data.buffer, this.data.byteOffset + e * t.BYTES_PER_ELEMENT, r);
46
- }
47
- getArrayMemory(t, e) {
48
- return {
49
- bufferPosition: this.bufferPosition,
50
- bufferByteOffset: this.bufferByteOffset + t * this.data.BYTES_PER_ELEMENT
51
- };
52
- }
53
- free() {
54
- this.buffer.free(this.data.byteOffset);
55
- }
56
- getSharedMemory() {
57
- return {
58
- bufferPosition: this.bufferPosition,
59
- bufferByteOffset: this.bufferByteOffset
60
- };
61
- }
62
- }
63
- const j = 0, F = 1;
64
- function z(i, t = 0) {
65
- for (; Atomics.compareExchange(i, t, j, F) !== j; )
66
- "WorkerGlobalScope" in self && Atomics.wait(i, t, F);
67
- }
68
- function g(i, t = 0) {
69
- Atomics.compareExchange(i, t, F, j) !== F && console.warn("We are unlocking when it was not locked!"), Atomics.notify(i, t);
70
- }
71
- const de = 1, Vt = {
72
- 5120: "i8",
73
- 5121: "u8",
74
- 5122: "i16",
75
- 5123: "u16",
76
- 5124: "i32",
77
- 5125: "u32",
78
- 5126: "f32"
79
- }, Kt = {
80
- f32: Float32Array,
81
- f64: Float64Array
82
- }, Gt = {
83
- i8: Int8Array,
84
- i16: Int16Array,
85
- i32: Int32Array
86
- }, Xt = {
87
- u8: Uint8Array,
88
- u8c: Uint8ClampedArray,
89
- u16: Uint16Array,
90
- u32: Uint32Array
91
- }, Zt = {
92
- i64: BigInt64Array,
93
- u64: BigUint64Array
94
- }, Wt = {
95
- ...Kt,
96
- ...Gt,
97
- ...Xt
98
- }, vt = (i) => {
99
- const t = Vt[i];
100
- return t !== void 0 ? t : i;
101
- };
102
- function jt(i, ...t) {
103
- const e = Zt[i];
104
- return new (e || Wt[vt(i)])(...t);
105
- }
106
- const it = 0, st = 1, ot = 2, at = 3, nt = 4, A = 5, lt = 6, K = 1, G = 2, ft = 32, X = 0, Z = 1, y = 8;
107
- class W {
108
- buf;
109
- start;
110
- u8;
111
- u32;
112
- state;
113
- lock;
114
- constructor(t = {}) {
115
- if (this.buf = t.buf ? t.buf : new ArrayBuffer(t.size || 4096), this.start = t.start != null ? I(Math.max(t.start, 0), 4) : 0, this.u8 = new Uint8Array(this.buf), this.u32 = new Uint32Array(this.buf), this.state = new Uint32Array(this.buf, this.start, ft / 4), this.lock = new Int32Array(this.buf, this.start + this.state.byteLength - 4, 1), !t.skipInitialization) {
116
- const e = t.align || 8;
117
- if (e < 8)
118
- throw new Error(`invalid alignment: ${e}, must be a pow2 and >= 8`);
119
- const r = this.initialTop(e), s = t.end != null ? Math.min(t.end, this.buf.byteLength) : this.buf.byteLength;
120
- if (r >= s)
121
- throw new Error(
122
- `insufficient address range (0x${this.start.toString(
123
- 16
124
- )} - 0x${s.toString(16)})`
125
- );
126
- this.align = e, this.doCompact = t.compact !== !1, this.doSplit = t.split !== !1, this.minSplit = t.minSplit || 16, this.end = s, this.top = r, this._free = 0, this._used = 0;
127
- }
128
- }
129
- stats() {
130
- const t = (r) => {
131
- let s = 0, o = 0;
132
- for (; r; )
133
- if (s++, o += this.blockSize(r), r = this.blockNext(r), r > this.end) {
134
- console.error(`Trying to get stats for block past end of buffer: ${r} > ${this.end}`);
135
- break;
136
- }
137
- return { count: s, size: o };
138
- }, e = t(this._free);
139
- return {
140
- free: e,
141
- used: t(this._used),
142
- top: this.top,
143
- available: this.end - this.top + e.size,
144
- total: this.buf.byteLength
145
- };
146
- }
147
- callocAs(t, e, r = 0) {
148
- const s = this.mallocAs(t, e);
149
- return s && s.fill(r), s;
150
- }
151
- mallocAs(t, e) {
152
- const r = this.malloc(e * qt[t]);
153
- return r ? jt(t, this.buf, r, e) : void 0;
154
- }
155
- calloc(t, e = 0) {
156
- const r = this.malloc(t);
157
- return r && this.u8.fill(e, r, r + t), r;
158
- }
159
- malloc(t) {
160
- if (t <= 0)
161
- return 0;
162
- z(this.lock);
163
- const e = I(t + y, this.align), r = this.end;
164
- let s = this.top, o = this._free, a = 0;
165
- for (; o; ) {
166
- const l = this.blockSize(o), n = o + l >= s;
167
- if (n || l >= e) {
168
- let f = this.mallocTop(
169
- o,
170
- a,
171
- l,
172
- e,
173
- n
174
- );
175
- return g(this.lock), f;
176
- }
177
- a = o, o = this.blockNext(o);
178
- }
179
- if (o = s, s = o + e, s <= r) {
180
- this.initBlock(o, e, this._used), this._used = o, this.top = s;
181
- let l = _(o);
182
- return g(this.lock), l;
183
- }
184
- return g(this.lock), 0;
185
- }
186
- mallocTop(t, e, r, s, o) {
187
- if (o && t + s > this.end) return 0;
188
- if (e ? this.unlinkBlock(e, t) : this._free = this.blockNext(t), this.setBlockNext(t, this._used), this._used = t, o)
189
- this.top = t + this.setBlockSize(t, s);
190
- else if (this.doSplit) {
191
- const a = r - s;
192
- a >= this.minSplit && this.splitBlock(t, s, a);
193
- }
194
- return _(t);
195
- }
196
- realloc(t, e) {
197
- if (e <= 0)
198
- return 0;
199
- const r = C(t);
200
- let s = 0, o = this._used, a = 0;
201
- for (; o; ) {
202
- if (o === r) {
203
- [s, a] = this.reallocBlock(o, e);
204
- break;
205
- }
206
- o = this.blockNext(o);
207
- }
208
- return s && s !== r && this.u8.copyWithin(
209
- _(s),
210
- _(r),
211
- a
212
- ), _(s);
213
- }
214
- reallocBlock(t, e) {
215
- const r = this.blockSize(t), s = t + r, o = s >= this.top, a = I(e + y, this.align);
216
- if (a <= r) {
217
- if (this.doSplit) {
218
- const l = r - a;
219
- l >= this.minSplit ? this.splitBlock(t, a, l) : o && (this.top = t + a);
220
- } else o && (this.top = t + a);
221
- return [t, s];
222
- }
223
- return o && t + a < this.end ? (this.top = t + this.setBlockSize(t, a), [t, s]) : (this.free(t), [C(this.malloc(e)), s]);
224
- }
225
- reallocArray(t, e) {
226
- if (t.buffer !== this.buf)
227
- return;
228
- const r = this.realloc(
229
- t.byteOffset,
230
- e * t.BYTES_PER_ELEMENT
231
- );
232
- return r ? new t.constructor(this.buf, r, e) : void 0;
233
- }
234
- bytesFor(t) {
235
- let e;
236
- if (typeof t != "number") {
237
- if (t.buffer !== this.buf)
238
- return;
239
- e = t.byteOffset;
240
- } else
241
- e = t;
242
- e = C(e);
243
- let r = this._used;
244
- for (; r; ) {
245
- if (r === e)
246
- return this.blockSize(e) - y;
247
- r = this.blockNext(r);
248
- }
249
- }
250
- lengthOf(t) {
251
- let e = this.bytesFor(t);
252
- if (e)
253
- return e / this.u32.BYTES_PER_ELEMENT;
254
- }
255
- free(t) {
256
- let e;
257
- if (typeof t != "number") {
258
- if (t.buffer !== this.buf)
259
- return !1;
260
- e = t.byteOffset;
261
- } else
262
- e = t;
263
- z(this.lock), e = C(e);
264
- let r = this._used, s = 0;
265
- for (; r; ) {
266
- if (r === e)
267
- return s ? this.unlinkBlock(s, r) : this._used = this.blockNext(r), this.insert(r), this.doCompact && this.compact(), g(this.lock), !0;
268
- s = r, r = this.blockNext(r);
269
- }
270
- return g(this.lock), !1;
271
- }
272
- freeAll() {
273
- this._free = 0, this._used = 0, this.top = this.initialTop();
274
- }
275
- release() {
276
- return delete this.u8, delete this.u32, delete this.state, delete this.buf, !0;
277
- }
278
- get align() {
279
- return this.state[nt];
280
- }
281
- set align(t) {
282
- this.state[nt] = t;
283
- }
284
- get end() {
285
- return this.state[at];
286
- }
287
- set end(t) {
288
- this.state[at] = t;
289
- }
290
- get top() {
291
- return Atomics.load(this.state, ot);
292
- }
293
- set top(t) {
294
- Atomics.store(this.state, ot, t);
295
- }
296
- get _free() {
297
- return Atomics.load(this.state, it);
298
- }
299
- set _free(t) {
300
- Atomics.store(this.state, it, t);
301
- }
302
- get _used() {
303
- return Atomics.load(this.state, st);
304
- }
305
- set _used(t) {
306
- Atomics.store(this.state, st, t);
307
- }
308
- get doCompact() {
309
- return !!(this.state[A] & K);
310
- }
311
- set doCompact(t) {
312
- t ? this.state[A] |= 1 << K - 1 : this.state[A] &= ~K;
313
- }
314
- get doSplit() {
315
- return !!(this.state[A] & G);
316
- }
317
- set doSplit(t) {
318
- t ? this.state[A] |= 1 << G - 1 : this.state[A] &= ~G;
319
- }
320
- get minSplit() {
321
- return this.state[lt];
322
- }
323
- set minSplit(t) {
324
- if (t <= y)
325
- throw new Error(`illegal min split threshold: ${t}, require at least ${y + 1}`);
326
- this.state[lt] = t;
327
- }
328
- blockSize(t) {
329
- return Atomics.load(this.u32, (t >> 2) + X);
330
- }
331
- /**
332
- * Sets & returns given block size.
333
- *
334
- * @param block -
335
- * @param size -
336
- */
337
- setBlockSize(t, e) {
338
- return Atomics.store(this.u32, (t >> 2) + X, e), e;
339
- }
340
- blockNext(t) {
341
- return Atomics.load(this.u32, (t >> 2) + Z);
342
- }
343
- /**
344
- * Sets block next pointer to `next`. Use zero to indicate list end.
345
- *
346
- * @param block -
347
- */
348
- setBlockNext(t, e) {
349
- Atomics.store(this.u32, (t >> 2) + Z, e);
350
- }
351
- /**
352
- * Initializes block header with given `size` and `next` pointer. Returns `block`.
353
- *
354
- * @param block -
355
- * @param size -
356
- * @param next -
357
- */
358
- initBlock(t, e, r) {
359
- const s = t >>> 2;
360
- return Atomics.store(this.u32, s + X, e), Atomics.store(this.u32, s + Z, r), t;
361
- }
362
- unlinkBlock(t, e) {
363
- this.setBlockNext(t, this.blockNext(e));
364
- }
365
- splitBlock(t, e, r) {
366
- this.insert(
367
- this.initBlock(
368
- t + this.setBlockSize(t, e),
369
- r,
370
- 0
371
- )
372
- ), this.doCompact && this.compact();
373
- }
374
- initialTop(t = this.align) {
375
- return I(this.start + ft + y, t) - y;
376
- }
377
- /**
378
- * Traverses free list and attempts to recursively merge blocks
379
- * occupying consecutive memory regions. Returns true if any blocks
380
- * have been merged. Only called if `compact` option is enabled.
381
- */
382
- compact() {
383
- let t = this._free, e = 0, r = 0, s, o = !1;
384
- for (; t; ) {
385
- for (s = t, r = this.blockNext(t); r && s + this.blockSize(s) === r; )
386
- s = r, r = this.blockNext(r);
387
- if (s !== t) {
388
- const a = s - t + this.blockSize(s);
389
- this.setBlockSize(t, a);
390
- const l = this.blockNext(s);
391
- let n = this.blockNext(t);
392
- for (; n && n !== l; ) {
393
- const f = this.blockNext(n);
394
- this.setBlockNext(n, 0), n = f;
395
- }
396
- this.setBlockNext(t, l), o = !0;
397
- }
398
- t + this.blockSize(t) >= this.top && (this.top = t, e ? this.unlinkBlock(e, t) : this._free = this.blockNext(t)), e = t, t = this.blockNext(t);
399
- }
400
- return o;
401
- }
402
- /**
403
- * Inserts given block into list of free blocks, sorted by address.
404
- *
405
- * @param block -
406
- */
407
- insert(t) {
408
- let e = this._free, r = 0;
409
- for (; e && !(t <= e); )
410
- r = e, e = this.blockNext(e);
411
- r ? this.setBlockNext(r, t) : this._free = t, this.setBlockNext(t, e);
412
- }
413
- }
414
- const _ = (i) => i > 0 ? i + y : 0, C = (i) => i > 0 ? i - y : 0, I = (i, t) => (t--, i + t & ~t), qt = {
415
- u8: 1,
416
- u8c: 1,
417
- i8: 1,
418
- u16: 2,
419
- i16: 2,
420
- u32: 4,
421
- i32: 4,
422
- i64: 8,
423
- u64: 8,
424
- f32: 4,
425
- f64: 8
426
- }, Jt = [
427
- "B",
428
- "kB",
429
- "MB",
430
- "GB",
431
- "TB",
432
- "PB",
433
- "EB",
434
- "ZB",
435
- "YB"
436
- ], Qt = [
437
- "B",
438
- "KiB",
439
- "MiB",
440
- "GiB",
441
- "TiB",
442
- "PiB",
443
- "EiB",
444
- "ZiB",
445
- "YiB"
446
- ], te = [
447
- "b",
448
- "kbit",
449
- "Mbit",
450
- "Gbit",
451
- "Tbit",
452
- "Pbit",
453
- "Ebit",
454
- "Zbit",
455
- "Ybit"
456
- ], ee = [
457
- "b",
458
- "kibit",
459
- "Mibit",
460
- "Gibit",
461
- "Tibit",
462
- "Pibit",
463
- "Eibit",
464
- "Zibit",
465
- "Yibit"
466
- ], ht = (i, t, e) => {
467
- let r = i;
468
- return typeof t == "string" || Array.isArray(t) ? r = i.toLocaleString(t, e) : (t === !0 || e !== void 0) && (r = i.toLocaleString(void 0, e)), r;
469
- }, _t = (i) => {
470
- if (typeof i == "number")
471
- return Math.log10(i);
472
- const t = i.toString(10);
473
- return t.length + Math.log10(`0.${t.slice(0, 15)}`);
474
- }, re = (i) => typeof i == "number" ? Math.log(i) : _t(i) * Math.log(10), ie = (i, t) => {
475
- if (typeof i == "number")
476
- return i / t;
477
- const e = i / BigInt(t), r = i % BigInt(t);
478
- return Number(e) + Number(r) / t;
479
- }, ct = (i, t) => {
480
- if (t === void 0)
481
- return i;
482
- if (typeof t != "number" || !Number.isSafeInteger(t) || t < 0)
483
- throw new TypeError(`Expected fixedWidth to be a non-negative integer, got ${typeof t}: ${t}`);
484
- return t === 0 ? i : i.length < t ? i.padStart(t, " ") : i;
485
- }, se = (i) => {
486
- const { minimumFractionDigits: t, maximumFractionDigits: e } = i;
487
- if (!(t === void 0 && e === void 0))
488
- return {
489
- ...t !== void 0 && { minimumFractionDigits: t },
490
- ...e !== void 0 && { maximumFractionDigits: e },
491
- roundingMode: "trunc"
492
- };
493
- };
494
- function oe(i, t) {
495
- if (typeof i != "bigint" && !Number.isFinite(i))
496
- throw new TypeError(`Expected a finite number, got ${typeof i}: ${i}`);
497
- t = {
498
- bits: !1,
499
- binary: !1,
500
- space: !0,
501
- nonBreakingSpace: !1,
502
- ...t
503
- };
504
- const e = t.bits ? t.binary ? ee : te : t.binary ? Qt : Jt, r = t.space ? t.nonBreakingSpace ? " " : " " : "", s = typeof i == "number" ? i === 0 : i === 0n;
505
- if (t.signed && s) {
506
- const f = ` 0${r}${e[0]}`;
507
- return ct(f, t.fixedWidth);
508
- }
509
- const o = i < 0, a = o ? "-" : t.signed ? "+" : "";
510
- o && (i = -i);
511
- const l = se(t);
512
- let n;
513
- if (i < 1) {
514
- const f = ht(i, t.locale, l);
515
- n = a + f + r + e[0];
516
- } else {
517
- const f = Math.min(Math.floor(t.binary ? re(i) / Math.log(1024) : _t(i) / 3), e.length - 1);
518
- if (i = ie(i, (t.binary ? 1024 : 1e3) ** f), !l) {
519
- const M = Math.max(3, Math.floor(i).toString().length);
520
- i = i.toPrecision(M);
521
- }
522
- const T = ht(Number(i), t.locale, l), H = e[f];
523
- n = a + T + r + H;
524
- }
525
- return ct(n, t.fixedWidth);
526
- }
527
- const ae = 8192, ut = 0, v = 1, N = 2;
528
- class ye {
529
- buffers;
530
- onGrowBufferHandlers = [];
531
- isClone;
532
- memory;
533
- get bufferSize() {
534
- return this.memory.data[ut];
535
- }
536
- constructor(t) {
537
- if (t && "buffers" in t)
538
- this.buffers = t.buffers.map((e) => new W({
539
- buf: e,
540
- skipInitialization: !0
541
- })), this.memory = new h(this, {
542
- bufferPosition: 0,
543
- bufferByteOffset: 40
544
- }), this.isClone = !0;
545
- else {
546
- "SharedArrayBuffer" in globalThis || console.warn("SharedArrayBuffer is not working: falling back to ArrayBuffer");
547
- const e = t?.bufferSize ?? ae;
548
- if (e > et)
549
- throw new Error(`Buffer size ${e} is greater than max ${et} that we can reference with pointers`);
550
- let r = this.createBuffer(e);
551
- this.buffers = [
552
- r
553
- ];
554
- const s = r.callocAs("u32", 3);
555
- if (s)
556
- this.memory = new h(this, {
557
- bufferPosition: 0,
558
- bufferByteOffset: s.byteOffset
559
- });
560
- else
561
- throw new Error("Failed to initialize first byte from buffer");
562
- this.memory.data[ut] = e, this.memory.data[v] = 1, this.memory.data[N] = t?.autoGrowSize ?? 100, this.isClone = !1;
563
- for (let o = 1; o < (t?.initialBuffers ?? 1); o++)
564
- this.buffers.push(this.createBuffer(e));
565
- }
566
- }
567
- addSharedBuffer(t) {
568
- this.buffers[t.bufferPosition] = new W({
569
- buf: t.buffer,
570
- skipInitialization: !0
571
- });
572
- }
573
- growBuffer() {
574
- const t = this.createBuffer();
575
- let e = Atomics.add(this.memory.data, v, 1);
576
- return this.buffers[e] = t, this.onGrowBufferHandlers.forEach((r) => r({
577
- bufferPosition: e,
578
- buffer: t.buf
579
- })), t;
580
- }
581
- createBuffer(t) {
582
- const e = t ?? this.bufferSize;
583
- let r;
584
- return "SharedArrayBuffer" in globalThis ? r = new SharedArrayBuffer(e) : r = new ArrayBuffer(e), new W({
585
- buf: r,
586
- // We can't use this unless we can 100% guarantee that every thread will stop using memory the instant it is freed
587
- // ex: Allocate 16 bytes. Thread A frees that allocation and then allocates 12 bytes and 4 bytes, but Thread B is mid-execution on the old allocation can changes the internal state of the 4-byte allocation breaking everything
588
- // After the internal state is wrong MemoryBuffer will loose track of which blocks are where and how big they are
589
- compact: !1,
590
- split: !1
591
- });
592
- }
593
- addOnGrowBufferHandlers(t) {
594
- this.onGrowBufferHandlers.push(t);
595
- }
596
- allocUI32(t) {
597
- t = Math.ceil(t);
598
- for (let s = 0; s < this.buffers.length; s++) {
599
- const o = this.buffers[s];
600
- if (!o)
601
- continue;
602
- const a = o.callocAs("u32", t);
603
- if (a)
604
- return s === this.buffers.length - 1 && Atomics.load(this.memory.data, v) === this.buffers.length && this.memory.data[N] < 100 && this.memory.data[N] > 0 && o.top / o.end > this.memory.data[N] / 100 && this.growBuffer(), new h(this, {
605
- data: a,
606
- buffer: o
607
- });
608
- }
609
- if (this.buffers.length >= rt)
610
- throw new Error(`Can't initialize a new buffer since it would have a position greater than the max of ${rt}`);
611
- let e = this.growBuffer();
612
- const r = e.callocAs("u32", t);
613
- if (r)
614
- return new h(this, {
615
- data: r,
616
- buffer: e
617
- });
618
- throw new Error(`Unable to allocate ${t} numbers even after adding a new buffer`);
619
- }
620
- getSharedAlloc(t) {
621
- if (this.buffers[t.bufferPosition] !== void 0)
622
- return new h(this, t);
623
- }
624
- get currentUsed() {
625
- return this.totalAllocated - this.buffers.reduce((t, e) => t + e.stats().available, 0);
626
- }
627
- get totalAllocated() {
628
- return this.buffers[0].buf.byteLength * this.buffers.length;
629
- }
630
- prettyMemory() {
631
- return `${dt(this.currentUsed)} / ${dt(this.totalAllocated)}`;
632
- }
633
- getSharedMemory() {
634
- return {
635
- buffers: this.buffers.map((t) => t.buf)
636
- };
637
- }
638
- }
639
- function dt(i) {
640
- return oe(i, {
641
- binary: !0,
642
- minimumFractionDigits: 1,
643
- maximumFractionDigits: 1
644
- });
645
- }
646
- const yt = 4, Bt = 1, p = 2;
647
- class u {
648
- static ALLOCATE_COUNT = yt;
649
- memory;
650
- /* First block
651
- 32 index 0
652
- uint16 0 - next buffer position
653
- uint16 1 - next buffer index
654
- 32 index 1
655
- uint16 2 - last buffer position
656
- uint16 3 - last buffer index
657
- 32 index 2
658
- uint32 4 - length
659
- 32 index 3
660
- uint16 6 - type
661
- uint16 7 - data length (defaults to 1 number per data)
662
- */
663
- /* Other blocks
664
- 32 index 0
665
- uint16 0 - next buffer position
666
- uint16 1 - next buffer index
667
- 32 index 1 => data
668
- */
669
- firstBlock;
670
- uint16Array;
671
- onDelete;
672
- get length() {
673
- return Atomics.load(this.firstBlock.data, p);
674
- }
675
- get type() {
676
- return Atomics.load(this.uint16Array, 0);
677
- }
678
- set type(t) {
679
- Atomics.store(this.uint16Array, 0, t);
680
- }
681
- get dataLength() {
682
- return Math.max(1, Atomics.load(this.uint16Array, 1));
683
- }
684
- set dataLength(t) {
685
- Atomics.store(this.uint16Array, 1, t);
686
- }
687
- constructor(t, e) {
688
- if (this.memory = t, e && "firstBlock" in e)
689
- this.firstBlock = new h(t, e.firstBlock), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + (p + 1) * Uint32Array.BYTES_PER_ELEMENT, 2);
690
- else {
691
- e && e.initWithBlock ? this.firstBlock = new h(t, e.initWithBlock) : this.firstBlock = t.allocUI32(yt), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + (p + 1) * Uint32Array.BYTES_PER_ELEMENT, 2);
692
- const r = e?.type ?? Uint32Array;
693
- r === Uint32Array ? this.type = 0 : r === Int32Array ? this.type = 1 : r === Float32Array && (this.type = 2), this.dataLength = e?.dataLength ?? 1;
694
- }
695
- }
696
- insert(t) {
697
- typeof t == "number" && (t = [t]);
698
- let e = this.dataLength;
699
- if (t.length > e)
700
- throw new Error(`Can't insert ${t.length} array into shared list of ${e} dataLength`);
701
- let r = this.memory.allocUI32(Bt + e), s = this.getDataBlock(r.data), o = r.pointer;
702
- for (let n = 0; n < t.length; n++)
703
- s instanceof Int32Array || s instanceof Uint32Array ? Atomics.store(s, n, t[n]) : s[n] = t[n];
704
- let a, l = !1;
705
- for (; !l; )
706
- a = O(this.firstBlock.data, 1), l = V(this.firstBlock.data, 1, o, a);
707
- if (a) {
708
- let { bufferPosition: n, bufferByteOffset: f } = B(a), T = new Uint32Array(this.memory.buffers[n].buf, f, 1);
709
- x(T, 0, o);
710
- } else
711
- x(this.firstBlock.data, 0, o);
712
- Atomics.add(this.firstBlock.data, p, 1);
713
- }
714
- deleteMatch(t) {
715
- for (let { data: e, index: r, deleteCurrent: s } of this)
716
- if (t(e, r))
717
- return s(), !0;
718
- return !1;
719
- }
720
- deleteIndex(t) {
721
- return t >= this.length || t < 0 ? !1 : this.deleteMatch((e, r) => r === t);
722
- }
723
- deleteValue(t) {
724
- return typeof t == "number" ? this.deleteMatch((e) => e[0] === t) : this.deleteMatch((e) => {
725
- if (e.length !== t.length)
726
- return !1;
727
- for (let r = 0; r < e.length; r++)
728
- if (e[r] !== t[r])
729
- return !1;
730
- return !0;
731
- });
732
- }
733
- clear() {
734
- let t, e, r = !1;
735
- for (; !r; ) {
736
- if (t = O(this.firstBlock.data, 0), e = O(this.firstBlock.data, 1), !e)
737
- return;
738
- r = V(this.firstBlock.data, 1, 0, e);
739
- }
740
- if (!t)
741
- return;
742
- V(this.firstBlock.data, 0, 0, t);
743
- let s = 0, o = t;
744
- for (; o; ) {
745
- let { bufferPosition: a, bufferByteOffset: l } = B(o), n = this.memory.buffers[a];
746
- if (!n)
747
- break;
748
- let f = new Uint32Array(n.buf, l, 2);
749
- o = O(f, 0), s++, this.onDelete && this.onDelete(this.getDataBlock(f)), n.free(f.byteOffset);
750
- }
751
- Atomics.sub(this.firstBlock.data, p, s);
752
- }
753
- *[Symbol.iterator]() {
754
- let t = 0, { bufferPosition: e, bufferByteOffset: r } = c(this.firstBlock.data, 0), s = this.firstBlock.data, o = 0, a = 0;
755
- for (; r; ) {
756
- let l = this.memory.buffers[e];
757
- if (!l)
758
- return;
759
- let n = new Uint32Array(l.buf, r, 2), f = this.getDataBlock(n), T = e, H = r;
760
- ({ bufferPosition: e, bufferByteOffset: r } = c(n, 0));
761
- let M = !0;
762
- yield {
763
- data: f,
764
- index: t,
765
- deleteCurrent: () => {
766
- k(s, 0, e, r), r || k(this.firstBlock.data, 1, o, a), this.onDelete && this.onDelete(this.getDataBlock(n)), l.free(n.byteOffset), Atomics.sub(this.firstBlock.data, p, 1), M = !1;
767
- }
768
- }, M && (s = n, o = T, a = H, t++);
769
- }
770
- }
771
- forEach(t) {
772
- for (let e of this)
773
- t(e.data);
774
- }
775
- getSharedMemory() {
776
- return {
777
- firstBlock: this.firstBlock.getSharedMemory()
778
- };
779
- }
780
- getDataBlock(t) {
781
- const e = t.byteOffset + Bt * t.BYTES_PER_ELEMENT;
782
- switch (this.type) {
783
- case 1:
784
- return new Int32Array(t.buffer, e, this.dataLength);
785
- case 0:
786
- return new Uint32Array(t.buffer, e, this.dataLength);
787
- case 2:
788
- return new Float32Array(t.buffer, e, this.dataLength);
789
- default:
790
- throw new Error(`Unknown data block type ${this.type}`);
791
- }
792
- }
793
- free() {
794
- let { bufferPosition: t, bufferByteOffset: e } = c(this.firstBlock.data, 0);
795
- for (; e; ) {
796
- let r = new h(this.memory, {
797
- bufferPosition: t,
798
- bufferByteOffset: e
799
- });
800
- ({ bufferPosition: t, bufferByteOffset: e } = c(r.data, 0)), this.onDelete && this.onDelete(this.getDataBlock(r.data)), r.free();
801
- }
802
- this.firstBlock.free();
803
- }
804
- }
805
- const mt = 10;
806
- class Ot {
807
- static ALLOCATE_COUNT = 4;
808
- memory;
809
- // Memory order: Pointer, Lock, Length, MaxHash
810
- pointerMemory;
811
- lock;
812
- get hashMemory() {
813
- return new h(this.memory, c(this.pointerMemory.data, 0));
814
- }
815
- get length() {
816
- return Atomics.load(this.pointerMemory.data, 2);
817
- }
818
- get maxHash() {
819
- return Atomics.load(this.pointerMemory.data, 3);
820
- }
821
- constructor(t, e) {
822
- if (this.memory = t, e)
823
- this.pointerMemory = new h(t, e.firstBlock);
824
- else {
825
- this.pointerMemory = t.allocUI32(Ot.ALLOCATE_COUNT);
826
- let r = t.allocUI32(mt);
827
- k(this.pointerMemory.data, 0, r.bufferPosition, r.bufferByteOffset), Atomics.store(this.pointerMemory.data, 3, mt);
828
- }
829
- this.lock = new Int32Array(this.pointerMemory.data.buffer, this.pointerMemory.bufferByteOffset + Uint32Array.BYTES_PER_ELEMENT, 1);
830
- }
831
- set(t, e) {
832
- this.length >= this.maxHash * 2 && this.growHashTable();
833
- let r = P(t);
834
- this.setHashKey(this.hashMemory, this.maxHash, r, e) && Atomics.add(this.pointerMemory.data, 2, 1);
835
- }
836
- setHashKey(t, e, r, s) {
837
- let o = this.hash(r, e), a, l = c(t.data, o);
838
- if (l.bufferByteOffset === 0) {
839
- a = new u(this.memory, {
840
- dataLength: 2
841
- });
842
- let f = a.getSharedMemory();
843
- k(t.data, o, f.firstBlock.bufferPosition, f.firstBlock.bufferByteOffset);
844
- } else
845
- a = new u(this.memory, {
846
- firstBlock: l
847
- });
848
- let n = !0;
849
- return a.deleteValue(r) && (n = !1), a.insert([r, s]), n;
850
- }
851
- get(t) {
852
- let e = P(t), r = this.hash(e, this.maxHash), s = c(this.hashMemory.data, r);
853
- if (s.bufferByteOffset === 0)
854
- return;
855
- let o = new u(this.memory, {
856
- firstBlock: s
857
- });
858
- for (let { data: a } of o)
859
- if (a[0] === e)
860
- return a[1];
861
- }
862
- has(t) {
863
- let e = P(t), r = this.hash(e, this.maxHash), s = c(this.hashMemory.data, r);
864
- if (s.bufferByteOffset === 0)
865
- return !1;
866
- let o = new u(this.memory, {
867
- firstBlock: s
868
- });
869
- for (let { data: a } of o)
870
- if (a[0] === e)
871
- return !0;
872
- return !1;
873
- }
874
- delete(t) {
875
- let e = P(t), r = this.hash(e, this.maxHash), s = c(this.hashMemory.data, r);
876
- if (s.bufferByteOffset === 0)
877
- return !1;
878
- let o = new u(this.memory, {
879
- firstBlock: s
880
- });
881
- for (let { data: a, deleteCurrent: l } of o)
882
- if (a[0] === e)
883
- return l(), Atomics.sub(this.pointerMemory.data, 2, 1), !0;
884
- return !1;
885
- }
886
- growHashTable() {
887
- let t = this.maxHash, e = t * 2, r = this.memory.allocUI32(e), s = this.hashMemory;
888
- for (let o = 0; o < t; o++) {
889
- let a = c(s.data, o);
890
- if (a.bufferByteOffset === 0)
891
- continue;
892
- let l = new u(this.memory, {
893
- firstBlock: a
894
- });
895
- for (let { data: n } of l)
896
- this.setHashKey(r, e, n[0], n[1]);
897
- }
898
- k(this.pointerMemory.data, 0, r.bufferPosition, r.bufferByteOffset), Atomics.store(this.pointerMemory.data, 3, e);
899
- }
900
- hash(t, e) {
901
- return t % e;
902
- }
903
- free() {
904
- for (let t = 0; t < this.maxHash; t++) {
905
- let e = c(this.hashMemory.data, t);
906
- if (e.bufferByteOffset === 0)
907
- continue;
908
- new u(this.memory, {
909
- firstBlock: e
910
- }).free();
911
- }
912
- this.hashMemory.free(), this.pointerMemory.free();
913
- }
914
- getSharedMemory() {
915
- return {
916
- firstBlock: this.pointerMemory.getSharedMemory()
917
- };
918
- }
919
- }
920
- function P(i) {
921
- return typeof i == "number" ? i : typeof i == "string" ? ne(i) : i;
922
- }
923
- function ne(i) {
924
- let t = i.length, e = 17 ^ t, r = 0, s;
925
- for (; t >= 4; )
926
- s = i.charCodeAt(r) & 255 | (i.charCodeAt(++r) & 255) << 8 | (i.charCodeAt(++r) & 255) << 16 | (i.charCodeAt(++r) & 255) << 14, s = (s & 65535) * 1540483477 + (((s >>> 16) * 1540483477 & 65535) << 16), s ^= s >>> 14, s = (s & 65535) * 1540483477 + (((s >>> 16) * 1540483477 & 65535) << 16), e = (e & 65535) * 1540483477 + (((e >>> 16) * 1540483477 & 65535) << 16) ^ s, t -= 4, ++r;
927
- switch (t) {
928
- case 3:
929
- e ^= (i.charCodeAt(r + 2) & 255) << 16;
930
- case 2:
931
- e ^= (i.charCodeAt(r + 1) & 255) << 8;
932
- case 1:
933
- e ^= i.charCodeAt(r) & 255, e = (e & 65535) * 1540483477 + (((e >>> 16) * 1540483477 & 65535) << 16);
934
- }
935
- return e ^= e >>> 13, e = (e & 65535) * 1540483477 + (((e >>> 16) * 1540483477 & 65535) << 16), e ^= e >>> 15, e = e >>> 0, e;
936
- }
937
- class Be {
938
- memory;
939
- list;
940
- constructor(t, e) {
941
- this.memory = t, e ? this.list = new u(t, e) : this.list = new u(t);
942
- }
943
- get length() {
944
- return this.list.length;
945
- }
946
- insert(t) {
947
- this.list.insert(L(t.memory.bufferPosition, t.memory.bufferByteOffset));
948
- }
949
- delete(t) {
950
- return this.list.deleteValue(L(t.memory.bufferPosition, t.memory.bufferByteOffset));
951
- }
952
- *[Symbol.iterator]() {
953
- let t = this.list[Symbol.iterator]();
954
- for (let { data: e } of t) {
955
- let { bufferPosition: r, bufferByteOffset: s } = c(e, 0), o = new h(this.memory, {
956
- bufferPosition: r,
957
- bufferByteOffset: s
958
- });
959
- yield this.createItem(o);
960
- }
961
- }
962
- forEach(t) {
963
- for (let e of this)
964
- t(e);
965
- }
966
- find(t) {
967
- for (let e of this)
968
- if (t(e))
969
- return e;
970
- }
971
- getSharedMemory() {
972
- return this.list.getSharedMemory();
973
- }
974
- free() {
975
- for (let t of this)
976
- "free" in t && typeof t.free == "function" ? t.free() : t.memory.free();
977
- this.list.free();
978
- }
979
- }
980
- const bt = {
981
- 1: Uint8Array,
982
- 2: Uint16Array
983
- }, U = 0, gt = 1, kt = 2, At = 3;
984
- class Mt {
985
- static ALLOCATE_COUNT = 4;
986
- memory;
987
- allocatedMemory;
988
- lock;
989
- cachedPointer;
990
- cachedString;
991
- constructor(t, e) {
992
- this.memory = t, typeof e == "string" ? (this.allocatedMemory = this.memory.allocUI32(Mt.ALLOCATE_COUNT), this.lock = new Int32Array(this.allocatedMemory.data.buffer, this.allocatedMemory.bufferByteOffset + At * this.allocatedMemory.data.BYTES_PER_ELEMENT), this.updateString(e)) : (this.allocatedMemory = new h(t, e), this.lock = new Int32Array(this.allocatedMemory.data.buffer, this.allocatedMemory.bufferByteOffset + At * this.allocatedMemory.data.BYTES_PER_ELEMENT), "value" in e && this.updateString(e.value));
993
- }
994
- updateString(t) {
995
- let e = this.createString(t);
996
- z(this.lock), x(this.allocatedMemory.data, U, e.pointer), Atomics.store(this.allocatedMemory.data, gt, t.length), Atomics.store(this.allocatedMemory.data, kt, e.charType), g(this.lock), this.cachedPointer = e.pointer, this.cachedString = t;
997
- }
998
- createString(t) {
999
- if (t === "")
1000
- return {
1001
- pointer: 0,
1002
- charType: 1
1003
- /* ASCII */
1004
- };
1005
- let e = [];
1006
- for (let n = 0; n < t.length; n++)
1007
- e.push(t.charCodeAt(n));
1008
- let s = Math.max(...e) > 255 ? 2 : 1, o = bt[s], a = this.memory.allocUI32(Math.ceil(t.length / (4 / o.BYTES_PER_ELEMENT))), l = new o(a.data.buffer, a.data.byteOffset, t.length);
1009
- for (let n = 0; n < t.length; n++)
1010
- l[n] = t.charCodeAt(n);
1011
- return {
1012
- pointer: a.pointer,
1013
- charType: s
1014
- };
1015
- }
1016
- get value() {
1017
- let t = O(this.allocatedMemory.data, U);
1018
- if (this.cachedPointer === t && this.cachedString !== void 0)
1019
- return this.cachedString;
1020
- if (t === 0)
1021
- return "";
1022
- let { bufferPosition: e, bufferByteOffset: r } = B(t);
1023
- z(this.lock);
1024
- let s = Atomics.load(this.allocatedMemory.data, kt), o = bt[s], a = Atomics.load(this.allocatedMemory.data, gt), l = new o(this.memory.buffers[e].buf, r, a), n = String.fromCharCode.apply(null, l);
1025
- return g(this.lock), this.cachedPointer = t, this.cachedString = n, n;
1026
- }
1027
- set value(t) {
1028
- let { bufferPosition: e, bufferByteOffset: r } = c(this.allocatedMemory.data, U);
1029
- this.updateString(t), r && this.memory.buffers[e].free(r);
1030
- }
1031
- getSharedMemory() {
1032
- return this.allocatedMemory.getSharedMemory();
1033
- }
1034
- get pointer() {
1035
- return this.allocatedMemory.pointer;
1036
- }
1037
- free() {
1038
- let { bufferPosition: t, bufferByteOffset: e } = c(this.allocatedMemory.data, U);
1039
- e && this.memory.buffers[t].free(e), this.allocatedMemory.free();
1040
- }
1041
- }
1042
- const E = 0, d = 1, pt = 2, Et = 3, wt = 4;
1043
- class m {
1044
- static ALLOCATE_COUNT = 4;
1045
- memory;
1046
- // Pointer, List Length, Buffer Length, Type/DataLength
1047
- firstBlock;
1048
- uint16Array;
1049
- get length() {
1050
- return Atomics.load(this.firstBlock.data, d);
1051
- }
1052
- get type() {
1053
- return this.uint16Array[0];
1054
- }
1055
- set type(t) {
1056
- Atomics.store(this.uint16Array, 0, t);
1057
- }
1058
- get dataLength() {
1059
- return this.uint16Array[1] || 1;
1060
- }
1061
- set dataLength(t) {
1062
- Atomics.store(this.uint16Array, 1, t);
1063
- }
1064
- get bufferLength() {
1065
- return Atomics.load(this.firstBlock.data, pt);
1066
- }
1067
- set bufferLength(t) {
1068
- Atomics.store(this.firstBlock.data, pt, t);
1069
- }
1070
- get pointer() {
1071
- return this.firstBlock.pointer;
1072
- }
1073
- cachedFullDataBlock;
1074
- cachedPointer;
1075
- constructor(t, e) {
1076
- if (this.memory = t, e && "firstBlock" in e) {
1077
- if (this.firstBlock = new h(t, e.firstBlock), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + Et * Uint32Array.BYTES_PER_ELEMENT, 2), "type" in e || "dataLength" in e) {
1078
- const r = e.bufferLength ?? wt;
1079
- let s = t.allocUI32(r * (e.dataLength ?? 1));
1080
- k(this.firstBlock.data, E, s.bufferPosition, s.bufferByteOffset), this.bufferLength = r, this.dataLength = e.dataLength ?? 1;
1081
- }
1082
- if ("type" in e) {
1083
- const r = e?.type ?? Uint32Array;
1084
- r === Uint32Array ? this.type = 0 : r === Int32Array ? this.type = 1 : r === Float32Array && (this.type = 2);
1085
- }
1086
- } else {
1087
- this.firstBlock = t.allocUI32(m.ALLOCATE_COUNT), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + Et * Uint32Array.BYTES_PER_ELEMENT, 2);
1088
- let r = e?.dataLength ?? 1, s = e?.bufferLength ?? wt, o = t.allocUI32(s * r);
1089
- k(this.firstBlock.data, E, o.bufferPosition, o.bufferByteOffset), this.bufferLength = s;
1090
- const a = e?.type ?? Uint32Array;
1091
- a === Uint32Array ? this.type = 0 : a === Int32Array ? this.type = 1 : a === Float32Array && (this.type = 2), this.dataLength = r;
1092
- }
1093
- this.cachedPointer = this.firstBlock.data[0], this.cachedFullDataBlock = this.getFullDataBlock();
1094
- }
1095
- at(t) {
1096
- let e = this.length;
1097
- if (t >= e || t < 0)
1098
- throw new Error(`${t} is out of bounds ${e}`);
1099
- let r = this.getFullDataBlock();
1100
- return this.getDataBlock(r, t);
1101
- }
1102
- get(t, e = 0) {
1103
- if (e >= this.dataLength)
1104
- throw new Error(`${e} is out of dataLength bounds ${this.dataLength}`);
1105
- if (t >= this.length || t < 0)
1106
- throw new Error(`${t} is out of bounds ${this.length}`);
1107
- return this.getFullDataBlock()[t * this.dataLength + e];
1108
- }
1109
- push(t) {
1110
- let e = this.dataLength;
1111
- const r = typeof t == "number";
1112
- if (!r && t.length > e)
1113
- throw new Error(`Can't insert ${t.length} array into shared list of ${e} dataLength`);
1114
- let s = this.getFullDataBlock(), o = this.length, a = e * o;
1115
- return r ? s[a] = t : s.set(t, a), Atomics.add(this.firstBlock.data, d, 1) + 1 >= this.bufferLength && this.growBuffer(), o;
1116
- }
1117
- pop() {
1118
- let t = Atomics.sub(this.firstBlock.data, d, d), e = this.getFullDataBlock();
1119
- return this.getDataBlock(e, t - 1);
1120
- }
1121
- // Returns the first number irregardless of dataLength - faster way to pop if you don't care about the rest of the data block
1122
- popNumber() {
1123
- const t = Atomics.sub(this.firstBlock.data, d, d);
1124
- return this.getFullDataBlock()[(t - 1) * this.dataLength];
1125
- }
1126
- deleteIndex(t) {
1127
- let e = this.length;
1128
- if (t >= e || t < 0)
1129
- throw new Error(`${t} is out of bounds ${e}`);
1130
- let r = this.dataLength, s = this.getFullDataBlock();
1131
- for (let o = t; o < e; o++)
1132
- for (let a = 0; a < r; a++)
1133
- s[o * r + a] = s[(o + 1) * r + a];
1134
- Atomics.sub(this.firstBlock.data, d, d);
1135
- }
1136
- clear() {
1137
- this.firstBlock.data[d] = 0;
1138
- }
1139
- *[Symbol.iterator]() {
1140
- let t = this.getFullDataBlock(), e = this.dataLength, r = this.length * e;
1141
- for (let s = 0; s < r; s += e)
1142
- yield t.subarray(s, s + e);
1143
- }
1144
- // Significantly faster but won't be thread safe if anything is removing/adding to it during iteration
1145
- getCurrentArray() {
1146
- return this.getFullDataBlock().subarray(0, this.length * this.dataLength);
1147
- }
1148
- getFullDataBlock() {
1149
- let t = Atomics.load(this.firstBlock.data, E);
1150
- if (this.cachedPointer === t && this.cachedFullDataBlock)
1151
- return this.cachedFullDataBlock;
1152
- let e = B(t), r = new h(this.memory, e), s;
1153
- switch (this.type) {
1154
- case 1:
1155
- s = new Int32Array(r.data.buffer, r.bufferByteOffset, this.dataLength * this.bufferLength);
1156
- break;
1157
- case 0:
1158
- s = new Uint32Array(r.data.buffer, r.bufferByteOffset, this.dataLength * this.bufferLength);
1159
- break;
1160
- case 2:
1161
- s = new Float32Array(r.data.buffer, r.bufferByteOffset, this.dataLength * this.bufferLength);
1162
- break;
1163
- default:
1164
- throw new Error(`Unknown data block type ${this.type}`);
1165
- }
1166
- return this.cachedPointer = t, this.cachedFullDataBlock = s, s;
1167
- }
1168
- getDataBlock(t, e) {
1169
- const r = e * this.dataLength;
1170
- return t.subarray(r, r + this.dataLength);
1171
- }
1172
- growBuffer() {
1173
- let e = this.bufferLength * 2, r = this.dataLength, s = c(this.firstBlock.data, E), o = new h(this.memory, s), a = this.getFullDataBlock(), l = this.memory.allocUI32(e * r), n;
1174
- switch (this.type) {
1175
- case 1:
1176
- n = new Int32Array(l.data.buffer, l.bufferByteOffset, r * e);
1177
- break;
1178
- case 0:
1179
- n = new Uint32Array(l.data.buffer, l.bufferByteOffset, r * e);
1180
- break;
1181
- case 2:
1182
- n = new Float32Array(l.data.buffer, l.bufferByteOffset, r * e);
1183
- break;
1184
- default:
1185
- throw new Error(`Unknown data block type ${this.type}`);
1186
- }
1187
- n.set(a);
1188
- const f = l.pointer;
1189
- x(this.firstBlock.data, E, f), this.bufferLength = e, o.free(), this.cachedPointer = f, this.cachedFullDataBlock = n;
1190
- }
1191
- free() {
1192
- let t = c(this.firstBlock.data, E);
1193
- new h(this.memory, t).free(), this.firstBlock.free();
1194
- }
1195
- getSharedMemory() {
1196
- return {
1197
- firstBlock: this.firstBlock.getSharedMemory()
1198
- };
1199
- }
1200
- }
1201
- class me {
1202
- static ALLOCATE_COUNT = u.ALLOCATE_COUNT;
1203
- heap;
1204
- list;
1205
- cache = /* @__PURE__ */ new Map();
1206
- constructor(t, e) {
1207
- e ? this.list = new u(t, e) : this.list = new u(t), this.heap = t, this.list.onDelete = (r) => {
1208
- let s = Atomics.load(r, 0);
1209
- if (s) {
1210
- let o = this.cache.get(s);
1211
- o || (o = this.initItem(s)), o && (o.free(), this.cache.delete(s));
1212
- }
1213
- };
1214
- }
1215
- get length() {
1216
- return this.list.length;
1217
- }
1218
- clear() {
1219
- this.list.clear(), this.cache.clear();
1220
- }
1221
- insert(t) {
1222
- this.list.insert(t.pointer), this.cache.set(t.pointer, t);
1223
- }
1224
- delete(t) {
1225
- return this.cache.delete(t.pointer), this.list.deleteValue(t.pointer);
1226
- }
1227
- getByPointer(t) {
1228
- let e = this.cache.get(t);
1229
- return e || (e = this.initItem(t), e && this.cache.set(t, e)), e;
1230
- }
1231
- *[Symbol.iterator]() {
1232
- let t = this.list[Symbol.iterator]();
1233
- for (let { data: e, deleteCurrent: r } of t) {
1234
- let s = Atomics.load(e, 0);
1235
- if (!s)
1236
- continue;
1237
- let o = this.cache.get(s);
1238
- o || (o = this.initItem(s), o && this.cache.set(s, o)), o && (yield {
1239
- item: o,
1240
- deleteCurrent: r
1241
- });
1242
- }
1243
- }
1244
- forEach(t, e) {
1245
- for (let { item: r } of this)
1246
- (!e || e(r)) && t(r);
1247
- }
1248
- find(t) {
1249
- for (let { item: e } of this)
1250
- if (t(e))
1251
- return e;
1252
- }
1253
- filter(t) {
1254
- let e = [];
1255
- for (let { item: r } of this)
1256
- t(r) && e.push(r);
1257
- return e;
1258
- }
1259
- map(t) {
1260
- const e = [];
1261
- for (let { item: r } of this)
1262
- e.push(t(r));
1263
- return e;
1264
- }
1265
- getSharedMemory() {
1266
- return this.list.getSharedMemory();
1267
- }
1268
- free() {
1269
- this.list.free(), this.cache.clear();
1270
- }
1271
- }
1272
- const D = 0, Lt = 1, St = 2, q = 3, Tt = q + m.ALLOCATE_COUNT;
1273
- class Ct {
1274
- static ALLOCATE_COUNT = 3 + m.ALLOCATE_COUNT * 2;
1275
- memory;
1276
- // Current Length, Type/DataLength, MaxChunkLength, Pointer vector, Recycle vector
1277
- firstBlock;
1278
- uint16Array;
1279
- pointerVector;
1280
- recycleVector;
1281
- cachedFullDataBlock = {};
1282
- get length() {
1283
- return Atomics.load(this.firstBlock.data, D) - this.recycleVector.length;
1284
- }
1285
- get maxChunkSize() {
1286
- return this.firstBlock.data[St];
1287
- }
1288
- set maxChunkSize(t) {
1289
- Atomics.store(this.firstBlock.data, St, t);
1290
- }
1291
- get type() {
1292
- return this.uint16Array[0];
1293
- }
1294
- set type(t) {
1295
- Atomics.store(this.uint16Array, 0, t);
1296
- }
1297
- get dataLength() {
1298
- return Math.max(1, this.uint16Array[1]);
1299
- }
1300
- set dataLength(t) {
1301
- Atomics.store(this.uint16Array, 1, t);
1302
- }
1303
- get bufferLength() {
1304
- return this.maxChunkSize * this.pointerVector.length;
1305
- }
1306
- get recycleBufferLength() {
1307
- return this.recycleVector.bufferLength;
1308
- }
1309
- get byteMultipler() {
1310
- return this.type === 3 ? 2 : 1;
1311
- }
1312
- constructor(t, e) {
1313
- if (this.memory = t, e && "firstBlock" in e)
1314
- this.firstBlock = new h(t, e.firstBlock), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + Lt * Uint32Array.BYTES_PER_ELEMENT, 2), this.pointerVector = new m(t, {
1315
- firstBlock: {
1316
- bufferPosition: this.firstBlock.bufferPosition,
1317
- bufferByteOffset: this.firstBlock.bufferByteOffset + q * Uint32Array.BYTES_PER_ELEMENT
1318
- }
1319
- }), this.recycleVector = new m(t, {
1320
- firstBlock: {
1321
- bufferPosition: this.firstBlock.bufferPosition,
1322
- bufferByteOffset: this.firstBlock.bufferByteOffset + Tt * Uint32Array.BYTES_PER_ELEMENT
1323
- }
1324
- });
1325
- else {
1326
- this.firstBlock = t.allocUI32(Ct.ALLOCATE_COUNT), this.uint16Array = new Uint16Array(this.firstBlock.data.buffer, this.firstBlock.bufferByteOffset + Lt * Uint32Array.BYTES_PER_ELEMENT, 2);
1327
- let r = e?.dataLength ?? 1, s = e?.maxChunkSize ?? 100;
1328
- this.pointerVector = new m(t, {
1329
- type: Uint32Array,
1330
- firstBlock: {
1331
- bufferPosition: this.firstBlock.bufferPosition,
1332
- bufferByteOffset: this.firstBlock.bufferByteOffset + q * Uint32Array.BYTES_PER_ELEMENT
1333
- }
1334
- }), this.recycleVector = new m(t, {
1335
- type: Uint32Array,
1336
- firstBlock: {
1337
- bufferPosition: this.firstBlock.bufferPosition,
1338
- bufferByteOffset: this.firstBlock.bufferByteOffset + Tt * Uint32Array.BYTES_PER_ELEMENT
1339
- },
1340
- bufferLength: e?.recycleBufferLength
1341
- });
1342
- const o = e?.type ?? Uint32Array;
1343
- o === Uint32Array ? this.type = 0 : o === Int32Array ? this.type = 1 : o === Float32Array ? this.type = 2 : o === Float64Array && (this.type = 3), this.dataLength = r, this.maxChunkSize = s;
1344
- let a = t.allocUI32(s * r * this.byteMultipler);
1345
- this.pointerVector.push(a.pointer);
1346
- }
1347
- }
1348
- at(t) {
1349
- let e = this.getFullDataBlock(t);
1350
- return this.getDataBlock(e, t % this.maxChunkSize);
1351
- }
1352
- get(t, e = 0) {
1353
- const r = this.dataLength;
1354
- if (e >= r)
1355
- throw new Error(`${e} is out of dataLength bounds ${r}`);
1356
- return this.getFullDataBlock(t)[t % this.maxChunkSize * r + e];
1357
- }
1358
- push(t) {
1359
- typeof t == "number" && (t = [t]);
1360
- let e = this.dataLength;
1361
- if (t.length > e)
1362
- throw new Error(`Can't insert ${t.length} array into shared list of ${e} dataLength`);
1363
- let r;
1364
- this.recycleVector.length ? r = this.recycleVector.popNumber() : r = Atomics.add(this.firstBlock.data, D, 1);
1365
- let s = this.getFullDataBlock(r), o = r % this.maxChunkSize;
1366
- return s.set(t, e * o), r;
1367
- }
1368
- deleteIndex(t) {
1369
- this.recycleVector.push(t);
1370
- }
1371
- clear() {
1372
- this.firstBlock.data[D] = 0, this.recycleVector.clear();
1373
- }
1374
- *[Symbol.iterator]() {
1375
- const t = {};
1376
- for (let s of this.recycleVector)
1377
- t[s[0]] = !0;
1378
- let e = this.getFullDataBlock(0), r = 0;
1379
- for (let s = 0; s < Atomics.load(this.firstBlock.data, D); s++)
1380
- if (!t[s]) {
1381
- let o = Math.floor(s / this.maxChunkSize);
1382
- o !== r && (e = this.getFullDataBlock(s), r = o), yield this.getDataBlock(e, s % this.maxChunkSize);
1383
- }
1384
- }
1385
- getFullDataBlock(t) {
1386
- let e = Math.floor(t / this.maxChunkSize), r = this.cachedFullDataBlock[e];
1387
- if (r)
1388
- return r;
1389
- if (e >= this.pointerVector.length) {
1390
- let a = this.memory.allocUI32(this.maxChunkSize * this.dataLength * this.byteMultipler);
1391
- this.pointerVector.push(a.pointer);
1392
- }
1393
- let s = new h(this.memory, B(this.pointerVector.get(e))), o;
1394
- switch (this.type) {
1395
- case 1:
1396
- o = new Int32Array(s.data.buffer, s.bufferByteOffset, this.dataLength * this.maxChunkSize);
1397
- break;
1398
- case 0:
1399
- o = new Uint32Array(s.data.buffer, s.bufferByteOffset, this.dataLength * this.maxChunkSize);
1400
- break;
1401
- case 2:
1402
- o = new Float32Array(s.data.buffer, s.bufferByteOffset, this.dataLength * this.maxChunkSize);
1403
- break;
1404
- case 3:
1405
- o = new Float64Array(s.data.buffer, s.bufferByteOffset, this.dataLength * this.maxChunkSize);
1406
- break;
1407
- default:
1408
- throw new Error(`Unknown data block type ${this.type}`);
1409
- }
1410
- return this.cachedFullDataBlock[e] = o, o;
1411
- }
1412
- getDataBlock(t, e) {
1413
- const r = e * this.dataLength;
1414
- return t.subarray(r, r + this.dataLength);
1415
- }
1416
- free() {
1417
- this.recycleVector.free();
1418
- for (let t of this.pointerVector) {
1419
- let e = t[0];
1420
- new h(this.memory, B(e)).free();
1421
- }
1422
- this.pointerVector.free(), this.firstBlock.free();
1423
- }
1424
- getSharedMemory() {
1425
- return {
1426
- firstBlock: this.firstBlock.getSharedMemory()
1427
- };
1428
- }
1429
- }
1430
- class be {
1431
- memory;
1432
- pointers = [];
1433
- recycledIndexes = [];
1434
- totalLength = 0;
1435
- maxChunkSize = 100;
1436
- dataLength = 1;
1437
- byteMultipler = 1;
1438
- typeConstructor;
1439
- fullDataBlocks = {};
1440
- get length() {
1441
- return this.totalLength - this.recycledIndexes.length;
1442
- }
1443
- get bufferLength() {
1444
- return this.maxChunkSize * this.pointers.length;
1445
- }
1446
- constructor(t, e) {
1447
- this.memory = t;
1448
- const r = e?.dataLength ?? 1, s = e?.maxChunkSize ?? 100;
1449
- this.dataLength = r, this.maxChunkSize = s, this.typeConstructor = e.type, this.typeConstructor === Float64Array && (this.byteMultipler = 2);
1450
- let o = t.allocUI32(s * r * this.byteMultipler);
1451
- this.pointers.push(o.pointer);
1452
- let a = new this.typeConstructor(o.data.buffer, o.bufferByteOffset, this.dataLength * this.maxChunkSize);
1453
- this.fullDataBlocks[0] = a;
1454
- }
1455
- at(t) {
1456
- let e = this.fullDataBlocks[Math.floor(t / this.maxChunkSize)];
1457
- return this.getDataBlock(e, t % this.maxChunkSize);
1458
- }
1459
- get(t, e = 0) {
1460
- const r = this.dataLength;
1461
- if (e >= r)
1462
- throw new Error(`${e} is out of dataLength bounds ${r}`);
1463
- return this.fullDataBlocks[Math.floor(t / this.maxChunkSize)][t % this.maxChunkSize * r + e];
1464
- }
1465
- push(t) {
1466
- const e = typeof t == "number";
1467
- if (!e && t.length > this.dataLength)
1468
- throw new Error(`Can't insert ${t.length} array into shared list of ${this.dataLength} dataLength`);
1469
- let r = this.recycledIndexes.pop();
1470
- r === void 0 && (r = this.totalLength++);
1471
- let s = Math.floor(r / this.maxChunkSize);
1472
- if (s >= this.pointers.length) {
1473
- let n = this.memory.allocUI32(this.maxChunkSize * this.dataLength * this.byteMultipler);
1474
- this.pointers.push(n.pointer);
1475
- let f = new this.typeConstructor(n.data.buffer, n.bufferByteOffset, this.dataLength * this.maxChunkSize);
1476
- this.fullDataBlocks[s] = f;
1477
- }
1478
- let o = this.fullDataBlocks[s], a = r % this.maxChunkSize, l = this.dataLength * a;
1479
- return e ? o[l] = t : o.set(t, l), r;
1480
- }
1481
- deleteIndex(t) {
1482
- this.recycledIndexes.push(t);
1483
- }
1484
- clear() {
1485
- this.totalLength = 0, this.recycledIndexes = [];
1486
- }
1487
- *[Symbol.iterator]() {
1488
- const t = {};
1489
- for (let s of this.recycledIndexes)
1490
- t[s] = !0;
1491
- let e = this.getFullDataBlock(0), r = 0;
1492
- for (let s = 0; s < this.totalLength; s++)
1493
- if (!t[s]) {
1494
- let o = Math.floor(s / this.maxChunkSize);
1495
- o !== r && (e = this.getFullDataBlock(s), r = o), yield this.getDataBlock(e, s % this.maxChunkSize);
1496
- }
1497
- }
1498
- getFullDataBlock(t) {
1499
- let e = Math.floor(t / this.maxChunkSize), r = this.fullDataBlocks[e];
1500
- if (r)
1501
- return r;
1502
- if (e >= this.pointers.length) {
1503
- let a = this.memory.allocUI32(this.maxChunkSize * this.dataLength * this.byteMultipler);
1504
- this.pointers.push(a.pointer);
1505
- }
1506
- let s = new h(this.memory, B(this.pointers[e])), o = new this.typeConstructor(s.data.buffer, s.bufferByteOffset, this.dataLength * this.maxChunkSize);
1507
- return this.fullDataBlocks[e] = o, o;
1508
- }
1509
- getDataBlock(t, e) {
1510
- const r = e * this.dataLength;
1511
- return t.subarray(r, r + this.dataLength);
1512
- }
1513
- free() {
1514
- for (let t of this.pointers)
1515
- new h(this.memory, B(t)).free();
1516
- this.pointers = [], this.recycledIndexes = [], this.totalLength = 0, this.fullDataBlocks = {};
1517
- }
1518
- }
1519
- const It = new ArrayBuffer(4), Nt = new Uint32Array(It), R = new Uint16Array(It);
1520
- function ge(i, t) {
1521
- return le(Atomics.load(i, t));
1522
- }
1523
- function ke(i, t, e, r) {
1524
- Atomics.store(i, t, fe(e, r));
1525
- }
1526
- function le(i) {
1527
- return Nt[0] = i, [R[0], R[1]];
1528
- }
1529
- function fe(i, t) {
1530
- return R[0] = i, R[1] = t, Nt[0];
1531
- }
1532
- const Pt = new ArrayBuffer(8), Ut = new BigUint64Array(Pt), b = new Uint16Array(Pt);
1533
- function Ae(i, t) {
1534
- return Ut[0] = Atomics.load(i, t), [b[0], b[1], b[2], b[3]];
1535
- }
1536
- function pe(i, t, e, r, s, o = 0) {
1537
- b[0] = e, b[1] = r, b[2] = s, b[3] = o, Atomics.store(i, t, Ut[0]);
1538
- }
1539
- const Dt = new ArrayBuffer(4), xt = new Float32Array(Dt), Ft = new Int32Array(Dt);
1540
- function zt(i, t) {
1541
- return i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)), Q(Atomics.load(i, t));
1542
- }
1543
- function Ee(i, t, e) {
1544
- i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)), Atomics.store(i, t, $(e));
1545
- }
1546
- function Q(i) {
1547
- return Ft[0] = i, xt[0];
1548
- }
1549
- function $(i) {
1550
- return xt[0] = i, Ft[0];
1551
- }
1552
- function we(i, t, e) {
1553
- return i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)), Q(Atomics.exchange(i, t, $(e)));
1554
- }
1555
- function Rt(i, t, e, r) {
1556
- return i instanceof Float32Array && (i = new Int32Array(i.buffer, i.byteOffset, i.length)), Q(Atomics.compareExchange(i, t, $(e), $(r)));
1557
- }
1558
- function Le(i, t, e, r) {
1559
- let s, o;
1560
- do
1561
- s = Atomics.load(i, t), o = Math.min(s + e, r);
1562
- while (Atomics.compareExchange(i, t, s, o) !== s);
1563
- }
1564
- function Se(i, t, e, r) {
1565
- let s, o;
1566
- do
1567
- s = Atomics.load(i, t), o = Math.max(s - e, r);
1568
- while (Atomics.compareExchange(i, t, s, o) !== s);
1569
- }
1570
- function Te(i, t, e, r) {
1571
- let s, o;
1572
- do
1573
- s = zt(i, t), o = Math.min(s + e, r);
1574
- while (Rt(i, t, s, o) !== s);
1575
- }
1576
- function _e(i, t, e, r) {
1577
- let s, o;
1578
- do
1579
- s = zt(i, t), o = Math.max(s - e, r);
1580
- while (Rt(i, t, s, o) !== s);
1581
- }
1582
- const $t = new ArrayBuffer(8), Yt = new Float64Array($t), Ht = new BigInt64Array($t);
1583
- function Oe(i, t) {
1584
- return i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)), tt(Atomics.load(i, t));
1585
- }
1586
- function Me(i, t, e) {
1587
- i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)), Atomics.store(i, t, Y(e));
1588
- }
1589
- function tt(i) {
1590
- return Ht[0] = i, Yt[0];
1591
- }
1592
- function Y(i) {
1593
- return Yt[0] = i, Ht[0];
1594
- }
1595
- function Ce(i, t, e) {
1596
- return i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)), tt(Atomics.exchange(i, t, Y(e)));
1597
- }
1598
- function Ie(i, t, e, r) {
1599
- return i instanceof Float64Array && (i = new BigInt64Array(i.buffer, i.byteOffset, i.length)), tt(Atomics.compareExchange(i, t, Y(e), Y(r)));
1600
- }
1601
- const w = 0, J = 1, S = 2;
1602
- function Ne(i, t = 0) {
1603
- for (; Atomics.compareExchange(i, t, w, J) === S; )
1604
- Atomics.wait(i, t, S);
1605
- Atomics.add(i, t + 1, 1);
1606
- }
1607
- function Pe(i, t = 0) {
1608
- let e = Atomics.compareExchange(i, t, w, S);
1609
- for (; e !== w; )
1610
- Atomics.wait(i, t, e), e = Atomics.compareExchange(i, t, w, S);
1611
- }
1612
- function Ue(i, t = 0) {
1613
- Atomics.sub(i, t + 1, 1) - 1 <= 0 && (Atomics.compareExchange(i, t, J, w) !== J && console.warn("We are unlocking when it was not read locked!"), Atomics.notify(i, t));
1614
- }
1615
- function De(i, t = 0) {
1616
- Atomics.compareExchange(i, t, S, w) !== S && console.warn("We are unlocking when it was not write locked!"), Atomics.notify(i, t);
1617
- }
1618
- const xe = 2;
1619
- export {
1620
- h as AllocatedMemory,
1621
- he as BYTE_OFFSET_BIT_COUNT,
1622
- me as CachedItemList,
1623
- be as LocalPool,
1624
- et as MAX_BYTE_OFFSET_LENGTH,
1625
- rt as MAX_POSITION_LENGTH,
1626
- W as MemoryBuffer,
1627
- ye as MemoryHeap,
1628
- ce as POSITION_BIT_COUNT,
1629
- xe as READ_WRITE_LOCK_ALLOCATE_COUNT,
1630
- de as SIMPLE_LOCK_ALLOCATE_COUNT,
1631
- u as SharedList,
1632
- Ot as SharedMap,
1633
- Be as SharedPointerList,
1634
- Ct as SharedPool,
1635
- Mt as SharedString,
1636
- m as SharedVector,
1637
- Te as addAtomicFloat32,
1638
- Le as addAtomicInt,
1639
- Rt as compareExchangeFloat32,
1640
- Ie as compareExchangeFloat64,
1641
- fe as convert16To32,
1642
- le as convert32To16,
1643
- $ as convertFloat32ToInt32,
1644
- Y as convertFloat64ToInt64,
1645
- Q as convertInt32ToFloat32,
1646
- tt as convertInt64ToFloat64,
1647
- L as createPointer,
1648
- we as exchangeFloat32,
1649
- Ce as exchangeFloat64,
1650
- B as getPointer,
1651
- ge as load16From32,
1652
- Ae as load16From64,
1653
- zt as loadFloat32,
1654
- Oe as loadFloat64,
1655
- c as loadPointer,
1656
- O as loadRawPointer,
1657
- z as lock,
1658
- Ne as readLock,
1659
- Ue as readUnlock,
1660
- ue as replacePointer,
1661
- V as replaceRawPointer,
1662
- ke as store16In32,
1663
- pe as store16In64,
1664
- Ee as storeFloat32,
1665
- Me as storeFloat64,
1666
- k as storePointer,
1667
- x as storeRawPointer,
1668
- _e as subtractAtomicFloat,
1669
- Se as subtractAtomicInt,
1670
- g as unlock,
1671
- Pe as writeLock,
1672
- De as writeUnlock
1673
- };
1674
- //# sourceMappingURL=shared-memory-objects.js.map