@app-compose/core 3.0.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,581 @@
1
+ //#region src/runnable/definition.ts
2
+ const Context$ = Symbol("$context");
3
+ const Execute$ = Symbol("$execute");
4
+ const Dispatch$ = Symbol("$dispatch");
5
+ //#endregion
6
+ //#region src/computable/definition.ts
7
+ const Spot$ = Symbol("$spot");
8
+ const Read$ = Symbol("$read");
9
+ const Build$ = Symbol("$build");
10
+ const Literal$ = Symbol("$literal");
11
+ const Compute$ = Symbol("$compute");
12
+ const Missing$ = Symbol("$missing");
13
+ const Optional$ = Symbol("$optional");
14
+ //#endregion
15
+ //#region src/computable/build.ts
16
+ /**
17
+ * Creates a build context from a shape
18
+ *
19
+ * @internal
20
+ */
21
+ const build = (context) => {
22
+ return {
23
+ [Spot$]: true,
24
+ [Build$]: context,
25
+ [Compute$]: [],
26
+ [Optional$]: false
27
+ };
28
+ };
29
+ //#endregion
30
+ //#region src/shared.ts
31
+ const LIBRARY_NAME = "[app-compose]";
32
+ const isObject = (x) => Object.prototype.toString.call(x) === "[object Object]";
33
+ const identity = (x) => x;
34
+ const T = () => true;
35
+ //#endregion
36
+ //#region src/computable/computer.ts
37
+ const createComputer = (registry) => {
38
+ const context = (value) => {
39
+ if (isObject(value)) if (Spot$ in value) return compute(value);
40
+ else {
41
+ let out = {};
42
+ for (const key of Object.keys(value)) if ((out[key] = context(value[key])) === Missing$) return Missing$;
43
+ return out;
44
+ }
45
+ else if (Array.isArray(value)) {
46
+ const out = Array.from({ length: value.length });
47
+ for (let i = 0; i < value.length; i++) if ((out[i] = context(value[i])) === Missing$) return Missing$;
48
+ return out;
49
+ } else throw new Error(`${LIBRARY_NAME} Literal value found in context: ${String(value)}.`);
50
+ };
51
+ /**
52
+ * `compute` - resolve a `Spot` to its final value.
53
+ *
54
+ * Resolves the spot's underlying value (`Build$`, `Literal$`, or `Read$`),
55
+ * then applies all `Compute$` transformations in order.
56
+ *
57
+ * `Missing$` flow is three-step `read -> compute -> optional`
58
+ *
59
+ * 1. Read `source` value (either literal, built, or from registry) as-is
60
+ * 2. Map the `source` value through the `Compute$` pipeline, preserving `Missing$` and delegating to internal-land
61
+ * 3. Guard `Missing$` according to `Optional$`, coercing to `undefined` if optional, or propagating as-is if not
62
+ *
63
+ * @param spot The `Spot` to evaluate
64
+ * @returns The resolved value, or `Missing$` when non-optional spot resolution fails
65
+ */
66
+ const compute = (spot) => {
67
+ let resolved;
68
+ if (Build$ in spot) resolved = context(spot[Build$]);
69
+ else if (Literal$ in spot) resolved = spot[Literal$];
70
+ else if (Read$ in spot) resolved = registry.has(spot[Read$]) ? registry.get(spot[Read$]) : Missing$;
71
+ else throw new Error(`${LIBRARY_NAME} Invalid Unit.`);
72
+ for (const step of spot[Compute$]) resolved = step(resolved);
73
+ if (resolved === Missing$ && spot[Optional$]) return void 0;
74
+ else return resolved;
75
+ };
76
+ const computeSafe = (spot) => {
77
+ const result = compute(spot);
78
+ return result === Missing$ ? void 0 : result;
79
+ };
80
+ return {
81
+ compute,
82
+ computeSafe
83
+ };
84
+ };
85
+ //#endregion
86
+ //#region src/computable/literal.ts
87
+ const literal = (value) => {
88
+ return {
89
+ [Spot$]: true,
90
+ [Literal$]: value,
91
+ [Compute$]: [],
92
+ [Optional$]: false
93
+ };
94
+ };
95
+ //#endregion
96
+ //#region src/computable/lens.ts
97
+ const Self$ = Symbol();
98
+ const raise = () => {
99
+ throw new Error(`${LIBRARY_NAME} Modifying a Reference is not allowed.`);
100
+ };
101
+ const reader = (property) => (value) => value === Missing$ ? Missing$ : value?.[property];
102
+ const get = (target, property, recv) => typeof property === "string" ? proxy({
103
+ ...target,
104
+ [Compute$]: target[Compute$].concat(reader(property))
105
+ }) : property === Self$ ? target : Reflect.get(target, property, recv);
106
+ const set = () => raise();
107
+ const proxy = (ref) => new Proxy(ref, {
108
+ get,
109
+ set
110
+ });
111
+ proxy.self = (lensable) => lensable[Self$] ?? lensable;
112
+ //#endregion
113
+ //#region src/computable/optional.ts
114
+ /**
115
+ * Mark a `Spot` as optional.
116
+ */
117
+ const optional = (spot) => {
118
+ return {
119
+ ...proxy.self(spot),
120
+ [Optional$]: true
121
+ };
122
+ };
123
+ //#endregion
124
+ //#region src/computable/reference.ts
125
+ const reference = (id) => {
126
+ return {
127
+ [Spot$]: true,
128
+ [Read$]: id,
129
+ [Compute$]: [],
130
+ [Optional$]: false
131
+ };
132
+ };
133
+ reference.lensed = (id) => {
134
+ return proxy({
135
+ [Spot$]: true,
136
+ [Read$]: id,
137
+ [Compute$]: [],
138
+ [Optional$]: false
139
+ });
140
+ };
141
+ //#endregion
142
+ //#region src/computable/shape.ts
143
+ const safe = (fn) => (value) => {
144
+ try {
145
+ return value === Missing$ ? Missing$ : fn(value);
146
+ } catch {
147
+ return Missing$;
148
+ }
149
+ };
150
+ function shape(ctxOrSpot, fn) {
151
+ const spot = build(ctxOrSpot);
152
+ if (fn) spot[Compute$].push(safe(fn));
153
+ return spot;
154
+ }
155
+ //#endregion
156
+ //#region src/runnable/task.ts
157
+ const dispatch = {
158
+ result: (result) => result.status === "done" ? result.value : Missing$,
159
+ status: (result) => result.status,
160
+ error: (result) => result.status === "fail" ? result.error : Missing$
161
+ };
162
+ const createTask = (config) => {
163
+ const id = {
164
+ result: Symbol(`Task[${config.name}]::result`),
165
+ status: Symbol(`Task[${config.name}]::status`),
166
+ error: Symbol(`Task[${config.name}]::error`)
167
+ };
168
+ const context = {
169
+ run: config.run.context ?? literal(void 0),
170
+ enabled: config.enabled?.context ?? literal(void 0)
171
+ };
172
+ return {
173
+ name: config.name,
174
+ kind: "task",
175
+ result: reference.lensed(id.result),
176
+ status: reference(id.status),
177
+ error: reference(id.error),
178
+ [Context$]: build(context),
179
+ [Execute$]: async (built) => {
180
+ const ctx = built;
181
+ if (ctx === Missing$) return { status: "skip" };
182
+ try {
183
+ if (!await (config.enabled?.fn ?? T)(ctx.enabled)) return { status: "skip" };
184
+ } catch (error) {
185
+ return {
186
+ status: "fail",
187
+ error
188
+ };
189
+ }
190
+ try {
191
+ return {
192
+ status: "done",
193
+ value: await config.run.fn(ctx.run)
194
+ };
195
+ } catch (error) {
196
+ return {
197
+ status: "fail",
198
+ error
199
+ };
200
+ }
201
+ },
202
+ [Dispatch$]: {
203
+ [id.result]: dispatch.result,
204
+ [id.status]: dispatch.status,
205
+ [id.error]: dispatch.error
206
+ }
207
+ };
208
+ };
209
+ //#endregion
210
+ //#region src/is.ts
211
+ const is = {
212
+ tag: (x) => isObject(x) && Tag$ in x,
213
+ runnable: (x) => isObject(x) && Execute$ in x,
214
+ task: (x) => is.runnable(x) && x.kind === "task",
215
+ wire: (x) => is.runnable(x) && x.kind === "wire"
216
+ };
217
+ //#endregion
218
+ //#region src/runnable/wire.ts
219
+ const Tag$ = Symbol("$tag");
220
+ const tag = (name) => {
221
+ const id = Symbol(`Tag[${name}]`);
222
+ return {
223
+ [Tag$]: id,
224
+ name,
225
+ value: reference.lensed(id)
226
+ };
227
+ };
228
+ const pluck = (path) => (value) => path.reduce((acc, key) => acc?.[key], value);
229
+ function* walk(shape, path = []) {
230
+ if (is.tag(shape)) yield {
231
+ tag: shape,
232
+ fn: pluck(path)
233
+ };
234
+ else if (Array.isArray(shape)) for (let index = 0; index < shape.length; index++) yield* walk(shape[index], [...path, index]);
235
+ else if (isObject(shape)) for (const key of Object.keys(shape)) yield* walk(shape[key], [...path, key]);
236
+ else throw new Error(`${LIBRARY_NAME} Invalid shape ${String(shape)} provided to Wire at path "${path.join(".")}".`);
237
+ }
238
+ const createWire = (config) => {
239
+ const tags = /* @__PURE__ */ new Set();
240
+ const dispatch = {};
241
+ for (const entry of walk(config.to)) if (tags.has(entry.tag)) throw new Error(`${LIBRARY_NAME} Duplicate tag "${entry.tag.name}" found in Wire destination.`);
242
+ else tags.add(entry.tag), dispatch[entry.tag[Tag$]] = entry.fn;
243
+ return {
244
+ name: Array.from(tags).map((tag) => tag.name).join(" + "),
245
+ kind: "wire",
246
+ [Context$]: build(config.from),
247
+ [Execute$]: identity,
248
+ [Dispatch$]: dispatch
249
+ };
250
+ };
251
+ //#endregion
252
+ //#region src/compose/resolver.ts
253
+ function* scanShape(shape) {
254
+ if (isObject(shape)) if (Spot$ in shape) yield* scanSpot(shape);
255
+ else for (const key of Object.keys(shape)) yield* scanShape(shape[key]);
256
+ else if (Array.isArray(shape)) for (const item of shape) yield* scanShape(item);
257
+ else throw new Error(`${LIBRARY_NAME} Literal value found in context: ${String(shape)}.`);
258
+ }
259
+ function* scanSpot(spot) {
260
+ if (Literal$ in spot) return;
261
+ else if (Read$ in spot) return yield {
262
+ id: spot[Read$],
263
+ optional: spot[Optional$]
264
+ };
265
+ else if (Build$ in spot) for (const entry of scanShape(spot[Build$])) yield {
266
+ id: entry.id,
267
+ optional: entry.optional || spot[Optional$]
268
+ };
269
+ else throw new Error(`${LIBRARY_NAME} Invalid Unit.`);
270
+ }
271
+ function resolve(spot) {
272
+ const required = /* @__PURE__ */ new Set();
273
+ const optional = /* @__PURE__ */ new Set();
274
+ for (const entry of scanSpot(spot)) if (entry.optional) optional.add(entry.id);
275
+ else required.add(entry.id);
276
+ return {
277
+ required,
278
+ optional
279
+ };
280
+ }
281
+ //#endregion
282
+ //#region src/compose/analyze.ts
283
+ const analyze = (runnable) => {
284
+ const internal = runnable;
285
+ const writes = Object.getOwnPropertySymbols(internal[Dispatch$]);
286
+ const dependencies = resolve(internal[Context$]);
287
+ return {
288
+ type: internal.kind,
289
+ display: { name: internal.name },
290
+ writes,
291
+ dependencies
292
+ };
293
+ };
294
+ const createAnalyzer = () => {
295
+ const cache = /* @__PURE__ */ new WeakMap();
296
+ const get = (runnable) => {
297
+ const analysis = cache.get(runnable) ?? analyze(runnable);
298
+ return cache.set(runnable, analysis), analysis;
299
+ };
300
+ return { get };
301
+ };
302
+ //#endregion
303
+ //#region src/compose/graph.ts
304
+ const graph = (root) => {
305
+ let entryID = 0;
306
+ const symbolToID = /* @__PURE__ */ new Map();
307
+ const analyzer = createAnalyzer();
308
+ const toEntry = (runnable) => {
309
+ const { type, display, writes, dependencies } = analyzer.get(runnable);
310
+ writes.forEach((x) => symbolToID.set(x, entryID));
311
+ return {
312
+ type: "run",
313
+ meta: {
314
+ name: display.name,
315
+ kind: type
316
+ },
317
+ id: entryID++,
318
+ dependencies: {
319
+ required: Array.from(dependencies.required, (x) => symbolToID.get(x) ?? -1),
320
+ optional: Array.from(dependencies.optional, (x) => symbolToID.get(x)).filter((x) => x !== void 0)
321
+ }
322
+ };
323
+ };
324
+ const traverse = (node) => {
325
+ switch (node.type) {
326
+ case "con":
327
+ case "seq": return {
328
+ type: node.type,
329
+ meta: { name: node.meta?.name },
330
+ children: node.children.map(traverse)
331
+ };
332
+ case "run": return toEntry(node.value);
333
+ }
334
+ };
335
+ return traverse(root);
336
+ };
337
+ //#endregion
338
+ //#region src/compose/guard.ts
339
+ const UNKNOWN_NAME = "<unknown>";
340
+ const TypeMap = {
341
+ task: "Task",
342
+ wire: "Wire"
343
+ };
344
+ const metaOf = (node, key) => "meta" in node && node.meta?.[key] ? node.meta[key] : void 0;
345
+ const stackToName = (stack) => stack.map(({ node, index }) => {
346
+ const name = metaOf(node, "name");
347
+ if (index !== void 0) return name ? `#${index + 1} (${name})` : `#${index + 1}`;
348
+ else return name ?? "root";
349
+ }).join(" > ");
350
+ const createNotify = (handler) => ({
351
+ duplicate: ({ type, name, stack }) => {
352
+ const message = `A duplicate ${TypeMap[type]} found with name ${TypeMap[type]}[${name}] in step ${stackToName(stack)}.`;
353
+ handler.error(message);
354
+ },
355
+ notSatisfied: ({ type, name, stack, missing: set }) => {
356
+ const list = Array.from(set, (id) => id.description ?? UNKNOWN_NAME).join(", ");
357
+ const message = `Unsatisfied dependencies found for ${TypeMap[type]} with name ${TypeMap[type]}[${name}] in step ${stackToName(stack)}: missing ${list}.`;
358
+ handler.error(message);
359
+ },
360
+ unused: ({ type, name, stack, id }) => {
361
+ const target = `${TypeMap[type]}[${name}] for ${id.description ?? UNKNOWN_NAME}`;
362
+ const message = `Unused ${TypeMap[type]} found with name ${target} in step ${stackToName(stack)}.`;
363
+ handler.warn(message);
364
+ }
365
+ });
366
+ const createGuard = ({ handler }) => {
367
+ const notify = createNotify(handler);
368
+ const analyzer = createAnalyzer();
369
+ const duplicate = (root) => {
370
+ const seen = /* @__PURE__ */ new Set();
371
+ const traverse = (stack) => {
372
+ const { node: current } = stack.at(-1);
373
+ if (current.type === "con" || current.type === "seq") return current.children.forEach((node, index) => traverse([...stack, {
374
+ node,
375
+ index
376
+ }]));
377
+ if (current.type === "run") {
378
+ const { type, display, writes } = analyzer.get(current.value);
379
+ if (writes.some((write) => seen.has(write))) notify.duplicate({
380
+ type,
381
+ name: display.name,
382
+ stack
383
+ });
384
+ writes.forEach((w) => seen.add(w));
385
+ }
386
+ };
387
+ traverse([{ node: root }]);
388
+ };
389
+ const unused = (root) => {
390
+ const candidates = /* @__PURE__ */ new Map();
391
+ const traverse = (stack) => {
392
+ const { node: current } = stack.at(-1);
393
+ if (current.type === "con" || current.type === "seq") return current.children.forEach((node, index) => traverse([...stack, {
394
+ node,
395
+ index
396
+ }]));
397
+ if (current.type === "run") {
398
+ const { type, display, writes, dependencies } = analyzer.get(current.value);
399
+ if (type === "wire") writes.forEach((id) => candidates.set(id, {
400
+ id,
401
+ type,
402
+ name: display.name,
403
+ stack
404
+ }));
405
+ dependencies.required.forEach((id) => candidates.delete(id));
406
+ dependencies.optional.forEach((id) => candidates.delete(id));
407
+ }
408
+ };
409
+ traverse([{ node: root }]);
410
+ for (const context of candidates.values()) notify.unused(context);
411
+ };
412
+ const unsatisfied = (root) => {
413
+ const traverse = (stack, available) => {
414
+ const { node: current } = stack.at(-1);
415
+ switch (current.type) {
416
+ case "run":
417
+ const { type, display, writes, dependencies } = analyzer.get(current.value);
418
+ const missing = /* @__PURE__ */ new Set();
419
+ for (const id of dependencies.required) if (!available.has(id)) missing.add(id);
420
+ if (missing.size > 0) notify.notSatisfied({
421
+ type,
422
+ name: display.name,
423
+ stack,
424
+ missing
425
+ });
426
+ return new Set(writes);
427
+ case "con": {
428
+ const wrote = /* @__PURE__ */ new Set();
429
+ for (const [index, node] of current.children.entries()) traverse([...stack, {
430
+ node,
431
+ index
432
+ }], available).forEach((item) => wrote.add(item));
433
+ return wrote;
434
+ }
435
+ case "seq": {
436
+ const wrote = /* @__PURE__ */ new Set(), local = new Set(available);
437
+ for (const [index, node] of current.children.entries()) traverse([...stack, {
438
+ node,
439
+ index
440
+ }], local).forEach((item) => (wrote.add(item), local.add(item)));
441
+ return wrote;
442
+ }
443
+ }
444
+ };
445
+ traverse([{ node: root }], /* @__PURE__ */ new Set());
446
+ };
447
+ return (root) => (duplicate(root), unsatisfied(root), unused(root));
448
+ };
449
+ //#endregion
450
+ //#region src/compose/observer.ts
451
+ const eventToUserland = { onTaskFail: (event) => {
452
+ const runnable = event.runnable;
453
+ const result = event.value;
454
+ if (runnable.kind === "task" && result.status === "fail") return {
455
+ task: runnable,
456
+ error: result.error
457
+ };
458
+ else return null;
459
+ } };
460
+ const observe = (event) => {
461
+ let userland;
462
+ const current = event.stack.at(-1);
463
+ switch (event.type) {
464
+ case "node:start":
465
+ if ("meta" in current) current.meta?.hooks?.onStart?.({ meta: current.meta });
466
+ break;
467
+ case "node:complete":
468
+ if ("meta" in current) current.meta?.hooks?.onComplete?.({ meta: current.meta });
469
+ break;
470
+ case "execute:complete":
471
+ if (userland = eventToUserland.onTaskFail(event)) {
472
+ for (const node of event.stack) if ("meta" in node) node.meta?.hooks?.onTaskFail?.(userland);
473
+ }
474
+ break;
475
+ }
476
+ };
477
+ //#endregion
478
+ //#region src/compose/runner.ts
479
+ const execute = (ctx, runnable) => Promise.resolve().then(() => ctx.computer.compute(runnable[Context$])).then((value) => runnable[Execute$](value)).then((value) => {
480
+ for (const key of Object.getOwnPropertySymbols(runnable[Dispatch$])) ctx.registry.set(key, runnable[Dispatch$][key](value));
481
+ return value;
482
+ });
483
+ const traverse = async (ctx, stack) => {
484
+ const current = stack.at(-1);
485
+ observe({
486
+ type: "node:start",
487
+ stack
488
+ });
489
+ switch (current.type) {
490
+ case "seq":
491
+ for (const child of current.children) await traverse(ctx, [...stack, child]);
492
+ break;
493
+ case "con":
494
+ await Promise.all(current.children.map((child) => traverse(ctx, [...stack, child])));
495
+ break;
496
+ case "run":
497
+ const runnable = current.value;
498
+ await execute(ctx, runnable).then((value) => observe({
499
+ type: "execute:complete",
500
+ stack,
501
+ runnable,
502
+ value
503
+ }));
504
+ break;
505
+ }
506
+ observe({
507
+ type: "node:complete",
508
+ stack
509
+ });
510
+ };
511
+ const run = async (node) => {
512
+ const registry = /* @__PURE__ */ new Map();
513
+ const computer = createComputer(registry);
514
+ await traverse({
515
+ computer,
516
+ registry
517
+ }, [node]);
518
+ return { get: (spot) => computer.computeSafe(spot) };
519
+ };
520
+ //#endregion
521
+ //#region src/compose/compose.ts
522
+ const Node$ = Symbol("$node");
523
+ const normalize = (arg) => {
524
+ if (Node$ in arg) return arg[Node$];
525
+ else if (Execute$ in arg) return {
526
+ type: "run",
527
+ value: arg
528
+ };
529
+ else throw new Error(`${LIBRARY_NAME} Invalid argument passed to step.`);
530
+ };
531
+ const raiseOnGuard = (message) => {
532
+ throw new Error(message);
533
+ };
534
+ const builder = (node) => {
535
+ return {
536
+ [Node$]: node,
537
+ meta: (meta) => builder({
538
+ ...node,
539
+ meta: {
540
+ ...node.meta,
541
+ ...meta
542
+ }
543
+ }),
544
+ step: (arg) => {
545
+ if (Array.isArray(arg)) return builder({
546
+ ...node,
547
+ children: [...node.children, {
548
+ type: "con",
549
+ children: arg.map(normalize)
550
+ }]
551
+ });
552
+ else return builder({
553
+ ...node,
554
+ children: [...node.children, normalize(arg)]
555
+ });
556
+ },
557
+ run: () => {
558
+ return createGuard({ handler: {
559
+ warn: console.warn.bind(console, LIBRARY_NAME),
560
+ error: raiseOnGuard
561
+ } })(node), run(node);
562
+ },
563
+ guard: () => {
564
+ return createGuard({ handler: {
565
+ warn: raiseOnGuard,
566
+ error: raiseOnGuard
567
+ } })(node);
568
+ },
569
+ graph: () => graph(node)
570
+ };
571
+ };
572
+ const compose = () => {
573
+ return builder({
574
+ type: "seq",
575
+ children: []
576
+ });
577
+ };
578
+ //#endregion
579
+ export { compose, createTask, createWire, is, literal, optional, shape, tag };
580
+
581
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/runnable/definition.ts","../src/computable/definition.ts","../src/computable/build.ts","../src/shared.ts","../src/computable/computer.ts","../src/computable/literal.ts","../src/computable/lens.ts","../src/computable/optional.ts","../src/computable/reference.ts","../src/computable/shape.ts","../src/runnable/task.ts","../src/is.ts","../src/runnable/wire.ts","../src/compose/resolver.ts","../src/compose/analyze.ts","../src/compose/graph.ts","../src/compose/guard.ts","../src/compose/observer.ts","../src/compose/runner.ts","../src/compose/compose.ts"],"sourcesContent":["import type { SpotInternal } from \"@computable\"\nimport type { Eventual } from \"@shared\"\n\nconst Context$ = Symbol(\"$context\")\nconst Execute$ = Symbol(\"$execute\")\nconst Dispatch$ = Symbol(\"$dispatch\")\n\ntype Runnable = { [Execute$]: unknown }\ntype RunnableKind<T extends string> = { readonly kind: T }\n\ntype RunnableInternal<T = unknown> = {\n [Context$]: SpotInternal<unknown>\n [Execute$]: (ctx: unknown) => Eventual<T>\n [Dispatch$]: Record<symbol, (value: T) => unknown>\n}\n\nexport { Context$, Dispatch$, Execute$ }\nexport type { Runnable, RunnableInternal, RunnableKind }\n","const Spot$ = Symbol(\"$spot\")\nconst Phantom$ = Symbol(\"$T\")\n\nconst Read$ = Symbol(\"$read\")\nconst Build$ = Symbol(\"$build\")\nconst Literal$ = Symbol(\"$literal\")\n\nconst Compute$ = Symbol(\"$compute\")\n\nconst Missing$ = Symbol(\"$missing\")\nconst Optional$ = Symbol(\"$optional\")\n\ntype Spot<T> = { [Spot$]: true; [Phantom$]?: T }\ntype SpotValue<T extends Spot<any>> = T extends Spot<infer V> ? V : never\n\ntype ComputeStep = (source: unknown) => unknown\n\ntype Compute = { [Compute$]: ComputeStep[] }\ntype Optional = { [Optional$]: boolean }\n\n// Spot Flavors\ntype Literal = { [Literal$]: unknown }\ntype Build = { [Build$]: unknown }\ntype Read = { [Read$]: symbol }\n\ntype SpotInternal<T = unknown> = (Literal | Read | Build) & Compute & Optional & Spot<T>\n\nexport { Build$, Compute$, Literal$, Missing$, Optional$, Read$, Spot$ }\nexport type { ComputeStep, Spot, SpotInternal, SpotValue }\n","import { Build$, Compute$, Optional$, Spot$, type SpotInternal } from \"./definition\"\n\n/**\n * Creates a build context from a shape\n *\n * @internal\n */\nconst build = <T = unknown>(context: unknown): SpotInternal<T> => {\n return { [Spot$]: true, [Build$]: context, [Compute$]: [], [Optional$]: false }\n}\n\nexport { build }\n","type AnyShape = Record<string, unknown>\ntype Eventual<T> = Promise<T> | T\n\ntype BuiltInObject =\n | null\n | undefined\n | boolean\n | string\n | number\n | Error\n | Date\n | RegExp\n | Int8Array\n | Uint8Array\n | Uint8ClampedArray\n | Int16Array\n | Uint16Array\n | Int32Array\n | Uint32Array\n | Float32Array\n | Float64Array\n | ReadonlyMap<unknown, unknown>\n | ReadonlySet<unknown>\n | WeakMap<object, unknown>\n | WeakSet<object>\n | ArrayBuffer\n | DataView\n | Function\n | Promise<unknown>\n | Generator\n | { readonly [Symbol.toStringTag]: string }\n\nconst LIBRARY_NAME = \"[app-compose]\"\n\nconst isObject = (x: unknown): x is object => Object.prototype.toString.call(x) === \"[object Object]\"\n\nconst identity = <T>(x: T): T => x\nconst T = (): true => true\n\nexport { LIBRARY_NAME, T, identity, isObject }\nexport type { AnyShape, BuiltInObject, Eventual }\n","import { isObject, LIBRARY_NAME } from \"@shared\"\nimport { Build$, Compute$, Literal$, Missing$, Optional$, Read$, Spot$, type SpotInternal } from \"./definition\"\n\ntype Computer = {\n compute: <T = unknown>(spot: SpotInternal<T>) => T | typeof Missing$\n computeSafe: <T = unknown>(spot: SpotInternal<T>) => T | undefined\n}\n\nconst createComputer = (registry: Map<symbol, unknown>): Computer => {\n const context = (value: unknown): unknown | typeof Missing$ => {\n if (isObject(value))\n if (Spot$ in value) return compute(value as SpotInternal)\n else {\n let out: Record<string, unknown> = {}\n\n for (const key of Object.keys(value))\n if ((out[key] = context(value[key as keyof typeof value])) === Missing$) return Missing$\n\n return out\n }\n else if (Array.isArray(value)) {\n const out: unknown[] = Array.from({ length: value.length })\n\n for (let i = 0; i < value.length; i++) if ((out[i] = context(value[i])) === Missing$) return Missing$\n\n return out\n } else throw new Error(`${LIBRARY_NAME} Literal value found in context: ${String(value)}.`)\n }\n\n /**\n * `compute` - resolve a `Spot` to its final value.\n *\n * Resolves the spot's underlying value (`Build$`, `Literal$`, or `Read$`),\n * then applies all `Compute$` transformations in order.\n *\n * `Missing$` flow is three-step `read -> compute -> optional`\n *\n * 1. Read `source` value (either literal, built, or from registry) as-is\n * 2. Map the `source` value through the `Compute$` pipeline, preserving `Missing$` and delegating to internal-land\n * 3. Guard `Missing$` according to `Optional$`, coercing to `undefined` if optional, or propagating as-is if not\n *\n * @param spot The `Spot` to evaluate\n * @returns The resolved value, or `Missing$` when non-optional spot resolution fails\n */\n const compute = <T = unknown>(spot: SpotInternal<T>): T | typeof Missing$ => {\n let resolved: unknown\n\n if (Build$ in spot) resolved = context(spot[Build$])\n else if (Literal$ in spot) resolved = spot[Literal$]\n else if (Read$ in spot) resolved = registry.has(spot[Read$]) ? registry.get(spot[Read$]) : Missing$\n else throw /* unknown unit */ new Error(`${LIBRARY_NAME} Invalid Unit.`)\n\n for (const step of spot[Compute$]) resolved = step(resolved)\n\n if (resolved === Missing$ && spot[Optional$]) return undefined as T\n else return resolved as T\n }\n\n const computeSafe = <T = unknown>(spot: SpotInternal<T>): T | undefined => {\n const result = compute(spot)\n return result === Missing$ ? undefined : result\n }\n\n return { compute, computeSafe }\n}\n\nexport { createComputer, type Computer }\n","import { type Spot, type SpotInternal, Compute$, Literal$, Optional$, Spot$ } from \"./definition\"\n\nconst literal = <const T>(value: T): Spot<T> => {\n const spot: SpotInternal<T> = { [Spot$]: true, [Literal$]: value, [Compute$]: [], [Optional$]: false }\n\n return spot\n}\n\nexport { literal }\n","import { LIBRARY_NAME } from \"@shared\"\nimport { Compute$, Missing$, type SpotInternal } from \"./definition\"\n\nconst Self$ = Symbol(/* internal */)\n\nconst raise = () => {\n throw new Error(`${LIBRARY_NAME} Modifying a Reference is not allowed.`)\n}\n\nconst reader = (property: string) => (value: any) => (value === Missing$ ? Missing$ : value?.[property])\n\nconst get: ProxyHandler<SpotInternal>[\"get\"] = (target, property, recv) =>\n typeof property === \"string\"\n ? proxy({ ...target, [Compute$]: target[Compute$].concat(reader(property)) })\n : property === Self$\n ? target\n : Reflect.get(target, property, recv)\n\nconst set: ProxyHandler<SpotInternal>[\"set\"] = () => raise()\n\nexport const proxy = <T extends SpotInternal>(ref: T): T => new Proxy<T>(ref, { get, set })\n\nproxy.self = <T extends SpotInternal>(lensable: T): T => (lensable as any)[Self$] ?? lensable\n","import { Optional$, type Spot, type SpotInternal } from \"./definition\"\nimport { proxy } from \"./lens\"\n\n/**\n * Mark a `Spot` as optional.\n */\nconst optional = <T>(spot: Spot<T>): Spot<T | undefined> => {\n const self = proxy.self(spot as SpotInternal<T>)\n const updated: SpotInternal<T | undefined> = { ...self, [Optional$]: true }\n\n return updated\n}\n\nexport { optional }\n","import type { AnyShape } from \"@shared\"\nimport { Compute$, Optional$, Read$, Spot$, type Spot, type SpotInternal } from \"./definition\"\nimport { proxy } from \"./lens\"\n\ntype SpotProvider<T> = [T] extends [AnyShape] ? { readonly [Key in keyof T]: SpotProvider<T[Key]> } & Spot<T> : Spot<T>\n\nconst reference = <T>(id: symbol): Spot<T> => {\n const spot: SpotInternal<T> = { [Spot$]: true, [Read$]: id, [Compute$]: [], [Optional$]: false }\n\n return spot\n}\n\nreference.lensed = <T>(id: symbol): SpotProvider<T> => {\n const spot: SpotInternal<T> = { [Spot$]: true, [Read$]: id, [Compute$]: [], [Optional$]: false }\n\n return proxy(spot) as SpotProvider<T>\n}\n\nexport { reference, type SpotProvider }\n","import type { ContextToSpot } from \"./context\"\nimport { build } from \"./build\"\nimport { Compute$, Missing$, type ComputeStep, type Spot } from \"./definition\"\n\nconst safe =\n <Fn extends (value: any) => any>(fn: Fn): ComputeStep =>\n (value) => {\n try {\n return value === Missing$ ? Missing$ : /* USERLAND */ fn(value)\n } catch {\n return Missing$\n }\n }\n\nfunction shape<S, T>(spot: Spot<S>, fn: (from: S) => T): Spot<T>\n\nfunction shape<T>(ctx: ContextToSpot<T>): Spot<T>\nfunction shape<S, T>(ctx: ContextToSpot<S>, fn: (from: NoInfer<S>) => T): Spot<T>\n\nfunction shape<S, T>(ctxOrSpot: ContextToSpot<S> | Spot<S>, fn?: (from: NoInfer<S>) => T): Spot<T> {\n const spot = build<S>(ctxOrSpot)\n\n if (fn) spot[Compute$].push(safe(fn))\n\n return spot as Spot<T>\n}\n\nexport { shape }\n","import type { IsSpot, SpotToContext } from \"@computable\"\nimport { build, literal, Missing$, reference, type Spot, type SpotProvider } from \"@computable\"\nimport { T, type Eventual } from \"@shared\"\nimport { Context$, Dispatch$, Execute$, type Runnable, type RunnableInternal, type RunnableKind } from \"./definition\"\n\ntype WithContext<Context, Return> = Context extends void\n ? { fn: () => Eventual<Return>; context?: never }\n : IsSpot<Context> extends true\n ? { fn: (ctx: NoInfer<SpotToContext<Context>>) => Eventual<Return>; context: Context }\n : { fn: (ctx: unknown) => Eventual<Return>; context: never }\n\ntype TaskConfig<Result, RunContext, EnabledContext> = {\n name: string\n run: WithContext<RunContext, Result>\n enabled?: WithContext<EnabledContext, boolean>\n}\n\ntype Task<R> = {\n readonly name: string\n\n readonly result: SpotProvider<R>\n readonly status: Spot<TaskStatus>\n readonly error: Spot<unknown>\n} & Runnable &\n RunnableKind<\"task\">\n\ntype TaskResult<T> = T extends Task<infer R> ? R : never\ntype TaskStatus = \"done\" | \"fail\" | \"skip\"\ntype TaskExecutionValue<R> = { status: \"done\"; value: R } | { status: \"fail\"; error: unknown } | { status: \"skip\" }\n\nconst dispatch = {\n result: <R>(result: TaskExecutionValue<R>) => (result.status === \"done\" ? result.value : Missing$),\n status: <R>(result: TaskExecutionValue<R>) => result.status,\n error: <R>(result: TaskExecutionValue<R>) => (result.status === \"fail\" ? result.error : Missing$),\n}\n\nconst createTask = <Result, RunContext = void, EnabledContext = void>(\n config: TaskConfig<Result, RunContext, EnabledContext>,\n): Task<Result> => {\n const id = {\n result: Symbol(`Task[${config.name}]::result`),\n status: Symbol(`Task[${config.name}]::status`),\n error: Symbol(`Task[${config.name}]::error`),\n }\n\n const context = {\n run: config.run.context ?? literal(undefined),\n enabled: config.enabled?.context ?? literal(undefined),\n }\n\n type ExecutionResult = TaskExecutionValue<Result>\n type ExecutionContext = { run: SpotToContext<RunContext>; enabled: SpotToContext<EnabledContext> } | typeof Missing$\n\n const runnable: RunnableInternal<ExecutionResult> & Task<Result> = {\n name: config.name,\n kind: \"task\",\n\n result: reference.lensed<Result>(id.result),\n status: reference<TaskStatus>(id.status),\n error: reference<unknown>(id.error),\n\n [Context$]: build(context),\n [Execute$]: async (built: unknown) => {\n const ctx = built as ExecutionContext\n if (ctx === Missing$) return { status: \"skip\" }\n\n try {\n const enabled = await /* USERLAND */ (config.enabled?.fn ?? T)(ctx.enabled)\n if (!enabled) return { status: \"skip\" }\n } catch (error) {\n return { status: \"fail\", error }\n }\n\n try {\n const value = await /* USERLAND */ config.run.fn(ctx.run)\n return { status: \"done\", value }\n } catch (error) {\n return { status: \"fail\", error }\n }\n },\n [Dispatch$]: { [id.result]: dispatch.result, [id.status]: dispatch.status, [id.error]: dispatch.error },\n }\n\n return runnable\n}\n\nexport { createTask, type Task, type TaskExecutionValue, type TaskResult, type TaskStatus }\n","import { Execute$, type Runnable, type RunnableKind, type Tag, Tag$, type Task, type Wire } from \"@runnable\"\nimport { isObject } from \"@shared\"\n\nconst is = {\n tag: (x: unknown): x is Tag<unknown> => isObject(x) && Tag$ in x,\n runnable: (x: unknown): x is Runnable & RunnableKind<string> => isObject(x) && Execute$ in x,\n\n task: (x: unknown): x is Task<unknown> => is.runnable(x) && x.kind === \"task\",\n wire: (x: unknown): x is Wire => is.runnable(x) && x.kind === \"wire\",\n}\n\nexport { is }\n","import type { ContextToSpot } from \"@computable\"\nimport { build, reference, type SpotProvider } from \"@computable\"\nimport { is } from \"@is\"\nimport { identity, isObject, LIBRARY_NAME } from \"@shared\"\nimport { Context$, Dispatch$, Execute$, type Runnable, type RunnableInternal, type RunnableKind } from \"./definition\"\n\nconst Tag$ = Symbol(\"$tag\")\n\ntype Tag<T> = { [Tag$]: symbol; readonly name: string; readonly value: SpotProvider<T> }\n\nconst tag = <T = never>(name: string): Tag<T> => {\n const id = Symbol(`Tag[${name}]`)\n\n return { [Tag$]: id, name, value: reference.lensed<T>(id) }\n}\n\ntype Wire = { readonly name: string } & Runnable & RunnableKind<\"wire\">\n\ntype TagShape<T> =\n T extends Tag<unknown>\n ? T\n : T extends readonly unknown[]\n ? { [K in keyof T & number]: TagShape<T[K]> }\n : T extends Record<string, unknown>\n ? { [K in keyof T & string]: TagShape<T[K]> }\n : Tag<unknown>\n\ntype TagShapeToValue<S> = [S] extends [Tag<infer V>]\n ? V\n : S extends Record<string, unknown> | readonly unknown[]\n ? { [K in keyof S]: TagShapeToValue<S[K]> }\n : never\n\ntype WireConfig<S> = { from: NoInfer<ContextToSpot<TagShapeToValue<S>>>; to: S & TagShape<S> }\n\ntype WireEntry = { tag: Tag<unknown>; fn: (v: unknown) => unknown }\n\nconst pluck =\n (path: PropertyKey[]) =>\n (value: any): unknown =>\n path.reduce((acc, key) => acc?.[key], value)\n\nfunction* walk(shape: unknown, path: PropertyKey[] = []): Generator<WireEntry> {\n if (is.tag(shape)) yield { tag: shape, fn: pluck(path) }\n else if (Array.isArray(shape))\n for (let index = 0; index < shape.length; index++) yield* walk(shape[index], [...path, index])\n else if (isObject(shape))\n for (const key of Object.keys(shape)) yield* walk(shape[key as keyof typeof shape], [...path, key])\n else throw new Error(`${LIBRARY_NAME} Invalid shape ${String(shape)} provided to Wire at path \"${path.join(\".\")}\".`)\n}\n\nconst createWire = <const S>(config: WireConfig<S>): Wire => {\n const tags: Set<Tag<unknown>> = new Set()\n const dispatch: RunnableInternal[typeof Dispatch$] = {}\n\n for (const entry of walk(config.to))\n if (tags.has(entry.tag))\n throw new Error(`${LIBRARY_NAME} Duplicate tag \"${entry.tag.name}\" found in Wire destination.`)\n else void (tags.add(entry.tag), (dispatch[entry.tag[Tag$]] = entry.fn))\n\n const name = Array.from(tags)\n .map((tag) => tag.name)\n .join(\" + \")\n\n return {\n name,\n kind: \"wire\",\n\n [Context$]: build(config.from),\n [Execute$]: identity,\n [Dispatch$]: dispatch,\n } as RunnableInternal & Wire\n}\n\nexport { createWire, tag, Tag$, type Tag, type Wire }\n","import { Build$, Literal$, Optional$, Read$, Spot$, type SpotInternal } from \"@computable\"\nimport { isObject, LIBRARY_NAME } from \"@shared\"\n\ntype Dependency = { required: Set<symbol>; optional: Set<symbol> }\ntype DependencyEntry = { id: symbol; optional: boolean }\n\nfunction* scanShape(shape: unknown): Generator<DependencyEntry, void, void> {\n if (isObject(shape))\n if (Spot$ in shape) yield* scanSpot(shape as SpotInternal)\n else for (const key of Object.keys(shape)) yield* scanShape(shape[key as keyof typeof shape])\n else if (Array.isArray(shape)) for (const item of shape) yield* scanShape(item)\n else throw new Error(`${LIBRARY_NAME} Literal value found in context: ${String(shape)}.`)\n}\n\nfunction* scanSpot(spot: SpotInternal): Generator<DependencyEntry, void, void> {\n if (Literal$ in spot) return\n else if (Read$ in spot) return yield { id: spot[Read$], optional: spot[Optional$] }\n else if (Build$ in spot)\n for (const entry of scanShape(spot[Build$])) yield { id: entry.id, optional: entry.optional || spot[Optional$] }\n else throw /* unknown unit */ new Error(`${LIBRARY_NAME} Invalid Unit.`)\n}\n\nfunction resolve(spot: SpotInternal): Dependency {\n const required = new Set<symbol>()\n const optional = new Set<symbol>()\n\n for (const entry of scanSpot(spot))\n if (entry.optional) optional.add(entry.id)\n else required.add(entry.id)\n\n return { required, optional }\n}\n\nexport { resolve, type Dependency }\n","import { Context$, Dispatch$, type Runnable, type RunnableInternal, type Task, type Wire } from \"@runnable\"\nimport type { ComposableKind } from \"./definition\"\nimport { resolve, type Dependency } from \"./resolver\"\n\ntype RunnableMeta = { type: ComposableKind; display: { name: string }; writes: symbol[]; dependencies: Dependency }\n\ntype ComposeAnalyzer = {\n get: (runnable: RunnableInternal) => RunnableMeta\n}\n\nconst analyze = (runnable: RunnableInternal): RunnableMeta => {\n const internal = runnable as RunnableInternal & (Task<unknown> | Wire)\n\n const writes = Object.getOwnPropertySymbols(internal[Dispatch$])\n const dependencies = resolve(internal[Context$])\n\n return { type: internal.kind, display: { name: internal.name }, writes, dependencies }\n}\n\nconst createAnalyzer = (): ComposeAnalyzer => {\n const cache = new WeakMap<Runnable, RunnableMeta>()\n\n const get = (runnable: Runnable): RunnableMeta => {\n const analysis = cache.get(runnable) ?? analyze(runnable as RunnableInternal)\n return (cache.set(runnable, analysis), analysis)\n }\n\n return { get }\n}\n\nexport { createAnalyzer }\n","import type { RunnableInternal } from \"@runnable\"\nimport type { ComposableKind, ComposeNode } from \"./definition\"\nimport { createAnalyzer } from \"./analyze\"\n\ntype EntryID = number\n\ntype GraphExecutionMeta = { name?: string }\ntype GraphRunMeta = { name: string; kind: ComposableKind }\ntype GraphRunDeps = { required: EntryID[]; optional: EntryID[] }\n\ntype GraphNode =\n | { type: \"con\"; meta: GraphExecutionMeta; children: GraphNode[] }\n | { type: \"seq\"; meta: GraphExecutionMeta; children: GraphNode[] }\n | { type: \"run\"; meta: GraphRunMeta; id: EntryID; dependencies: GraphRunDeps }\n\nconst graph = (root: ComposeNode): GraphNode => {\n let entryID = 0\n const symbolToID = new Map<symbol, EntryID>()\n\n const analyzer = createAnalyzer()\n\n const toEntry = (runnable: RunnableInternal): GraphNode => {\n const { type, display, writes, dependencies } = analyzer.get(runnable)\n\n writes.forEach((x) => symbolToID.set(x, entryID))\n\n return {\n type: \"run\",\n meta: { name: display.name, kind: type },\n id: entryID++,\n dependencies: {\n required: Array.from(dependencies.required, (x) => symbolToID.get(x) ?? -1),\n optional: Array.from(dependencies.optional, (x) => symbolToID.get(x)).filter((x) => x !== undefined),\n },\n }\n }\n\n const traverse = (node: ComposeNode): GraphNode => {\n switch (node.type) {\n case \"con\":\n case \"seq\":\n return { type: node.type, meta: { name: node.meta?.name }, children: node.children.map(traverse) }\n\n case \"run\":\n return toEntry(node.value as RunnableInternal)\n }\n }\n\n return traverse(root)\n}\n\nexport { graph, type GraphNode }\n","import type { RunnableInternal } from \"@runnable\"\nimport type { ComposableKind, ComposeMeta, ComposeNode } from \"./definition\"\nimport { createAnalyzer } from \"./analyze\"\n\ntype NotifyEntry = { index?: number; node: ComposeNode }\n\ntype NotifyContext = { type: ComposableKind; name: string; stack: NotifyEntry[] }\ntype GuardHandler = Record<\"warn\" | \"error\", (message: string) => void>\n\nconst UNKNOWN_NAME = \"<unknown>\"\n\nconst TypeMap = { task: \"Task\", wire: \"Wire\" } satisfies Record<ComposableKind, string>\n\nconst metaOf = <const K extends keyof ComposeMeta>(node: ComposeNode, key: K): ComposeMeta[K] =>\n \"meta\" in node && node.meta?.[key] ? node.meta[key] : undefined\n\nconst stackToName = (stack: NotifyEntry[]): string =>\n stack\n .map(({ node, index }) => {\n const name = metaOf(node, \"name\")\n if (index !== undefined) return name ? `#${index + 1} (${name})` : `#${index + 1}`\n else return name ?? \"root\"\n })\n .join(\" > \")\n\nconst createNotify = (handler: GuardHandler) => ({\n duplicate: ({ type, name, stack }: NotifyContext) => {\n const message = `A duplicate ${TypeMap[type]} found with name ${TypeMap[type]}[${name}] in step ${stackToName(stack)}.`\n\n handler.error(message)\n },\n\n notSatisfied: ({ type, name, stack, missing: set }: NotifyContext & { missing: Set<symbol> }) => {\n const list = Array.from(set, (id) => id.description ?? UNKNOWN_NAME).join(\", \")\n const message = `Unsatisfied dependencies found for ${TypeMap[type]} with name ${TypeMap[type]}[${name}] in step ${stackToName(stack)}: missing ${list}.`\n\n handler.error(message)\n },\n\n unused: ({ type, name, stack, id }: NotifyContext & { id: symbol }) => {\n const target = `${TypeMap[type]}[${name}] for ${id.description ?? UNKNOWN_NAME}`\n const message = `Unused ${TypeMap[type]} found with name ${target} in step ${stackToName(stack)}.`\n\n handler.warn(message)\n },\n})\n\ntype GuardConfig = { handler: GuardHandler }\n\nconst createGuard = ({ handler }: GuardConfig) => {\n const notify = createNotify(handler)\n const analyzer = createAnalyzer()\n\n const duplicate = (root: ComposeNode) => {\n const seen = new Set<symbol>()\n\n const traverse = (stack: NotifyEntry[]) => {\n const { node: current } = stack.at(-1)!\n\n if (current.type === \"con\" || current.type === \"seq\")\n return current.children.forEach((node, index) => traverse([...stack, { node, index }]))\n\n if (current.type === \"run\") {\n const { type, display, writes } = analyzer.get(current.value as RunnableInternal)\n\n if (writes.some((write) => seen.has(write))) notify.duplicate({ type, name: display.name, stack })\n\n writes.forEach((w) => seen.add(w))\n }\n }\n\n traverse([{ node: root }])\n }\n\n const unused = (root: ComposeNode) => {\n const candidates: Map<symbol, NotifyContext & { id: symbol }> = new Map()\n\n const traverse = (stack: NotifyEntry[]) => {\n const { node: current } = stack.at(-1)!\n\n if (current.type === \"con\" || current.type === \"seq\")\n return current.children.forEach((node, index) => traverse([...stack, { node, index }]))\n\n if (current.type === \"run\") {\n const { type, display, writes, dependencies } = analyzer.get(current.value as RunnableInternal)\n\n if (type === \"wire\") writes.forEach((id) => candidates.set(id, { id, type, name: display.name, stack }))\n\n dependencies.required.forEach((id) => candidates.delete(id))\n dependencies.optional.forEach((id) => candidates.delete(id))\n }\n }\n\n traverse([{ node: root }])\n\n for (const context of candidates.values()) notify.unused(context)\n }\n\n const unsatisfied = (root: ComposeNode) => {\n const traverse = (stack: NotifyEntry[], available: Set<symbol>): Set<symbol> => {\n const { node: current } = stack.at(-1)!\n\n switch (current.type) {\n case \"run\":\n const { type, display, writes, dependencies } = analyzer.get(current.value as RunnableInternal)\n\n const missing = new Set<symbol>()\n for (const id of dependencies.required) if (!available.has(id)) missing.add(id)\n\n if (missing.size > 0) notify.notSatisfied({ type, name: display.name, stack, missing })\n\n return new Set(writes)\n\n // all concurrent steps are isolated\n case \"con\": {\n const wrote = new Set<symbol>()\n\n for (const [index, node] of current.children.entries())\n traverse([...stack, { node, index }], available).forEach((item) => wrote.add(item))\n\n return wrote\n }\n\n // sequential steps share the context of previous steps\n case \"seq\": {\n const wrote = new Set<symbol>(),\n local = new Set<symbol>(available)\n\n for (const [index, node] of current.children.entries())\n traverse([...stack, { node, index }], local).forEach((item) => (wrote.add(item), local.add(item)))\n\n return wrote\n }\n }\n }\n\n traverse([{ node: root }], new Set())\n }\n\n return (root: ComposeNode) => (duplicate(root), unsatisfied(root), unused(root))\n}\n\nexport { createGuard, type GuardHandler }\n","import type { RunnableInternal, RunnableKind, Task, TaskExecutionValue } from \"@runnable\"\nimport type { ComposableKind, ComposeMeta, ComposeNode } from \"./definition\"\n\ntype ObserverEvent =\n | { type: \"node:start\"; stack: ComposeNode[] }\n | { type: \"node:complete\"; stack: ComposeNode[] }\n | { type: \"execute:complete\"; stack: ComposeNode[]; runnable: RunnableInternal; value: unknown }\n\ntype ComposeHookMap = {\n onStart: (event: { meta?: ComposeMeta }) => void\n onComplete: (event: { meta?: ComposeMeta }) => void\n\n onTaskFail: (event: { task: Task<unknown>; error: unknown }) => void\n}\n\nconst eventToUserland = {\n onTaskFail: (event: ObserverEvent & { type: \"execute:complete\" }) => {\n const runnable = event.runnable as RunnableInternal & RunnableKind<ComposableKind>\n const result = event.value as TaskExecutionValue<unknown>\n\n if (runnable.kind === \"task\" && result.status === \"fail\")\n return { task: runnable as unknown as Task<unknown>, error: result.error }\n else return null\n },\n}\n\nconst observe = (event: ObserverEvent) => {\n let userland\n const current = event.stack.at(-1)!\n\n switch (event.type) {\n case \"node:start\":\n if (\"meta\" in current) current.meta?.hooks?.onStart?.({ meta: current.meta })\n break\n\n case \"node:complete\":\n if (\"meta\" in current) current.meta?.hooks?.onComplete?.({ meta: current.meta })\n break\n\n case \"execute:complete\":\n if ((userland = eventToUserland.onTaskFail(event)))\n for (const node of event.stack) if (\"meta\" in node) node.meta?.hooks?.onTaskFail?.(userland)\n break\n }\n}\n\nexport { observe, type ComposeHookMap }\n","import { createComputer, type Computer, type Spot, type SpotInternal } from \"@computable\"\nimport { Context$, Dispatch$, Execute$, type RunnableInternal } from \"@runnable\"\nimport type { ComposeNode, Registry } from \"./definition\"\nimport { observe } from \"./observer\"\n\ntype Context = { computer: Computer; registry: Registry }\ntype Scope = { get: <T>(spot: Spot<T>) => T | undefined }\n\nconst execute = (ctx: Context, runnable: RunnableInternal): Promise<unknown> =>\n Promise.resolve()\n .then(() => ctx.computer.compute(runnable[Context$]))\n .then((value) => runnable[Execute$](value))\n .then((value) => {\n for (const key of Object.getOwnPropertySymbols(runnable[Dispatch$]))\n ctx.registry.set(key, runnable[Dispatch$][key]!(value))\n return value\n })\n\nconst traverse = async (ctx: Context, stack: ComposeNode[]) => {\n const current = stack.at(-1)!\n\n observe({ type: \"node:start\", stack })\n\n switch (current.type) {\n case \"seq\":\n for (const child of current.children) await traverse(ctx, [...stack, child])\n break\n\n case \"con\":\n await Promise.all(current.children.map((child) => traverse(ctx, [...stack, child])))\n break\n\n case \"run\":\n const runnable = current.value as RunnableInternal\n\n await execute(ctx, runnable).then((value) => observe({ type: \"execute:complete\", stack, runnable, value }))\n\n break\n }\n\n observe({ type: \"node:complete\", stack })\n}\n\nconst run = async (node: ComposeNode): Promise<Scope> => {\n const registry: Registry = new Map()\n const computer = createComputer(registry)\n\n const ctx: Context = { computer, registry }\n\n await traverse(ctx, [node])\n\n return {\n get: <T>(spot: Spot<T>): T | undefined => computer.computeSafe(spot as SpotInternal<T>),\n }\n}\n\nexport { run, type Scope }\n","import { Execute$, type Runnable } from \"@runnable\"\nimport { LIBRARY_NAME } from \"@shared\"\nimport type { ComposeInner, ComposeMeta, ComposeNode } from \"./definition\"\nimport { graph, type GraphNode } from \"./graph\"\nimport { createGuard, type GuardHandler } from \"./guard\"\nimport { run, type Scope } from \"./runner\"\n\nconst Node$ = Symbol(\"$node\")\n\ntype Composable = Composer | Runnable\n\ntype Composer = {\n /**\n * Execution Graph Node\n * @private\n * @internal\n */\n [Node$]: ComposeInner\n\n run: () => Promise<Scope>\n guard: () => void\n graph: () => GraphNode\n\n meta: (meta: Partial<ComposeMeta>) => Composer\n step: (compose: Composable | Composable[]) => Composer\n}\n\nconst normalize = (arg: Composable): ComposeNode => {\n if (Node$ in arg) return arg[Node$]\n else if (Execute$ in arg) return { type: \"run\", value: arg as Runnable }\n else throw new Error(`${LIBRARY_NAME} Invalid argument passed to step.`)\n}\n\nconst raiseOnGuard = (message: string): never => {\n throw new Error(message)\n}\n\nconst builder = (node: ComposeInner): Composer => {\n return {\n [Node$]: node,\n\n meta: (meta) => builder({ ...node, meta: { ...node.meta, ...meta } }),\n\n step: (arg) => {\n if (Array.isArray(arg))\n return builder({ ...node, children: [...node.children, { type: \"con\", children: arg.map(normalize) }] })\n else return builder({ ...node, children: [...node.children, normalize(arg)] })\n },\n\n run: () => {\n const handler: GuardHandler = { warn: console.warn.bind(console, LIBRARY_NAME), error: raiseOnGuard }\n const guard = createGuard({ handler })\n\n return (guard(node), run(node))\n },\n\n guard: () => {\n const handler: GuardHandler = { warn: raiseOnGuard, error: raiseOnGuard }\n const guard = createGuard({ handler })\n\n return guard(node)\n },\n\n graph: () => graph(node),\n }\n}\n\nconst compose = (): Composer => {\n const root: ComposeNode = { type: \"seq\", children: [] }\n\n return builder(root)\n}\n\nexport { compose, Node$, type Composer }\n"],"mappings":";AAGA,MAAM,WAAW,OAAO,UAAU;AAClC,MAAM,WAAW,OAAO,UAAU;AAClC,MAAM,YAAY,OAAO,WAAW;;;ACLpC,MAAM,QAAQ,OAAO,OAAO;AAG5B,MAAM,QAAQ,OAAO,OAAO;AAC5B,MAAM,SA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