@wardic/solid 2.1.1 → 2.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.
- package/dist/browser/batch-gestures.js +16 -2
- package/dist/browser/batch-gestures.js.map +1 -1
- package/dist/browser/batch-reorder-places.js +3 -3
- package/dist/browser/batch-reorder.js +17 -8
- package/dist/browser/batch-reorder.js.map +1 -1
- package/dist/browser/create-animation-controls.js +22 -0
- package/dist/browser/create-animation-controls.js.map +1 -0
- package/dist/browser/frame-effect.js +14 -3
- package/dist/browser/frame-effect.js.map +1 -1
- package/dist/browser/gesture-callbacks.js +3 -1
- package/dist/browser/gesture-callbacks.js.map +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/kept-transform.js +53 -0
- package/dist/browser/kept-transform.js.map +1 -0
- package/dist/browser/lifecycle.js +22 -13
- package/dist/browser/lifecycle.js.map +1 -1
- package/dist/browser/live-value.js +37 -5
- package/dist/browser/live-value.js.map +1 -1
- package/dist/browser/motion-props.js +1 -1
- package/dist/browser/presence-hooks.js +1 -1
- package/dist/browser/presence-hooks.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 +28 -8
- package/dist/browser/stage-ward.js.map +1 -1
- package/dist/browser/stage.js.map +1 -1
- package/dist/browser/unstable/v2/index.js.map +1 -1
- package/dist/browser/v1/batch-reorder-group.js +4 -4
- 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 +22 -8
- 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/index.js.map +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/presence.js +1 -1
- package/dist/browser/v1/presence.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 +19 -9
- 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-places.js +3 -3
- package/dist/server/batch-reorder.js +17 -8
- package/dist/server/batch-reorder.js.map +1 -1
- package/dist/server/create-animation-controls.js +22 -0
- package/dist/server/create-animation-controls.js.map +1 -0
- package/dist/server/frame-effect.js +14 -3
- package/dist/server/frame-effect.js.map +1 -1
- package/dist/server/gesture-callbacks.js +3 -1
- package/dist/server/gesture-callbacks.js.map +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/kept-transform.js +53 -0
- package/dist/server/kept-transform.js.map +1 -0
- package/dist/server/lifecycle.js +22 -13
- package/dist/server/lifecycle.js.map +1 -1
- package/dist/server/live-value.js +37 -5
- package/dist/server/live-value.js.map +1 -1
- package/dist/server/motion-props.js +1 -1
- package/dist/server/presence-hooks.js +1 -1
- package/dist/server/presence-hooks.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 +28 -8
- package/dist/server/stage-ward.js.map +1 -1
- package/dist/server/stage.js.map +1 -1
- package/dist/server/unstable/v2/index.js.map +1 -1
- package/dist/server/v1/batch-reorder-group.js +4 -4
- 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 +22 -8
- 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/index.js.map +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/presence.js +1 -1
- package/dist/server/v1/presence.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 +19 -9
- 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-places.js +3 -3
- package/dist/solid/batch-reorder.d.ts.map +1 -1
- package/dist/solid/batch-reorder.js +18 -8
- package/dist/solid/batch-reorder.js.map +1 -1
- package/dist/solid/create-animation-controls.d.ts +20 -0
- package/dist/solid/create-animation-controls.d.ts.map +1 -0
- package/dist/solid/create-animation-controls.js +22 -0
- package/dist/solid/create-animation-controls.js.map +1 -0
- 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/gesture-callbacks.d.ts.map +1 -1
- package/dist/solid/gesture-callbacks.js +2 -0
- package/dist/solid/gesture-callbacks.js.map +1 -1
- package/dist/solid/index.d.ts +4 -3
- package/dist/solid/index.d.ts.map +1 -1
- package/dist/solid/index.jsx +1 -1
- package/dist/solid/index.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/lifecycle.d.ts +13 -5
- package/dist/solid/lifecycle.d.ts.map +1 -1
- package/dist/solid/lifecycle.js +20 -21
- package/dist/solid/lifecycle.js.map +1 -1
- 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/motion-props.js +1 -1
- package/dist/solid/presence-hooks.jsx +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 +28 -7
- 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/unstable/v2/index.d.ts +4 -0
- package/dist/solid/unstable/v2/index.d.ts.map +1 -1
- package/dist/solid/unstable/v2/index.jsx.map +1 -1
- package/dist/solid/v1/batch-reorder-group.jsx +4 -4
- 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 +22 -8
- 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 +3 -1
- package/dist/solid/v1/index.d.ts.map +1 -1
- package/dist/solid/v1/index.jsx +1 -1
- package/dist/solid/v1/index.jsx.map +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/presence.jsx +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 +20 -9
- package/dist/solid/ward.jsx.map +1 -1
- package/package.json +5 -5
- package/src/batch-gestures.ts +16 -3
- package/src/batch-reorder-places.ts +3 -3
- package/src/batch-reorder.ts +17 -8
- package/src/create-animation-controls.ts +22 -0
- package/src/frame-effect.tsx +14 -3
- package/src/gesture-callbacks.ts +2 -0
- package/src/index.tsx +4 -2
- package/src/kept-transform.ts +57 -0
- package/src/lifecycle.ts +32 -24
- package/src/live-value.tsx +37 -5
- package/src/motion-props.ts +1 -1
- package/src/presence-hooks.tsx +1 -1
- package/src/presence.tsx +19 -3
- package/src/provider.tsx +5 -0
- package/src/sensors.tsx +6 -4
- package/src/stage-ward.tsx +32 -10
- package/src/stage.ts +4 -1
- package/src/unstable/v2/index.tsx +4 -0
- package/src/v1/batch-reorder-group.tsx +4 -4
- package/src/v1/create-batch.tsx +34 -2
- package/src/v1/create-ward.tsx +24 -9
- package/src/v1/directive.tsx +7 -2
- package/src/v1/index.tsx +3 -1
- package/src/v1/live-value.tsx +10 -3
- package/src/v1/presence.tsx +1 -1
- 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 +21 -10
package/src/lifecycle.ts
CHANGED
|
@@ -100,6 +100,11 @@ export interface WardDragInfo extends GestureInfo.WardicDragInfo {
|
|
|
100
100
|
readonly element: WardElement
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
/** A drag's or a pan's end (Motion's `PanInfo` at `onDragEnd`): its {@link WardDragInfo}, and how it ended, `endedBy` (#1042). */
|
|
104
|
+
export interface WardDragEndInfo extends GestureInfo.WardicDragEndInfo {
|
|
105
|
+
readonly element: WardElement
|
|
106
|
+
}
|
|
107
|
+
|
|
103
108
|
/** What each of `next(name)`'s names resolves to. */
|
|
104
109
|
export interface WardEvents {
|
|
105
110
|
/** The next landing. */
|
|
@@ -135,8 +140,8 @@ export interface WardEvents {
|
|
|
135
140
|
readonly directionLock: "x" | "y"
|
|
136
141
|
/** That drag moved: its start and each move after (Motion's `onDrag`). */
|
|
137
142
|
readonly drag: WardDragInfo
|
|
138
|
-
/** That drag ended at its release (Motion's `onDragEnd`). */
|
|
139
|
-
readonly dragEnd:
|
|
143
|
+
/** That drag ended: at its release, a cancel or a lost release, as its `endedBy` says (Motion's `onDragEnd`). */
|
|
144
|
+
readonly dragEnd: WardDragEndInfo
|
|
140
145
|
/**
|
|
141
146
|
* The drag's release came to rest on its own (Motion's `onDragTransitionEnd`): its Fling
|
|
142
147
|
* or its spring back, or at once for one released in place. Not for one a grab stopped.
|
|
@@ -152,8 +157,8 @@ export interface WardEvents {
|
|
|
152
157
|
readonly panStart: WardDragInfo
|
|
153
158
|
/** That pan moved: its start and each move after (Motion's `onPan`). */
|
|
154
159
|
readonly pan: WardDragInfo
|
|
155
|
-
/** That pan ended at its release, or was cancelled (Motion's `onPanEnd`). Only a pan that started. */
|
|
156
|
-
readonly panEnd:
|
|
160
|
+
/** That pan ended at its release, or was cancelled, as its `endedBy` says (Motion's `onPanEnd`). Only a pan that started. */
|
|
161
|
+
readonly panEnd: WardDragEndInfo
|
|
157
162
|
/**
|
|
158
163
|
* The element came into view, as its `viewport` says (Motion's `onViewportEnter`). One that
|
|
159
164
|
* starts out of view tells nothing until it enters.
|
|
@@ -249,21 +254,16 @@ const PRESS_EVENT: Record<Recognizer.PressPhase, WardEvent | undefined> = {
|
|
|
249
254
|
}
|
|
250
255
|
|
|
251
256
|
/** A drag's or a pan's start or end. */
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
const DRAG_EVENT: Record<Drag.Sample["phase"], MovementEvent | undefined> = {
|
|
256
|
-
start: "dragStart",
|
|
257
|
-
move: undefined,
|
|
258
|
-
end: "dragEnd",
|
|
257
|
+
interface MovementEvents {
|
|
258
|
+
readonly start: "dragStart" | "panStart"
|
|
259
|
+
readonly end: "dragEnd" | "panEnd"
|
|
259
260
|
}
|
|
260
261
|
|
|
261
|
-
/**
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}
|
|
262
|
+
/** A drag's start and end events: its start, which `drag` hears too, is told on its own. */
|
|
263
|
+
const DRAG_EVENTS: MovementEvents = { start: "dragStart", end: "dragEnd" }
|
|
264
|
+
|
|
265
|
+
/** A pan's, past its session's start: as {@link DRAG_EVENTS}, `pan` its every move. */
|
|
266
|
+
const PAN_EVENTS: MovementEvents = { start: "panStart", end: "panEnd" }
|
|
267
267
|
|
|
268
268
|
/**
|
|
269
269
|
* A ward's lifecycle, made under its `owner`. It's the spine's {@link AnimationHooks}; the ward
|
|
@@ -420,9 +420,9 @@ export class Lifecycle implements Spine.AnimationHooks {
|
|
|
420
420
|
dragged(sample: Drag.Sample, locked: boolean, element: WardElement): void {
|
|
421
421
|
// A sensor given the ward reads every sample, as one on its element would (#884).
|
|
422
422
|
UndefinedOr.map(this.samples, (heard) => Iter.forEach(heard, (listener) => listener(sample)))
|
|
423
|
-
if (sample.
|
|
423
|
+
if (sample.endedBy === "controls") return
|
|
424
424
|
if (Bool.and(locked, sample.phase === "start")) this.tell("directionLock", () => sample.axis as "x" | "y")
|
|
425
|
-
this.moved(
|
|
425
|
+
this.moved(DRAG_EVENTS, "drag", sample, element)
|
|
426
426
|
}
|
|
427
427
|
|
|
428
428
|
/** A pan's sample (#273): its session's start, then as a drag's. */
|
|
@@ -432,7 +432,7 @@ export class Lifecycle implements Spine.AnimationHooks {
|
|
|
432
432
|
this.tell("panSessionStart", () => ({ ...GestureInfo.pointOfSample(sample), element }))
|
|
433
433
|
return
|
|
434
434
|
}
|
|
435
|
-
this.moved(
|
|
435
|
+
this.moved(PAN_EVENTS, "pan", sample as Drag.Sample, element)
|
|
436
436
|
}
|
|
437
437
|
|
|
438
438
|
/** The drag's release came to rest on its own (#273). */
|
|
@@ -455,12 +455,20 @@ export class Lifecycle implements Spine.AnimationHooks {
|
|
|
455
455
|
this.tell(Bool.match(edge.active, { onTrue: (): WardEvent => "viewportEnter", onFalse: () => "viewportLeave" }), constUndefined)
|
|
456
456
|
}
|
|
457
457
|
|
|
458
|
-
/**
|
|
459
|
-
|
|
458
|
+
/**
|
|
459
|
+
* A drag's or a pan's sample past a pan's session's start: its start's event, then `every` at its start
|
|
460
|
+
* and each move; at its end, its end's event, told how it ended (#1042). Each info built only for a
|
|
461
|
+
* reader. Plain statements: it runs at every move.
|
|
462
|
+
*/
|
|
463
|
+
private moved(events: MovementEvents, every: "drag" | "pan", sample: Drag.Sample, element: WardElement): void {
|
|
460
464
|
if (Predicate.isUndefined(this.events)) return
|
|
461
465
|
const info = (): WardDragInfo => ({ ...GestureInfo.dragInfoOf(sample), element })
|
|
462
|
-
if (
|
|
463
|
-
|
|
466
|
+
if (sample.phase === "end") {
|
|
467
|
+
this.tell(events.end, (): WardDragEndInfo => ({ ...GestureInfo.dragEndInfoOf(sample), element }))
|
|
468
|
+
return
|
|
469
|
+
}
|
|
470
|
+
if (sample.phase === "start") this.tell(events.start, info)
|
|
471
|
+
this.tell(every, info)
|
|
464
472
|
}
|
|
465
473
|
|
|
466
474
|
/** Resolve the `next(name)` calls waiting, with `value()`, made once there are any. */
|
package/src/live-value.tsx
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
import type * as InterpolatorRegistry from "@wardic/core/InterpolatorRegistry"
|
|
27
27
|
import * as LiveValue from "@wardic/core/LiveValue"
|
|
28
28
|
import * as Bool from "effect/Boolean"
|
|
29
|
+
import * as Cause from "effect/Cause"
|
|
29
30
|
import * as Effect from "effect/Effect"
|
|
30
31
|
import * as Predicate from "effect/Predicate"
|
|
31
32
|
import * as Atom from "effect/reactivity/Atom"
|
|
@@ -41,7 +42,8 @@ import * as OwnerScope from "@wardic/dom/unstable/OwnerScope"
|
|
|
41
42
|
import * as ServerInterpolators from "@wardic/dom/unstable/ServerInterpolators"
|
|
42
43
|
import { followAtom } from "./bridge.tsx"
|
|
43
44
|
import { CLIENT_ONLY, CLIENT_ONLY_DEFERRED } from "./solid-reactivity.ts"
|
|
44
|
-
import {
|
|
45
|
+
import { failedOn, FUNCTION_FAILED, keptComputeOf, MIXER_FAILED } from "./kept-transform.ts"
|
|
46
|
+
import { useProvidedRuntime, useWardicRuntime, useWardicSkipAnimations } from "./provider.tsx"
|
|
45
47
|
|
|
46
48
|
/** A Live value read now on a server: an Atom through a server's own registry, an accessor called. */
|
|
47
49
|
const readOnServer = <A,>(source: LiveStyle.LiveSource<A>): A => LiveStyle.readLive(source, LiveStyle.serverRegistryOf, untrack) as A
|
|
@@ -84,6 +86,8 @@ const liveOf = <A, R>(runtime: WardicRuntime, live: Effect.Effect<Atom.Atom<A>,
|
|
|
84
86
|
* two stops blends their outputs, numbers, units and colours alike. `input` is as long as `output`,
|
|
85
87
|
* ascending or descending; outside it the ends hold, unless `clamp: false`. `ease` eases each stretch,
|
|
86
88
|
* one for all or one each, and a `mixer`, `(from, to) => (t) => value`, blends outputs of any type. A signal read inside `fn` is tracked too: its change maps again.
|
|
89
|
+
* A function or a `mixer` that throws keeps the value it gave last, and is logged once until it returns;
|
|
90
|
+
* one that throws for its first value throws to whatever reads it first.
|
|
87
91
|
* Through ranges from a `createScroll` value, the browser draws it with the scroll where it can.
|
|
88
92
|
* Motion's `useTransform`.
|
|
89
93
|
*
|
|
@@ -121,17 +125,45 @@ export function createTransform(
|
|
|
121
125
|
onFalse: () => interpolatorOf(fnOrInput as ReadonlyArray<number>, output as ReadonlyArray<unknown>, options) as (a: unknown) => unknown,
|
|
122
126
|
})
|
|
123
127
|
if (isServer) return () => fn(readOnServer(source))
|
|
128
|
+
// An app's function, or a `mixer` in its ranges, that throws: its last value kept, reported at the first
|
|
129
|
+
// throw of a run of them, again after a clean call; its first value's throw is its first reader's (#979).
|
|
130
|
+
const runtime = useProvidedRuntime()
|
|
131
|
+
const message = Bool.match(Predicate.isFunction(fnOrInput), { onTrue: () => FUNCTION_FAILED, onFalse: () => MIXER_FAILED })
|
|
124
132
|
const atom = LiveStyle.atomOf(source)
|
|
125
133
|
// A plain accessor: mapped in a memo, as Solid maps it.
|
|
126
|
-
if (Predicate.isUndefined(atom)) return createMemo((
|
|
134
|
+
if (Predicate.isUndefined(atom)) return createMemo(keptComputeOf(source as Accessor<unknown>, fn, runtime, message), CLIENT_ONLY)
|
|
127
135
|
// On an Atom: derived on it, so it's set where its source is. What `fn` reads of Solid besides its
|
|
128
136
|
// source is tracked here, and a change of it re-derives the Atom.
|
|
129
137
|
const registry = useWardicRuntime().runSync(AtomRegistry.AtomRegistry)
|
|
130
|
-
|
|
138
|
+
let last: unknown
|
|
139
|
+
let kept = false
|
|
140
|
+
let failing = false
|
|
141
|
+
// The try is in the read the registry calls, around a direct call (#979).
|
|
142
|
+
const derived = Atom.make((get) =>
|
|
143
|
+
untrack(() => {
|
|
144
|
+
const v = get(atom)
|
|
145
|
+
try {
|
|
146
|
+
last = fn(v)
|
|
147
|
+
kept = true
|
|
148
|
+
if (failing) failing = false
|
|
149
|
+
} catch (defect) {
|
|
150
|
+
if (!kept) throw defect
|
|
151
|
+
if (!failing) failedOn(runtime, message, Cause.die(defect))
|
|
152
|
+
failing = true
|
|
153
|
+
}
|
|
154
|
+
return last
|
|
155
|
+
}))
|
|
131
156
|
// A change of what `fn` reads of Solid derives it again: the registry's own refresh, where a counter
|
|
132
|
-
// Atom it read was bumped (#618, L2).
|
|
157
|
+
// Atom it read was bumped (#618, L2). A throw here is the Atom's to report, as it derives again.
|
|
133
158
|
createEffect(
|
|
134
|
-
() =>
|
|
159
|
+
() => {
|
|
160
|
+
const v = registry.get(atom)
|
|
161
|
+
try {
|
|
162
|
+
return fn(v)
|
|
163
|
+
} catch {
|
|
164
|
+
return undefined
|
|
165
|
+
}
|
|
166
|
+
},
|
|
135
167
|
() => {
|
|
136
168
|
registry.refresh(derived)
|
|
137
169
|
},
|
package/src/motion-props.ts
CHANGED
|
@@ -101,7 +101,7 @@ type ConfigKey = (typeof CONFIG_KEYS)[number]
|
|
|
101
101
|
* it. A build allocates its config alone (#525, #540).
|
|
102
102
|
*/
|
|
103
103
|
const configBuildOf = (motion: WardicMotionProps, keys: ReadonlyArray<ConfigKey>): Reactivity.Accessor<WardConfig.WardConfig> => () => {
|
|
104
|
-
// Per
|
|
104
|
+
// Per Subject at mount (#540): a loop.
|
|
105
105
|
const config: Record<string, unknown> = {}
|
|
106
106
|
for (const key of keys) {
|
|
107
107
|
const value = motion[key]
|
package/src/presence-hooks.tsx
CHANGED
package/src/presence.tsx
CHANGED
|
@@ -106,7 +106,9 @@ export function AnimatePresence(props: AnimatePresenceProps): JSX.Element {
|
|
|
106
106
|
const ref = untrack(() => props.ref)
|
|
107
107
|
const own = Bool.match(hasRef(ref), { onTrue: makePresenceHandle, onFalse: constUndefined })
|
|
108
108
|
// `mode="wait"`'s held children may go on the page (#277): the children are rendered again.
|
|
109
|
-
const [released,
|
|
109
|
+
const [released, setReleased] = createSignal<undefined>(undefined, { equals: false })
|
|
110
|
+
// Whether the controller is presenting the children now, in the effect below (#987).
|
|
111
|
+
let presenting = false
|
|
110
112
|
// The presence above, if any (#277's PR 5c): read before this one provides its own.
|
|
111
113
|
const parent = usePresenceContext()
|
|
112
114
|
const presence = PresenceController.makePresence({
|
|
@@ -123,7 +125,16 @@ export function AnimatePresence(props: AnimatePresenceProps): JSX.Element {
|
|
|
123
125
|
anchorX: () => untrack(() => props.anchorX),
|
|
124
126
|
anchorY: () => untrack(() => props.anchorY),
|
|
125
127
|
presenceAffectsLayout: () => untrack(() => props.presenceAffectsLayout),
|
|
126
|
-
|
|
128
|
+
// #987 (ADR-0048, *Amendment (#987)*): a release made inside `present` (a leaver with nothing to play
|
|
129
|
+
// goes at once there, or a take-over cuts the last exit short) is in the effect below, whose source
|
|
130
|
+
// `shown` reads `released`. Set there, the effect re-ran on its own write (EFFECT_WRITES_OWN_SOURCE),
|
|
131
|
+
// so it's a microtask later, still before the paint. Any other, an exit's end in a tick, is at once:
|
|
132
|
+
// the held child starts in that tick's Late window (#680).
|
|
133
|
+
release: () =>
|
|
134
|
+
Bool.match(presenting, {
|
|
135
|
+
onTrue: () => queueMicrotask(() => setReleased(undefined)),
|
|
136
|
+
onFalse: () => setReleased(undefined),
|
|
137
|
+
}),
|
|
127
138
|
})
|
|
128
139
|
UndefinedOr.map(own, (handle) => (ref as (presence: Presence) => void)(handle.handle))
|
|
129
140
|
onSettledClientOnly(presence.mounted)
|
|
@@ -143,7 +154,12 @@ export function AnimatePresence(props: AnimatePresenceProps): JSX.Element {
|
|
|
143
154
|
createEffect(
|
|
144
155
|
shown,
|
|
145
156
|
(current) => {
|
|
146
|
-
|
|
157
|
+
presenting = true
|
|
158
|
+
try {
|
|
159
|
+
presence.present(current)
|
|
160
|
+
} finally {
|
|
161
|
+
presenting = false
|
|
162
|
+
}
|
|
147
163
|
},
|
|
148
164
|
CLIENT_ONLY,
|
|
149
165
|
)
|
package/src/provider.tsx
CHANGED
|
@@ -366,6 +366,11 @@ export function useWardicRuntime(): WardicRuntime {
|
|
|
366
366
|
return fromContext(contextValue(), "useWardicRuntime", (value) => value.runtime)
|
|
367
367
|
}
|
|
368
368
|
|
|
369
|
+
/** The nearest provider's runtime, or none outside one: where a transform's failure is reported (#979). */
|
|
370
|
+
export function useProvidedRuntime(): WardicRuntime | undefined {
|
|
371
|
+
return UndefinedOr.map(contextValue(), (value) => value.runtime)
|
|
372
|
+
}
|
|
373
|
+
|
|
369
374
|
/**
|
|
370
375
|
* The nearest `WardicProvider`'s flush gate: what a binding registers its elements with, and writes
|
|
371
376
|
* their values into, committed once a frame. For building an element of your own on Wardic's
|
package/src/sensors.tsx
CHANGED
|
@@ -40,13 +40,14 @@ import { isServer } from "@solidjs/web"
|
|
|
40
40
|
import { type Accessor, createSignal, DEV, onCleanup, useContext } from "solid-js"
|
|
41
41
|
import type * as WardConfig from "@wardic/dom/unstable/WardConfig"
|
|
42
42
|
import { inViewOptionsOf } from "./gesture-callbacks.ts"
|
|
43
|
+
import { failedOn } from "./kept-transform.ts"
|
|
43
44
|
import type { Listener } from "./waiters.ts"
|
|
44
45
|
import { type StageSubject, WardicStage } from "./stage.ts"
|
|
45
46
|
import { type AnyWard, isWard, type Sensed, sensedOf } from "./ward.tsx"
|
|
46
47
|
import * as OwnerScope from "@wardic/dom/unstable/OwnerScope"
|
|
47
48
|
import type { WardicServices } from "./runtime.ts"
|
|
48
49
|
import { fromAtom } from "./bridge.tsx"
|
|
49
|
-
import { useWardicReducedMotionSetting, useWardicRuntime } from "./provider.tsx"
|
|
50
|
+
import { useProvidedRuntime, useWardicReducedMotionSetting, useWardicRuntime } from "./provider.tsx"
|
|
50
51
|
|
|
51
52
|
export type { CreateDragOptions } from "./drag-samples.ts"
|
|
52
53
|
|
|
@@ -90,9 +91,10 @@ export const stageSensorOf = <A,>(
|
|
|
90
91
|
const [value, setValue] = createSignal<A>(initial as Exclude<A, Function>)
|
|
91
92
|
const scope = Scope.makeUnsafe()
|
|
92
93
|
onCleanup(() => Effect.runSync(Scope.close(scope, Exit.void)))
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
// #979 group I, row 26 (ADR-0074): on the provider's runtime, so the app's logger and reporters hear it;
|
|
95
|
+
// a Stage needs no provider, and with none, Effect's default runtime's.
|
|
96
|
+
const runtime = useProvidedRuntime()
|
|
97
|
+
const onDefect = (cause: Cause.Cause<never>): void => failedOn(runtime, `wardic.${name}: a gesture handler failed`, cause)
|
|
96
98
|
const watch = watchOf(target, { on: (next) => setValue(() => next as Exclude<A, Function>), onDefect })
|
|
97
99
|
Effect.runSync(watch.pipe(Effect.provideService(InputSource.InputSource, (stage as NonNullable<typeof stage>).input), Scope.provide(scope)))
|
|
98
100
|
return value
|
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
|
|
@@ -174,7 +177,7 @@ const NO_GESTURES: Gestures = { subject: undefined, hovered: false, pressed: fal
|
|
|
174
177
|
/** The Subject it's on: its spine, its gate registration, and which of its recognizers run. */
|
|
175
178
|
interface Mounted {
|
|
176
179
|
readonly subject: object
|
|
177
|
-
readonly spine: Spine.
|
|
180
|
+
readonly spine: Spine.SubjectSpine
|
|
178
181
|
/** Its spine's record of what it drew: a Scene object's own each Subject, as the last exits beside the next. */
|
|
179
182
|
readonly snapshot: Spine.Snapshot
|
|
180
183
|
hover: boolean
|
|
@@ -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))
|
|
@@ -557,11 +579,11 @@ const wardOn = (
|
|
|
557
579
|
// Its `initial`, written before its first frame is drawn (ADR-0070 decision 5).
|
|
558
580
|
if (Bool.not(Rec.isEmptyRecord(begun.initialValues))) gate.write(mountId, begun.initialValues)
|
|
559
581
|
let exiting: (() => void) | undefined
|
|
560
|
-
const spine = Spine.
|
|
582
|
+
const spine = Spine.makeSubjectSpine({
|
|
561
583
|
runtime,
|
|
562
584
|
gate,
|
|
563
585
|
id: mountId,
|
|
564
|
-
|
|
586
|
+
subject,
|
|
565
587
|
tag: undefined,
|
|
566
588
|
config: cfg,
|
|
567
589
|
parent: node.inherited,
|
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
|
}
|
|
@@ -190,6 +190,8 @@ export {
|
|
|
190
190
|
/** @deprecated `@wardic/solid/unstable/v2` is `@wardic/solid` since 2.0: import it from there. This alias goes at Wardic's next major (#566). */
|
|
191
191
|
WardicStage,
|
|
192
192
|
/** @deprecated `@wardic/solid/unstable/v2` is `@wardic/solid` since 2.0: import it from there. This alias goes at Wardic's next major (#566). */
|
|
193
|
+
type WardDragEndInfo,
|
|
194
|
+
/** @deprecated `@wardic/solid/unstable/v2` is `@wardic/solid` since 2.0: import it from there. This alias goes at Wardic's next major (#566). */
|
|
193
195
|
type WardDragInfo,
|
|
194
196
|
/** @deprecated `@wardic/solid/unstable/v2` is `@wardic/solid` since 2.0: import it from there. This alias goes at Wardic's next major (#566). */
|
|
195
197
|
type WardElement,
|
|
@@ -446,6 +448,8 @@ export {
|
|
|
446
448
|
/** @deprecated `@wardic/solid/unstable/v2` is `@wardic/solid` since 2.0: import it from there. This alias goes at Wardic's next major (#566). */
|
|
447
449
|
type WardicAnimateOptions,
|
|
448
450
|
/** @deprecated `@wardic/solid/unstable/v2` is `@wardic/solid` since 2.0: import it from there. This alias goes at Wardic's next major (#566). */
|
|
451
|
+
type WardicAnimationEnd,
|
|
452
|
+
/** @deprecated `@wardic/solid/unstable/v2` is `@wardic/solid` since 2.0: import it from there. This alias goes at Wardic's next major (#566). */
|
|
449
453
|
type WardicAnimationSequence,
|
|
450
454
|
/** @deprecated `@wardic/solid/unstable/v2` is `@wardic/solid` since 2.0: import it from there. This alias goes at Wardic's next major (#566). */
|
|
451
455
|
type WardicAnimationSubject,
|
|
@@ -264,7 +264,7 @@ const attributeOn = (el: Element, name: string, value: string | undefined): void
|
|
|
264
264
|
|
|
265
265
|
/** `el`'s style taken from `prev` to `next`: each key `next` drops removed, each it changes set. */
|
|
266
266
|
const restyle = (el: HTMLElement, prev: Style.Style, next: Style.Style): void => {
|
|
267
|
-
// Per
|
|
267
|
+
// Per Subject at mount (#540): statements.
|
|
268
268
|
Arr.forEach(Rec.keys(prev), (key) => {
|
|
269
269
|
if (Predicate.isNullish(next[key])) el.style.removeProperty(key)
|
|
270
270
|
})
|
|
@@ -468,7 +468,7 @@ const ItemElement = <V,>({ tag, local, rest, item, writes }: ItemElementProps<V>
|
|
|
468
468
|
|
|
469
469
|
/** A new element for `tag`, or, hydrating, the server's next one: Solid's `<Dynamic>`'s. */
|
|
470
470
|
const elementFor = (tag: string, hydrating: boolean): HTMLElement => {
|
|
471
|
-
// Per
|
|
471
|
+
// Per Subject at mount (#540): statements.
|
|
472
472
|
if (hydrating) return getNextElement() as HTMLElement
|
|
473
473
|
return document.createElement(tag)
|
|
474
474
|
}
|
|
@@ -478,7 +478,7 @@ const elementFor = (tag: string, hydrating: boolean): HTMLElement => {
|
|
|
478
478
|
* new element as one CSS text (Q47), hydrating a key at a time, and from then on the group's to write.
|
|
479
479
|
*/
|
|
480
480
|
const itemStyleOn = <V,>(el: HTMLElement, hydrating: boolean, local: ItemLocal<V>, item: BatchReorderItem, shared: SharedStyle): void => {
|
|
481
|
-
// Per
|
|
481
|
+
// Per Subject at mount (#540): statements.
|
|
482
482
|
if ("style" in local) {
|
|
483
483
|
createRenderEffect((prev: Style.Style) => {
|
|
484
484
|
const next = item.style(local.style)
|
|
@@ -503,7 +503,7 @@ const attributeFor = <V,>(
|
|
|
503
503
|
shared: SharedAttribute,
|
|
504
504
|
own: (local: ItemLocal<V>, shared: SharedAttribute) => string | undefined,
|
|
505
505
|
): void => {
|
|
506
|
-
// Per
|
|
506
|
+
// Per Subject at mount (#540): statements.
|
|
507
507
|
if (key in local) {
|
|
508
508
|
createRenderEffect(() => attributeOn(el, shared.name, own(local, shared)))
|
|
509
509
|
return
|
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
|
))
|