@app-compose/core 3.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +80 -0
- package/dist/index.cjs +598 -0
- package/dist/index.d.cts +185 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +185 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +592 -0
- package/dist/index.js.map +1 -0
- package/package.json +69 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
declare const Spot$: unique symbol;
|
|
2
|
+
declare const Phantom$: unique symbol;
|
|
3
|
+
type Spot<T> = {
|
|
4
|
+
[Spot$]: true;
|
|
5
|
+
[Phantom$]?: T;
|
|
6
|
+
};
|
|
7
|
+
type SpotValue<T extends Spot<any>> = T extends Spot<infer V> ? V : never;
|
|
8
|
+
type AnyShape = Record<string, unknown>;
|
|
9
|
+
type Eventual<T> = Promise<T> | T;
|
|
10
|
+
type BuiltInObject = null | undefined | boolean | string | number | Error | Date | RegExp | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | ReadonlyMap<unknown, unknown> | ReadonlySet<unknown> | WeakMap<object, unknown> | WeakSet<object> | ArrayBuffer | DataView | Function | Promise<unknown> | Generator | {
|
|
11
|
+
readonly [Symbol.toStringTag]: string;
|
|
12
|
+
};
|
|
13
|
+
type ContextToSpot<T> = [T] extends [BuiltInObject] ? Spot<T> : Spot<T> | ContextShapeToSpot<T>;
|
|
14
|
+
type ContextShapeToSpot<T> = { readonly [K in keyof T]: ContextToSpot<T[K]>; };
|
|
15
|
+
type KeyValue = Record<string, unknown> | readonly unknown[];
|
|
16
|
+
type SpotToContext<T> = T extends Spot<infer Value> ? Value : T extends KeyValue ? { [Key in keyof T]: SpotToContext<T[Key]>; } : never;
|
|
17
|
+
type IsSpot<T> = T extends Spot<unknown> ? true : T extends readonly unknown[] ? { [Key in keyof T & number]: IsSpot<T[Key]>; }[number] extends true ? true : false : T extends Record<string, unknown> ? { [Key in keyof T]: IsSpot<T[Key]>; }[keyof T] extends true ? true : false : false;
|
|
18
|
+
declare const literal: <const T>(value: T) => Spot<T>;
|
|
19
|
+
/**
|
|
20
|
+
* Mark a `Spot` as optional.
|
|
21
|
+
*/
|
|
22
|
+
declare const optional: <T>(spot: Spot<T>) => Spot<T | undefined>;
|
|
23
|
+
type SpotProvider<T> = [T] extends [AnyShape] ? { readonly [Key in keyof T]: SpotProvider<T[Key]>; } & Spot<T> : Spot<T>;
|
|
24
|
+
declare function shape<S, T>(spot: Spot<S>, fn: (from: S) => T): Spot<T>;
|
|
25
|
+
declare function shape<T>(ctx: ContextToSpot<T>): Spot<T>;
|
|
26
|
+
declare function shape<S, T>(ctx: ContextToSpot<S>, fn: (from: NoInfer<S>) => T): Spot<T>;
|
|
27
|
+
declare const Execute$: unique symbol;
|
|
28
|
+
type Runnable<T extends string = string> = {
|
|
29
|
+
readonly [Execute$]: unknown;
|
|
30
|
+
readonly kind: T;
|
|
31
|
+
};
|
|
32
|
+
type WithContext<Context, Return> = Context extends void ? {
|
|
33
|
+
fn: () => Eventual<Return>;
|
|
34
|
+
context?: never;
|
|
35
|
+
} : IsSpot<Context> extends true ? {
|
|
36
|
+
fn: (ctx: NoInfer<SpotToContext<Context>>) => Eventual<Return>;
|
|
37
|
+
context: Context;
|
|
38
|
+
} : {
|
|
39
|
+
fn: (ctx: unknown) => Eventual<Return>;
|
|
40
|
+
context: never;
|
|
41
|
+
};
|
|
42
|
+
type TaskConfig<Result, RunContext, EnabledContext> = {
|
|
43
|
+
name: string;
|
|
44
|
+
run: WithContext<RunContext, Result>;
|
|
45
|
+
enabled?: WithContext<EnabledContext, boolean>;
|
|
46
|
+
};
|
|
47
|
+
type Task<R> = {
|
|
48
|
+
readonly name: string;
|
|
49
|
+
readonly result: SpotProvider<R>;
|
|
50
|
+
readonly status: Spot<TaskStatus>;
|
|
51
|
+
readonly error: Spot<unknown>;
|
|
52
|
+
} & Runnable<"task">;
|
|
53
|
+
type TaskResult<T> = T extends Task<infer R> ? R : never;
|
|
54
|
+
type TaskStatus = "done" | "fail" | "skip";
|
|
55
|
+
declare const createTask: <Result, RunContext = void, EnabledContext = void>(config: TaskConfig<Result, RunContext, EnabledContext>) => Task<Result>;
|
|
56
|
+
declare const Tag$: unique symbol;
|
|
57
|
+
type Tag<T> = {
|
|
58
|
+
[Tag$]: symbol;
|
|
59
|
+
readonly name: string;
|
|
60
|
+
readonly value: SpotProvider<T>;
|
|
61
|
+
};
|
|
62
|
+
declare const tag: <T = never>(name: string) => Tag<T>;
|
|
63
|
+
type Wire = {
|
|
64
|
+
readonly name: string;
|
|
65
|
+
} & Runnable<"wire">;
|
|
66
|
+
type TagShape<T> = T extends Tag<unknown> ? T : T extends readonly unknown[] ? { [K in keyof T & number]: TagShape<T[K]>; } : T extends Record<string, unknown> ? { [K in keyof T & string]: TagShape<T[K]>; } : Tag<unknown>;
|
|
67
|
+
type TagShapeToValue<S> = [S] extends [Tag<infer V>] ? V : S extends Record<string, unknown> | readonly unknown[] ? { [K in keyof S]: TagShapeToValue<S[K]>; } : never;
|
|
68
|
+
type WireConfig<S> = {
|
|
69
|
+
from: NoInfer<ContextToSpot<TagShapeToValue<S>>>;
|
|
70
|
+
to: S & TagShape<S>;
|
|
71
|
+
};
|
|
72
|
+
declare const createWire: <const S>(config: WireConfig<S>) => Wire;
|
|
73
|
+
type ReadonlyMeta = Readonly<ComposeMeta>;
|
|
74
|
+
type ComposeEvent = {
|
|
75
|
+
node: "seq";
|
|
76
|
+
scope: Scope;
|
|
77
|
+
phase: "enter";
|
|
78
|
+
meta?: ReadonlyMeta;
|
|
79
|
+
} | {
|
|
80
|
+
node: "seq";
|
|
81
|
+
scope: Scope;
|
|
82
|
+
phase: "exit";
|
|
83
|
+
meta?: ReadonlyMeta;
|
|
84
|
+
} | {
|
|
85
|
+
node: "con";
|
|
86
|
+
scope: Scope;
|
|
87
|
+
phase: "enter";
|
|
88
|
+
meta?: ReadonlyMeta;
|
|
89
|
+
} | {
|
|
90
|
+
node: "con";
|
|
91
|
+
scope: Scope;
|
|
92
|
+
phase: "exit";
|
|
93
|
+
meta?: ReadonlyMeta;
|
|
94
|
+
} | {
|
|
95
|
+
node: "run";
|
|
96
|
+
scope: Scope;
|
|
97
|
+
phase: "enter";
|
|
98
|
+
runnable: KnownRunnable;
|
|
99
|
+
} | {
|
|
100
|
+
node: "run";
|
|
101
|
+
scope: Scope;
|
|
102
|
+
phase: "exit";
|
|
103
|
+
runnable: KnownRunnable;
|
|
104
|
+
};
|
|
105
|
+
type ComposeObserver = (event: ComposeEvent, path: readonly ReadonlyMeta[]) => void;
|
|
106
|
+
type ComposeMeta = {
|
|
107
|
+
name?: string;
|
|
108
|
+
observe?: ComposeObserver;
|
|
109
|
+
};
|
|
110
|
+
type ComposeNodeSeq = {
|
|
111
|
+
type: "seq";
|
|
112
|
+
meta?: ComposeMeta;
|
|
113
|
+
children: ComposeNode[];
|
|
114
|
+
};
|
|
115
|
+
type ComposeNodeCon = {
|
|
116
|
+
type: "con";
|
|
117
|
+
meta?: ComposeMeta;
|
|
118
|
+
children: ComposeNode[];
|
|
119
|
+
};
|
|
120
|
+
type ComposeNodeRun = {
|
|
121
|
+
type: "run";
|
|
122
|
+
value: Runnable;
|
|
123
|
+
};
|
|
124
|
+
type ComposeNode = ComposeNodeSeq | ComposeNodeCon | ComposeNodeRun;
|
|
125
|
+
type ComposeInner = ComposeNodeCon | ComposeNodeSeq;
|
|
126
|
+
type ComposableKind = "task" | "wire";
|
|
127
|
+
type KnownRunnableMap = {
|
|
128
|
+
task: Task<unknown>;
|
|
129
|
+
wire: Wire;
|
|
130
|
+
};
|
|
131
|
+
type KnownRunnable = KnownRunnableMap[ComposableKind];
|
|
132
|
+
type Scope = {
|
|
133
|
+
get: <T>(spot: Spot<T>) => T | undefined;
|
|
134
|
+
};
|
|
135
|
+
type EntryID = number;
|
|
136
|
+
type GraphExecutionMeta = {
|
|
137
|
+
name?: string;
|
|
138
|
+
};
|
|
139
|
+
type GraphRunMeta = {
|
|
140
|
+
name: string;
|
|
141
|
+
kind: ComposableKind;
|
|
142
|
+
};
|
|
143
|
+
type GraphRunDeps = {
|
|
144
|
+
required: EntryID[];
|
|
145
|
+
optional: EntryID[];
|
|
146
|
+
};
|
|
147
|
+
type GraphNode = {
|
|
148
|
+
type: "con";
|
|
149
|
+
meta: GraphExecutionMeta;
|
|
150
|
+
children: GraphNode[];
|
|
151
|
+
} | {
|
|
152
|
+
type: "seq";
|
|
153
|
+
meta: GraphExecutionMeta;
|
|
154
|
+
children: GraphNode[];
|
|
155
|
+
} | {
|
|
156
|
+
type: "run";
|
|
157
|
+
meta: GraphRunMeta;
|
|
158
|
+
id: EntryID;
|
|
159
|
+
dependencies: GraphRunDeps;
|
|
160
|
+
};
|
|
161
|
+
declare const Node$: unique symbol;
|
|
162
|
+
type Composable = Composer | Runnable;
|
|
163
|
+
type Composer = {
|
|
164
|
+
/**
|
|
165
|
+
* Execution Graph Node
|
|
166
|
+
* @private
|
|
167
|
+
* @internal
|
|
168
|
+
*/
|
|
169
|
+
[Node$]: ComposeInner;
|
|
170
|
+
run: () => Promise<Scope>;
|
|
171
|
+
guard: () => void;
|
|
172
|
+
graph: () => GraphNode;
|
|
173
|
+
meta: (meta: Partial<ComposeMeta>) => Composer;
|
|
174
|
+
step: (compose: Composable | Composable[]) => Composer;
|
|
175
|
+
};
|
|
176
|
+
declare const compose: () => Composer;
|
|
177
|
+
declare const is: {
|
|
178
|
+
spot: (x: unknown) => x is Spot<unknown>;
|
|
179
|
+
tag: (x: unknown) => x is Tag<unknown>;
|
|
180
|
+
runnable: (x: unknown) => x is Runnable;
|
|
181
|
+
task: (x: unknown) => x is Task<unknown>;
|
|
182
|
+
wire: (x: unknown) => x is Wire;
|
|
183
|
+
};
|
|
184
|
+
export { type ComposeEvent, type ComposeObserver, type Composer, type Spot, type SpotValue, type Tag, type Task, type TaskResult, type TaskStatus, type Wire, compose, createTask, createWire, is, literal, optional, shape, tag };
|
|
185
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/computable/definition.ts","../src/shared.ts","../src/computable/context.ts","../src/computable/literal.ts","../src/computable/optional.ts","../src/computable/reference.ts","../src/computable/shape.ts","../src/runnable/definition.ts","../src/runnable/task.ts","../src/runnable/wire.ts","../src/compose/observer.ts","../src/compose/definition.ts","../src/compose/graph.ts","../src/compose/compose.ts","../src/is.ts"],"mappings":"A,cAAM;cACA;KAWD,KAAK;GAAQ;GAAe,YAAY;;KACxC,UAAU,UAAU,aAAa,UAAU,WAAW,KAAK;KCb3D,WAAW;KACX,SAAS,KAAK,QAAQ,KAAK;KAE3B,+DAMD,QACA,OACA,SACA,YACA,aACA,oBACA,aACA,cACA,aACA,cACA,eACA,eACA,gCACA,uBACA,2BACA,kBACA,cACA,WACA,WACA,mBACA;YACY,OAAO;;KC3BlB,cAAc,MAAM,YAAY,iBAAiB,KAAK,KAAK,KAAK,KAAK,mBAAmB;KACxF,mBAAmB,iBAAiB,WAAW,IAAI,cAAc,EAAE;KAEnE,WAAW;KAEX,cAAc,KACjB,UAAU,WAAW,SAAS,QAAQ,UAAU,cAAc,aAAa,IAAI,cAAc,EAAE;KAE5F,OAAO,KACV,UAAU,uBAEN,kCACK,aAAa,aAAa,OAAO,EAAE,+CAGtC,UAAU,6BACL,aAAa,IAAI,OAAO,EAAE,eAAc;cCjB/C,gBAAiB,GAAC,OAAS,MAAI,KAAK;;;;cCIpC,WAAY,GAAC,MAAQ,KAAK,OAAK,KAAK;KCFrC,aAAa,MAAM,YAAY,wBAAwB,aAAa,IAAI,aAAa,EAAE,WAAU,KAAK,KAAK,KAAK;iBCU5G,MAAM,GAAG,GAAG,MAAM,KAAK,IAAI,KAAK,MAAM,MAAM,IAAI,KAAK;iBAErD,MAAM,GAAG,K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;KAGrD,mBAAmB,OAAO,cAAc,eAAe;KCZvD;EAAgB;EAAe,UAAU;;KAEzC;EAAmB;EAAa,OAAO;EAAa,UAAU;;KAC9D;EAAmB;EAAa,OAAO;EAAa,UAAU;;KAC9D;EAAmB;EAAa,OAAO;;KAEvC,cAAc,iBAAiB,iBAAiB;KAChD,eAAe,iBAAiB;KAGhC;KAEA;EAAqB,MAAM;EAAe,MAAM;;KAChD,gBAAgB,iBAAiB;KAEjC;EAAU,MAAM,GAAG,MAAM,KAAK,OAAO;;KChBrC;KAKA;EAAuB;;KACvB;EAAiB;EAAc,MAAM;;KACrC;EAAiB,UAAU;EAAW,UAAU;;KAEhD;EACC;EAAa,MAAM;EAAoB,UAAU;;EACjD;EAAa,MAAM;EAAoB,UAAU;;EACjD;EAAa,MAAM;EAAc,IAAI;EAAS,cAAc;;cCR5D;KAED,aAAa,WAAW;KAExB;;;;;;GAMF,QAAQ;EAET,WAAW,QAAQ;EACnB;EACA,aAAa;EAEb,OAAO,MAAM,QAAQ,iBAAiB;EACtC,OAAO,SAAS,aAAa,iBAAiB;;cA2C1C,eAAc;cC/Dd;EACJ,OAAI,eAAgB,KAAK;EAEzB,MAAG,eAAgB,KAAK;EAExB,WAAQ,eAAgB,KAAK;EAE7B,OAAI,eAAgB,KAAK;EACzB,OAAI,eAAgB,KAAK"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
declare const Spot$: unique symbol;
|
|
2
|
+
declare const Phantom$: unique symbol;
|
|
3
|
+
type Spot<T> = {
|
|
4
|
+
[Spot$]: true;
|
|
5
|
+
[Phantom$]?: T;
|
|
6
|
+
};
|
|
7
|
+
type SpotValue<T extends Spot<any>> = T extends Spot<infer V> ? V : never;
|
|
8
|
+
type AnyShape = Record<string, unknown>;
|
|
9
|
+
type Eventual<T> = Promise<T> | T;
|
|
10
|
+
type BuiltInObject = null | undefined | boolean | string | number | Error | Date | RegExp | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | ReadonlyMap<unknown, unknown> | ReadonlySet<unknown> | WeakMap<object, unknown> | WeakSet<object> | ArrayBuffer | DataView | Function | Promise<unknown> | Generator | {
|
|
11
|
+
readonly [Symbol.toStringTag]: string;
|
|
12
|
+
};
|
|
13
|
+
type ContextToSpot<T> = [T] extends [BuiltInObject] ? Spot<T> : Spot<T> | ContextShapeToSpot<T>;
|
|
14
|
+
type ContextShapeToSpot<T> = { readonly [K in keyof T]: ContextToSpot<T[K]>; };
|
|
15
|
+
type KeyValue = Record<string, unknown> | readonly unknown[];
|
|
16
|
+
type SpotToContext<T> = T extends Spot<infer Value> ? Value : T extends KeyValue ? { [Key in keyof T]: SpotToContext<T[Key]>; } : never;
|
|
17
|
+
type IsSpot<T> = T extends Spot<unknown> ? true : T extends readonly unknown[] ? { [Key in keyof T & number]: IsSpot<T[Key]>; }[number] extends true ? true : false : T extends Record<string, unknown> ? { [Key in keyof T]: IsSpot<T[Key]>; }[keyof T] extends true ? true : false : false;
|
|
18
|
+
declare const literal: <const T>(value: T) => Spot<T>;
|
|
19
|
+
/**
|
|
20
|
+
* Mark a `Spot` as optional.
|
|
21
|
+
*/
|
|
22
|
+
declare const optional: <T>(spot: Spot<T>) => Spot<T | undefined>;
|
|
23
|
+
type SpotProvider<T> = [T] extends [AnyShape] ? { readonly [Key in keyof T]: SpotProvider<T[Key]>; } & Spot<T> : Spot<T>;
|
|
24
|
+
declare function shape<S, T>(spot: Spot<S>, fn: (from: S) => T): Spot<T>;
|
|
25
|
+
declare function shape<T>(ctx: ContextToSpot<T>): Spot<T>;
|
|
26
|
+
declare function shape<S, T>(ctx: ContextToSpot<S>, fn: (from: NoInfer<S>) => T): Spot<T>;
|
|
27
|
+
declare const Execute$: unique symbol;
|
|
28
|
+
type Runnable<T extends string = string> = {
|
|
29
|
+
readonly [Execute$]: unknown;
|
|
30
|
+
readonly kind: T;
|
|
31
|
+
};
|
|
32
|
+
type WithContext<Context, Return> = Context extends void ? {
|
|
33
|
+
fn: () => Eventual<Return>;
|
|
34
|
+
context?: never;
|
|
35
|
+
} : IsSpot<Context> extends true ? {
|
|
36
|
+
fn: (ctx: NoInfer<SpotToContext<Context>>) => Eventual<Return>;
|
|
37
|
+
context: Context;
|
|
38
|
+
} : {
|
|
39
|
+
fn: (ctx: unknown) => Eventual<Return>;
|
|
40
|
+
context: never;
|
|
41
|
+
};
|
|
42
|
+
type TaskConfig<Result, RunContext, EnabledContext> = {
|
|
43
|
+
name: string;
|
|
44
|
+
run: WithContext<RunContext, Result>;
|
|
45
|
+
enabled?: WithContext<EnabledContext, boolean>;
|
|
46
|
+
};
|
|
47
|
+
type Task<R> = {
|
|
48
|
+
readonly name: string;
|
|
49
|
+
readonly result: SpotProvider<R>;
|
|
50
|
+
readonly status: Spot<TaskStatus>;
|
|
51
|
+
readonly error: Spot<unknown>;
|
|
52
|
+
} & Runnable<"task">;
|
|
53
|
+
type TaskResult<T> = T extends Task<infer R> ? R : never;
|
|
54
|
+
type TaskStatus = "done" | "fail" | "skip";
|
|
55
|
+
declare const createTask: <Result, RunContext = void, EnabledContext = void>(config: TaskConfig<Result, RunContext, EnabledContext>) => Task<Result>;
|
|
56
|
+
declare const Tag$: unique symbol;
|
|
57
|
+
type Tag<T> = {
|
|
58
|
+
[Tag$]: symbol;
|
|
59
|
+
readonly name: string;
|
|
60
|
+
readonly value: SpotProvider<T>;
|
|
61
|
+
};
|
|
62
|
+
declare const tag: <T = never>(name: string) => Tag<T>;
|
|
63
|
+
type Wire = {
|
|
64
|
+
readonly name: string;
|
|
65
|
+
} & Runnable<"wire">;
|
|
66
|
+
type TagShape<T> = T extends Tag<unknown> ? T : T extends readonly unknown[] ? { [K in keyof T & number]: TagShape<T[K]>; } : T extends Record<string, unknown> ? { [K in keyof T & string]: TagShape<T[K]>; } : Tag<unknown>;
|
|
67
|
+
type TagShapeToValue<S> = [S] extends [Tag<infer V>] ? V : S extends Record<string, unknown> | readonly unknown[] ? { [K in keyof S]: TagShapeToValue<S[K]>; } : never;
|
|
68
|
+
type WireConfig<S> = {
|
|
69
|
+
from: NoInfer<ContextToSpot<TagShapeToValue<S>>>;
|
|
70
|
+
to: S & TagShape<S>;
|
|
71
|
+
};
|
|
72
|
+
declare const createWire: <const S>(config: WireConfig<S>) => Wire;
|
|
73
|
+
type ReadonlyMeta = Readonly<ComposeMeta>;
|
|
74
|
+
type ComposeEvent = {
|
|
75
|
+
node: "seq";
|
|
76
|
+
scope: Scope;
|
|
77
|
+
phase: "enter";
|
|
78
|
+
meta?: ReadonlyMeta;
|
|
79
|
+
} | {
|
|
80
|
+
node: "seq";
|
|
81
|
+
scope: Scope;
|
|
82
|
+
phase: "exit";
|
|
83
|
+
meta?: ReadonlyMeta;
|
|
84
|
+
} | {
|
|
85
|
+
node: "con";
|
|
86
|
+
scope: Scope;
|
|
87
|
+
phase: "enter";
|
|
88
|
+
meta?: ReadonlyMeta;
|
|
89
|
+
} | {
|
|
90
|
+
node: "con";
|
|
91
|
+
scope: Scope;
|
|
92
|
+
phase: "exit";
|
|
93
|
+
meta?: ReadonlyMeta;
|
|
94
|
+
} | {
|
|
95
|
+
node: "run";
|
|
96
|
+
scope: Scope;
|
|
97
|
+
phase: "enter";
|
|
98
|
+
runnable: KnownRunnable;
|
|
99
|
+
} | {
|
|
100
|
+
node: "run";
|
|
101
|
+
scope: Scope;
|
|
102
|
+
phase: "exit";
|
|
103
|
+
runnable: KnownRunnable;
|
|
104
|
+
};
|
|
105
|
+
type ComposeObserver = (event: ComposeEvent, path: readonly ReadonlyMeta[]) => void;
|
|
106
|
+
type ComposeMeta = {
|
|
107
|
+
name?: string;
|
|
108
|
+
observe?: ComposeObserver;
|
|
109
|
+
};
|
|
110
|
+
type ComposeNodeSeq = {
|
|
111
|
+
type: "seq";
|
|
112
|
+
meta?: ComposeMeta;
|
|
113
|
+
children: ComposeNode[];
|
|
114
|
+
};
|
|
115
|
+
type ComposeNodeCon = {
|
|
116
|
+
type: "con";
|
|
117
|
+
meta?: ComposeMeta;
|
|
118
|
+
children: ComposeNode[];
|
|
119
|
+
};
|
|
120
|
+
type ComposeNodeRun = {
|
|
121
|
+
type: "run";
|
|
122
|
+
value: Runnable;
|
|
123
|
+
};
|
|
124
|
+
type ComposeNode = ComposeNodeSeq | ComposeNodeCon | ComposeNodeRun;
|
|
125
|
+
type ComposeInner = ComposeNodeCon | ComposeNodeSeq;
|
|
126
|
+
type ComposableKind = "task" | "wire";
|
|
127
|
+
type KnownRunnableMap = {
|
|
128
|
+
task: Task<unknown>;
|
|
129
|
+
wire: Wire;
|
|
130
|
+
};
|
|
131
|
+
type KnownRunnable = KnownRunnableMap[ComposableKind];
|
|
132
|
+
type Scope = {
|
|
133
|
+
get: <T>(spot: Spot<T>) => T | undefined;
|
|
134
|
+
};
|
|
135
|
+
type EntryID = number;
|
|
136
|
+
type GraphExecutionMeta = {
|
|
137
|
+
name?: string;
|
|
138
|
+
};
|
|
139
|
+
type GraphRunMeta = {
|
|
140
|
+
name: string;
|
|
141
|
+
kind: ComposableKind;
|
|
142
|
+
};
|
|
143
|
+
type GraphRunDeps = {
|
|
144
|
+
required: EntryID[];
|
|
145
|
+
optional: EntryID[];
|
|
146
|
+
};
|
|
147
|
+
type GraphNode = {
|
|
148
|
+
type: "con";
|
|
149
|
+
meta: GraphExecutionMeta;
|
|
150
|
+
children: GraphNode[];
|
|
151
|
+
} | {
|
|
152
|
+
type: "seq";
|
|
153
|
+
meta: GraphExecutionMeta;
|
|
154
|
+
children: GraphNode[];
|
|
155
|
+
} | {
|
|
156
|
+
type: "run";
|
|
157
|
+
meta: GraphRunMeta;
|
|
158
|
+
id: EntryID;
|
|
159
|
+
dependencies: GraphRunDeps;
|
|
160
|
+
};
|
|
161
|
+
declare const Node$: unique symbol;
|
|
162
|
+
type Composable = Composer | Runnable;
|
|
163
|
+
type Composer = {
|
|
164
|
+
/**
|
|
165
|
+
* Execution Graph Node
|
|
166
|
+
* @private
|
|
167
|
+
* @internal
|
|
168
|
+
*/
|
|
169
|
+
[Node$]: ComposeInner;
|
|
170
|
+
run: () => Promise<Scope>;
|
|
171
|
+
guard: () => void;
|
|
172
|
+
graph: () => GraphNode;
|
|
173
|
+
meta: (meta: Partial<ComposeMeta>) => Composer;
|
|
174
|
+
step: (compose: Composable | Composable[]) => Composer;
|
|
175
|
+
};
|
|
176
|
+
declare const compose: () => Composer;
|
|
177
|
+
declare const is: {
|
|
178
|
+
spot: (x: unknown) => x is Spot<unknown>;
|
|
179
|
+
tag: (x: unknown) => x is Tag<unknown>;
|
|
180
|
+
runnable: (x: unknown) => x is Runnable;
|
|
181
|
+
task: (x: unknown) => x is Task<unknown>;
|
|
182
|
+
wire: (x: unknown) => x is Wire;
|
|
183
|
+
};
|
|
184
|
+
export { type ComposeEvent, type ComposeObserver, type Composer, type Spot, type SpotValue, type Tag, type Task, type TaskResult, type TaskStatus, type Wire, compose, createTask, createWire, is, literal, optional, shape, tag };
|
|
185
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/computable/definition.ts","../src/shared.ts","../src/computable/context.ts","../src/computable/literal.ts","../src/computable/optional.ts","../src/computable/reference.ts","../src/computable/shape.ts","../src/runnable/definition.ts","../src/runnable/task.ts","../src/runnable/wire.ts","../src/compose/observer.ts","../src/compose/definition.ts","../src/compose/graph.ts","../src/compose/compose.ts","../src/is.ts"],"mappings":"A,cAAM;cACA;KAWD,KAAK;GAAQ;GAAe,YAAY;;KACxC,UAAU,UAAU,aAAa,UAAU,WAAW,KAAK;KCb3D,WAAW;KACX,SAAS,KAAK,QAAQ,KAAK;KAE3B,+DAMD,QACA,OACA,SACA,YACA,aACA,oBACA,aACA,cACA,aACA,cACA,eACA,eACA,gCACA,uBACA,2BACA,kBACA,cACA,WACA,WACA,mBACA;YACY,OAAO;;KC3BlB,cAAc,MAAM,YAAY,iBAAiB,KAAK,KAAK,KAAK,KA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