@the-w1zard/types 1.0.1 → 1.0.2
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/package.json +26 -26
- package/src/index.d.ts +3267 -0
- package/src/index.ts +2 -20
- package/src/mimic.d.ts +53 -0
- package/src/mirror_image.d.ts +147 -0
- package/src/platform.d.ts +3 -44
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,3267 @@
|
|
|
1
|
+
export {}
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
declare global {
|
|
5
|
+
|
|
6
|
+
// TYPES
|
|
7
|
+
// #region ══════════════════════════════════════════════════════════════════════════════════════════════════════
|
|
8
|
+
type Boundary = 'same-app' | 'same-node' | 'cross-node'
|
|
9
|
+
|
|
10
|
+
type StubHit = { category: string; key: string; prop: string; location: any };
|
|
11
|
+
|
|
12
|
+
type ExtractFactory<A1, A2> =
|
|
13
|
+
A1 extends string
|
|
14
|
+
? Extract<A2, (...args: any[]) => any>
|
|
15
|
+
: Extract<A1, (...args: any[]) => any>
|
|
16
|
+
interface CloudState {
|
|
17
|
+
get<T>(key: string | symbol): T | undefined;
|
|
18
|
+
set<T>(key: string | symbol, value: T | ((prev: T | undefined) => T)): void;
|
|
19
|
+
subscribe<T>(key: string | symbol, listener: (value: T) => void): () => void;
|
|
20
|
+
clear(): void;
|
|
21
|
+
}
|
|
22
|
+
type ConcentrationGenericsCtx = { self: any;[category: string]: any };
|
|
23
|
+
type CGFactory = (ctx: ConcentrationGenericsCtx) => Record<string, any>
|
|
24
|
+
type types<C> = { [K in keyof ReturnType<Extract<C, (...args: any[]) => any>>]: ReturnType<Extract<C, (...args: any[]) => any>>[K] extends { types: infer T } ? T : never }
|
|
25
|
+
type __location = { file: string; line: number; column: number; functionName: string }
|
|
26
|
+
type KernelTypeParameter = {
|
|
27
|
+
helpers: {
|
|
28
|
+
generateTypeString: (typeDef: any, paramValues?: Record<string, string>) => string
|
|
29
|
+
validateGenericUsage: (typeDef: any, providedParams: string[]) => boolean
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
type arg1<C> = string | C
|
|
33
|
+
type arg2<C> = C | KernelTypeParameter
|
|
34
|
+
type concentrationTypeRef =
|
|
35
|
+
| { kind: "Named"; name: string; args?: concentrationTypeRef[] }
|
|
36
|
+
| { kind: "Union"; types: concentrationTypeRef[] }
|
|
37
|
+
| { kind: "Function"; params: { name: string; type: concentrationTypeRef }[]; returnType: concentrationTypeRef }
|
|
38
|
+
| { kind: "Object"; fields: Record<string, { type: concentrationTypeRef; optional?: boolean }> }
|
|
39
|
+
type concentrationGeneric = {
|
|
40
|
+
name: string
|
|
41
|
+
typeParameters: concentrationTypeParameter[]
|
|
42
|
+
signature: concentrationTypeRef // always a Function here
|
|
43
|
+
}
|
|
44
|
+
type SubstEnv = Record<string, concentrationTypeRef>
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
interface CGInterface<C> {
|
|
50
|
+
arg1: arg1<C>
|
|
51
|
+
arg2?: C | KernelTypeParameter
|
|
52
|
+
arg3?: KernelTypeParameter
|
|
53
|
+
}
|
|
54
|
+
type concentrationTypeFlags = | "Any" | "Unknown" | "Boolean" | "Number" | "String" | "Object" | "Function" | "TypeParameter" | "Union" | "Intersection"
|
|
55
|
+
type concentrationTypeEnv = Record<string, concentrationTypeId>
|
|
56
|
+
type concentrationTypeId = string
|
|
57
|
+
type concentrationTypeParameter = {
|
|
58
|
+
id: concentrationTypeId
|
|
59
|
+
name: string
|
|
60
|
+
constraint?: concentrationTypeId
|
|
61
|
+
default?: concentrationTypeId
|
|
62
|
+
}
|
|
63
|
+
type concentrationSignature = {
|
|
64
|
+
typeParameters?: concentrationTypeParameter[]
|
|
65
|
+
parameters: { name: string; type: concentrationTypeId }[]
|
|
66
|
+
returnType: concentrationTypeId
|
|
67
|
+
}
|
|
68
|
+
type concentrationType = {
|
|
69
|
+
id: concentrationTypeId
|
|
70
|
+
flags: concentrationTypeFlags[]
|
|
71
|
+
name?: string
|
|
72
|
+
signatures?: concentrationSignature[]
|
|
73
|
+
aliasOf?: concentrationTypeId
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
// #endregion ============================================
|
|
79
|
+
// #region STATE MACHINE
|
|
80
|
+
// ============================================
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
interface StateMachineConfig {
|
|
84
|
+
v: string;
|
|
85
|
+
transitions: Record<string, string[]>;
|
|
86
|
+
guards?: Record<string, (props: any, prev: string, next: string) => boolean>;
|
|
87
|
+
onEnter?: Record<string, (props: any, prev: string, next: string) => void>;
|
|
88
|
+
onExit?: Record<string, (props: any, prev: string, next: string) => void>;
|
|
89
|
+
onTransition?: (props: any, prev: string, next: string) => void;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
interface SyncStreamOptions665 {
|
|
101
|
+
/** Max unacknowledged in-flight payloads before the sender backs off. */
|
|
102
|
+
windowSize?: number;
|
|
103
|
+
/** Retransmit timeout per in-flight seq (default 5s). Keeps a lost ack from wedging the window. */
|
|
104
|
+
retransmitMs?: number;
|
|
105
|
+
}
|
|
106
|
+
type SBackpressureStrategy665 = "drop" | "pause" | "error";
|
|
107
|
+
interface StreamRelayOptions665 {
|
|
108
|
+
maxSubscribers?: number;
|
|
109
|
+
bufferSize?: number;
|
|
110
|
+
backpressureStrategy?: SBackpressureStrategy665;
|
|
111
|
+
}
|
|
112
|
+
interface PipelineStage665<T> {
|
|
113
|
+
name: string;
|
|
114
|
+
handler: (data: T) => T | Promise<T>;
|
|
115
|
+
errorHandler?: (err: Error, data: T) => T | Promise<T>;
|
|
116
|
+
}
|
|
117
|
+
type PipelineEvent665<T> = | { type: "stage:enter"; stage: string; data: T } | { type: "stage:exit"; stage: string; data: T } | { type: "error"; stage: string; data?: T; error: string };
|
|
118
|
+
interface MeshOptions665 {
|
|
119
|
+
peerId?: string;
|
|
120
|
+
announceInterval?: number; // ms
|
|
121
|
+
peerTimeout?: number; // ms — peer considered stale
|
|
122
|
+
maxPeers?: number;
|
|
123
|
+
}
|
|
124
|
+
interface MeshPeer665<TMeta extends Record<string, unknown> = Record<string, unknown>> {
|
|
125
|
+
id: string;
|
|
126
|
+
metadata: TMeta;
|
|
127
|
+
latency: number;
|
|
128
|
+
lastSeen: number;
|
|
129
|
+
}
|
|
130
|
+
interface MeshMessage665<T> {
|
|
131
|
+
from: string;
|
|
132
|
+
p: T;
|
|
133
|
+
timestamp: number;
|
|
134
|
+
}
|
|
135
|
+
interface MeshState665 {
|
|
136
|
+
peerId: string;
|
|
137
|
+
peers: Array<{ id: string; metadata: Record<string, unknown> }>;
|
|
138
|
+
meshSize: number;
|
|
139
|
+
}
|
|
140
|
+
interface PlinkoContext665<TState, TPayload> {
|
|
141
|
+
state: TState;
|
|
142
|
+
p: TPayload;
|
|
143
|
+
path: string[];
|
|
144
|
+
metadata: Map<string, any>;
|
|
145
|
+
reply: (data: unknown, targetSc?: string) => Promise<unknown>;
|
|
146
|
+
abort: (reason?: string) => never;
|
|
147
|
+
send?(rt: string, p: unknown): void;
|
|
148
|
+
}
|
|
149
|
+
interface PlinkoNode665<TState, TPayload> {
|
|
150
|
+
matcher: (p: TPayload, ctx: PlinkoContext665<TState, TPayload>) => boolean | Promise<boolean>;
|
|
151
|
+
execute?: (p: TPayload, ctx: PlinkoContext665<TState, TPayload>) => unknown | Promise<unknown>;
|
|
152
|
+
branches?: Record<string, PlinkoNode665<TState, TPayload>>;
|
|
153
|
+
hooks?: {
|
|
154
|
+
beforeEnter?: (p: TPayload, ctx: PlinkoContext665<TState, TPayload>) => void | Promise<void>;
|
|
155
|
+
afterExit?: (result: unknown, ctx: PlinkoContext665<TState, TPayload>) => void | Promise<void>;
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
type PlinkoTree665<TState, TPayload> = Record<string, PlinkoNode665<TState, TPayload>>;
|
|
159
|
+
interface PlinkoOptions665<TState = any, TPayload = any> {
|
|
160
|
+
autoResetOnTerminal?: boolean;
|
|
161
|
+
onTransition?: (from: string[], to: string[], p: TPayload) => void;
|
|
162
|
+
onError?: (err: Error, path: string[], p: TPayload) => void;
|
|
163
|
+
}
|
|
164
|
+
interface PlinkoEvaluation665<TState, TPayload> {
|
|
165
|
+
success: boolean;
|
|
166
|
+
path: string[];
|
|
167
|
+
result: unknown;
|
|
168
|
+
terminal: boolean;
|
|
169
|
+
state?: TState;
|
|
170
|
+
metadata?: Map<string, any>;
|
|
171
|
+
}
|
|
172
|
+
interface PlinkoHandle665<TState, TPayload> {
|
|
173
|
+
evaluate(p: TPayload, replyFn?: (data: unknown, targetSc?: string) => Promise<unknown>): Promise<PlinkoEvaluation665<TState, TPayload>>;
|
|
174
|
+
getState(): TState;
|
|
175
|
+
getPath(): string[];
|
|
176
|
+
reset(): void;
|
|
177
|
+
}
|
|
178
|
+
interface SwitchboardContext665<TPayload> {
|
|
179
|
+
p: TPayload;
|
|
180
|
+
reply: (data: unknown) => Promise<unknown>;
|
|
181
|
+
store: Map<string, any>;
|
|
182
|
+
}
|
|
183
|
+
interface SSwitchboardResult665 {
|
|
184
|
+
success: boolean;
|
|
185
|
+
matchedKey: string | null;
|
|
186
|
+
unmatched: boolean;
|
|
187
|
+
result?: unknown;
|
|
188
|
+
error?: Error;
|
|
189
|
+
}
|
|
190
|
+
interface SwitchboardRoute665<TPayload> {
|
|
191
|
+
(p: TPayload, ctx: SwitchboardContext665<TPayload>): unknown;
|
|
192
|
+
}
|
|
193
|
+
type SwitchboardRoutes665<TPayload, TKey extends string = string> = { [K in TKey]?: SwitchboardRoute665<TPayload> | "unmatched"; } & { default?: SwitchboardRoute665<TPayload> };
|
|
194
|
+
interface SwitchboardOptions665<TPayload, TKey extends string = string> {
|
|
195
|
+
rt?: string;
|
|
196
|
+
subrt?: string;
|
|
197
|
+
selectKey: (p: TPayload) => TKey;
|
|
198
|
+
onUnmatched?: (p: TPayload, key: string) => void;
|
|
199
|
+
onDispatch?: (route: string, p: TPayload, result: unknown) => void;
|
|
200
|
+
}
|
|
201
|
+
interface CRDTStateHook665<S> {
|
|
202
|
+
(v: S): [S, (patch: unknown) => void];
|
|
203
|
+
}
|
|
204
|
+
interface StreamLabOptions665 {
|
|
205
|
+
/** Route all bus traffic through the flood-gate transport fabric. */
|
|
206
|
+
floodGates?: boolean;
|
|
207
|
+
/** Transport provider for flood gates (memory by default in the VM). */
|
|
208
|
+
}
|
|
209
|
+
interface Outbound {
|
|
210
|
+
seq: number;
|
|
211
|
+
p: unknown;
|
|
212
|
+
acked: boolean;
|
|
213
|
+
sentAt: number;
|
|
214
|
+
timer?: ReturnType<typeof setTimeout>;
|
|
215
|
+
}
|
|
216
|
+
interface SyncStreamHandler665 {
|
|
217
|
+
onOrdered: (cb: (p: unknown, seq: number) => void) => void;
|
|
218
|
+
onComplete: (cb: () => void) => void;
|
|
219
|
+
close: () => void;
|
|
220
|
+
}
|
|
221
|
+
type SignalKey = any;
|
|
222
|
+
|
|
223
|
+
type AlienSignal<T> = {
|
|
224
|
+
(): T;
|
|
225
|
+
(next: T): void;
|
|
226
|
+
peek?: () => T;
|
|
227
|
+
};
|
|
228
|
+
type Change<T> = {
|
|
229
|
+
key: SignalKey;
|
|
230
|
+
previous: T;
|
|
231
|
+
current: T;
|
|
232
|
+
version: number;
|
|
233
|
+
timestamp: number;
|
|
234
|
+
source?: string;
|
|
235
|
+
};
|
|
236
|
+
type AtomContract<T> = {
|
|
237
|
+
name: string;
|
|
238
|
+
postcondition: (next: T, previous: T) => boolean;
|
|
239
|
+
block: boolean;
|
|
240
|
+
};
|
|
241
|
+
type SyncJob = () => void;
|
|
242
|
+
type AsyncEffectJob = {
|
|
243
|
+
id: string;
|
|
244
|
+
priority: number;
|
|
245
|
+
run: () => void | Promise<void>;
|
|
246
|
+
retry?: number;
|
|
247
|
+
timeout?: number;
|
|
248
|
+
};
|
|
249
|
+
type Unsubscribe = () => void;
|
|
250
|
+
type ConflictMeta = { at: number; node: string; userId?: string };
|
|
251
|
+
type ConflictEnvelope<T = any> = { value: T; meta: ConflictMeta };
|
|
252
|
+
type ConflictStrategy<T = any> = | 'lww' | 'merge' | { priority: string[] } | ((local: ConflictEnvelope<T> | undefined, remote: ConflictEnvelope<T>) => ConflictEnvelope<T>);
|
|
253
|
+
|
|
254
|
+
interface SHADOW_FN {
|
|
255
|
+
<T = any>(
|
|
256
|
+
v: T | (() => T),
|
|
257
|
+
key: string,
|
|
258
|
+
sl?: string | undefined,
|
|
259
|
+
ms?: string | undefined,
|
|
260
|
+
rt?: string | undefined,
|
|
261
|
+
): {
|
|
262
|
+
get: () => T;
|
|
263
|
+
set: (value: T | ((prev: T) => T)) => void;
|
|
264
|
+
subscribe: (fn: (value: T) => void) => () => void;
|
|
265
|
+
destroy: () => void;
|
|
266
|
+
exists: () => boolean;
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
use<T>(
|
|
270
|
+
v: T | (() => T),
|
|
271
|
+
key: string,
|
|
272
|
+
sl?: string | undefined,
|
|
273
|
+
ms?: string | undefined,
|
|
274
|
+
rt?: string | undefined,
|
|
275
|
+
): readonly [T, (value: T | ((prev: T) => T)) => void];
|
|
276
|
+
|
|
277
|
+
withTTL<T>(
|
|
278
|
+
v?: T | (() => T),
|
|
279
|
+
k?: string | undefined,
|
|
280
|
+
sl?: string | undefined,
|
|
281
|
+
ms?: string | undefined,
|
|
282
|
+
rt?: string | undefined,
|
|
283
|
+
ttlMs?: number,
|
|
284
|
+
): {
|
|
285
|
+
get: () => T | null;
|
|
286
|
+
set: (value: T | ((prev: T) => T)) => void;
|
|
287
|
+
subscribe: (fn: (value: T | null) => void) => () => void;
|
|
288
|
+
refresh: () => void;
|
|
289
|
+
destroy: () => void;
|
|
290
|
+
exists: () => boolean;
|
|
291
|
+
getTimeRemaining: () => number;
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
batch<T extends Record<string, any>>(
|
|
295
|
+
v: T,
|
|
296
|
+
options?: { debounceMs?: number },
|
|
297
|
+
key?: string | undefined,
|
|
298
|
+
sl?: string | undefined,
|
|
299
|
+
ms?: string | undefined,
|
|
300
|
+
rt?: string | undefined,
|
|
301
|
+
): {
|
|
302
|
+
get: () => T;
|
|
303
|
+
set: (updates: Partial<T> | ((prev: T) => Partial<T>)) => void;
|
|
304
|
+
subscribe: (fn: (value: T) => void) => () => void;
|
|
305
|
+
flush: () => void;
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
interface PORTAL_FN {
|
|
309
|
+
(k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined): any;
|
|
310
|
+
use(v?: any, k?: SU, sl?: string, ms?: string, rt?: string): any;
|
|
311
|
+
crdt(v?: any, k?: SU, sl?: string, ms?: string, rt?: string, trigger_render?: boolean, nodeId?: any): any;
|
|
312
|
+
umbrella(v: Record<string, any> | undefined, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, trigger_render?: boolean): any;
|
|
313
|
+
effect(effect: () => void | (() => void), k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, deps?: any[]): void;
|
|
314
|
+
context: {
|
|
315
|
+
(v: Record<string, any>, k: string, sl: string, ms: string, rt: string, trigger_render: boolean): any;
|
|
316
|
+
};
|
|
317
|
+
state: {
|
|
318
|
+
(v?: any, k?: SU, sl?: string, ms?: string, rt?: string): any;
|
|
319
|
+
use(v?: any, k?: SU, sl?: string, ms?: string, rt?: string, trigger_render?: boolean): any;
|
|
320
|
+
};
|
|
321
|
+
store: {
|
|
322
|
+
(v?: any | (() => any), key?: string | undefined, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined): any;
|
|
323
|
+
use(v?: any | (() => any), key?: string | undefined, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, trigger_render?: boolean): any;
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
type StateMeshReactor<T = any, A = any> = (state: T, action: A, snapshot: T) => T;
|
|
327
|
+
type StateMeshUpdater<T> = T | ((current: T) => T);
|
|
328
|
+
interface StateMesh<T = any, A = any> {
|
|
329
|
+
state: T;
|
|
330
|
+
snapshot(): T;
|
|
331
|
+
set(next: StateMeshUpdater<T>): void;
|
|
332
|
+
transition: <B = A>(action: B, reactor?: StateMeshReactor<T, B>) => void;
|
|
333
|
+
|
|
334
|
+
commit(): void;
|
|
335
|
+
rollback(): void;
|
|
336
|
+
}
|
|
337
|
+
type SamplingRate = {
|
|
338
|
+
numerator: number;
|
|
339
|
+
denominator: number;
|
|
340
|
+
};
|
|
341
|
+
type ProbabilisticSampling = {
|
|
342
|
+
version: 1;
|
|
343
|
+
algorithm: 'fnv1a64';
|
|
344
|
+
seed: string;
|
|
345
|
+
rate: SamplingRate;
|
|
346
|
+
namespace: string;
|
|
347
|
+
};
|
|
348
|
+
type ProbabilisticOptions<T> = {
|
|
349
|
+
// Exact probability as a fraction. { numerator: 1, denominator: 10 } means keep approximately 10%. Avoids float ambiguity across runtimes.
|
|
350
|
+
rate: SamplingRate;
|
|
351
|
+
// Shared deterministic seed. Same seed + namespace + key = same sampling decision.
|
|
352
|
+
seed: string | number;
|
|
353
|
+
|
|
354
|
+
// Stable identity of the logical item. Must remain unchanged across producer, consumer, retries, replay, reconnects, and process restarts. Prefer event ID / record ID / trace ID.
|
|
355
|
+
key: (chunk: T, index: number) => string;
|
|
356
|
+
// Separates unrelated sampled populations that happen to use the same seed. Keep this constant on both ends.
|
|
357
|
+
|
|
358
|
+
namespace?: string;
|
|
359
|
+
};
|
|
360
|
+
type ProbabilisticSender = (
|
|
361
|
+
p: any,
|
|
362
|
+
onChunk: (chunk: any) => void,
|
|
363
|
+
k: string,
|
|
364
|
+
sl?: SU,
|
|
365
|
+
ms?: SU,
|
|
366
|
+
rt?: SU,
|
|
367
|
+
chain?: 'chain' | 'rechain',
|
|
368
|
+
binary?: boolean,
|
|
369
|
+
) => Promise<void>;
|
|
370
|
+
type SamplingEnvelope<T> = {
|
|
371
|
+
__probabilistic: ProbabilisticSampling;
|
|
372
|
+
data: T;
|
|
373
|
+
};
|
|
374
|
+
type SamplingConfig = {
|
|
375
|
+
version?: 1;
|
|
376
|
+
rate: number; // 0..1
|
|
377
|
+
seed: string | number;
|
|
378
|
+
algorithm?: 'fnv1a64';
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
type StreamEncoding = 'json' | 'msgpack' | 'binary';
|
|
382
|
+
type StreamRetryMode = | 'none' | 'at-least-once' | 'idempotent';
|
|
383
|
+
type StreamContractOffer = {
|
|
384
|
+
protocol: 'stream-contract';
|
|
385
|
+
version: 1;
|
|
386
|
+
|
|
387
|
+
schemas: readonly string[];
|
|
388
|
+
encodings: readonly StreamEncoding[];
|
|
389
|
+
|
|
390
|
+
limits: {
|
|
391
|
+
maxChunkBytes: number;
|
|
392
|
+
maxInFlightChunks: number;
|
|
393
|
+
maxInFlightBytes?: number;
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
retry: {
|
|
397
|
+
modes: readonly StreamRetryMode[];
|
|
398
|
+
maxAttempts: number;
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
capabilities?: Record<string, boolean>;
|
|
402
|
+
};
|
|
403
|
+
type NegotiatedStreamContract = {
|
|
404
|
+
protocol: 'stream-contract';
|
|
405
|
+
version: 1;
|
|
406
|
+
|
|
407
|
+
schema: string;
|
|
408
|
+
encoding: StreamEncoding;
|
|
409
|
+
|
|
410
|
+
limits: {
|
|
411
|
+
maxChunkBytes: number;
|
|
412
|
+
maxInFlightChunks: number;
|
|
413
|
+
maxInFlightBytes?: number;
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
retry: {
|
|
417
|
+
mode: StreamRetryMode;
|
|
418
|
+
maxAttempts: number;
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
capabilities: Record<string, boolean>;
|
|
422
|
+
};
|
|
423
|
+
type NegotiationChunk =
|
|
424
|
+
| {
|
|
425
|
+
type: 'negotiate.accept';
|
|
426
|
+
contract: NegotiatedStreamContract;
|
|
427
|
+
}
|
|
428
|
+
| {
|
|
429
|
+
type: 'negotiate.reject';
|
|
430
|
+
code: string;
|
|
431
|
+
message: string;
|
|
432
|
+
};
|
|
433
|
+
type ConstellationFailureMode2 = 'continue' | 'fail-fast';
|
|
434
|
+
type ConstellationMember2 = {
|
|
435
|
+
id: string;
|
|
436
|
+
p: any;
|
|
437
|
+
k: string;
|
|
438
|
+
sl?: SU;
|
|
439
|
+
ms?: SU;
|
|
440
|
+
rt?: SU;
|
|
441
|
+
binary?: boolean;
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Relative scheduling priority.
|
|
445
|
+
* 1 = one turn, 2 = two turns, etc.
|
|
446
|
+
*/
|
|
447
|
+
weight?: number;
|
|
448
|
+
};
|
|
449
|
+
type ConstellationChunk2 = {
|
|
450
|
+
memberId: string;
|
|
451
|
+
chunk: any;
|
|
452
|
+
receivedAt: number;
|
|
453
|
+
};
|
|
454
|
+
type ConstellationMemberStatus2 = | 'running' | 'done' | 'error' | 'removed';
|
|
455
|
+
type ConstellationMemberSnapshot2 = {
|
|
456
|
+
id: string;
|
|
457
|
+
status: ConstellationMemberStatus2;
|
|
458
|
+
queuedChunks: number;
|
|
459
|
+
error?: Error;
|
|
460
|
+
};
|
|
461
|
+
type ConstellationStrategy = | 'round-robin' | 'weighted' | 'least-busy' | 'first-alive';
|
|
462
|
+
type ConstellationFailover = | 'next-member' | 'retry-same' | 'abort';
|
|
463
|
+
type ConstellationOptions2 = {
|
|
464
|
+
failure?: ConstellationFailureMode2;
|
|
465
|
+
maxQueuedChunksPerMember?: number;
|
|
466
|
+
onMemberStatus?: (
|
|
467
|
+
member: ConstellationMember,
|
|
468
|
+
status: ConstellationMemberStatus,
|
|
469
|
+
error?: Error,
|
|
470
|
+
) => void;
|
|
471
|
+
|
|
472
|
+
// ---- from constellation3 ----
|
|
473
|
+
/** Selection strategy for picking the next ready member. Default: 'weighted'. */
|
|
474
|
+
strategy?: ConstellationStrategy;
|
|
475
|
+
|
|
476
|
+
/** What to do when a member's stream throws or rejects. Default: 'next-member'. */
|
|
477
|
+
failover?: ConstellationFailover;
|
|
478
|
+
|
|
479
|
+
/** Max retries before giving up (used by 'retry-same' and 'next-member'). Default: 2. */
|
|
480
|
+
maxRetries?: number;
|
|
481
|
+
|
|
482
|
+
/** How many consecutive failures before a member is marked unhealthy. Default: 3. */
|
|
483
|
+
unhealthyAfterFailures?: number;
|
|
484
|
+
|
|
485
|
+
/** Interval (ms) for the health/idle sweep. 0 disables. Default: 5_000. */
|
|
486
|
+
healthCheckMs?: number;
|
|
487
|
+
|
|
488
|
+
/** Evict idle members after this many ms of no use. 0 disables. Default: 0. */
|
|
489
|
+
idleEvictMs?: number;
|
|
490
|
+
|
|
491
|
+
/** Called when a member joins the constellation. */
|
|
492
|
+
onMemberJoin?: (member: ConstellationMember) => void;
|
|
493
|
+
|
|
494
|
+
/** Called when a member leaves (manual, idle, or error). */
|
|
495
|
+
onMemberLeave?: (
|
|
496
|
+
member: ConstellationMember,
|
|
497
|
+
reason?: 'error' | 'manual' | 'idle',
|
|
498
|
+
) => void;
|
|
499
|
+
|
|
500
|
+
/** Called when a failover occurs: `to` is null if no successor was available. */
|
|
501
|
+
onFailover?: (
|
|
502
|
+
from: ConstellationMember,
|
|
503
|
+
to: ConstellationMember | null,
|
|
504
|
+
error: unknown,
|
|
505
|
+
) => void;
|
|
506
|
+
};
|
|
507
|
+
type ConstellationHandle2 = {
|
|
508
|
+
readonly done: Promise<void>;
|
|
509
|
+
|
|
510
|
+
join(member: ConstellationMember2): void;
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* Stops forwarding output from this member.
|
|
514
|
+
* This does not mutate or depend on your existing fn implementation.
|
|
515
|
+
*/
|
|
516
|
+
remove(memberId: string): boolean;
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Stops forwarding all future output and rejects `done`.
|
|
520
|
+
*/
|
|
521
|
+
abort(reason?: unknown): void;
|
|
522
|
+
|
|
523
|
+
members(): readonly ConstellationMemberSnapshot2[];
|
|
524
|
+
setHealth(memberId: any, healthy: any): any
|
|
525
|
+
on(event: string, handler: (e: Event) => void): any
|
|
526
|
+
dispose(): any
|
|
527
|
+
};
|
|
528
|
+
type ConstellationFactory2 = (options?: ConstellationOptions2,) => (onChunk?: (event: ConstellationChunk2) => void,) => ConstellationHandle2;
|
|
529
|
+
type ConstellationFactory = (options?: ConstellationOptions,) => (onChunk?: (event: ConstellationChunk) => void,) => ConstellationHandle
|
|
530
|
+
type ConstellationOptions = {
|
|
531
|
+
strategy?: 'round-robin' | 'weighted' | 'least-busy' | 'first-alive'
|
|
532
|
+
failure?: 'continue' | 'fail-fast'
|
|
533
|
+
maxQueuedChunksPerMember?: number
|
|
534
|
+
maxRetries?: number
|
|
535
|
+
onMemberStatus?: (
|
|
536
|
+
member: ConstellationMember,
|
|
537
|
+
status: ConstellationMemberStatus,
|
|
538
|
+
error?: Error,
|
|
539
|
+
) => void
|
|
540
|
+
onFailover?: (
|
|
541
|
+
from: ConstellationMember,
|
|
542
|
+
to: ConstellationMember | null,
|
|
543
|
+
error: unknown,
|
|
544
|
+
) => void
|
|
545
|
+
}
|
|
546
|
+
type ConstellationMember = {
|
|
547
|
+
id: string
|
|
548
|
+
p: any
|
|
549
|
+
k: string
|
|
550
|
+
sl?: SU
|
|
551
|
+
ms?: SU
|
|
552
|
+
rt?: SU
|
|
553
|
+
binary?: boolean
|
|
554
|
+
weight?: number
|
|
555
|
+
}
|
|
556
|
+
type ConstellationMemberStatus = | 'running' | 'done' | 'error' | 'removed'
|
|
557
|
+
type ConstellationChunk = {
|
|
558
|
+
memberId: string
|
|
559
|
+
chunk: any
|
|
560
|
+
receivedAt: number
|
|
561
|
+
}
|
|
562
|
+
type ConstellationHandle = {
|
|
563
|
+
done: Promise<void>
|
|
564
|
+
|
|
565
|
+
join(member: ConstellationMember): void
|
|
566
|
+
|
|
567
|
+
remove(memberId: string): boolean
|
|
568
|
+
|
|
569
|
+
abort(reason?: unknown): void
|
|
570
|
+
|
|
571
|
+
members(): Array<{
|
|
572
|
+
id: string
|
|
573
|
+
status: ConstellationMemberStatus
|
|
574
|
+
queuedChunks: number
|
|
575
|
+
error?: Error
|
|
576
|
+
}>
|
|
577
|
+
}
|
|
578
|
+
type StreamAddress = {
|
|
579
|
+
streamId: string;
|
|
580
|
+
k: string;
|
|
581
|
+
sl?: SU;
|
|
582
|
+
ms?: SU;
|
|
583
|
+
rt?: SU;
|
|
584
|
+
};
|
|
585
|
+
type LiminalState = 'waiting' | 'live' | 'closed';
|
|
586
|
+
type LiminalChunk<T = unknown> = {
|
|
587
|
+
type: 'liminal';
|
|
588
|
+
direction: 'upstream->downstream' | 'downstream->upstream';
|
|
589
|
+
data: T;
|
|
590
|
+
upstreamStreamId: string;
|
|
591
|
+
downstreamStreamId: string;
|
|
592
|
+
observedAt: number;
|
|
593
|
+
};
|
|
594
|
+
type StreamChunk<T = unknown> = {
|
|
595
|
+
type: 'chunk';
|
|
596
|
+
data: T;
|
|
597
|
+
streamId?: string;
|
|
598
|
+
ts?: number;
|
|
599
|
+
};
|
|
600
|
+
type StreamDone = {
|
|
601
|
+
type: 'done';
|
|
602
|
+
streamId?: string;
|
|
603
|
+
ts?: number;
|
|
604
|
+
};
|
|
605
|
+
type StreamError = {
|
|
606
|
+
type: 'error';
|
|
607
|
+
error: string | Error | unknown;
|
|
608
|
+
streamId?: string;
|
|
609
|
+
ts?: number;
|
|
610
|
+
};
|
|
611
|
+
type StreamEvent<T = unknown> =
|
|
612
|
+
| StreamChunk<T>
|
|
613
|
+
| StreamDone
|
|
614
|
+
| StreamError;
|
|
615
|
+
type rts = { sl?: any; ms?: any; rt?: any }
|
|
616
|
+
type SIG_BUS_Boundary = 'same-app' | 'same-node' | 'cross-node'
|
|
617
|
+
type SIG_BUS_Priority = 'high' | 'normal' | 'low';
|
|
618
|
+
type SIG_BUS_Strategy = 'overwrite' | 'merge' | 'skip';
|
|
619
|
+
type SIG_BUS_SyncDirection = 'memory->adapter' | 'adapter->memory' | 'both';
|
|
620
|
+
type SIG_BUS_DeliveryStatus = 'ack' | 'nak';
|
|
621
|
+
type SIG_BUS_AdapterSendPayload = | SIG_BUS_Message | Uint8Array | SIG_BUS_SecureEnvelope;
|
|
622
|
+
type SIG_BUS_Handler = (p: any, ctx?: SIG_BUS_HandlerContext) => any | Promise<any>;
|
|
623
|
+
type SIG_BUS_CBORValue = null | boolean | number | string | Uint8Array | SIG_BUS_CBORValue[] | { [k: string]: SIG_BUS_CBORValue }
|
|
624
|
+
type SIG_BUS_QueryExpr = | { type: 'eq'; key: string; value: unknown } | { type: 'and'; exprs: SIG_BUS_QueryExpr[] } | { type: 'or'; exprs: SIG_BUS_QueryExpr[] };
|
|
625
|
+
interface SIG_BUS_Adapter {
|
|
626
|
+
id?: string;
|
|
627
|
+
send(msg: SIG_BUS_AdapterSendPayload): void;
|
|
628
|
+
onMessage(handler: (msg: SIG_BUS_AdapterSendPayload) => void): () => void;
|
|
629
|
+
onConnect?(handler: () => void): void;
|
|
630
|
+
onDisconnect?(handler: () => void): void;
|
|
631
|
+
}
|
|
632
|
+
interface SIG_BUS_SecureEnvelope {
|
|
633
|
+
sessionId: string;
|
|
634
|
+
token: string;
|
|
635
|
+
p: SIG_BUS_Message | SIG_BUS_CBORValue;
|
|
636
|
+
}
|
|
637
|
+
interface SIG_BUS_Message {
|
|
638
|
+
id: string;
|
|
639
|
+
rt: string;
|
|
640
|
+
ms?: string;
|
|
641
|
+
sl?: string;
|
|
642
|
+
k?: string;
|
|
643
|
+
topic?: string;
|
|
644
|
+
p: unknown;
|
|
645
|
+
ttl?: number;
|
|
646
|
+
ts?: number;
|
|
647
|
+
_ack?: boolean;
|
|
648
|
+
_adapter?: SIG_BUS_Adapter;
|
|
649
|
+
priority?: any;
|
|
650
|
+
tags?: string[];
|
|
651
|
+
streamId?: string;
|
|
652
|
+
sessionId?: any;
|
|
653
|
+
token?: any;
|
|
654
|
+
binary?: 'signal_save_value' | 'signal' | true | false | string;
|
|
655
|
+
error?: any
|
|
656
|
+
adapter_id?: any
|
|
657
|
+
cross_cse_ngin_connect_adapter_id?: any
|
|
658
|
+
cross_app_adapter_adapter_id?: any
|
|
659
|
+
type?: string
|
|
660
|
+
boundary?: SIG_BUS_Boundary
|
|
661
|
+
}
|
|
662
|
+
interface SIG_BUS_BackpressureConfig {
|
|
663
|
+
maxQueueSize?: number;
|
|
664
|
+
slowConsumerThresholdMs?: number;
|
|
665
|
+
throttleMs?: number;
|
|
666
|
+
}
|
|
667
|
+
interface SIG_BUS_Schema {
|
|
668
|
+
validate(p: unknown): boolean;
|
|
669
|
+
coerce?(p: unknown): unknown;
|
|
670
|
+
}
|
|
671
|
+
interface SIG_BUS_rtPermissions {
|
|
672
|
+
allow?: string[];
|
|
673
|
+
deny?: string[];
|
|
674
|
+
read?: string[];
|
|
675
|
+
write?: string[];
|
|
676
|
+
}
|
|
677
|
+
interface SIG_BUS_rtInfo {
|
|
678
|
+
rt: string;
|
|
679
|
+
handlers: number;
|
|
680
|
+
adapters: string[];
|
|
681
|
+
middleware: number;
|
|
682
|
+
messageCount: number;
|
|
683
|
+
tags: string[];
|
|
684
|
+
}
|
|
685
|
+
interface SIG_BUS_AdapterMetrics {
|
|
686
|
+
id: string;
|
|
687
|
+
latencyMs: number;
|
|
688
|
+
failureRate: number;
|
|
689
|
+
throughputPerSec: number;
|
|
690
|
+
healthy: boolean;
|
|
691
|
+
disabled: boolean;
|
|
692
|
+
}
|
|
693
|
+
interface SIG_BUS_RouteRule {
|
|
694
|
+
name: string;
|
|
695
|
+
match: (msg: SIG_BUS_Message | SIG_BUS_CBORValue) => boolean;
|
|
696
|
+
targetAdapters?: string[];
|
|
697
|
+
targetrts?: string[];
|
|
698
|
+
}
|
|
699
|
+
interface SIG_BUS_Transform {
|
|
700
|
+
outgoing?(msg: SIG_BUS_Message | SIG_BUS_CBORValue): SIG_BUS_Message | Promise<SIG_BUS_Message>;
|
|
701
|
+
incoming?(msg: SIG_BUS_Message | SIG_BUS_CBORValue): SIG_BUS_Message | Promise<SIG_BUS_Message>;
|
|
702
|
+
}
|
|
703
|
+
interface SIG_BUS_EncryptionConfig {
|
|
704
|
+
rt?: string;
|
|
705
|
+
adapterId?: string;
|
|
706
|
+
secret?: string;
|
|
707
|
+
publicKey?: string;
|
|
708
|
+
algorithm?: string;
|
|
709
|
+
}
|
|
710
|
+
interface SIG_BUS_DurableOptions {
|
|
711
|
+
subscriberId: string;
|
|
712
|
+
fromOffset?: number;
|
|
713
|
+
fromTimestamp?: number;
|
|
714
|
+
tags?: string[];
|
|
715
|
+
}
|
|
716
|
+
interface SIG_BUS_ReplayOptions {
|
|
717
|
+
rt: string;
|
|
718
|
+
fromOffset?: number;
|
|
719
|
+
toOffset?: number;
|
|
720
|
+
fromTimestamp?: number;
|
|
721
|
+
toTimestamp?: number;
|
|
722
|
+
tags?: string[];
|
|
723
|
+
}
|
|
724
|
+
interface SIG_BUS_GroupOptions {
|
|
725
|
+
enabled?: boolean;
|
|
726
|
+
middleware?: (msg: SIG_BUS_Message | SIG_BUS_CBORValue) => boolean | void;
|
|
727
|
+
}
|
|
728
|
+
interface SIG_BUS_SendOptions {
|
|
729
|
+
ttl?: number;
|
|
730
|
+
priority?: SIG_BUS_Priority;
|
|
731
|
+
tags?: string[];
|
|
732
|
+
metadata?: Record<string, unknown>;
|
|
733
|
+
expectReply?: boolean;
|
|
734
|
+
}
|
|
735
|
+
interface SIG_BUS_BatchItem {
|
|
736
|
+
rt: string;
|
|
737
|
+
p: Record<string, unknown>;
|
|
738
|
+
}
|
|
739
|
+
interface SIG_BUS_HandlerContext {
|
|
740
|
+
rt: string;
|
|
741
|
+
adapter?: SIG_BUS_Adapter;
|
|
742
|
+
meta: SIG_BUS_MessageMeta;
|
|
743
|
+
}
|
|
744
|
+
interface SIG_BUS_ClusterConfig {
|
|
745
|
+
nodeId: string;
|
|
746
|
+
peers: string[];
|
|
747
|
+
}
|
|
748
|
+
interface SIG_BUS_WebRTCAdapterOptions {
|
|
749
|
+
signalingAdapter: SIG_BUS_Adapter;
|
|
750
|
+
peerId: string;
|
|
751
|
+
iceServers?: RTCIceServer[];
|
|
752
|
+
}
|
|
753
|
+
interface SIG_BUS_MessageMeta {
|
|
754
|
+
id?: string;
|
|
755
|
+
ttl?: number;
|
|
756
|
+
priority?: SIG_BUS_Priority;
|
|
757
|
+
tags?: string[];
|
|
758
|
+
timestamp?: number;
|
|
759
|
+
streamId?: string;
|
|
760
|
+
[key: string]: unknown;
|
|
761
|
+
}
|
|
762
|
+
interface SIG_BUS_CompressionConfig {
|
|
763
|
+
rt?: string;
|
|
764
|
+
adapterId?: string;
|
|
765
|
+
algorithm: string;
|
|
766
|
+
}
|
|
767
|
+
interface SIG_BUS_SEND_FN {
|
|
768
|
+
(ppayload: unknown, k: string, sl?: string, ms?: string, rt?: string, ttl?: number, chain?: 'chain' | 'rechain', binary?: boolean): Promise<unknown>
|
|
769
|
+
broadcast(p: unknown, k: string, sl?: string, ms?: string, rt?: string, ttl?: number, binary?: boolean): Promise<unknown>
|
|
770
|
+
broadcastState(state: any, k: string, sl: string, ms: string, rt: string, chain?: 'chain' | 'rechain'): any
|
|
771
|
+
bare_metal(p: unknown, k: string, sl?: string, ms?: string, rt?: string, boundary?: "same-app" | "same-node" | "cross-node"): Promise<unknown>
|
|
772
|
+
emit(event: string, p: any, sl?: string, ms?: string, rt?: string): void
|
|
773
|
+
}
|
|
774
|
+
interface SIG_BUS_SUB_FN {
|
|
775
|
+
(handler: any, k: string, sl?: string, ms?: string, rt?: string, boundary?: Boundary): any
|
|
776
|
+
subscribe(handler: (d: unknown) => MaybePromise<void>, quad: string, trip: string, sub: string, ch: string,): any
|
|
777
|
+
}
|
|
778
|
+
interface SIG_BUS_BOUNDARY_FN {
|
|
779
|
+
register(k: string, sl?: string, ms?: string, rt?: string, boundary?: Boundary): any
|
|
780
|
+
probe<T = any>(p: unknown, k: string, sl?: string, ms?: string, rt?: string, boundary?: "same-app" | "same-node" | "cross-node"): any
|
|
781
|
+
|
|
782
|
+
}
|
|
783
|
+
interface SIG_BUS_CELL_FN {
|
|
784
|
+
<T = any>(k: string, sl?: string, ms?: string, rt?: string, chain?: 'chain' | 'rechain', v?: T): any
|
|
785
|
+
send<T = any>(p: unknown, k: string, sl?: string, ms?: string, rt?: string, chain?: 'chain' | 'rechain'): any
|
|
786
|
+
cell<T = any>(k: string, sl?: string, ms?: string, rt?: string, type?: 'waitFor' | 'sub' | 'cell', chain?: 'chain' | 'rechain', v?: T): any
|
|
787
|
+
crdt<T = any>(k: string, sl?: string, ms?: string, rt?: string, chain?: 'chain' | 'rechain', v?: T): any
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
type CELL_TYPE = 'waitFor' | 'sub' | 'cell' | 'none'
|
|
791
|
+
type CHAIN_TYPE = 'chain' | 'rechain'
|
|
792
|
+
type STORE_TYPE = 'tc' | 'rr' | 'auto'
|
|
793
|
+
type INI_QD<T = any> = [v?: T, k?: string, sl?: string, ms?: string, rt?: string]
|
|
794
|
+
// ...args: [...INI_QD<T>,]
|
|
795
|
+
// mailbox<T = any>(...args: [...INI_QD<T>, ]): any
|
|
796
|
+
type QD_INI = [k: string, v?: any, sl?: string, ms?: string, rt?: string,]
|
|
797
|
+
// ...args: [...QD_INI,]
|
|
798
|
+
// mailbox(...args: [...QD_INI, ]): any
|
|
799
|
+
type QD = [k: string, sl?: string, ms?: string, rt?: string]
|
|
800
|
+
// ...args: [...QD,]
|
|
801
|
+
// mailbox(...args: [...QD, ]): any
|
|
802
|
+
|
|
803
|
+
|
|
804
|
+
interface SIG_BUS_DEPLUX_FN {
|
|
805
|
+
(k: string, sl?: string, ms?: string, rt?: string, opts?: { windowSize?: number; livenessId?: string; }, type?: string): any;
|
|
806
|
+
async<TUp = any, TDown = any>(...args: [...QD, opts?: { windowSize?: number }]): any;
|
|
807
|
+
solo(readConfig: { k: string; sl?: string; ms?: string; rt?: string },
|
|
808
|
+
writeConfig: { k?: string; sl?: string; ms?: string; rt?: string }
|
|
809
|
+
): { sub: ReadableStream; send: WritableStream }
|
|
810
|
+
open(...args: [opts: any, ...QD,]): any
|
|
811
|
+
sx(...args: [...QD, opts: any]): any
|
|
812
|
+
}
|
|
813
|
+
interface DUPLEX_HANDLER_FN {
|
|
814
|
+
<TUp = any, TDown = any>(handlerFn: (data: TUp, stream: any) => void | Promise<void>, k: string, sl?: string, ms?: string, rt?: string, opts?: { windowSize?: number; }, type?: 'default' | 'sync' | 'stream-relay' | 'rate-limited' | 'fan-out' | 'priority' | 'transactional' | 'presence' | 'authority' | 'multicast' | 'partitioned' | 'batch' | 'filtered' | 'idempotent' | 'checkpoint' | 'transform'): any;
|
|
815
|
+
|
|
816
|
+
async<TUp = any, TDown = any>(handlerFn: (data: TUp, stream: DuplexStream<TDown, TUp>) => void | Promise<void>, k: string, sl?: string, ms?: string, rt?: string, opts?: { windowSize?: number }): any;
|
|
817
|
+
}
|
|
818
|
+
interface DuplexStream<TSend = any, TRecv = any> {
|
|
819
|
+
send: (p: TSend) => void;
|
|
820
|
+
onData: (handler: (chunk: TRecv, seq: number) => void) => () => boolean;
|
|
821
|
+
onError: (handler: (err: DuplexError) => void) => () => boolean;
|
|
822
|
+
onRemoteClose: (handler: () => void) => () => boolean;
|
|
823
|
+
closeUp?: () => void;
|
|
824
|
+
closeDown?: () => void;
|
|
825
|
+
close: () => void;
|
|
826
|
+
isFullyClosed: () => boolean;
|
|
827
|
+
isFatallyErrored: () => boolean;
|
|
828
|
+
}
|
|
829
|
+
interface DuplexError {
|
|
830
|
+
dir: 'up' | 'down';
|
|
831
|
+
message: string;
|
|
832
|
+
fatal: boolean;
|
|
833
|
+
retryable?: boolean;
|
|
834
|
+
code?: string;
|
|
835
|
+
}
|
|
836
|
+
type LateArrivalStrategy = 'discard' | 'delay' | 'reorder';
|
|
837
|
+
type CompressFormat = 'gzip' | 'deflate' | 'deflate-raw' | 'brotli' | 'zstd';
|
|
838
|
+
interface HANDLER_FN {
|
|
839
|
+
(handler: (d: any) => any, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, binary?: boolean): any;
|
|
840
|
+
syncGuard(handler: (chunk: any, seq: number, streamId: string) => Promise<void> | void, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, options?: SyncSubGuardOptions): void;
|
|
841
|
+
sync(k: string, sl?: string, ms?: string, rt?: string): any;
|
|
842
|
+
sync_2(handler: (chunk: any, seq: number) => Promise<void> | void, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, binary?: boolean): void;
|
|
843
|
+
openSync(handler: (chunk: any, seq: number) => Promise<void> | void, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined): () => void;
|
|
844
|
+
priority(handler: (p: any) => void, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined): () => void;
|
|
845
|
+
transactional(apply: (chunks: any[]) => Promise<void> | void, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined): () => void;
|
|
846
|
+
delta<T>(applyPatch: (current: T, diff: any) => T, v: T, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined): any;
|
|
847
|
+
presence(k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, onUpdate?: (all: Record<string, any>) => void): any;
|
|
848
|
+
authority<T>(resolve: (guess: T) => Promise<T> | T, k: string, sl: string, ms: string, rt: string): () => void;
|
|
849
|
+
heartbeat(onDead: () => void, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, opts?: { deadThresholdMs?: number }): any;
|
|
850
|
+
backpressure(handler: (p: any) => Promise<void> | void, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined): () => void;
|
|
851
|
+
stateful(handler: (p: any) => void, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, opts?: { key?: string }): any;
|
|
852
|
+
multicast(receiverId: string, handler: (p: any, seq: number) => void, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, opts?: { key?: string; startFrom?: 'beginning' | 'now' }): Promise<any>;
|
|
853
|
+
partitioned(handler: (key: string, p: any, partition: number) => void, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, opts?: { partitions?: number[]; partitionCount?: number }): any;
|
|
854
|
+
batch(handler: (p: any) => void, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined): () => void;
|
|
855
|
+
filtered(handler: (p: any) => void, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, predicate?: (p: any) => boolean): () => void;
|
|
856
|
+
deadLetter(handler: (entry: SIG_BUS_Message) => Promise<boolean> | boolean): any;
|
|
857
|
+
idempotent(handler: (p: any) => Promise<void> | void, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, opts?: { keyPrefix?: string; ttlMs?: number }): any;
|
|
858
|
+
lateArrival(handler: (p: any, seq: number) => void, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, opts?: { strategy?: LateArrivalStrategy; toleranceMs?: number }): () => void;
|
|
859
|
+
checkpoint(streamKey: string, handler: (p: any, seq: number) => Promise<void> | void, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, opts?: { every?: number }): Promise<any>;
|
|
860
|
+
rateLimited(handler: (p: any) => void, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined): () => void;
|
|
861
|
+
combo(k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined): any;
|
|
862
|
+
transform<T = any, R = any>(fn: (p: T) => Promise<R> | R, onResult: (result: R, seq: number) => void, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, opts?: { concurrency?: number }): () => void;
|
|
863
|
+
map<T = any, R = any>(fn: (item: T) => R, onResult: (r: R, seq: number) => void, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, opts?: { concurrency?: number }): () => void;
|
|
864
|
+
filter<T = any>(predicate: (item: T) => boolean, onResult: (item: T, seq: number) => void, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined): () => void;
|
|
865
|
+
reduce<T = any, R = any>(fn: (acc: R, item: T) => R, v: R, onUpdate: (acc: R) => void, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined): () => void;
|
|
866
|
+
fanout(receiverId: string, handler: (p: any, seq: number) => void, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, opts?: { key?: string; startFrom?: 'beginning' | 'now' }): Promise<any>;
|
|
867
|
+
useDRSS<T extends Record<string, unknown>>(v: any, handler: (chunk: any, state: any) => any | Promise<T>, k: string, sl?: string, ms?: string, rt?: string, binary?: boolean): any;
|
|
868
|
+
useDRSSSync(v: any, handler: (chunk: any, seq: number, state: any) => any | Promise<any>, k: string, sl?: string, ms?: string, rt?: string, binary?: boolean): any;
|
|
869
|
+
}
|
|
870
|
+
interface SyncSubGuardOptions {
|
|
871
|
+
sl?: string;
|
|
872
|
+
ms?: string;
|
|
873
|
+
rt?: string;
|
|
874
|
+
maxBufferSize?: number;
|
|
875
|
+
streamTTLMs?: number;
|
|
876
|
+
maxStreams?: number;
|
|
877
|
+
binary?: boolean;
|
|
878
|
+
onStreamComplete?: (streamId: string, totalChunks: number) => void;
|
|
879
|
+
onStreamError?: (streamId: string, error: string) => void;
|
|
880
|
+
}
|
|
881
|
+
interface FieldTouch {
|
|
882
|
+
field: string;
|
|
883
|
+
action: 'viewing' | 'editing';
|
|
884
|
+
userId?: string;
|
|
885
|
+
timestamp?: number;
|
|
886
|
+
[key: string]: any;
|
|
887
|
+
}
|
|
888
|
+
interface DRSConflictOptions {
|
|
889
|
+
k?: string;
|
|
890
|
+
sl?: string;
|
|
891
|
+
ms?: string;
|
|
892
|
+
rt?: string;
|
|
893
|
+
conflictStrategy?: 'lww' | 'version-vector' | 'custom' | string;
|
|
894
|
+
versionKey?: string;
|
|
895
|
+
debounceMs?: number;
|
|
896
|
+
binary?: boolean;
|
|
897
|
+
onConflict?: (local: any, remote: any) => any;
|
|
898
|
+
}
|
|
899
|
+
interface RelayFlowOptions extends StreamRelayOptions { }
|
|
900
|
+
interface SyncIntegrityOptions {
|
|
901
|
+
sl?: string;
|
|
902
|
+
ms?: string;
|
|
903
|
+
rt?: string;
|
|
904
|
+
windowSize?: number;
|
|
905
|
+
chunkRetries?: number;
|
|
906
|
+
retryBackoffMs?: number;
|
|
907
|
+
timeoutMs?: number;
|
|
908
|
+
binary?: boolean;
|
|
909
|
+
priority?: any;
|
|
910
|
+
ttl?: number;
|
|
911
|
+
onProgress?: (sent: number, acked: number, total: number) => void;
|
|
912
|
+
onChunkFailed?: (seq: number, retries: number) => void;
|
|
913
|
+
}
|
|
914
|
+
interface SyncIntegrityResult {
|
|
915
|
+
success: boolean;
|
|
916
|
+
delivered: number;
|
|
917
|
+
acknowledged: number;
|
|
918
|
+
failed: number[];
|
|
919
|
+
durationMs: number;
|
|
920
|
+
}
|
|
921
|
+
type ComboStrategy = 'arrival' | 'round-robin' | 'timestamp';
|
|
922
|
+
|
|
923
|
+
interface HydraStage<T> {
|
|
924
|
+
name: string;
|
|
925
|
+
handler: (data: T) => T;
|
|
926
|
+
}
|
|
927
|
+
type BackpressureRelayStrategy = 'drop-oldest' | 'drop-newest' | 'block' | 'drop' | 'latest' | 'error' | "pause";
|
|
928
|
+
interface StreamRelayOptions {
|
|
929
|
+
maxSubscribers?: number;
|
|
930
|
+
bufferSize?: number;
|
|
931
|
+
backpressureStrategy?: BackpressureRelayStrategy
|
|
932
|
+
deliveryGuarantee?: 'at-most-once' | 'at-least-once';
|
|
933
|
+
subscriberTimeoutMs?: number;
|
|
934
|
+
onSubscriberDrop?: (id: string, reason: string) => void;
|
|
935
|
+
}
|
|
936
|
+
interface SyncStreamOptions {
|
|
937
|
+
windowSize?: number;
|
|
938
|
+
retransmitMs?: number;
|
|
939
|
+
}
|
|
940
|
+
interface SyncStreamSendHandle {
|
|
941
|
+
push(p: unknown): void;
|
|
942
|
+
pendingCount(): number;
|
|
943
|
+
close(): void;
|
|
944
|
+
}
|
|
945
|
+
interface SyncStreamHandler {
|
|
946
|
+
onOrdered(cb: (p: unknown, seq: number) => void): void;
|
|
947
|
+
onComplete(cb: () => void): void;
|
|
948
|
+
close(): void;
|
|
949
|
+
}
|
|
950
|
+
interface Outbound {
|
|
951
|
+
seq: number;
|
|
952
|
+
p: unknown;
|
|
953
|
+
acked: boolean;
|
|
954
|
+
sentAt: number;
|
|
955
|
+
timer?: ReturnType<typeof setTimeout>;
|
|
956
|
+
}
|
|
957
|
+
interface SIG_BUS_useEffect_FN {
|
|
958
|
+
(effect: () => void | (() => void), deps: any[], k: string, sl: string, ms: string, rt: string): any;
|
|
959
|
+
auto(effect: (scope: ReturnType<any>) => void, deps: any[], k: string, sl: string, ms: string, rt: string): any;
|
|
960
|
+
layout(effect: any, deps: any, k: string, sl: string, ms: string, rt: string): any
|
|
961
|
+
}
|
|
962
|
+
interface SIG_BUS_STREAM_FN {
|
|
963
|
+
(p: any, onChunk: (chunk: any) => void, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, chain?: 'chain' | 'rechain', binary?: boolean): Promise<void>;
|
|
964
|
+
chunk(streamId: string, chunk: string, k: string, sl?: string, ms?: string, rt?: string): void
|
|
965
|
+
done(streamId: string, chunk: string, k: string, sl?: string, ms?: string, rt?: string): void
|
|
966
|
+
cancel(streamId: string, chunk: string, k: string, sl?: string, ms?: string, rt?: string): void
|
|
967
|
+
liminal<T = unknown>(upstream: StreamAddress, downstream: StreamAddress, onChunk: (event: LiminalChunk<T>) => void,): { id: string; done: Promise<void>; close: () => void; }
|
|
968
|
+
constellation(
|
|
969
|
+
options?: ConstellationOptions,
|
|
970
|
+
): (
|
|
971
|
+
onChunk?: (event: ConstellationChunk) => void,
|
|
972
|
+
) => ConstellationHandle
|
|
973
|
+
constellation2(
|
|
974
|
+
options?: ConstellationOptions2,
|
|
975
|
+
): (
|
|
976
|
+
onChunk: (event: ConstellationChunk2) => void,
|
|
977
|
+
) => ConstellationHandle2
|
|
978
|
+
negotiate(offer: StreamContractOffer, k: string, sl?: string, ms?: string, rt?: string, timeoutMs?: number,): Promise<NegotiatedStreamContract>
|
|
979
|
+
probabilistic<T>(send: ProbabilisticSender, options: ProbabilisticOptions<T>,): ProbabilisticSender
|
|
980
|
+
readable(k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined): ReadableStream<any>;
|
|
981
|
+
writable(k?: SU, sl?: string, ms?: string, rt?: string): WritableStream<any>;
|
|
982
|
+
StreamRelay(k?: SU, sl?: string, ms?: string, rt?: string, opts?: StreamRelayOptions): any;
|
|
983
|
+
transform(readConfig: {
|
|
984
|
+
k: string;
|
|
985
|
+
sl?: string | undefined;
|
|
986
|
+
ms?: string | undefined;
|
|
987
|
+
rt?: string | undefined;
|
|
988
|
+
}, writeConfig: {
|
|
989
|
+
k?: string | undefined;
|
|
990
|
+
sl?: string | undefined;
|
|
991
|
+
ms?: string | undefined;
|
|
992
|
+
rt?: string | undefined;
|
|
993
|
+
}, transformer?: (chunk: any) => any | Promise<any>): {
|
|
994
|
+
sub: TransformStream<any, any>;
|
|
995
|
+
send: TransformStream<any, any>;
|
|
996
|
+
};
|
|
997
|
+
pipeline<T = any>(k?: SU, sl?: string, ms?: string, rt?: string, stages?: HydraStage<T>[]): {
|
|
998
|
+
unsubscribe: () => void;
|
|
999
|
+
};
|
|
1000
|
+
route<T = any>(k?: SU, sl?: string, ms?: string, rt?: string, selectKey?: (p: T) => string, outPrefix?: string, opts?: {
|
|
1001
|
+
defaultKey?: string;
|
|
1002
|
+
onUnmatched?: (p: T, key: string) => void;
|
|
1003
|
+
}): {
|
|
1004
|
+
unsubscribe: () => void;
|
|
1005
|
+
stats: () => Record<string, number>;
|
|
1006
|
+
};
|
|
1007
|
+
syncGuard(chunks: any[], k: string, options?: SyncIntegrityOptions): Promise<SyncIntegrityResult>;
|
|
1008
|
+
relayWithFlowControl(k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, options?: RelayFlowOptions): any;
|
|
1009
|
+
useDRSWithConsensus(vState: any, k?: SU, sl?: string, ms?: string, rt?: string, options?: DRSConflictOptions): any;
|
|
1010
|
+
|
|
1011
|
+
sync_2(chunks: any[], k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, onAck?: (seq: number) => void, windowSize?: number, binary?: boolean): Promise<void>;
|
|
1012
|
+
sync(k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, opts?: SyncStreamOptions): any;
|
|
1013
|
+
|
|
1014
|
+
relay(k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, options?: {
|
|
1015
|
+
maxSubscribers?: number;
|
|
1016
|
+
bufferSize?: number;
|
|
1017
|
+
backpressureStrategy?: 'drop' | 'pause' | 'error';
|
|
1018
|
+
}): any;
|
|
1019
|
+
openSync(k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, opts?: {
|
|
1020
|
+
windowSize?: number;
|
|
1021
|
+
}): any;
|
|
1022
|
+
priority(k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined): any;
|
|
1023
|
+
transactional(chunks: any[], k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined): Promise<{
|
|
1024
|
+
committed: boolean;
|
|
1025
|
+
error?: string;
|
|
1026
|
+
}>;
|
|
1027
|
+
delta<T extends any>(computeDelta: (prev: T, next: T) => any, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined): any;
|
|
1028
|
+
presence(k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined): any;
|
|
1029
|
+
authority<T = any>(v: T, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined): any;
|
|
1030
|
+
heartbeat(k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, opts?: {
|
|
1031
|
+
idleThresholdMs?: number;
|
|
1032
|
+
}): any;
|
|
1033
|
+
backpressure(k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, opts?: {
|
|
1034
|
+
windowSize?: number;
|
|
1035
|
+
}): any;
|
|
1036
|
+
stateful(k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, opts?: {
|
|
1037
|
+
key?: string;
|
|
1038
|
+
}): any;
|
|
1039
|
+
multicast(k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, opts?: {
|
|
1040
|
+
key?: string;
|
|
1041
|
+
}): any;
|
|
1042
|
+
partitioned(k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, opts?: {
|
|
1043
|
+
partitionCount?: number;
|
|
1044
|
+
}): any;
|
|
1045
|
+
batch(k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, opts?: {
|
|
1046
|
+
maxSize?: number;
|
|
1047
|
+
maxWaitMs?: number;
|
|
1048
|
+
}): any;
|
|
1049
|
+
filtered(predicate: (p: any) => boolean, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined): any;
|
|
1050
|
+
deadLetter(p: any, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, opts?: {
|
|
1051
|
+
maxRetries?: number;
|
|
1052
|
+
backoff?: any;
|
|
1053
|
+
}): Promise<{
|
|
1054
|
+
delivered: boolean;
|
|
1055
|
+
}>;
|
|
1056
|
+
idempotent(k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined): any;
|
|
1057
|
+
lateArrival(k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined): any;
|
|
1058
|
+
checkpoint(streamKey: string, opts?: {
|
|
1059
|
+
every?: number;
|
|
1060
|
+
}): any;
|
|
1061
|
+
rateLimited(opts: {
|
|
1062
|
+
ratePerSecond: number;
|
|
1063
|
+
burst?: number;
|
|
1064
|
+
}, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined): any;
|
|
1065
|
+
combo(k: string, sl: string[], ms?: string | undefined, rt?: string | undefined, strategy?: ComboStrategy): any;
|
|
1066
|
+
transformative(k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined): any;
|
|
1067
|
+
fanout(k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, opts?: {
|
|
1068
|
+
key?: string;
|
|
1069
|
+
}): any;
|
|
1070
|
+
useDRSS<T extends Record<string, unknown> = any, P = any>(v: any, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, binary?: boolean): any;
|
|
1071
|
+
useDRSSSync(v: any, k: string, sl?: string | undefined, ms?: string | undefined, rt?: string | undefined, binary?: boolean): any;
|
|
1072
|
+
}
|
|
1073
|
+
interface SIG_BUS_HANDLER_FN { }
|
|
1074
|
+
|
|
1075
|
+
|
|
1076
|
+
|
|
1077
|
+
|
|
1078
|
+
|
|
1079
|
+
|
|
1080
|
+
interface SIG_BUS_CELL_DRS_FN {
|
|
1081
|
+
(...args: [...QD_INI, type?: CELL_TYPE, chain?: CHAIN_TYPE]): any
|
|
1082
|
+
crdt<T = any>(...args: [...INI_QD<T>]): any
|
|
1083
|
+
cell(...args: [...QD_INI, type?: CELL_TYPE, chain?: CHAIN_TYPE]): any
|
|
1084
|
+
rifts: {
|
|
1085
|
+
<T = any>(module?: any, named_?: any, store?: STORE_TYPE, wait?: number, chain?: CHAIN_TYPE): any
|
|
1086
|
+
mailbox<T = any>(...args: [...INI_QD<T>, STORE_TYPE]): any
|
|
1087
|
+
}
|
|
1088
|
+
crdtb<T = any>(...args: [...INI_QD<T>, nodeId?: string]): any
|
|
1089
|
+
topology(k: string, sl?: string, ms?: string, rt?: string, chain?: 'chain' | 'rechain', selfId?: string, opts?: { probeTimeoutMs?: number }): any
|
|
1090
|
+
map<K, V>(k: string, v: Map<K, V>, sl?: string, ms?: string, rt?: string, type?: CELL_TYPE, chain?: CHAIN_TYPE): any
|
|
1091
|
+
set<T = any>(k: string, v: Iterable<T>, sl?: string, ms?: string, rt?: string, type?: CELL_TYPE, chain?: CHAIN_TYPE): any
|
|
1092
|
+
array<T = any>(k: string, v: T[], sl?: string, ms?: string, rt?: string, type?: CELL_TYPE, chain?: CHAIN_TYPE): any
|
|
1093
|
+
obj<T extends Record<PropertyKey, any>>(k: string, v?: T, sl?: string, ms?: string, rt?: string, type?: CELL_TYPE, chain?: CHAIN_TYPE): any
|
|
1094
|
+
string(k: string, v: string, sl?: string, ms?: string, rt?: string, type?: CELL_TYPE, chain?: CHAIN_TYPE): any
|
|
1095
|
+
num(k: string, v: number, sl?: string, ms?: string, rt?: string, type?: CELL_TYPE, chain?: CHAIN_TYPE): any
|
|
1096
|
+
boolean(k: string, v: boolean, sl?: string, ms?: string, rt?: string, type?: CELL_TYPE, chain?: CHAIN_TYPE): any
|
|
1097
|
+
stream(...args: [...INI_QD, opts?: any]): any
|
|
1098
|
+
duplex(...args: [...INI_QD, chain?: CHAIN_TYPE, opts?: any,]): any
|
|
1099
|
+
time_travel(...args: [...INI_QD,]): any
|
|
1100
|
+
gated(predicate: (topo: any, ...ctx: any[]) => boolean, value: any, deps: any[], k: any, sl?: string, ms?: string, rt?: string): any
|
|
1101
|
+
transaction(...args: [...QD_INI,]): any
|
|
1102
|
+
signal<T = any>(v?: T | (() => T), k?: string, sl?: string, ms?: string, rt?: string, chain?: CHAIN_TYPE): any
|
|
1103
|
+
graph(...args: [...QD_INI,]): any
|
|
1104
|
+
distributed(...args: [...QD_INI,]): any
|
|
1105
|
+
synchronization(...args: [...QD_INI,]): any
|
|
1106
|
+
replication(...args: [...QD_INI,]): any
|
|
1107
|
+
resilience(...args: [...QD_INI,]): any
|
|
1108
|
+
temporal(...args: [...QD_INI,]): any
|
|
1109
|
+
mesh<T = any>(v?: T, reactor?: StateMeshReactor<T>, k?: string, sl?: string, ms?: string, rt?: string,): StateMesh<T>
|
|
1110
|
+
store(...args: [...INI_QD,]): any
|
|
1111
|
+
mailbox(...args: [...INI_QD,]): any
|
|
1112
|
+
mailbox2(...args: [...INI_QD,]): any
|
|
1113
|
+
stateStore(...args: [...INI_QD,]): any
|
|
1114
|
+
liveStore(...args: [...INI_QD, nodeId?: string]): any
|
|
1115
|
+
live(...args: [...INI_QD,]): any
|
|
1116
|
+
observable(...args: [...INI_QD,]): any
|
|
1117
|
+
ref(...args: [...INI_QD,]): any
|
|
1118
|
+
umbrella(v?: Record<string, any>, k?: string, sl?: string, ms?: string, rt?: string): any
|
|
1119
|
+
context(v?: Record<string, any>, k?: string, sl?: string, ms?: string, rt?: string): any
|
|
1120
|
+
}
|
|
1121
|
+
type SIG_BUS_SS_FN = {
|
|
1122
|
+
// ── callable: creates a signal handle ────────────────────────────────────────────────────
|
|
1123
|
+
<T = any>(v?: any, key?: string, sl?: string, ms?: string, rt?: string, chain?: 'chain' | 'rechain', options?: SignalOptions<T>): any;
|
|
1124
|
+
update(node: SignalNode | ComputedNode | EffectScopeNode): boolean
|
|
1125
|
+
notify(effect: EffectNode): any
|
|
1126
|
+
|
|
1127
|
+
|
|
1128
|
+
|
|
1129
|
+
|
|
1130
|
+
|
|
1131
|
+
|
|
1132
|
+
|
|
1133
|
+
|
|
1134
|
+
_bindComponentToSignal(rk: string, sl?: string, ms?: string, rt?: string): void;
|
|
1135
|
+
_hashTuple(tuple: unknown[]): string
|
|
1136
|
+
_serializeTuple(tuple: any[]): string
|
|
1137
|
+
create<T = any>(key: string, v?: any, sl?: string, ms?: string, rt?: string, options?: SignalOptions<T>): string;
|
|
1138
|
+
read<T>(key: string, sl?: string, ms?: string, rt?: string,): any
|
|
1139
|
+
write<T>(key: string, sl?: string, ms?: string, rt?: string,): any
|
|
1140
|
+
normalizeKey(rawKey: string): any
|
|
1141
|
+
runTeardown(t: Teardown): void
|
|
1142
|
+
reportError(e: unknown): void
|
|
1143
|
+
untrackFn<T>(fn: () => T): T
|
|
1144
|
+
untrack<T>(fn: () => T): T
|
|
1145
|
+
|
|
1146
|
+
setEffectErrorHandler(fn: EffectErrorHandler | null): void
|
|
1147
|
+
getActiveSub(): ReactiveNode | undefined
|
|
1148
|
+
setActiveSub(sub?: ReactiveNode): any
|
|
1149
|
+
getBatchDepth(): number
|
|
1150
|
+
startBatch(): any
|
|
1151
|
+
endBatch(): any
|
|
1152
|
+
isSignal(fn: () => void): boolean
|
|
1153
|
+
isComputed(fn: () => void): boolean
|
|
1154
|
+
isEffect(fn: () => void): boolean
|
|
1155
|
+
isEffectScope(fn: () => void): boolean
|
|
1156
|
+
signal<T>(v?: T): { (): T | undefined; (value: T | undefined): void; }
|
|
1157
|
+
computed<T>(getter: (previousValue?: T) => T): () => T
|
|
1158
|
+
effect(fn: () => void | (() => void), onError?: EffectErrorHandler): (that: EffectNode) => void
|
|
1159
|
+
effectScope(fn: () => void, onError?: EffectErrorHandler): (that: EffectScopeNode) => void
|
|
1160
|
+
trigger(fn: () => void): any
|
|
1161
|
+
updateComputed(c: ComputedNode): boolean
|
|
1162
|
+
updateSignal(s: SignalNode): boolean
|
|
1163
|
+
run(e: EffectNode): void
|
|
1164
|
+
flushSS(): void
|
|
1165
|
+
runCleanup(e: EffectNode): void
|
|
1166
|
+
disposeAllDepsInReverse(sub: ReactiveNode): void
|
|
1167
|
+
purgeDeps(sub: ReactiveNode): any
|
|
1168
|
+
|
|
1169
|
+
// ── ergonomic helpers ────────────────────────────────────────────────────────────────────
|
|
1170
|
+
sysEffect(fn: () => void | (() => void)): () => void;
|
|
1171
|
+
|
|
1172
|
+
// ── internals exposed on the namespace ───────────────────────────────────────────────────
|
|
1173
|
+
_validateSchema(rk: string, value: any, sl?: string, ms?: string, rt?: string): any;
|
|
1174
|
+
_hashTuple(tuple: unknown[]): string;
|
|
1175
|
+
_recordCausal(rk: string, value: any, source: string, sl?: string, ms?: string, rt?: string, cause?: string): void;
|
|
1176
|
+
_resolveConflict(rk: string, prev: any, next: any, sl?: string, ms?: string, rt?: string): any;
|
|
1177
|
+
_writeResolved(rk: string, value: any, source: string, sl?: string, ms?: string, rt?: string, cause?: string): void;
|
|
1178
|
+
|
|
1179
|
+
// ── key + schema ─────────────────────────────────────────────────────────────────────────
|
|
1180
|
+
resolveKey(key: any, sl?: string, ms?: string, rt?: string): string;
|
|
1181
|
+
registerSchema<T = any>(key: any, schema: SignalSchema<T>, sl?: string, ms?: string, rt?: string): void;
|
|
1182
|
+
|
|
1183
|
+
// ── signal CRUD ──────────────────────────────────────────────────────────────────────────
|
|
1184
|
+
write<T = any>(key: any, value: T | ((prev: T | undefined) => T), sl?: string, ms?: string, rt?: string, source?: string): void;
|
|
1185
|
+
read<T = any>(key: any, sl?: string, ms?: string, rt?: string): T | undefined;
|
|
1186
|
+
peek<T = any>(key: any, sl?: string, ms?: string, rt?: string): T | undefined;
|
|
1187
|
+
subscribe<T>(key: string, listener: (value: T, previous: T) => void, sl?: string, ms?: string, rt?: string,): Unsubscribe
|
|
1188
|
+
has(key: any, sl?: string, ms?: string, rt?: string): boolean;
|
|
1189
|
+
delete(key: any, sl?: string, ms?: string, rt?: string): void;
|
|
1190
|
+
|
|
1191
|
+
// ── signal state modifiers ───────────────────────────────────────────────────────────────
|
|
1192
|
+
freeze(key: any, sl?: string, ms?: string, rt?: string): void;
|
|
1193
|
+
seal(key: any, sl?: string, ms?: string, rt?: string): void;
|
|
1194
|
+
reset(key: any, sl?: string, ms?: string, rt?: string): void;
|
|
1195
|
+
hydrate<T = any>(key: any, value: T, sl?: string, ms?: string, rt?: string): void;
|
|
1196
|
+
|
|
1197
|
+
clone(srcKey: any, destKey: any, src: rts, dest: rts,): void;
|
|
1198
|
+
|
|
1199
|
+
// ── persistence ──────────────────────────────────────────────────────────────────────────
|
|
1200
|
+
persist<T = any>(key: any, value: T, sl?: string, ms?: string, rt?: string, options?: { serialize?: (v: T) => string }): Promise<void>;
|
|
1201
|
+
unpersist(key: any, sl?: string, ms?: string, rt?: string): Promise<void>;
|
|
1202
|
+
|
|
1203
|
+
// ── messaging ────────────────────────────────────────────────────────────────────────────
|
|
1204
|
+
sub<T = any>(k: string, handler: any, sl?: string, ms?: string, rt?: string): () => void;
|
|
1205
|
+
send(p: any, fromKey: any, toKey: any, ms?: string, rt?: string): void;
|
|
1206
|
+
|
|
1207
|
+
// ── derived ──────────────────────────────────────────────────────────────────────────────
|
|
1208
|
+
derive<T = any>(
|
|
1209
|
+
key: any,
|
|
1210
|
+
deps: any[],
|
|
1211
|
+
compute: (...values: any[]) => T, sl?: string, ms?: string, rt?: string,
|
|
1212
|
+
options?: { eager?: boolean; onError?: (err: Error) => void }
|
|
1213
|
+
): string;
|
|
1214
|
+
invalidateDerived(key: any): void;
|
|
1215
|
+
|
|
1216
|
+
// ── async ────────────────────────────────────────────────────────────────────────────────
|
|
1217
|
+
createAsync<T = any>(
|
|
1218
|
+
key: any,
|
|
1219
|
+
fetcher: (signal: AbortSignal) => Promise<T>, sl?: string, ms?: string, rt?: string,
|
|
1220
|
+
options?: { fallback?: T }
|
|
1221
|
+
): AsyncSignalHandles;
|
|
1222
|
+
invalidateAsync(key: any, sl?: string, ms?: string, rt?: string): void;
|
|
1223
|
+
mutateAsync<T = any>(key: any, optimistic: T, sl?: string, ms?: string, rt?: string): void;
|
|
1224
|
+
abortAsync(key: any, sl?: string, ms?: string, rt?: string): void;
|
|
1225
|
+
prefetchAsync<T = any>(key: any, fetcher: () => Promise<T>, sl?: string, ms?: string, rt?: string): void;
|
|
1226
|
+
readAsync<T = any>(key: any, sl?: string, ms?: string, rt?: string): T;
|
|
1227
|
+
|
|
1228
|
+
// ── batch / tx ───────────────────────────────────────────────────────────────────────────
|
|
1229
|
+
batch(fn: () => void): void;
|
|
1230
|
+
tx(fn: () => void): void;
|
|
1231
|
+
transaction(block: () => void): void;
|
|
1232
|
+
|
|
1233
|
+
// ── history / time travel ────────────────────────────────────────────────────────────────
|
|
1234
|
+
enableHistory(key: any, sl?: string, ms?: string, rt?: string, options?: { max: number }): void;
|
|
1235
|
+
undo(key: any, sl?: string, ms?: string, rt?: string): void;
|
|
1236
|
+
redo(key: any, sl?: string, ms?: string, rt?: string): void;
|
|
1237
|
+
signalTimeline(key: any, sl?: string, ms?: string, rt?: string): SignalTimelineEntry[];
|
|
1238
|
+
snapshot(): Record<string, any>;
|
|
1239
|
+
restore(snapshot: Record<string, any>): void;
|
|
1240
|
+
diffSnapshots(a: Record<string, any>, b: Record<string, any>): Record<string, { from: any; to: any }>;
|
|
1241
|
+
applyPatch(patch: Record<string, { from: any; to: any }>): void;
|
|
1242
|
+
replay(key: any, sl?: string, ms?: string, rt?: string, options?: { speed?: number }): Promise<void>;
|
|
1243
|
+
|
|
1244
|
+
// ── causal / conflict / contracts ────────────────────────────────────────────────────────
|
|
1245
|
+
getCausalChain(key: any, sl?: string, ms?: string, rt?: string): CausalEntry[];
|
|
1246
|
+
conflictPolicy<T = any>(key: any, policy: ConflictPolicy<T>): void;
|
|
1247
|
+
declareContract(
|
|
1248
|
+
name: string,
|
|
1249
|
+
key: any,
|
|
1250
|
+
postcondition: (next: any, prev: any) => boolean, sl?: string, ms?: string, rt?: string,
|
|
1251
|
+
options?: { block?: boolean }
|
|
1252
|
+
): void;
|
|
1253
|
+
removeContract(name: string): void;
|
|
1254
|
+
|
|
1255
|
+
// ── scopes ───────────────────────────────────────────────────────────────────────────────
|
|
1256
|
+
createScope(id: string): SignalScopeHandle;
|
|
1257
|
+
|
|
1258
|
+
// ── effects ──────────────────────────────────────────────────────────────────────────────
|
|
1259
|
+
|
|
1260
|
+
effectOnce(
|
|
1261
|
+
keys: any[],
|
|
1262
|
+
predicate: (...v: any[]) => boolean,
|
|
1263
|
+
fn: (...v: any[]) => void
|
|
1264
|
+
): () => void;
|
|
1265
|
+
|
|
1266
|
+
// ── operators ────────────────────────────────────────────────────────────────────────────
|
|
1267
|
+
map<A = any, B = any>(srcKey: any, destKey: any, fn: (v: A) => B, src: rts, dest: rts): () => void;
|
|
1268
|
+
filter<T = any>(srcKey: any, destKey: any, pred: (v: T) => boolean, src: rts, dest: rts): () => void;
|
|
1269
|
+
debounce(sourceKey: any, delay: number, src: rts, dest: rts): [string, () => void];
|
|
1270
|
+
throttle(srcKey: any, destKey: any, ms: number, src: rts, dest: rts): () => void;
|
|
1271
|
+
merge(srcKeys: any[], destKey: any, src: rts, dest: rts): () => void;
|
|
1272
|
+
zip(srcKeys: any[], destKey: any, src: rts, dest: rts): () => void;
|
|
1273
|
+
combine(srcKeys: any[], destKey: any, src: rts, dest: rts): () => void;
|
|
1274
|
+
scan<T = any, A = any>(srcKey: any, destKey: any, reducer: (a: A, v: T) => A, seed: A, src: rts, dest: rts): () => void;
|
|
1275
|
+
switch(srcKey: any, destKey: any, src: rts, dest: rts): () => void;
|
|
1276
|
+
buffer(srcKey: any, destKey: any, count: number, src: rts, dest: rts): () => void;
|
|
1277
|
+
window(srcKey: any, destKey: any, ms: number, src: rts, dest: rts): () => void;
|
|
1278
|
+
distinct<T = any>(srcKey: any, destKey: any, equals?: (a: T, b: T) => boolean, src?: rts, dest?: rts,): any;
|
|
1279
|
+
audit(srcKey: any, destKey: any, ms: number, src: rts, dest: rts): () => void;
|
|
1280
|
+
sample(srcKey: any, triggerKey: any, destKey: any, src: rts, dest: rts): () => void;
|
|
1281
|
+
gate(srcKey: any, gateKey: any, destKey: any, src: rts, dest: rts): () => void;
|
|
1282
|
+
};
|
|
1283
|
+
interface AsyncSignalHandles {
|
|
1284
|
+
dataKey: string;
|
|
1285
|
+
loadingKey: string;
|
|
1286
|
+
errorKey: string;
|
|
1287
|
+
}
|
|
1288
|
+
interface SignalScopeHandle {
|
|
1289
|
+
add(key: any): void;
|
|
1290
|
+
suspend(): void;
|
|
1291
|
+
resume(): void;
|
|
1292
|
+
dispose(): void;
|
|
1293
|
+
snapshot(): Record<string, any>;
|
|
1294
|
+
restore(snapshot: Record<string, any>): void;
|
|
1295
|
+
fork(): SignalScopeHandle;
|
|
1296
|
+
merge(forked: SignalScopeHandle): void;
|
|
1297
|
+
}
|
|
1298
|
+
type Teardown =
|
|
1299
|
+
| void
|
|
1300
|
+
| null
|
|
1301
|
+
| (() => void)
|
|
1302
|
+
| { unsubscribe(): void }
|
|
1303
|
+
| { [Symbol.dispose](): void }
|
|
1304
|
+
| Teardown[];
|
|
1305
|
+
interface Link {
|
|
1306
|
+
version: number;
|
|
1307
|
+
dep: ReactiveNode;
|
|
1308
|
+
sub: ReactiveNode;
|
|
1309
|
+
prevSub: Link | undefined;
|
|
1310
|
+
nextSub: Link | undefined;
|
|
1311
|
+
prevDep: Link | undefined;
|
|
1312
|
+
nextDep: Link | undefined;
|
|
1313
|
+
bus?: any
|
|
1314
|
+
value?: any
|
|
1315
|
+
label?: string
|
|
1316
|
+
}
|
|
1317
|
+
interface Stack<T> {
|
|
1318
|
+
value: T;
|
|
1319
|
+
prev: Stack<T> | undefined;
|
|
1320
|
+
}
|
|
1321
|
+
const enum ReactiveFlags {
|
|
1322
|
+
None = 0,
|
|
1323
|
+
Mutable = 1,
|
|
1324
|
+
Watching = 2,
|
|
1325
|
+
RecursedCheck = 4,
|
|
1326
|
+
Recursed = 8,
|
|
1327
|
+
Dirty = 16,
|
|
1328
|
+
Pending = 32,
|
|
1329
|
+
}
|
|
1330
|
+
interface EffectScopeNode extends ReactiveNode {
|
|
1331
|
+
onError?: EffectErrorHandler;
|
|
1332
|
+
children?: Set<ReactiveNode>;
|
|
1333
|
+
}
|
|
1334
|
+
type EffectErrorHandler = (err: unknown, node: ReactiveNode) => void;
|
|
1335
|
+
interface ReactiveNode {
|
|
1336
|
+
deps?: Link;
|
|
1337
|
+
depsTail?: Link;
|
|
1338
|
+
subs?: Link;
|
|
1339
|
+
subsTail?: Link;
|
|
1340
|
+
flags: ReactiveFlags;
|
|
1341
|
+
}
|
|
1342
|
+
interface AsyncNode<T = any> extends ReactiveNode {
|
|
1343
|
+
fetcher: (signal: AbortSignal) => Promise<T>;
|
|
1344
|
+
value: T | undefined;
|
|
1345
|
+
error: unknown;
|
|
1346
|
+
pending: boolean;
|
|
1347
|
+
controller: AbortController | null;
|
|
1348
|
+
version: number;
|
|
1349
|
+
onError?: EffectErrorHandler;
|
|
1350
|
+
}
|
|
1351
|
+
interface EffectNode extends ReactiveNode {
|
|
1352
|
+
fn(): (() => void) | void;
|
|
1353
|
+
cleanup: (() => void) | void;
|
|
1354
|
+
onError?: EffectErrorHandler;
|
|
1355
|
+
}
|
|
1356
|
+
interface ComputedNode<T = any> extends ReactiveNode {
|
|
1357
|
+
value: T | undefined;
|
|
1358
|
+
getter: (previousValue?: T) => T;
|
|
1359
|
+
}
|
|
1360
|
+
interface SignalNode<T = any> extends ReactiveNode {
|
|
1361
|
+
currentValue: T;
|
|
1362
|
+
pendingValue: T;
|
|
1363
|
+
}
|
|
1364
|
+
interface SignalScope {
|
|
1365
|
+
id: string
|
|
1366
|
+
keys: Set<string>
|
|
1367
|
+
effects: Set<any>
|
|
1368
|
+
suspended: boolean
|
|
1369
|
+
pendingFlush: Map<string, any>
|
|
1370
|
+
}
|
|
1371
|
+
type SignalListener = { (value: any, source?: string): void }
|
|
1372
|
+
interface SignalLifecycle<T = any> {
|
|
1373
|
+
onCreate?: () => void;
|
|
1374
|
+
onWrite?: (value: T, prev: T | undefined) => void;
|
|
1375
|
+
onRead?: (value: T) => void;
|
|
1376
|
+
onDelete?: () => void;
|
|
1377
|
+
onFreeze?: () => void;
|
|
1378
|
+
onExpire?: () => void;
|
|
1379
|
+
onError?: (err: Error) => void;
|
|
1380
|
+
}
|
|
1381
|
+
interface SignalEffect {
|
|
1382
|
+
keys: string[];
|
|
1383
|
+
fn: (...values: any[]) => (() => void) | void | Promise<(() => void) | void>;
|
|
1384
|
+
cleanup: (() => void) | null;
|
|
1385
|
+
controller: AbortController | null;
|
|
1386
|
+
}
|
|
1387
|
+
interface AsyncSignalState<T> {
|
|
1388
|
+
fetcher: () => Promise<T> | void;
|
|
1389
|
+
controller: AbortController | null;
|
|
1390
|
+
retryCount: number;
|
|
1391
|
+
staleValue?: T;
|
|
1392
|
+
}
|
|
1393
|
+
type ConflictPolicy2<T = any> = | ConflictPolicyName | ((current: T, incoming: T, meta: { key: string; timestamp: number }) => T)
|
|
1394
|
+
// interface ConflictPolicy<T = any> { resolve?: (prev: T | undefined, next: T) => T | undefined; }
|
|
1395
|
+
interface ConflictPolicy<T = any> { resolve?: (prev: T | undefined, next: T) => T | undefined; }
|
|
1396
|
+
interface SignalOptions<T = any> {
|
|
1397
|
+
schema?: SignalSchema<T>;
|
|
1398
|
+
conflict?: ConflictPolicy<T>;
|
|
1399
|
+
history?: { max: N };
|
|
1400
|
+
lifecycle?: SignalLifecycle<T>;
|
|
1401
|
+
persist?: B;
|
|
1402
|
+
ttl?: N;
|
|
1403
|
+
broadcast?: B;
|
|
1404
|
+
trigger_render?: B;
|
|
1405
|
+
conflictStrategy?: ConflictStrategy
|
|
1406
|
+
source?: A
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
type ConflictStrategy = "latest" | "fail" | "accumulate";
|
|
1410
|
+
|
|
1411
|
+
type Boundary = "same-app" | "cross-app" | "isolated" | string;
|
|
1412
|
+
|
|
1413
|
+
interface SysEntry {
|
|
1414
|
+
read: () => any;
|
|
1415
|
+
write: (v: any) => void;
|
|
1416
|
+
node: any;
|
|
1417
|
+
isComputed: boolean;
|
|
1418
|
+
}
|
|
1419
|
+
interface Metrics {
|
|
1420
|
+
readCount: number;
|
|
1421
|
+
writeCount: number;
|
|
1422
|
+
subscriberCount: number;
|
|
1423
|
+
lastWrite: number | null;
|
|
1424
|
+
flushDuration: number;
|
|
1425
|
+
}
|
|
1426
|
+
interface SignalHandle<T = any> {
|
|
1427
|
+
value: T;
|
|
1428
|
+
peek(): T;
|
|
1429
|
+
}
|
|
1430
|
+
interface ComputedHandle<T = any> {
|
|
1431
|
+
value: T;
|
|
1432
|
+
peek(): T;
|
|
1433
|
+
}
|
|
1434
|
+
interface SignalSchema<T = any> {
|
|
1435
|
+
validate: (v: any) => boolean;
|
|
1436
|
+
coerce?: (v: any) => T;
|
|
1437
|
+
}
|
|
1438
|
+
interface SignalLifecycle<T = any> {
|
|
1439
|
+
onCreate?: () => void;
|
|
1440
|
+
onWrite?: (value: T, prev: T | undefined) => void;
|
|
1441
|
+
onRead?: (value: T) => void;
|
|
1442
|
+
onDelete?: () => void;
|
|
1443
|
+
onFreeze?: () => void;
|
|
1444
|
+
onExpire?: () => void;
|
|
1445
|
+
onError?: (err: Error) => void;
|
|
1446
|
+
}
|
|
1447
|
+
interface SignalEffect {
|
|
1448
|
+
keys: string[];
|
|
1449
|
+
fn: (...values: any[]) => (() => void) | void | Promise<(() => void) | void>;
|
|
1450
|
+
cleanup: (() => void) | null;
|
|
1451
|
+
controller: AbortController | null;
|
|
1452
|
+
}
|
|
1453
|
+
interface AsyncSignalState<T = any> {
|
|
1454
|
+
fetcher: () => Promise<T> | void;
|
|
1455
|
+
controller: AbortController | null;
|
|
1456
|
+
retryCount: number;
|
|
1457
|
+
staleValue?: T;
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
interface SignalTimelineEntry {
|
|
1461
|
+
value: any;
|
|
1462
|
+
timestamp: number;
|
|
1463
|
+
source?: string;
|
|
1464
|
+
}
|
|
1465
|
+
type ConflictPolicyName = 'last-write-wins' | 'first-write-wins' | 'merge' | 'reject-on-conflict' | 'queue'
|
|
1466
|
+
interface CausalEntry {
|
|
1467
|
+
key: string
|
|
1468
|
+
value: any
|
|
1469
|
+
timestamp: number
|
|
1470
|
+
source?: 'write' | 'effect' | 'derived' | 'staff' | 'ngin' | string
|
|
1471
|
+
cause?: string
|
|
1472
|
+
}
|
|
1473
|
+
interface DOMBinding {
|
|
1474
|
+
node: Node
|
|
1475
|
+
update: (node: Node, value: any) => void
|
|
1476
|
+
active?: boolean
|
|
1477
|
+
}
|
|
1478
|
+
interface CallbackHookState extends HookState {
|
|
1479
|
+
callback: (...args: any[]) => any
|
|
1480
|
+
deps: any[]
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
|
|
1484
|
+
// #endregion
|
|
1485
|
+
// #region MATBE GENERIC
|
|
1486
|
+
|
|
1487
|
+
// #region MaybeScope
|
|
1488
|
+
interface ScopeOptions {
|
|
1489
|
+
sl?: any
|
|
1490
|
+
ms?: any
|
|
1491
|
+
rt?: any
|
|
1492
|
+
k?: any
|
|
1493
|
+
}
|
|
1494
|
+
type MS1 = symbol;
|
|
1495
|
+
|
|
1496
|
+
|
|
1497
|
+
interface maybe_ch_payload {
|
|
1498
|
+
|
|
1499
|
+
v?: any
|
|
1500
|
+
rt?: SU
|
|
1501
|
+
ms?: SU
|
|
1502
|
+
sl?: SU
|
|
1503
|
+
k?: SU
|
|
1504
|
+
}
|
|
1505
|
+
interface maybe_rt {
|
|
1506
|
+
sl?: SU
|
|
1507
|
+
ms?: SU
|
|
1508
|
+
rt?: SU
|
|
1509
|
+
}
|
|
1510
|
+
interface SauronRegistry extends SauronState {
|
|
1511
|
+
name: string
|
|
1512
|
+
destroy(): void
|
|
1513
|
+
}
|
|
1514
|
+
interface SAURON_REGISTRY_STORAGE {
|
|
1515
|
+
get<T>(key: string, opts?: ScopeOptions): T | undefined
|
|
1516
|
+
set<T>(key: string, value: T | ((prev: T | undefined) => T), opts?: { triggerRender?: boolean } & ScopeOptions): void
|
|
1517
|
+
delete(key: string, opts?: ScopeOptions): boolean
|
|
1518
|
+
getByPrefix<T>(prefix: string, opts?: ScopeOptions): { key: string; value: T }[]
|
|
1519
|
+
getAll<T = any>(opts?: ScopeOptions): Record<string, T>
|
|
1520
|
+
subscribe<T>(key: string, listener: (value: T) => void, opts?: ScopeOptions): () => void
|
|
1521
|
+
subscribeAll(listener: (key: string, value: any) => void, opts?: ScopeOptions): () => void
|
|
1522
|
+
batch(key: string, fn: () => void, opts?: ScopeOptions): void
|
|
1523
|
+
clear(opts?: ScopeOptions): void
|
|
1524
|
+
|
|
1525
|
+
name: string
|
|
1526
|
+
destroy(): void
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
// #endregion
|
|
1530
|
+
// #endregion
|
|
1531
|
+
|
|
1532
|
+
|
|
1533
|
+
type GateContext<TPayload = unknown> = {
|
|
1534
|
+
p: TPayload;
|
|
1535
|
+
store: Map<string, unknown>;
|
|
1536
|
+
reply: (data: unknown, targetrt?: string) => Promise<unknown>;
|
|
1537
|
+
};
|
|
1538
|
+
type GateMatcher<TPayload = unknown> = (p: TPayload, ctx: GateContext<TPayload>) => MaybePromise<boolean>;
|
|
1539
|
+
type GateHandler<TPayload = unknown, TResult = unknown> = (p: TPayload, ctx: GateContext<TPayload>) => MaybePromise<TResult>;
|
|
1540
|
+
type GateDefinition<TPayload = unknown, TResult = unknown> = {
|
|
1541
|
+
/**
|
|
1542
|
+
* Higher values are checked first in sequential mode.
|
|
1543
|
+
* In concurrent mode priority only provides deterministic ordering metadata.
|
|
1544
|
+
*/
|
|
1545
|
+
priority?: number;
|
|
1546
|
+
|
|
1547
|
+
matcher: GateMatcher<TPayload>;
|
|
1548
|
+
handler?: GateHandler<TPayload, TResult>;
|
|
1549
|
+
};
|
|
1550
|
+
type GateMap<TPayload = unknown> = Record<string, GateMatcher<TPayload> | GateDefinition<TPayload>>;
|
|
1551
|
+
type GateRunResult<TResult = unknown> = {
|
|
1552
|
+
name: string;
|
|
1553
|
+
matched: boolean;
|
|
1554
|
+
success: boolean;
|
|
1555
|
+
result?: TResult;
|
|
1556
|
+
error?: unknown;
|
|
1557
|
+
};
|
|
1558
|
+
type GateMasterOptions = {
|
|
1559
|
+
/**
|
|
1560
|
+
* true: match all gates and run all matches in parallel
|
|
1561
|
+
* false: match and run one gate at a time, in priority order
|
|
1562
|
+
*/
|
|
1563
|
+
concurrency?: boolean;
|
|
1564
|
+
|
|
1565
|
+
/**
|
|
1566
|
+
* In sequential mode, stop after the first successful matching handler.
|
|
1567
|
+
* Defaults to false because Gate Master is intended to fan out to all matches.
|
|
1568
|
+
*/
|
|
1569
|
+
stopAfterFirstMatch?: boolean;
|
|
1570
|
+
|
|
1571
|
+
/**
|
|
1572
|
+
* If true, a failed matcher/handler stops sequential processing.
|
|
1573
|
+
* Defaults to false, so other independent gates keep running.
|
|
1574
|
+
*/
|
|
1575
|
+
failFast?: boolean;
|
|
1576
|
+
|
|
1577
|
+
onError?: (
|
|
1578
|
+
error: unknown,
|
|
1579
|
+
gateName: string,
|
|
1580
|
+
phase: "match" | "execute",
|
|
1581
|
+
p: unknown
|
|
1582
|
+
) => void;
|
|
1583
|
+
};
|
|
1584
|
+
type Awaitable<T> = T | Promise<T>;
|
|
1585
|
+
type NodeId = string;
|
|
1586
|
+
type RunId = string;
|
|
1587
|
+
type PlinkoOutcome = | "success" | "failure" | "skipped" | "cancelled";
|
|
1588
|
+
type PlinkoRunStatus = | "idle" | "running" | "succeeded" | "failed" | "cancelled";
|
|
1589
|
+
type SerializedError = {
|
|
1590
|
+
name: string;
|
|
1591
|
+
message: string;
|
|
1592
|
+
stack?: string;
|
|
1593
|
+
cause?: SerializedError;
|
|
1594
|
+
};
|
|
1595
|
+
type PlinkoRetryPolicy = {
|
|
1596
|
+
maxAttempts?: number;
|
|
1597
|
+
delayMs?: number;
|
|
1598
|
+
maxDelayMs?: number;
|
|
1599
|
+
backoff?: "fixed" | "linear" | "exponential";
|
|
1600
|
+
jitter?: "none" | "full";
|
|
1601
|
+
retryIf?: (error: unknown, attempt: number) => boolean;
|
|
1602
|
+
};
|
|
1603
|
+
type PlinkoNodeContext<TInput, TResults extends Record<string, unknown> = Record<string, unknown>,> = {
|
|
1604
|
+
readonly runId: RunId;
|
|
1605
|
+
readonly nodeId: NodeId;
|
|
1606
|
+
readonly attempt: number;
|
|
1607
|
+
readonly input: TInput;
|
|
1608
|
+
readonly results: Readonly<TResults>;
|
|
1609
|
+
readonly variables: ReadonlyMap<string, unknown>;
|
|
1610
|
+
readonly signal: AbortSignal;
|
|
1611
|
+
|
|
1612
|
+
emit(name: string, p?: unknown): void;
|
|
1613
|
+
};
|
|
1614
|
+
type ActionNode<TInput, TResults extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown,> = {
|
|
1615
|
+
kind?: "action";
|
|
1616
|
+
label?: string;
|
|
1617
|
+
|
|
1618
|
+
when?: (
|
|
1619
|
+
ctx: PlinkoNodeContext<TInput, TResults>,
|
|
1620
|
+
) => Awaitable<boolean>;
|
|
1621
|
+
|
|
1622
|
+
run: (
|
|
1623
|
+
ctx: PlinkoNodeContext<TInput, TResults>,
|
|
1624
|
+
) => Awaitable<TOutput>;
|
|
1625
|
+
|
|
1626
|
+
timeoutMs?: number;
|
|
1627
|
+
retry?: PlinkoRetryPolicy;
|
|
1628
|
+
on?: Partial<Record<PlinkoOutcome, NodeId>>;
|
|
1629
|
+
};
|
|
1630
|
+
type PlinkoDefinition<TInput> = {
|
|
1631
|
+
id: string;
|
|
1632
|
+
version?: string;
|
|
1633
|
+
start: NodeId;
|
|
1634
|
+
nodes: Record<NodeId, ActionNode<TInput>>;
|
|
1635
|
+
};
|
|
1636
|
+
type CompiledGraph<TInput> = Readonly<{
|
|
1637
|
+
id: string;
|
|
1638
|
+
version?: string;
|
|
1639
|
+
start: NodeId;
|
|
1640
|
+
nodes: Readonly<Record<NodeId, ActionNode<TInput>>>;
|
|
1641
|
+
}>;
|
|
1642
|
+
type PlinkoEvent =
|
|
1643
|
+
| {
|
|
1644
|
+
type: "run.started";
|
|
1645
|
+
runId: RunId;
|
|
1646
|
+
graphId: string;
|
|
1647
|
+
graphVersion?: string;
|
|
1648
|
+
input: unknown;
|
|
1649
|
+
at: number;
|
|
1650
|
+
}
|
|
1651
|
+
| {
|
|
1652
|
+
type: "node.selected";
|
|
1653
|
+
runId: RunId;
|
|
1654
|
+
nodeId: NodeId;
|
|
1655
|
+
at: number;
|
|
1656
|
+
}
|
|
1657
|
+
| {
|
|
1658
|
+
type: "node.started";
|
|
1659
|
+
runId: RunId;
|
|
1660
|
+
nodeId: NodeId;
|
|
1661
|
+
attempt: number;
|
|
1662
|
+
at: number;
|
|
1663
|
+
}
|
|
1664
|
+
| {
|
|
1665
|
+
type: "node.skipped";
|
|
1666
|
+
runId: RunId;
|
|
1667
|
+
nodeId: NodeId;
|
|
1668
|
+
reason: string;
|
|
1669
|
+
at: number;
|
|
1670
|
+
}
|
|
1671
|
+
| {
|
|
1672
|
+
type: "node.succeeded";
|
|
1673
|
+
runId: RunId;
|
|
1674
|
+
nodeId: NodeId;
|
|
1675
|
+
attempt: number;
|
|
1676
|
+
result: unknown;
|
|
1677
|
+
durationMs: number;
|
|
1678
|
+
at: number;
|
|
1679
|
+
}
|
|
1680
|
+
| {
|
|
1681
|
+
type: "node.failed";
|
|
1682
|
+
runId: RunId;
|
|
1683
|
+
nodeId: NodeId;
|
|
1684
|
+
attempt: number;
|
|
1685
|
+
error: SerializedError;
|
|
1686
|
+
durationMs: number;
|
|
1687
|
+
willRetry: boolean;
|
|
1688
|
+
at: number;
|
|
1689
|
+
}
|
|
1690
|
+
| {
|
|
1691
|
+
type: "node.retrying";
|
|
1692
|
+
runId: RunId;
|
|
1693
|
+
nodeId: NodeId;
|
|
1694
|
+
attempt: number;
|
|
1695
|
+
delayMs: number;
|
|
1696
|
+
at: number;
|
|
1697
|
+
}
|
|
1698
|
+
| {
|
|
1699
|
+
type: "node.cancelled";
|
|
1700
|
+
runId: RunId;
|
|
1701
|
+
nodeId: NodeId;
|
|
1702
|
+
attempt: number;
|
|
1703
|
+
reason?: unknown;
|
|
1704
|
+
at: number;
|
|
1705
|
+
}
|
|
1706
|
+
| {
|
|
1707
|
+
type: "transition.taken";
|
|
1708
|
+
runId: RunId;
|
|
1709
|
+
from: NodeId;
|
|
1710
|
+
outcome: PlinkoOutcome;
|
|
1711
|
+
to?: NodeId;
|
|
1712
|
+
at: number;
|
|
1713
|
+
}
|
|
1714
|
+
| {
|
|
1715
|
+
type: "run.event";
|
|
1716
|
+
runId: RunId;
|
|
1717
|
+
nodeId: NodeId;
|
|
1718
|
+
name: string;
|
|
1719
|
+
p?: unknown;
|
|
1720
|
+
at: number;
|
|
1721
|
+
}
|
|
1722
|
+
| {
|
|
1723
|
+
type: "run.completed";
|
|
1724
|
+
runId: RunId;
|
|
1725
|
+
status: Extract<
|
|
1726
|
+
PlinkoRunStatus,
|
|
1727
|
+
"succeeded" | "failed" | "cancelled"
|
|
1728
|
+
>;
|
|
1729
|
+
result: Record<string, unknown>;
|
|
1730
|
+
error?: SerializedError;
|
|
1731
|
+
at: number;
|
|
1732
|
+
};
|
|
1733
|
+
type PlinkoEnvelope = {
|
|
1734
|
+
__plinko: 1;
|
|
1735
|
+
graphId: string;
|
|
1736
|
+
graphVersion?: string;
|
|
1737
|
+
runId: RunId;
|
|
1738
|
+
event: PlinkoEvent;
|
|
1739
|
+
snapshot: PlinkoRunSnapshot;
|
|
1740
|
+
};
|
|
1741
|
+
type PlinkoRunSnapshot = Readonly<{
|
|
1742
|
+
id: RunId;
|
|
1743
|
+
graphId: string;
|
|
1744
|
+
graphVersion?: string;
|
|
1745
|
+
status: PlinkoRunStatus;
|
|
1746
|
+
currentNodeId?: NodeId;
|
|
1747
|
+
input: unknown;
|
|
1748
|
+
results: Readonly<Record<string, unknown>>;
|
|
1749
|
+
events: readonly PlinkoEvent[];
|
|
1750
|
+
startedAt?: number;
|
|
1751
|
+
endedAt?: number;
|
|
1752
|
+
error?: SerializedError;
|
|
1753
|
+
}>;
|
|
1754
|
+
type MutablePlinkoRunSnapshot = {
|
|
1755
|
+
id: RunId;
|
|
1756
|
+
graphId: string;
|
|
1757
|
+
graphVersion?: string;
|
|
1758
|
+
status: PlinkoRunStatus;
|
|
1759
|
+
currentNodeId?: NodeId;
|
|
1760
|
+
input: unknown;
|
|
1761
|
+
results: Record<string, unknown>;
|
|
1762
|
+
events: PlinkoEvent[];
|
|
1763
|
+
startedAt?: number;
|
|
1764
|
+
endedAt?: number;
|
|
1765
|
+
error?: SerializedError;
|
|
1766
|
+
};
|
|
1767
|
+
type PlinkoAttemptEvent<TOutput> =
|
|
1768
|
+
| {
|
|
1769
|
+
type: "started";
|
|
1770
|
+
attempt: number;
|
|
1771
|
+
}
|
|
1772
|
+
| {
|
|
1773
|
+
type: "succeeded";
|
|
1774
|
+
attempt: number;
|
|
1775
|
+
result: TOutput;
|
|
1776
|
+
durationMs: number;
|
|
1777
|
+
}
|
|
1778
|
+
| {
|
|
1779
|
+
type: "failed";
|
|
1780
|
+
attempt: number;
|
|
1781
|
+
error: SerializedError;
|
|
1782
|
+
durationMs: number;
|
|
1783
|
+
willRetry: boolean;
|
|
1784
|
+
}
|
|
1785
|
+
| {
|
|
1786
|
+
type: "retrying";
|
|
1787
|
+
attempt: number;
|
|
1788
|
+
delayMs: number;
|
|
1789
|
+
}
|
|
1790
|
+
| {
|
|
1791
|
+
type: "cancelled";
|
|
1792
|
+
attempt: number;
|
|
1793
|
+
reason?: unknown;
|
|
1794
|
+
};
|
|
1795
|
+
type PlinkoNodeExecution<TOutput> = {
|
|
1796
|
+
outcome: PlinkoOutcome;
|
|
1797
|
+
result?: TOutput;
|
|
1798
|
+
error?: SerializedError;
|
|
1799
|
+
attempt: number;
|
|
1800
|
+
};
|
|
1801
|
+
type PlinkoStartOptions = {
|
|
1802
|
+
runId?: RunId;
|
|
1803
|
+
k?: string;
|
|
1804
|
+
sl?: SU;
|
|
1805
|
+
ms?: SU;
|
|
1806
|
+
rt?: SU;
|
|
1807
|
+
ttl?: number;
|
|
1808
|
+
maxTransitions?: number;
|
|
1809
|
+
};
|
|
1810
|
+
type PlinkoRunHandle = Readonly<{
|
|
1811
|
+
id: RunId;
|
|
1812
|
+
done: Promise<PlinkoRunSnapshot>;
|
|
1813
|
+
|
|
1814
|
+
cancel(reason?: unknown): void;
|
|
1815
|
+
}>;
|
|
1816
|
+
type PlinkoDefinitionHandle<TInput> = Readonly<{
|
|
1817
|
+
graph: CompiledGraph<TInput>;
|
|
1818
|
+
|
|
1819
|
+
start(
|
|
1820
|
+
input: TInput,
|
|
1821
|
+
options?: PlinkoStartOptions,
|
|
1822
|
+
): PlinkoRunHandle;
|
|
1823
|
+
}>;
|
|
1824
|
+
type SIG_BUS_PLINKO_FN = {
|
|
1825
|
+
<TInput>(
|
|
1826
|
+
definition: PlinkoDefinition<TInput>,
|
|
1827
|
+
): PlinkoDefinitionHandle<TInput>;
|
|
1828
|
+
|
|
1829
|
+
define<TInput>(
|
|
1830
|
+
definition: PlinkoDefinition<TInput>,
|
|
1831
|
+
): PlinkoDefinitionHandle<TInput>;
|
|
1832
|
+
|
|
1833
|
+
compile<TInput>(
|
|
1834
|
+
definition: PlinkoDefinition<TInput>,
|
|
1835
|
+
): CompiledGraph<TInput>;
|
|
1836
|
+
};
|
|
1837
|
+
type StartOptions = {
|
|
1838
|
+
eventSink?: EventSink;
|
|
1839
|
+
maxTransitions?: number;
|
|
1840
|
+
runId?: RunId;
|
|
1841
|
+
|
|
1842
|
+
/**
|
|
1843
|
+
* Used for non-durable diagnostics/telemetry. If omitted, telemetry append
|
|
1844
|
+
* failures are ignored. Event-sink failures are never ignored.
|
|
1845
|
+
*/
|
|
1846
|
+
onTelemetryError?: (error: unknown, event: PlinkoEvent) => void;
|
|
1847
|
+
};
|
|
1848
|
+
type RunSnapshot = Readonly<{
|
|
1849
|
+
id: RunId;
|
|
1850
|
+
graphId: string;
|
|
1851
|
+
graphVersion?: string;
|
|
1852
|
+
status: RunStatus;
|
|
1853
|
+
currentNodeId?: NodeId;
|
|
1854
|
+
input: unknown;
|
|
1855
|
+
results: Readonly<Record<string, unknown>>;
|
|
1856
|
+
events: readonly PlinkoEvent[];
|
|
1857
|
+
startedAt?: number;
|
|
1858
|
+
endedAt?: number;
|
|
1859
|
+
error?: SerializedError;
|
|
1860
|
+
}>;
|
|
1861
|
+
type MutableRunSnapshot = {
|
|
1862
|
+
id: RunId;
|
|
1863
|
+
graphId: string;
|
|
1864
|
+
graphVersion?: string;
|
|
1865
|
+
status: RunStatus;
|
|
1866
|
+
currentNodeId?: NodeId;
|
|
1867
|
+
input: unknown;
|
|
1868
|
+
results: Record<string, unknown>;
|
|
1869
|
+
events: PlinkoEvent[];
|
|
1870
|
+
startedAt?: number;
|
|
1871
|
+
endedAt?: number;
|
|
1872
|
+
error?: SerializedError;
|
|
1873
|
+
};
|
|
1874
|
+
type ReadonlyValue<T> = T extends object ? Readonly<T> : T;
|
|
1875
|
+
type Outcome = | "success" | "failure" | "skipped" | "cancelled";
|
|
1876
|
+
type RunStatus = | "idle" | "running" | "succeeded" | "failed" | "cancelled";
|
|
1877
|
+
type RetryPolicy = {
|
|
1878
|
+
maxAttempts?: number;
|
|
1879
|
+
delayMs?: number;
|
|
1880
|
+
maxDelayMs?: number;
|
|
1881
|
+
backoff?: "fixed" | "linear" | "exponential";
|
|
1882
|
+
jitter?: "none" | "full";
|
|
1883
|
+
retryIf?: (error: unknown, attempt: number) => boolean;
|
|
1884
|
+
};
|
|
1885
|
+
type NodeContext<TInput, TResults extends Record<string, unknown> = Record<string, unknown>,> = {
|
|
1886
|
+
readonly runId: RunId;
|
|
1887
|
+
readonly nodeId: NodeId;
|
|
1888
|
+
readonly attempt: number;
|
|
1889
|
+
readonly input: TInput;
|
|
1890
|
+
readonly results: Readonly<TResults>;
|
|
1891
|
+
readonly variables: ReadonlyMap<string, unknown>;
|
|
1892
|
+
readonly signal: AbortSignal;
|
|
1893
|
+
emit(name: string, p?: unknown): void;
|
|
1894
|
+
};
|
|
1895
|
+
type AttemptEvent<TOutput> =
|
|
1896
|
+
| {
|
|
1897
|
+
type: "started";
|
|
1898
|
+
attempt: number;
|
|
1899
|
+
}
|
|
1900
|
+
| {
|
|
1901
|
+
type: "succeeded";
|
|
1902
|
+
attempt: number;
|
|
1903
|
+
result: TOutput;
|
|
1904
|
+
durationMs: number;
|
|
1905
|
+
}
|
|
1906
|
+
| {
|
|
1907
|
+
type: "failed";
|
|
1908
|
+
attempt: number;
|
|
1909
|
+
error: SerializedError;
|
|
1910
|
+
durationMs: number;
|
|
1911
|
+
willRetry: boolean;
|
|
1912
|
+
}
|
|
1913
|
+
| {
|
|
1914
|
+
type: "retrying";
|
|
1915
|
+
attempt: number;
|
|
1916
|
+
delayMs: number;
|
|
1917
|
+
}
|
|
1918
|
+
| {
|
|
1919
|
+
type: "cancelled";
|
|
1920
|
+
attempt: number;
|
|
1921
|
+
reason?: unknown;
|
|
1922
|
+
};
|
|
1923
|
+
type NodeExecution<TOutput = unknown> = {
|
|
1924
|
+
outcome: Outcome;
|
|
1925
|
+
result?: TOutput;
|
|
1926
|
+
error?: SerializedError;
|
|
1927
|
+
attempt: number;
|
|
1928
|
+
};
|
|
1929
|
+
type EventSink = {
|
|
1930
|
+
append(event: PlinkoEvent): void | Promise<void>;
|
|
1931
|
+
};
|
|
1932
|
+
type RunHandle = {
|
|
1933
|
+
id: RunId;
|
|
1934
|
+
done: Promise<RunSnapshot>;
|
|
1935
|
+
|
|
1936
|
+
getSnapshot(): RunSnapshot;
|
|
1937
|
+
subscribe(listener: () => void): () => void;
|
|
1938
|
+
cancel(reason?: unknown): void;
|
|
1939
|
+
};
|
|
1940
|
+
interface HandlerContext {
|
|
1941
|
+
rt: string;
|
|
1942
|
+
adapter?: SIG_BUS_Adapter;
|
|
1943
|
+
meta: SIG_BUS_MessageMeta;
|
|
1944
|
+
}
|
|
1945
|
+
interface SwitchboardResult {
|
|
1946
|
+
success: boolean;
|
|
1947
|
+
matchedKey: string | null;
|
|
1948
|
+
result?: any;
|
|
1949
|
+
error?: Error;
|
|
1950
|
+
unmatched?: boolean;
|
|
1951
|
+
}
|
|
1952
|
+
type SwitchboardRoute2<TPayload = any> = (p: TPayload, ctx?: any) => Promise<any> | any;
|
|
1953
|
+
type SwitchboardRoutes<TPayload = any, TKey extends string = string> = | { [K in TKey | 'default']?: SwitchboardRoute2<TPayload> } | Map<string, SwitchboardRoute2<TPayload>>;
|
|
1954
|
+
interface SwitchboardHandle<TPayload = any, TKey extends string = string> {
|
|
1955
|
+
unregister: () => void; // same as your prior unregister()
|
|
1956
|
+
registerRoute: (rawKey: string, route: SwitchboardRoute2<TPayload>) => void;
|
|
1957
|
+
unregisterRoute: (rawKey: string) => boolean;
|
|
1958
|
+
updateRoutes: (routes: Partial<Record<string, SwitchboardRoute2<TPayload>>>) => void;
|
|
1959
|
+
getRoutes: () => Record<string, SwitchboardRoute2<TPayload> | undefined>;
|
|
1960
|
+
changes: () => AsyncIterable<{ type: 'add' | 'remove' | 'update'; key: string }>;
|
|
1961
|
+
}
|
|
1962
|
+
interface SwitchboardOptions2<TPayload = any, TKey extends string = string> {
|
|
1963
|
+
selectKey: (p: TPayload) => TKey;
|
|
1964
|
+
onUnmatched?: (p: TPayload, key: string | null) => void;
|
|
1965
|
+
}
|
|
1966
|
+
type PlinkoConditionType2 = | 'onSuccess' | 'onFailure' | 'always' | 'envVariable' | 'configValue' | 'fileExists' | 'fileNotExists' | 'itemSuccess' | 'itemFailure' | 'custom' | 'and' | 'or' | 'not' | 'timeBased' | 'rateLimit' | 'random' | 'dependencies';
|
|
1967
|
+
type ExecutionMode2 = 'sequential' | 'parallel' | 'firstMatch' | 'allMatch' | 'race';
|
|
1968
|
+
type BackoffStrategy2 = 'exponential' | 'linear' | 'fixed' | 'none';
|
|
1969
|
+
interface RetryConfig2 {
|
|
1970
|
+
max: number;
|
|
1971
|
+
backoff: BackoffStrategy2;
|
|
1972
|
+
delay?: number;
|
|
1973
|
+
maxDelay?: number;
|
|
1974
|
+
retryOn?: string[]; // Error types to retry on
|
|
1975
|
+
}
|
|
1976
|
+
interface PlinkoCondition2 {
|
|
1977
|
+
type: PlinkoConditionType2;
|
|
1978
|
+
// Environment/Config
|
|
1979
|
+
envKey?: string;
|
|
1980
|
+
configKey?: string;
|
|
1981
|
+
operator?: 'equals' | 'contains' | 'startsWith' | 'endsWith' | 'regex' | 'gt' | 'gte' | 'lt' | 'lte';
|
|
1982
|
+
value?: any;
|
|
1983
|
+
// File operations
|
|
1984
|
+
filePath?: string;
|
|
1985
|
+
// Item tracking
|
|
1986
|
+
itemLabel?: string;
|
|
1987
|
+
// Custom expressions
|
|
1988
|
+
expression?: string;
|
|
1989
|
+
// Logic operators
|
|
1990
|
+
conditions?: PlinkoCondition2[];
|
|
1991
|
+
// Time based
|
|
1992
|
+
window?: number; // Time window in ms
|
|
1993
|
+
limit?: number; // Rate limit count
|
|
1994
|
+
// Execution targets
|
|
1995
|
+
executeChain?: string | string[] | PlinkoStep2[];
|
|
1996
|
+
exe?: PlinkoStep2[];
|
|
1997
|
+
// Branching
|
|
1998
|
+
onSuccess?: string | PlinkoStep2[];
|
|
1999
|
+
onFailure?: string | PlinkoStep2[];
|
|
2000
|
+
// Priority (higher runs first)
|
|
2001
|
+
priority?: number;
|
|
2002
|
+
// Optional label
|
|
2003
|
+
label?: string;
|
|
2004
|
+
// Timeout for this condition's execution
|
|
2005
|
+
timeout?: number;
|
|
2006
|
+
}
|
|
2007
|
+
interface PlinkoStep2 {
|
|
2008
|
+
id?: string;
|
|
2009
|
+
label?: string;
|
|
2010
|
+
path?: string;
|
|
2011
|
+
type: 'chain' | 'parallel' | 'conditionalTree' | 'function' | 'retry' | 'timeout' | 'circuitBreaker';
|
|
2012
|
+
args?: any[];
|
|
2013
|
+
// Execution
|
|
2014
|
+
execute?: (context: PlinkoContext2) => any | Promise<any>;
|
|
2015
|
+
// Chain execution (sequential steps)
|
|
2016
|
+
steps?: PlinkoStep2[];
|
|
2017
|
+
// Conditional tree args
|
|
2018
|
+
conditions?: PlinkoCondition2[];
|
|
2019
|
+
// Retry configuration
|
|
2020
|
+
retry?: RetryConfig2;
|
|
2021
|
+
// Timeout in ms
|
|
2022
|
+
timeout?: number;
|
|
2023
|
+
// Circuit breaker
|
|
2024
|
+
circuitBreaker?: {
|
|
2025
|
+
failureThreshold: number;
|
|
2026
|
+
resetTimeout: number;
|
|
2027
|
+
halfOpenMaxCalls: number;
|
|
2028
|
+
};
|
|
2029
|
+
// Condition to run this step
|
|
2030
|
+
condition?: (context: PlinkoContext2) => boolean | Promise<boolean>;
|
|
2031
|
+
// Priority
|
|
2032
|
+
priority?: number;
|
|
2033
|
+
// Dependencies
|
|
2034
|
+
dependsOn?: string[];
|
|
2035
|
+
// On complete hook
|
|
2036
|
+
onComplete?: (result: any, context: PlinkoContext2) => any | Promise<any>;
|
|
2037
|
+
onError?: (error: Error, context: PlinkoContext2) => any | Promise<any>;
|
|
2038
|
+
// Environment
|
|
2039
|
+
environment?: string | string[];
|
|
2040
|
+
metadata?: Record<string, any>;
|
|
2041
|
+
}
|
|
2042
|
+
interface PlinkoContext22 {
|
|
2043
|
+
// Original p
|
|
2044
|
+
p: any;
|
|
2045
|
+
// Shared state
|
|
2046
|
+
state: Map<string, any>;
|
|
2047
|
+
// Results from each step
|
|
2048
|
+
results: Map<string, any>;
|
|
2049
|
+
// Execution history
|
|
2050
|
+
history: string[];
|
|
2051
|
+
// Variables (mutable)
|
|
2052
|
+
variables: Map<string, any>;
|
|
2053
|
+
// Step results with timestamps
|
|
2054
|
+
stepResults: Map<string, StepResult2>;
|
|
2055
|
+
// Session ID
|
|
2056
|
+
sessionId: string;
|
|
2057
|
+
// Start time
|
|
2058
|
+
startTime: number;
|
|
2059
|
+
// Parent context (for nested executions)
|
|
2060
|
+
parent?: PlinkoContext2;
|
|
2061
|
+
// Bus reference
|
|
2062
|
+
bus: any;
|
|
2063
|
+
// Metadata
|
|
2064
|
+
metadata: Map<string, any>;
|
|
2065
|
+
}
|
|
2066
|
+
interface PlinkoContext2 {
|
|
2067
|
+
p: any;
|
|
2068
|
+
state: Map<any, any>;
|
|
2069
|
+
results: Map<any, any>;
|
|
2070
|
+
history: string[];
|
|
2071
|
+
variables: Map<any, any>;
|
|
2072
|
+
stepResults: Map<any, any>;
|
|
2073
|
+
sessionId: string;
|
|
2074
|
+
startTime: number;
|
|
2075
|
+
bus: any;
|
|
2076
|
+
metadata: Map<any, any>;
|
|
2077
|
+
}
|
|
2078
|
+
interface StepResult2 {
|
|
2079
|
+
success: boolean;
|
|
2080
|
+
result?: any;
|
|
2081
|
+
error?: Error;
|
|
2082
|
+
duration: number;
|
|
2083
|
+
startTime: number;
|
|
2084
|
+
endTime: number;
|
|
2085
|
+
metadata?: Record<string, any>;
|
|
2086
|
+
}
|
|
2087
|
+
interface PlinkoTree2<T = any> {
|
|
2088
|
+
[key: string]: PlinkoStep2 | PlinkoTree2<T> | ((context: PlinkoContext2) => any);
|
|
2089
|
+
}
|
|
2090
|
+
interface PlinkoExecutionResult2 {
|
|
2091
|
+
sessionId: string;
|
|
2092
|
+
success: boolean;
|
|
2093
|
+
results: Map<string, StepResult2>;
|
|
2094
|
+
history: string[];
|
|
2095
|
+
duration: number;
|
|
2096
|
+
error?: Error;
|
|
2097
|
+
metadata: Record<string, any>;
|
|
2098
|
+
}
|
|
2099
|
+
type GateMatcher1<T = any> = (p: T) => boolean | Promise<boolean>;
|
|
2100
|
+
type GateHandler1<T = any, R = any> = (
|
|
2101
|
+
p: T,
|
|
2102
|
+
context: {
|
|
2103
|
+
reply: (data: any, subrt?: string) => Promise<unknown>;
|
|
2104
|
+
store: Map<string, any>;
|
|
2105
|
+
bus: any;
|
|
2106
|
+
}
|
|
2107
|
+
) => R | Promise<R>;
|
|
2108
|
+
interface GateDefinition1<T = any, R = any> {
|
|
2109
|
+
priority?: number;
|
|
2110
|
+
matcher: GateMatcher1<T>;
|
|
2111
|
+
execute: GateHandler1<T, R>;
|
|
2112
|
+
persistent?: boolean;
|
|
2113
|
+
blocking?: boolean;
|
|
2114
|
+
}
|
|
2115
|
+
type GateInput1<T = any> =
|
|
2116
|
+
| GateMatcher1<T>
|
|
2117
|
+
| GateDefinition1<T>;
|
|
2118
|
+
type GateMap1<T = any> = Record<string, GateInput1<T>>;
|
|
2119
|
+
interface GateExecutionResult1 {
|
|
2120
|
+
gateId: string;
|
|
2121
|
+
fired: boolean;
|
|
2122
|
+
result?: any;
|
|
2123
|
+
error?: Error;
|
|
2124
|
+
duration: number;
|
|
2125
|
+
}
|
|
2126
|
+
interface ResolvedGate1<T = any> extends GateDefinition1<T> {
|
|
2127
|
+
id: string;
|
|
2128
|
+
}
|
|
2129
|
+
interface RelayHandle {
|
|
2130
|
+
publish: (chunk: any) => Promise<void>;
|
|
2131
|
+
subscribe: (handler: (chunk: any) => void) => {
|
|
2132
|
+
unsubscribe: () => void;
|
|
2133
|
+
pause: () => void;
|
|
2134
|
+
resume: () => void;
|
|
2135
|
+
getBufferSize: () => number;
|
|
2136
|
+
};
|
|
2137
|
+
end: () => Promise<void>;
|
|
2138
|
+
stats?(): { subscribers: number; ended: boolean };
|
|
2139
|
+
}
|
|
2140
|
+
interface RelaySubscription {
|
|
2141
|
+
unsubscribe(): void;
|
|
2142
|
+
pause(): void;
|
|
2143
|
+
resume(): void;
|
|
2144
|
+
getBufferSize(): number;
|
|
2145
|
+
}
|
|
2146
|
+
interface RelayOptions {
|
|
2147
|
+
maxSubscribers?: number;
|
|
2148
|
+
bufferSize?: number;
|
|
2149
|
+
backpressureStrategy?: 'drop' | 'pause' | 'error';
|
|
2150
|
+
}
|
|
2151
|
+
interface OffsetCheckpoint {
|
|
2152
|
+
epoch: string;
|
|
2153
|
+
offset: number;
|
|
2154
|
+
}
|
|
2155
|
+
interface RelaySub {
|
|
2156
|
+
id: string;
|
|
2157
|
+
buffer: WireEnvelope[];
|
|
2158
|
+
paused: boolean;
|
|
2159
|
+
closed: boolean;
|
|
2160
|
+
notify: (() => void) | null;
|
|
2161
|
+
pump: Promise<void>;
|
|
2162
|
+
}
|
|
2163
|
+
interface OffsetStore {
|
|
2164
|
+
get(sid: string): Promise<OffsetCheckpoint | undefined>;
|
|
2165
|
+
set(sid: string, cp: OffsetCheckpoint): Promise<void>;
|
|
2166
|
+
delete(sid: string): Promise<void>;
|
|
2167
|
+
}
|
|
2168
|
+
interface SyncSubOptions {
|
|
2169
|
+
name?: string;
|
|
2170
|
+
epoch?: string; // resume a run from its checkpoint
|
|
2171
|
+
maxSkew?: number;
|
|
2172
|
+
bufferTtlMs?: number;
|
|
2173
|
+
nackDelayMs?: number;
|
|
2174
|
+
nackBatch?: number;
|
|
2175
|
+
graceMs?: number;
|
|
2176
|
+
offsetStore?: OffsetStore;
|
|
2177
|
+
checkpointEveryMs?: number;
|
|
2178
|
+
onDlq?: (env: WireEnvelope, reason: string) => MaybePromise<void>;
|
|
2179
|
+
onComplete?: (err?: Error) => void;
|
|
2180
|
+
signal?: AbortSignal;
|
|
2181
|
+
}
|
|
2182
|
+
interface SyncHandle {
|
|
2183
|
+
close(): void;
|
|
2184
|
+
whenComplete(): Promise<void>;
|
|
2185
|
+
state(): { epoch: string | null; expected: number; buffered: number };
|
|
2186
|
+
}
|
|
2187
|
+
interface SyncSendOptions {
|
|
2188
|
+
name?: string;
|
|
2189
|
+
epoch?: string; // reuse to resume a prior interrupted run
|
|
2190
|
+
trace?: string;
|
|
2191
|
+
windowSize?: number;
|
|
2192
|
+
timeoutMs?: number;
|
|
2193
|
+
maxRetries?: number;
|
|
2194
|
+
backoffBaseMs?: number;
|
|
2195
|
+
onProgress?: (acked: number, total: number) => void;
|
|
2196
|
+
onDlq?: (env: WireEnvelope, reason: string) => MaybePromise<void>;
|
|
2197
|
+
signal?: AbortSignal;
|
|
2198
|
+
}
|
|
2199
|
+
interface StreamLabMetrics {
|
|
2200
|
+
dataSent: number;
|
|
2201
|
+
dataAcked: number;
|
|
2202
|
+
dataRetransmitted: number;
|
|
2203
|
+
nackSent: number;
|
|
2204
|
+
nackReceived: number;
|
|
2205
|
+
overflow: number;
|
|
2206
|
+
dlq: number;
|
|
2207
|
+
dropped: number;
|
|
2208
|
+
errors: number;
|
|
2209
|
+
streamsActive: number;
|
|
2210
|
+
streamsCompleted: number;
|
|
2211
|
+
relaySent: number;
|
|
2212
|
+
}
|
|
2213
|
+
type WireKind = 'data' | 'ack' | 'nack' | 'done' | 'abort' | 'dlq';
|
|
2214
|
+
interface WireEnvelope<T = unknown> {
|
|
2215
|
+
v: number
|
|
2216
|
+
kind: WireKind;
|
|
2217
|
+
sid: string; // deterministic logical stream id
|
|
2218
|
+
epoch: string; // run id — reusing an epoch resumes that run
|
|
2219
|
+
seq: number;
|
|
2220
|
+
total: number;
|
|
2221
|
+
data?: T;
|
|
2222
|
+
enc?: 'json' | 'base64';
|
|
2223
|
+
trace: string;
|
|
2224
|
+
retryOf?: number;
|
|
2225
|
+
reason?: string;
|
|
2226
|
+
}
|
|
2227
|
+
interface SauronState {
|
|
2228
|
+
get<T>(key: string | symbol, opts?: ScopeOptions): T | undefined
|
|
2229
|
+
set<T>(key: string | symbol, value: T | ((prev: T | undefined) => T), opts?: { triggerRender?: boolean } & ScopeOptions): void
|
|
2230
|
+
delete(key: string | symbol, opts?: ScopeOptions): boolean
|
|
2231
|
+
getByPrefix<T>(prefix: string, opts?: ScopeOptions): { key: string; value: T }[]
|
|
2232
|
+
getAll<T = any>(opts?: ScopeOptions): Record<string | symbol, T>
|
|
2233
|
+
subscribe<T>(key: string | symbol, listener: (value: T) => void, opts?: ScopeOptions): () => void
|
|
2234
|
+
subscribeAll(listener: (key: string | symbol, value: any) => void, opts?: ScopeOptions): () => void
|
|
2235
|
+
clear(opts?: ScopeOptions): void
|
|
2236
|
+
waitFor<T = any>(key: string | symbol, opts: ScopeOptions): Promise<T>
|
|
2237
|
+
batch?(key: any, fn: () => void): void
|
|
2238
|
+
}
|
|
2239
|
+
interface HookState {
|
|
2240
|
+
value: any
|
|
2241
|
+
deps?: any[]
|
|
2242
|
+
cleanup?: () => void
|
|
2243
|
+
ref?: any
|
|
2244
|
+
domRefs?: Map<string, Node>
|
|
2245
|
+
bindings?: Set<DOMBinding>
|
|
2246
|
+
}
|
|
2247
|
+
interface ComponentInstance {
|
|
2248
|
+
id: string
|
|
2249
|
+
hooks: Map<string, HookState>
|
|
2250
|
+
unmount: Set<() => void>
|
|
2251
|
+
render?: () => void
|
|
2252
|
+
parent?: ComponentInstance | null
|
|
2253
|
+
contextProviders?: Map<string, { value: any; subscribe: (fn: () => void) => () => void }>
|
|
2254
|
+
}
|
|
2255
|
+
interface OptimisticHookState extends HookState {
|
|
2256
|
+
previousValue: any
|
|
2257
|
+
isPending: boolean
|
|
2258
|
+
}
|
|
2259
|
+
interface SauronContext<T> {
|
|
2260
|
+
id: string;
|
|
2261
|
+
DefaultValue?: T;
|
|
2262
|
+
Provider?: any;
|
|
2263
|
+
sl?: string
|
|
2264
|
+
ms?: string
|
|
2265
|
+
rt?: string
|
|
2266
|
+
}
|
|
2267
|
+
interface RuntimeAdapter {
|
|
2268
|
+
getComponentInstance: () => { instance: ComponentInstance, forceUpdate: () => void }
|
|
2269
|
+
onHookSubscribe: (key: string, forceUpdate: () => void) => void
|
|
2270
|
+
}
|
|
2271
|
+
|
|
2272
|
+
// #region PRIMITIVE TYPES
|
|
2273
|
+
|
|
2274
|
+
type ObjectType = Record<string, IncantationsConfig<any, any, any, any, any, any, any, any, any, any>>;
|
|
2275
|
+
type SelfType = { self: any;[category: string]: any };
|
|
2276
|
+
type Factory = (ctx: SelfType) => ObjectType
|
|
2277
|
+
|
|
2278
|
+
|
|
2279
|
+
type AnySelfType = { self: any;[key: string]: any };
|
|
2280
|
+
type AnyObject = Record<string, any>;
|
|
2281
|
+
type AnyFactory = (ctx: AnySelfType) => AnyObject;
|
|
2282
|
+
type AnyType = AnyObject | AnyFactory;
|
|
2283
|
+
|
|
2284
|
+
|
|
2285
|
+
|
|
2286
|
+
type incan_vars_obj = Record<string, any>;
|
|
2287
|
+
type incan_vars_ctx = { self: any;[category: string]: any };
|
|
2288
|
+
type incan_vars_vault_factory = (ctx: incan_vars_ctx) => incan_vars_obj | incan_vars_obj;
|
|
2289
|
+
|
|
2290
|
+
|
|
2291
|
+
type ArcheTypeCtx = { self: any;[category: string]: any };
|
|
2292
|
+
|
|
2293
|
+
|
|
2294
|
+
|
|
2295
|
+
// #endregion ============================================
|
|
2296
|
+
// #region FUNCTION TYPES
|
|
2297
|
+
// ============================================
|
|
2298
|
+
type vault_source = {
|
|
2299
|
+
variants?: Record<string, Record<string, any>>;
|
|
2300
|
+
base?: ClassInput;
|
|
2301
|
+
slots?: Record<string, ClassInput>;
|
|
2302
|
+
compoundVariants?: any[];
|
|
2303
|
+
defaultVariants?: Record<string, any>;
|
|
2304
|
+
animation?: any;
|
|
2305
|
+
aliases?: any;
|
|
2306
|
+
};
|
|
2307
|
+
type base_props = {
|
|
2308
|
+
className?: string;
|
|
2309
|
+
class?: string;
|
|
2310
|
+
children?: any;
|
|
2311
|
+
style?: any;
|
|
2312
|
+
[key: string]: any;
|
|
2313
|
+
};
|
|
2314
|
+
|
|
2315
|
+
|
|
2316
|
+
type ClassInput =
|
|
2317
|
+
| string
|
|
2318
|
+
| number
|
|
2319
|
+
| boolean
|
|
2320
|
+
| null
|
|
2321
|
+
| undefined
|
|
2322
|
+
| ClassInput[]
|
|
2323
|
+
| Record<string, boolean | null | undefined>;
|
|
2324
|
+
type AsConfig = Record<string, ClassInput>;
|
|
2325
|
+
|
|
2326
|
+
type AnimationVariant = {
|
|
2327
|
+
enter?: ClassInput;
|
|
2328
|
+
exit?: ClassInput;
|
|
2329
|
+
hover?: ClassInput;
|
|
2330
|
+
focus?: ClassInput;
|
|
2331
|
+
active?: ClassInput;
|
|
2332
|
+
};
|
|
2333
|
+
|
|
2334
|
+
type MotionVariant = {
|
|
2335
|
+
initial?: Record<string, any>;
|
|
2336
|
+
animate?: Record<string, any>;
|
|
2337
|
+
exit?: Record<string, any>;
|
|
2338
|
+
transition?: Record<string, any>;
|
|
2339
|
+
whileHover?: Record<string, any>;
|
|
2340
|
+
whileFocus?: Record<string, any>;
|
|
2341
|
+
whileTap?: Record<string, any>;
|
|
2342
|
+
};
|
|
2343
|
+
|
|
2344
|
+
|
|
2345
|
+
type AsNode = Record<string, any> & { parent: string };
|
|
2346
|
+
|
|
2347
|
+
type SlotRecord = Record<string, ClassInput>;
|
|
2348
|
+
|
|
2349
|
+
type VariantSchema = Record<string, Record<string, ClassInput>>;
|
|
2350
|
+
|
|
2351
|
+
|
|
2352
|
+
|
|
2353
|
+
type AnyVariantSchema =
|
|
2354
|
+
| VariantSchema
|
|
2355
|
+
| SlotVariantSchema;
|
|
2356
|
+
|
|
2357
|
+
type AnimationPresetMap = Record<
|
|
2358
|
+
string,
|
|
2359
|
+
AnimationVariant | MotionVariant
|
|
2360
|
+
>;
|
|
2361
|
+
|
|
2362
|
+
type ExposedVariants = Record<string, VariantGroup>;
|
|
2363
|
+
|
|
2364
|
+
// #endregion ============================================
|
|
2365
|
+
// #region BASE PROPS
|
|
2366
|
+
// ============================================
|
|
2367
|
+
|
|
2368
|
+
type BaseProps = {
|
|
2369
|
+
className?: string;
|
|
2370
|
+
class?: string;
|
|
2371
|
+
children?: any;
|
|
2372
|
+
style?: any;
|
|
2373
|
+
[key: string]: any;
|
|
2374
|
+
};
|
|
2375
|
+
|
|
2376
|
+
// #endregion ============================================
|
|
2377
|
+
// #region VARIANT GROUP
|
|
2378
|
+
// ============================================
|
|
2379
|
+
|
|
2380
|
+
type VariantGroup = Record<string, ClassInput> & {
|
|
2381
|
+
extend: (
|
|
2382
|
+
overrides: Record<string, ClassInput>
|
|
2383
|
+
) => Record<string, ClassInput>;
|
|
2384
|
+
};
|
|
2385
|
+
|
|
2386
|
+
// #endregion ============================================
|
|
2387
|
+
// #region COMPOUND VARIANTS
|
|
2388
|
+
// ============================================
|
|
2389
|
+
|
|
2390
|
+
type CompoundVariant = {
|
|
2391
|
+
variants: Record<string, string>;
|
|
2392
|
+
className?: ClassInput;
|
|
2393
|
+
style?: A;
|
|
2394
|
+
class?: ClassInput;
|
|
2395
|
+
};
|
|
2396
|
+
|
|
2397
|
+
type SlotVariantSchema1 = Record<
|
|
2398
|
+
string,
|
|
2399
|
+
Record<string, SlotRecord>
|
|
2400
|
+
>;
|
|
2401
|
+
|
|
2402
|
+
type SlotVariantSchema = Record<string, Record<string, SlotRecord>>;
|
|
2403
|
+
|
|
2404
|
+
type SlotCompoundVariant = {
|
|
2405
|
+
variants?: Record<string, string>;
|
|
2406
|
+
slots?: string[];
|
|
2407
|
+
class: ClassInput;
|
|
2408
|
+
};
|
|
2409
|
+
|
|
2410
|
+
|
|
2411
|
+
// #endregion ============================================
|
|
2412
|
+
// #region STATE MACHINE
|
|
2413
|
+
// ============================================
|
|
2414
|
+
|
|
2415
|
+
interface StateMachineConfig1 {
|
|
2416
|
+
[ComponentVariantKey: string]: {
|
|
2417
|
+
initial: string;
|
|
2418
|
+
transitions: Record<string, string[]>;
|
|
2419
|
+
guards?: Record<string, (props: any, prev: string, next: string) => boolean>;
|
|
2420
|
+
onEnter?: Record<string, (props: any, prev: string, next: string) => void>;
|
|
2421
|
+
onExit?: Record<string, (props: any, prev: string, next: string) => void>;
|
|
2422
|
+
onTransition?: (props: any, prev: string, next: string) => void;
|
|
2423
|
+
};
|
|
2424
|
+
}
|
|
2425
|
+
interface StateMachineConfig {
|
|
2426
|
+
initial: string;
|
|
2427
|
+
transitions: Record<string, string[]>;
|
|
2428
|
+
guards?: Record<string, (props: any, prev: string, next: string) => boolean>;
|
|
2429
|
+
onEnter?: Record<string, (props: any, prev: string, next: string) => void>;
|
|
2430
|
+
onExit?: Record<string, (props: any, prev: string, next: string) => void>;
|
|
2431
|
+
onTransition?: (props: any, prev: string, next: string) => void;
|
|
2432
|
+
}
|
|
2433
|
+
|
|
2434
|
+
// #endregion ============================================
|
|
2435
|
+
// #region MACHINE TYPES
|
|
2436
|
+
// ============================================
|
|
2437
|
+
|
|
2438
|
+
type MachineState = {
|
|
2439
|
+
currentState: Record<string, string>;
|
|
2440
|
+
};
|
|
2441
|
+
|
|
2442
|
+
type LogicMachine = {
|
|
2443
|
+
[logicalState: string]: {
|
|
2444
|
+
ON?: Record<string, string>;
|
|
2445
|
+
ASYNC_GUARD?: (props: any) => Promise<any> | boolean;
|
|
2446
|
+
actions?: string[];
|
|
2447
|
+
};
|
|
2448
|
+
};
|
|
2449
|
+
|
|
2450
|
+
type MachineRunner = {
|
|
2451
|
+
states: Record<string, string>;
|
|
2452
|
+
send: (
|
|
2453
|
+
variantKey: string,
|
|
2454
|
+
event: string,
|
|
2455
|
+
currentProps: any
|
|
2456
|
+
) => Record<string, string> | undefined;
|
|
2457
|
+
};
|
|
2458
|
+
|
|
2459
|
+
// #endregion ============================================
|
|
2460
|
+
// #region VAULT TYPES
|
|
2461
|
+
// ============================================
|
|
2462
|
+
|
|
2463
|
+
type VaultSource = {
|
|
2464
|
+
variants?: Record<string, Record<string, any>>;
|
|
2465
|
+
base?: ClassInput;
|
|
2466
|
+
slots?: Record<string, ClassInput>;
|
|
2467
|
+
compoundVariants?: any[];
|
|
2468
|
+
defaultVariants?: Record<string, any>;
|
|
2469
|
+
animation?: any;
|
|
2470
|
+
aliases?: any;
|
|
2471
|
+
};
|
|
2472
|
+
|
|
2473
|
+
type VaultEntry = {
|
|
2474
|
+
source: VaultSource;
|
|
2475
|
+
variants?: { [variantKey: string]: { [entryKey: string]: string } };
|
|
2476
|
+
};
|
|
2477
|
+
|
|
2478
|
+
type VaultConfig = {
|
|
2479
|
+
vault?: VaultEntry;
|
|
2480
|
+
[key: string]: IncantationsConfig | VaultEntry | undefined;
|
|
2481
|
+
};
|
|
2482
|
+
|
|
2483
|
+
// #endregion ============================================
|
|
2484
|
+
// #region FREYR ENUMS
|
|
2485
|
+
// ============================================
|
|
2486
|
+
|
|
2487
|
+
type FreyrMode = "light" | "dark" | "system" | string;
|
|
2488
|
+
type FreyrTheme = "default" | "ocean" | "forest" | "sunset" | string;
|
|
2489
|
+
type FreyrVersion = "v1" | "v2" | "v3" | string;
|
|
2490
|
+
type FreyrFonts = "sans" | "serif" | "mono" | string;
|
|
2491
|
+
type FreyrPresets = "minimal" | "modern" | "vintage" | string;
|
|
2492
|
+
|
|
2493
|
+
type IncantationsFreyrContext = {
|
|
2494
|
+
theme: FreyrTheme;
|
|
2495
|
+
version: FreyrVersion;
|
|
2496
|
+
mode: FreyrMode;
|
|
2497
|
+
};
|
|
2498
|
+
|
|
2499
|
+
type IncantationsFreyr = {
|
|
2500
|
+
mode?: FreyrMode;
|
|
2501
|
+
theme?: FreyrTheme;
|
|
2502
|
+
version?: FreyrVersion;
|
|
2503
|
+
fonts?: FreyrFonts;
|
|
2504
|
+
presets?: FreyrPresets;
|
|
2505
|
+
};
|
|
2506
|
+
|
|
2507
|
+
// #endregion ============================================
|
|
2508
|
+
// #region INCANTATIONS LEVEL 3
|
|
2509
|
+
// ============================================
|
|
2510
|
+
type variant_group = Record<string, ClassInput> & {
|
|
2511
|
+
extend: (
|
|
2512
|
+
overrides: Record<string, ClassInput>
|
|
2513
|
+
) => Record<string, ClassInput>;
|
|
2514
|
+
};
|
|
2515
|
+
|
|
2516
|
+
type IncantationsLvl3 = {
|
|
2517
|
+
db: any;
|
|
2518
|
+
bus: any;
|
|
2519
|
+
form: any;
|
|
2520
|
+
rdb: any;
|
|
2521
|
+
loader: any;
|
|
2522
|
+
session_mgmt: any;
|
|
2523
|
+
signals: any;
|
|
2524
|
+
jobs: any;
|
|
2525
|
+
fetch: any;
|
|
2526
|
+
sauron: any;
|
|
2527
|
+
htmx: any;
|
|
2528
|
+
cloud: any;
|
|
2529
|
+
cron: any;
|
|
2530
|
+
action: any;
|
|
2531
|
+
auth: any;
|
|
2532
|
+
realtime: any;
|
|
2533
|
+
reflect: any;
|
|
2534
|
+
};
|
|
2535
|
+
type vault_entry = {
|
|
2536
|
+
source: vault_source;
|
|
2537
|
+
variants?: { [variantKey: string]: { [entryKey: string]: string } };
|
|
2538
|
+
};
|
|
2539
|
+
|
|
2540
|
+
// #endregion ============================================
|
|
2541
|
+
// #region GENERIC INCANTATIONS CONFIG
|
|
2542
|
+
|
|
2543
|
+
type IncantationsConfig<
|
|
2544
|
+
S extends string = never,
|
|
2545
|
+
V extends Record<string, Record<string, any>> = Record<string, Record<string, any>>,
|
|
2546
|
+
T = unknown,
|
|
2547
|
+
I = unknown,
|
|
2548
|
+
E = unknown,
|
|
2549
|
+
C = unknown,
|
|
2550
|
+
SP = unknown,
|
|
2551
|
+
SO = unknown,
|
|
2552
|
+
CL = unknown,
|
|
2553
|
+
G = unknown
|
|
2554
|
+
> = {
|
|
2555
|
+
// Identifiers
|
|
2556
|
+
__S__?: S;
|
|
2557
|
+
__V__?: V;
|
|
2558
|
+
__T__?: T;
|
|
2559
|
+
__I__?: I;
|
|
2560
|
+
__E__?: E;
|
|
2561
|
+
__C__?: C;
|
|
2562
|
+
__SP__?: SP;
|
|
2563
|
+
__SO__?: SO;
|
|
2564
|
+
__CL__?: CL;
|
|
2565
|
+
__G__?: G;
|
|
2566
|
+
// NEED TO WORK ON THESE
|
|
2567
|
+
timeMachine?: any
|
|
2568
|
+
useMachine?: any
|
|
2569
|
+
useTimeMachine?: any
|
|
2570
|
+
logicMachine?: any
|
|
2571
|
+
inlineStyles?: any
|
|
2572
|
+
theme?: any
|
|
2573
|
+
className?: any
|
|
2574
|
+
preset?: any
|
|
2575
|
+
__Incantations__?: any
|
|
2576
|
+
meta?: any
|
|
2577
|
+
staticMeta?: any
|
|
2578
|
+
machinesMachine?: any
|
|
2579
|
+
router?: any
|
|
2580
|
+
|
|
2581
|
+
|
|
2582
|
+
// Types
|
|
2583
|
+
enums?: E;
|
|
2584
|
+
types?: T;
|
|
2585
|
+
interfaces?: I;
|
|
2586
|
+
generics?: G;
|
|
2587
|
+
|
|
2588
|
+
interface?: I;
|
|
2589
|
+
enum?: I;
|
|
2590
|
+
|
|
2591
|
+
// Styles
|
|
2592
|
+
styles?: {
|
|
2593
|
+
base?: A;
|
|
2594
|
+
variants?: Record<string, Record<string, A>>;
|
|
2595
|
+
defaultVariants?: Record<string, string>;
|
|
2596
|
+
};
|
|
2597
|
+
slots?: Record<S, ClassInput>;
|
|
2598
|
+
// Freyr & Global
|
|
2599
|
+
global?: () => G;
|
|
2600
|
+
freyrClasses?: string;
|
|
2601
|
+
freyrIncantations?: A;
|
|
2602
|
+
__globalContent?: Record<string, any>;
|
|
2603
|
+
__isGlobalized__?: boolean;
|
|
2604
|
+
freyr?: IncantationsFreyr | ((props: any) => any);
|
|
2605
|
+
classNames?: ClassInput;
|
|
2606
|
+
customTheme?: ClassInput;
|
|
2607
|
+
customCSS?: any;
|
|
2608
|
+
// Variants
|
|
2609
|
+
variants?: V;
|
|
2610
|
+
compoundVariants?: S extends never ? CompoundVariant[] : SlotCompoundVariant[];
|
|
2611
|
+
defaultVariants?: { [K in keyof V]?: keyof V[K] };
|
|
2612
|
+
base?: ClassInput;
|
|
2613
|
+
|
|
2614
|
+
// Animations
|
|
2615
|
+
animation?: S extends never
|
|
2616
|
+
? AnimationVariant | AnimationPresetMap
|
|
2617
|
+
: Record<S, AnimationVariant> | undefined;
|
|
2618
|
+
transition?: S extends never
|
|
2619
|
+
? AnimationVariant | AnimationPresetMap
|
|
2620
|
+
: Record<S, AnimationVariant> | undefined;
|
|
2621
|
+
|
|
2622
|
+
// Extend & Sync
|
|
2623
|
+
extend?: string;
|
|
2624
|
+
cloud?: CL;
|
|
2625
|
+
sync?: string;
|
|
2626
|
+
master?: boolean;
|
|
2627
|
+
|
|
2628
|
+
// Context
|
|
2629
|
+
context?: (props: any) => any;
|
|
2630
|
+
useContext?: any;
|
|
2631
|
+
createContext?: any;
|
|
2632
|
+
sauronContext?: any;
|
|
2633
|
+
reactContext?: any;
|
|
2634
|
+
useReactContext?: any;
|
|
2635
|
+
_compiledReactContext?: any;
|
|
2636
|
+
|
|
2637
|
+
// State Machines
|
|
2638
|
+
stateMachine?: { [K in keyof V]?: StateMachineConfig; };
|
|
2639
|
+
__logicMachineRunner?: any;
|
|
2640
|
+
getLogicState?: () => Record<string, string>;
|
|
2641
|
+
__machineRunner?: MachineRunner | null;
|
|
2642
|
+
getMachineState?: () => Record<string, string>;
|
|
2643
|
+
variantMachine?: any;
|
|
2644
|
+
|
|
2645
|
+
|
|
2646
|
+
|
|
2647
|
+
// As
|
|
2648
|
+
as?: AsConfig;
|
|
2649
|
+
asName?: string;
|
|
2650
|
+
|
|
2651
|
+
// Singles
|
|
2652
|
+
aliases?: { [K in keyof V]?: Record<string, keyof V[K]> };
|
|
2653
|
+
|
|
2654
|
+
// Constants & Specs
|
|
2655
|
+
constants?: C;
|
|
2656
|
+
specs?: SP;
|
|
2657
|
+
source?: SO;
|
|
2658
|
+
|
|
2659
|
+
// Documentation
|
|
2660
|
+
docs?: {
|
|
2661
|
+
[K in keyof V]?: {
|
|
2662
|
+
description?: string;
|
|
2663
|
+
values?: { [J in keyof V[keyof V]]?: string };
|
|
2664
|
+
};
|
|
2665
|
+
} & { description?: string };
|
|
2666
|
+
|
|
2667
|
+
// Dev Tools
|
|
2668
|
+
__location?: {
|
|
2669
|
+
file: string;
|
|
2670
|
+
line: number;
|
|
2671
|
+
column: number;
|
|
2672
|
+
functionName: string;
|
|
2673
|
+
};
|
|
2674
|
+
__definitionName?: string;
|
|
2675
|
+
__concentrationEnumGraph?: Record<string, TypeGraph>;
|
|
2676
|
+
__concentrationInterfaceGraph?: Record<string, TypeGraph>;
|
|
2677
|
+
__concentrationGenericGraph?: Record<string, TypeGraph>;
|
|
2678
|
+
__IncantationsTypeGraph?: Record<string, TypeGraph>;
|
|
2679
|
+
};
|
|
2680
|
+
// #endregion ============================================
|
|
2681
|
+
// #region TypeGraph - Complete Type Introspection System
|
|
2682
|
+
|
|
2683
|
+
type TypeFlags =
|
|
2684
|
+
| "Any"
|
|
2685
|
+
| "Unknown"
|
|
2686
|
+
| "Boolean"
|
|
2687
|
+
| "Number"
|
|
2688
|
+
| "String"
|
|
2689
|
+
| "Object"
|
|
2690
|
+
| "Array"
|
|
2691
|
+
| "Function"
|
|
2692
|
+
| "TypeParameter"
|
|
2693
|
+
| "Union"
|
|
2694
|
+
| "Intersection"
|
|
2695
|
+
| "Literal"
|
|
2696
|
+
| "Enum"
|
|
2697
|
+
| "Interface"
|
|
2698
|
+
| "Class"
|
|
2699
|
+
| "Generic"
|
|
2700
|
+
| "Record"
|
|
2701
|
+
| "Tuple"
|
|
2702
|
+
| "Optional"
|
|
2703
|
+
| "Nullable"
|
|
2704
|
+
| "Readonly";
|
|
2705
|
+
|
|
2706
|
+
type TypeGraph = {
|
|
2707
|
+
// Core identification
|
|
2708
|
+
id?: string;
|
|
2709
|
+
name?: string;
|
|
2710
|
+
type: TypeFlags;
|
|
2711
|
+
kind?: "primitive" | "composite" | "reference" | "generic";
|
|
2712
|
+
|
|
2713
|
+
// Value representation
|
|
2714
|
+
value?: any;
|
|
2715
|
+
defaultValue?: any;
|
|
2716
|
+
|
|
2717
|
+
// Type structure
|
|
2718
|
+
properties?: Record<string, TypeGraph>;
|
|
2719
|
+
elements?: TypeGraph[];
|
|
2720
|
+
indexSignature?: TypeGraph;
|
|
2721
|
+
|
|
2722
|
+
// Type parameters (generics)
|
|
2723
|
+
typeParameters?: TypeGraph[];
|
|
2724
|
+
typeArguments?: TypeGraph[];
|
|
2725
|
+
constraint?: TypeGraph;
|
|
2726
|
+
|
|
2727
|
+
// Union/Intersection members
|
|
2728
|
+
unionMembers?: TypeGraph[];
|
|
2729
|
+
intersectionMembers?: TypeGraph[];
|
|
2730
|
+
|
|
2731
|
+
// Function types
|
|
2732
|
+
parameters?: TypeGraph[];
|
|
2733
|
+
returnType?: TypeGraph;
|
|
2734
|
+
isAsync?: boolean;
|
|
2735
|
+
|
|
2736
|
+
// Class/Interface
|
|
2737
|
+
extends?: TypeGraph[];
|
|
2738
|
+
implements?: TypeGraph[];
|
|
2739
|
+
constructors?: TypeGraph[];
|
|
2740
|
+
methods?: Record<string, TypeGraph>;
|
|
2741
|
+
accessors?: Record<string, TypeGraph>;
|
|
2742
|
+
|
|
2743
|
+
// Enum
|
|
2744
|
+
enumMembers?: Record<string, string | number>;
|
|
2745
|
+
isStringEnum?: boolean;
|
|
2746
|
+
isNumericEnum?: boolean;
|
|
2747
|
+
|
|
2748
|
+
// Record types
|
|
2749
|
+
keyType?: TypeGraph;
|
|
2750
|
+
valueType?: TypeGraph;
|
|
2751
|
+
|
|
2752
|
+
// Tuple
|
|
2753
|
+
tupleElements?: TypeGraph[];
|
|
2754
|
+
isFixedLength?: boolean;
|
|
2755
|
+
restElement?: TypeGraph;
|
|
2756
|
+
|
|
2757
|
+
// Modifiers
|
|
2758
|
+
isOptional?: boolean;
|
|
2759
|
+
isNullable?: boolean;
|
|
2760
|
+
isReadonly?: boolean;
|
|
2761
|
+
isAbstract?: boolean;
|
|
2762
|
+
isStatic?: boolean;
|
|
2763
|
+
|
|
2764
|
+
// Generic constraints
|
|
2765
|
+
extendsConstraint?: TypeGraph;
|
|
2766
|
+
defaultType?: TypeGraph;
|
|
2767
|
+
|
|
2768
|
+
// Metadata
|
|
2769
|
+
description?: string;
|
|
2770
|
+
tags?: Record<string, any>;
|
|
2771
|
+
source?: {
|
|
2772
|
+
file: string;
|
|
2773
|
+
line: number;
|
|
2774
|
+
column: number;
|
|
2775
|
+
};
|
|
2776
|
+
|
|
2777
|
+
// Dependencies
|
|
2778
|
+
imports?: Record<string, string[]>;
|
|
2779
|
+
s?: string[];
|
|
2780
|
+
references?: TypeGraph[];
|
|
2781
|
+
|
|
2782
|
+
// Runtime info
|
|
2783
|
+
runtimeType?: any;
|
|
2784
|
+
validator?: (value: any) => boolean;
|
|
2785
|
+
serializer?: (value: any) => any;
|
|
2786
|
+
deserializer?: (value: any) => any;
|
|
2787
|
+
|
|
2788
|
+
// Graph relationships
|
|
2789
|
+
parent?: TypeGraph;
|
|
2790
|
+
children?: TypeGraph[];
|
|
2791
|
+
dependencies?: TypeGraph[];
|
|
2792
|
+
|
|
2793
|
+
// Custom metadata
|
|
2794
|
+
metadata?: Record<string, any>;
|
|
2795
|
+
|
|
2796
|
+
// Timestamps
|
|
2797
|
+
createdAt?: Date;
|
|
2798
|
+
updatedAt?: Date;
|
|
2799
|
+
version?: string;
|
|
2800
|
+
};
|
|
2801
|
+
|
|
2802
|
+
|
|
2803
|
+
// #endregion ============================================
|
|
2804
|
+
// #region TYPE GRAPH PREDICATES
|
|
2805
|
+
// ============================================
|
|
2806
|
+
|
|
2807
|
+
type TypeGraphPredicates = {
|
|
2808
|
+
isPrimitive: (graph: TypeGraph) => boolean;
|
|
2809
|
+
isComposite: (graph: TypeGraph) => boolean;
|
|
2810
|
+
isGeneric: (graph: TypeGraph) => boolean;
|
|
2811
|
+
isUnion: (graph: TypeGraph) => boolean;
|
|
2812
|
+
isIntersection: (graph: TypeGraph) => boolean;
|
|
2813
|
+
isObject: (graph: TypeGraph) => boolean;
|
|
2814
|
+
isArray: (graph: TypeGraph) => boolean;
|
|
2815
|
+
isFunction: (graph: TypeGraph) => boolean;
|
|
2816
|
+
isEnum: (graph: TypeGraph) => boolean;
|
|
2817
|
+
isOptional: (graph: TypeGraph) => boolean;
|
|
2818
|
+
isNullable: (graph: TypeGraph) => boolean;
|
|
2819
|
+
};
|
|
2820
|
+
|
|
2821
|
+
// #endregion ============================================
|
|
2822
|
+
// #region TYPE GRAPH TRANSFORMERS
|
|
2823
|
+
// ============================================
|
|
2824
|
+
|
|
2825
|
+
type TypeGraphTransformers = {
|
|
2826
|
+
// Traverse graph
|
|
2827
|
+
traverse: (
|
|
2828
|
+
graph: TypeGraph,
|
|
2829
|
+
visitor: (node: TypeGraph) => void
|
|
2830
|
+
) => void;
|
|
2831
|
+
|
|
2832
|
+
// Find nodes
|
|
2833
|
+
findNodes: (
|
|
2834
|
+
graph: TypeGraph,
|
|
2835
|
+
predicate: (node: TypeGraph) => boolean
|
|
2836
|
+
) => TypeGraph[];
|
|
2837
|
+
|
|
2838
|
+
// Transform nodes
|
|
2839
|
+
mapNodes: (
|
|
2840
|
+
graph: TypeGraph,
|
|
2841
|
+
mapper: (node: TypeGraph) => TypeGraph
|
|
2842
|
+
) => TypeGraph;
|
|
2843
|
+
|
|
2844
|
+
// Collect types
|
|
2845
|
+
collectTypes: (graph: TypeGraph) => Set<TypeFlags>;
|
|
2846
|
+
|
|
2847
|
+
// Resolve references
|
|
2848
|
+
resolveReferences: (
|
|
2849
|
+
graph: TypeGraph,
|
|
2850
|
+
context: Record<string, TypeGraph>
|
|
2851
|
+
) => TypeGraph;
|
|
2852
|
+
|
|
2853
|
+
// Validate
|
|
2854
|
+
validate: (
|
|
2855
|
+
graph: TypeGraph,
|
|
2856
|
+
value: any
|
|
2857
|
+
) => boolean;
|
|
2858
|
+
};
|
|
2859
|
+
|
|
2860
|
+
|
|
2861
|
+
// #endregion ============================================
|
|
2862
|
+
// #region EXAMPLE USAGE
|
|
2863
|
+
// ============================================
|
|
2864
|
+
|
|
2865
|
+
// Example: Build a type graph for a config
|
|
2866
|
+
|
|
2867
|
+
// #endregion ============================================
|
|
2868
|
+
// #region IncantationsConfigCreator
|
|
2869
|
+
type IncantationsConfigCreator = <
|
|
2870
|
+
S extends string = never,
|
|
2871
|
+
V extends Record<string, Record<string, any>> = Record<string, Record<string, any>>,
|
|
2872
|
+
T = unknown,
|
|
2873
|
+
I = unknown,
|
|
2874
|
+
E = unknown,
|
|
2875
|
+
C = unknown,
|
|
2876
|
+
SP = unknown,
|
|
2877
|
+
SO = unknown,
|
|
2878
|
+
CL = unknown,
|
|
2879
|
+
G = unknown
|
|
2880
|
+
>(
|
|
2881
|
+
config: IncantationsConfig<S, V, T, I, E, C, SP, SO, CL, G>
|
|
2882
|
+
) => IncantationsConfig<S, V, T, I, E, C, SP, SO, CL, G>;
|
|
2883
|
+
|
|
2884
|
+
// #endregion ============================================
|
|
2885
|
+
// #region AllIncantationTypes
|
|
2886
|
+
type AllIncantationTypes = {
|
|
2887
|
+
ClassInput: ClassInput;
|
|
2888
|
+
AnimationVariant: AnimationVariant;
|
|
2889
|
+
MotionVariant: MotionVariant;
|
|
2890
|
+
AsConfig: AsConfig;
|
|
2891
|
+
AsNode: AsNode;
|
|
2892
|
+
SlotRecord: SlotRecord;
|
|
2893
|
+
VariantSchema: VariantSchema;
|
|
2894
|
+
SlotVariantSchema: SlotVariantSchema;
|
|
2895
|
+
AnyVariantSchema: AnyVariantSchema;
|
|
2896
|
+
AnimationPresetMap: AnimationPresetMap;
|
|
2897
|
+
ExposedVariants: ExposedVariants;
|
|
2898
|
+
BaseProps: BaseProps;
|
|
2899
|
+
VariantGroup: VariantGroup;
|
|
2900
|
+
CompoundVariant: CompoundVariant;
|
|
2901
|
+
SlotCompoundVariant: SlotCompoundVariant;
|
|
2902
|
+
StateMachineConfig: StateMachineConfig;
|
|
2903
|
+
MachineState: MachineState;
|
|
2904
|
+
LogicMachine: LogicMachine;
|
|
2905
|
+
MachineRunner: MachineRunner;
|
|
2906
|
+
VaultSource: VaultSource;
|
|
2907
|
+
VaultEntry: VaultEntry;
|
|
2908
|
+
VaultConfig: VaultConfig;
|
|
2909
|
+
IncantationsFreyrContext: IncantationsFreyrContext;
|
|
2910
|
+
IncantationsFreyr: IncantationsFreyr;
|
|
2911
|
+
IncantationsLvl3: IncantationsLvl3;
|
|
2912
|
+
TypeFlags: TypeFlags;
|
|
2913
|
+
IncantationsConfig: IncantationsConfig;
|
|
2914
|
+
};
|
|
2915
|
+
|
|
2916
|
+
// #endregion ============================================
|
|
2917
|
+
|
|
2918
|
+
// #endregion ============================================
|
|
2919
|
+
// #region INFER INCANTATIONS CONFIG
|
|
2920
|
+
// ============================================
|
|
2921
|
+
|
|
2922
|
+
type InferIncantationsConfig = <
|
|
2923
|
+
Cfg extends {
|
|
2924
|
+
__S__?: any;
|
|
2925
|
+
__V__?: any;
|
|
2926
|
+
__T__?: any;
|
|
2927
|
+
__I__?: any;
|
|
2928
|
+
__E__?: any;
|
|
2929
|
+
__C__?: any;
|
|
2930
|
+
__SP__?: any;
|
|
2931
|
+
__SO__?: any;
|
|
2932
|
+
__CL__?: any;
|
|
2933
|
+
__G__?: any;
|
|
2934
|
+
}
|
|
2935
|
+
>(
|
|
2936
|
+
config: Cfg
|
|
2937
|
+
) => {
|
|
2938
|
+
S: Cfg["__S__"];
|
|
2939
|
+
V: Cfg["__V__"];
|
|
2940
|
+
T: Cfg["__T__"];
|
|
2941
|
+
I: Cfg["__I__"];
|
|
2942
|
+
E: Cfg["__E__"];
|
|
2943
|
+
C: Cfg["__C__"];
|
|
2944
|
+
SP: Cfg["__SP__"];
|
|
2945
|
+
SO: Cfg["__SO__"];
|
|
2946
|
+
CL: Cfg["__CL__"];
|
|
2947
|
+
G: Cfg["__G__"];
|
|
2948
|
+
Config: Cfg;
|
|
2949
|
+
};
|
|
2950
|
+
|
|
2951
|
+
// #endregion ============================================
|
|
2952
|
+
// #region VARIANT PROPS
|
|
2953
|
+
// ============================================
|
|
2954
|
+
|
|
2955
|
+
type VariantProps = {
|
|
2956
|
+
[key: string]: any;
|
|
2957
|
+
animation?: string;
|
|
2958
|
+
preset?: string;
|
|
2959
|
+
class?: any;
|
|
2960
|
+
className?: any;
|
|
2961
|
+
__instanceId__?: string;
|
|
2962
|
+
freyr?: FreyrConfig | ((props: any) => any);
|
|
2963
|
+
};
|
|
2964
|
+
|
|
2965
|
+
type FreyrConfig = {
|
|
2966
|
+
mode?: FreyrMode;
|
|
2967
|
+
theme?: FreyrTheme;
|
|
2968
|
+
version?: FreyrVersion;
|
|
2969
|
+
fonts?: FreyrFonts;
|
|
2970
|
+
presets?: FreyrPresets;
|
|
2971
|
+
};
|
|
2972
|
+
|
|
2973
|
+
|
|
2974
|
+
// #endregion ============================================
|
|
2975
|
+
// #region SLOTTED RESULT
|
|
2976
|
+
// ============================================
|
|
2977
|
+
|
|
2978
|
+
type SlottedResult<S extends string = string> = {
|
|
2979
|
+
[K in S]?: string;
|
|
2980
|
+
} & {
|
|
2981
|
+
className?: string;
|
|
2982
|
+
class?: string;
|
|
2983
|
+
[key: string]: any;
|
|
2984
|
+
};
|
|
2985
|
+
// #endregion ============================================
|
|
2986
|
+
// #region NAMESPACE AUGMENT
|
|
2987
|
+
// ============================================
|
|
2988
|
+
|
|
2989
|
+
type NamespaceAugment = any; // Define based on your implementation
|
|
2990
|
+
|
|
2991
|
+
// #endregion ============================================
|
|
2992
|
+
// #region INCANTATIONS RESULT
|
|
2993
|
+
// ============================================
|
|
2994
|
+
|
|
2995
|
+
// ============================================
|
|
2996
|
+
// INCANTATIONS RESULT - Complete Type
|
|
2997
|
+
// (ALL properties from IncantationsConfig + React additions)
|
|
2998
|
+
// ============================================
|
|
2999
|
+
|
|
3000
|
+
// ============================================
|
|
3001
|
+
// INCANTATIONS RESULT - Fixed with proper constraints
|
|
3002
|
+
// ============================================
|
|
3003
|
+
|
|
3004
|
+
type IncantationsResult<
|
|
3005
|
+
S extends string = never,
|
|
3006
|
+
V extends Record<string, Record<string, any>> = Record<string, Record<string, any>>,
|
|
3007
|
+
T = unknown,
|
|
3008
|
+
I = unknown,
|
|
3009
|
+
E = unknown,
|
|
3010
|
+
C = unknown,
|
|
3011
|
+
SP = unknown,
|
|
3012
|
+
SO = unknown,
|
|
3013
|
+
CL = unknown,
|
|
3014
|
+
G = unknown
|
|
3015
|
+
> = {
|
|
3016
|
+
// ── THE MAIN FUNCTION ────────────────────────────────────────────────────
|
|
3017
|
+
(props?: VariantProps & T & {
|
|
3018
|
+
animation?: keyof AnimationVariant | string;
|
|
3019
|
+
preset?: string;
|
|
3020
|
+
class?: any;
|
|
3021
|
+
className?: any;
|
|
3022
|
+
__instanceId__?: string;
|
|
3023
|
+
freyr?: FreyrConfig | ((props: any) => any);
|
|
3024
|
+
}): string;
|
|
3025
|
+
|
|
3026
|
+
// ── IDENTIFIERS ──────────────────────────────────────────────────────────
|
|
3027
|
+
__S__?: S;
|
|
3028
|
+
__V__?: V;
|
|
3029
|
+
__T__?: T;
|
|
3030
|
+
__I__?: I;
|
|
3031
|
+
__E__?: E;
|
|
3032
|
+
__C__?: C;
|
|
3033
|
+
__SP__?: SP;
|
|
3034
|
+
__SO__?: SO;
|
|
3035
|
+
__CL__?: CL;
|
|
3036
|
+
__G__?: G;
|
|
3037
|
+
|
|
3038
|
+
// ── TYPES ──────────────────────────────────────────────────────────────
|
|
3039
|
+
enums?: E;
|
|
3040
|
+
types?: T;
|
|
3041
|
+
interfaces?: I;
|
|
3042
|
+
generics?: G;
|
|
3043
|
+
|
|
3044
|
+
// ── STYLES ──────────────────────────────────────────────────────────────
|
|
3045
|
+
styles?: {
|
|
3046
|
+
base?: A;
|
|
3047
|
+
variants?: Record<string, Record<string, A>>;
|
|
3048
|
+
defaultVariants?: Record<string, string>;
|
|
3049
|
+
};
|
|
3050
|
+
slots?: Record<S, ClassInput>;
|
|
3051
|
+
base?: ClassInput;
|
|
3052
|
+
|
|
3053
|
+
// ── VARIANTS ──────────────────────────────────────────────────────────────
|
|
3054
|
+
variants?: V;
|
|
3055
|
+
compoundVariants?: S extends never ? CompoundVariant[] : SlotCompoundVariant[];
|
|
3056
|
+
defaultVariants?: { [K in keyof V]?: keyof V[K] };
|
|
3057
|
+
|
|
3058
|
+
// ── ANIMATIONS ──────────────────────────────────────────────────────────
|
|
3059
|
+
animation?: S extends never
|
|
3060
|
+
? AnimationVariant | AnimationPresetMap
|
|
3061
|
+
: Record<S, AnimationVariant> | undefined;
|
|
3062
|
+
transition?: S extends never
|
|
3063
|
+
? AnimationVariant | AnimationPresetMap
|
|
3064
|
+
: Record<S, AnimationVariant> | undefined;
|
|
3065
|
+
|
|
3066
|
+
// ── EXTEND & SYNC ──────────────────────────────────────────────────────
|
|
3067
|
+
extend?: string;
|
|
3068
|
+
cloud?: CL;
|
|
3069
|
+
sync?: string;
|
|
3070
|
+
master?: boolean;
|
|
3071
|
+
|
|
3072
|
+
// ── CONTEXT ──────────────────────────────────────────────────────────────
|
|
3073
|
+
context?: (props: any) => any;
|
|
3074
|
+
useContext?: any;
|
|
3075
|
+
createContext?: any;
|
|
3076
|
+
sauronContext?: any;
|
|
3077
|
+
reactContext?: any;
|
|
3078
|
+
_compiledReactContext?: any;
|
|
3079
|
+
|
|
3080
|
+
// ── STATE MACHINES ────────────────────────────────────────────────────
|
|
3081
|
+
stateMachine?: {
|
|
3082
|
+
[K in keyof V]?: StateMachineConfig;
|
|
3083
|
+
};
|
|
3084
|
+
logicMachine?: LogicMachine;
|
|
3085
|
+
__logicMachineRunner?: any;
|
|
3086
|
+
getLogicState?: () => Record<string, string>;
|
|
3087
|
+
__machineRunner?: MachineRunner | null;
|
|
3088
|
+
getMachineState?: () => Record<string, string>;
|
|
3089
|
+
variantMachine?: any;
|
|
3090
|
+
|
|
3091
|
+
// ── FREYR & GLOBAL ──────────────────────────────────────────────────────
|
|
3092
|
+
global?: () => G;
|
|
3093
|
+
freyrClasses?: string;
|
|
3094
|
+
freyrIncantations?: A;
|
|
3095
|
+
__globalContent?: Record<string, any>;
|
|
3096
|
+
__isGlobalized__?: boolean;
|
|
3097
|
+
freyr?: IncantationsFreyr | ((props: any) => any);
|
|
3098
|
+
classNames?: any;
|
|
3099
|
+
customTheme?: any;
|
|
3100
|
+
customCSS?: any;
|
|
3101
|
+
|
|
3102
|
+
// ── AS ──────────────────────────────────────────────────────────────────
|
|
3103
|
+
as?: AsConfig;
|
|
3104
|
+
asName?: string;
|
|
3105
|
+
|
|
3106
|
+
// ── SINGLES ──────────────────────────────────────────────────────────────
|
|
3107
|
+
aliases?: { [K in keyof V]?: Record<string, keyof V[K]> };
|
|
3108
|
+
|
|
3109
|
+
// ── CONSTANTS & SPECS ──────────────────────────────────────────────────
|
|
3110
|
+
constants?: C;
|
|
3111
|
+
specs?: SP;
|
|
3112
|
+
source?: SO;
|
|
3113
|
+
|
|
3114
|
+
// ── DOCUMENTATION ──────────────────────────────────────────────────────
|
|
3115
|
+
docs?: {
|
|
3116
|
+
[K in keyof V]?: {
|
|
3117
|
+
description?: string;
|
|
3118
|
+
values?: { [J in keyof V[keyof V]]?: string };
|
|
3119
|
+
};
|
|
3120
|
+
} & { description?: string };
|
|
3121
|
+
|
|
3122
|
+
// ── DEV TOOLS ──────────────────────────────────────────────────────────
|
|
3123
|
+
__location?: {
|
|
3124
|
+
file: string;
|
|
3125
|
+
line: number;
|
|
3126
|
+
column: number;
|
|
3127
|
+
functionName: string;
|
|
3128
|
+
};
|
|
3129
|
+
__definitionName?: string;
|
|
3130
|
+
__concentrationEnumGraph?: Record<string, TypeGraph>;
|
|
3131
|
+
__concentrationInterfaceGraph?: Record<string, TypeGraph>;
|
|
3132
|
+
__concentrationGenericGraph?: Record<string, TypeGraph>;
|
|
3133
|
+
__IncantationsTypeGraph?: Record<string, TypeGraph>;
|
|
3134
|
+
|
|
3135
|
+
// ── REACT CONTEXT (Added by wizard template) ──────────────────────────
|
|
3136
|
+
ReactContext: A;
|
|
3137
|
+
createReactContext: (props?: any) =>A;
|
|
3138
|
+
useReactContext: () => any;
|
|
3139
|
+
|
|
3140
|
+
// ── SUB-COMPONENT UTILITIES ─────────────────────────────────────────────
|
|
3141
|
+
extendResult: (
|
|
3142
|
+
overrides: Partial<IncantationsConfig<S, V, T, I, E, C, SP, SO, CL, G>>
|
|
3143
|
+
) => IncantationsResult<S, V, T, I, E, C, SP, SO, CL, G>;
|
|
3144
|
+
};
|
|
3145
|
+
// #endregion ============================================
|
|
3146
|
+
// #region INCANTATIONS RESULT CREATOR
|
|
3147
|
+
// ============================================
|
|
3148
|
+
|
|
3149
|
+
type IncantationsResultCreator = <
|
|
3150
|
+
S extends string = never,
|
|
3151
|
+
V extends AnyVariantSchema = any,
|
|
3152
|
+
T = unknown,
|
|
3153
|
+
I = unknown,
|
|
3154
|
+
C = unknown,
|
|
3155
|
+
SP = unknown,
|
|
3156
|
+
SO = unknown,
|
|
3157
|
+
CL = unknown,
|
|
3158
|
+
E = unknown,
|
|
3159
|
+
G = unknown
|
|
3160
|
+
>(
|
|
3161
|
+
config: ((
|
|
3162
|
+
props?: VariantProps & T & {
|
|
3163
|
+
animation?: keyof AnimationVariant | string;
|
|
3164
|
+
preset?: string;
|
|
3165
|
+
class?: any;
|
|
3166
|
+
className?: any;
|
|
3167
|
+
__instanceId__?: string;
|
|
3168
|
+
freyr?: FreyrConfig | ((props: any) => any);
|
|
3169
|
+
}
|
|
3170
|
+
) => string) & {
|
|
3171
|
+
// ── CORE HOOKS & PROCESSING ENGINE ──────────────────────────────────────
|
|
3172
|
+
slots: (
|
|
3173
|
+
props?: VariantProps & {
|
|
3174
|
+
preset?: string;
|
|
3175
|
+
class?: Partial<Record<S, ClassInput>>;
|
|
3176
|
+
className?: Partial<Record<S, ClassInput>>;
|
|
3177
|
+
__instanceId__?: string;
|
|
3178
|
+
freyr?: FreyrConfig | ((props: any) => any);
|
|
3179
|
+
}
|
|
3180
|
+
) => SlottedResult<S>;
|
|
3181
|
+
|
|
3182
|
+
// ── THE INLINE STYLES SYSTEM ───────────────────────────────────────────
|
|
3183
|
+
styles?: Record<string, any>;
|
|
3184
|
+
inlineStyles?: A;
|
|
3185
|
+
freyrClasses?: string;
|
|
3186
|
+
freyrIncantations?: A;
|
|
3187
|
+
classNames?: any;
|
|
3188
|
+
customTheme?: any;
|
|
3189
|
+
customCSS?: any;
|
|
3190
|
+
|
|
3191
|
+
// ── BLUEPRINT ECHOES (CONFIG TO RESULT COPIES) ───────────────────────────
|
|
3192
|
+
types: T;
|
|
3193
|
+
interface: I;
|
|
3194
|
+
enum: E;
|
|
3195
|
+
constants: C;
|
|
3196
|
+
specs: SP;
|
|
3197
|
+
source: SO;
|
|
3198
|
+
cloud: CL;
|
|
3199
|
+
as: AsConfig;
|
|
3200
|
+
variants: ExposedVariants;
|
|
3201
|
+
compoundVariants?: any[];
|
|
3202
|
+
defaultVariants?: Record<string, any>;
|
|
3203
|
+
aliases?: Record<string, string>;
|
|
3204
|
+
docs?: string;
|
|
3205
|
+
|
|
3206
|
+
// ── ADVANCED NESTED ENGINES ──────────────────────────────────────────────
|
|
3207
|
+
variantMachine?: Record<string, any>;
|
|
3208
|
+
transition?: {
|
|
3209
|
+
show?: Record<string, any>;
|
|
3210
|
+
hide?: Record<string, any>;
|
|
3211
|
+
[key: string]: any;
|
|
3212
|
+
};
|
|
3213
|
+
|
|
3214
|
+
// ── SYSTEM MIGRATION & REACTION THREADS ──────────────────────────────────
|
|
3215
|
+
sync?: string;
|
|
3216
|
+
master?: boolean;
|
|
3217
|
+
context: (props: any, __sauron_id__?: string) => I;
|
|
3218
|
+
createContext?: any;
|
|
3219
|
+
sauronContext?: any;
|
|
3220
|
+
global: NamespaceAugment;
|
|
3221
|
+
|
|
3222
|
+
// ── STATE ENGINE ACCESSORS (EXPOSED RUNTIMES) ────────────────────────────
|
|
3223
|
+
stateMachine?: Record<string, any>;
|
|
3224
|
+
logicMachine?: Record<string, any>;
|
|
3225
|
+
__machineRunner?: any;
|
|
3226
|
+
__logicMachineRunner?: any;
|
|
3227
|
+
getMachineState?: () => Record<string, any>;
|
|
3228
|
+
getLogicState?: () => Record<string, any>;
|
|
3229
|
+
useMachine?: (props?: any) => {
|
|
3230
|
+
state: Record<string, any>;
|
|
3231
|
+
setState: (key: string, value: any) => void;
|
|
3232
|
+
} & Record<string, (value: any) => void>;
|
|
3233
|
+
|
|
3234
|
+
// ── GLOBALIZATION & COMPILER PROFILES ────────────────────────────────────
|
|
3235
|
+
__globalContent?: any;
|
|
3236
|
+
__isGlobalized__?: boolean;
|
|
3237
|
+
__location: string;
|
|
3238
|
+
__definitionName: string;
|
|
3239
|
+
|
|
3240
|
+
// ── SUB-COMPONENT UTILITIES ─────────────────────────────────────────────
|
|
3241
|
+
extend: (
|
|
3242
|
+
overrides: Partial<IncantationsConfig<S, V, T, I, E, C, SP, SO, CL, G>>
|
|
3243
|
+
) => IncantationsResult<S, V, T, I, C, SP, SO, CL, E, G>;
|
|
3244
|
+
}
|
|
3245
|
+
) => IncantationsResult<S, V, T, I, C, SP, SO, CL, E, G>;
|
|
3246
|
+
|
|
3247
|
+
|
|
3248
|
+
// #endregion ============================================
|
|
3249
|
+
|
|
3250
|
+
|
|
3251
|
+
|
|
3252
|
+
|
|
3253
|
+
|
|
3254
|
+
|
|
3255
|
+
|
|
3256
|
+
|
|
3257
|
+
|
|
3258
|
+
|
|
3259
|
+
|
|
3260
|
+
|
|
3261
|
+
|
|
3262
|
+
|
|
3263
|
+
|
|
3264
|
+
|
|
3265
|
+
|
|
3266
|
+
|
|
3267
|
+
}
|