foldkit-bundle-surface 0.3.1 → 0.4.0
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.d.mts +49 -482
- package/dist/index.d.mts.map +1 -1
- package/package.json +12 -12
package/dist/index.d.mts
CHANGED
|
@@ -1,497 +1,64 @@
|
|
|
1
|
-
import { Option,
|
|
1
|
+
import { Option, Schema } from "effect";
|
|
2
2
|
import { AnyMessage, AnyPlaced, AnyPlacedCollection, AnyWiring, Bundle, Link, Wrapper } from "foldkit-bundle";
|
|
3
3
|
import { AppScope, Contract, FieldRef, Module, ModuleItem } from "foldkit-surface";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import { Html, HtmlBuilder } from "foldkit/html";
|
|
10
|
-
import "foldkit/url";
|
|
11
|
-
import "foldkit/message";
|
|
12
|
-
//#region ../bundle/src/placed.d.ts
|
|
13
|
-
declare const PlacedTypeId: unique symbol;
|
|
14
|
-
/**
|
|
15
|
-
* Args for a placement: a static value, or a factory deriving them from the
|
|
16
|
-
* parent seed — the fields `assembly.initial(rest)` was given, before any
|
|
17
|
-
* placement initialised. A factory runs once per initialization and its result
|
|
18
|
-
* is retained for the placement's `init`, `update`, helpers, Subscriptions,
|
|
19
|
-
* and resources; it never re-runs against changing parent state, so keep it
|
|
20
|
-
* pure of its seed.
|
|
21
|
-
*
|
|
22
|
-
* When no initialization ran — a hand-built Model in a test, which never went
|
|
23
|
-
* through `initial` — `update` derives from the given parent per use, without
|
|
24
|
-
* retaining, so each Model is folded with its own seed.
|
|
25
|
-
*
|
|
26
|
-
* Read only seed fields (route, auth, workspace, ...), never sibling
|
|
27
|
-
* placement fields: every factory sees the same base seed, so a sibling read
|
|
28
|
-
* is consistently absent rather than order-dependent.
|
|
29
|
-
*/
|
|
30
|
-
type ArgsSource<Seed, Args> = Args | ((seed: Seed) => Args);
|
|
31
|
-
interface PlaceConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, ParentSeed = Parent> {
|
|
32
|
-
/**
|
|
33
|
-
* The bundle's args: a static value, or a factory from the parent seed (the
|
|
34
|
-
* fields `assembly.initial(rest)` was given, minus this placement's own
|
|
35
|
-
* field). A factory is computed once per initialization and retained for
|
|
36
|
-
* `init`, `update`, and helpers. Subscriptions and resources built from it
|
|
37
|
-
* require `initial`/`config` to have run first; a bundle with neither
|
|
38
|
-
* contributes empty records either way.
|
|
39
|
-
*/
|
|
40
|
-
readonly args?: ArgsSource<ParentSeed, Args>;
|
|
41
|
-
/** Handles the child's OutMessage in parent terms, with the child already written back. */
|
|
42
|
-
readonly onOut?: (outMessage: OutMessage, context: Update.FoldContext<Message, LinkMessage>) => Update.Step<NoInfer<Parent>, OutStepMessage, R2>;
|
|
43
|
-
/**
|
|
44
|
-
* Observes each of the child's Messages in parent terms, after the child has
|
|
45
|
-
* handled it and its `onOut` has run, so the parent's own update needs no arm
|
|
46
|
-
* for the wrapper. Helpers are not Messages and do not reach it.
|
|
47
|
-
*/
|
|
48
|
-
readonly onMessage?: (message: Message) => Update.Step<NoInfer<Parent>, OutStepMessage, R2>;
|
|
49
|
-
/** Prefix for the placement's Subscription and resource keys. Defaults to `Name@path`. */
|
|
50
|
-
readonly key?: string;
|
|
51
|
-
/** A gate beside the Link's own: Subscriptions and resources run only while both hold. */
|
|
52
|
-
readonly when?: (parent: Parent) => boolean;
|
|
53
|
-
}
|
|
54
|
-
/** A lifted resource record: each child entry in parent terms, keyed by the placement. */
|
|
55
|
-
type PlacedResources<Parent, ParentMessage, Resources> = Readonly<Record<string, { readonly [K in keyof Resources]: Resources[K] extends ManagedResource.Entry<any, any, infer Requirements, infer Value, infer Service, infer OnAcquired extends (...args: ReadonlyArray<any>) => any> ? ManagedResource.Entry<Parent, ParentMessage, Requirements, Value, Service, (...args: Parameters<OnAcquired>) => ParentMessage> : never; }[keyof Resources]>>;
|
|
56
|
-
type PlacedHelpers<Parent, ParentMessage, R, Helpers> = { readonly [K in keyof Helpers]: Helpers[K] extends ((model: any, ...input: infer Input) => any) ? (...input: Input) => Update.Step<Parent, ParentMessage, R> : never; };
|
|
57
|
-
interface Placed<Name extends string, Parent, ParentMessage, Model, Message, R, S, ViewInputs, Resources, Helpers, Field extends string = string, Claimed extends string = string> {
|
|
58
|
-
readonly [PlacedTypeId]: typeof PlacedTypeId;
|
|
59
|
-
/** Types only: the top-level Model field this placement owns, or `string` when unknown. */
|
|
60
|
-
readonly field?: Field;
|
|
61
|
-
/** Types only: the parent Message tag this placement routes, or `string` when unknown. */
|
|
62
|
-
readonly claims?: Claimed;
|
|
63
|
-
readonly name: Name;
|
|
64
|
-
/** `Name@path`, or the configured `key`: the prefix of every Subscription and resource key. */
|
|
65
|
-
readonly key: string;
|
|
66
|
-
/** The encoded args as text, when the bundle has an args Schema. */
|
|
67
|
-
readonly argsSummary: string | undefined;
|
|
68
|
-
/** Whether `args` was given as a seed factory; resolved once per initialization. */
|
|
69
|
-
readonly hasDynamicArgs: boolean;
|
|
70
|
-
/**
|
|
71
|
-
* Derives the factory's args from `seed`, validates them against the
|
|
72
|
-
* bundle's args Schema, and retains them for `init`, `update`, helpers,
|
|
73
|
-
* Subscriptions, and resources. A no-op for static args. The assembly calls
|
|
74
|
-
* this with the base seed before running inits, so every factory sees the
|
|
75
|
-
* same parent state whatever the placement order.
|
|
76
|
-
*/
|
|
77
|
-
readonly resolveArgs: (seed: unknown) => void;
|
|
78
|
-
/**
|
|
79
|
-
* Assembly use: marks the placement skipped because `rest` provides its
|
|
80
|
-
* top-level field, so its factory never runs and its records contribute
|
|
81
|
-
* nothing while the child is absent. Cleared by the next `resolveArgs`.
|
|
82
|
-
*/
|
|
83
|
-
readonly skipArgs: () => void;
|
|
84
|
-
readonly link: Link$1<Parent, ParentMessage, Model, Message>;
|
|
85
|
-
/** Writes the child's initial Model and starts its `init` Commands. */
|
|
86
|
-
readonly init: Update.Step<Parent, ParentMessage, R>;
|
|
87
|
-
/** Folds the Message when it belongs to this placement; `None` otherwise. */
|
|
88
|
-
readonly update: (parent: Parent, message: AnyMessage$1) => Option.Option<Update.Return<Parent, ParentMessage, R>>;
|
|
89
|
-
readonly subscriptions: Subscription.Subscriptions<Parent, ParentMessage, S>;
|
|
90
|
-
readonly resources: PlacedResources<Parent, ParentMessage, Resources>;
|
|
91
|
-
/**
|
|
92
|
-
* Renders the child through `h.submodel`; nothing while the child is absent.
|
|
93
|
-
* Generic over the parent's whole Message, which must include this placement's.
|
|
94
|
-
*/
|
|
95
|
-
readonly view: PlacedView<Parent, ParentMessage, ViewInputs>;
|
|
96
|
-
/**
|
|
97
|
-
* The same view in another slot, for rendering one placement in two DOM
|
|
98
|
-
* positions (desktop and mobile). `h.submodel` throws on a repeated slot.
|
|
99
|
-
*/
|
|
100
|
-
readonly viewIn: (slot: string) => PlacedView<Parent, ParentMessage, ViewInputs>;
|
|
101
|
-
readonly helpers: PlacedHelpers<Parent, ParentMessage, R, Helpers>;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* What a placement's view needs of a builder: `submodel`, and `OnClick` to
|
|
105
|
-
* read its Message from. A wrapper of Foldkit's builder that keeps both, such
|
|
106
|
-
* as `foldkit-ssr`'s resumable builder, is one.
|
|
107
|
-
*/
|
|
108
|
-
type BuilderLike = Pick<HtmlBuilder<any>, 'submodel' | 'OnClick'>;
|
|
109
|
-
type PlacedView<Parent, ParentMessage, ViewInputs> = [ViewInputs] extends [void] ? <H extends BuilderLike>(parent: Parent, h: ViewBuilder<H, ParentMessage>) => Html : <H extends BuilderLike>(parent: Parent, h: ViewBuilder<H, ParentMessage>, viewInputs: ViewInputs) => Html;
|
|
110
|
-
/** A readable type error: intersected onto a parameter, its message names the fix. */
|
|
111
|
-
interface Invalid<Message extends string> {
|
|
112
|
-
readonly invalid: Message;
|
|
113
|
-
}
|
|
114
|
-
type BuilderMessage<H> = H extends {
|
|
115
|
-
readonly OnClick: (message: infer M, ...rest: any) => any;
|
|
116
|
-
} ? M : never;
|
|
117
|
-
/**
|
|
118
|
-
* The parent's `h`, checked to accept this placement's Messages. Generic over the
|
|
119
|
-
* whole builder rather than its Message: inferring a Message through
|
|
120
|
-
* `HtmlBuilder` costs thousands of type instantiations per call, while the
|
|
121
|
-
* builder infers as itself and its Message is extracted once per builder type.
|
|
122
|
-
*/
|
|
123
|
-
type ViewBuilder<H, ParentMessage> = H & ([ParentMessage] extends [BuilderMessage<H>] ? unknown : Invalid<"The parent Message does not include this placement's wrapper variant; spread its Link.wrapper(...).cases into defineMessageUnion">);
|
|
124
|
-
/** The tag of a Link's parent variant, or `string` when it cannot be read. */
|
|
125
|
-
type TagOf<LinkMessage> = LinkMessage extends {
|
|
126
|
-
readonly _tag: infer Tag extends string;
|
|
127
|
-
} ? Tag : string;
|
|
128
|
-
//#endregion
|
|
129
|
-
//#region ../bundle/src/link.d.ts
|
|
130
|
-
declare const LinkTypeId: unique symbol;
|
|
131
|
-
/** The parent Message variant `Tag({ message })` that carries a child's Messages. */
|
|
132
|
-
type Wrapped<Tag extends string, ChildMessage> = {
|
|
133
|
-
readonly _tag: Tag;
|
|
134
|
-
readonly message: ChildMessage;
|
|
135
|
-
};
|
|
136
|
-
/**
|
|
137
|
-
* Both directions between a child Message and its parent variant. Spread
|
|
138
|
-
* `cases` into the parent's `defineMessageUnion` so the variant is part of the
|
|
139
|
-
* parent Message.
|
|
140
|
-
*/
|
|
141
|
-
interface Wrapper$1<Tag extends string, ChildMessage> {
|
|
142
|
-
readonly tag: Tag;
|
|
143
|
-
readonly Schema: CallableTaggedStruct<Tag, {
|
|
144
|
-
readonly message: Schema.Codec<ChildMessage, unknown>;
|
|
145
|
-
}>;
|
|
146
|
-
readonly cases: { readonly [K in Tag]: {
|
|
147
|
-
readonly message: Schema.Codec<ChildMessage, unknown>;
|
|
148
|
-
}; };
|
|
149
|
-
readonly make: (message: ChildMessage) => Wrapped<Tag, ChildMessage>;
|
|
150
|
-
readonly toParentMessage: (message: ChildMessage) => Wrapped<Tag, ChildMessage>;
|
|
151
|
-
readonly fromParentMessage: (message: AnyMessage$1) => Option.Option<ChildMessage>;
|
|
152
|
-
}
|
|
153
|
-
/** Every Foldkit Message is tagged; routing only needs the tag. */
|
|
154
|
-
type AnyMessage$1 = {
|
|
155
|
-
readonly _tag: string;
|
|
156
|
-
};
|
|
157
|
-
/**
|
|
158
|
-
* `Field` is the parent's top-level field the child is written into, when the
|
|
159
|
-
* Link is one: `never` for a child nested deeper, and `string` when unknown.
|
|
160
|
-
*/
|
|
161
|
-
interface Link$1<Parent, ParentMessage, Child, ChildMessage, Field extends string = string> extends Pipeable.Pipeable {
|
|
162
|
-
readonly [LinkTypeId]: typeof LinkTypeId;
|
|
163
|
-
/** Types only: the top-level field, so `placements.initial` knows who writes it. */
|
|
164
|
-
readonly field?: Field;
|
|
165
|
-
readonly read: (parent: Parent) => Option.Option<Child>;
|
|
166
|
-
readonly write: (parent: Parent, child: Child) => Parent;
|
|
167
|
-
readonly toParentMessage: (message: ChildMessage) => ParentMessage;
|
|
168
|
-
/** Recognises this child's variant among all of the parent's Messages. */
|
|
169
|
-
readonly fromParentMessage: (message: AnyMessage$1) => Option.Option<ChildMessage>;
|
|
170
|
-
/** The parent's own gate: while it returns `false`, the child's Subscriptions and resources stop. */
|
|
171
|
-
readonly when: Option.Option<(parent: Parent) => boolean>;
|
|
172
|
-
/** Where the child lives, for placement keys and diagnostics. */
|
|
173
|
-
readonly path: ReadonlyArray<string>;
|
|
174
|
-
/** The parent Message tags this link's Messages travel under, outermost first. */
|
|
175
|
-
readonly messages: ReadonlyArray<string>;
|
|
176
|
-
/** The application a Link built from a Surface field ref belongs to, for its Module contract. */
|
|
177
|
-
readonly owner?: object | undefined;
|
|
178
|
-
}
|
|
179
|
-
/** A Message union's variant `Tag({ message })`, as `defineMessageUnion` declares it. */
|
|
180
|
-
type Variant = {
|
|
181
|
-
readonly fields: {
|
|
182
|
-
readonly _tag: Schema.tag<string>;
|
|
183
|
-
readonly message: Schema.Top;
|
|
184
|
-
};
|
|
4
|
+
//#region src/index.d.ts
|
|
5
|
+
type AnyPlacement = AnyPlaced | AnyPlacedCollection;
|
|
6
|
+
/** What an assembly lists: placements, collections, and integration wiring. */
|
|
7
|
+
type AssemblyItems = {
|
|
8
|
+
readonly placements: ReadonlyArray<AnyPlacement | AnyWiring>;
|
|
185
9
|
};
|
|
186
|
-
type VariantTag<V extends Variant> = V['fields']['_tag'] extends Schema.tag<infer Tag extends string> ? Tag : never;
|
|
187
|
-
type OnlyMessage<V extends Variant> = [Exclude<keyof V['fields'], '_tag' | 'message'>] extends [never] ? unknown : Invalid<'A wrapper variant carries only `message`; this variant has other fields'>;
|
|
188
10
|
/**
|
|
189
|
-
*
|
|
190
|
-
* the
|
|
191
|
-
*
|
|
11
|
+
* A Link from a Surface field ref: `App.model.search`. The contract of a
|
|
12
|
+
* placement through it names the ref's application, so placing a child through
|
|
13
|
+
* another application's ref is a `foreign-contract` finding.
|
|
192
14
|
*/
|
|
193
|
-
declare
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
readonly read: (parent: Parent) => Option.Option<Child>;
|
|
197
|
-
readonly write: (parent: Parent, child: Child) => Parent;
|
|
198
|
-
readonly wrapper: Wrapper$1<Tag, ChildMessage>;
|
|
199
|
-
readonly when?: (parent: Parent) => boolean;
|
|
200
|
-
readonly path: Path;
|
|
201
|
-
readonly owner?: object | undefined;
|
|
202
|
-
}
|
|
15
|
+
declare const link: <Root, Value, const Tag extends string, ChildMessage>(ref: FieldRef<Root, Value>, wrapper: Wrapper<Tag, ChildMessage>, options?: {
|
|
16
|
+
readonly when?: (parent: Root) => boolean;
|
|
17
|
+
}) => Link<Root, import("foldkit-bundle").Wrapped<Tag, ChildMessage>, Value, ChildMessage, string>;
|
|
203
18
|
/**
|
|
204
|
-
* The
|
|
205
|
-
*
|
|
19
|
+
* The contract of one placement or collection: it owns its Model path and names
|
|
20
|
+
* the parent Message tags its Messages travel under.
|
|
206
21
|
*/
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
/** The parent Message variant `Tag({ key, message })` that carries one collection item's Messages. */
|
|
211
|
-
type KeyedWrapped<Tag extends string, ChildMessage, Key extends string = string> = {
|
|
212
|
-
readonly _tag: Tag;
|
|
213
|
-
readonly key: Key;
|
|
214
|
-
readonly message: ChildMessage;
|
|
215
|
-
};
|
|
216
|
-
type KeyedFields<ChildMessage, Key extends string> = {
|
|
217
|
-
readonly key: Schema.Codec<Key, string>;
|
|
218
|
-
readonly message: Schema.Codec<ChildMessage, unknown>;
|
|
219
|
-
};
|
|
220
|
-
/** Both directions between an item's Message and its keyed parent variant. */
|
|
221
|
-
interface KeyedWrapper<Tag extends string, ChildMessage, Key extends string = string> {
|
|
222
|
-
readonly tag: Tag;
|
|
223
|
-
readonly Schema: CallableTaggedStruct<Tag, KeyedFields<ChildMessage, Key>>;
|
|
224
|
-
readonly cases: { readonly [K in Tag]: KeyedFields<ChildMessage, Key>; };
|
|
225
|
-
readonly make: (key: Key, message: ChildMessage) => KeyedWrapped<Tag, ChildMessage, Key>;
|
|
226
|
-
readonly fromParentMessage: (message: AnyMessage$1) => Option.Option<readonly [key: Key, message: ChildMessage]>;
|
|
227
|
-
}
|
|
22
|
+
declare const contract: <Root, F extends Schema.Struct.Fields, Cases extends Record<string, Schema.Struct.Fields>>(app: AppScope<Root, F, Cases>, placement: AnyPlacement) => Contract;
|
|
23
|
+
/** A Module of an assembly's placements and wiring, plus any other contracts of the application. */
|
|
24
|
+
declare const module: <Root, F extends Schema.Struct.Fields, Cases extends Record<string, Schema.Struct.Fields>>(app: AppScope<Root, F, Cases>, assembly: AssemblyItems, items?: readonly ModuleItem<Root>[]) => Module<Root, F, Cases>;
|
|
228
25
|
/**
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
* operations. `entries` is the order views and Subscriptions follow.
|
|
26
|
+
* The parent scope of `foldkit-bundle`, built from a Surface application, with
|
|
27
|
+
* `module` bound to it: `const Page = BundleSurface.parent(App)`.
|
|
232
28
|
*/
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
readonly make: <Parent, const Tag extends string, Child, ChildMessage, const Path extends ReadonlyArray<string> = readonly string[]>(config: MakeConfig<Parent, Tag, Child, ChildMessage, Path>) => Link$1<Parent, Wrapped<Tag, ChildMessage>, Child, ChildMessage, FieldOfPath<Path>>;
|
|
257
|
-
readonly field: <Parent>() => <const Key extends keyof Parent & string, const Tag extends string, ChildMessage>(key: Key, wrap: Wrapper$1<Tag, ChildMessage>, options?: {
|
|
258
|
-
readonly when?: (parent: Parent) => boolean;
|
|
259
|
-
}) => Link$1<Parent, Wrapped<Tag, ChildMessage>, Parent[Key], ChildMessage, Key>;
|
|
260
|
-
readonly optional: <Parent>() => <const Key extends OptionKeys<Parent>, const Tag extends string, ChildMessage>(key: Key, wrap: Wrapper$1<Tag, ChildMessage>, options?: {
|
|
261
|
-
readonly when?: (parent: Parent) => boolean;
|
|
262
|
-
}) => Link$1<Parent, Wrapped<Tag, ChildMessage>, OptionValue<Parent[Key]>, ChildMessage, Key>;
|
|
263
|
-
readonly compose: <A, AMessage, B, BMessage extends AnyMessage$1, C, CMessage>(outer: Link$1<A, AMessage, B, BMessage, string>, inner: Link$1<B, BMessage, C, CMessage, string>) => Link$1<A, AMessage, C, CMessage, never>;
|
|
264
|
-
readonly andThen: {
|
|
265
|
-
<B, BMessage extends AnyMessage$1, C, CMessage>(inner: Link$1<B, BMessage, C, CMessage, string>): <A, AMessage>(outer: Link$1<A, AMessage, B, BMessage, string>) => Link$1<A, AMessage, C, CMessage, never>;
|
|
266
|
-
<A, AMessage, B, BMessage extends AnyMessage$1, C, CMessage>(outer: Link$1<A, AMessage, B, BMessage, string>, inner: Link$1<B, BMessage, C, CMessage, string>): Link$1<A, AMessage, C, CMessage, never>;
|
|
267
|
-
};
|
|
268
|
-
readonly when: {
|
|
269
|
-
<Parent>(predicate: (parent: Parent) => boolean): <ParentMessage, Child, ChildMessage, Field extends string>(self: Link$1<Parent, ParentMessage, Child, ChildMessage, Field>) => Link$1<Parent, ParentMessage, Child, ChildMessage, Field>;
|
|
270
|
-
<Parent, ParentMessage, Child, ChildMessage, Field extends string>(self: Link$1<Parent, ParentMessage, Child, ChildMessage, Field>, predicate: (parent: Parent) => boolean): Link$1<Parent, ParentMessage, Child, ChildMessage, Field>;
|
|
271
|
-
};
|
|
272
|
-
readonly foldInit: <Parent, ParentMessage, Child, ChildMessage, Field extends string>(link: Link$1<Parent, ParentMessage, Child, ChildMessage, Field>, rest: Omit<Parent, Field>) => {
|
|
273
|
-
readonly toParentModel: (child: Child) => Parent;
|
|
274
|
-
readonly toParentMessage: (message: ChildMessage) => ParentMessage;
|
|
29
|
+
declare const parent: <Root, F extends Schema.Struct.Fields, Cases extends Record<string, Schema.Struct.Fields>>(app: AppScope<Root, F, Cases>) => {
|
|
30
|
+
Model: Schema.Codec<Root, unknown, never, never>;
|
|
31
|
+
Message: Schema.Codec<Schema.Schema.Type<import("foldkit/message").MessageUnion<Cases>> & AnyMessage, unknown, never, never>;
|
|
32
|
+
withServices: <S>() => Bundle.Parent<Root, Schema.Schema.Type<import("foldkit/message").MessageUnion<Cases>> & AnyMessage, S>;
|
|
33
|
+
at: <B extends Bundle.AnyBundle, const Field extends { [K in keyof Root]: [Root[K]] extends [Bundle.BundleParts<B>["Model"]] ? [Bundle.BundleParts<B>["Model"]] extends [Root[K]] ? K : never : never; }[keyof Root] & string, OutStepMessage = never, R2 = never>(declared: Bundle.Declared<B, Field>, ...config: Bundle.PlaceConfigParam<Bundle.BundleParts<B>["Args"], Root, import("foldkit-bundle").Wrapped<`Got${Capitalize<Field>}Message`, Bundle.BundleParts<B>["Message"]>, Bundle.BundleParts<B>["Message"], Bundle.BundleParts<B>["OutMessage"], OutStepMessage, R2, Omit<Root, Field>> & ([import("foldkit-bundle").Wrapped<`Got${Capitalize<Field>}Message`, Bundle.BundleParts<B>["Message"]>] extends [Schema.Schema.Type<import("foldkit/message").MessageUnion<Cases>> & AnyMessage] ? unknown : import("foldkit-bundle").Invalid<"The parent Message does not include this placement's wrapper variant; spread its cases into defineMessageUnion">)) => import("foldkit-bundle").PlacedBy<B, Root, import("foldkit-bundle").Wrapped<`Got${Capitalize<Field>}Message`, Bundle.BundleParts<B>["Message"]>, OutStepMessage, R2, Field>;
|
|
34
|
+
place: <B extends Bundle.AnyBundle, const Field extends { [K in keyof Root]: [Root[K]] extends [Bundle.BundleParts<B>["Model"]] ? [Bundle.BundleParts<B>["Model"]] extends [Root[K]] ? K : never : never; }[keyof Root] & string, OutStepMessage = never, R2 = never>(bundle: B, field: Field, ...config: Bundle.PlaceConfigParam<Bundle.BundleParts<B>["Args"], Root, import("foldkit-bundle").Wrapped<`Got${Capitalize<Field>}Message`, Bundle.BundleParts<B>["Message"]>, Bundle.BundleParts<B>["Message"], Bundle.BundleParts<B>["OutMessage"], OutStepMessage, R2, Omit<Root, Field>> & ([import("foldkit-bundle").Wrapped<`Got${Capitalize<Field>}Message`, Bundle.BundleParts<B>["Message"]>] extends [Schema.Schema.Type<import("foldkit/message").MessageUnion<Cases>> & AnyMessage] ? unknown : import("foldkit-bundle").Invalid<"The parent Message does not include this placement's wrapper variant; spread its cases into defineMessageUnion">)) => import("foldkit-bundle").PlacedBy<B, Root, import("foldkit-bundle").Wrapped<`Got${Capitalize<Field>}Message`, Bundle.BundleParts<B>["Message"]>, OutStepMessage, R2, Field>;
|
|
35
|
+
each: <B extends Bundle.AnyBundle, const Field extends { [K in keyof Root]: Root[K] extends Readonly<Record<string, infer V>> ? [V] extends [Bundle.BundleParts<B>["Model"]] ? [Bundle.BundleParts<B>["Model"]] extends [V] ? K : never : never : never; }[keyof Root] & string, OutStepMessage = never, R2 = never>(declared: Bundle.DeclaredEach<B, Field>, ...config: Bundle.EachConfigParam<Bundle.BundleParts<B>["Args"], Root, import("foldkit-bundle").KeyedWrapped<`Got${Capitalize<Field>}Message`, Bundle.BundleParts<B>["Message"]>, Bundle.BundleParts<B>["Message"], Bundle.BundleParts<B>["OutMessage"], OutStepMessage, R2, string, Omit<Root, Field>> & ([import("foldkit-bundle").KeyedWrapped<`Got${Capitalize<Field>}Message`, Bundle.BundleParts<B>["Message"]>] extends [Schema.Schema.Type<import("foldkit/message").MessageUnion<Cases>> & AnyMessage] ? unknown : import("foldkit-bundle").Invalid<"The parent Message does not include this placement's wrapper variant; spread its cases into defineMessageUnion">)) => import("foldkit-bundle").CollectionBy<B, Root, import("foldkit-bundle").KeyedWrapped<`Got${Capitalize<Field>}Message`, Bundle.BundleParts<B>["Message"]>, OutStepMessage, R2, Field>;
|
|
36
|
+
placeEach: <B extends Bundle.AnyBundle, const Field extends { [K in keyof Root]: Root[K] extends Readonly<Record<string, infer V>> ? [V] extends [Bundle.BundleParts<B>["Model"]] ? [Bundle.BundleParts<B>["Model"]] extends [V] ? K : never : never : never; }[keyof Root] & string, OutStepMessage = never, R2 = never>(bundle: B & import("foldkit-bundle").WithoutResources<B>, field: Field, ...config: Bundle.EachConfigParam<Bundle.BundleParts<B>["Args"], Root, import("foldkit-bundle").KeyedWrapped<`Got${Capitalize<Field>}Message`, Bundle.BundleParts<B>["Message"]>, Bundle.BundleParts<B>["Message"], Bundle.BundleParts<B>["OutMessage"], OutStepMessage, R2, string, Omit<Root, Field>> & ([import("foldkit-bundle").KeyedWrapped<`Got${Capitalize<Field>}Message`, Bundle.BundleParts<B>["Message"]>] extends [Schema.Schema.Type<import("foldkit/message").MessageUnion<Cases>> & AnyMessage] ? unknown : import("foldkit-bundle").Invalid<"The parent Message does not include this placement's wrapper variant; spread its cases into defineMessageUnion">)) => import("foldkit-bundle").CollectionBy<B, Root, import("foldkit-bundle").KeyedWrapped<`Got${Capitalize<Field>}Message`, Bundle.BundleParts<B>["Message"]>, OutStepMessage, R2, Field>;
|
|
37
|
+
assemble: <const Ps extends ReadonlyArray<import("foldkit-bundle").Placed<string, Root, Schema.Schema.Type<import("foldkit/message").MessageUnion<Cases>> & AnyMessage, any, any, any, any, any, any, any> | import("foldkit-bundle").PlacedCollection<string, Root, Schema.Schema.Type<import("foldkit/message").MessageUnion<Cases>> & AnyMessage, any, any, any, any, any, any, any, any> | import("foldkit-bundle").Wiring<Root, Schema.Schema.Type<import("foldkit/message").MessageUnion<Cases>> & AnyMessage, any>>>(...items: Ps) => Bundle.Assembly<Root, Schema.Schema.Type<import("foldkit/message").MessageUnion<Cases>> & AnyMessage, Ps, never>;
|
|
38
|
+
link: {
|
|
39
|
+
readonly field: <const Key extends keyof Root & string, const Tag extends string, ChildMessage>(key: Key, wrapper: Wrapper<Tag, ChildMessage>, options?: {
|
|
40
|
+
readonly when?: (parent: Root) => boolean;
|
|
41
|
+
} | undefined) => Link<Root, import("foldkit-bundle").Wrapped<Tag, ChildMessage>, Root[Key], ChildMessage, Key>;
|
|
42
|
+
readonly optional: <const Key extends { [K in keyof Root]: Root[K] extends Option.Option<unknown> ? K : never; }[keyof Root] & string, const Tag extends string, ChildMessage>(key: Key, wrap: Wrapper<Tag, ChildMessage>, options?: {
|
|
43
|
+
readonly when?: (parent: Root) => boolean;
|
|
44
|
+
} | undefined) => Link<Root, import("foldkit-bundle").Wrapped<Tag, ChildMessage>, Root[Key] extends (infer T) ? T extends Root[Key] ? T extends Option.Option<infer Value> ? Value : never : never : never, ChildMessage, Key>;
|
|
45
|
+
readonly collection: <const Field extends { [K in keyof Root]: Root[K] extends Readonly<Record<string, unknown>> ? K : never; }[keyof Root] & string, const Tag extends string, ChildMessage, Key extends string>(field: Field, wrap: import("foldkit-bundle").KeyedWrapper<Tag, ChildMessage, Key>, options?: {
|
|
46
|
+
readonly when?: (parent: Root, key: Key) => boolean;
|
|
47
|
+
} | undefined) => import("foldkit-bundle").CollectionLink<Root, import("foldkit-bundle").KeyedWrapped<Tag, ChildMessage, Key>, Root[Field] extends (infer T) ? T extends Root[Field] ? T extends Readonly<Record<string, infer Value>> ? Value : never : never : never, ChildMessage, Key, Field>;
|
|
48
|
+
readonly collectionById: <const Field extends { [K in keyof Root]: Root[K] extends readonly unknown[] ? K : never; }[keyof Root] & string, const Tag extends string, ChildMessage, Key extends string>(field: Field, wrap: import("foldkit-bundle").KeyedWrapper<Tag, ChildMessage, Key>, options: {
|
|
49
|
+
readonly id: (item: Root[Field] extends (infer T) ? T extends Root[Field] ? T extends readonly (infer Item)[] ? Item : never : never : never) => Key;
|
|
50
|
+
readonly when?: (parent: Root, key: Key) => boolean;
|
|
51
|
+
}) => import("foldkit-bundle").CollectionLink<Root, import("foldkit-bundle").KeyedWrapped<Tag, ChildMessage, Key>, Root[Field] extends (infer T) ? T extends Root[Field] ? T extends readonly (infer Item)[] ? Item : never : never : never, ChildMessage, Key, Field>;
|
|
275
52
|
};
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
readonly when?: (parent: Parent, key: Key) => boolean;
|
|
279
|
-
}) => CollectionLink<Parent, KeyedWrapped<Tag, ChildMessage, Key>, RecordValue<Parent[Field]>, ChildMessage, Key, Field>;
|
|
280
|
-
readonly collectionById: <Parent>() => <const Field extends ArrayKeys<Parent>, const Tag extends string, ChildMessage, Key extends string>(field: Field, wrap: KeyedWrapper<Tag, ChildMessage, Key>, options: {
|
|
281
|
-
readonly id: (item: ArrayItem<Parent[Field]>) => Key;
|
|
282
|
-
readonly when?: (parent: Parent, key: Key) => boolean;
|
|
283
|
-
}) => CollectionLink<Parent, KeyedWrapped<Tag, ChildMessage, Key>, ArrayItem<Parent[Field]>, ChildMessage, Key, Field>;
|
|
284
|
-
readonly child: <Parent, ParentMessage, Child, ChildMessage, Services>(link: Link$1<Parent, ParentMessage, Child, ChildMessage, string>, update: (model: Child, message: ChildMessage) => Update.Return<Child, ChildMessage, Services>, view: (model: Child, h: HtmlBuilder<ChildMessage>) => Html, slotId: string) => {
|
|
285
|
-
readonly update: (parent: Parent, message: ChildMessage) => Update.Return<Parent, ParentMessage, Services>;
|
|
286
|
-
readonly view: PlacedView<Parent, ParentMessage, void>;
|
|
287
|
-
};
|
|
288
|
-
};
|
|
289
|
-
//#endregion
|
|
290
|
-
//#region ../bundle/src/collection.d.ts
|
|
291
|
-
declare const PlacedCollectionTypeId: unique symbol;
|
|
292
|
-
interface EachConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key extends string = string, ParentSeed = Parent> {
|
|
293
|
-
/**
|
|
294
|
-
* The args every item's `init` and `update` receive: a static value, or a
|
|
295
|
-
* factory from the parent seed, computed once per initialization and
|
|
296
|
-
* retained. Adding items requires `initial`/`config` to have run; `update`
|
|
297
|
-
* on a Model no initialization produced derives per use instead.
|
|
298
|
-
*/
|
|
299
|
-
readonly args?: ArgsSource<ParentSeed, Args>;
|
|
300
|
-
/** Handles an item's OutMessage in parent terms, with the item already written back. */
|
|
301
|
-
readonly onOut?: (outMessage: OutMessage, key: Key, context: Update.FoldContext<Message, LinkMessage>) => Update.Step<NoInfer<Parent>, OutStepMessage, R2>;
|
|
302
|
-
/** Observes each item's Messages in parent terms, after the item has handled it and its `onOut` has run. */
|
|
303
|
-
readonly onMessage?: (message: Message, key: Key) => Update.Step<NoInfer<Parent>, OutStepMessage, R2>;
|
|
304
|
-
/** Prefix for the collection's Subscription keys. Defaults to `Name@path[]`. */
|
|
305
|
-
readonly key?: string;
|
|
306
|
-
readonly when?: (parent: Parent, key: Key) => boolean;
|
|
307
|
-
}
|
|
308
|
-
type CollectionView<Parent, ParentMessage, ViewInputs, Key extends string = string> = [ViewInputs] extends [void] ? <H extends BuilderLike>(parent: Parent, h: ViewBuilder<H, ParentMessage>, key: Key) => Html : <H extends BuilderLike>(parent: Parent, h: ViewBuilder<H, ParentMessage>, key: Key, viewInputs: ViewInputs) => Html;
|
|
309
|
-
type CollectionHelpers<Parent, ParentMessage, R, Helpers, Key extends string = string> = { readonly [K in keyof Helpers]: Helpers[K] extends ((model: any, ...input: infer Input) => any) ? (key: Key, ...input: Input) => Update.Step<Parent, ParentMessage, R> : never; };
|
|
310
|
-
interface PlacedCollection<Name extends string, Parent, ParentMessage, Model, Message, R, S, ViewInputs, Helpers, Field extends string = string, Key extends string = string, Claimed extends string = string> {
|
|
311
|
-
readonly [PlacedCollectionTypeId]: typeof PlacedCollectionTypeId;
|
|
312
|
-
/** Types only: the record field this collection owns, or `string` when unknown. */
|
|
313
|
-
readonly field?: Field;
|
|
314
|
-
/** Types only: the parent Message tag this collection routes, or `string` when unknown. */
|
|
315
|
-
readonly claims?: Claimed;
|
|
316
|
-
readonly name: Name;
|
|
317
|
-
/** `Name@path[]`, or the configured `key`: the prefix of every Subscription key. */
|
|
318
|
-
readonly key: string;
|
|
319
|
-
/** The encoded args as text, when the bundle has an args Schema. */
|
|
320
|
-
readonly argsSummary: string | undefined;
|
|
321
|
-
/** Whether `args` was given as a seed factory; resolved once per initialization. */
|
|
322
|
-
readonly hasDynamicArgs: boolean;
|
|
323
|
-
/**
|
|
324
|
-
* Derives the factory's args from `seed` and retains them for `add`,
|
|
325
|
-
* `update`, and Subscriptions. A no-op for static args.
|
|
326
|
-
*/
|
|
327
|
-
readonly resolveArgs: (seed: unknown) => void;
|
|
328
|
-
readonly link: CollectionLink<Parent, ParentMessage, Model, Message, Key>;
|
|
329
|
-
/** Folds the Message into its item; `None` when it is not this collection's. A missing key leaves the parent unchanged. */
|
|
330
|
-
readonly update: (parent: Parent, message: AnyMessage$1) => Option.Option<Update.Return<Parent, ParentMessage, R>>;
|
|
331
|
-
/**
|
|
332
|
-
* Writes a new item from `init` and starts its Commands. `prepare` adjusts the
|
|
333
|
-
* initial Model first, for what only the parent knows, such as the item's id.
|
|
334
|
-
* An existing item is replaced.
|
|
335
|
-
*/
|
|
336
|
-
readonly add: (key: Key, prepare?: (model: Model) => Model) => Update.Step<Parent, ParentMessage, R>;
|
|
337
|
-
/** Removes an item; its Subscriptions stop with it, and later Messages for it are ignored. */
|
|
338
|
-
readonly remove: (key: Key) => Update.Step<Parent, ParentMessage, never>;
|
|
339
|
-
readonly subscriptions: Subscription.Subscriptions<Parent, ParentMessage, S>;
|
|
340
|
-
/** One item's view; nothing when the key is missing. */
|
|
341
|
-
readonly view: CollectionView<Parent, ParentMessage, ViewInputs, Key>;
|
|
342
|
-
/** Every item's view, in the order of the Link's `entries`. */
|
|
343
|
-
readonly viewAll: <H extends BuilderLike>(parent: Parent, h: ViewBuilder<H, ParentMessage>, ...viewInputs: [ViewInputs] extends [void] ? [] : [viewInputs: ViewInputs]) => ReadonlyArray<Html>;
|
|
344
|
-
readonly helpers: CollectionHelpers<Parent, ParentMessage, R, Helpers, Key>;
|
|
345
|
-
}
|
|
346
|
-
//#endregion
|
|
347
|
-
//#region ../bundle/src/declare.d.ts
|
|
348
|
-
/** The type parameters of a Bundle, by name. */
|
|
349
|
-
type BundleParts<B> = B extends Bundle$1<infer Name, infer Args, infer Model, infer Message, infer OutMessage, infer R, infer S, infer ViewInputs, infer Resources, infer Helpers> ? {
|
|
350
|
-
Name: Name;
|
|
351
|
-
Args: Args;
|
|
352
|
-
Model: Model;
|
|
353
|
-
Message: Message;
|
|
354
|
-
OutMessage: OutMessage;
|
|
355
|
-
R: R;
|
|
356
|
-
S: S;
|
|
357
|
-
ViewInputs: ViewInputs;
|
|
358
|
-
Resources: Resources;
|
|
359
|
-
Helpers: Helpers;
|
|
360
|
-
} : never;
|
|
361
|
-
//#endregion
|
|
362
|
-
//#region ../bundle/src/bundle.d.ts
|
|
363
|
-
/**
|
|
364
|
-
* The parent seed a factory observes: the parent without the placement's own
|
|
365
|
-
* field, or the whole parent where the field is unknown (`string`).
|
|
366
|
-
*/
|
|
367
|
-
type SeedFor<Parent, Field extends string> = string extends Field ? Parent : Omit<Parent, Field>;
|
|
368
|
-
declare const BundleTypeId: unique symbol;
|
|
369
|
-
/** A child Managed Resource entry: its requirements are an `Option`, so the entry can release. */
|
|
370
|
-
type ResourceEntry<Model, Message> = ManagedResource.Entry<Model, Message, Option.Option<any>, any, any>;
|
|
371
|
-
type ResourceEntries<Model, Message> = Readonly<Record<string, ResourceEntry<Model, Message>>>;
|
|
372
|
-
/** A programmatic entry point, like `Dialog.open`: the child Model plus any input. */
|
|
373
|
-
type Helper<Model, Message, OutMessage, R> = (model: Model, ...input: ReadonlyArray<any>) => Update.ReturnWithOutMessage<Model, Message, OutMessage, R>;
|
|
374
|
-
interface BundleSpec<Name extends string, Args, Model, Message extends AnyMessage$1, OutMessage, R, S, ViewInputs, Resources extends ResourceEntries<Model, Message>, Helpers extends Readonly<Record<string, Helper<Model, Message, OutMessage, R>>>> {
|
|
375
|
-
readonly name: Name;
|
|
376
|
-
readonly Model: Schema.Codec<Model, unknown>;
|
|
377
|
-
readonly Message: Schema.Codec<Message, unknown>;
|
|
378
|
-
/**
|
|
379
|
-
* The args Schema. When given, `Args` is inferred from it, a placement's args
|
|
380
|
-
* are checked against it, and Module lists them.
|
|
381
|
-
*/
|
|
382
|
-
readonly args?: Schema.Codec<Args, unknown>;
|
|
383
|
-
/** Set by `with`: the bound args, encoded as text, for Module. */
|
|
384
|
-
readonly preset?: string | undefined;
|
|
385
|
-
/** Runs when the bundle is placed; its Commands start with the placement. */
|
|
386
|
-
readonly init: (args: Args) => Update.Return<Model, Message, R>;
|
|
387
|
-
readonly update: (model: Model, message: Message, args: Args) => Update.ReturnWithOutMessage<Model, Message, OutMessage, R>;
|
|
388
|
-
readonly subscriptions?: (args: Args) => Subscription.Subscriptions<Model, Message, S>;
|
|
389
|
-
readonly resources?: (args: Args) => Resources;
|
|
390
|
-
readonly view?: Submodel.View<Model, Message, ViewInputs>;
|
|
391
|
-
readonly helpers?: Helpers;
|
|
392
|
-
}
|
|
393
|
-
interface Bundle$1<Name extends string, Args, Model, Message extends AnyMessage$1, OutMessage, R, S, ViewInputs, Resources extends ResourceEntries<Model, Message>, Helpers extends Readonly<Record<string, Helper<Model, Message, OutMessage, R>>>> extends BundleSpec<Name, Args, Model, Message, OutMessage, R, S, ViewInputs, Resources, Helpers>, Pipeable.Pipeable {
|
|
394
|
-
readonly [BundleTypeId]: typeof BundleTypeId;
|
|
395
|
-
/**
|
|
396
|
-
* A preset: the same bundle with its args bound, so placements need no `args`.
|
|
397
|
-
* The args are checked against the args Schema when there is one.
|
|
398
|
-
*/
|
|
399
|
-
readonly with: (args: Args) => Bundle$1<Name, void, Model, Message, OutMessage, R, S, ViewInputs, Resources, Helpers>;
|
|
400
|
-
/** Places the bundle where `link` points. */
|
|
401
|
-
readonly at: <Parent, LinkMessage, Field extends string, OutStepMessage = never, R2 = never>(link: Link$1<Parent, LinkMessage, Model, Message, Field>, ...config: PlaceConfigParam<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, SeedFor<Parent, Field>>) => Placed<Name, Parent, LinkMessage | OutStepMessage, Model, Message, R | R2, S, ViewInputs, Resources, Helpers, Field, TagOf<LinkMessage>>;
|
|
402
|
-
/** Places the bundle once per key of the collection `link` points at. */
|
|
403
|
-
readonly each: [keyof Resources] extends [never] ? <Parent, LinkMessage, Key extends string, Field extends string, OutStepMessage = never, R2 = never>(link: CollectionLink<Parent, LinkMessage, Model, Message, Key, Field>, ...config: EachConfigParam<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key, SeedFor<Parent, Field>>) => PlacedCollection<Name, Parent, LinkMessage | OutStepMessage, Model, Message, R | R2, S, ViewInputs, Helpers, Field, Key, TagOf<LinkMessage>> : Invalid<'Bundle.each does not support Managed Resources yet: the runtime provides a resource by one tag, so items would share it'>;
|
|
404
|
-
}
|
|
405
|
-
/**
|
|
406
|
-
* What placing needs: `args` when `init` takes them, and `onOut` when the
|
|
407
|
-
* bundle has an OutMessage, so an OutMessage is never dropped by omission.
|
|
408
|
-
* `args` is a static value or a factory from the parent seed (the parent
|
|
409
|
-
* without this placement's own field); the seed type defaults to the whole
|
|
410
|
-
* parent where the field is unknown.
|
|
411
|
-
*/
|
|
412
|
-
type PlacementConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, ParentSeed = Parent> = {
|
|
413
|
-
/** Prefix for the placement's Subscription and resource keys. Defaults to `Name@path`. */
|
|
414
|
-
readonly key?: string;
|
|
415
|
-
/** A gate beside the Link's own: the child's Subscriptions and resources run only while both hold. */
|
|
416
|
-
readonly when?: (parent: Parent) => boolean;
|
|
417
|
-
/** Observes each of the child's Messages in parent terms, after the child handled it. */
|
|
418
|
-
readonly onMessage?: Required<PlaceConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, ParentSeed>>['onMessage'];
|
|
419
|
-
} & ([Args] extends [void] ? {
|
|
420
|
-
readonly args?: never;
|
|
421
|
-
} : {
|
|
422
|
-
readonly args: ArgsSource<ParentSeed, Args>;
|
|
423
|
-
}) & ([OutMessage] extends [never] ? {
|
|
424
|
-
readonly onOut?: never;
|
|
425
|
-
} : {
|
|
426
|
-
readonly onOut: Required<PlaceConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, ParentSeed>>['onOut'];
|
|
427
|
-
});
|
|
428
|
-
/** The config argument is optional only when it would be empty. */
|
|
429
|
-
type PlaceConfigParam<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, ParentSeed = Parent> = [Args] extends [void] ? [OutMessage] extends [never] ? [config?: PlacementConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, ParentSeed>] : [config: PlacementConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, ParentSeed>] : [config: PlacementConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, ParentSeed>];
|
|
430
|
-
type EachOptions<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key extends string = string, ParentSeed = Parent> = {
|
|
431
|
-
readonly key?: string;
|
|
432
|
-
/** A gate per item beside the Link's own: an item's Subscriptions run only while both hold. */
|
|
433
|
-
readonly when?: (parent: Parent, key: Key) => boolean;
|
|
434
|
-
/** Observes each item's Messages in parent terms, after the item handled it. */
|
|
435
|
-
readonly onMessage?: Required<EachConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key, ParentSeed>>['onMessage'];
|
|
436
|
-
} & ([Args] extends [void] ? {
|
|
437
|
-
readonly args?: never;
|
|
438
|
-
} : {
|
|
439
|
-
readonly args: ArgsSource<ParentSeed, Args>;
|
|
440
|
-
}) & ([OutMessage] extends [never] ? {
|
|
441
|
-
readonly onOut?: never;
|
|
442
|
-
} : {
|
|
443
|
-
readonly onOut: Required<EachConfig<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key, ParentSeed>>['onOut'];
|
|
444
|
-
});
|
|
445
|
-
type EachConfigParam<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key extends string = string, ParentSeed = Parent> = [Args] extends [void] ? [OutMessage] extends [never] ? [config?: EachOptions<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key, ParentSeed>] : [config: EachOptions<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key, ParentSeed>] : [config: EachOptions<Args, Parent, LinkMessage, Message, OutMessage, OutStepMessage, R2, Key, ParentSeed>];
|
|
446
|
-
/** Any bundle, for APIs that accept one without caring about its types. */
|
|
447
|
-
type AnyBundle = Bundle$1<string, any, any, any, any, any, any, any, any, any>;
|
|
448
|
-
//#endregion
|
|
449
|
-
//#region ../bundle/src/parent.d.ts
|
|
450
|
-
type P<B> = BundleParts<B>;
|
|
451
|
-
/** Collections cannot place a bundle with Managed Resources; reported at the bundle. */
|
|
452
|
-
type WithoutResources<B> = [keyof P<B>['Resources']] extends [never] ? unknown : Invalid<'A collection cannot place a bundle with Managed Resources: the runtime provides a resource by one tag, so every item would share it'>;
|
|
453
|
-
type PlacedBy<B extends AnyBundle, Model, LinkMessage, OutStepMessage, R2, Field extends string> = Placed<P<B>['Name'], Model, LinkMessage | OutStepMessage, P<B>['Model'], P<B>['Message'], P<B>['R'] | R2, P<B>['S'], P<B>['ViewInputs'], P<B>['Resources'], P<B>['Helpers'], Field, TagOf<LinkMessage>>;
|
|
454
|
-
type CollectionBy<B extends AnyBundle, Model, LinkMessage, OutStepMessage, R2, Field extends string> = PlacedCollection<P<B>['Name'], Model, LinkMessage | OutStepMessage, P<B>['Model'], P<B>['Message'], P<B>['R'] | R2, P<B>['S'], P<B>['ViewInputs'], P<B>['Helpers'], Field, string, TagOf<LinkMessage>>;
|
|
455
|
-
//#endregion
|
|
456
|
-
//#region src/index.d.ts
|
|
457
|
-
type AnyPlacement = AnyPlaced | AnyPlacedCollection;
|
|
458
|
-
/** What an assembly lists: placements, collections, and integration wiring. */
|
|
459
|
-
type AssemblyItems = {
|
|
460
|
-
readonly placements: ReadonlyArray<AnyPlacement | AnyWiring>;
|
|
53
|
+
/** A Module of these placements and wiring plus the application's other contracts. */
|
|
54
|
+
module: (assembly: AssemblyItems, items?: readonly ModuleItem<Root>[]) => Module<Root, F, Cases>;
|
|
461
55
|
};
|
|
462
56
|
export declare const BundleSurface: {
|
|
463
|
-
readonly link:
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
readonly
|
|
467
|
-
readonly module: <Root, F extends Schema.Struct.Fields, Cases extends Record<string, Schema.Struct.Fields>>(app: AppScope<Root, F, Cases>, assembly: AssemblyItems, items?: readonly ModuleItem<Root>[]) => Module<Root, F, Cases>;
|
|
468
|
-
readonly parent: <Root, F extends Schema.Struct.Fields, Cases extends Record<string, Schema.Struct.Fields>>(app: AppScope<Root, F, Cases>) => {
|
|
469
|
-
/** A Module of these placements and wiring plus the application's other contracts. */
|
|
470
|
-
module: (assembly: AssemblyItems, items?: readonly ModuleItem<Root>[]) => Module<Root, F, Cases>;
|
|
471
|
-
Model: Schema.Codec<Root, unknown, never, never>;
|
|
472
|
-
Message: Schema.Codec<Schema.Schema.Type<import("foldkit/message").MessageUnion<Cases>> & AnyMessage, unknown, never, never>;
|
|
473
|
-
withServices: <S>() => Bundle.Parent<Root, Schema.Schema.Type<import("foldkit/message").MessageUnion<Cases>> & AnyMessage, S>;
|
|
474
|
-
at: <B extends Bundle.AnyBundle, const Field extends { [K in keyof Root]: [Root[K]] extends [Bundle.BundleParts<B>["Model"]] ? [Bundle.BundleParts<B>["Model"]] extends [Root[K]] ? K : never : never; }[keyof Root] & string, OutStepMessage = never, R2 = never>(declared: Bundle.Declared<B, Field>, ...config: Bundle.PlaceConfigParam<Bundle.BundleParts<B>["Args"], Root, import("foldkit-bundle").Wrapped<`Got${Capitalize<Field>}Message`, Bundle.BundleParts<B>["Message"]>, Bundle.BundleParts<B>["Message"], Bundle.BundleParts<B>["OutMessage"], OutStepMessage, R2, Omit<Root, Field>> & ([import("foldkit-bundle").Wrapped<`Got${Capitalize<Field>}Message`, Bundle.BundleParts<B>["Message"]>] extends [Schema.Schema.Type<import("foldkit/message").MessageUnion<Cases>> & AnyMessage] ? unknown : import("foldkit-bundle").Invalid<"The parent Message does not include this placement's wrapper variant; spread its cases into defineMessageUnion">)) => PlacedBy<B, Root, import("foldkit-bundle").Wrapped<`Got${Capitalize<Field>}Message`, Bundle.BundleParts<B>["Message"]>, OutStepMessage, R2, Field>;
|
|
475
|
-
place: <B extends Bundle.AnyBundle, const Field_1 extends { [K in keyof Root]: [Root[K]] extends [Bundle.BundleParts<B>["Model"]] ? [Bundle.BundleParts<B>["Model"]] extends [Root[K]] ? K : never : never; }[keyof Root] & string, OutStepMessage_1 = never, R2_1 = never>(bundle: B, field: Field_1, ...config: Bundle.PlaceConfigParam<Bundle.BundleParts<B>["Args"], Root, import("foldkit-bundle").Wrapped<`Got${Capitalize<Field_1>}Message`, Bundle.BundleParts<B>["Message"]>, Bundle.BundleParts<B>["Message"], Bundle.BundleParts<B>["OutMessage"], OutStepMessage_1, R2_1, Omit<Root, Field_1>> & ([import("foldkit-bundle").Wrapped<`Got${Capitalize<Field_1>}Message`, Bundle.BundleParts<B>["Message"]>] extends [Schema.Schema.Type<import("foldkit/message").MessageUnion<Cases>> & AnyMessage] ? unknown : import("foldkit-bundle").Invalid<"The parent Message does not include this placement's wrapper variant; spread its cases into defineMessageUnion">)) => PlacedBy<B, Root, import("foldkit-bundle").Wrapped<`Got${Capitalize<Field_1>}Message`, Bundle.BundleParts<B>["Message"]>, OutStepMessage_1, R2_1, Field_1>;
|
|
476
|
-
each: <B extends Bundle.AnyBundle, const Field_2 extends { [K in keyof Root]: Root[K] extends Readonly<Record<string, infer V>> ? [V] extends [Bundle.BundleParts<B>["Model"]] ? [Bundle.BundleParts<B>["Model"]] extends [V] ? K : never : never : never; }[keyof Root] & string, OutStepMessage_2 = never, R2_2 = never>(declared: Bundle.DeclaredEach<B, Field_2>, ...config: Bundle.EachConfigParam<Bundle.BundleParts<B>["Args"], Root, import("foldkit-bundle").KeyedWrapped<`Got${Capitalize<Field_2>}Message`, Bundle.BundleParts<B>["Message"]>, Bundle.BundleParts<B>["Message"], Bundle.BundleParts<B>["OutMessage"], OutStepMessage_2, R2_2, string, Omit<Root, Field_2>> & ([import("foldkit-bundle").KeyedWrapped<`Got${Capitalize<Field_2>}Message`, Bundle.BundleParts<B>["Message"]>] extends [Schema.Schema.Type<import("foldkit/message").MessageUnion<Cases>> & AnyMessage] ? unknown : import("foldkit-bundle").Invalid<"The parent Message does not include this placement's wrapper variant; spread its cases into defineMessageUnion">)) => CollectionBy<B, Root, import("foldkit-bundle").KeyedWrapped<`Got${Capitalize<Field_2>}Message`, Bundle.BundleParts<B>["Message"]>, OutStepMessage_2, R2_2, Field_2>;
|
|
477
|
-
placeEach: <B extends Bundle.AnyBundle, const Field_3 extends { [K in keyof Root]: Root[K] extends Readonly<Record<string, infer V>> ? [V] extends [Bundle.BundleParts<B>["Model"]] ? [Bundle.BundleParts<B>["Model"]] extends [V] ? K : never : never : never; }[keyof Root] & string, OutStepMessage_3 = never, R2_3 = never>(bundle: B & WithoutResources<B>, field: Field_3, ...config: Bundle.EachConfigParam<Bundle.BundleParts<B>["Args"], Root, import("foldkit-bundle").KeyedWrapped<`Got${Capitalize<Field_3>}Message`, Bundle.BundleParts<B>["Message"]>, Bundle.BundleParts<B>["Message"], Bundle.BundleParts<B>["OutMessage"], OutStepMessage_3, R2_3, string, Omit<Root, Field_3>> & ([import("foldkit-bundle").KeyedWrapped<`Got${Capitalize<Field_3>}Message`, Bundle.BundleParts<B>["Message"]>] extends [Schema.Schema.Type<import("foldkit/message").MessageUnion<Cases>> & AnyMessage] ? unknown : import("foldkit-bundle").Invalid<"The parent Message does not include this placement's wrapper variant; spread its cases into defineMessageUnion">)) => CollectionBy<B, Root, import("foldkit-bundle").KeyedWrapped<`Got${Capitalize<Field_3>}Message`, Bundle.BundleParts<B>["Message"]>, OutStepMessage_3, R2_3, Field_3>;
|
|
478
|
-
assemble: <const Ps extends readonly (import("foldkit-bundle").Placed<string, Root, Schema.Schema.Type<import("foldkit/message").MessageUnion<Cases>> & AnyMessage, any, any, any, any, any, any, any, string, string> | import("foldkit-bundle").PlacedCollection<string, Root, Schema.Schema.Type<import("foldkit/message").MessageUnion<Cases>> & AnyMessage, any, any, any, any, any, any, any, any, string> | import("foldkit-bundle").Wiring<Root, Schema.Schema.Type<import("foldkit/message").MessageUnion<Cases>> & AnyMessage, any>)[]>(...items: Ps) => Bundle.Assembly<Root, Schema.Schema.Type<import("foldkit/message").MessageUnion<Cases>> & AnyMessage, Ps, never>;
|
|
479
|
-
link: {
|
|
480
|
-
readonly field: <const Key extends keyof Root & string, const Tag extends string, ChildMessage>(key: Key, wrapper: Wrapper<Tag, ChildMessage>, options?: {
|
|
481
|
-
readonly when?: (parent: Root) => boolean;
|
|
482
|
-
} | undefined) => Link<Root, import("foldkit-bundle").Wrapped<Tag, ChildMessage>, Root[Key], ChildMessage, Key>;
|
|
483
|
-
readonly optional: <const Key extends { [K in keyof Root]: Root[K] extends Option.Option<unknown> ? K : never; }[keyof Root] & string, const Tag_1 extends string, ChildMessage_1>(key: Key, wrap: Wrapper<Tag_1, ChildMessage_1>, options?: {
|
|
484
|
-
readonly when?: (parent: Root) => boolean;
|
|
485
|
-
} | undefined) => Link<Root, import("foldkit-bundle").Wrapped<Tag_1, ChildMessage_1>, Root[Key] extends (infer T) ? T extends Root[Key] ? T extends Option.Option<infer Value> ? Value : never : never : never, ChildMessage_1, Key>;
|
|
486
|
-
readonly collection: <const Field_4 extends { [K in keyof Root]: Root[K] extends Readonly<Record<string, unknown>> ? K : never; }[keyof Root] & string, const Tag_2 extends string, ChildMessage_2, Key extends string>(field: Field_4, wrap: import("foldkit-bundle").KeyedWrapper<Tag_2, ChildMessage_2, Key>, options?: {
|
|
487
|
-
readonly when?: (parent: Root, key: Key) => boolean;
|
|
488
|
-
} | undefined) => import("foldkit-bundle").CollectionLink<Root, import("foldkit-bundle").KeyedWrapped<Tag_2, ChildMessage_2, Key>, Root[Field_4] extends (infer T) ? T extends Root[Field_4] ? T extends Readonly<Record<string, infer Value>> ? Value : never : never : never, ChildMessage_2, Key, Field_4>;
|
|
489
|
-
readonly collectionById: <const Field_4 extends { [K in keyof Root]: Root[K] extends readonly unknown[] ? K : never; }[keyof Root] & string, const Tag_3 extends string, ChildMessage_3, Key_1 extends string>(field: Field_4, wrap: import("foldkit-bundle").KeyedWrapper<Tag_3, ChildMessage_3, Key_1>, options: {
|
|
490
|
-
readonly id: (item: Root[Field_4] extends (infer T) ? T extends Root[Field_4] ? T extends readonly (infer Item)[] ? Item : never : never : never) => Key_1;
|
|
491
|
-
readonly when?: (parent: Root, key: Key_1) => boolean;
|
|
492
|
-
}) => import("foldkit-bundle").CollectionLink<Root, import("foldkit-bundle").KeyedWrapped<Tag_3, ChildMessage_3, Key_1>, Root[Field_4] extends (infer T) ? T extends Root[Field_4] ? T extends readonly (infer Item)[] ? Item : never : never : never, ChildMessage_3, Key_1, Field_4>;
|
|
493
|
-
};
|
|
494
|
-
};
|
|
57
|
+
readonly link: typeof link;
|
|
58
|
+
readonly contract: typeof contract;
|
|
59
|
+
readonly module: typeof module;
|
|
60
|
+
readonly parent: typeof parent;
|
|
495
61
|
};
|
|
496
62
|
//#endregion
|
|
63
|
+
export {};
|
|
497
64
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;KAwBK,eAAe,YAAY;;KAG3B;WAA2B,YAAY,cAAc,eAAe;;;;;;;cAcnE,OAAQ,MAAM,aAAa,oBAAoB,cAAY,KAC1D,SAAS,MAAM,QAAM,SACjB,QAAQ,KAAK,eAAa;WACf,QAAQ,QAAQ;MAAkB,KAAA,+BAAA,QAAA,KAAA,eAAA,OAAA;;;;;cAiBlD,WACJ,MACA,UAAU,OAAO,OAAO,QACxB,cAAc,eAAe,OAAO,OAAO,SAAO,KAE7C,SAAS,MAAM,GAAG,QAAM,WAClB,iBACV;;cAYG,SACJ,MACA,UAAU,OAAO,OAAO,QACxB,cAAc,eAAe,OAAO,OAAO,SAAO,KAE7C,SAAS,MAAM,GAAG,QAAM,UACnB,eAAa,iBACP,WAAW,YAAO,OAAA,MAAA,GAAA;;;;;cAa9B,SACJ,MACA,UAAU,OAAO,OAAO,QACxB,cAAc,eAAe,OAAO,OAAO,SAAO,KAE7C,SAAS,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;EAYF,SAAA,UAAA,eAAa,iBAAkB,WAAW,YAAO,OAAA,MAAA,GAAA;;qBAK3D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foldkit-bundle-surface",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "foldkit-bundle placements as foldkit-surface Module contracts: each placement owns its Model path, validated with every other owner.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"foldkit",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"url": "git+https://github.com/doeixd/foldkit-plus.git",
|
|
20
20
|
"directory": "packages/bundle-surface"
|
|
21
21
|
},
|
|
22
|
-
"homepage": "https://
|
|
22
|
+
"homepage": "https://foldkit-plus.pages.dev/bundle/guides/bundle-surface",
|
|
23
23
|
"bugs": {
|
|
24
24
|
"url": "https://github.com/doeixd/foldkit-plus/issues"
|
|
25
25
|
},
|
|
@@ -37,21 +37,21 @@
|
|
|
37
37
|
"LICENSE"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"foldkit-surface": "0.
|
|
41
|
-
"foldkit-bundle": "0.
|
|
40
|
+
"foldkit-surface": "0.9.0",
|
|
41
|
+
"foldkit-bundle": "0.7.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"effect": "^4.0.0",
|
|
45
|
-
"foldkit": "^0.
|
|
45
|
+
"foldkit": "^0.168.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@effect/platform-browser": "4.0.
|
|
49
|
-
"effect": "4.0.
|
|
50
|
-
"foldkit": "0.
|
|
51
|
-
"jsdom": "
|
|
52
|
-
"tsdown": "^0.23.
|
|
53
|
-
"typescript": "
|
|
54
|
-
"foldkit-mirror": "0.
|
|
48
|
+
"@effect/platform-browser": "^4.0.4",
|
|
49
|
+
"effect": "^4.0.4",
|
|
50
|
+
"foldkit": "0.168.0",
|
|
51
|
+
"jsdom": "30.1.2",
|
|
52
|
+
"tsdown": "^0.23.1",
|
|
53
|
+
"typescript": "7.0.2",
|
|
54
|
+
"foldkit-mirror": "0.6.0"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"build": "tsdown",
|