@atolljs/core 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +10 -8
- package/dist/contract/listSchema.d.ts +4 -4
- package/dist/contract/reef.d.ts +377 -0
- package/dist/contract/sharedMemory.d.ts +13 -13
- package/dist/contract/zod.d.ts +263 -34
- package/dist/index.d.ts +1 -2
- package/dist/index.js +14 -15
- package/dist/index10.js +185 -14
- package/dist/index11.js +47 -188
- package/dist/index12.js +59 -45
- package/dist/index13.js +19 -58
- package/dist/index14.js +60 -24
- package/dist/index15.js +43 -56
- package/dist/index16.js +41 -45
- package/dist/index17.js +38 -42
- package/dist/index18.js +54 -35
- package/dist/index19.js +46 -51
- package/dist/index20.js +50 -47
- package/dist/index3.js +199 -22
- package/dist/index4.js +66 -61
- package/dist/index6.js +84 -84
- package/dist/index7.js +19 -19
- package/dist/index8.js +33 -6
- package/dist/index9.js +14 -29
- package/package.json +8 -6
- package/src/contract/listSchema.ts +51 -29
- package/src/contract/reef.ts +62 -0
- package/src/contract/sharedMemory.ts +25 -25
- package/src/contract/zod.ts +344 -32
- package/src/index.ts +1 -2
- package/dist/contract/msgpackCodec.d.ts +0 -7
- package/dist/contract/mz.d.ts +0 -43
- package/dist/index21.js +0 -59
- package/src/contract/msgpackCodec.ts +0 -9
- package/src/contract/mz.ts +0 -48
package/dist/index6.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { msgpackrCodec as e } from "./index2.js";
|
|
2
|
-
import {
|
|
3
|
-
import { memberToSpec as
|
|
4
|
-
import { fmtBytes as
|
|
2
|
+
import { fluent as t, z as n } from "./index3.js";
|
|
3
|
+
import { memberToSpec as r, zodArrayInfo as i, zodObjectShape as a, zodStringBytes as o } from "./index4.js";
|
|
4
|
+
import { fmtBytes as s, scoped as c } from "./index5.js";
|
|
5
5
|
//#region src/contract/sharedMemory.ts
|
|
6
|
-
var
|
|
7
|
-
function
|
|
6
|
+
var l = c("memory"), u = 8, d = (e, t) => e + t - 1 & ~(t - 1), f = (e) => d(e, u), p = (e) => typeof e == "object" && !!e && typeof e.kind == "string" && typeof e.byteLength == "number";
|
|
7
|
+
function m(e) {
|
|
8
8
|
let t = [];
|
|
9
|
-
for (let [n, r] of Object.entries(e)) if (
|
|
9
|
+
for (let [n, r] of Object.entries(e)) if (p(r)) t.push({
|
|
10
10
|
path: n,
|
|
11
11
|
descriptor: r
|
|
12
12
|
});
|
|
13
13
|
else for (let [e, i] of Object.entries(r)) {
|
|
14
|
-
if (!
|
|
14
|
+
if (!p(i)) throw TypeError(`shared memory "${n}.${e}" is not a field descriptor — intent groups nest one level only`);
|
|
15
15
|
t.push({
|
|
16
16
|
path: `${n}.${e}`,
|
|
17
17
|
descriptor: i
|
|
@@ -19,14 +19,14 @@ function p(e) {
|
|
|
19
19
|
}
|
|
20
20
|
return t;
|
|
21
21
|
}
|
|
22
|
-
var
|
|
23
|
-
encode: (e) =>
|
|
24
|
-
decode: (e) => JSON.parse(
|
|
25
|
-
},
|
|
26
|
-
function
|
|
27
|
-
|
|
22
|
+
var h = new TextEncoder(), g = new TextDecoder(), _ = {
|
|
23
|
+
encode: (e) => h.encode(JSON.stringify(e)),
|
|
24
|
+
decode: (e) => JSON.parse(g.decode(e))
|
|
25
|
+
}, v = /* @__PURE__ */ new Map();
|
|
26
|
+
function y(e, t) {
|
|
27
|
+
v.set(e, t);
|
|
28
28
|
}
|
|
29
|
-
var
|
|
29
|
+
var b = {
|
|
30
30
|
i8: 1,
|
|
31
31
|
u8: 1,
|
|
32
32
|
i16: 2,
|
|
@@ -37,20 +37,20 @@ var y = {
|
|
|
37
37
|
f64: 8,
|
|
38
38
|
i64: 8,
|
|
39
39
|
u64: 8
|
|
40
|
-
},
|
|
41
|
-
function
|
|
42
|
-
let t = {},
|
|
40
|
+
}, x = (e) => typeof e == "string" ? b[e] : "string" in e ? e.string : 1, S = (e) => typeof e == "string" ? b[e] : 1;
|
|
41
|
+
function C(e) {
|
|
42
|
+
let t = {}, n = {}, i = 0;
|
|
43
43
|
for (let a of Object.keys(e)) {
|
|
44
|
-
let o =
|
|
45
|
-
|
|
44
|
+
let o = r(e[a], String(a));
|
|
45
|
+
n[a] = o, i = d(i, S(o)), t[a] = i, i += x(o);
|
|
46
46
|
}
|
|
47
47
|
return {
|
|
48
|
-
layout:
|
|
48
|
+
layout: n,
|
|
49
49
|
offsets: t,
|
|
50
|
-
recordSize:
|
|
50
|
+
recordSize: f(i)
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
-
var
|
|
53
|
+
var w = {
|
|
54
54
|
number: () => ({
|
|
55
55
|
kind: "number",
|
|
56
56
|
byteLength: 8
|
|
@@ -66,20 +66,20 @@ var C = {
|
|
|
66
66
|
byteLength: 4 + n,
|
|
67
67
|
schema: t
|
|
68
68
|
};
|
|
69
|
-
let r = t ?
|
|
69
|
+
let r = t ? o(t) : null;
|
|
70
70
|
if (r !== null) return {
|
|
71
71
|
kind: "string",
|
|
72
72
|
byteLength: 4 + r,
|
|
73
73
|
schema: t
|
|
74
74
|
};
|
|
75
|
-
throw TypeError("field.string: pass { maxBytes } or a schema carrying a byte budget —
|
|
75
|
+
throw TypeError("field.string: pass { maxBytes } or a schema carrying a byte budget — reef.string(n) / z.string().meta({ bytes: n })");
|
|
76
76
|
},
|
|
77
77
|
object: (e) => {
|
|
78
78
|
let { schema: t, maxBytes: n } = e;
|
|
79
79
|
if (n === void 0 && t) {
|
|
80
|
-
let e =
|
|
80
|
+
let e = a(t);
|
|
81
81
|
if (e) {
|
|
82
|
-
let { layout: n, offsets: r, recordSize: i } =
|
|
82
|
+
let { layout: n, offsets: r, recordSize: i } = C(e);
|
|
83
83
|
return {
|
|
84
84
|
kind: "object",
|
|
85
85
|
byteLength: 8 + i,
|
|
@@ -99,33 +99,33 @@ var C = {
|
|
|
99
99
|
};
|
|
100
100
|
},
|
|
101
101
|
array: (e) => {
|
|
102
|
-
let { schema: t, maxBytes:
|
|
103
|
-
if (
|
|
104
|
-
let e =
|
|
102
|
+
let { schema: t, maxBytes: n } = e;
|
|
103
|
+
if (n === void 0 && t) {
|
|
104
|
+
let e = i(t);
|
|
105
105
|
if (e) {
|
|
106
106
|
if (e.capacity === null) throw TypeError("field.array: z.array() needs .max(n) or .length(n) — bounded arrays are fixed-width");
|
|
107
|
-
let
|
|
107
|
+
let n;
|
|
108
108
|
try {
|
|
109
|
-
|
|
109
|
+
n = r(e.element, "array element");
|
|
110
110
|
} catch (e) {
|
|
111
111
|
throw TypeError(`field.array: element isn't a fixed-width member — use field.list for arrays of records (${e.message})`);
|
|
112
112
|
}
|
|
113
|
-
let i =
|
|
113
|
+
let i = d(x(n), S(n));
|
|
114
114
|
return {
|
|
115
115
|
kind: "array",
|
|
116
116
|
byteLength: 8 + e.capacity * i,
|
|
117
117
|
schema: t,
|
|
118
|
-
element:
|
|
118
|
+
element: n,
|
|
119
119
|
elementStride: i,
|
|
120
120
|
capacity: e.capacity
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
123
|
throw TypeError("field.array: schema can't derive a fixed byte width (not a bounded zod array) — pass { maxBytes } for codec-encoded storage");
|
|
124
124
|
}
|
|
125
|
-
if (
|
|
125
|
+
if (n === void 0) throw TypeError("field.array: pass { schema } for a fixed-layout field or { maxBytes } for a codec-encoded field");
|
|
126
126
|
return {
|
|
127
127
|
kind: "array",
|
|
128
|
-
byteLength: 4 +
|
|
128
|
+
byteLength: 4 + n,
|
|
129
129
|
schema: t
|
|
130
130
|
};
|
|
131
131
|
},
|
|
@@ -146,26 +146,26 @@ var C = {
|
|
|
146
146
|
byteLength: e
|
|
147
147
|
}),
|
|
148
148
|
list: ({ schema: e, count: t }) => {
|
|
149
|
-
let n =
|
|
150
|
-
if (!n) throw TypeError("field.list: schema must be
|
|
151
|
-
let { layout: r, offsets:
|
|
149
|
+
let n = a(e);
|
|
150
|
+
if (!n) throw TypeError("field.list: schema must be a reef.object() of fixed-width members");
|
|
151
|
+
let { layout: r, offsets: i, recordSize: o } = C(n);
|
|
152
152
|
return {
|
|
153
153
|
kind: "list",
|
|
154
154
|
byteLength: o * t,
|
|
155
155
|
schema: e,
|
|
156
156
|
layout: r,
|
|
157
|
-
offsets:
|
|
157
|
+
offsets: i,
|
|
158
158
|
recordSize: o,
|
|
159
159
|
count: t
|
|
160
160
|
};
|
|
161
161
|
}
|
|
162
|
-
},
|
|
162
|
+
}, T = {
|
|
163
163
|
Int32: Int32Array,
|
|
164
164
|
Float64: Float64Array,
|
|
165
165
|
BigInt64: BigInt64Array,
|
|
166
166
|
Uint8: Uint8Array
|
|
167
167
|
};
|
|
168
|
-
|
|
168
|
+
y("number", (e, t, n) => {
|
|
169
169
|
let r = new Float64Array(t.buffer, n, 1);
|
|
170
170
|
return {
|
|
171
171
|
byteOffset: n,
|
|
@@ -175,7 +175,7 @@ v("number", (e, t, n) => {
|
|
|
175
175
|
r[0] = e;
|
|
176
176
|
}
|
|
177
177
|
};
|
|
178
|
-
}),
|
|
178
|
+
}), y("boolean", (e, t, n) => {
|
|
179
179
|
let r = new Uint8Array(t.buffer, n, 1);
|
|
180
180
|
return {
|
|
181
181
|
byteOffset: n,
|
|
@@ -186,8 +186,8 @@ v("number", (e, t, n) => {
|
|
|
186
186
|
}
|
|
187
187
|
};
|
|
188
188
|
});
|
|
189
|
-
for (let e of Object.keys(
|
|
190
|
-
let i =
|
|
189
|
+
for (let e of Object.keys(T)) y(e, (t, n, r) => {
|
|
190
|
+
let i = T[e], a = new i(n.buffer, r, t.byteLength / i.BYTES_PER_ELEMENT);
|
|
191
191
|
return {
|
|
192
192
|
byteOffset: r,
|
|
193
193
|
byteLength: t.byteLength,
|
|
@@ -195,7 +195,7 @@ for (let e of Object.keys(w)) v(e, (t, n, r) => {
|
|
|
195
195
|
write: (e) => a.set(e)
|
|
196
196
|
};
|
|
197
197
|
});
|
|
198
|
-
|
|
198
|
+
y("string", (e, t, n) => {
|
|
199
199
|
let r = new TextEncoder(), i = new TextDecoder(), a = e.byteLength - 4, o = new Uint32Array(t.buffer, n, 1), s = (e) => {
|
|
200
200
|
if (e.byteLength > a) throw Error(`Encoded value of ${e.byteLength} bytes exceeds field capacity of ${a} bytes at offset ${n}`);
|
|
201
201
|
o[0] = e.byteLength, new Uint8Array(t.buffer, n + 4, e.byteLength).set(e);
|
|
@@ -207,7 +207,7 @@ v("string", (e, t, n) => {
|
|
|
207
207
|
write: (t) => s(r.encode(e.schema ? e.schema.parse(t) : t))
|
|
208
208
|
};
|
|
209
209
|
});
|
|
210
|
-
function
|
|
210
|
+
function E(e) {
|
|
211
211
|
let t = new DataView(e.buffer), n = new Uint8Array(e.buffer), r = new TextEncoder(), i = new TextDecoder(), a = {
|
|
212
212
|
i8: {
|
|
213
213
|
get: (e) => t.getInt8(e),
|
|
@@ -298,10 +298,10 @@ function T(e) {
|
|
|
298
298
|
}
|
|
299
299
|
};
|
|
300
300
|
}
|
|
301
|
-
var
|
|
301
|
+
var D = (e, t, n) => {
|
|
302
302
|
let { schema: r, byteLength: i, kind: a } = e, o = e;
|
|
303
303
|
if (o.layout && o.offsets && o.recordSize !== void 0) {
|
|
304
|
-
let e = new Uint32Array(t.buffer, n, 2), a = n + 8, s =
|
|
304
|
+
let e = new Uint32Array(t.buffer, n, 2), a = n + 8, s = E(t).compile(o.layout, o.offsets);
|
|
305
305
|
return {
|
|
306
306
|
byteOffset: n,
|
|
307
307
|
byteLength: i,
|
|
@@ -312,7 +312,7 @@ var E = (e, t, n) => {
|
|
|
312
312
|
};
|
|
313
313
|
}
|
|
314
314
|
if (o.element !== void 0 && o.elementStride !== void 0 && o.capacity !== void 0) {
|
|
315
|
-
let e = new Uint32Array(t.buffer, n, 1), a = new Uint32Array(t.buffer, n + 4, 1), s =
|
|
315
|
+
let e = new Uint32Array(t.buffer, n, 1), a = new Uint32Array(t.buffer, n + 4, 1), s = E(t).ops(o.element), c = o.elementStride, l = o.capacity, u = n + 8;
|
|
316
316
|
return {
|
|
317
317
|
byteOffset: n,
|
|
318
318
|
byteLength: i,
|
|
@@ -344,9 +344,9 @@ var E = (e, t, n) => {
|
|
|
344
344
|
write: (e) => l(t.codec.encode(r ? r.parse(e) : e))
|
|
345
345
|
};
|
|
346
346
|
};
|
|
347
|
-
|
|
348
|
-
function
|
|
349
|
-
let r = e, { offsets: i, recordSize: a, count: o } = r, s =
|
|
347
|
+
y("object", D), y("array", D);
|
|
348
|
+
function O(e, t, n) {
|
|
349
|
+
let r = e, { offsets: i, recordSize: a, count: o } = r, s = E(t).compile(r.layout, i), c = (e) => {
|
|
350
350
|
if (e < 0 || e >= o) throw RangeError(`Record index ${e} out of bounds (0..${o - 1})`);
|
|
351
351
|
}, l = (e, t = {}, r) => (c(e), s.read(n + e * a, t, r)), u = (e, t, r) => {
|
|
352
352
|
c(e), s.write(n + e * a, t, r);
|
|
@@ -368,27 +368,27 @@ function D(e, t, n) {
|
|
|
368
368
|
}
|
|
369
369
|
};
|
|
370
370
|
}
|
|
371
|
-
|
|
372
|
-
var
|
|
373
|
-
function
|
|
371
|
+
y("list", O);
|
|
372
|
+
var k = [];
|
|
373
|
+
function A(e) {
|
|
374
374
|
let t = {};
|
|
375
|
-
for (let [n, r] of Object.entries(e)) t[n] =
|
|
375
|
+
for (let [n, r] of Object.entries(e)) t[n] = p(r) ? j(r) : Object.fromEntries(Object.entries(r).map(([e, t]) => [e, j(t)]));
|
|
376
376
|
return t;
|
|
377
377
|
}
|
|
378
|
-
function
|
|
378
|
+
function j(e) {
|
|
379
379
|
if (e.schema) return e.schema;
|
|
380
380
|
switch (e.kind) {
|
|
381
|
-
case "number": return t.number();
|
|
382
|
-
case "boolean": return t.boolean();
|
|
383
|
-
case "string": return t.string();
|
|
384
|
-
case "Int32": return t.instanceof(Int32Array);
|
|
385
|
-
case "Float64": return t.instanceof(Float64Array);
|
|
386
|
-
case "BigInt64": return t.instanceof(BigInt64Array);
|
|
387
|
-
case "Uint8": return t.instanceof(Uint8Array);
|
|
388
|
-
default: return t.unknown();
|
|
381
|
+
case "number": return t(n.number());
|
|
382
|
+
case "boolean": return t(n.boolean());
|
|
383
|
+
case "string": return t(n.string());
|
|
384
|
+
case "Int32": return t(n.instanceof(Int32Array));
|
|
385
|
+
case "Float64": return t(n.instanceof(Float64Array));
|
|
386
|
+
case "BigInt64": return t(n.instanceof(BigInt64Array));
|
|
387
|
+
case "Uint8": return t(n.instanceof(Uint8Array));
|
|
388
|
+
default: return t(n.unknown());
|
|
389
389
|
}
|
|
390
390
|
}
|
|
391
|
-
var
|
|
391
|
+
var M = class {
|
|
392
392
|
totalBytes;
|
|
393
393
|
spec;
|
|
394
394
|
schemas;
|
|
@@ -402,11 +402,11 @@ var j = class {
|
|
|
402
402
|
isBound = !1;
|
|
403
403
|
boundBuffer;
|
|
404
404
|
constructor(t, n = {}) {
|
|
405
|
-
this.spec = t, this.codec = n.codec ?? e, this.plugins = n.plugins, this.entries =
|
|
405
|
+
this.spec = t, this.codec = n.codec ?? e, this.plugins = n.plugins, this.entries = m(t), this.schemas = A(t);
|
|
406
406
|
let r = 0;
|
|
407
|
-
for (let { path: e, descriptor: t } of this.entries) r =
|
|
408
|
-
this.versionOffset =
|
|
409
|
-
fields: Object.fromEntries(this.entries.map((e) => [e.path, `${e.descriptor.kind}@${this.offsets.get(e.path)?.toLocaleString()}+${
|
|
407
|
+
for (let { path: e, descriptor: t } of this.entries) r = f(r), this.offsets.set(e, r), r += t.byteLength;
|
|
408
|
+
this.versionOffset = f(r), this.totalBytes = this.versionOffset + f(this.entries.length * 4), k.push(this), l.info(`contract defined: ${this.entries.length} field(s), ${s(this.totalBytes)}`, {
|
|
409
|
+
fields: Object.fromEntries(this.entries.map((e) => [e.path, `${e.descriptor.kind}@${this.offsets.get(e.path)?.toLocaleString()}+${s(e.descriptor.byteLength)}`])),
|
|
410
410
|
pluginOverrides: Object.keys(this.plugins ?? {})
|
|
411
411
|
});
|
|
412
412
|
}
|
|
@@ -414,10 +414,10 @@ var j = class {
|
|
|
414
414
|
this.connectors.clear();
|
|
415
415
|
let t = new Int32Array(e, this.versionOffset, this.entries.length);
|
|
416
416
|
this.entries.forEach(({ path: n, descriptor: r }, i) => {
|
|
417
|
-
let a = this.plugins?.[r.kind] ??
|
|
417
|
+
let a = this.plugins?.[r.kind] ?? v.get(r.kind);
|
|
418
418
|
if (!a) throw Error(`Unknown shared memory field kind: ${r.kind}`);
|
|
419
|
-
|
|
420
|
-
let
|
|
419
|
+
l.debug(`bind "${n}" (${r.kind}, ${s(r.byteLength)}) via ${this.plugins?.[r.kind] ? "plugin" : "built-in"} factory`);
|
|
420
|
+
let o = a(r, {
|
|
421
421
|
buffer: e,
|
|
422
422
|
codec: this.codec,
|
|
423
423
|
version: {
|
|
@@ -426,9 +426,9 @@ var j = class {
|
|
|
426
426
|
}
|
|
427
427
|
}, this.offsets.get(n));
|
|
428
428
|
this.connectors.set(n, {
|
|
429
|
-
...
|
|
429
|
+
...o,
|
|
430
430
|
write: (e) => {
|
|
431
|
-
|
|
431
|
+
o.write(e), Atomics.add(t, i, 1), Atomics.notify(t, i);
|
|
432
432
|
},
|
|
433
433
|
_version: {
|
|
434
434
|
view: t,
|
|
@@ -461,9 +461,9 @@ var j = class {
|
|
|
461
461
|
return n;
|
|
462
462
|
}
|
|
463
463
|
};
|
|
464
|
-
function
|
|
465
|
-
let n = new
|
|
466
|
-
for (let [t, r] of Object.entries(e)) if (
|
|
464
|
+
function N(e, t = {}) {
|
|
465
|
+
let n = new M(e, t);
|
|
466
|
+
for (let [t, r] of Object.entries(e)) if (p(r)) Object.defineProperty(n, t, {
|
|
467
467
|
enumerable: !0,
|
|
468
468
|
get: () => n.connector(t)
|
|
469
469
|
});
|
|
@@ -480,14 +480,14 @@ function M(e, t = {}) {
|
|
|
480
480
|
}
|
|
481
481
|
return n;
|
|
482
482
|
}
|
|
483
|
-
function
|
|
484
|
-
for (let t of
|
|
485
|
-
|
|
483
|
+
function P(e) {
|
|
484
|
+
for (let t of k) t.bind(e);
|
|
485
|
+
l.info(`bound ${k.length} contract(s) — ${s(e.byteLength)} buffer`);
|
|
486
486
|
}
|
|
487
|
-
function
|
|
488
|
-
return
|
|
487
|
+
function F() {
|
|
488
|
+
return k.length;
|
|
489
489
|
}
|
|
490
490
|
//#endregion
|
|
491
|
-
export {
|
|
491
|
+
export { M as SharedMemory, P as bindSharedMemories, N as defineSharedMemory, w as field, F as getDefinedSharedMemoryCount, _ as jsonCodec, y as registerConnectorFactory };
|
|
492
492
|
|
|
493
493
|
//# sourceMappingURL=index6.js.map
|
package/dist/index7.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
//#region src/contract/
|
|
3
|
-
var
|
|
4
|
-
i8: () => e.number().int().
|
|
5
|
-
u8: () => e.number().int().
|
|
6
|
-
i16: () => e.number().int().
|
|
7
|
-
u16: () => e.number().int().
|
|
8
|
-
i32: () => e.int32(),
|
|
9
|
-
u32: () => e.uint32(),
|
|
10
|
-
f32: () => e.float32(),
|
|
11
|
-
f64: () => e.float64(),
|
|
12
|
-
i64: () => e.int64(),
|
|
13
|
-
u64: () => e.uint64(),
|
|
14
|
-
int: (
|
|
15
|
-
boolean: () => e.boolean(),
|
|
16
|
-
string: (
|
|
17
|
-
object: (
|
|
18
|
-
array: (
|
|
1
|
+
import { fluent as e, z as t } from "./index3.js";
|
|
2
|
+
//#region src/contract/reef.ts
|
|
3
|
+
var n = new TextEncoder(), r = {
|
|
4
|
+
i8: () => e(t.number().check(t.int(), t.gte(-128), t.lte(127))),
|
|
5
|
+
u8: () => e(t.number().check(t.int(), t.gte(0), t.lte(255))),
|
|
6
|
+
i16: () => e(t.number().check(t.int(), t.gte(-32768), t.lte(32767))),
|
|
7
|
+
u16: () => e(t.number().check(t.int(), t.gte(0), t.lte(65535))),
|
|
8
|
+
i32: () => e(t.int32()),
|
|
9
|
+
u32: () => e(t.uint32()),
|
|
10
|
+
f32: () => e(t.float32()),
|
|
11
|
+
f64: () => e(t.float64()),
|
|
12
|
+
i64: () => e(t.int64()),
|
|
13
|
+
u64: () => e(t.uint64()),
|
|
14
|
+
int: (n, r) => e(t.number().check(t.int(), t.gte(n), t.lte(r))),
|
|
15
|
+
boolean: () => e(t.boolean()),
|
|
16
|
+
string: (r) => e(t.string().check(t.refine((e) => n.encode(e).byteLength <= r, `exceeds ${r} UTF-8 bytes`)).register(t.globalRegistry, { bytes: r })),
|
|
17
|
+
object: (n) => e(t.object(n)),
|
|
18
|
+
array: (n) => e(t.array(n))
|
|
19
19
|
};
|
|
20
20
|
//#endregion
|
|
21
|
-
export {
|
|
21
|
+
export { r as reef };
|
|
22
22
|
|
|
23
23
|
//# sourceMappingURL=index7.js.map
|
package/dist/index8.js
CHANGED
|
@@ -1,10 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
//#region src/pool/memory.ts
|
|
2
|
+
var e = class {
|
|
3
|
+
memory;
|
|
4
|
+
maxPages;
|
|
5
|
+
constructor(e = {}) {
|
|
6
|
+
let t = e.initialPages ?? 16;
|
|
7
|
+
this.maxPages = e.maximumPages ?? 16384, this.memory = new WebAssembly.Memory({
|
|
8
|
+
initial: t,
|
|
9
|
+
maximum: this.maxPages,
|
|
10
|
+
shared: !0
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
ensureCapacity(e) {
|
|
14
|
+
let t = this.memory.buffer.byteLength;
|
|
15
|
+
if (t >= e) return;
|
|
16
|
+
let n = e - t, r = Math.ceil(n / 65536);
|
|
17
|
+
if (this.memory.buffer.byteLength / 65536 + r > this.maxPages) throw Error(`Cannot grow memory: exceeds maximum page limit of ${this.maxPages}`);
|
|
18
|
+
this.memory.grow(r);
|
|
19
|
+
}
|
|
20
|
+
getView(e, t = 0, n) {
|
|
21
|
+
let r = this.memory.buffer;
|
|
22
|
+
switch (e) {
|
|
23
|
+
case "Int32": return new Int32Array(r, t, n);
|
|
24
|
+
case "Float64": return new Float64Array(r, t, n);
|
|
25
|
+
case "BigInt64": return new BigInt64Array(r, t, n);
|
|
26
|
+
case "Uint8": return new Uint8Array(r, t, n);
|
|
27
|
+
default: throw Error(`Unsupported view type: ${e}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
getBuffer() {
|
|
31
|
+
return this.memory.buffer;
|
|
32
|
+
}
|
|
6
33
|
};
|
|
7
34
|
//#endregion
|
|
8
|
-
export {
|
|
35
|
+
export { e as MemoryManager };
|
|
9
36
|
|
|
10
37
|
//# sourceMappingURL=index8.js.map
|
package/dist/index9.js
CHANGED
|
@@ -1,37 +1,22 @@
|
|
|
1
|
-
//#region src/pool/
|
|
2
|
-
var e = class {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
constructor(e = {}) {
|
|
6
|
-
let t = e.initialPages ?? 16;
|
|
7
|
-
this.maxPages = e.maximumPages ?? 16384, this.memory = new WebAssembly.Memory({
|
|
8
|
-
initial: t,
|
|
9
|
-
maximum: this.maxPages,
|
|
10
|
-
shared: !0
|
|
11
|
-
});
|
|
1
|
+
//#region src/pool/errors.ts
|
|
2
|
+
var e = class extends Error {
|
|
3
|
+
constructor(e = "WorkerPool task queue is full") {
|
|
4
|
+
super(e), this.name = "PoolQueueFullError";
|
|
12
5
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
let n = e - t, r = Math.ceil(n / 65536);
|
|
17
|
-
if (this.memory.buffer.byteLength / 65536 + r > this.maxPages) throw Error(`Cannot grow memory: exceeds maximum page limit of ${this.maxPages}`);
|
|
18
|
-
this.memory.grow(r);
|
|
6
|
+
}, t = class extends Error {
|
|
7
|
+
constructor(e = "task aborted") {
|
|
8
|
+
super(e), this.name = "AbortError";
|
|
19
9
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
case "Int32": return new Int32Array(r, t, n);
|
|
24
|
-
case "Float64": return new Float64Array(r, t, n);
|
|
25
|
-
case "BigInt64": return new BigInt64Array(r, t, n);
|
|
26
|
-
case "Uint8": return new Uint8Array(r, t, n);
|
|
27
|
-
default: throw Error(`Unsupported view type: ${e}`);
|
|
28
|
-
}
|
|
10
|
+
}, n = class extends Error {
|
|
11
|
+
constructor(e = "task timed out") {
|
|
12
|
+
super(e), this.name = "TaskTimeoutError";
|
|
29
13
|
}
|
|
30
|
-
|
|
31
|
-
|
|
14
|
+
}, r = class extends Error {
|
|
15
|
+
constructor(e = "worker crashed") {
|
|
16
|
+
super(e), this.name = "WorkerCrashedError";
|
|
32
17
|
}
|
|
33
18
|
};
|
|
34
19
|
//#endregion
|
|
35
|
-
export { e as
|
|
20
|
+
export { e as PoolQueueFullError, t as TaskAbortedError, n as TaskTimeoutError, r as WorkerCrashedError };
|
|
36
21
|
|
|
37
22
|
//# sourceMappingURL=index9.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atolljs/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Typed shared-memory worker pools — defineWorker/connectWorker, SharedArrayBuffer contracts, cross-thread reactivity",
|
|
5
5
|
"homepage": "https://jwhenry3.github.io/atolljs/consumer/quickstart/",
|
|
6
6
|
"type": "module",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"scripts": {
|
|
28
28
|
"dev:all": "node scripts/dev-all.mjs",
|
|
29
29
|
"kill:all": "node scripts/kill-all.mjs",
|
|
30
|
+
"atoll": "node packages/cli/src/cli.ts",
|
|
30
31
|
"serve:all": "node scripts/serve-all.mjs",
|
|
31
32
|
"build": "tsc --noEmit && vite build",
|
|
32
33
|
"test": "vitest run",
|
|
@@ -49,6 +50,7 @@
|
|
|
49
50
|
"@types/react-dom": "^19.3.0",
|
|
50
51
|
"@vitejs/plugin-vue": "^6.0.9",
|
|
51
52
|
"@vitest/coverage-v8": "^4.1.11",
|
|
53
|
+
"esbuild": "0.28.2",
|
|
52
54
|
"fast-json-stringify": "^7.0.1",
|
|
53
55
|
"happy-dom": "^20.14.5",
|
|
54
56
|
"htmlparser2": "^12.0.0",
|
|
@@ -61,13 +63,12 @@
|
|
|
61
63
|
"typescript": "^7.0.2",
|
|
62
64
|
"vite": "^8.3.1",
|
|
63
65
|
"vitest": "^4.1.11",
|
|
64
|
-
"vue": "^3.5.43"
|
|
66
|
+
"vue": "^3.5.43",
|
|
67
|
+
"zod": "^4.6.5"
|
|
65
68
|
},
|
|
66
69
|
"dependencies": {
|
|
67
|
-
"@msgpack/msgpack": "^3.1.3",
|
|
68
70
|
"msgpackr": "^2.1.0",
|
|
69
|
-
"solid-js": "^1.9.15"
|
|
70
|
-
"zod": "^4.6.5"
|
|
71
|
+
"solid-js": "^1.9.15"
|
|
71
72
|
},
|
|
72
73
|
"repository": {
|
|
73
74
|
"type": "git",
|
|
@@ -79,5 +80,6 @@
|
|
|
79
80
|
},
|
|
80
81
|
"bugs": {
|
|
81
82
|
"url": "https://github.com/jwhenry3/atolljs/issues"
|
|
82
|
-
}
|
|
83
|
+
},
|
|
84
|
+
"license": "MIT"
|
|
83
85
|
}
|