@wardic/core 1.3.1 → 1.3.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/BaseValue.d.ts +1 -1
- package/dist/BaseValue.js +2 -2
- package/dist/BaseValue.js.map +1 -1
- package/dist/Batch.d.ts +5 -9
- package/dist/Batch.d.ts.map +1 -1
- package/dist/Batch.js +166 -20
- package/dist/Batch.js.map +1 -1
- package/dist/Clock.d.ts +16 -0
- package/dist/Clock.d.ts.map +1 -1
- package/dist/Clock.js +13 -0
- package/dist/Clock.js.map +1 -1
- package/dist/DragRecognizer.d.ts +10 -5
- package/dist/DragRecognizer.d.ts.map +1 -1
- package/dist/DragRecognizer.js +60 -24
- package/dist/DragRecognizer.js.map +1 -1
- package/dist/Frame.js +1 -1
- package/dist/Frame.js.map +1 -1
- package/dist/InputFeed.d.ts +10 -7
- package/dist/InputFeed.d.ts.map +1 -1
- package/dist/InputFeed.js +16 -35
- package/dist/InputFeed.js.map +1 -1
- package/dist/LiveValue.d.ts +9 -3
- package/dist/LiveValue.d.ts.map +1 -1
- package/dist/LiveValue.js +160 -14
- package/dist/LiveValue.js.map +1 -1
- package/dist/Machine.d.ts +16 -6
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +50 -27
- package/dist/Machine.js.map +1 -1
- package/dist/Playback.d.ts.map +1 -1
- package/dist/Playback.js +10 -8
- package/dist/Playback.js.map +1 -1
- package/dist/Recognizer.d.ts +1 -1
- package/dist/Recognizer.d.ts.map +1 -1
- package/dist/Recognizer.js +9 -4
- package/dist/Recognizer.js.map +1 -1
- package/dist/internal/frameLoop.d.ts +10 -2
- package/dist/internal/frameLoop.d.ts.map +1 -1
- package/dist/internal/frameLoop.js +148 -18
- package/dist/internal/frameLoop.js.map +1 -1
- package/dist/internal/guarded.d.ts +16 -0
- package/dist/internal/guarded.d.ts.map +1 -0
- package/dist/internal/guarded.js +68 -0
- package/dist/internal/guarded.js.map +1 -0
- package/dist/internal/stepper.d.ts +9 -3
- package/dist/internal/stepper.d.ts.map +1 -1
- package/dist/internal/stepper.js +5 -4
- package/dist/internal/stepper.js.map +1 -1
- package/dist/unstable/AnimationControls.d.ts +15 -8
- package/dist/unstable/AnimationControls.d.ts.map +1 -1
- package/dist/unstable/AnimationControls.js +36 -15
- package/dist/unstable/AnimationControls.js.map +1 -1
- package/dist/unstable/AppearHandoff.d.ts +6 -0
- package/dist/unstable/AppearHandoff.d.ts.map +1 -1
- package/dist/unstable/AppearHandoff.js.map +1 -1
- package/dist/unstable/Config.d.ts +5 -1
- package/dist/unstable/Config.d.ts.map +1 -1
- package/dist/unstable/Config.js.map +1 -1
- package/dist/unstable/FlushGate.d.ts +4 -2
- package/dist/unstable/FlushGate.d.ts.map +1 -1
- package/dist/unstable/FlushGate.js +155 -38
- package/dist/unstable/FlushGate.js.map +1 -1
- package/dist/unstable/FrameEffects.d.ts +4 -1
- package/dist/unstable/FrameEffects.d.ts.map +1 -1
- package/dist/unstable/FrameEffects.js +12 -1
- package/dist/unstable/FrameEffects.js.map +1 -1
- package/dist/unstable/Imperative.d.ts +13 -4
- package/dist/unstable/Imperative.d.ts.map +1 -1
- package/dist/unstable/Imperative.js +202 -43
- package/dist/unstable/Imperative.js.map +1 -1
- package/dist/unstable/MeasuredPairs.d.ts +6 -2
- package/dist/unstable/MeasuredPairs.d.ts.map +1 -1
- package/dist/unstable/MeasuredPairs.js.map +1 -1
- package/dist/unstable/PresenceRecord.d.ts +4 -0
- package/dist/unstable/PresenceRecord.d.ts.map +1 -1
- package/dist/unstable/PresenceRecord.js.map +1 -1
- package/dist/unstable/Report.d.ts +7 -0
- package/dist/unstable/Report.d.ts.map +1 -1
- package/dist/unstable/Report.js +17 -1
- package/dist/unstable/Report.js.map +1 -1
- package/dist/unstable/RetargetLegs.d.ts +6 -0
- package/dist/unstable/RetargetLegs.d.ts.map +1 -1
- package/dist/unstable/RetargetLegs.js +15 -0
- package/dist/unstable/RetargetLegs.js.map +1 -1
- package/dist/unstable/Spine.d.ts +53 -7
- package/dist/unstable/Spine.d.ts.map +1 -1
- package/dist/unstable/Spine.js +190 -40
- package/dist/unstable/Spine.js.map +1 -1
- package/dist/unstable/VariantTarget.d.ts +25 -3
- package/dist/unstable/VariantTarget.d.ts.map +1 -1
- package/dist/unstable/VariantTarget.js +66 -13
- package/dist/unstable/VariantTarget.js.map +1 -1
- package/dist/unstable/VariantTree.d.ts +37 -3
- package/dist/unstable/VariantTree.d.ts.map +1 -1
- package/dist/unstable/VariantTree.js +54 -7
- package/dist/unstable/VariantTree.js.map +1 -1
- package/package.json +1 -1
- package/src/BaseValue.ts +2 -2
- package/src/Batch.ts +167 -17
- package/src/Clock.ts +20 -0
- package/src/DragRecognizer.ts +82 -30
- package/src/Frame.ts +1 -1
- package/src/InputFeed.ts +37 -40
- package/src/LiveValue.ts +140 -14
- package/src/Machine.ts +67 -34
- package/src/Playback.ts +10 -8
- package/src/Recognizer.ts +9 -3
- package/src/internal/frameLoop.ts +165 -19
- package/src/internal/guarded.ts +69 -0
- package/src/internal/stepper.ts +14 -5
- package/src/unstable/AnimationControls.ts +49 -21
- package/src/unstable/AppearHandoff.ts +7 -0
- package/src/unstable/Config.ts +7 -1
- package/src/unstable/FlushGate.ts +169 -37
- package/src/unstable/FrameEffects.ts +15 -2
- package/src/unstable/Imperative.ts +219 -48
- package/src/unstable/MeasuredPairs.ts +7 -1
- package/src/unstable/PresenceRecord.ts +4 -0
- package/src/unstable/Report.ts +19 -1
- package/src/unstable/RetargetLegs.ts +14 -0
- package/src/unstable/Spine.ts +235 -40
- package/src/unstable/VariantTarget.ts +93 -14
- package/src/unstable/VariantTree.ts +87 -6
|
@@ -48,6 +48,11 @@ export interface Target {
|
|
|
48
48
|
* none.
|
|
49
49
|
*/
|
|
50
50
|
readonly keyframes: Keyframes | undefined
|
|
51
|
+
/**
|
|
52
|
+
* A resolver it called that threw, and its variant's name (#979): it resolved to nothing in its place.
|
|
53
|
+
* None when every resolver it called returned.
|
|
54
|
+
*/
|
|
55
|
+
readonly failure: Option.Option<VariantFailure>
|
|
51
56
|
}
|
|
52
57
|
|
|
53
58
|
/** A target's **Keyframes** (#429): each such key's stops. */
|
|
@@ -99,14 +104,34 @@ type Definition = Config.WardicVariant | Config.WardicVariantResolver | string |
|
|
|
99
104
|
const velocitiesOf = (state: VariantState): Readonly<Record<string, number>> =>
|
|
100
105
|
UndefinedOr.match(state.velocitiesNow, { onUndefined: () => state.velocities, onDefined: (now) => now(state) })
|
|
101
106
|
|
|
102
|
-
/** A resolver
|
|
103
|
-
|
|
104
|
-
|
|
107
|
+
/** A resolver's throw, handed on in place of a definition: the one value, its throw in {@link thrown}. */
|
|
108
|
+
// #979 (ADR-0074): every resolver runs in `calledOf`, so its throw is caught once, for every binding.
|
|
109
|
+
// One value, told apart by identity: every target passes the check, and a property check (`in`, a
|
|
110
|
+
// symbol a values map never has) cost a resolution 4–5% in Maglev (bench:solid's mount).
|
|
111
|
+
const FAILED: { readonly failed: true } = { failed: true }
|
|
112
|
+
type Failed = typeof FAILED
|
|
113
|
+
|
|
114
|
+
/** What the resolver behind the last {@link FAILED} threw: set by `calledOf` and read by `resolveOne` at once, with no app code between. */
|
|
115
|
+
// Module state (#979, bench:solid's mount): one throw at a time, handed from `calledOf` to `resolveOne` in one
|
|
116
|
+
// synchronous step and cleared there, so `FAILED` stays one value told apart by identity.
|
|
117
|
+
let thrown: unknown = undefined
|
|
118
|
+
|
|
119
|
+
/** A resolver called with what it reads, as Motion calls it, its throw handed on as {@link FAILED}; anything else as it is. */
|
|
120
|
+
// #979, Q4: a bare `try`, measured within 2% of the call alone; `Result.try` cost 21–35% more a call.
|
|
121
|
+
const calledOf = (definition: Definition | Failed, custom: unknown, state: VariantState): Definition | Failed => {
|
|
122
|
+
if (Predicate.isFunction(definition)) {
|
|
123
|
+
try {
|
|
124
|
+
return definition(custom, { ...state.values }, { ...velocitiesOf(state) })
|
|
125
|
+
} catch (defect) {
|
|
126
|
+
thrown = defect
|
|
127
|
+
return FAILED
|
|
128
|
+
}
|
|
129
|
+
}
|
|
105
130
|
return definition
|
|
106
131
|
}
|
|
107
132
|
|
|
108
133
|
/** A name looked up in `variants`; anything else as it is. */
|
|
109
|
-
const namedOf = (definition: Definition, variants: Config.WardicVariants | undefined): Definition => {
|
|
134
|
+
const namedOf = (definition: Definition | Failed, variants: Config.WardicVariants | undefined): Definition | Failed => {
|
|
110
135
|
if (Bool.not(Predicate.isString(definition))) return definition
|
|
111
136
|
if (Predicate.isUndefined(variants)) return undefined
|
|
112
137
|
return variants[definition as string]
|
|
@@ -134,7 +159,20 @@ export const resolveTargets = (entry: Entry, variants: Config.WardicVariants | u
|
|
|
134
159
|
return Arr.map(entry as ReadonlyArray<string>, (name): NamedTarget => ({ ...resolveOne(name, variants, custom, state), name }))
|
|
135
160
|
}
|
|
136
161
|
const one = entry as Config.WardicVariant | string | undefined
|
|
137
|
-
return [{ ...resolveOne(one, variants, custom, state), name:
|
|
162
|
+
return [{ ...resolveOne(one, variants, custom, state), name: nameOfEntry(one) }]
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** An entry's name: the entry itself, when it's one. */
|
|
166
|
+
// Per Retarget, per element (#460, compose once): statements.
|
|
167
|
+
const nameOfEntry = (entry: Config.WardicVariant | string | undefined): string | undefined => {
|
|
168
|
+
if (Predicate.isString(entry)) return entry
|
|
169
|
+
return undefined
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** The first of two failures: what a merge keeps. */
|
|
173
|
+
const firstFailure = (before: Option.Option<VariantFailure>, after: Option.Option<VariantFailure>): Option.Option<VariantFailure> => {
|
|
174
|
+
if (Option.isSome(before)) return before
|
|
175
|
+
return after
|
|
138
176
|
}
|
|
139
177
|
|
|
140
178
|
/**
|
|
@@ -155,6 +193,8 @@ export const mergedOf = (targets: ReadonlyArray<Target>): Target =>
|
|
|
155
193
|
onUndefined: () => merged.transitionEnd,
|
|
156
194
|
onDefined: (own) => UndefinedOr.match(merged.transitionEnd, { onUndefined: () => own, onDefined: (before) => ({ ...before, ...own }) }),
|
|
157
195
|
}),
|
|
196
|
+
// The first name's whose resolver threw (#979).
|
|
197
|
+
failure: firstFailure(merged.failure, target.failure),
|
|
158
198
|
}))
|
|
159
199
|
|
|
160
200
|
/**
|
|
@@ -168,12 +208,21 @@ const keyframesOver = (target: Target, before: Keyframes | undefined): Keyframes
|
|
|
168
208
|
return Bool.match(Rec.isEmptyRecord(over), { onTrue: () => undefined, onFalse: () => over })
|
|
169
209
|
}
|
|
170
210
|
|
|
211
|
+
/** No failure: one value, as every target that resolves carries it (#979, bench:solid's mount). */
|
|
212
|
+
export const NO_FAILURE: Option.Option<VariantFailure> = Option.none()
|
|
213
|
+
|
|
171
214
|
/** Nothing resolved. */
|
|
172
|
-
export const NO_TARGET: Target = { values: {}, transition: undefined, transitionEnd: undefined, keyframes: undefined }
|
|
215
|
+
export const NO_TARGET: Target = { values: {}, transition: undefined, transitionEnd: undefined, keyframes: undefined, failure: NO_FAILURE }
|
|
173
216
|
|
|
174
217
|
/** One name or values map resolved ({@link resolveTarget}). */
|
|
175
218
|
const resolveOne = (entry: Config.WardicVariant | string | undefined, variants: Config.WardicVariants | undefined, custom: unknown, state: VariantState): Target => {
|
|
176
219
|
const definition = calledOf(namedOf(calledOf(namedOf(entry, variants), custom, state), variants), custom, state)
|
|
220
|
+
// A resolver that threw resolves to nothing, carrying what it threw and the name it was reached by (#979).
|
|
221
|
+
if (definition === FAILED) {
|
|
222
|
+
const defect = thrown
|
|
223
|
+
thrown = undefined
|
|
224
|
+
return { ...NO_TARGET, failure: Option.some({ defect, name: nameOfEntry(entry) }) }
|
|
225
|
+
}
|
|
177
226
|
if (Bool.or(Predicate.isUndefined(definition), Bool.or(Predicate.isString(definition), Predicate.isFunction(definition)))) {
|
|
178
227
|
return NO_TARGET
|
|
179
228
|
}
|
|
@@ -185,11 +234,11 @@ const resolveOne = (entry: Config.WardicVariant | string | undefined, variants:
|
|
|
185
234
|
// pass over its keys (#452).
|
|
186
235
|
if (Bool.not(Predicate.isObject(target.transition))) {
|
|
187
236
|
const split = Stops.splitValues(target, "last")
|
|
188
|
-
return { values: split.values, transition: undefined, transitionEnd, keyframes: Option.getOrUndefined(split.keyframes) }
|
|
237
|
+
return { values: split.values, transition: undefined, transitionEnd, keyframes: Option.getOrUndefined(split.keyframes), failure: NO_FAILURE }
|
|
189
238
|
}
|
|
190
239
|
const { transition, ...values } = target
|
|
191
240
|
const split = Stops.splitValues(values, "last")
|
|
192
|
-
return { values: split.values, transition: transition as Config.WardicVariantTransition, transitionEnd, keyframes: Option.getOrUndefined(split.keyframes) }
|
|
241
|
+
return { values: split.values, transition: transition as Config.WardicVariantTransition, transitionEnd, keyframes: Option.getOrUndefined(split.keyframes), failure: NO_FAILURE }
|
|
193
242
|
}
|
|
194
243
|
|
|
195
244
|
/** A target's Transition end (#428), clean for core: none for anything but a values map, or an empty one. */
|
|
@@ -215,32 +264,62 @@ export const transitionOfTarget = (own: Config.WardicVariantTransition | undefin
|
|
|
215
264
|
return rest as Config.WardicTransition
|
|
216
265
|
}
|
|
217
266
|
|
|
267
|
+
/** A target's values, and its failure: what {@link startingVariantsOf} reads of each. */
|
|
268
|
+
const valuesOfTarget = (target: Target): Values.Values => target.values
|
|
269
|
+
const failureOfTarget = (target: Target): Option.Option<VariantFailure> => target.failure
|
|
270
|
+
|
|
271
|
+
/** A variant's resolver that threw (#979): what it threw, and the variant's name where it has one. */
|
|
272
|
+
export interface VariantFailure {
|
|
273
|
+
readonly defect: unknown
|
|
274
|
+
readonly name: string | undefined
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** `variants` as the Starting style reads them, and the first of them whose resolver threw. */
|
|
278
|
+
export interface StartingVariants {
|
|
279
|
+
readonly variants: object | undefined
|
|
280
|
+
readonly failure: Option.Option<VariantFailure>
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** No variants: one value, as most elements have none (#979, bench:solid's mount). */
|
|
284
|
+
const NO_STARTING_VARIANTS: StartingVariants = { variants: undefined, failure: NO_FAILURE }
|
|
285
|
+
|
|
218
286
|
/**
|
|
219
287
|
* `variants` with each entry resolved to its values, a dynamic one with `custom` and no values yet
|
|
220
288
|
* (#277): what dom's Starting style reads, which takes values maps only. As they are when none is a
|
|
221
|
-
* function.
|
|
289
|
+
* function. A resolver that throws gives its entry no values, and its throw is the failure.
|
|
222
290
|
*/
|
|
223
|
-
export const startingVariantsOf = (variants: object | undefined, custom: unknown):
|
|
224
|
-
if (Predicate.isUndefined(variants)) return
|
|
291
|
+
export const startingVariantsOf = (variants: object | undefined, custom: unknown): StartingVariants => {
|
|
292
|
+
if (Predicate.isUndefined(variants)) return NO_STARTING_VARIANTS
|
|
225
293
|
const entries = variants as Config.WardicVariants
|
|
226
|
-
if (Bool.not(Arr.some(Rec.values(entries), Predicate.isFunction))) return variants
|
|
227
|
-
|
|
294
|
+
if (Bool.not(Arr.some(Rec.values(entries), Predicate.isFunction))) return { variants, failure: NO_FAILURE }
|
|
295
|
+
// Once an element's setup (#979): each entry resolved, a throwing resolver's left with no values.
|
|
296
|
+
const targets = Rec.map(entries, (_, name) => resolveTarget(name, entries, custom, NO_VARIANT_STATE))
|
|
297
|
+
return { variants: Rec.map(targets, valuesOfTarget), failure: Option.firstSomeOf(Arr.map(Rec.values(targets), failureOfTarget)) }
|
|
228
298
|
}
|
|
229
299
|
|
|
300
|
+
/** What orchestration's resolution of a variant name, `entry`, came to: its failure, or none once it resolves. */
|
|
301
|
+
export type Orchestrated = (entry: Config.WardicVariantLabels, failure: Option.Option<VariantFailure>) => void
|
|
302
|
+
|
|
230
303
|
/**
|
|
231
304
|
* The own transition of an element's target now (#277): its `animate` map's, else the variant it
|
|
232
305
|
* names or inherits (`name`), resolved with `custom` and no values. What its orchestration reads.
|
|
306
|
+
* `orchestrated` is told what a name's resolution came to: a resolver that throws gives no own
|
|
307
|
+
* transition.
|
|
233
308
|
*/
|
|
234
309
|
export const ownTransitionOf = (
|
|
235
310
|
animate: object | Config.WardicVariantLabels | undefined,
|
|
236
311
|
name: Config.WardicVariantLabels | undefined,
|
|
237
312
|
variants: object | undefined,
|
|
238
313
|
custom: unknown,
|
|
314
|
+
orchestrated?: Orchestrated,
|
|
239
315
|
): Config.WardicVariantTransition | undefined => {
|
|
240
316
|
const byName = variants as Config.WardicVariants | undefined
|
|
241
317
|
if (Bool.and(Predicate.isNotUndefined(animate), Bool.not(isLabels(animate)))) {
|
|
242
318
|
return resolveTarget(animate as Config.WardicVariant, byName, custom, NO_VARIANT_STATE).transition
|
|
243
319
|
}
|
|
244
320
|
if (Predicate.isUndefined(name)) return undefined
|
|
245
|
-
|
|
321
|
+
const target = resolveTarget(name, byName, custom, NO_VARIANT_STATE)
|
|
322
|
+
// #979 (Q6): a throw here is reported through the element's own once, its resolution's apart.
|
|
323
|
+
if (Predicate.isNotUndefined(orchestrated)) orchestrated(name, target.failure)
|
|
324
|
+
return target.transition
|
|
246
325
|
}
|
|
@@ -25,10 +25,15 @@
|
|
|
25
25
|
// element's place in variant orchestration in core.
|
|
26
26
|
import * as Stagger from "../Stagger.ts"
|
|
27
27
|
import type * as Values from "../Values.ts"
|
|
28
|
+
import * as Report from "./Report.ts"
|
|
28
29
|
import * as Stops from "./Stops.ts"
|
|
30
|
+
import type * as WardicServices from "./WardicServices.ts"
|
|
29
31
|
import * as Arr from "effect/Array"
|
|
30
32
|
import * as Bool from "effect/Boolean"
|
|
33
|
+
import * as Cause from "effect/Cause"
|
|
34
|
+
import * as Effect from "effect/Effect"
|
|
31
35
|
import { constTrue, constUndefined, identity } from "effect/Function"
|
|
36
|
+
import type * as Option from "effect/Option"
|
|
32
37
|
import * as Predicate from "effect/Predicate"
|
|
33
38
|
import * as UndefinedOr from "effect/UndefinedOr"
|
|
34
39
|
import * as AnimationControls from "./AnimationControls.ts"
|
|
@@ -480,6 +485,12 @@ export const startsQuiet = (
|
|
|
480
485
|
return VariantTarget.sameLabels(initial as Config.WardicVariantLabels, animateOf(config, inherited, untrack) as Config.WardicVariantLabels)
|
|
481
486
|
}
|
|
482
487
|
|
|
488
|
+
/** What an element starts from, and the first of its variants whose resolver threw (#979). */
|
|
489
|
+
export interface Starting {
|
|
490
|
+
readonly values: Values.Values
|
|
491
|
+
readonly failure: Option.Option<VariantTarget.VariantFailure>
|
|
492
|
+
}
|
|
493
|
+
|
|
483
494
|
/**
|
|
484
495
|
* The values an element starts from, its Starting style's input (ADR-0003): its `initial` (own, else
|
|
485
496
|
* inherited, #50), or, when it {@link startsAtAnimate}, its `animate` (own, else inherited), as
|
|
@@ -490,6 +501,32 @@ export const startingValuesOf = (
|
|
|
490
501
|
inherited: WardicVariantContextValue | undefined,
|
|
491
502
|
presenceBlocks: boolean,
|
|
492
503
|
untrack: Reactivity.Reactivity["untrack"],
|
|
504
|
+
): Values.Values => startingValuesFrom(config, inherited, presenceBlocks, untrack, VariantTarget.startingVariantsOf(config.variants, config.custom).variants)
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* {@link startingValuesOf}, with what a resolver among the element's variants threw: its entry gives no
|
|
508
|
+
* values, and the element starts at the rest (#979).
|
|
509
|
+
*/
|
|
510
|
+
export const startingOf = (
|
|
511
|
+
config: VariantConfig,
|
|
512
|
+
inherited: WardicVariantContextValue | undefined,
|
|
513
|
+
presenceBlocks: boolean,
|
|
514
|
+
untrack: Reactivity.Reactivity["untrack"],
|
|
515
|
+
): Starting => {
|
|
516
|
+
const variants = VariantTarget.startingVariantsOf(config.variants, config.custom)
|
|
517
|
+
return { values: startingValuesFrom(config, inherited, presenceBlocks, untrack, variants.variants), failure: variants.failure }
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* {@link startingValuesOf} from its variants already resolved to values (`VariantTarget.startingVariantsOf`):
|
|
522
|
+
* what an element's start reads, which reads their failure too.
|
|
523
|
+
*/
|
|
524
|
+
export const startingValuesFrom = (
|
|
525
|
+
config: VariantConfig,
|
|
526
|
+
inherited: WardicVariantContextValue | undefined,
|
|
527
|
+
presenceBlocks: boolean,
|
|
528
|
+
untrack: Reactivity.Reactivity["untrack"],
|
|
529
|
+
variants: object | undefined,
|
|
493
530
|
): Values.Values => {
|
|
494
531
|
const atAnimate = startsAtAnimate(config, inherited, presenceBlocks)
|
|
495
532
|
const animate = animateOf(config, inherited, untrack)
|
|
@@ -502,11 +539,11 @@ export const startingValuesOf = (
|
|
|
502
539
|
from = false
|
|
503
540
|
first = animate
|
|
504
541
|
}
|
|
542
|
+
// Dynamic variants resolved first (#277): `@wardic/dom`'s Starting style reads values maps only.
|
|
505
543
|
const values = Stops.resolveInitial({
|
|
506
544
|
initial: from,
|
|
507
545
|
animate,
|
|
508
|
-
|
|
509
|
-
variants: VariantTarget.startingVariantsOf(config.variants, config.custom) as Readonly<Record<string, object | undefined>> | undefined,
|
|
546
|
+
variants: variants as Readonly<Record<string, object | undefined>> | undefined,
|
|
510
547
|
})
|
|
511
548
|
// The first target's Transition end (#428, Motion's `makeLatestValues`): set at once, so a server
|
|
512
549
|
// renders it, and a hydration finds it.
|
|
@@ -554,17 +591,61 @@ export const directed = (index: number, total: number, direction: 1 | -1): numbe
|
|
|
554
591
|
return index
|
|
555
592
|
}
|
|
556
593
|
|
|
594
|
+
/**
|
|
595
|
+
* Where a stagger reports a `delayChildren` function that throws: the runtime it's reported on, and whether
|
|
596
|
+
* it's failing, so a run of throws is reported once. A Variant child's is its element's, for its life, its
|
|
597
|
+
* run ended by its next clean call. A presence's exit and a server's Appear timing make one for the event,
|
|
598
|
+
* `event`, whose first throw is reported whatever its other calls do.
|
|
599
|
+
*/
|
|
600
|
+
export interface DelayFailures {
|
|
601
|
+
delayFailing: boolean
|
|
602
|
+
readonly runtime: Pick<WardicServices.Runner<never>, "runFork">
|
|
603
|
+
readonly event?: true
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/** The runtime a server render reports on: Effect's default, as a server holds no app reporters. */
|
|
607
|
+
export const ON_SERVER: Pick<WardicServices.Runner<never>, "runFork"> = { runFork: (effect) => Effect.runFork(effect) }
|
|
608
|
+
|
|
609
|
+
/** One exit's or one render's {@link DelayFailures}, reported on `runtime` at its first throw. */
|
|
610
|
+
export const eventDelayFailuresOf = (runtime: Pick<WardicServices.Runner<never>, "runFork">): DelayFailures => ({ delayFailing: false, runtime, event: true })
|
|
611
|
+
|
|
557
612
|
/**
|
|
558
613
|
* A child's delay in a stagger (ADR-0007): its `delayChildren` plus its place from the origin, turned
|
|
559
614
|
* by its `staggerDirection`. A function `delayChildren` (#436, Motion's `calcChildStagger`) decides it
|
|
560
|
-
* whole, from the child's index and the count
|
|
561
|
-
*
|
|
615
|
+
* whole, from the child's index and the count; one that throws gives the child no delay, reported on
|
|
616
|
+
* `failures` (on Effect's default runtime with none) at the first throw of a run of them. Every stagger,
|
|
617
|
+
* a Variant child's, a presence's exit's and a server's Appear timing, is placed by it.
|
|
562
618
|
*/
|
|
563
|
-
export const childDelayOf = (s: WardicStaggerConfig, index: number, total: number): number => {
|
|
564
|
-
if (Predicate.isFunction(s.delayChildren)) return s.delayChildren
|
|
619
|
+
export const childDelayOf = (s: WardicStaggerConfig, index: number, total: number, failures: DelayFailures | undefined): number => {
|
|
620
|
+
if (Predicate.isFunction(s.delayChildren)) return calledDelayOf(s.delayChildren, index, total, failures)
|
|
565
621
|
return s.delayChildren + Stagger.make(s.amount, { from: s.from })(directed(index, total, s.direction), total)
|
|
566
622
|
}
|
|
567
623
|
|
|
624
|
+
// #979 (ADR-0074, row 43, found by group H's probe): a `delayChildren` function is the app's, called at each
|
|
625
|
+
// child's Retarget, exit and Appear timing with no try. A throw halted Solid 2, came out of Solid 1's
|
|
626
|
+
// setter, and skipped Foldkit's later watches at a patch.
|
|
627
|
+
const DELAY_FAILED = "wardic.stagger: a delayChildren function failed"
|
|
628
|
+
|
|
629
|
+
/** `delayChildren` called for a child, a throw its child's: no delay, reported once a run on `failures`. */
|
|
630
|
+
// A child's run is its element's, whatever name it's staggered under: a parent's own transition staggers
|
|
631
|
+
// every name with one function, so a run kept by name would report it again for each. (The review's: a
|
|
632
|
+
// child staggered under two names at once, one function throwing and one not, is reported at each change.)
|
|
633
|
+
const calledDelayOf = (delayChildren: Config.WardicStagger, index: number, total: number, failures: DelayFailures | undefined): number => {
|
|
634
|
+
try {
|
|
635
|
+
const delay = delayChildren(index, total)
|
|
636
|
+
if (Predicate.isNotUndefined(failures) && failures.delayFailing && failures.event !== true) failures.delayFailing = false
|
|
637
|
+
return delay
|
|
638
|
+
} catch (defect) {
|
|
639
|
+
if (Predicate.isUndefined(failures)) {
|
|
640
|
+
Report.failureOn(undefined, DELAY_FAILED, Cause.die(defect), { index })
|
|
641
|
+
return 0
|
|
642
|
+
}
|
|
643
|
+
if (!failures.delayFailing) failures.runtime.runFork(Report.failure(DELAY_FAILED, Cause.die(defect)).pipe(Effect.annotateLogs({ index })))
|
|
644
|
+
failures.delayFailing = true
|
|
645
|
+
return 0
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
|
|
568
649
|
/** A name's orchestration (#297): its stagger config, and its own `when`, from its own transition, else the element's. */
|
|
569
650
|
export interface NameConfig {
|
|
570
651
|
readonly stagger: WardicStaggerConfig
|