@wardic/solid 2.1.0 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/batch-gestures.js +16 -2
- package/dist/browser/batch-gestures.js.map +1 -1
- package/dist/browser/batch-reorder.js +9 -3
- package/dist/browser/batch-reorder.js.map +1 -1
- package/dist/browser/frame-effect.js +14 -3
- package/dist/browser/frame-effect.js.map +1 -1
- package/dist/browser/kept-transform.js +53 -0
- package/dist/browser/kept-transform.js.map +1 -0
- package/dist/browser/live-value.js +37 -5
- package/dist/browser/live-value.js.map +1 -1
- package/dist/browser/presence.js +18 -3
- package/dist/browser/presence.js.map +1 -1
- package/dist/browser/provider.js +4 -0
- package/dist/browser/provider.js.map +1 -1
- package/dist/browser/sensors.js +6 -4
- package/dist/browser/sensors.js.map +1 -1
- package/dist/browser/stage-ward.js +26 -6
- package/dist/browser/stage-ward.js.map +1 -1
- package/dist/browser/stage.js.map +1 -1
- package/dist/browser/v1/create-batch.js +30 -2
- package/dist/browser/v1/create-batch.js.map +1 -1
- package/dist/browser/v1/create-ward.js +19 -5
- package/dist/browser/v1/create-ward.js.map +1 -1
- package/dist/browser/v1/directive.js +7 -2
- package/dist/browser/v1/directive.js.map +1 -1
- package/dist/browser/v1/index.js +1 -1
- package/dist/browser/v1/live-value.js +8 -3
- package/dist/browser/v1/live-value.js.map +1 -1
- package/dist/browser/v1/provider.js +4 -0
- package/dist/browser/v1/provider.js.map +1 -1
- package/dist/browser/v1/reorder.js +5 -1
- package/dist/browser/v1/reorder.js.map +1 -1
- package/dist/browser/v1/variant-node.js +10 -7
- package/dist/browser/v1/variant-node.js.map +1 -1
- package/dist/browser/variant-node.js +10 -7
- package/dist/browser/variant-node.js.map +1 -1
- package/dist/browser/ward.js +16 -6
- package/dist/browser/ward.js.map +1 -1
- package/dist/server/batch-gestures.js +16 -2
- package/dist/server/batch-gestures.js.map +1 -1
- package/dist/server/batch-reorder.js +9 -3
- package/dist/server/batch-reorder.js.map +1 -1
- package/dist/server/frame-effect.js +14 -3
- package/dist/server/frame-effect.js.map +1 -1
- package/dist/server/kept-transform.js +53 -0
- package/dist/server/kept-transform.js.map +1 -0
- package/dist/server/live-value.js +37 -5
- package/dist/server/live-value.js.map +1 -1
- package/dist/server/presence.js +18 -3
- package/dist/server/presence.js.map +1 -1
- package/dist/server/provider.js +4 -0
- package/dist/server/provider.js.map +1 -1
- package/dist/server/sensors.js +6 -4
- package/dist/server/sensors.js.map +1 -1
- package/dist/server/stage-ward.js +26 -6
- package/dist/server/stage-ward.js.map +1 -1
- package/dist/server/stage.js.map +1 -1
- package/dist/server/v1/create-batch.js +30 -2
- package/dist/server/v1/create-batch.js.map +1 -1
- package/dist/server/v1/create-ward.js +19 -5
- package/dist/server/v1/create-ward.js.map +1 -1
- package/dist/server/v1/directive.js +7 -2
- package/dist/server/v1/directive.js.map +1 -1
- package/dist/server/v1/index.js +1 -1
- package/dist/server/v1/live-value.js +8 -3
- package/dist/server/v1/live-value.js.map +1 -1
- package/dist/server/v1/provider.js +4 -0
- package/dist/server/v1/provider.js.map +1 -1
- package/dist/server/v1/reorder.js +5 -1
- package/dist/server/v1/reorder.js.map +1 -1
- package/dist/server/v1/variant-node.js +10 -7
- package/dist/server/v1/variant-node.js.map +1 -1
- package/dist/server/variant-node.js +10 -7
- package/dist/server/variant-node.js.map +1 -1
- package/dist/server/ward.js +16 -6
- package/dist/server/ward.js.map +1 -1
- package/dist/solid/batch-gestures.d.ts.map +1 -1
- package/dist/solid/batch-gestures.js +18 -2
- package/dist/solid/batch-gestures.js.map +1 -1
- package/dist/solid/batch-reorder.d.ts.map +1 -1
- package/dist/solid/batch-reorder.js +10 -3
- package/dist/solid/batch-reorder.js.map +1 -1
- package/dist/solid/frame-effect.d.ts.map +1 -1
- package/dist/solid/frame-effect.jsx +19 -5
- package/dist/solid/frame-effect.jsx.map +1 -1
- package/dist/solid/kept-transform.d.ts +15 -0
- package/dist/solid/kept-transform.d.ts.map +1 -0
- package/dist/solid/kept-transform.js +57 -0
- package/dist/solid/kept-transform.js.map +1 -0
- package/dist/solid/live-value.d.ts +2 -0
- package/dist/solid/live-value.d.ts.map +1 -1
- package/dist/solid/live-value.jsx +39 -5
- package/dist/solid/live-value.jsx.map +1 -1
- package/dist/solid/presence.d.ts.map +1 -1
- package/dist/solid/presence.jsx +19 -3
- package/dist/solid/presence.jsx.map +1 -1
- package/dist/solid/provider.d.ts +2 -0
- package/dist/solid/provider.d.ts.map +1 -1
- package/dist/solid/provider.jsx +4 -0
- package/dist/solid/provider.jsx.map +1 -1
- package/dist/solid/sensors.d.ts.map +1 -1
- package/dist/solid/sensors.jsx +6 -4
- package/dist/solid/sensors.jsx.map +1 -1
- package/dist/solid/stage-ward.d.ts +4 -1
- package/dist/solid/stage-ward.d.ts.map +1 -1
- package/dist/solid/stage-ward.jsx +26 -5
- package/dist/solid/stage-ward.jsx.map +1 -1
- package/dist/solid/stage.d.ts +4 -1
- package/dist/solid/stage.d.ts.map +1 -1
- package/dist/solid/stage.js.map +1 -1
- package/dist/solid/v1/create-batch.d.ts.map +1 -1
- package/dist/solid/v1/create-batch.jsx +32 -2
- package/dist/solid/v1/create-batch.jsx.map +1 -1
- package/dist/solid/v1/create-ward.d.ts +2 -0
- package/dist/solid/v1/create-ward.d.ts.map +1 -1
- package/dist/solid/v1/create-ward.jsx +19 -5
- package/dist/solid/v1/create-ward.jsx.map +1 -1
- package/dist/solid/v1/directive.d.ts.map +1 -1
- package/dist/solid/v1/directive.jsx +7 -2
- package/dist/solid/v1/directive.jsx.map +1 -1
- package/dist/solid/v1/index.d.ts +1 -1
- package/dist/solid/v1/index.jsx +1 -1
- package/dist/solid/v1/live-value.d.ts +2 -0
- package/dist/solid/v1/live-value.d.ts.map +1 -1
- package/dist/solid/v1/live-value.jsx +10 -3
- package/dist/solid/v1/live-value.jsx.map +1 -1
- package/dist/solid/v1/provider.d.ts +2 -0
- package/dist/solid/v1/provider.d.ts.map +1 -1
- package/dist/solid/v1/provider.jsx +4 -0
- package/dist/solid/v1/provider.jsx.map +1 -1
- package/dist/solid/v1/reorder.d.ts.map +1 -1
- package/dist/solid/v1/reorder.jsx +5 -1
- package/dist/solid/v1/reorder.jsx.map +1 -1
- package/dist/solid/v1/variant-node.d.ts +2 -1
- package/dist/solid/v1/variant-node.d.ts.map +1 -1
- package/dist/solid/v1/variant-node.js +10 -7
- package/dist/solid/v1/variant-node.js.map +1 -1
- package/dist/solid/variant-node.d.ts +2 -1
- package/dist/solid/variant-node.d.ts.map +1 -1
- package/dist/solid/variant-node.js +10 -7
- package/dist/solid/variant-node.js.map +1 -1
- package/dist/solid/ward.d.ts.map +1 -1
- package/dist/solid/ward.jsx +17 -6
- package/dist/solid/ward.jsx.map +1 -1
- package/package.json +5 -5
- package/src/batch-gestures.ts +16 -3
- package/src/batch-reorder.ts +9 -3
- package/src/frame-effect.tsx +14 -3
- package/src/kept-transform.ts +57 -0
- package/src/live-value.tsx +37 -5
- package/src/presence.tsx +19 -3
- package/src/provider.tsx +5 -0
- package/src/sensors.tsx +6 -4
- package/src/stage-ward.tsx +29 -7
- package/src/stage.ts +4 -1
- package/src/v1/create-batch.tsx +34 -2
- package/src/v1/create-ward.tsx +20 -5
- package/src/v1/directive.tsx +7 -2
- package/src/v1/index.tsx +1 -1
- package/src/v1/live-value.tsx +10 -3
- package/src/v1/provider.tsx +5 -0
- package/src/v1/reorder.tsx +5 -1
- package/src/v1/variant-node.ts +10 -5
- package/src/variant-node.ts +10 -5
- package/src/ward.tsx +16 -5
package/src/stage-ward.tsx
CHANGED
|
@@ -34,7 +34,7 @@ import * as VariantTree from "@wardic/core/unstable/VariantTree"
|
|
|
34
34
|
import * as OwnerScope from "@wardic/dom/unstable/OwnerScope"
|
|
35
35
|
import * as Arr from "effect/Array"
|
|
36
36
|
import * as Bool from "effect/Boolean"
|
|
37
|
-
import
|
|
37
|
+
import * as Cause from "effect/Cause"
|
|
38
38
|
import * as Effect from "effect/Effect"
|
|
39
39
|
import { constUndefined, constVoid, identity } from "effect/Function"
|
|
40
40
|
import * as Predicate from "effect/Predicate"
|
|
@@ -80,7 +80,10 @@ export interface StageWardEnvironment extends Imperative.AnimateEnv {
|
|
|
80
80
|
export interface StageMembership {
|
|
81
81
|
/** Its Subject joins the scene: the ward can start, its `initial` written for the next frame drawn. */
|
|
82
82
|
readonly join: (subject: object) => void
|
|
83
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* Its Subject leaves the scene: its exit has landed, or it had none. A throw here (an app's listener) is
|
|
85
|
+
* reported by the ward, and the leave goes on: `exitComplete` is told.
|
|
86
|
+
*/
|
|
84
87
|
readonly leave: (subject: object) => void
|
|
85
88
|
/** The parent its Subject will join, before it has: where a Variant child looks for the ward it follows, at its setup. */
|
|
86
89
|
readonly parentOf?: ((subject: object) => object | undefined) | undefined
|
|
@@ -248,6 +251,7 @@ interface WardParts {
|
|
|
248
251
|
readonly lifecycle: Lifecycle
|
|
249
252
|
readonly gate: StageWardEnvironment["gate"]
|
|
250
253
|
readonly registry: ReturnType<typeof Spine.registryOf>
|
|
254
|
+
readonly runtime: StageWardEnvironment["runtime"]
|
|
251
255
|
}
|
|
252
256
|
|
|
253
257
|
/**
|
|
@@ -283,6 +287,7 @@ interface SceneSide {
|
|
|
283
287
|
*/
|
|
284
288
|
const sceneSideOf = (parts: WardParts, membership: StageMembership): SceneSide => {
|
|
285
289
|
const { id, cfg, lifecycle, gate, registry } = parts
|
|
290
|
+
const exitFailed = Spine.exitVariantFailedOn(parts.runtime)
|
|
286
291
|
let mounts = 0
|
|
287
292
|
// Kept alive: it's set before anything reads it, and a registry drops an Atom no one holds.
|
|
288
293
|
const currentId = Atom.keepAlive(Atom.make(id))
|
|
@@ -304,7 +309,12 @@ const sceneSideOf = (parts: WardParts, membership: StageMembership): SceneSide =
|
|
|
304
309
|
const exit = values.exit
|
|
305
310
|
if (Predicate.isUndefined(exit)) return undefined
|
|
306
311
|
const exitConfig = { animate: exit, variants: values.variants, custom: values.custom, transition: values.transition } as Config.SpineConfig
|
|
307
|
-
|
|
312
|
+
const resolution = Spine.resolutionOf(exitConfig, parts.inherited, parts.start.initialLink, NOTHING_ACTIVE, m.snapshot)
|
|
313
|
+
const failure = Spine.failureOf(resolution)
|
|
314
|
+
if (Option.isNone(failure)) return resolution
|
|
315
|
+
// An exit whose resolver throws: reported each time, and it leaves without it (#979).
|
|
316
|
+
exitFailed(failure.value)
|
|
317
|
+
return undefined
|
|
308
318
|
})
|
|
309
319
|
|
|
310
320
|
/**
|
|
@@ -323,7 +333,12 @@ const sceneSideOf = (parts: WardParts, membership: StageMembership): SceneSide =
|
|
|
323
333
|
inFlight.delete(m.subject)
|
|
324
334
|
untracked()
|
|
325
335
|
m.dispose()
|
|
326
|
-
|
|
336
|
+
// The app's listeners run as it leaves: one that throws is reported, and it has left all the same (#981).
|
|
337
|
+
try {
|
|
338
|
+
membership.leave(m.subject)
|
|
339
|
+
} catch (defect) {
|
|
340
|
+
parts.runtime.runFork(Report.failure("wardic.stage: a Subject's leave failed", Cause.die(defect)))
|
|
341
|
+
}
|
|
327
342
|
exits.tell("exitComplete", () => ({ element: m.subject }))
|
|
328
343
|
leaving--
|
|
329
344
|
endExits()
|
|
@@ -426,7 +441,10 @@ const wardOn = (
|
|
|
426
441
|
onUndefined: (): GraphParent | undefined => undefined,
|
|
427
442
|
onDefined: (on) => Bool.match(VariantTree.isVariantChild(initialConfig), { onTrue: (): GraphParent | undefined => new GraphParent(on, joinsUnder), onFalse: constUndefined }),
|
|
428
443
|
})
|
|
429
|
-
|
|
444
|
+
// A variant that throws is this Subject's alone (#979): its failures, which its spine keeps and its
|
|
445
|
+
// orchestration reports to, once.
|
|
446
|
+
const variantFailures = Spine.variantFailuresOf(runtime)
|
|
447
|
+
const node = createVariantNode(cfg, initialConfig, follower, undefined, variantFailures)
|
|
430
448
|
UndefinedOr.map(follower, (f) => {
|
|
431
449
|
if (Bool.not(Predicate.isFunction(given))) f.early(given as object)
|
|
432
450
|
})
|
|
@@ -446,6 +464,9 @@ const wardOn = (
|
|
|
446
464
|
if (Bool.not(Predicate.isFunction(given))) provideOn(given as object)
|
|
447
465
|
if (Bool.and(Arr.contains(setup.pending, "animate"), initialConfig.initial === false)) throw new Error(STARTS_AT_PENDING)
|
|
448
466
|
const start = Spine.startOf(initialConfig, node.inherited, false, untrack)
|
|
467
|
+
// A variant whose resolver throws is this Subject's alone: reported once until it resolves, keeping
|
|
468
|
+
// its last target (#979; ADR-0074).
|
|
469
|
+
Spine.reportStart(variantFailures, start)
|
|
449
470
|
const snapshot = Spine.snapshotOf(start)
|
|
450
471
|
const reuse = Spine.makeReuse()
|
|
451
472
|
// Where its Subject starts: the ward's start, or a fresh one for the next Subject an accessor gives.
|
|
@@ -453,6 +474,7 @@ const wardOn = (
|
|
|
453
474
|
let begun = start
|
|
454
475
|
const beginFresh = (): void => {
|
|
455
476
|
begun = Spine.startOf(WARD_VIEW.setupOf(view).config, node.inherited, false, untrack)
|
|
477
|
+
Spine.reportStart(variantFailures, begun)
|
|
456
478
|
if (scene) return
|
|
457
479
|
snapshot.values = { ...begun.initialValues }
|
|
458
480
|
snapshot.velocities = {}
|
|
@@ -485,7 +507,7 @@ const wardOn = (
|
|
|
485
507
|
() => {
|
|
486
508
|
const g = gestures()
|
|
487
509
|
// `dragging` stays off: a scene's drag holds its keys as the Stage's `animate` does (#433), `z` among them.
|
|
488
|
-
return Spine.resolutionOf(cfg(), node.inherited, start.initialLink, { inView: false, focused: false, hovered: g.hovered, pressed: g.pressed, dragged: g.dragged, dragging: false }, snapshot, undefined)
|
|
510
|
+
return Spine.keptOf(variantFailures, Spine.resolutionOf(cfg(), node.inherited, start.initialLink, { inView: false, focused: false, hovered: g.hovered, pressed: g.pressed, dragged: g.dragged, dragging: false }, snapshot, undefined))
|
|
489
511
|
},
|
|
490
512
|
{ equals: sameTarget, transparent: true },
|
|
491
513
|
)
|
|
@@ -494,7 +516,7 @@ const wardOn = (
|
|
|
494
516
|
const lifecycle = new Lifecycle(owner, () => {
|
|
495
517
|
UndefinedOr.map(mounted, startRecognizers)
|
|
496
518
|
})
|
|
497
|
-
const side = UndefinedOr.map(sideOf, (of) => of({ id, cfg, inherited: node.inherited, start, lifecycle, gate, registry }))
|
|
519
|
+
const side = UndefinedOr.map(sideOf, (of) => of({ id, cfg, inherited: node.inherited, start, lifecycle, gate, registry, runtime }))
|
|
498
520
|
/** A handler's throw, reported as a fiber's failure is (ADR-0030, decision 4); the watch goes on. */
|
|
499
521
|
const onDefect = (cause: Cause.Cause<never>): void => {
|
|
500
522
|
runtime.runFork(Report.failure("wardic.ward: a gesture handler failed", cause))
|
package/src/stage.ts
CHANGED
|
@@ -200,7 +200,10 @@ export type StageKeyedBatchConfig<T> = StageBatchMembers<[item: T, i: number]> &
|
|
|
200
200
|
readonly whileTap?: StageBatchTarget | ((item: T, i: number) => StageBatchValues) | undefined
|
|
201
201
|
readonly transition?: BatchMembers.WardicBatchTransition | undefined
|
|
202
202
|
readonly parent?: object | undefined
|
|
203
|
-
/**
|
|
203
|
+
/**
|
|
204
|
+
* Dispose each object's geometries and materials, and its descendants', once it has left. A `dispose` or
|
|
205
|
+
* `removed` listener of the app's that throws is reported, and every part is still disposed.
|
|
206
|
+
*/
|
|
204
207
|
readonly dispose?: boolean | undefined
|
|
205
208
|
readonly keys?: ReadonlyArray<string> | undefined
|
|
206
209
|
}
|
package/src/v1/create-batch.tsx
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @module
|
|
6
6
|
*/
|
|
7
|
+
import * as Report from "@wardic/dom/Report"
|
|
7
8
|
import * as Bool from "effect/Boolean"
|
|
9
|
+
import * as Cause from "effect/Cause"
|
|
8
10
|
import * as Predicate from "effect/Predicate"
|
|
9
11
|
import * as UndefinedOr from "effect/UndefinedOr"
|
|
10
12
|
import { createRenderEffect, type JSX, on, onCleanup, untrack } from "solid-js"
|
|
@@ -81,6 +83,27 @@ const callGesture = (config: WardicBatchConfig | WardicKeyedBatchConfig<unknown>
|
|
|
81
83
|
callback(told.raw, info)
|
|
82
84
|
}
|
|
83
85
|
|
|
86
|
+
const START_FAILED = "createBatch: onAnimationStart failed"
|
|
87
|
+
const COMPLETE_FAILED = "createBatch: onAnimationComplete failed"
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* An app's flight callback, called: whether it threw. A throw is reported on the Batch's runtime at the
|
|
91
|
+
* first of a run (`failing` says one is on), and its flight goes on, its run forked and its landing told,
|
|
92
|
+
* as an element's own callback's throw is.
|
|
93
|
+
*/
|
|
94
|
+
// #979 (ADR-0074, row 33): `Spine.animationCallbacks`' shape. A start that threw kept the run from forking,
|
|
95
|
+
// and came out of the change's update; a landing's was swallowed by its fiber's observer. Group I (row 25,
|
|
96
|
+
// decision 3): once a run of each callback's throws, ended by its next clean call.
|
|
97
|
+
const callFlight = (runtime: WardicRuntime, failed: string, call: () => void, failing: boolean): boolean => {
|
|
98
|
+
try {
|
|
99
|
+
call()
|
|
100
|
+
return false
|
|
101
|
+
} catch (defect) {
|
|
102
|
+
if (!failing) runtime.runFork(Report.failure(failed, Cause.die(defect)))
|
|
103
|
+
return true
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
84
107
|
/** A Batch's gesture watches, ended with its owner, over the input it brings: their code loaded at the first (Q62). */
|
|
85
108
|
const gestureWatchesOf = (runtime: WardicRuntime): BatchMembers.BatchGestureWatches => {
|
|
86
109
|
const gestures = lazyBatchGestures(runtime, useFeatureRegistry())
|
|
@@ -165,6 +188,9 @@ export function createBatch(config: WardicBatchConfig | WardicKeyedBatchConfig<u
|
|
|
165
188
|
const hovers = wantsHover(config)
|
|
166
189
|
const presses = wantsPress(config)
|
|
167
190
|
const gestures = Bool.match(Bool.or(hovers, presses), { onTrue: () => gestureWatchesOf(runtime), onFalse: () => undefined })
|
|
191
|
+
// Whether its onAnimationStart's, and its onAnimationComplete's, last call threw: each its own run.
|
|
192
|
+
let startFailing = false
|
|
193
|
+
let completeFailing = false
|
|
168
194
|
// Its first targets and starts read untracked, wherever it's called: what tracks them is its own effect.
|
|
169
195
|
const binding = untrack(() =>
|
|
170
196
|
BatchMembers.bindBatch(
|
|
@@ -181,8 +207,14 @@ export function createBatch(config: WardicBatchConfig | WardicKeyedBatchConfig<u
|
|
|
181
207
|
},
|
|
182
208
|
config,
|
|
183
209
|
{
|
|
184
|
-
started: () =>
|
|
185
|
-
|
|
210
|
+
started: () =>
|
|
211
|
+
UndefinedOr.map(config.onAnimationStart, (call) => {
|
|
212
|
+
startFailing = callFlight(runtime, START_FAILED, call, startFailing)
|
|
213
|
+
}),
|
|
214
|
+
landed: (landing) =>
|
|
215
|
+
UndefinedOr.map(config.onAnimationComplete, (call) => {
|
|
216
|
+
completeFailing = callFlight(runtime, COMPLETE_FAILED, () => call(landing), completeFailing)
|
|
217
|
+
}),
|
|
186
218
|
gesture: (told) => callGesture(config, keyed, told),
|
|
187
219
|
},
|
|
188
220
|
))
|
package/src/v1/create-ward.tsx
CHANGED
|
@@ -266,6 +266,8 @@ export interface RunSpineOptions {
|
|
|
266
266
|
readonly valueReads?: ElementSetup.ElementValueReads | undefined
|
|
267
267
|
/** The provider runtime the spine forks its fibers on. */
|
|
268
268
|
readonly runtime: WardicRuntime
|
|
269
|
+
/** Its element's dynamic variants that throw (#979): made with its variant node, which reports to them too. */
|
|
270
|
+
readonly variantFailures: Spine.VariantFailures
|
|
269
271
|
/** The provider-owned flush gate (ADR-0006). */
|
|
270
272
|
readonly gate: FlushGate.Shape
|
|
271
273
|
/** SSR/hydration-stable gate id for this element's entry. */
|
|
@@ -433,7 +435,7 @@ const valueReadsIn = (given: ElementSetup.ElementValueReads | undefined): Elemen
|
|
|
433
435
|
}
|
|
434
436
|
|
|
435
437
|
export function runSpine(opts: RunSpineOptions): void {
|
|
436
|
-
const { bindGestures, byName, canStart, cfg, controls, defaultsInProps, el, entersFresh, extraDelay, gate, hydrating, id, internal = NO_INTERNALS, live, makeSink, onFrame, parent, restartStyle, runtime, styleOf, tag } = opts
|
|
438
|
+
const { bindGestures, byName, canStart, cfg, controls, defaultsInProps, el, entersFresh, extraDelay, gate, hydrating, id, internal = NO_INTERNALS, live, makeSink, onFrame, parent, restartStyle, runtime, styleOf, tag, variantFailures } = opts
|
|
437
439
|
// Its Features (#511, ADR-0067): its section's, and those it brings.
|
|
438
440
|
const features = UndefinedOr.match(opts.features, { onDefined: identity, onUndefined: () => useElementFeatures(internal) })
|
|
439
441
|
// Its section's projection system, the `layout` Feature's (#511): `undefined` without it. Read now,
|
|
@@ -473,6 +475,10 @@ export function runSpine(opts: RunSpineOptions): void {
|
|
|
473
475
|
// name for a Variant child that has none (#50). Seeds the spring `from` Snapshot so
|
|
474
476
|
// frame 1 flows continuously out of it (no snap).
|
|
475
477
|
const start = Spine.startOf(untrack(cfg), parent, PresenceRecord.presenceBlocksInitial(presence), untrack)
|
|
478
|
+
// A variant whose resolver throws is this element's alone: reported once until it resolves, the element
|
|
479
|
+
// keeping its last target, and nothing thrown into Solid's update, which would freeze every element in
|
|
480
|
+
// it (#979; ADR-0074).
|
|
481
|
+
Spine.reportStart(variantFailures, start)
|
|
476
482
|
const snapshot = Spine.snapshotOf(start)
|
|
477
483
|
const reuse = Spine.makeReuse()
|
|
478
484
|
// Where an element starts (#414): the ward's start, or, for one that comes after the last left the
|
|
@@ -482,6 +488,7 @@ export function runSpine(opts: RunSpineOptions): void {
|
|
|
482
488
|
if (Predicate.isUndefined(entersFresh)) return start
|
|
483
489
|
if (Bool.not(entersFresh(element))) return start
|
|
484
490
|
const fresh = Spine.startOf(untrack(cfg), parent, false, untrack)
|
|
491
|
+
Spine.reportStart(variantFailures, fresh)
|
|
485
492
|
snapshot.values = { ...fresh.initialValues }
|
|
486
493
|
snapshot.velocities = {}
|
|
487
494
|
snapshot.drawnAt = {}
|
|
@@ -864,7 +871,7 @@ export function runSpine(opts: RunSpineOptions): void {
|
|
|
864
871
|
// change, a recognizer's flip or the drag's recomputes it, and only one that resolves a new
|
|
865
872
|
// target drives a Retarget. A `transition`, a callback or an option alone tells nothing, as
|
|
866
873
|
// Motion's doesn't.
|
|
867
|
-
const target = createMemo((): Spine.Resolution => Spine.resolutionOf(cfg(), parent, begin.initialLink, active(), snapshot, ownChange()), undefined, { equals: Spine.sameResolution })
|
|
874
|
+
const target = createMemo((): Spine.Resolution => Spine.keptOf(variantFailures, Spine.resolutionOf(cfg(), parent, begin.initialLink, active(), snapshot, ownChange())), undefined, { equals: Spine.sameResolution })
|
|
868
875
|
// A colour only the `colors` Feature reads, on a Slim element without it (#511, decision 7): said
|
|
869
876
|
// once per provider, in development only, and not while a lazy load is on its way.
|
|
870
877
|
if (DEV && internal.complete !== true) warnUnreadColors(useFeatureRegistry(), features, () => target().resolved)
|
|
@@ -1023,7 +1030,10 @@ export function createWardWith(config: WardConfig.WardConfig | Accessor<WardConf
|
|
|
1023
1030
|
// Its place in variant orchestration (ADR-0007, #50): what it hands its children, and,
|
|
1024
1031
|
// as a Variant child, the ancestor it inherits from and joins (its stagger slot, its
|
|
1025
1032
|
// `when`). Read at hook-call time (component body owner), for this instance's lifetime.
|
|
1026
|
-
|
|
1033
|
+
// A variant that throws is this element's alone (#979): its failures, which its spine keeps and its
|
|
1034
|
+
// orchestration reports to, once.
|
|
1035
|
+
const variantFailures = Spine.variantFailuresOf(runtime)
|
|
1036
|
+
const node = createVariantNode(cfg, useVariantContext(), UndefinedOr.map(controls, (c) => c.change), variantFailures)
|
|
1027
1037
|
|
|
1028
1038
|
// The Renderer's PURE project (ADR-0003: synchronous, no engine), read once by the provider (#618, M1).
|
|
1029
1039
|
const { project } = useWardicRenderer()
|
|
@@ -1102,6 +1112,7 @@ export function createWardWith(config: WardConfig.WardConfig | Accessor<WardConf
|
|
|
1102
1112
|
runSpine({
|
|
1103
1113
|
valueReads,
|
|
1104
1114
|
runtime,
|
|
1115
|
+
variantFailures,
|
|
1105
1116
|
gate,
|
|
1106
1117
|
id,
|
|
1107
1118
|
el,
|
|
@@ -1199,9 +1210,13 @@ const serverWard = (config: WardConfig.WardConfig | Accessor<WardConfig.WardConf
|
|
|
1199
1210
|
// (#50); a Variant child's Starting style starts from its ancestor's `initial` name.
|
|
1200
1211
|
const node = VariantTree.serverVariantNode(c, useVariantContext())
|
|
1201
1212
|
const layoutNode = Spine.isLayoutNode(c)
|
|
1202
|
-
|
|
1213
|
+
// Its start, resolved once: the seed and the Appear animation's initial values read it. A variant that
|
|
1214
|
+
// throws leaves its values out of the markup, logged on the server (#979).
|
|
1215
|
+
const starting = VariantTree.startingOf(c, node.inherited, PresenceRecord.presenceBlocksInitial(usePresenceContext()), untrack)
|
|
1216
|
+
if (Option.isSome(starting.failure)) Spine.variantFailedOnServer(starting.failure.value)
|
|
1217
|
+
const initialValues = starting.values
|
|
1218
|
+
const seed = Style.starting(internal.tag, ElementSetup.drawnAtRest(initialValues, layoutNode, c.transformTemplate))
|
|
1203
1219
|
const dragDefaults = DragDefaults.dragDefaultsOf(c, internal)
|
|
1204
|
-
const initialValues = VariantTree.startingValuesOf(c, node.inherited, PresenceRecord.presenceBlocksInitial(usePresenceContext()), untrack)
|
|
1205
1220
|
// Its Appear animation (#48, ADR-0044): its slot in the render's, and the group its Variant
|
|
1206
1221
|
// children join when it leads one.
|
|
1207
1222
|
const appear = serverAppearOf(c, internal.tag, initialValues, node, VariantTree.startsQuiet(c, node.inherited, PresenceRecord.presenceBlocksInitial(usePresenceContext()), untrack))
|
package/src/v1/directive.tsx
CHANGED
|
@@ -53,12 +53,17 @@ export const runDirective = (el: HTMLElement, value: Accessor<WardConfig.WardCon
|
|
|
53
53
|
// provides none.
|
|
54
54
|
// Animation controls for its `animate` (#433): each change they make is its entry.
|
|
55
55
|
const { cfg, controls } = controlledOf(value)
|
|
56
|
-
const
|
|
56
|
+
const runtime = useWardicRuntime()
|
|
57
|
+
// A variant that throws is this element's alone (#979): its failures, which its spine keeps and its
|
|
58
|
+
// orchestration reports to, once.
|
|
59
|
+
const variantFailures = Spine.variantFailuresOf(runtime)
|
|
60
|
+
const node = createVariantNode(cfg, useVariantContext(), UndefinedOr.map(controls, (c) => c.change), variantFailures)
|
|
57
61
|
// Under a presence, its element is told to it (#286): its `key`, and whether it's a twin.
|
|
58
62
|
const presence = usePresenceContext()
|
|
59
63
|
if (Predicate.isNotUndefined(presence)) Spine.madeWith(presence, constVoid, untrack(cfg))(el)
|
|
60
64
|
runSpine({
|
|
61
|
-
runtime
|
|
65
|
+
runtime,
|
|
66
|
+
variantFailures,
|
|
62
67
|
gate: useWardicGate(),
|
|
63
68
|
id: createUniqueId(),
|
|
64
69
|
el: () => el,
|
package/src/v1/index.tsx
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*
|
|
18
18
|
* @deprecated Solid 1's binding, deprecated and frozen: it goes at Wardic's next major. Solid 2's is `@wardic/solid` (#566).
|
|
19
19
|
*/
|
|
20
|
-
export const VERSION = "2.1.
|
|
20
|
+
export const VERSION = "2.1.2"
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* `WardicProvider` (one Effect runtime + `AtomRegistry` per ADR-0006), the
|
package/src/v1/live-value.tsx
CHANGED
|
@@ -34,7 +34,8 @@ import { eachFrameOf } from "../animation-frame.ts"
|
|
|
34
34
|
import { fromAtom } from "./bridge.tsx"
|
|
35
35
|
import * as LiveStyle from "@wardic/dom/unstable/LiveStyle"
|
|
36
36
|
import * as OwnerScope from "@wardic/dom/unstable/OwnerScope"
|
|
37
|
-
import {
|
|
37
|
+
import { FUNCTION_FAILED, keptComputeOf, MIXER_FAILED } from "../kept-transform.ts"
|
|
38
|
+
import { useProvidedRuntime, useWardicRuntime, useWardicSkipAnimations } from "./provider.tsx"
|
|
38
39
|
import type { WardicRuntime, WardicServices } from "../runtime.ts"
|
|
39
40
|
import { isServer } from "./server.ts"
|
|
40
41
|
import * as ServerInterpolators from "@wardic/dom/unstable/ServerInterpolators"
|
|
@@ -58,6 +59,8 @@ const atomAccessorOf = <A,>(atom: Atom.Atom<A>): Accessor<A> => {
|
|
|
58
59
|
* two stops blends their outputs, numbers, units and colours alike. `input` is as long as `output`,
|
|
59
60
|
* ascending or descending; outside it the ends hold, unless `clamp: false`. `ease` eases each stretch,
|
|
60
61
|
* one for all or one each, and a `mixer`, `(from, to) => (t) => value`, blends outputs of any type. The function form needs no `WardicProvider` when its source is a signal.
|
|
62
|
+
* A function or a `mixer` that throws keeps the value it gave last, and is logged once until it returns;
|
|
63
|
+
* one that throws for its first value throws to whatever reads it first.
|
|
61
64
|
* Through ranges from a `createScroll` value, the browser draws it with the scroll where it can.
|
|
62
65
|
* Motion's `useTransform`.
|
|
63
66
|
*
|
|
@@ -82,9 +85,12 @@ export function createTransform(
|
|
|
82
85
|
output?: ReadonlyArray<unknown>,
|
|
83
86
|
options?: LiveValue.TransformOptions<unknown>,
|
|
84
87
|
): Accessor<unknown> {
|
|
88
|
+
// An app's function, or a `mixer` in its ranges, that throws: its last value kept, reported, and Solid's
|
|
89
|
+
// update it runs in goes on (#979).
|
|
85
90
|
if (Predicate.isFunction(fnOrInput)) {
|
|
86
91
|
const read = accessorOf(source)
|
|
87
|
-
return createMemo(() => fnOrInput(read()))
|
|
92
|
+
if (isServer) return createMemo(() => fnOrInput(read()))
|
|
93
|
+
return createMemo(keptComputeOf(read, fnOrInput, useProvidedRuntime(), FUNCTION_FAILED))
|
|
88
94
|
}
|
|
89
95
|
// On an Atom, its own or the one it carries: derived on it by core, so it's set where its source is,
|
|
90
96
|
// and one from a scroll is described for a Timeline value (#240).
|
|
@@ -94,7 +100,8 @@ export function createTransform(
|
|
|
94
100
|
}
|
|
95
101
|
const read = accessorOf(source)
|
|
96
102
|
const map = interpolatorOf(fnOrInput as ReadonlyArray<number>, output as ReadonlyArray<unknown>, options)
|
|
97
|
-
return createMemo(() => map(read() as number))
|
|
103
|
+
if (isServer) return createMemo(() => map(read() as number))
|
|
104
|
+
return createMemo(keptComputeOf(read as Accessor<number>, map, useProvidedRuntime(), MIXER_FAILED))
|
|
98
105
|
}
|
|
99
106
|
|
|
100
107
|
/**
|
package/src/v1/provider.tsx
CHANGED
|
@@ -338,6 +338,11 @@ export function useWardicRuntime(): WardicRuntime {
|
|
|
338
338
|
return fromContext(useContext(WardicContext), "useWardicRuntime", (value) => value.runtime)
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
+
/** The nearest provider's runtime, or none outside one: where a transform's failure is reported (#979). */
|
|
342
|
+
export function useProvidedRuntime(): WardicRuntime | undefined {
|
|
343
|
+
return UndefinedOr.map(useContext(WardicContext), (value) => value.runtime)
|
|
344
|
+
}
|
|
345
|
+
|
|
341
346
|
/**
|
|
342
347
|
* The nearest `WardicProvider`'s flush gate: what a binding registers its elements with, and writes
|
|
343
348
|
* their values into, committed once a frame. For building an element of your own on Wardic's
|
package/src/v1/reorder.tsx
CHANGED
|
@@ -467,8 +467,11 @@ export function reorderItem(el: HTMLElement, value: Accessor<ReorderItemDirectiv
|
|
|
467
467
|
return { ...rest, layout: itemLayoutOf(rest.layout) }
|
|
468
468
|
})
|
|
469
469
|
// As `use:wardic`: a Variant child joins the nearest variant context; it provides none (#50).
|
|
470
|
-
const node = createVariantNode(cfg, useVariantContext(), UndefinedOr.map(controls, (c) => c.change))
|
|
471
470
|
const runtime = useWardicRuntime()
|
|
471
|
+
// A variant that throws is this element's alone (#979): its failures, which its spine keeps and its
|
|
472
|
+
// orchestration reports to, once.
|
|
473
|
+
const variantFailures = Spine.variantFailuresOf(runtime)
|
|
474
|
+
const node = createVariantNode(cfg, useVariantContext(), UndefinedOr.map(controls, (c) => c.change), variantFailures)
|
|
472
475
|
const group = first.group as ItemGroup<unknown>
|
|
473
476
|
// The keyboard reorder's tab stop and instructions (ADR-0037), on the element itself: the app's
|
|
474
477
|
// own `tabindex` wins, and its `aria-describedby` ids are kept.
|
|
@@ -481,6 +484,7 @@ export function reorderItem(el: HTMLElement, value: Accessor<ReorderItemDirectiv
|
|
|
481
484
|
})
|
|
482
485
|
runSpine({
|
|
483
486
|
runtime,
|
|
487
|
+
variantFailures,
|
|
484
488
|
gate: useWardicGate(),
|
|
485
489
|
id: createUniqueId(),
|
|
486
490
|
el: () => el,
|
package/src/v1/variant-node.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { type Accessor, createEffect, createMemo, createSignal, on, onCleanup, u
|
|
|
14
14
|
import type * as AnimationControls from "@wardic/core/unstable/AnimationControls"
|
|
15
15
|
import type * as WardConfig from "@wardic/dom/unstable/WardConfig"
|
|
16
16
|
import * as VariantTree from "@wardic/core/unstable/VariantTree"
|
|
17
|
+
import * as Spine from "@wardic/core/unstable/Spine"
|
|
17
18
|
import * as VariantTarget from "@wardic/core/unstable/VariantTarget"
|
|
18
19
|
|
|
19
20
|
/** An element's place in variant orchestration, on the client. */
|
|
@@ -70,7 +71,10 @@ const ownOrchestration = (
|
|
|
70
71
|
parent: VariantTree.WardicVariantContextValue | undefined,
|
|
71
72
|
inherited: VariantTree.WardicVariantContextValue | undefined,
|
|
72
73
|
change: Accessor<AnimationControls.ControlsChange | undefined>,
|
|
74
|
+
failures: Spine.VariantFailures | undefined,
|
|
73
75
|
): OwnOrchestration => {
|
|
76
|
+
// What it resolves, told to its element's failures (#979): made here, as only an element that orchestrates has one.
|
|
77
|
+
const orchestrated = UndefinedOr.map(failures, Spine.orchestrationOf)
|
|
74
78
|
const config = untrack(cfg)
|
|
75
79
|
// Children in mount order (a Set keeps insertion order); the effect below snapshots that
|
|
76
80
|
// order at each trigger. Kept with a count of the unsettled ones rather than a signal of the
|
|
@@ -165,8 +169,8 @@ const ownOrchestration = (
|
|
|
165
169
|
VariantTree.orchestrationAt(at(), () => {
|
|
166
170
|
const c = cfg()
|
|
167
171
|
const own = UndefinedOr.match(VariantTree.topGestureName(VariantTree.activeNamesOf(gestures())), {
|
|
168
|
-
onDefined: (name) => VariantTarget.ownTransitionOf(undefined, name, c.variants, c.custom),
|
|
169
|
-
onUndefined: () => VariantTarget.ownTransitionOf(c.animate, variant(), c.variants, c.custom),
|
|
172
|
+
onDefined: (name) => VariantTarget.ownTransitionOf(undefined, name, c.variants, c.custom, orchestrated),
|
|
173
|
+
onUndefined: () => VariantTarget.ownTransitionOf(c.animate, variant(), c.variants, c.custom, orchestrated),
|
|
170
174
|
})
|
|
171
175
|
return VariantTarget.transitionOfTarget(own, c.transition)
|
|
172
176
|
}))
|
|
@@ -205,7 +209,7 @@ const ownOrchestration = (
|
|
|
205
209
|
const kept = known.get(name)
|
|
206
210
|
if (Predicate.isNotUndefined(kept)) return kept
|
|
207
211
|
const c = untrack(cfg)
|
|
208
|
-
const made = VariantTree.nameConfigOf(VariantTarget.transitionOfTarget(VariantTarget.ownTransitionOf(undefined, name, c.variants, c.custom), c.transition))
|
|
212
|
+
const made = VariantTree.nameConfigOf(VariantTarget.transitionOfTarget(VariantTarget.ownTransitionOf(undefined, name, c.variants, c.custom, orchestrated), c.transition))
|
|
209
213
|
known.set(name, made)
|
|
210
214
|
return made
|
|
211
215
|
}
|
|
@@ -268,6 +272,7 @@ export const createVariantNode = (
|
|
|
268
272
|
cfg: Accessor<VariantTree.VariantConfig>,
|
|
269
273
|
parent: VariantTree.WardicVariantContextValue | undefined,
|
|
270
274
|
controls?: Accessor<AnimationControls.ControlsChange | undefined>,
|
|
275
|
+
failures?: Spine.VariantFailures,
|
|
271
276
|
): VariantNode => {
|
|
272
277
|
const config = untrack(cfg)
|
|
273
278
|
const inherited = VariantTree.inheritedContext(config, parent)
|
|
@@ -278,7 +283,7 @@ export const createVariantNode = (
|
|
|
278
283
|
if (Predicate.isNotUndefined(joined)) onCleanup(joined.registration.dispose)
|
|
279
284
|
const own = Bool.match(VariantTree.hasOwnVariants(config), {
|
|
280
285
|
onFalse: constUndefined,
|
|
281
|
-
onTrue: () => ownOrchestration(cfg, parent, inherited, change),
|
|
286
|
+
onTrue: () => ownOrchestration(cfg, parent, inherited, change, failures),
|
|
282
287
|
})
|
|
283
288
|
// The spine reports on every frame (the per-frame path, docs/agents/effect-first.md): both
|
|
284
289
|
// reports are resolved here, once, so a frame makes two plain calls and allocates nothing.
|
|
@@ -293,7 +298,7 @@ export const createVariantNode = (
|
|
|
293
298
|
extraDelay: UndefinedOr.map(joined, ({ context, registration }) => (name: string | undefined) => {
|
|
294
299
|
const s = VariantTree.staggerOfName(context, name)
|
|
295
300
|
const n = registration.total()
|
|
296
|
-
return VariantTree.childDelayOf(s, registration.index(), n)
|
|
301
|
+
return VariantTree.childDelayOf(s, registration.index(), n, failures)
|
|
297
302
|
}),
|
|
298
303
|
canStart: () =>
|
|
299
304
|
UndefinedOr.match(inherited, { onUndefined: constTrue, onDefined: (context) => context.childrenMayStart() }) &&
|
package/src/variant-node.ts
CHANGED
|
@@ -28,6 +28,7 @@ import type * as AnimationControls from "@wardic/core/unstable/AnimationControls
|
|
|
28
28
|
import type * as WardConfig from "@wardic/dom/unstable/WardConfig"
|
|
29
29
|
import * as VariantTree from "@wardic/core/unstable/VariantTree"
|
|
30
30
|
import { CLIENT_ONLY, CLIENT_ONLY_SYNC } from "./solid-reactivity.ts"
|
|
31
|
+
import * as Spine from "@wardic/core/unstable/Spine"
|
|
31
32
|
import * as VariantTarget from "@wardic/core/unstable/VariantTarget"
|
|
32
33
|
|
|
33
34
|
/**
|
|
@@ -111,7 +112,10 @@ const ownOrchestration = (
|
|
|
111
112
|
parent: VariantTree.WardicVariantContextValue | undefined,
|
|
112
113
|
inherited: VariantTree.WardicVariantContextValue | undefined,
|
|
113
114
|
change: Accessor<AnimationControls.ControlsChange | undefined>,
|
|
115
|
+
failures: Spine.VariantFailures | undefined,
|
|
114
116
|
): OwnOrchestration => {
|
|
117
|
+
// What it resolves, told to its element's failures (#979): made here, as only an element that orchestrates has one.
|
|
118
|
+
const orchestrated = UndefinedOr.map(failures, Spine.orchestrationOf)
|
|
115
119
|
// Children in mount order (a Set keeps insertion order), snapshotted at each trigger. Kept with a
|
|
116
120
|
// count of the unsettled ones rather than a signal of the records, so a child's mount, unmount or
|
|
117
121
|
// settle costs the same at 1,000 children as at 1. The count is plain, and the signal its copy:
|
|
@@ -225,8 +229,8 @@ const ownOrchestration = (
|
|
|
225
229
|
VariantTree.orchestrationAt(at(), () => {
|
|
226
230
|
const c = cfg()
|
|
227
231
|
const own = UndefinedOr.match(VariantTree.topGestureName(VariantTree.activeNamesOf(gestures())), {
|
|
228
|
-
onDefined: (name) => VariantTarget.ownTransitionOf(undefined, name, c.variants, c.custom),
|
|
229
|
-
onUndefined: () => VariantTarget.ownTransitionOf(c.animate, variant(), c.variants, c.custom),
|
|
232
|
+
onDefined: (name) => VariantTarget.ownTransitionOf(undefined, name, c.variants, c.custom, orchestrated),
|
|
233
|
+
onUndefined: () => VariantTarget.ownTransitionOf(c.animate, variant(), c.variants, c.custom, orchestrated),
|
|
230
234
|
})
|
|
231
235
|
return VariantTarget.transitionOfTarget(own, c.transition)
|
|
232
236
|
}),
|
|
@@ -260,7 +264,7 @@ const ownOrchestration = (
|
|
|
260
264
|
const kept = known.get(name)
|
|
261
265
|
if (Predicate.isNotUndefined(kept)) return kept
|
|
262
266
|
const c = untrack(cfg)
|
|
263
|
-
const made = untrack(() => VariantTree.nameConfigOf(VariantTarget.transitionOfTarget(VariantTarget.ownTransitionOf(undefined, name, c.variants, c.custom), c.transition)))
|
|
267
|
+
const made = untrack(() => VariantTree.nameConfigOf(VariantTarget.transitionOfTarget(VariantTarget.ownTransitionOf(undefined, name, c.variants, c.custom, orchestrated), c.transition)))
|
|
264
268
|
known.set(name, made)
|
|
265
269
|
return made
|
|
266
270
|
}
|
|
@@ -328,6 +332,7 @@ export const createVariantNode = (
|
|
|
328
332
|
config: VariantTree.VariantConfig,
|
|
329
333
|
parent: VariantTree.WardicVariantContextValue | undefined,
|
|
330
334
|
controls?: Accessor<AnimationControls.ControlsChange | undefined>,
|
|
335
|
+
failures?: Spine.VariantFailures,
|
|
331
336
|
): VariantNode => {
|
|
332
337
|
if (Bool.and(Predicate.isUndefined(config.variants), Bool.not(VariantTree.namesOwnVariants(config)))) return plainNode(config, parent)
|
|
333
338
|
const inherited = VariantTree.inheritedContext(config, parent)
|
|
@@ -338,7 +343,7 @@ export const createVariantNode = (
|
|
|
338
343
|
if (Predicate.isNotUndefined(joined)) onCleanup(joined.registration.dispose)
|
|
339
344
|
const own = Bool.match(VariantTree.hasOwnVariants(config), {
|
|
340
345
|
onFalse: constUndefined,
|
|
341
|
-
onTrue: () => ownOrchestration(cfg, config, parent, inherited, change),
|
|
346
|
+
onTrue: () => ownOrchestration(cfg, config, parent, inherited, change, failures),
|
|
342
347
|
})
|
|
343
348
|
// The spine reports on every frame (the per-frame path, docs/agents/effect-first.md): both
|
|
344
349
|
// reports are resolved here, once, so a frame makes two plain calls and allocates nothing.
|
|
@@ -353,7 +358,7 @@ export const createVariantNode = (
|
|
|
353
358
|
extraDelay: UndefinedOr.map(joined, ({ context, registration }) => (name: string | undefined) => {
|
|
354
359
|
const s = VariantTree.staggerOfName(context, name)
|
|
355
360
|
const n = registration.total()
|
|
356
|
-
return VariantTree.childDelayOf(s, registration.index(), n)
|
|
361
|
+
return VariantTree.childDelayOf(s, registration.index(), n, failures)
|
|
357
362
|
}),
|
|
358
363
|
canStart: () =>
|
|
359
364
|
UndefinedOr.match(inherited, { onUndefined: constTrue, onDefined: (context) => context.childrenMayStart() }) &&
|
package/src/ward.tsx
CHANGED
|
@@ -824,6 +824,7 @@ const nodeFor = (
|
|
|
824
824
|
config: WardConfigValues,
|
|
825
825
|
parent: VariantTree.WardicVariantContextValue | undefined,
|
|
826
826
|
change: Accessor<AnimationControls.ControlsChange | undefined> | undefined,
|
|
827
|
+
failures: Spine.VariantFailures,
|
|
827
828
|
): VariantNode => {
|
|
828
829
|
if (Predicate.isNotUndefined(share)) {
|
|
829
830
|
const node = share.node
|
|
@@ -831,7 +832,7 @@ const nodeFor = (
|
|
|
831
832
|
if (share.carries) return node
|
|
832
833
|
}
|
|
833
834
|
}
|
|
834
|
-
return createVariantNode(cfg, config, parent, change)
|
|
835
|
+
return createVariantNode(cfg, config, parent, change, failures)
|
|
835
836
|
}
|
|
836
837
|
|
|
837
838
|
/** A ward's **Animation controls** (#433): the controls, its view with each change as its entry, and the change in effect. */
|
|
@@ -1006,7 +1007,10 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1006
1007
|
// Its place in variant orchestration (ADR-0007, #50): where it's made, its given parent's (#349),
|
|
1007
1008
|
// or its given ward's.
|
|
1008
1009
|
const parent = variantParentOf(internal)
|
|
1009
|
-
|
|
1010
|
+
// A variant that throws is this element's alone (#979): its failures, which its spine keeps and its
|
|
1011
|
+
// orchestration reports to, once.
|
|
1012
|
+
const variantFailures = Spine.variantFailuresOf(runtime)
|
|
1013
|
+
const node = nodeFor(share, cfg, initialConfig, parent, UndefinedOr.map(controls, (c) => c.change), variantFailures)
|
|
1010
1014
|
|
|
1011
1015
|
// The nearest <AnimatePresence> (ADR-0007), or none.
|
|
1012
1016
|
const presence = usePresenceContext()
|
|
@@ -1018,6 +1022,9 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1018
1022
|
const presenceBlocks = PresenceRecord.presenceBlocksInitial(presence)
|
|
1019
1023
|
if (Bool.and(Arr.contains(setup.pending, "animate"), VariantTree.startsAtAnimate(initialConfig, node.inherited, presenceBlocks))) throw new Error(STARTS_AT_PENDING)
|
|
1020
1024
|
const start = Spine.startOf(initialConfig, node.inherited, presenceBlocks, untrack)
|
|
1025
|
+
// A variant whose resolver throws is this element's alone: reported once until it resolves, the element
|
|
1026
|
+
// keeping its last target (#979; ADR-0074).
|
|
1027
|
+
Spine.reportStart(variantFailures, start)
|
|
1021
1028
|
// Read once by the provider (#618, M1).
|
|
1022
1029
|
const { project } = useWardicRenderer()
|
|
1023
1030
|
|
|
@@ -1073,6 +1080,7 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1073
1080
|
// The config now, a plain copy read untracked, as setup reads it: this runs in the mount effect.
|
|
1074
1081
|
const now = WARD_VIEW.setupOf(view).config
|
|
1075
1082
|
begun = Spine.startOf(now, node.inherited, false, untrack)
|
|
1083
|
+
Spine.reportStart(variantFailures, begun)
|
|
1076
1084
|
snapshot.values = { ...begun.initialValues }
|
|
1077
1085
|
snapshot.velocities = {}
|
|
1078
1086
|
snapshot.drawnAt = {}
|
|
@@ -1154,7 +1162,7 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1154
1162
|
const target = createMemo<Spine.Resolution>(
|
|
1155
1163
|
() => {
|
|
1156
1164
|
const g = gestures()
|
|
1157
|
-
return Spine.resolutionOf(
|
|
1165
|
+
return Spine.keptOf(variantFailures, Spine.resolutionOf(
|
|
1158
1166
|
cfg(),
|
|
1159
1167
|
node.inherited,
|
|
1160
1168
|
start.initialLink,
|
|
@@ -1168,7 +1176,7 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
|
|
|
1168
1176
|
},
|
|
1169
1177
|
snapshot,
|
|
1170
1178
|
ownChange(),
|
|
1171
|
-
)
|
|
1179
|
+
))
|
|
1172
1180
|
},
|
|
1173
1181
|
{ equals: sameTarget, transparent: true },
|
|
1174
1182
|
)
|
|
@@ -2051,7 +2059,10 @@ const serverWard = (config: WardConfig, internal: WardInternals): Ward => {
|
|
|
2051
2059
|
if (Bool.and(Arr.contains(setup.pending, "animate"), VariantTree.startsAtAnimate(atSetup, VariantTree.inheritedContext(atSetup, parent), presenceBlocks))) throw new Error(STARTS_AT_PENDING)
|
|
2052
2060
|
const c = AnimationControls.uncontrolledOf(WARD_VIEW.snapshotOf(view))
|
|
2053
2061
|
const node = VariantTree.serverVariantNode(c, parent)
|
|
2054
|
-
const
|
|
2062
|
+
const serverStart = Spine.startOf(c, node.inherited, presenceBlocks, untrack)
|
|
2063
|
+
// A variant that throws leaves its values out of the markup, logged on the server (#979).
|
|
2064
|
+
if (Option.isSome(serverStart.failure)) Spine.variantFailedOnServer(serverStart.failure.value)
|
|
2065
|
+
const initialValues = serverStart.initialValues
|
|
2055
2066
|
const layoutNode = Spine.isLayoutNode(c)
|
|
2056
2067
|
const seed = Style.starting(internal.tag, ElementSetup.drawnAtRest(initialValues, layoutNode, c.transformTemplate))
|
|
2057
2068
|
// Its Appear animation (#48, ADR-0044): its slot in the render's, and the group its Variant
|