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.
Files changed (201) hide show
  1. package/README.md +3 -3
  2. package/dist/asyncData/asyncData.d.ts +7 -7
  3. package/dist/asyncData/asyncData.d.ts.map +1 -1
  4. package/dist/asyncData/asyncData.js +12 -12
  5. package/dist/calendar/calendarDate.d.ts +15 -15
  6. package/dist/calendar/calendarDate.d.ts.map +1 -1
  7. package/dist/calendar/calendarDate.js +14 -14
  8. package/dist/calendar/comparison.d.ts +2 -2
  9. package/dist/calendar/comparison.d.ts.map +1 -1
  10. package/dist/calendar/comparison.js +5 -5
  11. package/dist/calendar/info.d.ts +2 -2
  12. package/dist/calendar/info.d.ts.map +1 -1
  13. package/dist/calendar/info.js +2 -2
  14. package/dist/calendar/locale.d.ts +7 -7
  15. package/dist/calendar/locale.d.ts.map +1 -1
  16. package/dist/calendar/locale.js +23 -23
  17. package/dist/canvas/shape.d.ts +89 -89
  18. package/dist/canvas/shape.d.ts.map +1 -1
  19. package/dist/canvas/shape.js +65 -53
  20. package/dist/command/index.d.ts +3 -3
  21. package/dist/customElement/index.d.ts +2 -2
  22. package/dist/customElement/index.js +2 -2
  23. package/dist/devTools/protocol.d.ts +278 -278
  24. package/dist/devTools/protocol.d.ts.map +1 -1
  25. package/dist/devTools/protocol.js +98 -92
  26. package/dist/devTools/schemaSummarize.d.ts.map +1 -1
  27. package/dist/devTools/schemaSummarize.js +24 -24
  28. package/dist/devTools/serialize.d.ts +1 -1
  29. package/dist/devTools/serialize.d.ts.map +1 -1
  30. package/dist/devTools/serialize.js +10 -10
  31. package/dist/devTools/store.d.ts.map +1 -1
  32. package/dist/devTools/store.js +52 -28
  33. package/dist/devTools/submodelPath.d.ts.map +1 -1
  34. package/dist/devTools/submodelPath.js +3 -3
  35. package/dist/devTools/summarize.d.ts +6 -6
  36. package/dist/devTools/summarize.d.ts.map +1 -1
  37. package/dist/devTools/summarize.js +13 -13
  38. package/dist/devTools/webSocketBridge.d.ts +3 -3
  39. package/dist/devTools/webSocketBridge.d.ts.map +1 -1
  40. package/dist/devTools/webSocketBridge.js +8 -8
  41. package/dist/dom/dom.d.ts +2 -0
  42. package/dist/dom/dom.d.ts.map +1 -1
  43. package/dist/dom/dom.js +47 -13
  44. package/dist/experimental/machine/machine.d.ts +29 -6
  45. package/dist/experimental/machine/machine.d.ts.map +1 -1
  46. package/dist/experimental/machine/machine.js +9 -8
  47. package/dist/experimental/server/entry.js +2 -2
  48. package/dist/experimental/server/serialize.js +2 -2
  49. package/dist/experimental/server/server.js +4 -4
  50. package/dist/fieldValidation/fieldValidation.d.ts +12 -12
  51. package/dist/fieldValidation/fieldValidation.d.ts.map +1 -1
  52. package/dist/fieldValidation/fieldValidation.js +9 -9
  53. package/dist/fieldValidation/rule.d.ts +2 -2
  54. package/dist/fieldValidation/rule.d.ts.map +1 -1
  55. package/dist/fieldValidation/rule.js +6 -6
  56. package/dist/file/file.d.ts +3 -3
  57. package/dist/file/file.d.ts.map +1 -1
  58. package/dist/file/file.js +3 -3
  59. package/dist/html/boundary.d.ts +93 -36
  60. package/dist/html/boundary.d.ts.map +1 -1
  61. package/dist/html/boundary.js +242 -75
  62. package/dist/html/childAttribute.d.ts +6 -4
  63. package/dist/html/childAttribute.d.ts.map +1 -1
  64. package/dist/html/childAttribute.js +7 -1
  65. package/dist/html/index.d.ts +31 -16
  66. package/dist/html/index.d.ts.map +1 -1
  67. package/dist/html/index.js +97 -40
  68. package/dist/html/lazy.d.ts +6 -6
  69. package/dist/html/lazy.d.ts.map +1 -1
  70. package/dist/html/lazy.js +37 -15
  71. package/dist/html/public.d.ts +1 -1
  72. package/dist/html/public.d.ts.map +1 -1
  73. package/dist/html/runtimeSingleton.d.ts +27 -6
  74. package/dist/html/runtimeSingleton.d.ts.map +1 -1
  75. package/dist/html/runtimeSingleton.js +46 -29
  76. package/dist/html/submodel.d.ts.map +1 -1
  77. package/dist/html/submodel.js +28 -39
  78. package/dist/http/http.d.ts +1 -1
  79. package/dist/http/http.js +1 -1
  80. package/dist/managedResource/managedResource.d.ts +5 -5
  81. package/dist/managedResource/managedResource.js +3 -3
  82. package/dist/mount/index.d.ts +92 -39
  83. package/dist/mount/index.d.ts.map +1 -1
  84. package/dist/mount/index.js +28 -8
  85. package/dist/mount/public.d.ts +1 -1
  86. package/dist/mount/public.d.ts.map +1 -1
  87. package/dist/mount/public.js +1 -1
  88. package/dist/navigation/urlRequest.d.ts +9 -9
  89. package/dist/navigation/urlRequest.d.ts.map +1 -1
  90. package/dist/navigation/urlRequest.js +2 -2
  91. package/dist/onUnmountModule.d.ts +19 -0
  92. package/dist/onUnmountModule.d.ts.map +1 -0
  93. package/dist/onUnmountModule.js +80 -0
  94. package/dist/port/port.d.ts +5 -5
  95. package/dist/port/port.js +5 -5
  96. package/dist/route/parser.d.ts +2 -2
  97. package/dist/route/parser.js +2 -2
  98. package/dist/runtime/hmrProtocol.d.ts +10 -10
  99. package/dist/runtime/hmrProtocol.d.ts.map +1 -1
  100. package/dist/runtime/hmrProtocol.js +10 -10
  101. package/dist/runtime/runtime.d.ts +4 -4
  102. package/dist/runtime/runtime.d.ts.map +1 -1
  103. package/dist/runtime/runtime.js +168 -51
  104. package/dist/schema/index.d.ts +41 -29
  105. package/dist/schema/index.d.ts.map +1 -1
  106. package/dist/schema/index.js +9 -9
  107. package/dist/snabbdom/init.d.ts +1 -1
  108. package/dist/snabbdom/init.d.ts.map +1 -1
  109. package/dist/snabbdom/init.js +5 -1
  110. package/dist/snabbdom/vnode.d.ts +1 -0
  111. package/dist/snabbdom/vnode.d.ts.map +1 -1
  112. package/dist/snabbdom/vnode.js +1 -0
  113. package/dist/subscription/animationFrame.d.ts +3 -3
  114. package/dist/subscription/animationFrame.d.ts.map +1 -1
  115. package/dist/subscription/animationFrame.js +2 -2
  116. package/dist/subscription/fromEvent.d.ts +2 -2
  117. package/dist/subscription/fromEvent.js +2 -2
  118. package/dist/subscription/subscription.d.ts +3 -3
  119. package/dist/subscription/subscription.js +1 -1
  120. package/dist/test/apps/bubbling.d.ts +6 -6
  121. package/dist/test/apps/bubbling.d.ts.map +1 -1
  122. package/dist/test/apps/bubbling.js +6 -6
  123. package/dist/test/apps/colorPicker.d.ts +7 -7
  124. package/dist/test/apps/colorPicker.d.ts.map +1 -1
  125. package/dist/test/apps/colorPicker.js +5 -5
  126. package/dist/test/apps/contextMenu.d.ts +5 -5
  127. package/dist/test/apps/contextMenu.d.ts.map +1 -1
  128. package/dist/test/apps/contextMenu.js +4 -4
  129. package/dist/test/apps/counter.d.ts +8 -8
  130. package/dist/test/apps/counter.d.ts.map +1 -1
  131. package/dist/test/apps/counter.js +8 -8
  132. package/dist/test/apps/crashOnRender.d.ts +18 -18
  133. package/dist/test/apps/crashOnRender.d.ts.map +1 -1
  134. package/dist/test/apps/crashOnRender.js +11 -11
  135. package/dist/test/apps/drafts.d.ts +9 -9
  136. package/dist/test/apps/drafts.d.ts.map +1 -1
  137. package/dist/test/apps/drafts.js +6 -6
  138. package/dist/test/apps/feedSocket.d.ts +6 -6
  139. package/dist/test/apps/feedSocket.d.ts.map +1 -1
  140. package/dist/test/apps/feedSocket.js +8 -8
  141. package/dist/test/apps/fileUpload.d.ts +2 -2
  142. package/dist/test/apps/fileUpload.d.ts.map +1 -1
  143. package/dist/test/apps/fileUpload.js +2 -2
  144. package/dist/test/apps/focusBoundary.d.ts +3 -3
  145. package/dist/test/apps/focusBoundary.d.ts.map +1 -1
  146. package/dist/test/apps/focusBoundary.js +3 -3
  147. package/dist/test/apps/formChild.d.ts +11 -11
  148. package/dist/test/apps/formChild.d.ts.map +1 -1
  149. package/dist/test/apps/formChild.js +13 -12
  150. package/dist/test/apps/interactions.d.ts +8 -8
  151. package/dist/test/apps/interactions.d.ts.map +1 -1
  152. package/dist/test/apps/interactions.js +8 -8
  153. package/dist/test/apps/keypress.d.ts +6 -6
  154. package/dist/test/apps/keypress.d.ts.map +1 -1
  155. package/dist/test/apps/keypress.js +6 -6
  156. package/dist/test/apps/login.d.ts +11 -11
  157. package/dist/test/apps/login.d.ts.map +1 -1
  158. package/dist/test/apps/login.js +15 -15
  159. package/dist/test/apps/logoutButton.d.ts +3 -3
  160. package/dist/test/apps/logoutButton.d.ts.map +1 -1
  161. package/dist/test/apps/logoutButton.js +2 -2
  162. package/dist/test/apps/mountPanel.d.ts +9 -9
  163. package/dist/test/apps/mountPanel.d.ts.map +1 -1
  164. package/dist/test/apps/mountPanel.js +9 -9
  165. package/dist/test/apps/multiRole.d.ts +3 -3
  166. package/dist/test/apps/multiRole.d.ts.map +1 -1
  167. package/dist/test/apps/multiRole.js +2 -2
  168. package/dist/test/apps/pointer.d.ts +7 -7
  169. package/dist/test/apps/pointer.d.ts.map +1 -1
  170. package/dist/test/apps/pointer.js +7 -7
  171. package/dist/test/apps/resumeUpload.d.ts +8 -8
  172. package/dist/test/apps/resumeUpload.d.ts.map +1 -1
  173. package/dist/test/apps/resumeUpload.js +7 -7
  174. package/dist/test/apps/scorePanel.d.ts +3 -3
  175. package/dist/test/apps/scorePanel.d.ts.map +1 -1
  176. package/dist/test/apps/scorePanel.js +2 -2
  177. package/dist/test/apps/selectiveKeys.d.ts +3 -3
  178. package/dist/test/apps/selectiveKeys.d.ts.map +1 -1
  179. package/dist/test/apps/selectiveKeys.js +3 -3
  180. package/dist/test/apps/uploads.d.ts +18 -18
  181. package/dist/test/apps/uploads.d.ts.map +1 -1
  182. package/dist/test/apps/uploads.js +13 -13
  183. package/dist/test/matchers.d.ts.map +1 -1
  184. package/dist/test/matchers.js +4 -4
  185. package/dist/test/query.d.ts.map +1 -1
  186. package/dist/test/query.js +28 -28
  187. package/dist/test/scene.d.ts +37 -8
  188. package/dist/test/scene.d.ts.map +1 -1
  189. package/dist/test/scene.js +58 -15
  190. package/dist/test/story.d.ts +35 -8
  191. package/dist/test/story.d.ts.map +1 -1
  192. package/dist/test/story.js +44 -22
  193. package/dist/update/update.d.ts +17 -20
  194. package/dist/update/update.d.ts.map +1 -1
  195. package/dist/url/index.d.ts +8 -8
  196. package/dist/url/index.d.ts.map +1 -1
  197. package/dist/url/index.js +19 -19
  198. package/dist/vdom.d.ts +3 -2
  199. package/dist/vdom.d.ts.map +1 -1
  200. package/dist/vdom.js +16 -6
  201. package/package.json +1 -1
@@ -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, and dispatches each Message emitted by the
21
- * returned Stream. The Stream's scope is tied to the element's lifetime: when
22
- * the element unmounts, the runtime interrupts the fiber, which closes the
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 returns an `Effect<Message>` that runs once
66
- * when the element mounts and produces exactly one Message.
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. An
71
- * args field named `element` is rejected where you declare it, since it would
72
- * collide with the element `execute` receives.
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: S.String, anchor: AnchorConfig },
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 & Readonly<{
185
- element?: ElementFieldIsReserved;
186
- }>;
235
+ args: Fields & ReservedExecuteFields;
187
236
  messages: Messages;
188
- execute: (input: Readonly<{
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: Readonly<{
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` alongside the declared args, and
204
- * returns a `Stream<Message>` whose lifetime is bound to the element's
205
- * lifetime: each emitted Message is dispatched, and the Stream's scope is
206
- * closed (running any registered `Effect.acquireRelease` finalizers) when the
207
- * element unmounts. Use this form when the Mount emits a continuum of events
208
- * from observers or listeners attached to the element.
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. An
213
- * args field named `element` is rejected where you declare it, since it would
214
- * collide with the element `execute` receives.
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 & Readonly<{
307
- element?: ElementFieldIsReserved;
308
- }>;
365
+ args: Fields & ReservedExecuteFields;
309
366
  messages: Messages;
310
- execute: (input: Readonly<{
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: Readonly<{
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,EACL,MAAM,EACP,MAAM,QAAQ,CAAA;;sBAWO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI;oBACxD,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI;;AAV1E;;;;;4CAK4C;AAC5C,qBAAa,YAAa,SAAQ,iBAMN;CAAG;AAE/B,mDAAmD;AAEnD,eAAO,MAAM,qBAAqB,EAAE,OAAO,MAEN,CAAA;AAErC,mDAAmD;AACnD,MAAM,MAAM,qBAAqB,GAAG,OAAO,qBAAqB,CAAA;AAEhE;;;;;;;;;;aAUa;AACb,MAAM,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC,GAAG,KAAK,IAAI,QAAQ,CAAC;IACrD,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;CACn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C,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"}
@@ -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
- const wrapEffectAsStream = (toEffect) => (element) => Stream.callback(queue => Effect.gen(function* () {
26
- const message = yield* toEffect(element);
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({ ...args, element }),
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({ element }),
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
  }));
@@ -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"}
@@ -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 as S } from 'effect';
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: S.Struct<{
6
- readonly protocol: S.String;
7
- readonly host: S.String;
8
- readonly port: S.Option<S.String>;
9
- readonly pathname: S.String;
10
- readonly search: S.Option<S.String>;
11
- readonly hash: S.Option<S.String>;
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: S.String;
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,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAKpC,4DAA4D;AAC5D,eAAO,MAAM,UAAU;;QACT,GAAG;;;;;;;;;;QACH,IAAI;;EAChB,CAAA;AACF,4DAA4D;AAC5D,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAA"}
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 as S } from 'effect';
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: S.String },
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
+ };
@@ -44,8 +44,8 @@ export type Ports = Readonly<{
44
44
  * @example
45
45
  * ```ts
46
46
  * export const ports = {
47
- * inbound: { stepChanged: Port.inbound(S.Number) },
48
- * outbound: { countChanged: Port.outbound(S.Number) },
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(S.Number) },
62
- * outbound: { countChanged: Port.outbound(S.Number) },
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: S.Number },
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(S.Number) },
18
- * outbound: { countChanged: Port.outbound(S.Number) },
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(S.Number) },
35
- * outbound: { countChanged: Port.outbound(S.Number) },
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: S.Number },
132
+ * args: { count: Schema.Number },
133
133
  * messages: [CompletedReportCount],
134
134
  * execute: ({ count }) =>
135
135
  * Port.emit(ports.outbound.countChanged, count).pipe(
@@ -118,7 +118,7 @@ export declare const __isSingleSegment: (segment: string) => boolean;
118
118
  *
119
119
  * @example
120
120
  * ```ts
121
- * const UserId = S.String.pipe(S.brand('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(S.Struct({ q: S.String })),
258
+ * query(Schema.Struct({ q: Schema.String })),
259
259
  * mapTo(SearchRoute),
260
260
  * )
261
261
  * ```
@@ -122,7 +122,7 @@ const warnIfNotSingleSegment = (name, segment) => Effect.sync(() => {
122
122
  *
123
123
  * @example
124
124
  * ```ts
125
- * const UserId = S.String.pipe(S.brand('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(S.Struct({ q: S.String })),
366
+ * query(Schema.Struct({ q: Schema.String })),
367
367
  * mapTo(SearchRoute),
368
368
  * )
369
369
  * ```