foldkit 0.156.0 → 0.157.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/README.md +3 -3
- package/dist/asyncData/asyncData.d.ts +7 -7
- package/dist/asyncData/asyncData.d.ts.map +1 -1
- package/dist/asyncData/asyncData.js +12 -12
- package/dist/calendar/calendarDate.d.ts +15 -15
- package/dist/calendar/calendarDate.d.ts.map +1 -1
- package/dist/calendar/calendarDate.js +14 -14
- package/dist/calendar/comparison.d.ts +2 -2
- package/dist/calendar/comparison.d.ts.map +1 -1
- package/dist/calendar/comparison.js +5 -5
- package/dist/calendar/info.d.ts +2 -2
- package/dist/calendar/info.d.ts.map +1 -1
- package/dist/calendar/info.js +2 -2
- package/dist/calendar/locale.d.ts +7 -7
- package/dist/calendar/locale.d.ts.map +1 -1
- package/dist/calendar/locale.js +23 -23
- package/dist/canvas/shape.d.ts +89 -89
- package/dist/canvas/shape.d.ts.map +1 -1
- package/dist/canvas/shape.js +65 -53
- package/dist/command/index.d.ts +3 -3
- package/dist/customElement/index.d.ts +2 -2
- package/dist/customElement/index.js +2 -2
- package/dist/devTools/protocol.d.ts +278 -278
- package/dist/devTools/protocol.d.ts.map +1 -1
- package/dist/devTools/protocol.js +98 -92
- package/dist/devTools/schemaSummarize.d.ts.map +1 -1
- package/dist/devTools/schemaSummarize.js +24 -24
- package/dist/devTools/serialize.d.ts +1 -1
- package/dist/devTools/serialize.d.ts.map +1 -1
- package/dist/devTools/serialize.js +10 -10
- package/dist/devTools/store.d.ts.map +1 -1
- package/dist/devTools/store.js +52 -28
- package/dist/devTools/submodelPath.d.ts.map +1 -1
- package/dist/devTools/submodelPath.js +3 -3
- package/dist/devTools/summarize.d.ts +6 -6
- package/dist/devTools/summarize.d.ts.map +1 -1
- package/dist/devTools/summarize.js +13 -13
- package/dist/devTools/webSocketBridge.d.ts +3 -3
- package/dist/devTools/webSocketBridge.d.ts.map +1 -1
- package/dist/devTools/webSocketBridge.js +8 -8
- package/dist/dom/dom.d.ts +2 -0
- package/dist/dom/dom.d.ts.map +1 -1
- package/dist/dom/dom.js +47 -13
- package/dist/experimental/machine/machine.d.ts +29 -6
- package/dist/experimental/machine/machine.d.ts.map +1 -1
- package/dist/experimental/machine/machine.js +9 -8
- package/dist/experimental/server/entry.js +2 -2
- package/dist/experimental/server/serialize.js +2 -2
- package/dist/experimental/server/server.js +4 -4
- package/dist/fieldValidation/fieldValidation.d.ts +12 -12
- package/dist/fieldValidation/fieldValidation.d.ts.map +1 -1
- package/dist/fieldValidation/fieldValidation.js +9 -9
- package/dist/fieldValidation/rule.d.ts +2 -2
- package/dist/fieldValidation/rule.d.ts.map +1 -1
- package/dist/fieldValidation/rule.js +6 -6
- package/dist/file/file.d.ts +3 -3
- package/dist/file/file.d.ts.map +1 -1
- package/dist/file/file.js +3 -3
- package/dist/html/boundary.d.ts +93 -36
- package/dist/html/boundary.d.ts.map +1 -1
- package/dist/html/boundary.js +242 -75
- package/dist/html/childAttribute.d.ts +6 -4
- package/dist/html/childAttribute.d.ts.map +1 -1
- package/dist/html/childAttribute.js +7 -1
- package/dist/html/index.d.ts +31 -16
- package/dist/html/index.d.ts.map +1 -1
- package/dist/html/index.js +97 -40
- package/dist/html/lazy.d.ts +6 -6
- package/dist/html/lazy.d.ts.map +1 -1
- package/dist/html/lazy.js +37 -15
- package/dist/html/public.d.ts +1 -1
- package/dist/html/public.d.ts.map +1 -1
- package/dist/html/runtimeSingleton.d.ts +27 -6
- package/dist/html/runtimeSingleton.d.ts.map +1 -1
- package/dist/html/runtimeSingleton.js +46 -29
- package/dist/html/submodel.d.ts.map +1 -1
- package/dist/html/submodel.js +28 -39
- package/dist/http/http.d.ts +1 -1
- package/dist/http/http.js +1 -1
- package/dist/managedResource/managedResource.d.ts +5 -5
- package/dist/managedResource/managedResource.js +3 -3
- package/dist/mount/index.d.ts +92 -39
- package/dist/mount/index.d.ts.map +1 -1
- package/dist/mount/index.js +28 -8
- package/dist/mount/public.d.ts +1 -1
- package/dist/mount/public.d.ts.map +1 -1
- package/dist/mount/public.js +1 -1
- package/dist/navigation/urlRequest.d.ts +9 -9
- package/dist/navigation/urlRequest.d.ts.map +1 -1
- package/dist/navigation/urlRequest.js +2 -2
- package/dist/onUnmountModule.d.ts +19 -0
- package/dist/onUnmountModule.d.ts.map +1 -0
- package/dist/onUnmountModule.js +80 -0
- package/dist/port/port.d.ts +5 -5
- package/dist/port/port.js +5 -5
- package/dist/route/parser.d.ts +2 -2
- package/dist/route/parser.js +2 -2
- package/dist/runtime/hmrProtocol.d.ts +10 -10
- package/dist/runtime/hmrProtocol.d.ts.map +1 -1
- package/dist/runtime/hmrProtocol.js +10 -10
- package/dist/runtime/runtime.d.ts +4 -4
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +168 -51
- package/dist/schema/index.d.ts +41 -29
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +9 -9
- package/dist/snabbdom/init.d.ts +1 -1
- package/dist/snabbdom/init.d.ts.map +1 -1
- package/dist/snabbdom/init.js +5 -1
- package/dist/snabbdom/vnode.d.ts +1 -0
- package/dist/snabbdom/vnode.d.ts.map +1 -1
- package/dist/snabbdom/vnode.js +1 -0
- package/dist/subscription/animationFrame.d.ts +3 -3
- package/dist/subscription/animationFrame.d.ts.map +1 -1
- package/dist/subscription/animationFrame.js +2 -2
- package/dist/subscription/fromEvent.d.ts +2 -2
- package/dist/subscription/fromEvent.js +2 -2
- package/dist/subscription/subscription.d.ts +3 -3
- package/dist/subscription/subscription.js +1 -1
- package/dist/test/apps/bubbling.d.ts +6 -6
- package/dist/test/apps/bubbling.d.ts.map +1 -1
- package/dist/test/apps/bubbling.js +6 -6
- package/dist/test/apps/colorPicker.d.ts +7 -7
- package/dist/test/apps/colorPicker.d.ts.map +1 -1
- package/dist/test/apps/colorPicker.js +5 -5
- package/dist/test/apps/contextMenu.d.ts +5 -5
- package/dist/test/apps/contextMenu.d.ts.map +1 -1
- package/dist/test/apps/contextMenu.js +4 -4
- package/dist/test/apps/counter.d.ts +8 -8
- package/dist/test/apps/counter.d.ts.map +1 -1
- package/dist/test/apps/counter.js +8 -8
- package/dist/test/apps/crashOnRender.d.ts +18 -18
- package/dist/test/apps/crashOnRender.d.ts.map +1 -1
- package/dist/test/apps/crashOnRender.js +11 -11
- package/dist/test/apps/drafts.d.ts +9 -9
- package/dist/test/apps/drafts.d.ts.map +1 -1
- package/dist/test/apps/drafts.js +6 -6
- package/dist/test/apps/feedSocket.d.ts +6 -6
- package/dist/test/apps/feedSocket.d.ts.map +1 -1
- package/dist/test/apps/feedSocket.js +8 -8
- package/dist/test/apps/fileUpload.d.ts +2 -2
- package/dist/test/apps/fileUpload.d.ts.map +1 -1
- package/dist/test/apps/fileUpload.js +2 -2
- package/dist/test/apps/focusBoundary.d.ts +3 -3
- package/dist/test/apps/focusBoundary.d.ts.map +1 -1
- package/dist/test/apps/focusBoundary.js +3 -3
- package/dist/test/apps/formChild.d.ts +11 -11
- package/dist/test/apps/formChild.d.ts.map +1 -1
- package/dist/test/apps/formChild.js +13 -12
- package/dist/test/apps/interactions.d.ts +8 -8
- package/dist/test/apps/interactions.d.ts.map +1 -1
- package/dist/test/apps/interactions.js +8 -8
- package/dist/test/apps/keypress.d.ts +6 -6
- package/dist/test/apps/keypress.d.ts.map +1 -1
- package/dist/test/apps/keypress.js +6 -6
- package/dist/test/apps/login.d.ts +11 -11
- package/dist/test/apps/login.d.ts.map +1 -1
- package/dist/test/apps/login.js +15 -15
- package/dist/test/apps/logoutButton.d.ts +3 -3
- package/dist/test/apps/logoutButton.d.ts.map +1 -1
- package/dist/test/apps/logoutButton.js +2 -2
- package/dist/test/apps/mountPanel.d.ts +9 -9
- package/dist/test/apps/mountPanel.d.ts.map +1 -1
- package/dist/test/apps/mountPanel.js +9 -9
- package/dist/test/apps/multiRole.d.ts +3 -3
- package/dist/test/apps/multiRole.d.ts.map +1 -1
- package/dist/test/apps/multiRole.js +2 -2
- package/dist/test/apps/pointer.d.ts +7 -7
- package/dist/test/apps/pointer.d.ts.map +1 -1
- package/dist/test/apps/pointer.js +7 -7
- package/dist/test/apps/resumeUpload.d.ts +8 -8
- package/dist/test/apps/resumeUpload.d.ts.map +1 -1
- package/dist/test/apps/resumeUpload.js +7 -7
- package/dist/test/apps/scorePanel.d.ts +3 -3
- package/dist/test/apps/scorePanel.d.ts.map +1 -1
- package/dist/test/apps/scorePanel.js +2 -2
- package/dist/test/apps/selectiveKeys.d.ts +3 -3
- package/dist/test/apps/selectiveKeys.d.ts.map +1 -1
- package/dist/test/apps/selectiveKeys.js +3 -3
- package/dist/test/apps/uploads.d.ts +18 -18
- package/dist/test/apps/uploads.d.ts.map +1 -1
- package/dist/test/apps/uploads.js +13 -13
- package/dist/test/matchers.d.ts.map +1 -1
- package/dist/test/matchers.js +4 -4
- package/dist/test/query.d.ts.map +1 -1
- package/dist/test/query.js +28 -28
- package/dist/test/scene.d.ts +37 -8
- package/dist/test/scene.d.ts.map +1 -1
- package/dist/test/scene.js +58 -15
- package/dist/test/story.d.ts +35 -8
- package/dist/test/story.d.ts.map +1 -1
- package/dist/test/story.js +44 -22
- package/dist/update/update.d.ts +17 -20
- package/dist/update/update.d.ts.map +1 -1
- package/dist/url/index.d.ts +8 -8
- package/dist/url/index.d.ts.map +1 -1
- package/dist/url/index.js +19 -19
- package/dist/vdom.d.ts +3 -2
- package/dist/vdom.d.ts.map +1 -1
- package/dist/vdom.js +16 -6
- package/package.json +1 -1
package/dist/mount/index.d.ts
CHANGED
|
@@ -11,15 +11,31 @@ declare const MountTracker_base: Context.ServiceClass<MountTracker, "@foldkit/Mo
|
|
|
11
11
|
* fire in their VNode-only environment. */
|
|
12
12
|
export declare class MountTracker extends MountTracker_base {
|
|
13
13
|
}
|
|
14
|
+
/** The state of the DOM currently owned by the Foldkit renderer. `Live` means
|
|
15
|
+
* it represents the current live Model. `Paused` means time travel has
|
|
16
|
+
* installed a historical view while the live application continues running. */
|
|
17
|
+
export declare const ViewState: Schema.Literals<readonly ["Live", "Paused"]>;
|
|
18
|
+
/** The state of the DOM currently owned by the Foldkit renderer. */
|
|
19
|
+
export type ViewState = typeof ViewState.Type;
|
|
20
|
+
declare const MountRuntime_base: Context.ServiceClass<MountRuntime, "@foldkit/MountRuntime", {
|
|
21
|
+
readonly captureViewStateChanges: () => Stream.Stream<ViewState>;
|
|
22
|
+
}>;
|
|
23
|
+
/** @internal Runtime state used by `OnMount` to supply
|
|
24
|
+
* `viewStateChanges`. */
|
|
25
|
+
export declare class MountRuntime extends MountRuntime_base {
|
|
26
|
+
}
|
|
14
27
|
/** Type-level brand for MountDefinition values. */
|
|
15
28
|
export declare const MountDefinitionTypeId: unique symbol;
|
|
16
29
|
/** Type-level brand for MountDefinition values. */
|
|
17
30
|
export type MountDefinitionTypeId = typeof MountDefinitionTypeId;
|
|
18
31
|
/** A named, type-constrained per-element side effect, optionally carrying the
|
|
19
32
|
* args used to construct it. The runtime invokes `f` with the live `Element`
|
|
20
|
-
* when the element mounts
|
|
21
|
-
*
|
|
22
|
-
*
|
|
33
|
+
* and required view-state Stream when the element mounts. A Mount acquired by
|
|
34
|
+
* a live render keeps live dispatch, while one acquired by a historical
|
|
35
|
+
* render uses no-op dispatch. When resume reuses a replay-created element,
|
|
36
|
+
* the runtime releases its historical Mount before starting the live action.
|
|
37
|
+
* Otherwise the Stream's scope is tied to the element's lifetime: when the
|
|
38
|
+
* element unmounts, the runtime interrupts the fiber, which closes the
|
|
23
39
|
* Stream's scope and runs any registered `acquireRelease` finalizers.
|
|
24
40
|
*
|
|
25
41
|
* Authors don't construct this shape directly. `Mount.define` builds it from
|
|
@@ -29,7 +45,7 @@ export type MountDefinitionTypeId = typeof MountDefinitionTypeId;
|
|
|
29
45
|
export type MountAction<Message, E = never> = Readonly<{
|
|
30
46
|
name: string;
|
|
31
47
|
args?: Record<string, unknown>;
|
|
32
|
-
f: (element: Element) => Stream.Stream<Message, E>;
|
|
48
|
+
f: (element: Element, viewStateChanges: Stream.Stream<ViewState>) => Stream.Stream<Message, E>;
|
|
33
49
|
}>;
|
|
34
50
|
/** A Mount definition for a Mount with no declared args. Call as `Definition()` to produce a MountAction. */
|
|
35
51
|
export interface MountDefinitionNoArgs<Name extends string, ResultMessage> {
|
|
@@ -37,7 +53,7 @@ export interface MountDefinitionNoArgs<Name extends string, ResultMessage> {
|
|
|
37
53
|
readonly name: Name;
|
|
38
54
|
(): Readonly<{
|
|
39
55
|
name: Name;
|
|
40
|
-
f: (element: Element) => Stream.Stream<ResultMessage>;
|
|
56
|
+
f: (element: Element, viewStateChanges: Stream.Stream<ViewState>) => Stream.Stream<ResultMessage>;
|
|
41
57
|
}>;
|
|
42
58
|
}
|
|
43
59
|
/** A Mount definition for a Mount with declared args. Call as `Definition(args)` to produce a MountAction. */
|
|
@@ -47,7 +63,7 @@ export interface MountDefinitionWithArgs<Name extends string, Fields extends Sch
|
|
|
47
63
|
(args: Schema.Schema.Type<Schema.Struct<Fields>>): Readonly<{
|
|
48
64
|
name: Name;
|
|
49
65
|
args: Schema.Schema.Type<Schema.Struct<Fields>>;
|
|
50
|
-
f: (element: Element) => Stream.Stream<ResultMessage>;
|
|
66
|
+
f: (element: Element, viewStateChanges: Stream.Stream<ViewState>) => Stream.Stream<ResultMessage>;
|
|
51
67
|
}>;
|
|
52
68
|
}
|
|
53
69
|
/** A Mount definition created with `Mount.define` or `Mount.defineStream`.
|
|
@@ -58,23 +74,58 @@ export type MountDefinition<Name extends string = string, ResultMessage = any> =
|
|
|
58
74
|
* element under that name, so an arg of the same name would shadow it. The
|
|
59
75
|
* literal is the type error a colliding declaration produces. */
|
|
60
76
|
type ElementFieldIsReserved = 'Mount args cannot declare `element`: execute already receives the live element';
|
|
77
|
+
/** @internal Rejects an args field named `viewStateChanges`. `execute`
|
|
78
|
+
* receives the runtime-owned Stream under that name. */
|
|
79
|
+
type ViewStateChangesFieldIsReserved = 'Mount args cannot declare `viewStateChanges`: execute already receives the view-state Stream';
|
|
80
|
+
/** @internal Fields the runtime supplies to every Mount execution. */
|
|
81
|
+
type ExecuteRuntimeInput = Readonly<{
|
|
82
|
+
element: Element;
|
|
83
|
+
viewStateChanges: Stream.Stream<ViewState>;
|
|
84
|
+
}>;
|
|
85
|
+
/** @internal Type-level rejection for args that collide with runtime fields. */
|
|
86
|
+
type ReservedExecuteFields = Readonly<{
|
|
87
|
+
element?: ElementFieldIsReserved;
|
|
88
|
+
viewStateChanges?: ViewStateChangesFieldIsReserved;
|
|
89
|
+
}>;
|
|
90
|
+
/** A never-ending view-state Stream for renderers without time travel.
|
|
91
|
+
* It emits `Live` immediately and never completes. Custom renderers and
|
|
92
|
+
* low-level MountAction wrappers can pass it as the required second argument
|
|
93
|
+
* to `MountAction.f` when the rendered view is always live. */
|
|
94
|
+
export declare const liveViewStateChanges: Stream.Stream<ViewState>;
|
|
61
95
|
/**
|
|
62
96
|
* Defines a one-shot Mount. Every input is a named field: `args` declares the
|
|
63
97
|
* args Schema, `messages` lists the Messages this Mount can produce, and
|
|
64
98
|
* `execute` holds the work. `execute` receives the live `Element` as `element`
|
|
65
|
-
* alongside the declared args, and
|
|
66
|
-
* when the element mounts and
|
|
99
|
+
* and the runtime's `viewStateChanges` Stream alongside the declared args, and
|
|
100
|
+
* returns an `Effect<Message>` that runs once when the element mounts and
|
|
101
|
+
* produces exactly one Message.
|
|
67
102
|
*
|
|
68
103
|
* `args` is optional. Omit it and the Definition is callable as `Definition()`;
|
|
69
104
|
* declare it and the Definition is callable as `Definition(args)`. `execute`
|
|
70
|
-
* keeps the same shape either way, because a Mount always has an element
|
|
71
|
-
*
|
|
72
|
-
* collide with the
|
|
105
|
+
* keeps the same shape either way, because a Mount always has an element and a
|
|
106
|
+
* view-state Stream. Args fields named `element` or `viewStateChanges` are
|
|
107
|
+
* rejected where you declare them, since they would collide with the runtime
|
|
108
|
+
* fields `execute` receives.
|
|
73
109
|
*
|
|
74
110
|
* Constructing a MountAction never runs `execute`. The runtime calls it when
|
|
75
111
|
* the element enters the DOM, so nothing the body does happens inside the pure
|
|
76
112
|
* view that built the action.
|
|
77
113
|
*
|
|
114
|
+
* `viewStateChanges` begins with the rendered view's `Live | Paused` state at
|
|
115
|
+
* the moment the Mount is acquired, followed by changes. This acquisition
|
|
116
|
+
* state stays available when `execute` performs asynchronous setup before
|
|
117
|
+
* consuming the Stream, so a Mount inserted by a historical render always
|
|
118
|
+
* observes `Paused` first. Time travel pauses the rendered view, not the live
|
|
119
|
+
* application. Use this Stream to make an imperative integration read-only
|
|
120
|
+
* while historical DOM is installed. A surviving live Mount stays acquired
|
|
121
|
+
* throughout pause and resume. Its live async work and external event sources
|
|
122
|
+
* also continue, so the integration must use the Stream to stop DOM-derived
|
|
123
|
+
* interaction while paused. Mounts acquired by a historical render cannot
|
|
124
|
+
* dispatch to the live Model. If the resumed live view owns the same element,
|
|
125
|
+
* Foldkit releases the replay acquisition before starting the live action. The
|
|
126
|
+
* Stream stays open for the Mount's lifetime. When time travel is unavailable,
|
|
127
|
+
* it emits only `Live`.
|
|
128
|
+
*
|
|
78
129
|
* Cleanup composes via `Effect.acquireRelease` inside the Effect: registered
|
|
79
130
|
* finalizers run when the element unmounts. The Mount's scope stays open
|
|
80
131
|
* across the element's full lifetime, even after the Effect completes.
|
|
@@ -144,7 +195,7 @@ type ElementFieldIsReserved = 'Mount args cannot declare `element`: execute alre
|
|
|
144
195
|
* @example With args
|
|
145
196
|
* ```ts
|
|
146
197
|
* const AnchorPopover = Mount.define('AnchorPopover', {
|
|
147
|
-
* args: { buttonId:
|
|
198
|
+
* args: { buttonId: Schema.String, anchor: AnchorConfig },
|
|
148
199
|
* messages: [CompletedAnchorPopover],
|
|
149
200
|
* execute: ({ element, buttonId, anchor }) =>
|
|
150
201
|
* Effect.gen(function* () {
|
|
@@ -181,42 +232,50 @@ type ElementFieldIsReserved = 'Mount args cannot declare `element`: execute alre
|
|
|
181
232
|
* and undoing it when the drag ends).)
|
|
182
233
|
*/
|
|
183
234
|
export declare function define<const Name extends string, Fields extends Schema.Struct.Fields, const Messages extends readonly [Schema.Top, ...ReadonlyArray<Schema.Top>]>(name: Name, config: Readonly<{
|
|
184
|
-
args: Fields &
|
|
185
|
-
element?: ElementFieldIsReserved;
|
|
186
|
-
}>;
|
|
235
|
+
args: Fields & ReservedExecuteFields;
|
|
187
236
|
messages: Messages;
|
|
188
|
-
execute: (input:
|
|
189
|
-
element: Element;
|
|
190
|
-
}> & Schema.Schema.Type<Schema.Struct<Fields>>) => Effect.Effect<Schema.Schema.Type<Messages[number]>, never, Scope.Scope>;
|
|
237
|
+
execute: (input: ExecuteRuntimeInput & Schema.Schema.Type<Schema.Struct<Fields>>) => Effect.Effect<Schema.Schema.Type<Messages[number]>, never, Scope.Scope>;
|
|
191
238
|
}>): MountDefinitionWithArgs<Name, Fields, Schema.Schema.Type<Messages[number]>>;
|
|
192
239
|
export declare function define<const Name extends string, const Messages extends readonly [Schema.Top, ...ReadonlyArray<Schema.Top>]>(name: Name, config: Readonly<{
|
|
193
240
|
args?: never;
|
|
194
241
|
messages: Messages;
|
|
195
|
-
execute: (input:
|
|
196
|
-
element: Element;
|
|
197
|
-
}>) => Effect.Effect<Schema.Schema.Type<Messages[number]>, never, Scope.Scope>;
|
|
242
|
+
execute: (input: ExecuteRuntimeInput) => Effect.Effect<Schema.Schema.Type<Messages[number]>, never, Scope.Scope>;
|
|
198
243
|
}>): MountDefinitionNoArgs<Name, Schema.Schema.Type<Messages[number]>>;
|
|
199
244
|
/**
|
|
200
245
|
* Defines a streaming Mount. Every input is a named field, exactly as in
|
|
201
246
|
* `Mount.define`: `args` declares the args Schema, `messages` lists the
|
|
202
247
|
* Messages this Mount can produce, and `execute` holds the work. `execute`
|
|
203
|
-
* receives the live `Element` as `element`
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
248
|
+
* receives the live `Element` as `element` and the runtime's
|
|
249
|
+
* `viewStateChanges` Stream alongside the declared args, and returns a
|
|
250
|
+
* `Stream<Message>` whose lifetime is bound to the element's lifetime: each
|
|
251
|
+
* emitted Message is dispatched, and the Stream's scope is closed (running any
|
|
252
|
+
* registered `Effect.acquireRelease` finalizers) when the element unmounts.
|
|
253
|
+
* Use this form when the Mount emits a continuum of events from observers or
|
|
254
|
+
* listeners attached to the element.
|
|
209
255
|
*
|
|
210
256
|
* `args` is optional. Omit it and the Definition is callable as `Definition()`;
|
|
211
257
|
* declare it and the Definition is callable as `Definition(args)`. `execute`
|
|
212
|
-
* keeps the same shape either way, because a Mount always has an element
|
|
213
|
-
*
|
|
214
|
-
* collide with the
|
|
258
|
+
* keeps the same shape either way, because a Mount always has an element and a
|
|
259
|
+
* view-state Stream. Args fields named `element` or `viewStateChanges` are
|
|
260
|
+
* rejected where you declare them, since they would collide with the runtime
|
|
261
|
+
* fields `execute` receives.
|
|
215
262
|
*
|
|
216
263
|
* Constructing a MountAction never runs `execute`. The runtime calls it when
|
|
217
264
|
* the element enters the DOM, so nothing the body does happens inside the pure
|
|
218
265
|
* view that built the action.
|
|
219
266
|
*
|
|
267
|
+
* `viewStateChanges` has the same semantics as in `Mount.define`: it begins
|
|
268
|
+
* with the rendered view's state at acquisition even after asynchronous
|
|
269
|
+
* setup, keeps a surviving live Mount acquired, and returns to `Live` only
|
|
270
|
+
* after the latest live view has been patched back into the DOM. A live
|
|
271
|
+
* Mount's external sources continue while paused, so use the state to stop
|
|
272
|
+
* listeners from turning historical DOM interaction into Messages. A Mount
|
|
273
|
+
* acquired by a historical render cannot dispatch to the live Model. If the
|
|
274
|
+
* resumed live view owns the same element, Foldkit releases the replay
|
|
275
|
+
* acquisition before starting the live action. The state Stream stays open
|
|
276
|
+
* for the Mount's lifetime. When time travel is unavailable, it emits only
|
|
277
|
+
* `Live`.
|
|
278
|
+
*
|
|
220
279
|
* At least one result Message schema is required. The Stream's emission
|
|
221
280
|
* type is `Schema.Schema.Type<Messages[number]>`; without a declared
|
|
222
281
|
* result, `execute` would have to return `Stream<never>`, leaving
|
|
@@ -303,20 +362,14 @@ export declare function define<const Name extends string, const Messages extends
|
|
|
303
362
|
* the mental model.
|
|
304
363
|
*/
|
|
305
364
|
export declare function defineStream<const Name extends string, Fields extends Schema.Struct.Fields, const Messages extends readonly [Schema.Top, ...ReadonlyArray<Schema.Top>]>(name: Name, config: Readonly<{
|
|
306
|
-
args: Fields &
|
|
307
|
-
element?: ElementFieldIsReserved;
|
|
308
|
-
}>;
|
|
365
|
+
args: Fields & ReservedExecuteFields;
|
|
309
366
|
messages: Messages;
|
|
310
|
-
execute: (input:
|
|
311
|
-
element: Element;
|
|
312
|
-
}> & Schema.Schema.Type<Schema.Struct<Fields>>) => Stream.Stream<Schema.Schema.Type<Messages[number]>, never, never>;
|
|
367
|
+
execute: (input: ExecuteRuntimeInput & Schema.Schema.Type<Schema.Struct<Fields>>) => Stream.Stream<Schema.Schema.Type<Messages[number]>, never, never>;
|
|
313
368
|
}>): MountDefinitionWithArgs<Name, Fields, Schema.Schema.Type<Messages[number]>>;
|
|
314
369
|
export declare function defineStream<const Name extends string, const Messages extends readonly [Schema.Top, ...ReadonlyArray<Schema.Top>]>(name: Name, config: Readonly<{
|
|
315
370
|
args?: never;
|
|
316
371
|
messages: Messages;
|
|
317
|
-
execute: (input:
|
|
318
|
-
element: Element;
|
|
319
|
-
}>) => Stream.Stream<Schema.Schema.Type<Messages[number]>, never, never>;
|
|
372
|
+
execute: (input: ExecuteRuntimeInput) => Stream.Stream<Schema.Schema.Type<Messages[number]>, never, never>;
|
|
320
373
|
}>): MountDefinitionNoArgs<Name, Schema.Schema.Type<Messages[number]>>;
|
|
321
374
|
/** Lifts a `MountAction` from one Message universe to another by mapping its
|
|
322
375
|
* dispatched Messages through a transform. Used by Submodel components to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mount/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,MAAM,EAIN,MAAM,EACN,KAAK,EAC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AAQ,CAAA;IAClB,OAAO,EAAE,CACP,KAAK,EAAE,mBAAmB,KACvB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA;CACvE,CAAC,GACD,qBAAqB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;AAgCpE;;;6EAG6E;AAC7E,eAAO,MAAM,UAAU,EAAE;IACvB,CAAC,CAAC,EAAE,CAAC,EACH,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GACnB,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IACtD,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;CAW9E,CAAA"}
|
package/dist/mount/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Context, Effect, Function, Predicate, Queue, Stream, } from 'effect';
|
|
1
|
+
import { Context, Effect, Function, Predicate, Queue, Schema, Stream, } from 'effect';
|
|
2
2
|
/** Effect service tag that observes Mount lifecycle events. The runtime
|
|
3
3
|
* provides an implementation that buffers events for DevTools history;
|
|
4
4
|
* the OnMount snabbdom hooks call `started` synchronously when an element
|
|
@@ -7,6 +7,14 @@ import { Context, Effect, Function, Predicate, Queue, Stream, } from 'effect';
|
|
|
7
7
|
* fire in their VNode-only environment. */
|
|
8
8
|
export class MountTracker extends Context.Service()('@foldkit/MountTracker') {
|
|
9
9
|
}
|
|
10
|
+
/** The state of the DOM currently owned by the Foldkit renderer. `Live` means
|
|
11
|
+
* it represents the current live Model. `Paused` means time travel has
|
|
12
|
+
* installed a historical view while the live application continues running. */
|
|
13
|
+
export const ViewState = Schema.Literals(['Live', 'Paused']);
|
|
14
|
+
/** @internal Runtime state used by `OnMount` to supply
|
|
15
|
+
* `viewStateChanges`. */
|
|
16
|
+
export class MountRuntime extends Context.Service()('@foldkit/MountRuntime') {
|
|
17
|
+
}
|
|
10
18
|
/** Type-level brand for MountDefinition values. */
|
|
11
19
|
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
|
|
12
20
|
export const MountDefinitionTypeId = Symbol.for('foldkit/MountDefinition');
|
|
@@ -22,8 +30,13 @@ const brandAsDefinition = (definition, name) => {
|
|
|
22
30
|
value: MountDefinitionTypeId,
|
|
23
31
|
});
|
|
24
32
|
};
|
|
25
|
-
|
|
26
|
-
|
|
33
|
+
/** A never-ending view-state Stream for renderers without time travel.
|
|
34
|
+
* It emits `Live` immediately and never completes. Custom renderers and
|
|
35
|
+
* low-level MountAction wrappers can pass it as the required second argument
|
|
36
|
+
* to `MountAction.f` when the rendered view is always live. */
|
|
37
|
+
export const liveViewStateChanges = Stream.concat(Stream.make(ViewState.make('Live')), Stream.never);
|
|
38
|
+
const wrapEffectAsStream = (toEffect) => (element, viewStateChanges) => Stream.callback(queue => Effect.gen(function* () {
|
|
39
|
+
const message = yield* toEffect(element, viewStateChanges);
|
|
27
40
|
Queue.offerUnsafe(queue, message);
|
|
28
41
|
return yield* Effect.never;
|
|
29
42
|
}));
|
|
@@ -33,7 +46,7 @@ export function define(name, config) {
|
|
|
33
46
|
const definition = (args) => ({
|
|
34
47
|
name,
|
|
35
48
|
args,
|
|
36
|
-
f: wrapEffectAsStream(element => config.execute({ ...args, element })),
|
|
49
|
+
f: wrapEffectAsStream((element, viewStateChanges) => config.execute({ ...args, element, viewStateChanges })),
|
|
37
50
|
});
|
|
38
51
|
brandAsDefinition(definition, name);
|
|
39
52
|
return definition;
|
|
@@ -41,7 +54,7 @@ export function define(name, config) {
|
|
|
41
54
|
else {
|
|
42
55
|
const definition = () => ({
|
|
43
56
|
name,
|
|
44
|
-
f: wrapEffectAsStream(element => config.execute({ element })),
|
|
57
|
+
f: wrapEffectAsStream((element, viewStateChanges) => config.execute({ element, viewStateChanges })),
|
|
45
58
|
});
|
|
46
59
|
brandAsDefinition(definition, name);
|
|
47
60
|
return definition;
|
|
@@ -53,7 +66,11 @@ export function defineStream(name, config) {
|
|
|
53
66
|
const definition = (args) => ({
|
|
54
67
|
name,
|
|
55
68
|
args,
|
|
56
|
-
f: (element) => config.execute({
|
|
69
|
+
f: (element, viewStateChanges) => config.execute({
|
|
70
|
+
...args,
|
|
71
|
+
element,
|
|
72
|
+
viewStateChanges,
|
|
73
|
+
}),
|
|
57
74
|
});
|
|
58
75
|
brandAsDefinition(definition, name);
|
|
59
76
|
return definition;
|
|
@@ -61,7 +78,10 @@ export function defineStream(name, config) {
|
|
|
61
78
|
else {
|
|
62
79
|
const definition = () => ({
|
|
63
80
|
name,
|
|
64
|
-
f: (element) => config.execute({
|
|
81
|
+
f: (element, viewStateChanges) => config.execute({
|
|
82
|
+
element,
|
|
83
|
+
viewStateChanges,
|
|
84
|
+
}),
|
|
65
85
|
});
|
|
66
86
|
brandAsDefinition(definition, name);
|
|
67
87
|
return definition;
|
|
@@ -73,5 +93,5 @@ export function defineStream(name, config) {
|
|
|
73
93
|
* consumer-supplied `toParentMessage` lift. Preserves `name` and `args`. */
|
|
74
94
|
export const mapMessage = Function.dual(2, (action, f) => ({
|
|
75
95
|
...action,
|
|
76
|
-
f: (element) => action.f(element).pipe(Stream.map(f)),
|
|
96
|
+
f: (element, viewStateChanges) => action.f(element, viewStateChanges).pipe(Stream.map(f)),
|
|
77
97
|
}));
|
package/dist/mount/public.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export type { MountAction, MountDefinition, MountDefinitionNoArgs, MountDefinitionWithArgs, } from './index.js';
|
|
2
|
-
export { MountDefinitionTypeId, MountTracker, define, defineStream, mapMessage, } from './index.js';
|
|
2
|
+
export { MountDefinitionTypeId, MountTracker, ViewState, define, defineStream, liveViewStateChanges, mapMessage, } from './index.js';
|
|
3
3
|
//# sourceMappingURL=public.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/mount/public.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,WAAW,EACX,eAAe,EACf,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,qBAAqB,EACrB,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,UAAU,GACX,MAAM,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/mount/public.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,WAAW,EACX,eAAe,EACf,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,qBAAqB,EACrB,YAAY,EACZ,SAAS,EACT,MAAM,EACN,YAAY,EACZ,oBAAoB,EACpB,UAAU,GACX,MAAM,YAAY,CAAA"}
|
package/dist/mount/public.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { MountDefinitionTypeId, MountTracker, define, defineStream, mapMessage, } from './index.js';
|
|
1
|
+
export { MountDefinitionTypeId, MountTracker, ViewState, define, defineStream, liveViewStateChanges, mapMessage, } from './index.js';
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { Schema
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
2
|
/** Union of `Internal` and `External` URL request types. */
|
|
3
3
|
export declare const UrlRequest: import("../schema/index.js").TaggedUnion<{
|
|
4
4
|
readonly Internal: {
|
|
5
|
-
url:
|
|
6
|
-
readonly protocol:
|
|
7
|
-
readonly host:
|
|
8
|
-
readonly port:
|
|
9
|
-
readonly pathname:
|
|
10
|
-
readonly search:
|
|
11
|
-
readonly hash:
|
|
5
|
+
url: Schema.Struct<{
|
|
6
|
+
readonly protocol: Schema.String;
|
|
7
|
+
readonly host: Schema.String;
|
|
8
|
+
readonly port: Schema.Option<Schema.String>;
|
|
9
|
+
readonly pathname: Schema.String;
|
|
10
|
+
readonly search: Schema.Option<Schema.String>;
|
|
11
|
+
readonly hash: Schema.Option<Schema.String>;
|
|
12
12
|
}>;
|
|
13
13
|
};
|
|
14
14
|
readonly External: {
|
|
15
|
-
href:
|
|
15
|
+
href: Schema.String;
|
|
16
16
|
};
|
|
17
17
|
}>;
|
|
18
18
|
/** Union of `Internal` and `External` URL request types. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urlRequest.d.ts","sourceRoot":"","sources":["../../src/navigation/urlRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"urlRequest.d.ts","sourceRoot":"","sources":["../../src/navigation/urlRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAK/B,4DAA4D;AAC5D,eAAO,MAAM,UAAU;;QACT,GAAG;;;;;;;;;;QACH,IAAI;;EAChB,CAAA;AACF,4DAA4D;AAC5D,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Schema
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
2
|
import { defineTaggedUnion } from '../schema/index.js';
|
|
3
3
|
import { Url } from '../url/index.js';
|
|
4
4
|
/** Union of `Internal` and `External` URL request types. */
|
|
5
5
|
export const UrlRequest = defineTaggedUnion({
|
|
6
6
|
Internal: { url: Url },
|
|
7
|
-
External: { href:
|
|
7
|
+
External: { href: Schema.String },
|
|
8
8
|
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type Module, type VNodeData } from './snabbdom/index.js';
|
|
2
|
+
/** Opens the replay-render window used to distinguish historical VNodes from
|
|
3
|
+
* the live imperative lifecycle they temporarily replace. */
|
|
4
|
+
export declare const beginReplayUnmountRender: () => void;
|
|
5
|
+
/** Closes a successful replay-render window and discards live `OnUnmount`
|
|
6
|
+
* callbacks deferred while installing the historical view. */
|
|
7
|
+
export declare const endReplayUnmountRender: () => void;
|
|
8
|
+
/** Records an `OnUnmount` callback and the render that owns it on a VNode. */
|
|
9
|
+
export declare const attachOnUnmount: (data: VNodeData, dispatch: () => void) => void;
|
|
10
|
+
/** Dispatches the live `OnUnmount` callbacks deferred by a replay patch that
|
|
11
|
+
* failed and forced the runtime to discard the damaged DOM. Repeated destroy
|
|
12
|
+
* calls for one element are deduplicated without conflating distinct elements
|
|
13
|
+
* built from a shared VNode. */
|
|
14
|
+
export declare const flushReplayUnmountsAfterPatchFailure: () => void;
|
|
15
|
+
/** Snabbdom module that preserves a live element's `OnUnmount` ownership while
|
|
16
|
+
* replay VNodes patch it in place, then routes teardown according to whether
|
|
17
|
+
* the historical patch succeeded or required recovery. */
|
|
18
|
+
export declare const onUnmountModule: Module;
|
|
19
|
+
//# sourceMappingURL=onUnmountModule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onUnmountModule.d.ts","sourceRoot":"","sources":["../src/onUnmountModule.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EAEX,KAAK,SAAS,EAGf,MAAM,qBAAqB,CAAA;AAqB5B;8DAC8D;AAC9D,eAAO,MAAM,wBAAwB,QAAO,IAG3C,CAAA;AAED;+DAC+D;AAC/D,eAAO,MAAM,sBAAsB,QAAO,IAGzC,CAAA;AAED,8EAA8E;AAC9E,eAAO,MAAM,eAAe,SACpB,SAAS,YACL,MAAM,IAAI,KACnB,IAUF,CAAA;AAED;;;iCAGiC;AACjC,eAAO,MAAM,oCAAoC,QAAO,IAWvD,CAAA;AAED;;2DAE2D;AAC3D,eAAO,MAAM,eAAe,EAAE,MA0B7B,CAAA"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { VNodeDataMask, vnodeDataMaskKey, } from './snabbdom/index.js';
|
|
2
|
+
const onUnmountDataKey = 'foldkitOnUnmount';
|
|
3
|
+
let isReplayRenderActive = false;
|
|
4
|
+
const pendingReplayUnmounts = new Map();
|
|
5
|
+
const getOnUnmountData = (vnode) => vnode.data?.[onUnmountDataKey];
|
|
6
|
+
const setOnUnmountData = (data, onUnmount) => {
|
|
7
|
+
data[onUnmountDataKey] = onUnmount;
|
|
8
|
+
data[vnodeDataMaskKey] =
|
|
9
|
+
(data[vnodeDataMaskKey] ?? 0) | VNodeDataMask.OnUnmount;
|
|
10
|
+
};
|
|
11
|
+
/** Opens the replay-render window used to distinguish historical VNodes from
|
|
12
|
+
* the live imperative lifecycle they temporarily replace. */
|
|
13
|
+
export const beginReplayUnmountRender = () => {
|
|
14
|
+
pendingReplayUnmounts.clear();
|
|
15
|
+
isReplayRenderActive = true;
|
|
16
|
+
};
|
|
17
|
+
/** Closes a successful replay-render window and discards live `OnUnmount`
|
|
18
|
+
* callbacks deferred while installing the historical view. */
|
|
19
|
+
export const endReplayUnmountRender = () => {
|
|
20
|
+
isReplayRenderActive = false;
|
|
21
|
+
pendingReplayUnmounts.clear();
|
|
22
|
+
};
|
|
23
|
+
/** Records an `OnUnmount` callback and the render that owns it on a VNode. */
|
|
24
|
+
export const attachOnUnmount = (data, dispatch) => {
|
|
25
|
+
const owner = isReplayRenderActive ? 'Replay' : 'Live';
|
|
26
|
+
const existing = data[onUnmountDataKey];
|
|
27
|
+
setOnUnmountData(data, {
|
|
28
|
+
dispatches: existing?.owner === owner
|
|
29
|
+
? [...existing.dispatches, dispatch]
|
|
30
|
+
: [dispatch],
|
|
31
|
+
owner,
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
/** Dispatches the live `OnUnmount` callbacks deferred by a replay patch that
|
|
35
|
+
* failed and forced the runtime to discard the damaged DOM. Repeated destroy
|
|
36
|
+
* calls for one element are deduplicated without conflating distinct elements
|
|
37
|
+
* built from a shared VNode. */
|
|
38
|
+
export const flushReplayUnmountsAfterPatchFailure = () => {
|
|
39
|
+
if (!isReplayRenderActive) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const unmountGroups = globalThis.Array.from(pendingReplayUnmounts.values());
|
|
43
|
+
pendingReplayUnmounts.clear();
|
|
44
|
+
for (const unmounts of unmountGroups) {
|
|
45
|
+
for (const dispatchUnmount of unmounts) {
|
|
46
|
+
dispatchUnmount();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
/** Snabbdom module that preserves a live element's `OnUnmount` ownership while
|
|
51
|
+
* replay VNodes patch it in place, then routes teardown according to whether
|
|
52
|
+
* the historical patch succeeded or required recovery. */
|
|
53
|
+
export const onUnmountModule = {
|
|
54
|
+
dataMask: VNodeDataMask.OnUnmount,
|
|
55
|
+
update: (oldVnode, vnode) => {
|
|
56
|
+
const previousOnUnmount = getOnUnmountData(oldVnode);
|
|
57
|
+
if (!isReplayRenderActive || previousOnUnmount?.owner !== 'Live') {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const data = vnode.data === undefined ? {} : { ...vnode.data };
|
|
61
|
+
vnode.data = data;
|
|
62
|
+
setOnUnmountData(data, previousOnUnmount);
|
|
63
|
+
},
|
|
64
|
+
destroy: vnode => {
|
|
65
|
+
const onUnmount = getOnUnmountData(vnode);
|
|
66
|
+
if (onUnmount?.owner !== 'Live') {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (isReplayRenderActive) {
|
|
70
|
+
if (vnode.elm !== undefined) {
|
|
71
|
+
pendingReplayUnmounts.set(vnode.elm, onUnmount.dispatches);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
for (const dispatchUnmount of onUnmount.dispatches) {
|
|
76
|
+
dispatchUnmount();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
};
|
package/dist/port/port.d.ts
CHANGED
|
@@ -44,8 +44,8 @@ export type Ports = Readonly<{
|
|
|
44
44
|
* @example
|
|
45
45
|
* ```ts
|
|
46
46
|
* export const ports = {
|
|
47
|
-
* inbound: { stepChanged: Port.inbound(
|
|
48
|
-
* outbound: { countChanged: Port.outbound(
|
|
47
|
+
* inbound: { stepChanged: Port.inbound(Schema.Number) },
|
|
48
|
+
* outbound: { countChanged: Port.outbound(Schema.Number) },
|
|
49
49
|
* }
|
|
50
50
|
* ```
|
|
51
51
|
*/
|
|
@@ -58,8 +58,8 @@ export declare const inbound: <Value, Encoded>(schema: Schema.Codec<Value, Encod
|
|
|
58
58
|
* @example
|
|
59
59
|
* ```ts
|
|
60
60
|
* export const ports = {
|
|
61
|
-
* inbound: { stepChanged: Port.inbound(
|
|
62
|
-
* outbound: { countChanged: Port.outbound(
|
|
61
|
+
* inbound: { stepChanged: Port.inbound(Schema.Number) },
|
|
62
|
+
* outbound: { countChanged: Port.outbound(Schema.Number) },
|
|
63
63
|
* }
|
|
64
64
|
* ```
|
|
65
65
|
*/
|
|
@@ -126,7 +126,7 @@ export declare const subscription: <Value, Encoded, Message>(port: Inbound<Value
|
|
|
126
126
|
*
|
|
127
127
|
* ```ts
|
|
128
128
|
* const ReportCount = Command.define('ReportCount', {
|
|
129
|
-
* args: { count:
|
|
129
|
+
* args: { count: Schema.Number },
|
|
130
130
|
* messages: [CompletedReportCount],
|
|
131
131
|
* execute: ({ count }) =>
|
|
132
132
|
* Port.emit(ports.outbound.countChanged, count).pipe(
|
package/dist/port/port.js
CHANGED
|
@@ -14,8 +14,8 @@ export const OutboundTypeId = Symbol.for('foldkit/Port/Outbound');
|
|
|
14
14
|
* @example
|
|
15
15
|
* ```ts
|
|
16
16
|
* export const ports = {
|
|
17
|
-
* inbound: { stepChanged: Port.inbound(
|
|
18
|
-
* outbound: { countChanged: Port.outbound(
|
|
17
|
+
* inbound: { stepChanged: Port.inbound(Schema.Number) },
|
|
18
|
+
* outbound: { countChanged: Port.outbound(Schema.Number) },
|
|
19
19
|
* }
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
@@ -31,8 +31,8 @@ export const inbound = (schema) => ({
|
|
|
31
31
|
* @example
|
|
32
32
|
* ```ts
|
|
33
33
|
* export const ports = {
|
|
34
|
-
* inbound: { stepChanged: Port.inbound(
|
|
35
|
-
* outbound: { countChanged: Port.outbound(
|
|
34
|
+
* inbound: { stepChanged: Port.inbound(Schema.Number) },
|
|
35
|
+
* outbound: { countChanged: Port.outbound(Schema.Number) },
|
|
36
36
|
* }
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
@@ -129,7 +129,7 @@ export const subscription = (port, toMessage) => persistent(Stream.map(stream(po
|
|
|
129
129
|
*
|
|
130
130
|
* ```ts
|
|
131
131
|
* const ReportCount = Command.define('ReportCount', {
|
|
132
|
-
* args: { count:
|
|
132
|
+
* args: { count: Schema.Number },
|
|
133
133
|
* messages: [CompletedReportCount],
|
|
134
134
|
* execute: ({ count }) =>
|
|
135
135
|
* Port.emit(ports.outbound.countChanged, count).pipe(
|
package/dist/route/parser.d.ts
CHANGED
|
@@ -118,7 +118,7 @@ export declare const __isSingleSegment: (segment: string) => boolean;
|
|
|
118
118
|
*
|
|
119
119
|
* @example
|
|
120
120
|
* ```ts
|
|
121
|
-
* const UserId =
|
|
121
|
+
* const UserId = Schema.String.pipe(Schema.brand('UserId'))
|
|
122
122
|
* pipe(literal('users'), slash(schemaSegment('userId', UserId)), mapTo(UserRoute))
|
|
123
123
|
* // parses /users/abc into { _tag: 'UserRoute', userId: UserId.make('abc') }
|
|
124
124
|
* ```
|
|
@@ -255,7 +255,7 @@ export declare const slash: {
|
|
|
255
255
|
* ```ts
|
|
256
256
|
* pipe(
|
|
257
257
|
* literal('search'),
|
|
258
|
-
* query(
|
|
258
|
+
* query(Schema.Struct({ q: Schema.String })),
|
|
259
259
|
* mapTo(SearchRoute),
|
|
260
260
|
* )
|
|
261
261
|
* ```
|
package/dist/route/parser.js
CHANGED
|
@@ -122,7 +122,7 @@ const warnIfNotSingleSegment = (name, segment) => Effect.sync(() => {
|
|
|
122
122
|
*
|
|
123
123
|
* @example
|
|
124
124
|
* ```ts
|
|
125
|
-
* const UserId =
|
|
125
|
+
* const UserId = Schema.String.pipe(Schema.brand('UserId'))
|
|
126
126
|
* pipe(literal('users'), slash(schemaSegment('userId', UserId)), mapTo(UserRoute))
|
|
127
127
|
* // parses /users/abc into { _tag: 'UserRoute', userId: UserId.make('abc') }
|
|
128
128
|
* ```
|
|
@@ -363,7 +363,7 @@ export const slash = (parserB) => (parserA) => ({
|
|
|
363
363
|
* ```ts
|
|
364
364
|
* pipe(
|
|
365
365
|
* literal('search'),
|
|
366
|
-
* query(
|
|
366
|
+
* query(Schema.Struct({ q: Schema.String })),
|
|
367
367
|
* mapTo(SearchRoute),
|
|
368
368
|
* )
|
|
369
369
|
* ```
|