@atolljs/core 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/contract/reef.d.ts +88 -28
- package/dist/contract/sharedMemory.d.ts +2 -0
- package/dist/contract/types.d.ts +2 -0
- package/dist/contract/zod.d.ts +114 -14
- package/dist/devtools.d.ts +223 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +19 -17
- package/dist/index10.js +14 -185
- package/dist/index11.js +310 -47
- package/dist/index12.js +46 -59
- package/dist/index13.js +59 -20
- package/dist/index14.js +24 -60
- package/dist/index15.js +56 -43
- package/dist/index16.js +44 -50
- package/dist/index17.js +52 -38
- package/dist/index18.js +36 -54
- package/dist/index19.js +81 -47
- package/dist/index20.js +48 -51
- package/dist/index21.js +57 -0
- package/dist/index3.js +101 -41
- package/dist/index5.js +156 -35
- package/dist/index6.js +32 -485
- package/dist/index7.js +508 -19
- package/dist/index8.js +19 -33
- package/dist/index9.js +29 -14
- package/dist/pool/workerClient.d.ts +2 -0
- package/dist/pool/workerPool.d.ts +4 -0
- package/package.json +1 -1
- package/src/contract/sharedMemory.ts +19 -3
- package/src/contract/types.ts +2 -0
- package/src/contract/zod.ts +130 -14
- package/src/devtools.ts +490 -0
- package/src/index.ts +16 -0
- package/src/pool/workerClient.ts +3 -0
- package/src/pool/workerPool.ts +56 -7
- package/src/reactive.ts +107 -42
- package/src/worker/workerBootstrap.ts +3 -0
package/dist/contract/reef.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ import { z } from './zod.js';
|
|
|
24
24
|
* `_zod.def`, so `reef.object({ id: z.uint32() })` mixes freely.
|
|
25
25
|
*/
|
|
26
26
|
export declare const reef: {
|
|
27
|
-
i8: () => import("./zod.js").Fluent<{
|
|
27
|
+
i8: () => import("./zod.js").Fluent<import("./zod.js").Fluent<{
|
|
28
28
|
readonly _zod: {
|
|
29
29
|
output: number;
|
|
30
30
|
input: number;
|
|
@@ -43,8 +43,8 @@ export declare const reef: {
|
|
|
43
43
|
};
|
|
44
44
|
check(...checks: import("./zod.js").Check[]): /*elided*/ any;
|
|
45
45
|
register(registry: import("./zod.js").Registry, meta: Record<string, unknown>): /*elided*/ any;
|
|
46
|
-
}
|
|
47
|
-
u8: () => import("./zod.js").Fluent<{
|
|
46
|
+
}>>;
|
|
47
|
+
u8: () => import("./zod.js").Fluent<import("./zod.js").Fluent<{
|
|
48
48
|
readonly _zod: {
|
|
49
49
|
output: number;
|
|
50
50
|
input: number;
|
|
@@ -63,8 +63,8 @@ export declare const reef: {
|
|
|
63
63
|
};
|
|
64
64
|
check(...checks: import("./zod.js").Check[]): any;
|
|
65
65
|
register(registry: import("./zod.js").Registry, meta: Record<string, unknown>): any;
|
|
66
|
-
}
|
|
67
|
-
i16: () => import("./zod.js").Fluent<{
|
|
66
|
+
}>>;
|
|
67
|
+
i16: () => import("./zod.js").Fluent<import("./zod.js").Fluent<{
|
|
68
68
|
readonly _zod: {
|
|
69
69
|
output: number;
|
|
70
70
|
input: number;
|
|
@@ -83,8 +83,8 @@ export declare const reef: {
|
|
|
83
83
|
};
|
|
84
84
|
check(...checks: import("./zod.js").Check[]): any;
|
|
85
85
|
register(registry: import("./zod.js").Registry, meta: Record<string, unknown>): any;
|
|
86
|
-
}
|
|
87
|
-
u16: () => import("./zod.js").Fluent<{
|
|
86
|
+
}>>;
|
|
87
|
+
u16: () => import("./zod.js").Fluent<import("./zod.js").Fluent<{
|
|
88
88
|
readonly _zod: {
|
|
89
89
|
output: number;
|
|
90
90
|
input: number;
|
|
@@ -103,7 +103,7 @@ export declare const reef: {
|
|
|
103
103
|
};
|
|
104
104
|
check(...checks: import("./zod.js").Check[]): any;
|
|
105
105
|
register(registry: import("./zod.js").Registry, meta: Record<string, unknown>): any;
|
|
106
|
-
}
|
|
106
|
+
}>>;
|
|
107
107
|
i32: () => import("./zod.js").Fluent<{
|
|
108
108
|
readonly _zod: {
|
|
109
109
|
output: number;
|
|
@@ -225,7 +225,7 @@ export declare const reef: {
|
|
|
225
225
|
register(registry: import("./zod.js").Registry, meta: Record<string, unknown>): any;
|
|
226
226
|
}>;
|
|
227
227
|
/** Bounded int — compiles to the narrowest covering kind (0..3 → u8). */
|
|
228
|
-
int: (min: number, max: number) => import("./zod.js").Fluent<{
|
|
228
|
+
int: (min: number, max: number) => import("./zod.js").Fluent<import("./zod.js").Fluent<{
|
|
229
229
|
readonly _zod: {
|
|
230
230
|
output: number;
|
|
231
231
|
input: number;
|
|
@@ -244,9 +244,9 @@ export declare const reef: {
|
|
|
244
244
|
};
|
|
245
245
|
check(...checks: import("./zod.js").Check[]): /*elided*/ any;
|
|
246
246
|
register(registry: import("./zod.js").Registry, meta: Record<string, unknown>): /*elided*/ any;
|
|
247
|
-
}
|
|
247
|
+
}>>;
|
|
248
248
|
/** A flag byte — reads and writes as boolean. */
|
|
249
|
-
boolean: () => import("./zod.js").Fluent<{
|
|
249
|
+
boolean: () => import("./zod.js").Fluent<import("./zod.js").Fluent<{
|
|
250
250
|
readonly _zod: {
|
|
251
251
|
output: boolean;
|
|
252
252
|
input: boolean;
|
|
@@ -265,11 +265,11 @@ export declare const reef: {
|
|
|
265
265
|
};
|
|
266
266
|
check(...checks: import("./zod.js").Check[]): /*elided*/ any;
|
|
267
267
|
register(registry: import("./zod.js").Registry, meta: Record<string, unknown>): /*elided*/ any;
|
|
268
|
-
}
|
|
268
|
+
}>>;
|
|
269
269
|
/** Fixed-capacity inline UTF-8 string — `bytes` is the byte budget. The
|
|
270
270
|
* schema itself refuses over-budget values, so `.parse` and connector
|
|
271
271
|
* writes enforce the same limit. */
|
|
272
|
-
string: (bytes: number) => import("./zod.js").Fluent<{
|
|
272
|
+
string: (bytes: number) => import("./zod.js").Fluent<import("./zod.js").Fluent<{
|
|
273
273
|
readonly _zod: {
|
|
274
274
|
output: string;
|
|
275
275
|
input: string;
|
|
@@ -288,52 +288,112 @@ export declare const reef: {
|
|
|
288
288
|
};
|
|
289
289
|
check(...checks: import("./zod.js").Check[]): /*elided*/ any;
|
|
290
290
|
register(registry: import("./zod.js").Registry, meta: Record<string, unknown>): /*elided*/ any;
|
|
291
|
-
}
|
|
291
|
+
}>>;
|
|
292
292
|
/** A fixed-layout record shape — every member must be a fixed-width schema. */
|
|
293
|
-
object: <S extends z.ZodRawShape>(shape: S) => import("./zod.js").Fluent<{
|
|
293
|
+
object: <S extends z.ZodRawShape>(shape: S) => import("./zod.js").Fluent<import("./zod.js").Fluent<{
|
|
294
294
|
readonly _zod: {
|
|
295
|
-
output: { [K in keyof S
|
|
295
|
+
output: { [K in keyof S as (S[K] extends {
|
|
296
|
+
_zod: {
|
|
297
|
+
output: infer O;
|
|
298
|
+
};
|
|
299
|
+
} ? undefined extends O ? true : false : false) extends true ? never : K]: S[K] extends infer T_1 ? T_1 extends S[K] ? T_1 extends {
|
|
300
|
+
_zod: {
|
|
301
|
+
output: infer O_1;
|
|
302
|
+
};
|
|
303
|
+
} ? O_1 : never : never : never; } & { [K in keyof S as (S[K] extends {
|
|
296
304
|
_zod: {
|
|
297
305
|
output: infer O;
|
|
298
306
|
};
|
|
299
|
-
} ? O : never
|
|
300
|
-
|
|
307
|
+
} ? undefined extends O ? true : false : false) extends true ? K : never]?: (S[K] extends infer T_1 ? T_1 extends S[K] ? T_1 extends {
|
|
308
|
+
_zod: {
|
|
309
|
+
output: infer O_1;
|
|
310
|
+
};
|
|
311
|
+
} ? O : never : never : never) | undefined; } extends infer T ? { [K in keyof T]: T[K]; } : never;
|
|
312
|
+
input: { [K in keyof S as (S[K] extends {
|
|
301
313
|
_zod: {
|
|
302
314
|
output: infer O;
|
|
303
315
|
};
|
|
304
|
-
} ? O : never
|
|
316
|
+
} ? undefined extends O ? true : false : false) extends true ? never : K]: S[K] extends infer T_1 ? T_1 extends S[K] ? T_1 extends {
|
|
317
|
+
_zod: {
|
|
318
|
+
output: infer O_1;
|
|
319
|
+
};
|
|
320
|
+
} ? O_1 : never : never : never; } & { [K in keyof S as (S[K] extends {
|
|
321
|
+
_zod: {
|
|
322
|
+
output: infer O;
|
|
323
|
+
};
|
|
324
|
+
} ? undefined extends O ? true : false : false) extends true ? K : never]?: (S[K] extends infer T_1 ? T_1 extends S[K] ? T_1 extends {
|
|
325
|
+
_zod: {
|
|
326
|
+
output: infer O_1;
|
|
327
|
+
};
|
|
328
|
+
} ? O : never : never : never) | undefined; } extends infer T ? { [K in keyof T]: T[K]; } : never;
|
|
305
329
|
def: import("./zod.js").SchemaDef & {
|
|
306
330
|
type: 'object';
|
|
307
331
|
shape: S;
|
|
308
332
|
};
|
|
309
333
|
};
|
|
310
334
|
get shape(): S;
|
|
311
|
-
inner(v: unknown): { [K in keyof S
|
|
335
|
+
inner(v: unknown): { [K in keyof S as (S[K] extends {
|
|
336
|
+
_zod: {
|
|
337
|
+
output: infer O;
|
|
338
|
+
};
|
|
339
|
+
} ? undefined extends O ? true : false : false) extends true ? never : K]: S[K] extends infer T_1 ? T_1 extends S[K] ? T_1 extends {
|
|
340
|
+
_zod: {
|
|
341
|
+
output: infer O_1;
|
|
342
|
+
};
|
|
343
|
+
} ? O_1 : never : never : never; } & { [K in keyof S as (S[K] extends {
|
|
312
344
|
_zod: {
|
|
313
345
|
output: infer O;
|
|
314
346
|
};
|
|
315
|
-
} ? O : never
|
|
316
|
-
|
|
347
|
+
} ? undefined extends O ? true : false : false) extends true ? K : never]?: (S[K] extends infer T_1 ? T_1 extends S[K] ? T_1 extends {
|
|
348
|
+
_zod: {
|
|
349
|
+
output: infer O_1;
|
|
350
|
+
};
|
|
351
|
+
} ? O : never : never : never) | undefined; } extends infer T ? { [K in keyof T]: T[K]; } : never;
|
|
352
|
+
parse(value: unknown): { [K in keyof S as (S[K] extends {
|
|
353
|
+
_zod: {
|
|
354
|
+
output: infer O;
|
|
355
|
+
};
|
|
356
|
+
} ? undefined extends O ? true : false : false) extends true ? never : K]: S[K] extends infer T_1 ? T_1 extends S[K] ? T_1 extends {
|
|
357
|
+
_zod: {
|
|
358
|
+
output: infer O_1;
|
|
359
|
+
};
|
|
360
|
+
} ? O_1 : never : never : never; } & { [K in keyof S as (S[K] extends {
|
|
317
361
|
_zod: {
|
|
318
362
|
output: infer O;
|
|
319
363
|
};
|
|
320
|
-
} ? O : never
|
|
364
|
+
} ? undefined extends O ? true : false : false) extends true ? K : never]?: (S[K] extends infer T_1 ? T_1 extends S[K] ? T_1 extends {
|
|
365
|
+
_zod: {
|
|
366
|
+
output: infer O_1;
|
|
367
|
+
};
|
|
368
|
+
} ? O : never : never : never) | undefined; } extends infer T ? { [K in keyof T]: T[K]; } : never;
|
|
321
369
|
safeParse(value: unknown): {
|
|
322
370
|
success: true;
|
|
323
|
-
data: { [K in keyof S
|
|
371
|
+
data: { [K in keyof S as (S[K] extends {
|
|
324
372
|
_zod: {
|
|
325
373
|
output: infer O;
|
|
326
374
|
};
|
|
327
|
-
} ? O : never
|
|
375
|
+
} ? undefined extends O ? true : false : false) extends true ? never : K]: S[K] extends infer T_1 ? T_1 extends S[K] ? T_1 extends {
|
|
376
|
+
_zod: {
|
|
377
|
+
output: infer O_1;
|
|
378
|
+
};
|
|
379
|
+
} ? O_1 : never : never : never; } & { [K in keyof S as (S[K] extends {
|
|
380
|
+
_zod: {
|
|
381
|
+
output: infer O;
|
|
382
|
+
};
|
|
383
|
+
} ? undefined extends O ? true : false : false) extends true ? K : never]?: (S[K] extends infer T_1 ? T_1 extends S[K] ? T_1 extends {
|
|
384
|
+
_zod: {
|
|
385
|
+
output: infer O_1;
|
|
386
|
+
};
|
|
387
|
+
} ? O : never : never : never) | undefined; } extends infer T ? { [K in keyof T]: T[K]; } : never;
|
|
328
388
|
} | {
|
|
329
389
|
success: false;
|
|
330
390
|
error: unknown;
|
|
331
391
|
};
|
|
332
392
|
check(...checks: import("./zod.js").Check[]): /*elided*/ any;
|
|
333
393
|
register(registry: import("./zod.js").Registry, meta: Record<string, unknown>): /*elided*/ any;
|
|
334
|
-
}
|
|
394
|
+
}>>;
|
|
335
395
|
/** A fixed-stride element — bound it with `.max(n)` or `.length(n)` before field.array. */
|
|
336
|
-
array: <E extends z.ZodTypeAny>(element: E) => import("./zod.js").Fluent<{
|
|
396
|
+
array: <E extends z.ZodTypeAny>(element: E) => import("./zod.js").Fluent<import("./zod.js").Fluent<{
|
|
337
397
|
readonly _zod: {
|
|
338
398
|
output: (E extends {
|
|
339
399
|
_zod: {
|
|
@@ -373,5 +433,5 @@ export declare const reef: {
|
|
|
373
433
|
};
|
|
374
434
|
check(...checks: import("./zod.js").Check[]): /*elided*/ any;
|
|
375
435
|
register(registry: import("./zod.js").Registry, meta: Record<string, unknown>): /*elided*/ any;
|
|
376
|
-
}
|
|
436
|
+
}>>;
|
|
377
437
|
};
|
|
@@ -49,6 +49,8 @@ export interface ConnectorContext {
|
|
|
49
49
|
view: Int32Array;
|
|
50
50
|
index: number;
|
|
51
51
|
};
|
|
52
|
+
/** The field's contract path — for devtools write events on granular commits. */
|
|
53
|
+
path?: string;
|
|
52
54
|
}
|
|
53
55
|
/**
|
|
54
56
|
* A connector factory builds a connector for one field kind over a region of
|
package/dist/contract/types.d.ts
CHANGED
|
@@ -60,6 +60,8 @@ export interface WorkerPoolConfig<S extends SharedSpec = SharedSpec, T extends T
|
|
|
60
60
|
persistence?: (memory: SharedMemory<S>) => MemoryPersistence | undefined;
|
|
61
61
|
/** Worker count — a number, or 'auto' (the default) for navigator.hardwareConcurrency ?? 4. */
|
|
62
62
|
poolSize?: number | 'auto';
|
|
63
|
+
/** Display label for devtools/dashboards — falls back to a generated id. */
|
|
64
|
+
name?: string;
|
|
63
65
|
memory?: MemoryConfig;
|
|
64
66
|
/** Max in-flight tasks per worker (default 1); excess tasks queue FIFO. */
|
|
65
67
|
concurrency?: number;
|
package/dist/contract/zod.d.ts
CHANGED
|
@@ -52,6 +52,10 @@ export interface SchemaDef {
|
|
|
52
52
|
format?: string;
|
|
53
53
|
shape?: Record<string, ZodLike>;
|
|
54
54
|
element?: ZodLike;
|
|
55
|
+
/** union members. */
|
|
56
|
+
options?: readonly ZodLike[];
|
|
57
|
+
/** literal value. */
|
|
58
|
+
literal?: unknown;
|
|
55
59
|
cls?: abstract new (...args: any[]) => unknown;
|
|
56
60
|
}
|
|
57
61
|
export declare class SchemaError extends Error {
|
|
@@ -143,13 +147,23 @@ declare class ZodUnknown extends ZodType<unknown> {
|
|
|
143
147
|
declare class ZodInstanceof<T> extends ZodType<T> {
|
|
144
148
|
inner(v: unknown): T;
|
|
145
149
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
/** Members whose output admits `undefined` become optional keys — mirroring
|
|
151
|
+
* zod's `z.optional()` object-member semantics (message-domain schemas like
|
|
152
|
+
* island prop contracts need this; reef's fixed-width members never produce
|
|
153
|
+
* it, so the split preserves their all-required output). */
|
|
154
|
+
type IsOptional<S, K extends keyof S> = S[K] extends {
|
|
155
|
+
_zod: {
|
|
156
|
+
output: infer O;
|
|
157
|
+
};
|
|
158
|
+
} ? undefined extends O ? true : false : false;
|
|
159
|
+
type Flatten<T> = {
|
|
160
|
+
[K in keyof T]: T[K];
|
|
152
161
|
};
|
|
162
|
+
type ShapeOutput<S extends Record<string, ZodLike>> = Flatten<{
|
|
163
|
+
[K in keyof S as IsOptional<S, K> extends true ? never : K]: OutputOf<S[K]>;
|
|
164
|
+
} & {
|
|
165
|
+
[K in keyof S as IsOptional<S, K> extends true ? K : never]?: OutputOf<S[K]>;
|
|
166
|
+
}>;
|
|
153
167
|
/** Strips unknown keys like zod's object parse — output is the shape only. */
|
|
154
168
|
declare class ZodObjectSchema<S extends Record<string, ZodLike>> extends ZodType<ShapeOutput<S>> {
|
|
155
169
|
readonly _zod: {
|
|
@@ -179,14 +193,90 @@ type OutputOf<S> = S extends {
|
|
|
179
193
|
output: infer O;
|
|
180
194
|
};
|
|
181
195
|
} ? O : never;
|
|
182
|
-
declare
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
196
|
+
declare class ZodOptional<E extends ZodLike> extends ZodType<OutputOf<E> | undefined> {
|
|
197
|
+
readonly _zod: {
|
|
198
|
+
output: OutputOf<E> | undefined;
|
|
199
|
+
input: OutputOf<E> | undefined;
|
|
200
|
+
def: SchemaDef & {
|
|
201
|
+
type: 'optional';
|
|
202
|
+
element: E;
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
inner(v: unknown): OutputOf<E> | undefined;
|
|
206
|
+
}
|
|
207
|
+
declare class ZodNullable<E extends ZodLike> extends ZodType<OutputOf<E> | null> {
|
|
208
|
+
readonly _zod: {
|
|
209
|
+
output: OutputOf<E> | null;
|
|
210
|
+
input: OutputOf<E> | null;
|
|
211
|
+
def: SchemaDef & {
|
|
212
|
+
type: 'nullable';
|
|
213
|
+
element: E;
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
inner(v: unknown): OutputOf<E> | null;
|
|
217
|
+
}
|
|
218
|
+
declare class ZodLiteral<V extends string | number | boolean> extends ZodType<V> {
|
|
219
|
+
readonly _zod: {
|
|
220
|
+
output: V;
|
|
221
|
+
input: V;
|
|
222
|
+
def: SchemaDef & {
|
|
223
|
+
type: 'literal';
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
inner(v: unknown): V;
|
|
227
|
+
}
|
|
228
|
+
declare class ZodUnion<O extends readonly ZodLike[]> extends ZodType<OutputOf<O[number]>> {
|
|
229
|
+
readonly _zod: {
|
|
230
|
+
output: OutputOf<O[number]>;
|
|
231
|
+
input: OutputOf<O[number]>;
|
|
232
|
+
def: SchemaDef & {
|
|
233
|
+
type: 'union';
|
|
234
|
+
options: O;
|
|
235
|
+
};
|
|
236
|
+
};
|
|
237
|
+
inner(v: unknown): OutputOf<O[number]>;
|
|
238
|
+
}
|
|
239
|
+
declare class ZodRecord<E extends ZodLike> extends ZodType<Record<string, OutputOf<E>>> {
|
|
240
|
+
readonly _zod: {
|
|
241
|
+
output: Record<string, OutputOf<E>>;
|
|
242
|
+
input: Record<string, OutputOf<E>>;
|
|
243
|
+
def: SchemaDef & {
|
|
244
|
+
type: 'record';
|
|
245
|
+
element: E;
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
inner(v: unknown): Record<string, OutputOf<E>>;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Function-typed members — how a props schema declares a `callbackProp`
|
|
252
|
+
* slot: the wire carries a `{__cb:id}` handle that `unmarshalCallbackProps`
|
|
253
|
+
* restores to a callable BEFORE contract validation runs, so at parse time
|
|
254
|
+
* the member is a real function.
|
|
255
|
+
*/
|
|
256
|
+
declare class ZodCallback<F extends (...args: any[]) => any = (...args: unknown[]) => unknown> extends ZodType<F> {
|
|
257
|
+
readonly _zod: {
|
|
258
|
+
output: F;
|
|
259
|
+
input: F;
|
|
260
|
+
def: SchemaDef & {
|
|
261
|
+
type: 'function';
|
|
262
|
+
};
|
|
263
|
+
};
|
|
264
|
+
inner(v: unknown): F;
|
|
265
|
+
}
|
|
266
|
+
declare const number: () => Fluent<ZodNumber>;
|
|
267
|
+
declare const string: () => Fluent<ZodString>;
|
|
268
|
+
declare const boolean_: () => Fluent<ZodBoolean>;
|
|
269
|
+
declare const bigint_: () => Fluent<ZodBigint>;
|
|
270
|
+
declare const unknown_: () => Fluent<ZodUnknown>;
|
|
271
|
+
declare const instanceof_: <T extends abstract new (...args: any[]) => any>(cls: T) => Fluent<ZodInstanceof<InstanceType<T>>>;
|
|
272
|
+
declare const object_: <S extends Record<string, ZodLike>>(shape: S) => Fluent<ZodObjectSchema<S>>;
|
|
273
|
+
declare const array: <E extends ZodLike>(element: E) => Fluent<ZodArraySchema<E>>;
|
|
274
|
+
declare const optional: <E extends ZodLike>(element: E) => Fluent<ZodOptional<E>>;
|
|
275
|
+
declare const nullable: <E extends ZodLike>(element: E) => Fluent<ZodNullable<E>>;
|
|
276
|
+
declare const literal: <V extends string | number | boolean>(value: V) => Fluent<ZodLiteral<V>>;
|
|
277
|
+
declare const union: <O extends readonly [ZodLike, ...ZodLike[]]>(options: O) => Fluent<ZodUnion<O>>;
|
|
278
|
+
declare const record: <E extends ZodLike>(element: E) => Fluent<ZodRecord<E>>;
|
|
279
|
+
declare const callback: <F extends (...args: any[]) => any = (...args: unknown[]) => unknown>() => Fluent<ZodCallback<F>>;
|
|
190
280
|
declare const int32: () => ZodNumber;
|
|
191
281
|
declare const uint32: () => ZodNumber;
|
|
192
282
|
declare const float32: () => ZodNumber;
|
|
@@ -204,6 +294,10 @@ export type Fluent<S extends ZodLike> = S & {
|
|
|
204
294
|
max(value: number | bigint): Fluent<S>;
|
|
205
295
|
length(n: number): Fluent<S>;
|
|
206
296
|
int(): Fluent<S>;
|
|
297
|
+
/** Wraps in an optional member — the `label?: string` spelling. */
|
|
298
|
+
optional(): Fluent<ZodOptional<S>>;
|
|
299
|
+
/** Wraps in a nullable member — `T | null`. */
|
|
300
|
+
nullable(): Fluent<ZodNullable<S>>;
|
|
207
301
|
};
|
|
208
302
|
/** Attaches the `Fluent` methods as non-enumerable own properties. */
|
|
209
303
|
export declare function fluent<S extends ZodType>(schema: S): Fluent<S>;
|
|
@@ -216,6 +310,12 @@ export declare const z: {
|
|
|
216
310
|
array: typeof array;
|
|
217
311
|
instanceof: typeof instanceof_;
|
|
218
312
|
unknown: typeof unknown_;
|
|
313
|
+
optional: typeof optional;
|
|
314
|
+
nullable: typeof nullable;
|
|
315
|
+
literal: typeof literal;
|
|
316
|
+
union: typeof union;
|
|
317
|
+
record: typeof record;
|
|
318
|
+
callback: typeof callback;
|
|
219
319
|
int32: typeof int32;
|
|
220
320
|
uint32: typeof uint32;
|
|
221
321
|
float32: typeof float32;
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured instrumentation events for the devtools/dashboard tooling.
|
|
3
|
+
* Same zero-cost contract as `log.ts` and islands' `proxyMetrics`: when no
|
|
4
|
+
* sink is installed, emit() is a single branch — production pays nothing.
|
|
5
|
+
*
|
|
6
|
+
* Events are emitted on whichever thread they occur on. Worker-side events
|
|
7
|
+
* reach the main thread's sink by postMessage forwarding (`ATOLL_DEVTOOLS`
|
|
8
|
+
* on the task channel — the pool re-emits them), so one sink sees the whole
|
|
9
|
+
* app. See docs/plans/devtools-dashboard.md.
|
|
10
|
+
*/
|
|
11
|
+
export type DevtoolsThread = 'main' | 'worker';
|
|
12
|
+
export type TaskSettleOutcome = 'ok' | 'error' | 'aborted' | 'timeout' | 'queue-full' | 'crashed';
|
|
13
|
+
export type DevtoolsEvent = {
|
|
14
|
+
type: 'pool:init';
|
|
15
|
+
poolId: string;
|
|
16
|
+
/** Config `name`, when supplied — a display label, not the id. */
|
|
17
|
+
label?: string;
|
|
18
|
+
poolSize: number;
|
|
19
|
+
concurrency: number;
|
|
20
|
+
memoryBytes?: number;
|
|
21
|
+
} | {
|
|
22
|
+
type: 'pool:terminate';
|
|
23
|
+
poolId: string;
|
|
24
|
+
} | {
|
|
25
|
+
type: 'worker:spawn';
|
|
26
|
+
poolId: string;
|
|
27
|
+
slot: number;
|
|
28
|
+
} | {
|
|
29
|
+
type: 'worker:error';
|
|
30
|
+
poolId: string;
|
|
31
|
+
slot: number;
|
|
32
|
+
message: string;
|
|
33
|
+
} | {
|
|
34
|
+
type: 'worker:respawn';
|
|
35
|
+
poolId: string;
|
|
36
|
+
slot: number;
|
|
37
|
+
} | {
|
|
38
|
+
type: 'task:enqueue';
|
|
39
|
+
poolId: string;
|
|
40
|
+
callId: number;
|
|
41
|
+
taskId: string;
|
|
42
|
+
} | {
|
|
43
|
+
type: 'task:dispatch';
|
|
44
|
+
poolId: string;
|
|
45
|
+
callId: number;
|
|
46
|
+
taskId: string;
|
|
47
|
+
slot: number;
|
|
48
|
+
waitMs: number;
|
|
49
|
+
} | {
|
|
50
|
+
type: 'task:settle';
|
|
51
|
+
poolId: string;
|
|
52
|
+
callId: number;
|
|
53
|
+
taskId: string;
|
|
54
|
+
outcome: TaskSettleOutcome;
|
|
55
|
+
/** dispatch→reply; absent for calls that never ran. */
|
|
56
|
+
runMs?: number;
|
|
57
|
+
error?: string;
|
|
58
|
+
} | {
|
|
59
|
+
type: 'memory:bind';
|
|
60
|
+
/** Version-counter index → field path, for pairing memory:write. */
|
|
61
|
+
fields: [index: number, path: string][];
|
|
62
|
+
totalBytes: number;
|
|
63
|
+
} | {
|
|
64
|
+
type: 'memory:write';
|
|
65
|
+
path: string;
|
|
66
|
+
version: number;
|
|
67
|
+
} | {
|
|
68
|
+
type: 'island:mount';
|
|
69
|
+
instance: string;
|
|
70
|
+
app: string;
|
|
71
|
+
pid: string;
|
|
72
|
+
/** The client pool driving this island — links the island to its worker. */
|
|
73
|
+
poolId?: string;
|
|
74
|
+
/** Renderer/framework tag supplied by the mounter — observability only. */
|
|
75
|
+
framework?: string;
|
|
76
|
+
} | {
|
|
77
|
+
type: 'island:unmount';
|
|
78
|
+
instance: string;
|
|
79
|
+
} | {
|
|
80
|
+
type: 'island:event';
|
|
81
|
+
instance: string;
|
|
82
|
+
name: string;
|
|
83
|
+
} | {
|
|
84
|
+
type: 'island:task';
|
|
85
|
+
instance: string;
|
|
86
|
+
/** The client call behind the round-trip — the island's "request". */
|
|
87
|
+
method: 'mount' | 'whoami' | 'dispatch' | 'setSize' | 'updateProps' | 'flush' | 'unmount';
|
|
88
|
+
/** Round-trip ms: call → ops returned (worker render + transport). */
|
|
89
|
+
ms: number;
|
|
90
|
+
/** Op count in the returned batch (response size in ops). */
|
|
91
|
+
ops?: number;
|
|
92
|
+
error?: string;
|
|
93
|
+
} | {
|
|
94
|
+
type: 'island:ops';
|
|
95
|
+
instance: string;
|
|
96
|
+
/** The client call that produced the batch. */
|
|
97
|
+
via: 'mount' | 'updateProps' | 'dispatch' | 'setSize' | 'flush' | 'unmount';
|
|
98
|
+
count: number;
|
|
99
|
+
/** Main-thread replay time; worker-side render time rides call timings. */
|
|
100
|
+
replayMs?: number;
|
|
101
|
+
} | {
|
|
102
|
+
type: 'net:fetch';
|
|
103
|
+
/** Per-context sequence — correlates the net:fetch-detail follow-up. */
|
|
104
|
+
id: number;
|
|
105
|
+
url: string;
|
|
106
|
+
method: string;
|
|
107
|
+
/** HTTP status — absent when the request failed before a response. */
|
|
108
|
+
status?: number;
|
|
109
|
+
/** Time from dispatch to response headers (error: to failure). */
|
|
110
|
+
ms: number;
|
|
111
|
+
/** Response Content-Length when advertised. */
|
|
112
|
+
bytes?: number;
|
|
113
|
+
error?: string;
|
|
114
|
+
reqHeaders?: [string, string][];
|
|
115
|
+
/** Capped preview; non-text bodies are described, not dumped. */
|
|
116
|
+
reqBody?: string;
|
|
117
|
+
} | {
|
|
118
|
+
/**
|
|
119
|
+
* Detail follow-up to net:fetch (same id) — emitted after the response
|
|
120
|
+
* settles so it can carry headers, a capped body preview, and the
|
|
121
|
+
* Resource Timing stage breakdown once the entry exists.
|
|
122
|
+
*/
|
|
123
|
+
type: 'net:fetch-detail';
|
|
124
|
+
id: number;
|
|
125
|
+
/** Present when the body was only readable async (Request objects). */
|
|
126
|
+
reqBody?: string;
|
|
127
|
+
resHeaders?: [string, string][];
|
|
128
|
+
resBody?: string;
|
|
129
|
+
/**
|
|
130
|
+
* Stage ms from PerformanceResourceTiming: queue (stalled → fetch
|
|
131
|
+
* start), dns, tcp, tls, wait (request → first byte), download.
|
|
132
|
+
* Absent for cross-origin responses without Timing-Allow-Origin.
|
|
133
|
+
*/
|
|
134
|
+
timing?: {
|
|
135
|
+
queue: number;
|
|
136
|
+
dns: number;
|
|
137
|
+
tcp: number;
|
|
138
|
+
tls: number;
|
|
139
|
+
wait: number;
|
|
140
|
+
download: number;
|
|
141
|
+
};
|
|
142
|
+
transferSize?: number;
|
|
143
|
+
encodedSize?: number;
|
|
144
|
+
decodedSize?: number;
|
|
145
|
+
} | {
|
|
146
|
+
type: 'runtime:memory';
|
|
147
|
+
/**
|
|
148
|
+
* measureUserAgentSpecificMemory: cluster total.
|
|
149
|
+
* performance.memory / process.memoryUsage fallback: this context's
|
|
150
|
+
* usedJSHeapSize / heapUsed.
|
|
151
|
+
*/
|
|
152
|
+
heapBytes: number;
|
|
153
|
+
heapLimitBytes?: number;
|
|
154
|
+
/** Resident set size — present on the Node memoryUsage() path. */
|
|
155
|
+
rssBytes?: number;
|
|
156
|
+
/**
|
|
157
|
+
* Per-execution-context attribution from
|
|
158
|
+
* `performance.measureUserAgentSpecificMemory` — emitted on the main
|
|
159
|
+
* thread only (workers can't self-identify among same-URL contexts).
|
|
160
|
+
* Worker contexts are identified by their script URL.
|
|
161
|
+
*/
|
|
162
|
+
contexts?: {
|
|
163
|
+
bytes: number;
|
|
164
|
+
scope?: string;
|
|
165
|
+
url?: string;
|
|
166
|
+
}[];
|
|
167
|
+
};
|
|
168
|
+
export type EmittedDevtoolsEvent = DevtoolsEvent & {
|
|
169
|
+
/** performance.now() on the emitting thread. */
|
|
170
|
+
at: number;
|
|
171
|
+
/** Which side of the boundary emitted the event. */
|
|
172
|
+
thread: DevtoolsThread;
|
|
173
|
+
/**
|
|
174
|
+
* Stamped by the pool when re-emitting a worker-forwarded event —
|
|
175
|
+
* attributes worker-side events (memory writes, fetches, heap samples)
|
|
176
|
+
* to the specific pool slot that produced them.
|
|
177
|
+
*/
|
|
178
|
+
worker?: {
|
|
179
|
+
poolId: string;
|
|
180
|
+
slot: number;
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
export type DevtoolsSink = (event: EmittedDevtoolsEvent) => void;
|
|
184
|
+
/** Install the event sink (devtools transports hook here); null disables. */
|
|
185
|
+
export declare const setDevtoolsSink: (custom: DevtoolsSink | null) => void;
|
|
186
|
+
/** Emit a structured event — one branch when no sink is installed. */
|
|
187
|
+
export declare const emitDevtools: (event: DevtoolsEvent) => void;
|
|
188
|
+
/**
|
|
189
|
+
* Re-emit an already-stamped event — for forwarding worker-side events that
|
|
190
|
+
* arrived over postMessage without re-stamping their timing/thread.
|
|
191
|
+
*/
|
|
192
|
+
export declare const forwardDevtools: (event: EmittedDevtoolsEvent) => void;
|
|
193
|
+
/** True when a devtools sink is installed on this thread. */
|
|
194
|
+
export declare const devtoolsEnabled: () => boolean;
|
|
195
|
+
/**
|
|
196
|
+
* Worker side: route emitted events to the main thread over the task
|
|
197
|
+
* channel (`ATOLL_DEVTOOLS` messages — the pool re-emits them into its
|
|
198
|
+
* sink). Switched on by the pool's INIT handshake when the pool has a
|
|
199
|
+
* sink installed, so workers only forward when someone is listening.
|
|
200
|
+
*/
|
|
201
|
+
export declare const enableWorkerDevtoolsForwarding: () => void;
|
|
202
|
+
/**
|
|
203
|
+
* Wrap `scope.fetch` to emit `net:fetch` (+ a `net:fetch-detail` follow-up
|
|
204
|
+
* with headers/body previews and stage timings) for every request — covers
|
|
205
|
+
* main thread (installed by connectDevtools) and workers (installed by the
|
|
206
|
+
* INIT handshake's forwarding flag). Idempotent; restores nothing (the
|
|
207
|
+
* wrapper delegates to the captured original). XHR is not covered.
|
|
208
|
+
*/
|
|
209
|
+
export declare const installFetchProbe: (scope: {
|
|
210
|
+
fetch?: typeof fetch;
|
|
211
|
+
}) => void;
|
|
212
|
+
/**
|
|
213
|
+
* Emit `runtime:memory` periodically — JS heap usage. On the main thread,
|
|
214
|
+
* prefers `performance.measureUserAgentSpecificMemory()`, which reports a
|
|
215
|
+
* per-execution-context breakdown (windows + workers identified by script
|
|
216
|
+
* URL) for the whole agent cluster; falls back to `performance.memory`,
|
|
217
|
+
* which also covers the worker-side install on engines that expose it
|
|
218
|
+
* there, then `process.memoryUsage()` on Node (heapUsed + rss — works
|
|
219
|
+
* inside worker_threads too). No-ops with none of the three.
|
|
220
|
+
*/
|
|
221
|
+
export declare const installMemoryProbe: (scope: object, intervalMs?: number) => void;
|
|
222
|
+
/** Process-unique ids for pools — 'pool-1', 'pool-2', … */
|
|
223
|
+
export declare const nextDevtoolsId: (prefix: string) => string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { bindSharedMemories, defineSharedMemory, field, getDefinedSharedMemoryCount, jsonCodec, registerConnectorFactory } from './contract/sharedMemory.js';
|
|
2
2
|
export { reef } from './contract/reef.js';
|
|
3
|
+
export { z, SchemaError } from './contract/zod.js';
|
|
4
|
+
export type { ZodLike } from './contract/zod.js';
|
|
3
5
|
export type { Codec, Connector, ConnectorContext, ConnectorFactory, FieldDescriptor, FieldGroup, FieldSchema, FixedArrayDescriptor, FixedObjectDescriptor, FlatKey, InferField, PathConnector, SpecPath, SpecSchemas, SharedAccess, SharedMemory, SharedMemoryOptions, SharedSpec, ScalarKind, ListConnector, ListDescriptor, ListFieldSpec, ListFields, ListMember, ListRecord, ListSpec, } from './contract/sharedMemory.js';
|
|
4
6
|
export { msgpackrCodec } from './contract/msgpackrCodec.js';
|
|
5
7
|
export { listSchema } from './contract/listSchema.js';
|
|
@@ -27,3 +29,5 @@ export { defineTask, isAsyncTask, toTask } from './task.js';
|
|
|
27
29
|
export type { AsyncTask, TaskSnapshot } from './task.js';
|
|
28
30
|
export { getLogLevel, log, scoped, setLogLevel, setLogSink } from './log.js';
|
|
29
31
|
export type { LogEntry, LogLevel, LogSink } from './log.js';
|
|
32
|
+
export { devtoolsEnabled, emitDevtools, installFetchProbe, installMemoryProbe, setDevtoolsSink, } from './devtools.js';
|
|
33
|
+
export type { DevtoolsEvent, DevtoolsSink, DevtoolsThread, EmittedDevtoolsEvent, TaskSettleOutcome, } from './devtools.js';
|