@wardic/foldkit 0.0.0-stage → 1.2.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 (154) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +59 -2
  3. package/THIRD_PARTY_NOTICES.md +145 -0
  4. package/dist/AnimationControls.d.ts +37 -0
  5. package/dist/AnimationControls.d.ts.map +1 -0
  6. package/dist/AnimationControls.js +37 -0
  7. package/dist/AnimationControls.js.map +1 -0
  8. package/dist/AnimationScope.d.ts +20 -0
  9. package/dist/AnimationScope.d.ts.map +1 -0
  10. package/dist/AnimationScope.js +20 -0
  11. package/dist/AnimationScope.js.map +1 -0
  12. package/dist/DragControls.d.ts +25 -0
  13. package/dist/DragControls.d.ts.map +1 -0
  14. package/dist/DragControls.js +21 -0
  15. package/dist/DragControls.js.map +1 -0
  16. package/dist/Features.d.ts +36 -0
  17. package/dist/Features.d.ts.map +1 -0
  18. package/dist/Features.js +44 -0
  19. package/dist/Features.js.map +1 -0
  20. package/dist/Ward.d.ts +301 -0
  21. package/dist/Ward.d.ts.map +1 -0
  22. package/dist/Ward.js +6 -0
  23. package/dist/Ward.js.map +1 -0
  24. package/dist/Wardic.d.ts +363 -0
  25. package/dist/Wardic.d.ts.map +1 -0
  26. package/dist/Wardic.js +85 -0
  27. package/dist/Wardic.js.map +1 -0
  28. package/dist/index.d.ts +15 -0
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +20 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/internal/builder.d.ts +8 -0
  33. package/dist/internal/builder.d.ts.map +1 -0
  34. package/dist/internal/builder.js +242 -0
  35. package/dist/internal/builder.js.map +1 -0
  36. package/dist/internal/commands.d.ts +143 -0
  37. package/dist/internal/commands.d.ts.map +1 -0
  38. package/dist/internal/commands.js +242 -0
  39. package/dist/internal/commands.js.map +1 -0
  40. package/dist/internal/delivery.d.ts +44 -0
  41. package/dist/internal/delivery.d.ts.map +1 -0
  42. package/dist/internal/delivery.js +85 -0
  43. package/dist/internal/delivery.js.map +1 -0
  44. package/dist/internal/dev.d.ts +10 -0
  45. package/dist/internal/dev.d.ts.map +1 -0
  46. package/dist/internal/dev.js +10 -0
  47. package/dist/internal/dev.js.map +1 -0
  48. package/dist/internal/dev.production.d.ts +8 -0
  49. package/dist/internal/dev.production.d.ts.map +1 -0
  50. package/dist/internal/dev.production.js +8 -0
  51. package/dist/internal/dev.production.js.map +1 -0
  52. package/dist/internal/drag.d.ts +66 -0
  53. package/dist/internal/drag.d.ts.map +1 -0
  54. package/dist/internal/drag.js +71 -0
  55. package/dist/internal/drag.js.map +1 -0
  56. package/dist/internal/element.d.ts +59 -0
  57. package/dist/internal/element.d.ts.map +1 -0
  58. package/dist/internal/element.js +582 -0
  59. package/dist/internal/element.js.map +1 -0
  60. package/dist/internal/gestures.d.ts +62 -0
  61. package/dist/internal/gestures.d.ts.map +1 -0
  62. package/dist/internal/gestures.js +109 -0
  63. package/dist/internal/gestures.js.map +1 -0
  64. package/dist/internal/hydrate.d.ts +5 -0
  65. package/dist/internal/hydrate.d.ts.map +1 -0
  66. package/dist/internal/hydrate.js +27 -0
  67. package/dist/internal/hydrate.js.map +1 -0
  68. package/dist/internal/keys.d.ts +21 -0
  69. package/dist/internal/keys.d.ts.map +1 -0
  70. package/dist/internal/keys.js +12 -0
  71. package/dist/internal/keys.js.map +1 -0
  72. package/dist/internal/layout.d.ts +29 -0
  73. package/dist/internal/layout.d.ts.map +1 -0
  74. package/dist/internal/layout.js +88 -0
  75. package/dist/internal/layout.js.map +1 -0
  76. package/dist/internal/mount.d.ts +22 -0
  77. package/dist/internal/mount.d.ts.map +1 -0
  78. package/dist/internal/mount.js +100 -0
  79. package/dist/internal/mount.js.map +1 -0
  80. package/dist/internal/presence.d.ts +33 -0
  81. package/dist/internal/presence.d.ts.map +1 -0
  82. package/dist/internal/presence.js +338 -0
  83. package/dist/internal/presence.js.map +1 -0
  84. package/dist/internal/reactivity.d.ts +15 -0
  85. package/dist/internal/reactivity.d.ts.map +1 -0
  86. package/dist/internal/reactivity.js +26 -0
  87. package/dist/internal/reactivity.js.map +1 -0
  88. package/dist/internal/reorder.d.ts +47 -0
  89. package/dist/internal/reorder.d.ts.map +1 -0
  90. package/dist/internal/reorder.js +250 -0
  91. package/dist/internal/reorder.js.map +1 -0
  92. package/dist/internal/scope.d.ts +28 -0
  93. package/dist/internal/scope.d.ts.map +1 -0
  94. package/dist/internal/scope.js +44 -0
  95. package/dist/internal/scope.js.map +1 -0
  96. package/dist/internal/server.d.ts +13 -0
  97. package/dist/internal/server.d.ts.map +1 -0
  98. package/dist/internal/server.js +13 -0
  99. package/dist/internal/server.js.map +1 -0
  100. package/dist/internal/server.node.d.ts +8 -0
  101. package/dist/internal/server.node.d.ts.map +1 -0
  102. package/dist/internal/server.node.js +8 -0
  103. package/dist/internal/server.node.js.map +1 -0
  104. package/dist/internal/services.d.ts +222 -0
  105. package/dist/internal/services.d.ts.map +1 -0
  106. package/dist/internal/services.js +338 -0
  107. package/dist/internal/services.js.map +1 -0
  108. package/dist/internal/tree.d.ts +71 -0
  109. package/dist/internal/tree.d.ts.map +1 -0
  110. package/dist/internal/tree.js +207 -0
  111. package/dist/internal/tree.js.map +1 -0
  112. package/dist/internal/variant-node.d.ts +62 -0
  113. package/dist/internal/variant-node.d.ts.map +1 -0
  114. package/dist/internal/variant-node.js +279 -0
  115. package/dist/internal/variant-node.js.map +1 -0
  116. package/dist/internal/view-transition.d.ts +10 -0
  117. package/dist/internal/view-transition.d.ts.map +1 -0
  118. package/dist/internal/view-transition.js +36 -0
  119. package/dist/internal/view-transition.js.map +1 -0
  120. package/dist/internal/walk.d.ts +26 -0
  121. package/dist/internal/walk.d.ts.map +1 -0
  122. package/dist/internal/walk.js +162 -0
  123. package/dist/internal/walk.js.map +1 -0
  124. package/package.json +99 -4
  125. package/src/AnimationControls.ts +46 -0
  126. package/src/AnimationScope.ts +19 -0
  127. package/src/DragControls.ts +27 -0
  128. package/src/Features.ts +45 -0
  129. package/src/Ward.ts +434 -0
  130. package/src/Wardic.ts +410 -0
  131. package/src/index.ts +20 -0
  132. package/src/internal/builder.ts +262 -0
  133. package/src/internal/commands.ts +359 -0
  134. package/src/internal/delivery.ts +116 -0
  135. package/src/internal/dev.production.ts +7 -0
  136. package/src/internal/dev.ts +9 -0
  137. package/src/internal/drag.ts +136 -0
  138. package/src/internal/element.ts +668 -0
  139. package/src/internal/gestures.ts +184 -0
  140. package/src/internal/hydrate.ts +29 -0
  141. package/src/internal/keys.ts +19 -0
  142. package/src/internal/layout.ts +109 -0
  143. package/src/internal/mount.ts +124 -0
  144. package/src/internal/presence.ts +362 -0
  145. package/src/internal/reactivity.ts +45 -0
  146. package/src/internal/reorder.ts +313 -0
  147. package/src/internal/scope.ts +60 -0
  148. package/src/internal/server.node.ts +7 -0
  149. package/src/internal/server.ts +12 -0
  150. package/src/internal/services.ts +486 -0
  151. package/src/internal/tree.ts +230 -0
  152. package/src/internal/variant-node.ts +352 -0
  153. package/src/internal/view-transition.ts +43 -0
  154. package/src/internal/walk.ts +211 -0
@@ -0,0 +1,222 @@
1
+ /**
2
+ * Where elements get Wardic's services (ADR-0071, decisions 9 and 31; *Amendment (#791)*): the seam
3
+ * that differs on Foldkit's preview. On 0.170, a **Handle** (`Wardic.make`) holds its **Provider**:
4
+ * Wardic's Layer built on the Handle's `env` into a Scope the Handle owns, by the first `w.*` element to
5
+ * mount while none is live, on that element's Mount fiber (so Foldkit's scheduler is inherited, decision
6
+ * 11), inside the patch (P2). Every `w.*` element counts itself in at mount and out at its release; once
7
+ * the last has left, the Handle closes the Scope at the end of the task, so a patch that swaps every
8
+ * element keeps the runtime. `w.Provider(options)` names the element the subtree options hang on (slice
9
+ * 2's); a second one while that element is mounted is reported and ignored.
10
+ *
11
+ * @module
12
+ */
13
+ import * as DefaultTransition from "@wardic/core/DefaultTransition";
14
+ import * as FrameLoop from "@wardic/core/FrameLoop";
15
+ import * as ReducedMotion from "@wardic/core/ReducedMotion";
16
+ import * as RefreshFrameSource from "@wardic/core/RefreshFrameSource";
17
+ import * as Renderer from "@wardic/core/Renderer";
18
+ import * as WardicServices from "@wardic/core/unstable/WardicServices";
19
+ import * as FlushGate from "@wardic/dom/FlushGate";
20
+ import * as ElementSetup from "@wardic/dom/unstable/ElementSetup";
21
+ import * as Feature from "@wardic/dom/unstable/Feature";
22
+ import * as Cause from "effect/Cause";
23
+ import * as Context from "effect/Context";
24
+ import * as Deferred from "effect/Deferred";
25
+ import * as Effect from "effect/Effect";
26
+ import * as AtomRegistry from "effect/reactivity/AtomRegistry";
27
+ import * as Scope from "effect/Scope";
28
+ import * as WardicConfigValue from "@wardic/core/unstable/WardicConfigValue";
29
+ import type * as Ward from "../Ward.ts";
30
+ import type { MakeOptions } from "../Wardic.ts";
31
+ /** A live **Provider**: Wardic's services built on an app's `env`, read once, as a Solid provider's context value holds them. */
32
+ export interface Provider {
33
+ /** Its runtime: the Runner the legs fork on, with the memo map its Features build into. */
34
+ readonly runtime: Feature.FeatureRuntime;
35
+ /** Its services, built: what `Wardic.provide` runs a Command's Effect with. */
36
+ readonly context: Context.Context<Feature.ProviderServices>;
37
+ /** Its Frame loop, for the binding's hint (decision 32). */
38
+ readonly loop: FrameLoop.FrameLoop["Service"];
39
+ /** Its Atom registry: what Live values are read through (decision 16). */
40
+ readonly atoms: AtomRegistry.AtomRegistry;
41
+ /** The Environment's Renderer (ADR-0003): what a presence's retained node commits its exit through. */
42
+ readonly renderer: Renderer.Renderer["Service"];
43
+ /** Its flush gate (ADR-0006). */
44
+ readonly gate: FlushGate.Shape;
45
+ /** Whether reduced motion applies now (ADR-0029): the user's preference, read as each animation starts. */
46
+ readonly reducedMotion: () => boolean;
47
+ /** Whether the user prefers reduced motion now, through the Probe's atom: what a `w.Config` setting is applied with. */
48
+ readonly prefers: () => boolean;
49
+ readonly positionalKeys: ReducedMotion.PositionalKeys["Service"];
50
+ readonly defaultTransition: DefaultTransition.DefaultTransition["Service"];
51
+ /** Its elements' reads of their values (#672): the Environment's, the DOM's where it gives none. */
52
+ readonly valueReads: ElementSetup.ElementValueReads;
53
+ /** The Environment's Refresh frames (ADR-0031), for what waits a frame out; `undefined` for one that gives none. */
54
+ readonly frames: RefreshFrameSource.Shape | undefined;
55
+ /** Its Features (#511), each built on first need. */
56
+ readonly registry: Feature.FeatureRegistry;
57
+ /**
58
+ * The Handle's Features in it (#516; #793, Q2): their services now, those given built on first need
59
+ * and each load's built as it arrives, and whether a load is still on its way.
60
+ */
61
+ readonly features: Feature.Own;
62
+ /** Run `recheck` as a load's Features arrive, until what's returned is called: an element re-checks what it wants then (Q15). */
63
+ readonly onFeatures: (recheck: () => void) => () => void;
64
+ /** The Scope the Handle owns it in: closed once its last element has left. */
65
+ readonly scope: Scope.Closeable;
66
+ /** The element carrying `w.Provider(options)`, while it's mounted: what the subtree options (slice 2) hang on, and what a selector resolves under. */
67
+ root: Element | undefined;
68
+ /** Its members, counted: its mounted `w.*` elements, and the Commands' animations and `provide`s while they run. */
69
+ elements: number;
70
+ /** The Mounts whose view DevTools replay has (decision 34): while any, no hint is given from a provider-wide delivery. */
71
+ readonly pausedViews: Set<object>;
72
+ /** Whether DevTools replay has a view now. */
73
+ readonly paused: () => boolean;
74
+ }
75
+ /** How the Measure passes are triggered (decision 30; #792, Q17): `Wardic.make`'s `layoutTrigger` and `layoutAttributes`. */
76
+ export interface LayoutOptions {
77
+ readonly trigger: "patch" | "declared" | undefined;
78
+ readonly attributes: ReadonlyArray<string> | undefined;
79
+ }
80
+ /** What a Handle holds of its provider: the live one, the `Deferred` a build in flight completes, and its Features. */
81
+ export interface State {
82
+ readonly env: WardicServices.WardicEnv;
83
+ /** Its Features (#516), as a Wardic instance's: those given, and each load started once per Handle (dom's `InstanceFeatures`); none without any. */
84
+ readonly instance: Feature.InstanceFeatures | undefined;
85
+ /** The Handle's app-wide config (`Wardic.make({ config })`), the root of every element's `w.Config` chain; none without one. */
86
+ readonly rootConfig: WardicConfigValue.WardicConfigValue | undefined;
87
+ /** How its Measure passes are triggered (decision 30). */
88
+ readonly layout: LayoutOptions;
89
+ /**
90
+ * Whether the render under way is a View Transition's (decision 33): the next pass asked for by the
91
+ * app's own changes, a `w.LayoutDependency` change or `Wardic.animateLayout` is an Instant change of
92
+ * the layout. Set by each decision, cleared by the pass that consumes it.
93
+ */
94
+ transitioning: boolean;
95
+ deferred: Deferred.Deferred<Provider>;
96
+ live: Provider | undefined;
97
+ /** Whether a build is in flight: an `env` that waits as it builds has the elements after the first await the `Deferred`. */
98
+ building: boolean;
99
+ /** A server render's Appear animations (#794, Q3, Q13): `Wardic.make({ appear, nonce })`, read by the walk at the Provider element's build. */
100
+ readonly server: ServerOptions;
101
+ /** On a server, in development (#794, Q4): the render under way, or none between renders. */
102
+ render: ServerRender | undefined;
103
+ /** Development's words on the server, each said once a Handle. */
104
+ readonly said: Set<string>;
105
+ /**
106
+ * Whether a client render names each element's Appear slot (#794, Q9 and Q10): the hydration render,
107
+ * and every render after it while a Handoff is still under way, so hydration keeps the inline
108
+ * `animation` the CSS plays through and no render strips one before its ward has taken it over. Set
109
+ * by `wardic.hydrate` when the page carries the Appear chunk a server rendered; cleared once every
110
+ * Handoff the hydration patch's Mounts found has released (its first commit), or, with none found,
111
+ * after those Mounts ({@link hydrationMounted}).
112
+ */
113
+ hydrating: boolean;
114
+ /** The Handoffs under way: hydrated elements whose Appear animation their ward hasn't yet taken over. */
115
+ pending: number;
116
+ /** The live `w.Presence`s (#840), each with what the Handle calls on it: see {@link LivePresence}. */
117
+ readonly presences: Set<LivePresence>;
118
+ /** Whether the live presences' snapshots stand (#840): taken by {@link snapshotPopLayouts}, spent by {@link snapshotSpent}. */
119
+ snapshotted: boolean;
120
+ }
121
+ /**
122
+ * A live `w.Presence`'s hooks the Handle calls (#840): `snapshot`, its children measured where they are,
123
+ * ahead of a patch, which `popLayout` pins the next change's leavers at; `flush`, its delivery run now
124
+ * from the records its observer holds, ahead of a `w.*` element's mount, so a presence inside an entering
125
+ * child starts that child's elements after this one has pinned its leavers.
126
+ */
127
+ export interface LivePresence {
128
+ readonly snapshot: () => void;
129
+ readonly flush: () => void;
130
+ }
131
+ /**
132
+ * Every live `popLayout` presence's children measured where they are (#840): called as a view renders a
133
+ * `w.Presence({ mode: "popLayout" })` element, before that render's patch. A presence's delivery comes a
134
+ * microtask after the patch, when a sibling the patch put in has already moved a leaver, so the box to
135
+ * pin the leaver at is read here, as Motion's `PopChild` reads it before React's update. Taken once for
136
+ * every such element a view renders: the snapshots stand until a microtask later, when the patch's
137
+ * deliveries have had them, or until a delivery spends them ({@link snapshotSpent}), so a render after
138
+ * it in the same task, as a Mount's message brings, measures afresh.
139
+ */
140
+ export declare const snapshotPopLayouts: (state: State) => void;
141
+ /** The live presences' snapshots spent (#840): what a presence's delivery says as it tells its controller what's shown, which pins at the snapshot and clears it. */
142
+ export declare const snapshotSpent: (state: State) => void;
143
+ /** Every live presence's delivery run now (#840): what a `w.*` element's Mount does before the element registers anything. */
144
+ export declare const flushPresences: (state: State) => void;
145
+ /** What a Handle renders a server's Appear animations with (ADR-0044; #794): `Wardic.make`'s `appear` and `nonce`. */
146
+ export interface ServerOptions {
147
+ readonly appear: boolean | "explain" | undefined;
148
+ readonly nonce: string | undefined;
149
+ }
150
+ /**
151
+ * A server render under way, in development (#794, Q4): opened by its first `w.*` element and closed by
152
+ * a microtask after the view's build (one synchronous call, the Provider element built last), when it
153
+ * gets its word with no Provider element, or with more than one. One a tick: two views built in one
154
+ * synchronous run share it.
155
+ */
156
+ export interface ServerRender {
157
+ /** Its Provider elements, counted as they build. */
158
+ providers: number;
159
+ }
160
+ /** Whether a Handle's server render plays Appear animations: unless `Wardic.make({ appear: false })` (ADR-0044 decision 5). */
161
+ export declare const appearsOn: (options: ServerOptions) => boolean;
162
+ /**
163
+ * `wardic.hydrate`'s word (#794, Q10): whether the page carries an Appear chunk, so the hydration render
164
+ * names each element's slot ({@link State.hydrating}); no Handoff under way yet.
165
+ */
166
+ export declare const hydrationStarts: (state: State, chunked: boolean) => void;
167
+ /**
168
+ * A Mount's word while hydration's window is open (#794, Q10): `handoff`, whether its element's Appear
169
+ * animation was found to take over. One found is counted in until what's returned is called, at its
170
+ * first commit (the Handoff's release) or at its teardown, and the last one out closes the window. A
171
+ * microtask after the hydration patch's Mounts, which run in one task, closes it with none found. A
172
+ * render in the window names each slot as the hydration render did; the first after it names none.
173
+ */
174
+ export declare const hydrationMounted: (state: State, handoff: boolean) => (() => void);
175
+ /** Note a `w.*` element's build on a server, in development ({@link ServerRender}): `provider` when it carries `w.Provider()`. None of the words under `appear: false`. */
176
+ export declare const noteServerRender: (state: State, provider: boolean) => void;
177
+ /** Keep `state` as `handle`'s, for {@link stateOf}. */
178
+ export declare const remember: (handle: object, state: State) => void;
179
+ /** The state of a Handle `Wardic.make` made: what `Wardic.animate` and `provide` reach through the `Wardic` service. */
180
+ export declare const stateOf: (handle: object) => State;
181
+ /**
182
+ * The registry a Handle's Live values are read through now (#791, Q12): the live Provider's, else a
183
+ * scratch one, which gives a plain Atom its value and a derived one its initial, as a server render
184
+ * reads them, for a Starting style rendered before the Provider exists.
185
+ */
186
+ export declare const registryOf: (state: State) => (() => AtomRegistry.AtomRegistry);
187
+ /** A Handle's state: no provider yet. */
188
+ export declare const makeState: (options: MakeOptions<Feature.InstanceFeaturesProp>) => State;
189
+ /**
190
+ * The service of a Feature the Handle has, built now if nothing has built it (#792, Q9): what
191
+ * `w.Presence` finds its controller by, and a gesture its recognizer. `undefined` when the Handle wasn't
192
+ * given the Feature, or its load hasn't arrived.
193
+ */
194
+ export declare const featureIn: <I, S>(provider: Provider, key: Context.Key<I, S>) => S | undefined;
195
+ /** Development's word on a Feature the Handle wasn't given (#511, ADR-0067 decision 7): dom's, with how a Handle takes one. */
196
+ export declare const missingMessage: (feature: string, what: string) => string;
197
+ /**
198
+ * Development's word on `feature`, wanted by an element without being given (#511, ADR-0067 decision 7):
199
+ * once per provider, and not while a load is on its way (#793, Q15), which may bring it.
200
+ */
201
+ export declare const warnMissing: (provider: Provider, feature: string, what: string) => void;
202
+ /** What reports an element's failure on the provider, `label` with its cause, annotated with the element's id. */
203
+ export declare const reporterOf: (provider: Provider, id: string) => ((label: string, cause: Cause.Cause<never>) => void);
204
+ /**
205
+ * The Handle's Provider for a mounting element: the live one; else, with a build in flight, the one
206
+ * its `Deferred` completes with; else built now, on this fiber. With `options` (the element carries
207
+ * `w.Provider(options)`), `element` becomes the Provider's root, unless another is mounted as one.
208
+ */
209
+ export declare const providerFor: (state: State, element: Element | undefined, options: Ward.ProviderOptions | undefined) => Effect.Effect<Provider>;
210
+ /**
211
+ * Reduced motion (ADR-0029) under `value`, the nearest `w.Config` (decision 22): its setting applied to
212
+ * the user's preference, read as each animation starts; the Provider's own where no `w.Config` is above.
213
+ */
214
+ export declare const reducedMotionUnder: (provider: Provider, value: WardicConfigValue.WardicConfigValue | undefined) => (() => boolean);
215
+ /**
216
+ * Count a member in: a mounted element, or a Command's animation or `provide` (`undefined`, never the
217
+ * root). Returns what its release calls: the count out, the root given up when it was this element, and,
218
+ * once the last member has left, the Scope closed at the end of the task, so a patch that removes every
219
+ * element and inserts new ones keeps the runtime.
220
+ */
221
+ export declare const joined: (state: State, provider: Provider, member: Element | undefined) => (() => void);
222
+ //# sourceMappingURL=services.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../src/internal/services.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,iBAAiB,MAAM,gCAAgC,CAAA;AACnE,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAA;AAEnD,OAAO,KAAK,aAAa,MAAM,4BAA4B,CAAA;AAC3D,OAAO,KAAK,kBAAkB,MAAM,iCAAiC,CAAA;AACrE,OAAO,KAAK,QAAQ,MAAM,uBAAuB,CAAA;AAIjD,OAAO,KAAK,cAAc,MAAM,sCAAsC,CAAA;AACtE,OAAO,KAAK,SAAS,MAAM,uBAAuB,C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AC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,CAGpF,CAAA;AA8EH;;;;GAIG;AACH,eAAO,MAAM,WAAW,UAAW,KAAK,WAAW,OAAO,GAAG,SAAS,WAAW,IAAI,CAAC,eAAe,GAAG,SAAS,KAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAMtI,CAAA;AAEJ;;;GAGG;AACH,eAAO,MAAM,kBAAkB,aAAc,QAAQ,SAAS,iBAAiB,CAAC,iBAAiB,GAAG,SAAS,KAAG,CAAC,MAAM,OAAO,CAI1H,CAAA;AAsBJ;;;;;GAKG;AACH,eAAO,MAAM,MAAM,UAAW,KAAK,YAAY,QAAQ,UAAU,OAAO,GAAG,SAAS,KAAG,CAAC,MAAM,IAAI,CAkBjG,CAAA"}
@@ -0,0 +1,338 @@
1
+ /**
2
+ * Where elements get Wardic's services (ADR-0071, decisions 9 and 31; *Amendment (#791)*): the seam
3
+ * that differs on Foldkit's preview. On 0.170, a **Handle** (`Wardic.make`) holds its **Provider**:
4
+ * Wardic's Layer built on the Handle's `env` into a Scope the Handle owns, by the first `w.*` element to
5
+ * mount while none is live, on that element's Mount fiber (so Foldkit's scheduler is inherited, decision
6
+ * 11), inside the patch (P2). Every `w.*` element counts itself in at mount and out at its release; once
7
+ * the last has left, the Handle closes the Scope at the end of the task, so a patch that swaps every
8
+ * element keeps the runtime. `w.Provider(options)` names the element the subtree options hang on (slice
9
+ * 2's); a second one while that element is mounted is reported and ignored.
10
+ *
11
+ * @module
12
+ */
13
+ import * as DefaultTransition from "@wardic/core/DefaultTransition";
14
+ import * as FrameLoop from "@wardic/core/FrameLoop";
15
+ import * as Probe from "@wardic/core/Probe";
16
+ import * as ReducedMotion from "@wardic/core/ReducedMotion";
17
+ import * as RefreshFrameSource from "@wardic/core/RefreshFrameSource";
18
+ import * as Renderer from "@wardic/core/Renderer";
19
+ import * as MeasuredPairs from "@wardic/core/unstable/MeasuredPairs";
20
+ import * as OwnValues from "@wardic/core/unstable/OwnValues";
21
+ import * as VariableValues from "@wardic/core/unstable/VariableValues";
22
+ import * as WardicServices from "@wardic/core/unstable/WardicServices";
23
+ import * as FlushGate from "@wardic/dom/FlushGate";
24
+ import * as Report from "@wardic/dom/Report";
25
+ import * as ElementSetup from "@wardic/dom/unstable/ElementSetup";
26
+ import * as Feature from "@wardic/dom/unstable/Feature";
27
+ import * as GestureFeatures from "@wardic/dom/unstable/GestureFeatures";
28
+ import * as InstanceFeatures from "@wardic/dom/unstable/InstanceFeatures";
29
+ import * as LiveStyle from "@wardic/dom/unstable/LiveStyle";
30
+ import * as Bool from "effect/Boolean";
31
+ import * as Cause from "effect/Cause";
32
+ import * as Context from "effect/Context";
33
+ import * as Deferred from "effect/Deferred";
34
+ import * as Effect from "effect/Effect";
35
+ import * as Exit from "effect/Exit";
36
+ import { constFalse, constVoid, identity } from "effect/Function";
37
+ import * as Iter from "effect/Iterable";
38
+ import * as Layer from "effect/Layer";
39
+ import * as Option from "effect/Option";
40
+ import * as Predicate from "effect/Predicate";
41
+ import * as UndefinedOr from "effect/UndefinedOr";
42
+ import * as AtomRegistry from "effect/reactivity/AtomRegistry";
43
+ import * as Scope from "effect/Scope";
44
+ import * as WardicConfigValue from "@wardic/core/unstable/WardicConfigValue";
45
+ import { reactivity } from "./reactivity.js";
46
+ import { rootConfigValueOf } from "./tree.js";
47
+ import { DEV } from "@wardic/foldkit/internal/dev";
48
+ /**
49
+ * Every live `popLayout` presence's children measured where they are (#840): called as a view renders a
50
+ * `w.Presence({ mode: "popLayout" })` element, before that render's patch. A presence's delivery comes a
51
+ * microtask after the patch, when a sibling the patch put in has already moved a leaver, so the box to
52
+ * pin the leaver at is read here, as Motion's `PopChild` reads it before React's update. Taken once for
53
+ * every such element a view renders: the snapshots stand until a microtask later, when the patch's
54
+ * deliveries have had them, or until a delivery spends them ({@link snapshotSpent}), so a render after
55
+ * it in the same task, as a Mount's message brings, measures afresh.
56
+ */
57
+ export const snapshotPopLayouts = (state) => {
58
+ if (state.snapshotted)
59
+ return;
60
+ Iter.forEach(state.presences, (presence) => presence.snapshot());
61
+ state.snapshotted = true;
62
+ queueMicrotask(() => {
63
+ state.snapshotted = false;
64
+ });
65
+ };
66
+ /** The live presences' snapshots spent (#840): what a presence's delivery says as it tells its controller what's shown, which pins at the snapshot and clears it. */
67
+ export const snapshotSpent = (state) => {
68
+ state.snapshotted = false;
69
+ };
70
+ /** Every live presence's delivery run now (#840): what a `w.*` element's Mount does before the element registers anything. */
71
+ export const flushPresences = (state) => {
72
+ Iter.forEach(state.presences, (presence) => presence.flush());
73
+ };
74
+ /** Development's word on a server render with no Provider element (#794, Q4): the Starting style alone, no Appear animation. */
75
+ const NO_PROVIDER = "wardic.appear: a w.* element rendered on a server with no w.Provider() above it keeps its Starting style until the script runs: its Appear animation needs the Provider element, which renders the rules. Put w.Provider() on the topmost w.* element.";
76
+ /** Development's word on more than one Provider element in a server render: their Appear rules collide, and a nested one's are dropped for the one above (the client reports and ignores a second). */
77
+ const MANY_PROVIDERS = "wardic.appear: more than one w.Provider() in a server render: the Appear rules of one collide with another's, and a nested one's are dropped for the one above it. Give w.Provider() once, on the topmost w.* element.";
78
+ /** Whether a Handle's server render plays Appear animations: unless `Wardic.make({ appear: false })` (ADR-0044 decision 5). */
79
+ export const appearsOn = (options) => options.appear !== false;
80
+ /**
81
+ * `wardic.hydrate`'s word (#794, Q10): whether the page carries an Appear chunk, so the hydration render
82
+ * names each element's slot ({@link State.hydrating}); no Handoff under way yet.
83
+ */
84
+ export const hydrationStarts = (state, chunked) => {
85
+ state.hydrating = chunked;
86
+ state.pending = 0;
87
+ };
88
+ /**
89
+ * A Mount's word while hydration's window is open (#794, Q10): `handoff`, whether its element's Appear
90
+ * animation was found to take over. One found is counted in until what's returned is called, at its
91
+ * first commit (the Handoff's release) or at its teardown, and the last one out closes the window. A
92
+ * microtask after the hydration patch's Mounts, which run in one task, closes it with none found. A
93
+ * render in the window names each slot as the hydration render did; the first after it names none.
94
+ */
95
+ export const hydrationMounted = (state, handoff) => {
96
+ if (Bool.not(state.hydrating))
97
+ return constVoid;
98
+ if (handoff)
99
+ state.pending++;
100
+ queueMicrotask(() => closeUnlessPending(state));
101
+ let released = false;
102
+ return () => {
103
+ if (released)
104
+ return;
105
+ released = true;
106
+ if (Bool.not(handoff))
107
+ return;
108
+ state.pending--;
109
+ closeUnlessPending(state);
110
+ };
111
+ };
112
+ /** The window closed, unless a Handoff is still under way. */
113
+ const closeUnlessPending = (state) => {
114
+ if (state.pending > 0)
115
+ return;
116
+ state.hydrating = false;
117
+ };
118
+ /** Note a `w.*` element's build on a server, in development ({@link ServerRender}): `provider` when it carries `w.Provider()`. None of the words under `appear: false`. */
119
+ export const noteServerRender = (state, provider) => {
120
+ const render = UndefinedOr.match(state.render, {
121
+ onDefined: identity,
122
+ onUndefined: () => {
123
+ const opened = { providers: 0 };
124
+ state.render = opened;
125
+ queueMicrotask(() => {
126
+ state.render = undefined;
127
+ if (Bool.not(appearsOn(state.server)))
128
+ return;
129
+ if (opened.providers === 0)
130
+ sayOnce(state, NO_PROVIDER);
131
+ if (opened.providers > 1)
132
+ sayOnce(state, MANY_PROVIDERS);
133
+ });
134
+ return opened;
135
+ },
136
+ });
137
+ if (provider)
138
+ render.providers++;
139
+ };
140
+ /** `message` said once a Handle, with Effect's logger: a server builds no runtime from the app's `env` (dom's `explainerOf` says its words so too). */
141
+ const sayOnce = (state, message) => {
142
+ if (state.said.has(message))
143
+ return;
144
+ state.said.add(message);
145
+ Effect.runSync(Effect.logWarning(message));
146
+ };
147
+ // Module state (#460, Q7): each Handle's state, held weakly by the Handle, for the Commands' Effects.
148
+ const states = new WeakMap();
149
+ /** Keep `state` as `handle`'s, for {@link stateOf}. */
150
+ export const remember = (handle, state) => {
151
+ states.set(handle, state);
152
+ };
153
+ /** The state of a Handle `Wardic.make` made: what `Wardic.animate` and `provide` reach through the `Wardic` service. */
154
+ export const stateOf = (handle) => UndefinedOr.getOrThrow(states.get(handle));
155
+ /**
156
+ * The registry a Handle's Live values are read through now (#791, Q12): the live Provider's, else a
157
+ * scratch one, which gives a plain Atom its value and a derived one its initial, as a server render
158
+ * reads them, for a Starting style rendered before the Provider exists.
159
+ */
160
+ export const registryOf = (state) => () => UndefinedOr.match(state.live, { onUndefined: LiveStyle.serverRegistryOf, onDefined: (provider) => provider.atoms });
161
+ /** A Handle's state: no provider yet. */
162
+ export const makeState = (options) => ({
163
+ env: options.env,
164
+ instance: UndefinedOr.map(options.features, InstanceFeatures.instanceFeaturesOf),
165
+ rootConfig: rootConfigValueOf(options.config),
166
+ layout: { trigger: options.layoutTrigger, attributes: options.layoutAttributes },
167
+ transitioning: false,
168
+ deferred: Deferred.makeUnsafe(),
169
+ live: undefined,
170
+ building: false,
171
+ server: { appear: options.appear, nonce: options.nonce },
172
+ render: undefined,
173
+ said: new Set(),
174
+ hydrating: false,
175
+ pending: 0,
176
+ presences: new Set(),
177
+ snapshotted: false,
178
+ });
179
+ /**
180
+ * The service of a Feature the Handle has, built now if nothing has built it (#792, Q9): what
181
+ * `w.Presence` finds its controller by, and a gesture its recognizer. `undefined` when the Handle wasn't
182
+ * given the Feature, or its load hasn't arrived.
183
+ */
184
+ export const featureIn = (provider, key) => GestureFeatures.serviceIn(provider.features.services(), key);
185
+ /** A load of the Handle's Features that failed (#793, Q15): reported once, and the rest stand. */
186
+ const LOAD_FAILED = "wardic.features: a load of the Handle's Features failed; its Features are left out";
187
+ /** Development's word on a Feature the Handle wasn't given (#511, ADR-0067 decision 7): dom's, with how a Handle takes one. */
188
+ export const missingMessage = (feature, what) => Feature.missingMessage(feature, what, "@wardic/foldkit", `which this Handle wasn't given. Add it: \`import { Features } from "@wardic/foldkit"\`, then \`Wardic.make({ env, features: [Features.${feature}] })\`.`);
189
+ /**
190
+ * Development's word on `feature`, wanted by an element without being given (#511, ADR-0067 decision 7):
191
+ * once per provider, and not while a load is on its way (#793, Q15), which may bring it.
192
+ */
193
+ export const warnMissing = (provider, feature, what) => {
194
+ if (DEV && Bool.not(provider.features.pending()))
195
+ provider.registry.warnOnce(feature, missingMessage(feature, what));
196
+ };
197
+ /** What reports an element's failure on the provider, `label` with its cause, annotated with the element's id. */
198
+ export const reporterOf = (provider, id) => (label, cause) => {
199
+ provider.runtime.runFork(Report.failure(label, cause).pipe(Effect.annotateLogs({ id })));
200
+ };
201
+ /** No Features: a Handle made without any. */
202
+ const NO_FEATURES = { services: () => Feature.NONE, pending: constFalse };
203
+ /** A second `w.Provider()` for one Handle, while the first's element is mounted: reported, then ignored. */
204
+ const SECOND_PROVIDER = "wardic.provider: a second w.Provider() mounted while this Handle's is. A Handle has one: put w.Provider() on one w.* element at " +
205
+ "the top of the view, or make a Handle (Wardic.make) for each program.";
206
+ /** An Option's value, or `undefined`: an optional Environment member read from a built context. */
207
+ const optional = (context, service) => Option.getOrUndefined(Context.getOption(context, service));
208
+ /**
209
+ * Build Wardic's Layer on `state`'s `env` into a Scope of the Handle's own, with the flush gate and the
210
+ * projection options a provider adds (ADR-0006), on the current fiber: the first element's Mount's.
211
+ */
212
+ const build = (state) => Effect.gen(function* () {
213
+ const pausedViews = new Set();
214
+ const scope = Scope.makeUnsafe();
215
+ const memoMap = Layer.makeMemoMapUnsafe();
216
+ // Read as each layout animation starts (slice 2), through the Provider's own reader once it's made.
217
+ let reducedMotionNow = constFalse;
218
+ const projection = { reducedMotion: () => reducedMotionNow() };
219
+ const layer = Layer.merge(FlushGate.layer({ batch: (apply) => apply() }), Layer.succeed(Feature.ProjectionOptions)(projection)).pipe(Layer.provideMerge(state.env));
220
+ const context = yield* Layer.buildWithMemoMap(layer, memoMap, scope);
221
+ const runner = yield* Effect.provideContext(WardicServices.makeRunner(), Context.add(context, Scope.Scope, scope));
222
+ const runtime = { ...runner, memoMap };
223
+ // The user's preference, through the Probe's atom (ADR-0029); an app's setting comes with `w.Config` (slice 1, PR 2).
224
+ const atoms = Context.get(context, AtomRegistry.AtomRegistry);
225
+ const probe = Context.get(context, Probe.Probe);
226
+ const prefers = () => atoms.get(probe.prefersReducedMotion);
227
+ const reducedMotion = () => ReducedMotion.applies("user", prefers());
228
+ reducedMotionNow = reducedMotion;
229
+ const services = context;
230
+ // Its Features' Scope is a child of the runtime's, closed with it: nothing more to dispose.
231
+ const registry = Feature.clientRegistry(runtime, () => Promise.resolve());
232
+ // The Handle's Features in it (#793, Q2 and Q15): each load started now, its arrival told to the
233
+ // elements' re-checks directly, since no patch ran; a failed load reported once.
234
+ const rechecks = new Set();
235
+ const arrived = () => Iter.forEach(rechecks, (recheck) => recheck());
236
+ const host = { reactivity: { ...reactivity, trigger: () => ({ track: constVoid, notify: arrived }) }, server: false, report: (cause) => runner.runFork(Report.failure(LOAD_FAILED, cause)) };
237
+ const features = UndefinedOr.match(state.instance, { onUndefined: () => NO_FEATURES, onDefined: (instance) => instance.own(registry, host) });
238
+ return {
239
+ runtime,
240
+ context,
241
+ loop: Context.get(context, FrameLoop.FrameLoop),
242
+ atoms,
243
+ gate: Context.get(context, FlushGate.FlushGate),
244
+ reducedMotion,
245
+ prefers,
246
+ renderer: Context.get(context, Renderer.Renderer),
247
+ positionalKeys: Context.get(context, ReducedMotion.PositionalKeys),
248
+ defaultTransition: Context.get(context, DefaultTransition.DefaultTransition),
249
+ valueReads: ElementSetup.valueReadsOf({
250
+ ownValues: optional(services, OwnValues.OwnValues),
251
+ measuredPairs: optional(services, MeasuredPairs.MeasuredPairs),
252
+ variableValues: optional(services, VariableValues.VariableValues),
253
+ }),
254
+ frames: optional(services, RefreshFrameSource.RefreshFrameSource),
255
+ registry,
256
+ features,
257
+ onFeatures: (recheck) => {
258
+ rechecks.add(recheck);
259
+ return () => {
260
+ rechecks.delete(recheck);
261
+ };
262
+ },
263
+ scope,
264
+ root: undefined,
265
+ elements: 0,
266
+ pausedViews,
267
+ paused: () => pausedViews.size > 0,
268
+ };
269
+ });
270
+ /**
271
+ * The Handle's Provider for a mounting element: the live one; else, with a build in flight, the one
272
+ * its `Deferred` completes with; else built now, on this fiber. With `options` (the element carries
273
+ * `w.Provider(options)`), `element` becomes the Provider's root, unless another is mounted as one.
274
+ */
275
+ export const providerFor = (state, element, options) => Effect.gen(function* () {
276
+ let provider = state.live;
277
+ if (Predicate.isUndefined(provider))
278
+ provider = yield* Bool.match(state.building, { onTrue: () => Deferred.await(state.deferred), onFalse: () => first(state) });
279
+ if (Predicate.isNotUndefined(options))
280
+ yield* UndefinedOr.match(element, { onUndefined: () => Effect.void, onDefined: (root) => takeRoot(provider, root) });
281
+ return provider;
282
+ });
283
+ /**
284
+ * Reduced motion (ADR-0029) under `value`, the nearest `w.Config` (decision 22): its setting applied to
285
+ * the user's preference, read as each animation starts; the Provider's own where no `w.Config` is above.
286
+ */
287
+ export const reducedMotionUnder = (provider, value) => UndefinedOr.match(value, {
288
+ onUndefined: () => provider.reducedMotion,
289
+ onDefined: (config) => () => ReducedMotion.applies(UndefinedOr.match(WardicConfigValue.settingOf(config), { onUndefined: () => "user", onDefined: identity }), provider.prefers()),
290
+ });
291
+ /** The first element's build: the Provider made live, and the `Deferred` done for the elements after it. */
292
+ const first = (state) => Effect.gen(function* () {
293
+ state.building = true;
294
+ const provider = yield* build(state);
295
+ state.building = false;
296
+ state.live = provider;
297
+ Deferred.doneUnsafe(state.deferred, Effect.succeed(provider));
298
+ return provider;
299
+ });
300
+ /** `element` as `provider`'s root, unless another is mounted as one: then reported, and ignored. */
301
+ const takeRoot = (provider, element) => {
302
+ if (Predicate.isUndefined(provider.root)) {
303
+ provider.root = element;
304
+ return Effect.void;
305
+ }
306
+ return Report.failure(SECOND_PROVIDER, Cause.die(new Error(SECOND_PROVIDER)));
307
+ };
308
+ /**
309
+ * Count a member in: a mounted element, or a Command's animation or `provide` (`undefined`, never the
310
+ * root). Returns what its release calls: the count out, the root given up when it was this element, and,
311
+ * once the last member has left, the Scope closed at the end of the task, so a patch that removes every
312
+ * element and inserts new ones keeps the runtime.
313
+ */
314
+ export const joined = (state, provider, member) => {
315
+ provider.elements++;
316
+ let left = false;
317
+ return () => {
318
+ if (left)
319
+ return;
320
+ left = true;
321
+ provider.elements--;
322
+ if (Bool.and(Predicate.isNotUndefined(member), provider.root === member))
323
+ provider.root = undefined;
324
+ if (provider.elements > 0)
325
+ return;
326
+ queueMicrotask(() => {
327
+ if (provider.elements > 0)
328
+ return;
329
+ if (state.live !== provider)
330
+ return;
331
+ state.live = undefined;
332
+ state.deferred = Deferred.makeUnsafe();
333
+ // Its Features ended first (what the layout's observer goes with), then its Scope.
334
+ Effect.runFork(Effect.andThen(Effect.promise(() => provider.registry.dispose()), Scope.close(provider.scope, Exit.void)));
335
+ });
336
+ };
337
+ };
338
+ //# sourceMappingURL=services.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"services.js","sourceRoot":"","sources":["../../src/internal/services.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,iBAAiB,MAAM,gCAAgC,CAAA;AACnE,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAA;AACnD,OAAO,KAAK,KAAK,MAAM,oBAAoB,CAAA;AAC3C,OAAO,KAAK,aAAa,MAAM,4BAA4B,CAAA;AAC3D,OAAO,KAAK,kBAAkB,MAAM,iCAAiC,CAAA;AACrE,OAAO,KAAK,QAAQ,MAAM,uBAAuB,CAAA;AACjD,OAAO,KAAK,aAAa,MAAM,qCAAqC,CAAA;AACpE,OAAO,KAAK,SAAS,MAAM,iCAAiC,CAAA;AAC5D,OAAO,KAAK,cAAc,MAAM,sCAAsC,CAAA;AACtE,OAAO,KAAK,cAAc,MAAM,sCAAsC,CAAA;AACtE,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAA;AAElD,OAAO,KAAK,MAAM,MAAM,oBAAoB,CAAA;AAC5C,OAAO,KAAK,YAAY,MAAM,mCAAmC,CAAA;AACjE,OAAO,KAAK,OAAO,MAAM,8BAA8B,CAAA;AACvD,OAAO,KAAK,eAAe,MAAM,sCAAsC,CAAA;AACvE,OAAO,K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