@wardic/dom 1.3.1 → 1.4.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/MeasuredPair.d.ts +14 -1
- package/dist/MeasuredPair.d.ts.map +1 -1
- package/dist/MeasuredPair.js +11 -13
- package/dist/MeasuredPair.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/internal/appear.d.ts +6 -0
- package/dist/internal/appear.d.ts.map +1 -1
- package/dist/internal/appear.js +20 -2
- package/dist/internal/appear.js.map +1 -1
- package/dist/internal/batch-handoff.d.ts.map +1 -1
- package/dist/internal/batch-handoff.js +25 -15
- package/dist/internal/batch-handoff.js.map +1 -1
- package/dist/internal/batch-writer.d.ts +1 -1
- package/dist/internal/batch-writer.d.ts.map +1 -1
- package/dist/internal/batch-writer.js +32 -16
- package/dist/internal/batch-writer.js.map +1 -1
- package/dist/internal/clock.d.ts +6 -0
- package/dist/internal/clock.d.ts.map +1 -1
- package/dist/internal/clock.js +27 -0
- package/dist/internal/clock.js.map +1 -1
- package/dist/internal/default-transition.d.ts +3 -2
- package/dist/internal/default-transition.d.ts.map +1 -1
- package/dist/internal/default-transition.js +28 -3
- package/dist/internal/default-transition.js.map +1 -1
- package/dist/internal/failing.d.ts +9 -0
- package/dist/internal/failing.d.ts.map +1 -0
- package/dist/internal/failing.js +33 -0
- package/dist/internal/failing.js.map +1 -0
- package/dist/internal/length-keys.d.ts +19 -0
- package/dist/internal/length-keys.d.ts.map +1 -0
- package/dist/internal/length-keys.js +77 -0
- package/dist/internal/length-keys.js.map +1 -0
- package/dist/internal/measured-pairs.d.ts +3 -2
- package/dist/internal/measured-pairs.d.ts.map +1 -1
- package/dist/internal/measured-pairs.js +60 -23
- package/dist/internal/measured-pairs.js.map +1 -1
- package/dist/internal/own-values.d.ts.map +1 -1
- package/dist/internal/own-values.js +2 -2
- package/dist/internal/own-values.js.map +1 -1
- package/dist/internal/positional-keys.d.ts +1 -1
- package/dist/internal/positional-keys.d.ts.map +1 -1
- package/dist/internal/positional-keys.js +4 -2
- package/dist/internal/positional-keys.js.map +1 -1
- package/dist/internal/projection.d.ts.map +1 -1
- package/dist/internal/projection.js +180 -46
- package/dist/internal/projection.js.map +1 -1
- package/dist/internal/renderer.d.ts +59 -27
- package/dist/internal/renderer.d.ts.map +1 -1
- package/dist/internal/renderer.js +241 -207
- package/dist/internal/renderer.js.map +1 -1
- package/dist/internal/scroll.d.ts.map +1 -1
- package/dist/internal/scroll.js +26 -2
- package/dist/internal/scroll.js.map +1 -1
- package/dist/internal/starting-style.js +5 -5
- package/dist/internal/transform-keys.d.ts +23 -0
- package/dist/internal/transform-keys.d.ts.map +1 -0
- package/dist/internal/transform-keys.js +55 -0
- package/dist/internal/transform-keys.js.map +1 -0
- package/dist/unstable/AppearAnimations.d.ts +2 -1
- package/dist/unstable/AppearAnimations.d.ts.map +1 -1
- package/dist/unstable/AppearAnimations.js +73 -22
- package/dist/unstable/AppearAnimations.js.map +1 -1
- package/dist/unstable/BatchMembers.d.ts +2 -2
- package/dist/unstable/BatchMembers.d.ts.map +1 -1
- package/dist/unstable/BatchMembers.js +30 -7
- package/dist/unstable/BatchMembers.js.map +1 -1
- package/dist/unstable/DomValues.js +1 -1
- package/dist/unstable/DomValues.js.map +1 -1
- package/dist/unstable/DragTrack.d.ts +2 -2
- package/dist/unstable/DragTrack.d.ts.map +1 -1
- package/dist/unstable/DragTrack.js +37 -10
- package/dist/unstable/DragTrack.js.map +1 -1
- package/dist/unstable/ElementSetup.d.ts.map +1 -1
- package/dist/unstable/ElementSetup.js +3 -2
- package/dist/unstable/ElementSetup.js.map +1 -1
- package/dist/unstable/GestureFeatures.d.ts +8 -2
- package/dist/unstable/GestureFeatures.d.ts.map +1 -1
- package/dist/unstable/GestureFeatures.js +26 -40
- package/dist/unstable/GestureFeatures.js.map +1 -1
- package/dist/unstable/GestureInfo.d.ts +11 -0
- package/dist/unstable/GestureInfo.d.ts.map +1 -1
- package/dist/unstable/GestureInfo.js +8 -0
- package/dist/unstable/GestureInfo.js.map +1 -1
- package/dist/unstable/Imperative.d.ts +1 -1
- package/dist/unstable/Imperative.d.ts.map +1 -1
- package/dist/unstable/Imperative.js.map +1 -1
- package/dist/unstable/LiveStyle.d.ts +28 -2
- package/dist/unstable/LiveStyle.d.ts.map +1 -1
- package/dist/unstable/LiveStyle.js +8 -32
- package/dist/unstable/LiveStyle.js.map +1 -1
- package/dist/unstable/MemberHold.js +3 -3
- package/dist/unstable/MemberHold.js.map +1 -1
- package/dist/unstable/PointerValues.d.ts.map +1 -1
- package/dist/unstable/PointerValues.js +82 -8
- package/dist/unstable/PointerValues.js.map +1 -1
- package/dist/unstable/PresenceController.d.ts +5 -2
- package/dist/unstable/PresenceController.d.ts.map +1 -1
- package/dist/unstable/PresenceController.js +82 -55
- package/dist/unstable/PresenceController.js.map +1 -1
- package/dist/unstable/ReorderInput.d.ts +2 -2
- package/dist/unstable/ReorderInput.js +2 -2
- package/dist/unstable/WardConfig.d.ts +18 -9
- package/dist/unstable/WardConfig.d.ts.map +1 -1
- package/dist/unstable/WardConfig.js.map +1 -1
- package/dist/unstable/features/TimelineKeys.d.ts.map +1 -1
- package/dist/unstable/features/TimelineKeys.js +19 -3
- package/dist/unstable/features/TimelineKeys.js.map +1 -1
- package/package.json +3 -3
- package/src/MeasuredPair.ts +21 -1
- package/src/index.ts +4 -1
- package/src/internal/appear.ts +20 -2
- package/src/internal/batch-handoff.ts +19 -11
- package/src/internal/batch-writer.ts +32 -16
- package/src/internal/clock.ts +28 -0
- package/src/internal/default-transition.ts +28 -4
- package/src/internal/failing.ts +37 -0
- package/src/internal/length-keys.ts +80 -0
- package/src/internal/measured-pairs.ts +58 -22
- package/src/internal/own-values.ts +2 -2
- package/src/internal/positional-keys.ts +4 -2
- package/src/internal/projection.ts +190 -44
- package/src/internal/renderer.ts +272 -198
- package/src/internal/scroll.ts +24 -2
- package/src/internal/starting-style.ts +5 -5
- package/src/internal/transform-keys.ts +59 -0
- package/src/unstable/AppearAnimations.ts +73 -24
- package/src/unstable/BatchMembers.ts +33 -9
- package/src/unstable/DomValues.ts +1 -1
- package/src/unstable/DragTrack.ts +49 -14
- package/src/unstable/ElementSetup.ts +3 -2
- package/src/unstable/GestureFeatures.ts +38 -47
- package/src/unstable/GestureInfo.ts +24 -0
- package/src/unstable/Imperative.ts +1 -0
- package/src/unstable/LiveStyle.ts +12 -8
- package/src/unstable/MemberHold.ts +3 -3
- package/src/unstable/PointerValues.ts +73 -8
- package/src/unstable/PresenceController.ts +80 -54
- package/src/unstable/ReorderInput.ts +2 -2
- package/src/unstable/WardConfig.ts +22 -10
- package/src/unstable/features/TimelineKeys.ts +20 -3
|
@@ -57,6 +57,7 @@ import type * as WardConfig from "./WardConfig.ts"
|
|
|
57
57
|
import type * as CorePresenceRecord from "@wardic/core/unstable/PresenceRecord"
|
|
58
58
|
import * as RetargetLegs from "@wardic/core/unstable/RetargetLegs"
|
|
59
59
|
import type * as WardicServices from "@wardic/core/unstable/WardicServices"
|
|
60
|
+
import * as Spine from "@wardic/core/unstable/Spine"
|
|
60
61
|
import * as VariantTree from "@wardic/core/unstable/VariantTree"
|
|
61
62
|
|
|
62
63
|
// #672 (PR5-Q3): the DOM's presence types, core's protocol over Element, here with the DOM's presence:
|
|
@@ -236,12 +237,13 @@ interface PreparedExit {
|
|
|
236
237
|
/**
|
|
237
238
|
* An exit's Measured pairs (#430): each key whose start and target differ in type, asked of the
|
|
238
239
|
* end-of-task batch, but a key with Keyframes of more than two stops (`stops`, #460). `undefined` with
|
|
239
|
-
* none, nearly every exit.
|
|
240
|
+
* none, nearly every exit. `failed` is told when the batch can't take them (a Transform template
|
|
241
|
+
* that throws): they switch, as pairs it couldn't read do.
|
|
240
242
|
*/
|
|
241
|
-
const exitMeasuredOf = (element: Element, from: Values.Values, to: Values.Values, stops: RetargetLegs.StopsByKey | undefined): RetargetLegs.MeasuredPairs | undefined => {
|
|
243
|
+
const exitMeasuredOf = (element: Element, from: Values.Values, to: Values.Values, stops: RetargetLegs.StopsByKey | undefined, failed: (defect: unknown) => void): RetargetLegs.MeasuredPairs | undefined => {
|
|
242
244
|
const pairs = Rec.filter(to, (target, key) => Bool.and(Bool.and(Object.hasOwn(from, key), Bool.not(RetargetLegs.hasManyStops(stops, key))), keepsMeasured(key, from[key], target)))
|
|
243
245
|
if (Rec.isEmptyRecord(pairs)) return undefined
|
|
244
|
-
return DomValues.measuredPairs.measure(castForDom(element), Rec.map(pairs, (target, key) => ({ from: UndefinedOr.getOrThrow(from[key]), to: target })), from)
|
|
246
|
+
return DomValues.measuredPairs.measure(castForDom(element), Rec.map(pairs, (target, key) => ({ from: UndefinedOr.getOrThrow(from[key]), to: target })), from, failed)
|
|
245
247
|
}
|
|
246
248
|
|
|
247
249
|
/** Whether a start and a target make a Measured pair (#430). */
|
|
@@ -618,8 +620,11 @@ export interface PresenceOptions {
|
|
|
618
620
|
readonly presenceAffectsLayout?: (() => boolean | undefined) | undefined
|
|
619
621
|
/**
|
|
620
622
|
* The children `mode="wait"` held may go on the page now: the binding renders its children again,
|
|
621
|
-
* through {@link PresenceController.shown}. Left out, a held child stays held.
|
|
623
|
+
* through {@link PresenceController.shown}. Left out, a held child stays held. It can be called inside
|
|
624
|
+
* {@link PresenceController.present}: a leaver with nothing to play goes at once there, so a binding
|
|
625
|
+
* that can't render again inside its own update defers it.
|
|
622
626
|
*/
|
|
627
|
+
// #987 (ADR-0048, *Amendment (#987)*): Solid 2's binding defers a release made there a microtask; Foldkit's defers every one.
|
|
623
628
|
readonly release?: (() => void) | undefined
|
|
624
629
|
}
|
|
625
630
|
|
|
@@ -682,21 +687,29 @@ export interface PresenceController {
|
|
|
682
687
|
|
|
683
688
|
/**
|
|
684
689
|
* {@link PresenceEvents} as Motion's (#257, Solid 1's): only its `onExitComplete`, read when it's called. One
|
|
685
|
-
* that throws is reported (`wardic.presence: onExitComplete failed`)
|
|
690
|
+
* that throws is reported (`wardic.presence: onExitComplete failed`) at the first of a run of throws, its
|
|
691
|
+
* next clean call ending the run, and the presence goes on.
|
|
686
692
|
*/
|
|
687
|
-
export const exitCompleteEvents = (runtime: WardicServices.Runner<WardicServices.WardicServices>, onExitComplete: () => (() => void) | undefined): PresenceEvents =>
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
callback()
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
})
|
|
693
|
+
export const exitCompleteEvents = (runtime: WardicServices.Runner<WardicServices.WardicServices>, onExitComplete: () => (() => void) | undefined): PresenceEvents => {
|
|
694
|
+
// #979 group I, row 29 (ADR-0074 decision 3): called at each exit's end, so a run is its throws there.
|
|
695
|
+
let failing = false
|
|
696
|
+
return {
|
|
697
|
+
exitStart: constVoid,
|
|
698
|
+
exiting: constVoid,
|
|
699
|
+
exitComplete: () => {
|
|
700
|
+
const callback = onExitComplete()
|
|
701
|
+
if (Predicate.isUndefined(callback)) return
|
|
702
|
+
try {
|
|
703
|
+
callback()
|
|
704
|
+
if (failing) failing = false
|
|
705
|
+
} catch (defect) {
|
|
706
|
+
if (failing) return
|
|
707
|
+
failing = true
|
|
708
|
+
runtime.runFork(Report.failure("wardic.presence: onExitComplete failed", Cause.die(defect)))
|
|
709
|
+
}
|
|
710
|
+
},
|
|
711
|
+
}
|
|
712
|
+
}
|
|
700
713
|
|
|
701
714
|
/** A projection method that takes an HTML element first, taking any element. */
|
|
702
715
|
type TakingAnyElement<F> = F extends (...args: infer P) => infer A ? P extends [HTMLElement, ...infer R] ? (el: Element, ...rest: R) => A : F : F
|
|
@@ -743,6 +756,9 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
|
|
|
743
756
|
* the wrong one — is diagnosable. The per-frame commit stays silent.
|
|
744
757
|
*/
|
|
745
758
|
const debug = Report.debugOf(runtime, "wardic.presence")
|
|
759
|
+
const exitFailed = Spine.exitVariantFailedOn(runtime)
|
|
760
|
+
// An exit's Measured pairs the batch couldn't take (its Transform template threw), reported each time (#979, row 8).
|
|
761
|
+
const exitMeasuredFailed = Spine.exitMeasuredFailedOn(runtime)
|
|
746
762
|
|
|
747
763
|
// The registry of live child records, keyed by their DOM element. Filled by
|
|
748
764
|
// register() (called from the child's spine on mount), drained as children
|
|
@@ -830,7 +846,9 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
|
|
|
830
846
|
|
|
831
847
|
/**
|
|
832
848
|
* A child's exit ended: with the last, `exiting` turns off, a completion is told, and the children
|
|
833
|
-
* `mode="wait"` held go on the page (#277), as Motion renders them after its `onExitComplete`.
|
|
849
|
+
* `mode="wait"` held go on the page (#277), as Motion renders them after its `onExitComplete`. A
|
|
850
|
+
* release that throws (a held child's start, on a binding that starts it at once) is reported, and the
|
|
851
|
+
* presence goes on.
|
|
834
852
|
*/
|
|
835
853
|
const leaveEnds = (el: Element, completed: boolean): void => {
|
|
836
854
|
if (Bool.not(leaving.delete(el))) return
|
|
@@ -841,7 +859,13 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
|
|
|
841
859
|
})
|
|
842
860
|
// `propagate` (#277's PR 5c): the last child that left lets the parent's child go.
|
|
843
861
|
allLeft()
|
|
844
|
-
if (held.length
|
|
862
|
+
if (held.length === 0) return
|
|
863
|
+
// Its own: a throw here came out of the exit's fiber unlogged, and on Solid 1 out of the release (#983).
|
|
864
|
+
try {
|
|
865
|
+
UndefinedOr.map(options.release, (release) => release())
|
|
866
|
+
} catch (defect) {
|
|
867
|
+
runtime.runFork(Report.failure(`wardic.presence: mode="wait"'s release failed`, Cause.die(defect)))
|
|
868
|
+
}
|
|
845
869
|
}
|
|
846
870
|
|
|
847
871
|
// What `leaveAll` calls once none is left (#277's PR 5c), and where its children last were.
|
|
@@ -861,9 +885,9 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
|
|
|
861
885
|
|
|
862
886
|
const ctx: PresenceContextValue = {
|
|
863
887
|
register: (rec) => {
|
|
864
|
-
registry.set(rec.
|
|
888
|
+
registry.set(rec.subject, rec)
|
|
865
889
|
return () => {
|
|
866
|
-
registry.delete(rec.
|
|
890
|
+
registry.delete(rec.subject)
|
|
867
891
|
}
|
|
868
892
|
},
|
|
869
893
|
blocksInitial: () => options.initial() === false && firstRender,
|
|
@@ -1053,9 +1077,9 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
|
|
|
1053
1077
|
*/
|
|
1054
1078
|
const driveExit = (el: Element, rec: PresenceRecord | undefined, custom: unknown): void => {
|
|
1055
1079
|
const parts = partsOf(el)
|
|
1056
|
-
exitParts.set(el, Arr.map(parts, (part) => part.
|
|
1080
|
+
exitParts.set(el, Arr.map(parts, (part) => part.subject))
|
|
1057
1081
|
const own = UndefinedOr.match(rec, { onUndefined: () => NO_OWN, onDefined: Arr.of })
|
|
1058
|
-
const byElement = new Map<Element, PresenceRecord>(Arr.map([...own, ...parts], (r) => [r.
|
|
1082
|
+
const byElement = new Map<Element, PresenceRecord>(Arr.map([...own, ...parts], (r) => [r.subject, r] as const))
|
|
1059
1083
|
// The nearest element inside the child its Variant children join: one that provides a context.
|
|
1060
1084
|
const providerOf = (node: Element | null): PresenceRecord | undefined => {
|
|
1061
1085
|
if (node === null) return undefined
|
|
@@ -1067,11 +1091,13 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
|
|
|
1067
1091
|
const joinsTo = new Map<PresenceRecord, PresenceRecord>()
|
|
1068
1092
|
Arr.forEach(parts, (part) => {
|
|
1069
1093
|
if (Bool.not(treeOf(part).joins)) return
|
|
1070
|
-
UndefinedOr.map(providerOf(part.
|
|
1094
|
+
UndefinedOr.map(providerOf(part.subject.parentElement), (provider) => joinsTo.set(part, provider))
|
|
1071
1095
|
})
|
|
1072
1096
|
const joinersOf = (provider: PresenceRecord): ReadonlyArray<PresenceRecord> => Arr.filter(parts, (part) => joinsTo.get(part) === provider)
|
|
1073
1097
|
const nodeOf = (node: PresenceRecord, inherited: WardConfig.WardicVariantLabels | undefined): ExitNode => {
|
|
1074
1098
|
const exit = node.exitOf(custom, inherited)
|
|
1099
|
+
// An exit whose resolver threw has no values: it leaves without it, reported each time (#979).
|
|
1100
|
+
if (Option.isSome(exit.failure)) exitFailed(exit.failure.value)
|
|
1075
1101
|
return { rec: node, exit, kids: Arr.map(joinersOf(node), (kid) => nodeOf(kid, exit.name)) }
|
|
1076
1102
|
}
|
|
1077
1103
|
// The child's own tree, if it's a Wardic element, and each element inside it that joins nothing
|
|
@@ -1088,7 +1114,8 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
|
|
|
1088
1114
|
// One `wardic.presence.exit` span spans the whole exit, from the leave to the last part's end.
|
|
1089
1115
|
// A failed run is logged and reported (ADR-0030, decision 4); the node is removed either way.
|
|
1090
1116
|
const fiber = runtime.runFork(
|
|
1091
|
-
|
|
1117
|
+
// Its stagger's `delayChildren` function that throws, reported once this exit (#979).
|
|
1118
|
+
Effect.all(Arr.map(roots, (root) => runOf(root, NO_DELAY, VariantTree.eventDelayFailuresOf(runtime))), { concurrency: "unbounded", discard: true }).pipe(
|
|
1092
1119
|
Effect.tapCause((cause) => Report.failure("wardic.presence: an exit failed", cause)),
|
|
1093
1120
|
Effect.ensuring(Effect.sync(() => partDone(el))),
|
|
1094
1121
|
// The app's to give, with no call-site stack (#746; ADR-0040, decision 2).
|
|
@@ -1102,25 +1129,21 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
|
|
|
1102
1129
|
* A node's exit and its Variant children's (#290), Motion's `animateVariant`: with `when`, one after
|
|
1103
1130
|
* the other, the children's delays from 0; else together, the children's from `delay`.
|
|
1104
1131
|
*/
|
|
1105
|
-
const runOf = (node: ExitNode, delay: DelayOf): Effect.Effect<unknown, never, WardicServices.WardicServices> => {
|
|
1132
|
+
const runOf = (node: ExitNode, delay: DelayOf, delays: VariantTree.DelayFailures): Effect.Effect<unknown, never, WardicServices.WardicServices> => {
|
|
1106
1133
|
// A list's names each run on their own (#297's PR 2): each name's keys and its children's, in that
|
|
1107
1134
|
// name's own `when`.
|
|
1108
1135
|
const groups = node.exit.groups
|
|
1109
1136
|
if (Predicate.isNotUndefined(groups)) {
|
|
1110
1137
|
const first = UndefinedOr.match(groups[0], { onUndefined: constUndefined, onDefined: (group) => group.name })
|
|
1111
|
-
return Effect.all(Arr.map(groups, (group) => runName(node, group.name, delay, group.name === first)), { concurrency: "unbounded", discard: true })
|
|
1138
|
+
return Effect.all(Arr.map(groups, (group) => runName(node, group.name, delay, group.name === first, delays)), { concurrency: "unbounded", discard: true })
|
|
1112
1139
|
}
|
|
1113
1140
|
const own = exitOf(node.rec, node.exit, delay)
|
|
1114
1141
|
if (node.kids.length === 0) return own
|
|
1115
|
-
const n = node.kids.length
|
|
1116
1142
|
// Each name orchestrates the children's keys of that name (#297, Motion's `animateVariant` a name):
|
|
1117
1143
|
// its own transition's delay and stagger, else the exit's.
|
|
1118
|
-
const slot = (
|
|
1119
|
-
const s = VariantTree.staggerOf(transitionOfName(node.exit, name))
|
|
1120
|
-
return VariantTree.childDelayOf(s, i, n)
|
|
1121
|
-
}
|
|
1144
|
+
const slot = slotsOf(node, delays)
|
|
1122
1145
|
const kidsFrom = (from: DelayOf): Effect.Effect<unknown, never, WardicServices.WardicServices> =>
|
|
1123
|
-
Effect.all(Arr.map(node.kids, (kid, i) => runOf(kid, (name) => from(name) + slot(i)(name))), { concurrency: "unbounded", discard: true })
|
|
1146
|
+
Effect.all(Arr.map(node.kids, (kid, i) => runOf(kid, (name) => from(name) + slot(i)(name), delays)), { concurrency: "unbounded", discard: true })
|
|
1124
1147
|
// `when` for a list as a whole, meanwhile (#297's PR 1): the exit's, its last name's that sets it.
|
|
1125
1148
|
const when = UndefinedOr.map(node.exit.transition, (t) => t.when)
|
|
1126
1149
|
if (when === "beforeChildren") return Effect.andThen(own, kidsFrom(NO_DELAY))
|
|
@@ -1128,25 +1151,27 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
|
|
|
1128
1151
|
return Effect.all([own, kidsFrom(delay)], { concurrency: "unbounded", discard: true })
|
|
1129
1152
|
}
|
|
1130
1153
|
|
|
1154
|
+
/** Each of `node`'s children's place in its exit's stagger, by the name it exits under: its delay. */
|
|
1155
|
+
const slotsOf = (node: ExitNode, delays: VariantTree.DelayFailures) => {
|
|
1156
|
+
const n = node.kids.length
|
|
1157
|
+
return (i: number) => (name: string | undefined): number => VariantTree.childDelayOf(VariantTree.staggerOf(transitionOfName(node.exit, name)), i, n, delays)
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1131
1160
|
/**
|
|
1132
1161
|
* One name of a list's exit (#297's PR 2, Motion's `animateVariant` a name): the element's keys of that
|
|
1133
1162
|
* name, and its Variant children's, one after the other with that name's `when`, else together. A
|
|
1134
1163
|
* child whose exit isn't the list runs it whole, under the list's first name.
|
|
1135
1164
|
*/
|
|
1136
|
-
const runName = (node: ExitNode, name: string, delay: DelayOf, first: boolean): Effect.Effect<unknown, never, WardicServices.WardicServices> => {
|
|
1165
|
+
const runName = (node: ExitNode, name: string, delay: DelayOf, first: boolean, delays: VariantTree.DelayFailures): Effect.Effect<unknown, never, WardicServices.WardicServices> => {
|
|
1137
1166
|
const own = exitOf(node.rec, node.exit, delay, name)
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
const slot = (i: number) => (of: string | undefined): number => {
|
|
1141
|
-
const s = VariantTree.staggerOf(transitionOfName(node.exit, of))
|
|
1142
|
-
return VariantTree.childDelayOf(s, i, n)
|
|
1143
|
-
}
|
|
1167
|
+
if (node.kids.length === 0) return own
|
|
1168
|
+
const slot = slotsOf(node, delays)
|
|
1144
1169
|
const kidsFrom = (from: DelayOf): Effect.Effect<unknown, never, WardicServices.WardicServices> =>
|
|
1145
1170
|
Effect.all(
|
|
1146
1171
|
Arr.map(node.kids, (kid, i) => {
|
|
1147
1172
|
const at: DelayOf = (of) => from(of) + slot(i)(of)
|
|
1148
|
-
if (Predicate.isNotUndefined(kid.exit.groups)) return runName(kid, name, at, first)
|
|
1149
|
-
if (first) return runOf(kid, at)
|
|
1173
|
+
if (Predicate.isNotUndefined(kid.exit.groups)) return runName(kid, name, at, first, delays)
|
|
1174
|
+
if (first) return runOf(kid, at, delays)
|
|
1150
1175
|
return Effect.void
|
|
1151
1176
|
}),
|
|
1152
1177
|
{ concurrency: "unbounded", discard: true },
|
|
@@ -1176,7 +1201,7 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
|
|
|
1176
1201
|
const skipped = UndefinedOr.match(rec.skipAnimations, { onUndefined: constFalse, onDefined: (own) => own() })
|
|
1177
1202
|
// Measured pairs (#430): an exit from `auto` to 0 measures both ends, as a Retarget does, unless
|
|
1178
1203
|
// reduced motion snaps them or the exit is skipped.
|
|
1179
|
-
const measured = Bool.match(Bool.or(reduce, skipped), { onTrue: constUndefined, onFalse: () => exitMeasuredOf(el, from, to, stops) })
|
|
1204
|
+
const measured = Bool.match(Bool.or(reduce, skipped), { onTrue: constUndefined, onFalse: () => exitMeasuredOf(el, from, to, stops, exitMeasuredFailed) })
|
|
1180
1205
|
const legs = UndefinedOr.match(exit.groups, {
|
|
1181
1206
|
onUndefined: () => RetargetLegs.legsOf(from, to, RetargetLegs.delayedBy(exit.transition, delay(singleNameOf(exit.name))), reduce, skipped, positionalKeys, defaultTransition, moving, undefined, stops, measured),
|
|
1182
1207
|
onDefined: (groups) =>
|
|
@@ -1195,7 +1220,7 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
|
|
|
1195
1220
|
const preparedOf = (rec: PresenceRecord, exit: CorePresenceRecord.PresenceExit): PreparedExit => {
|
|
1196
1221
|
const known = prepared.get(exit)
|
|
1197
1222
|
if (Predicate.isNotUndefined(known)) return known
|
|
1198
|
-
const el = rec.
|
|
1223
|
+
const el = rec.subject
|
|
1199
1224
|
const to = exit.values
|
|
1200
1225
|
// Seeded from the element's last snapshot, so its exit departs continuously. A key it never
|
|
1201
1226
|
// animated starts from its Base value's start links (ADR-0022), else at its target.
|
|
@@ -1457,7 +1482,7 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
|
|
|
1457
1482
|
const watchesIn = (el: Element): ReadonlyArray<PresenceWatch> => {
|
|
1458
1483
|
if (Predicate.isUndefined(watchesWithin)) {
|
|
1459
1484
|
const index = new Map<Element, Array<PresenceWatch>>()
|
|
1460
|
-
Iter.forEach(watches, (watch) => UndefinedOr.map(watch.
|
|
1485
|
+
Iter.forEach(watches, (watch) => UndefinedOr.map(watch.subject(), (at) => indexUp(index, at, watch)))
|
|
1461
1486
|
watchesWithin = index
|
|
1462
1487
|
}
|
|
1463
1488
|
return Arr.filter(UndefinedOr.match(watchesWithin.get(el), { onUndefined: (): ReadonlyArray<PresenceWatch> => [], onDefined: identity }), (watch) => watches.has(watch))
|
|
@@ -1496,7 +1521,7 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
|
|
|
1496
1521
|
|
|
1497
1522
|
/** A hook whose element left the page some other way, dropped (#277's PR 5b): not one a held child holds. */
|
|
1498
1523
|
const dropDetachedWatch = (watch: PresenceWatch): void => {
|
|
1499
|
-
UndefinedOr.map(watch.
|
|
1524
|
+
UndefinedOr.map(watch.subject(), (at) => {
|
|
1500
1525
|
if (Bool.or(at.isConnected, isHeld(at))) return
|
|
1501
1526
|
watches.delete(watch)
|
|
1502
1527
|
watch.gone()
|
|
@@ -1513,7 +1538,7 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
|
|
|
1513
1538
|
* else its last values, at the velocities its own animation left them.
|
|
1514
1539
|
*/
|
|
1515
1540
|
const drawnOf = (rec: PresenceRecord): Drawn =>
|
|
1516
|
-
UndefinedOr.match(draws.get(rec.
|
|
1541
|
+
UndefinedOr.match(draws.get(rec.subject), {
|
|
1517
1542
|
onUndefined: (): Drawn => ({
|
|
1518
1543
|
values: valuesDrawn(rec.snapshot.current),
|
|
1519
1544
|
velocities: UndefinedOr.match(rec.velocities, { onUndefined: () => NO_VELOCITIES, onDefined: (of) => ({ ...of() }) }),
|
|
@@ -1555,7 +1580,7 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
|
|
|
1555
1580
|
/** Where a leaver and the Wardic elements inside it paint now, in the Root frame: each one on the page. */
|
|
1556
1581
|
const boxesOf = (leaver: Element): ReadonlyMap<Element, Box.Box> => {
|
|
1557
1582
|
const boxes = new Map<Element, Box.Box>()
|
|
1558
|
-
Arr.forEach([leaver, ...Arr.map(partsOf(leaver), (part) => part.
|
|
1583
|
+
Arr.forEach([leaver, ...Arr.map(partsOf(leaver), (part) => part.subject)], (el) =>
|
|
1559
1584
|
Option.map(projection.rootBoxOf(el), (box) => boxes.set(el, box)))
|
|
1560
1585
|
return boxes
|
|
1561
1586
|
}
|
|
@@ -1587,8 +1612,8 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
|
|
|
1587
1612
|
// Each as drawn, and where it painted: a layout node moves from there (#286's PR 2).
|
|
1588
1613
|
const boxes = UndefinedOr.match(leaverBoxes.get(leaver), { onUndefined: (): ReadonlyMap<Element, Box.Box> => NO_BOXES, onDefined: identity })
|
|
1589
1614
|
leaverBoxes.delete(leaver)
|
|
1590
|
-
const seedOf = (rec: PresenceRecord): Drawn => ({ ...drawnOf(rec), box: boxes.get(rec.
|
|
1591
|
-
const paired = sameShape(Arr.map(before, (part) => part.
|
|
1615
|
+
const seedOf = (rec: PresenceRecord): Drawn => ({ ...drawnOf(rec), box: boxes.get(rec.subject) })
|
|
1616
|
+
const paired = sameShape(Arr.map(before, (part) => part.subject), after)
|
|
1592
1617
|
if (paired) Arr.forEach(Arr.zip(before, after), ([part, into]) => seeds.set(into, seedOf(part)))
|
|
1593
1618
|
debug("leave: taken over", { parts: before.length, paired })
|
|
1594
1619
|
// A twin crossfading out (Q8: D): its leaving Follower goes at once, uncompleted, and the new
|
|
@@ -1607,7 +1632,7 @@ export const makePresence = (options: PresenceOptions): PresenceController => {
|
|
|
1607
1632
|
// Leaving in this change: it goes as Solid took it, its records and hooks with it.
|
|
1608
1633
|
takenOver.add(leaver)
|
|
1609
1634
|
pops.delete(leaver)
|
|
1610
|
-
Arr.forEach([from, ...before], (rec) => registry.delete(rec.
|
|
1635
|
+
Arr.forEach([from, ...before], (rec) => registry.delete(rec.subject))
|
|
1611
1636
|
Arr.forEach(watchesIn(leaver), (watch) => {
|
|
1612
1637
|
watches.delete(watch)
|
|
1613
1638
|
watch.gone()
|
|
@@ -1755,13 +1780,14 @@ export const propagateTo = (parent: PresenceContextValue | undefined, propagate:
|
|
|
1755
1780
|
let disposed = false
|
|
1756
1781
|
let leaving = false
|
|
1757
1782
|
;(watch as (watch: PresenceWatch) => void)({
|
|
1758
|
-
|
|
1783
|
+
subject: presence.anchor,
|
|
1759
1784
|
holds: true,
|
|
1760
1785
|
leave: (_custom, release) => {
|
|
1761
1786
|
leaving = true
|
|
1787
|
+
// Its own teardown first, then the parent's child let go, whose chain can reach the app's code (#983).
|
|
1762
1788
|
presence.leaveAll(() => {
|
|
1763
|
-
release()
|
|
1764
1789
|
tear()
|
|
1790
|
+
release()
|
|
1765
1791
|
})
|
|
1766
1792
|
},
|
|
1767
1793
|
gone: () => {
|
|
@@ -29,8 +29,8 @@ const isPress = (event: InputSource.PointerLikeEvent): boolean => Bool.and(event
|
|
|
29
29
|
* keys inside their dispatch, so the reorder's `handle()` (the page's `preventDefault`) counts. A blur
|
|
30
30
|
* is judged after this task's own work, one scheduler hop on (#318): a reorder can blur the node it
|
|
31
31
|
* moves and puts focus back after (the driver's `keepFocus`). So `fork` runs that hop on the provider
|
|
32
|
-
* runtime, only when a blur happens, and a blur whose judging fails is reported. A
|
|
33
|
-
* driver inside an event goes to `onDefect
|
|
32
|
+
* runtime, only when a blur happens, and a blur whose judging fails is reported. A run of throws from
|
|
33
|
+
* the driver inside an event goes to `onDefect` at its first.
|
|
34
34
|
*/
|
|
35
35
|
export const watchItemInput = (
|
|
36
36
|
el: HTMLElement,
|
|
@@ -20,7 +20,7 @@ import type * as ProjectionSystem from "../ProjectionSystem.ts"
|
|
|
20
20
|
import type { WardicDragConstraints, WardicMeasureDragConstraints } from "./DragConstraints.ts"
|
|
21
21
|
import type { WardicDragControls } from "./DragControls.ts"
|
|
22
22
|
import type * as Feature from "./Feature.ts"
|
|
23
|
-
import type { WardicDragInfo, WardicPointInfo, WardicPressEvent, WardicPressInfo } from "./GestureInfo.ts"
|
|
23
|
+
import type { WardicDragEndInfo, WardicDragInfo, WardicPointInfo, WardicPressEvent, WardicPressInfo } from "./GestureInfo.ts"
|
|
24
24
|
|
|
25
25
|
/** What "in view" means: an element's `viewport`, and `createInView`'s. Motion's `viewport` and `useInView` options. */
|
|
26
26
|
// #273, ADR-0047.
|
|
@@ -49,6 +49,11 @@ export interface CSSProperties extends CSS.PropertiesHyphen {
|
|
|
49
49
|
* is used verbatim).
|
|
50
50
|
*/
|
|
51
51
|
export interface WardicTransformShorthands {
|
|
52
|
+
/**
|
|
53
|
+
* The element's own depth, Motion's `transformPerspective`: a `perspective()` at the head of its
|
|
54
|
+
* transform, a bare number in px. Its children's depth is the `perspective` property's.
|
|
55
|
+
*/
|
|
56
|
+
readonly transformPerspective?: number | string
|
|
52
57
|
readonly x?: number | string
|
|
53
58
|
readonly y?: number | string
|
|
54
59
|
readonly z?: number | string
|
|
@@ -58,6 +63,9 @@ export interface WardicTransformShorthands {
|
|
|
58
63
|
readonly scale?: number | string
|
|
59
64
|
readonly scaleX?: number | string
|
|
60
65
|
readonly scaleY?: number | string
|
|
66
|
+
/** The scale along the element's depth, CSS's `scaleZ()`: seen only beside a turn out of its plane. */
|
|
67
|
+
// #883 drew it, #887 typed it.
|
|
68
|
+
readonly scaleZ?: number | string
|
|
61
69
|
readonly rotate?: number | string
|
|
62
70
|
readonly rotateX?: number | string
|
|
63
71
|
readonly rotateY?: number | string
|
|
@@ -116,9 +124,10 @@ export type WardicValues =
|
|
|
116
124
|
/**
|
|
117
125
|
* The CSS lengths a value takes a bare number on, drawn in `px` (#522, Motion's `animate={{ height: 200 }}`):
|
|
118
126
|
* the DOM renderer's `LENGTH_KEYS`, so a number typechecks only where it's drawn as a length. Every
|
|
119
|
-
* other length takes `csstype`'s value, `0` or a string.
|
|
120
|
-
*
|
|
127
|
+
* other length takes `csstype`'s value, `0` or a string. In an element's `style`, a number on one of these
|
|
128
|
+
* is drawn by Wardic too, in px, so `style={{ width: 200 }}` is 200px.
|
|
121
129
|
*/
|
|
130
|
+
// #887: the style's number routed to the renderer (`LiveStyle`), where before a binding wrote it as it is.
|
|
122
131
|
export type WardicLengths = { readonly [K in DomRenderer.LengthKey]?: number | CSSProperties[K] }
|
|
123
132
|
|
|
124
133
|
/** The DOM's keys and their values fill core's {@link Config.ValueKeys}, typing every config type built on it. */
|
|
@@ -301,7 +310,7 @@ export interface WardBaseConfig {
|
|
|
301
310
|
// Dynamic variants: #277. Orchestration: ADR-0007.
|
|
302
311
|
readonly variants?: Config.WardicVariants
|
|
303
312
|
/**
|
|
304
|
-
* The value passed to this element's
|
|
313
|
+
* The value passed to this element's dynamic variants. When it changes, they're resolved again,
|
|
305
314
|
* and the element animates to what they give. A leaving element uses `<AnimatePresence custom>`
|
|
306
315
|
* instead, if given.
|
|
307
316
|
*/
|
|
@@ -335,13 +344,16 @@ export interface WardBaseConfig {
|
|
|
335
344
|
readonly transition?: WardicTransition
|
|
336
345
|
/**
|
|
337
346
|
* Where the element animates as it leaves an `<AnimatePresence>`: values or a `variants` name. The
|
|
338
|
-
* element stays on the page until it has played.
|
|
347
|
+
* element stays on the page until it has played. A dynamic variant that throws as the element
|
|
348
|
+
* leaves, alone or in a list, is reported, and the element leaves at once, without its exit; the
|
|
349
|
+
* others leaving beside it exit.
|
|
339
350
|
*
|
|
340
351
|
* @example <w.div exit={{ opacity: 0, scale: 0.9 }} />
|
|
341
352
|
*/
|
|
342
353
|
// ADR-0007: the child doesn't drive it (it's disposed); its spine publishes the exit into the
|
|
343
354
|
// presence registration, and the presence runs it on the retained node. A dynamic variant resolves
|
|
344
|
-
// as it leaves (#277); its own transition, else the element's.
|
|
355
|
+
// as it leaves (#277); its own transition, else the element's. One that throws: #979, reported by the
|
|
356
|
+
// presence's `nodeOf` each time.
|
|
345
357
|
readonly exit?: WardicVariant | Config.WardicVariantLabels
|
|
346
358
|
/**
|
|
347
359
|
* Called when an animation of the element starts, with what it animates to: the variant name, or
|
|
@@ -485,8 +497,8 @@ export interface WardPanConfig {
|
|
|
485
497
|
readonly onPanStart?: (event: PointerEvent, info: WardicDragInfo) => void
|
|
486
498
|
/** Called as the pan moves: at its start, and each move after. Solid 1; Solid 2's ward gives `"pan"`. */
|
|
487
499
|
readonly onPan?: (event: PointerEvent, info: WardicDragInfo) => void
|
|
488
|
-
/** Called when a pan that started ends, or is cancelled. Solid 1; Solid 2's ward gives `"panEnd"`. */
|
|
489
|
-
readonly onPanEnd?: (event: PointerEvent, info:
|
|
500
|
+
/** Called when a pan that started ends, or is cancelled, its info saying how (`endedBy`, #1042). Solid 1; Solid 2's ward gives `"panEnd"`. */
|
|
501
|
+
readonly onPanEnd?: (event: PointerEvent, info: WardicDragEndInfo) => void
|
|
490
502
|
}
|
|
491
503
|
|
|
492
504
|
/** The motion props the `drag` Feature reads: {@link WardConfig}'s `drag` group (#516). */
|
|
@@ -575,8 +587,8 @@ export interface WardDragConfig {
|
|
|
575
587
|
readonly onDragStart?: (event: PointerEvent, info: WardicDragInfo) => void
|
|
576
588
|
/** Called as the drag moves: at its start, and each move after. Solid 1; Solid 2's ward gives `"drag"`. */
|
|
577
589
|
readonly onDrag?: (event: PointerEvent, info: WardicDragInfo) => void
|
|
578
|
-
/** Called when the drag
|
|
579
|
-
readonly onDragEnd?: (event: PointerEvent, info:
|
|
590
|
+
/** Called when the drag ends, its info saying how: let go, or taken away (`endedBy`, #1042). Solid 1; Solid 2's ward gives `"dragEnd"`. */
|
|
591
|
+
readonly onDragEnd?: (event: PointerEvent, info: WardicDragEndInfo) => void
|
|
580
592
|
/** Called when the element comes to rest after it's let go. Not when a new grab stops it. Solid 1; Solid 2's ward gives `"dragTransitionEnd"`. */
|
|
581
593
|
readonly onDragTransitionEnd?: () => void
|
|
582
594
|
/** With `dragDirectionLock`: called with the axis a drag locked to, before `onDragStart`. Solid 1; Solid 2's ward gives `"directionLock"`. */
|
|
@@ -12,8 +12,11 @@
|
|
|
12
12
|
// Unstable: ADR-0071, decision 5. #672 (PR6-Q1): solid's `features/timeline-keys.ts`, moved to dom with the Features, for
|
|
13
13
|
// every DOM binding.
|
|
14
14
|
import * as LiveValue from "@wardic/core/LiveValue"
|
|
15
|
+
import * as Report from "@wardic/core/unstable/Report"
|
|
15
16
|
import * as TimelineValue from "../../TimelineValue.ts"
|
|
16
17
|
import * as Bool from "effect/Boolean"
|
|
18
|
+
import * as Effect from "effect/Effect"
|
|
19
|
+
import * as Exit from "effect/Exit"
|
|
17
20
|
import * as Option from "effect/Option"
|
|
18
21
|
import * as Predicate from "effect/Predicate"
|
|
19
22
|
import type * as Atom from "effect/reactivity/Atom"
|
|
@@ -49,6 +52,10 @@ export const makeTimelines = (): Timelines.Timelines["Service"] => {
|
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
54
|
|
|
55
|
+
// #979 (ADR-0074, row 7): a make calls the app's code, an `ease` or an interpolator, at each point its
|
|
56
|
+
// keyframes sample, some the frame path never reads. Its throw came out of the binding, a Solid 2 halt.
|
|
57
|
+
const TIMELINE_FAILED = "wardic.timeline: a Timeline value failed"
|
|
58
|
+
|
|
52
59
|
/**
|
|
53
60
|
* An element's keys. `shown` runs at each write of a key's Live value, so per frame while it moves: a key
|
|
54
61
|
* shown already from the same source is left as it is, with nothing read but its source, statements and
|
|
@@ -57,7 +64,7 @@ export const makeTimelines = (): Timelines.Timelines["Service"] => {
|
|
|
57
64
|
const elementKeysOf = (options: Timelines.TimelineKeysOptions, unmounted: () => void): ElementKeys => {
|
|
58
65
|
const { runtime, gate, id, live } = options
|
|
59
66
|
// #672: the spine hands its Subject; a DOM binding's is its element, which a Timeline value follows.
|
|
60
|
-
const element = options.
|
|
67
|
+
const element = options.subject as Element
|
|
61
68
|
const made = new Map<string, Made>()
|
|
62
69
|
// The keys that show their Live value, whatever runs them, each with the Atom it was shown from (none
|
|
63
70
|
// for a plain accessor's): the ones `recheck` looks at again.
|
|
@@ -65,7 +72,11 @@ const elementKeysOf = (options: Timelines.TimelineKeysOptions, unmounted: () =>
|
|
|
65
72
|
// The keys whose Timeline value the gate has, each with it.
|
|
66
73
|
const running = new Map<string, TimelineValue.TimelineValue>()
|
|
67
74
|
|
|
68
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* `key`'s Timeline value now, made again when its derivation changed; `undefined` for none. A make that
|
|
77
|
+
* throws is reported and makes none, so the gate draws the key, and it's kept as made: tried again only
|
|
78
|
+
* for a new derivation.
|
|
79
|
+
*/
|
|
69
80
|
const timelineOf = (key: string): TimelineValue.TimelineValue | undefined => {
|
|
70
81
|
const atom = live.atomOf(key)
|
|
71
82
|
if (Predicate.isUndefined(atom)) return undefined
|
|
@@ -75,7 +86,13 @@ const elementKeysOf = (options: Timelines.TimelineKeysOptions, unmounted: () =>
|
|
|
75
86
|
if (Predicate.isNotUndefined(last)) {
|
|
76
87
|
if (last.derivation === derivation) return last.timeline
|
|
77
88
|
}
|
|
78
|
-
const timeline =
|
|
89
|
+
const timeline = Exit.match(runtime.runSyncExit(TimelineValue.make(derivation, element, key)), {
|
|
90
|
+
onSuccess: Option.getOrUndefined,
|
|
91
|
+
onFailure: (cause) => {
|
|
92
|
+
runtime.runFork(Report.failure(TIMELINE_FAILED, cause).pipe(Effect.annotateLogs({ key })))
|
|
93
|
+
return undefined
|
|
94
|
+
},
|
|
95
|
+
})
|
|
79
96
|
made.set(key, { derivation, timeline })
|
|
80
97
|
return timeline
|
|
81
98
|
}
|