@wardic/core 1.3.0 → 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 +195 -24
- 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/BatchCalls.d.ts +16 -1
- package/dist/unstable/BatchCalls.d.ts.map +1 -1
- package/dist/unstable/BatchCalls.js +8 -0
- package/dist/unstable/BatchCalls.js.map +1 -1
- package/dist/unstable/Config.d.ts +16 -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 +42 -11
- package/dist/unstable/Imperative.d.ts.map +1 -1
- package/dist/unstable/Imperative.js +413 -77
- 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 +62 -10
- 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 +210 -20
- 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/BatchCalls.ts +20 -2
- package/src/unstable/Config.ts +24 -1
- package/src/unstable/FlushGate.ts +169 -37
- package/src/unstable/FrameEffects.ts +15 -2
- package/src/unstable/Imperative.ts +447 -89
- 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 +244 -43
- package/src/unstable/VariantTarget.ts +93 -14
- package/src/unstable/VariantTree.ts +87 -6
package/dist/unstable/Spine.js
CHANGED
|
@@ -94,16 +94,20 @@ export const exitTargetOf = (config, presenceCustom, state, inherited) => {
|
|
|
94
94
|
// A list (#297): merged, and each name's own keys on its own transition.
|
|
95
95
|
const targets = VariantTarget.resolveTargets(entry, config.variants, custom, state);
|
|
96
96
|
const merged = VariantTarget.mergedOf(targets);
|
|
97
|
+
// One of its names' resolvers threw (#979, Q3): it leaves without the whole exit, as with one name.
|
|
98
|
+
if (Option.isSome(merged.failure))
|
|
99
|
+
return { values: {}, transition: config.transition, name, keyframes: undefined, failure: merged.failure };
|
|
97
100
|
return {
|
|
98
101
|
values: merged.values,
|
|
99
102
|
transition: VariantTarget.transitionOfTarget(merged.transition, config.transition),
|
|
100
103
|
name,
|
|
101
104
|
groups: exitGroupsOf(targets, config.transition),
|
|
102
105
|
keyframes: merged.keyframes,
|
|
106
|
+
failure: merged.failure,
|
|
103
107
|
};
|
|
104
108
|
}
|
|
105
109
|
const target = VariantTarget.resolveTarget(entry, config.variants, custom, state);
|
|
106
|
-
return { values: target.values, transition: VariantTarget.transitionOfTarget(target.transition, config.transition), name, keyframes: target.keyframes };
|
|
110
|
+
return { values: target.values, transition: VariantTarget.transitionOfTarget(target.transition, config.transition), name, keyframes: target.keyframes, failure: target.failure };
|
|
107
111
|
};
|
|
108
112
|
/** A list's exit groups (#297): each name, with the keys it's the last to set, on its own transition else `element`. */
|
|
109
113
|
const exitGroupsOf = (targets, element) => Arr.map(targets, (target, i) => ({
|
|
@@ -148,13 +152,6 @@ const keyTransitionOf = (resolution, groups, key, transition, element) => {
|
|
|
148
152
|
return transition;
|
|
149
153
|
return groupTransitionOf(resolution, groups, Option.getOrElse(Arr.findFirstIndex(groups, (group) => group.has(key)), () => -1), transition, element, undefined, identity);
|
|
150
154
|
};
|
|
151
|
-
/** Whether `given` gives `key` a velocity (#448, Motion's `valueTransition.velocity`): it kicks the key, so it animates though at its target. */
|
|
152
|
-
const givesVelocity = (given, key) => {
|
|
153
|
-
const own = RetargetLegs.transitionForKey(given, key);
|
|
154
|
-
if (Predicate.isUndefined(own))
|
|
155
|
-
return false;
|
|
156
|
-
return Bool.and(Predicate.isNumber(own.velocity), own.velocity !== 0);
|
|
157
|
-
};
|
|
158
155
|
/** A key's velocity in the Snapshot, 0 with none (#448). Per key, per Retarget: a guard. */
|
|
159
156
|
const velocityOf = (snapshot, key) => {
|
|
160
157
|
const velocity = snapshot.velocities[key];
|
|
@@ -209,7 +206,7 @@ const sameField = (a, b) => {
|
|
|
209
206
|
return false;
|
|
210
207
|
};
|
|
211
208
|
/** A gesture layer that's off: nothing is resolved for it. */
|
|
212
|
-
const OFF = { active: false, values: {}, transition: undefined, name: undefined, ends: {}, keyframes: undefined };
|
|
209
|
+
const OFF = { active: false, values: {}, transition: undefined, name: undefined, ends: {}, keyframes: undefined, failure: VariantTarget.NO_FAILURE };
|
|
213
210
|
/**
|
|
214
211
|
* A gesture layer (#291), while it's on (its own, or its provider's): its own `while*` (a target, or
|
|
215
212
|
* a variant name), else the label its provider hands down. Off, or with neither, nothing is resolved.
|
|
@@ -452,9 +449,13 @@ const stopsCheckOf = (variables) => {
|
|
|
452
449
|
const PATH_ROTATION = "pathRotation";
|
|
453
450
|
/** The turn back at 0, written once no leg draws it (#460). */
|
|
454
451
|
const TURNED_BACK = { [PATH_ROTATION]: 0 };
|
|
455
|
-
/**
|
|
456
|
-
|
|
452
|
+
/**
|
|
453
|
+
* A leg over the keys of `to` (#325), counting toward `landing`: the spine gives it the keys. A Handoff's
|
|
454
|
+
* leg is `onFrameTimeline` (#1026).
|
|
455
|
+
*/
|
|
456
|
+
export const runningOf = (to, resolution, landing, kind, onFrameTimeline = false) => ({
|
|
457
457
|
supersede: Supersede.make(),
|
|
458
|
+
onFrameTimeline,
|
|
458
459
|
targets: to,
|
|
459
460
|
resolution,
|
|
460
461
|
count: 0,
|
|
@@ -502,6 +503,28 @@ const blendVelocityOf = (running, key) => {
|
|
|
502
503
|
return 0;
|
|
503
504
|
return ((last - before) * 1000) / apart;
|
|
504
505
|
};
|
|
506
|
+
/**
|
|
507
|
+
* A Blend leg's last two frames' values, kept for its velocity (#464): two records of its own, swapped each
|
|
508
|
+
* frame, the frame's values copied into the newer, since its Frame is its run's, rewritten each tick. Before
|
|
509
|
+
* its first frame, the Snapshot's values are its older. A leg that lands on its first frame keeps none: its
|
|
510
|
+
* velocity is 0.
|
|
511
|
+
*/
|
|
512
|
+
// #895: per frame, plain calls; its two records made at its first frame, nothing after.
|
|
513
|
+
const keepFrame = (running, frame, snapshotValues) => {
|
|
514
|
+
const older = running.last;
|
|
515
|
+
if (Predicate.isUndefined(older)) {
|
|
516
|
+
if (frame.done)
|
|
517
|
+
return;
|
|
518
|
+
running.before = { ...snapshotValues };
|
|
519
|
+
running.last = { ...frame.value };
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
// Set with `last` at its first frame: present by construction.
|
|
523
|
+
const newer = UndefinedOr.getOrThrow(running.before);
|
|
524
|
+
Object.assign(newer, frame.value);
|
|
525
|
+
running.before = older;
|
|
526
|
+
running.last = newer;
|
|
527
|
+
};
|
|
505
528
|
/** A leg's frame drawn (#325) at `now`: its last lands the keys it draws. Per frame: plain calls. */
|
|
506
529
|
const drew = (running, done, now) => {
|
|
507
530
|
if (done)
|
|
@@ -705,6 +728,7 @@ const layerOf = (target, name) => ({
|
|
|
705
728
|
name,
|
|
706
729
|
ends: endsOfTarget(target),
|
|
707
730
|
keyframes: target.keyframes,
|
|
731
|
+
failure: target.failure,
|
|
708
732
|
});
|
|
709
733
|
/** A list's target as an active entry (#297). */
|
|
710
734
|
const namedLayerOf = (target) => layerOf(target, target.name);
|
|
@@ -870,9 +894,10 @@ const measuringOf = (found, keyframes) => Arr.appendAll(UndefinedOr.match(found,
|
|
|
870
894
|
/**
|
|
871
895
|
* A Retarget's Measured pairs (#430): each of `keys` whose start and target are one, asked of the
|
|
872
896
|
* end-of-task batch with the values the element draws now, but a key with Keyframes of more than two
|
|
873
|
-
* stops (`many`, #460). `undefined` with none.
|
|
897
|
+
* stops (`many`, #460). `undefined` with none. When the batch can't take them, they switch, as pairs
|
|
898
|
+
* it couldn't read do, reported on `runtime` with the element's `id`.
|
|
874
899
|
*/
|
|
875
|
-
export const measuredOf = (measured, element, keys, from, to, values, many) => {
|
|
900
|
+
export const measuredOf = (measured, element, keys, from, to, values, many, runtime, id) => {
|
|
876
901
|
const pairs = {};
|
|
877
902
|
Arr.forEach(keys, (key) => {
|
|
878
903
|
if (RetargetLegs.hasManyStops(many, key))
|
|
@@ -886,8 +911,15 @@ export const measuredOf = (measured, element, keys, from, to, values, many) => {
|
|
|
886
911
|
});
|
|
887
912
|
if (Rec.isEmptyRecord(pairs))
|
|
888
913
|
return undefined;
|
|
889
|
-
|
|
914
|
+
// Its report made only for pairs asked, not once an element (#979, row 8): nearly every Retarget asks none.
|
|
915
|
+
return measured.measure(element, pairs, values, pairsFailedOn("wardic.spine: a Retarget's Measured pairs failed", runtime, { id }));
|
|
890
916
|
};
|
|
917
|
+
/** How Measured pairs the batch couldn't take are reported under `message`, on `runtime`, each time (#979, row 8). */
|
|
918
|
+
const pairsFailedOn = (message, runtime, annotations) => (defect) => {
|
|
919
|
+
runtime.runFork(Effect.annotateLogs(Report.failure(message, Cause.die(defect)), annotations));
|
|
920
|
+
};
|
|
921
|
+
/** How an exit's Measured pairs the batch couldn't take (its Transform template threw) are reported, on `runtime`. */
|
|
922
|
+
export const exitMeasuredFailedOn = (runtime) => pairsFailedOn("wardic.presence: an exit's Measured pairs failed", runtime, {});
|
|
891
923
|
/** A key's Keyframes in `keyframes` (#429): per key, per Retarget, so a guard, nothing made. */
|
|
892
924
|
const keyframesAtOf = (keyframes, key) => {
|
|
893
925
|
if (Predicate.isUndefined(keyframes))
|
|
@@ -1023,17 +1055,26 @@ const nameSettlesOf = (names, resolution, groups, legGroups, legCount, carriedGr
|
|
|
1023
1055
|
/**
|
|
1024
1056
|
* Solid 1's animation callbacks (#257, Motion's props): each Retarget's start and settle told to the
|
|
1025
1057
|
* config's `onAnimationStart` / `onAnimationComplete`, with its `definition`, as the Retarget read
|
|
1026
|
-
* the config. A callback that throws is reported
|
|
1027
|
-
* config has neither: it hands the
|
|
1058
|
+
* the config. A callback that throws is reported at the first of a run of throws, its next clean call
|
|
1059
|
+
* ending the run, and the element animates on. The Solid 2 binding's config has neither: it hands the
|
|
1060
|
+
* same facts over as async values.
|
|
1028
1061
|
*/
|
|
1029
1062
|
export const animationCallbacks = (runtime, id) => {
|
|
1030
|
-
//
|
|
1031
|
-
|
|
1063
|
+
// #979 group I, row 25 (ADR-0074 decision 3): a run is one callback's throws at its consecutive calls,
|
|
1064
|
+
// each name of a list one call, so a clean name ends it. Two lets, nothing more made per element.
|
|
1065
|
+
let startFailing = false;
|
|
1066
|
+
let completeFailing = false;
|
|
1067
|
+
// Per Retarget, per element: the callback looked up first, and nothing made without one. Whether it threw,
|
|
1068
|
+
// reported at a run's first throw (`failing` says one is on).
|
|
1069
|
+
const tell = (name, callback, definition, failing) => {
|
|
1032
1070
|
try {
|
|
1033
1071
|
callback(definition);
|
|
1072
|
+
return false;
|
|
1034
1073
|
}
|
|
1035
1074
|
catch (defect) {
|
|
1036
|
-
|
|
1075
|
+
if (!failing)
|
|
1076
|
+
runtime.runFork(Report.failure(`wardic.spine: ${name} failed`, Cause.die(defect)).pipe(Effect.annotateLogs({ id })));
|
|
1077
|
+
return true;
|
|
1037
1078
|
}
|
|
1038
1079
|
};
|
|
1039
1080
|
return {
|
|
@@ -1044,10 +1085,12 @@ export const animationCallbacks = (runtime, id) => {
|
|
|
1044
1085
|
return;
|
|
1045
1086
|
const definition = definitionOf(resolution, previous);
|
|
1046
1087
|
if (Arr.isArray(definition)) {
|
|
1047
|
-
Arr.forEach(definition, (name) =>
|
|
1088
|
+
Arr.forEach(definition, (name) => {
|
|
1089
|
+
startFailing = tell("onAnimationStart", callback, name, startFailing);
|
|
1090
|
+
});
|
|
1048
1091
|
return;
|
|
1049
1092
|
}
|
|
1050
|
-
tell("onAnimationStart", callback, definition);
|
|
1093
|
+
startFailing = tell("onAnimationStart", callback, definition, startFailing);
|
|
1051
1094
|
},
|
|
1052
1095
|
// A list's names were each told as they settled (`namesSettled`).
|
|
1053
1096
|
settled: (resolution, previous, config) => {
|
|
@@ -1057,13 +1100,15 @@ export const animationCallbacks = (runtime, id) => {
|
|
|
1057
1100
|
const definition = definitionOf(resolution, previous);
|
|
1058
1101
|
if (Arr.isArray(definition))
|
|
1059
1102
|
return;
|
|
1060
|
-
tell("onAnimationComplete", callback, definition);
|
|
1103
|
+
completeFailing = tell("onAnimationComplete", callback, definition, completeFailing);
|
|
1061
1104
|
},
|
|
1062
1105
|
namesSettled: (names, config) => {
|
|
1063
1106
|
const callback = config.onAnimationComplete;
|
|
1064
1107
|
if (Predicate.isUndefined(callback))
|
|
1065
1108
|
return;
|
|
1066
|
-
Arr.forEach(names, (name) =>
|
|
1109
|
+
Arr.forEach(names, (name) => {
|
|
1110
|
+
completeFailing = tell("onAnimationComplete", callback, name, completeFailing);
|
|
1111
|
+
});
|
|
1067
1112
|
},
|
|
1068
1113
|
};
|
|
1069
1114
|
};
|
|
@@ -1081,7 +1126,7 @@ const baseTargetOf = (own, variant, variants, custom, state, initialLink) => {
|
|
|
1081
1126
|
return VariantTarget.resolveTarget(own, variants, custom, state);
|
|
1082
1127
|
if (Predicate.isNotUndefined(variant))
|
|
1083
1128
|
return VariantTarget.resolveTarget(variant, variants, custom, state);
|
|
1084
|
-
return { values: initialLink, transition: undefined, transitionEnd: undefined, keyframes: undefined };
|
|
1129
|
+
return { values: initialLink, transition: undefined, transitionEnd: undefined, keyframes: undefined, failure: VariantTarget.NO_FAILURE };
|
|
1085
1130
|
};
|
|
1086
1131
|
/**
|
|
1087
1132
|
* The Override stack resolved (ascending priority, Motion's `variantPriorityOrder`): base (animate, or
|
|
@@ -1190,14 +1235,105 @@ const withGestures = (c, parent, layers, base, variant, active, transition, stat
|
|
|
1190
1235
|
*/
|
|
1191
1236
|
export const startOf = (config, parent, presenceBlocks, untrack) => {
|
|
1192
1237
|
const startedAtAnimate = VariantTree.startsAtAnimate(config, parent, presenceBlocks);
|
|
1193
|
-
|
|
1238
|
+
// Its variants resolved once (#277), what a resolver among them threw beside them (#979): one value
|
|
1239
|
+
// for an element with no variants, so its start makes nothing more (bench:solid's mount).
|
|
1240
|
+
const variants = VariantTarget.startingVariantsOf(config.variants, config.custom);
|
|
1241
|
+
const initialValues = VariantTree.startingValuesFrom(config, parent, presenceBlocks, untrack, variants.variants);
|
|
1194
1242
|
return {
|
|
1195
1243
|
quiet: VariantTree.startsQuiet(config, parent, presenceBlocks, untrack),
|
|
1196
1244
|
initialValues,
|
|
1197
1245
|
initialLink: Bool.match(startedAtAnimate, { onTrue: () => ({}), onFalse: () => initialValues }),
|
|
1198
1246
|
startedLink: Bool.match(startedAtAnimate, { onTrue: () => initialValues, onFalse: () => ({}) }),
|
|
1247
|
+
failure: variants.failure,
|
|
1199
1248
|
};
|
|
1200
1249
|
};
|
|
1250
|
+
/** How a variant's failure is reported under `message`, on a runtime: at Error, its cause what the resolver threw, annotated with the variant's name. */
|
|
1251
|
+
const failedOn = (message) => (runtime) => (failure) => {
|
|
1252
|
+
runtime.runFork(Effect.annotateLogs(Report.failure(message, Cause.die(failure.defect)), { variant: failure.name }));
|
|
1253
|
+
};
|
|
1254
|
+
/** How an element's variant that throws is reported, on its runtime. */
|
|
1255
|
+
const variantFailedOn = failedOn("wardic.ward: a variant failed");
|
|
1256
|
+
/** How an exit whose resolver throws is reported, on `runtime`, each time an element leaves: its element leaves without it (#979). */
|
|
1257
|
+
export const exitVariantFailedOn = failedOn("wardic.presence: an exit variant failed");
|
|
1258
|
+
/** An element's variant failure reported on Effect's default runtime: a server render's, which holds no app reporters (#979). */
|
|
1259
|
+
export const variantFailedOnServer = /*#__PURE__*/ variantFailedOn(VariantTree.ON_SERVER);
|
|
1260
|
+
/** The first of a list of entries' failures: built once, as it's asked per Retarget (#460, compose once). */
|
|
1261
|
+
const firstFailureOf = Arr.findFirst((layer) => layer.failure);
|
|
1262
|
+
/** The first of a resolution's entries' resolvers that threw, and its variant's name (#979). */
|
|
1263
|
+
export const failureOf = (resolution) => firstFailureOf(resolution.layers);
|
|
1264
|
+
/** An element's {@link VariantFailures}, none failing yet, reported on `runtime`. */
|
|
1265
|
+
// #979 (bench:solid's mount): one plain object an element, read by the functions below, not closures, and
|
|
1266
|
+
// holding its runtime: its report is made only at a failure. A report made once a runtime and found in a
|
|
1267
|
+
// WeakMap cost Solid 1's mount 6% (the lookup, an element).
|
|
1268
|
+
export const variantFailuresOf = (runtime) => ({ last: undefined, failing: undefined, delayFailing: false, runtime });
|
|
1269
|
+
/** Where a variant's failure was seen, until each resolves it again: its element's resolutions, and its orchestration. */
|
|
1270
|
+
const RESOLVING = 1;
|
|
1271
|
+
const ORCHESTRATING = 2;
|
|
1272
|
+
// #979 (ADR-0074; Q6 and its review): a resolver's throw is its element's alone. Each variant, by name,
|
|
1273
|
+
// is reported as it starts failing and fails until every place that saw it fail resolves it again, so
|
|
1274
|
+
// a throw its resolutions and its orchestration both see is reported once. Setup resolves with no
|
|
1275
|
+
// values, as orchestration does, so a setup failure counts for both: a resolver that throws only with
|
|
1276
|
+
// no values isn't reported again at the first change its orchestration reads.
|
|
1277
|
+
const failedAt = (failures, failure, at) => {
|
|
1278
|
+
const name = UndefinedOr.match(failure.name, { onDefined: identity, onUndefined: () => "" });
|
|
1279
|
+
if (Predicate.isUndefined(failures.failing))
|
|
1280
|
+
failures.failing = new Map();
|
|
1281
|
+
const before = failures.failing.get(name);
|
|
1282
|
+
if (Predicate.isUndefined(before)) {
|
|
1283
|
+
failures.failing.set(name, at);
|
|
1284
|
+
variantFailedOn(failures.runtime)(failure);
|
|
1285
|
+
return;
|
|
1286
|
+
}
|
|
1287
|
+
failures.failing.set(name, before | at);
|
|
1288
|
+
};
|
|
1289
|
+
const resolvedAt = (failing, name, at) => {
|
|
1290
|
+
if (Predicate.isUndefined(name))
|
|
1291
|
+
return;
|
|
1292
|
+
const before = failing.get(name);
|
|
1293
|
+
if (Predicate.isUndefined(before))
|
|
1294
|
+
return;
|
|
1295
|
+
const after = before & ~at;
|
|
1296
|
+
if (after === 0) {
|
|
1297
|
+
failing.delete(name);
|
|
1298
|
+
return;
|
|
1299
|
+
}
|
|
1300
|
+
failing.set(name, after);
|
|
1301
|
+
};
|
|
1302
|
+
/** `next`, else, while it carries a failure, the element's last good resolution: it keeps its target. */
|
|
1303
|
+
// Per Retarget, per element (#460, compose once): statements; nothing done while nothing fails.
|
|
1304
|
+
export const keptOf = (failures, next) => {
|
|
1305
|
+
const failure = failureOf(next);
|
|
1306
|
+
if (Option.isSome(failure)) {
|
|
1307
|
+
failedAt(failures, failure.value, RESOLVING);
|
|
1308
|
+
// The first one has no last good one: its failed entry resolved to nothing.
|
|
1309
|
+
const last = failures.last;
|
|
1310
|
+
if (Predicate.isUndefined(last))
|
|
1311
|
+
return next;
|
|
1312
|
+
return last;
|
|
1313
|
+
}
|
|
1314
|
+
failures.last = next;
|
|
1315
|
+
const failing = failures.failing;
|
|
1316
|
+
if (Predicate.isUndefined(failing) || failing.size === 0)
|
|
1317
|
+
return next;
|
|
1318
|
+
Arr.forEach(next.layers, (layer) => resolvedAt(failing, layer.name, RESOLVING));
|
|
1319
|
+
return next;
|
|
1320
|
+
};
|
|
1321
|
+
/** A start's failure, setup's or a re-entry's fresh start's: setup resolves as orchestration does, so it stands for both until each resolves the variant again. */
|
|
1322
|
+
export const reportStart = (failures, start) => {
|
|
1323
|
+
if (Option.isSome(start.failure))
|
|
1324
|
+
failedAt(failures, start.failure.value, RESOLVING | ORCHESTRATING);
|
|
1325
|
+
};
|
|
1326
|
+
/** What an element's orchestration resolves, told to its failures: made by a variant node that orchestrates. */
|
|
1327
|
+
export const orchestrationOf = (failures) => (entry, failure) => {
|
|
1328
|
+
if (Option.isSome(failure)) {
|
|
1329
|
+
failedAt(failures, failure.value, ORCHESTRATING);
|
|
1330
|
+
return;
|
|
1331
|
+
}
|
|
1332
|
+
const failing = failures.failing;
|
|
1333
|
+
if (Predicate.isUndefined(failing) || failing.size === 0)
|
|
1334
|
+
return;
|
|
1335
|
+
Arr.forEach(Arr.ensure(entry), (name) => resolvedAt(failing, name, ORCHESTRATING));
|
|
1336
|
+
};
|
|
1201
1337
|
/** A Snapshot seeded from the Starting values, velocities 0, so frame 1 flows out of the seed (no snap). */
|
|
1202
1338
|
export const snapshotOf = (start) => emptySnapshotOf({ ...start.initialValues });
|
|
1203
1339
|
/** A Snapshot of `values`, nothing moving: read as it is until a spine reads it. */
|
|
@@ -1704,20 +1840,15 @@ export const makeElementSpine = (options) => {
|
|
|
1704
1840
|
return undefined;
|
|
1705
1841
|
}, running));
|
|
1706
1842
|
}
|
|
1707
|
-
// A snap's or a blend's frames: merged into the Snapshot (ADR-0004), as the spring's are
|
|
1708
|
-
//
|
|
1709
|
-
//
|
|
1843
|
+
// A snap's or a blend's frames: merged into the Snapshot (ADR-0004) in place, as the spring's are
|
|
1844
|
+
// (#659; #895: a spread made a record per element per frame). A blend's last two are kept for its keys'
|
|
1845
|
+
// velocities (#464), copied, since its Frame is its run's, rewritten each tick (`keepFrame`).
|
|
1710
1846
|
const sink = (frame, dt) => {
|
|
1711
1847
|
const value = running.values(frame.value);
|
|
1712
|
-
|
|
1713
|
-
// Its first frame: from the Snapshot's values.
|
|
1714
|
-
if (Predicate.isUndefined(before))
|
|
1715
|
-
before = snapshot.values;
|
|
1716
|
-
running.before = before;
|
|
1848
|
+
keepFrame(running, frame, snapshot.values);
|
|
1717
1849
|
// Over the time its step covered (#865), its first's included: its run's dt, in ms.
|
|
1718
1850
|
running.lastStep = dt * 1000;
|
|
1719
|
-
|
|
1720
|
-
snapshot.values = { ...snapshot.values, ...value };
|
|
1851
|
+
Object.assign(snapshot.values, value);
|
|
1721
1852
|
gate.write(id, value);
|
|
1722
1853
|
recordFrame(value);
|
|
1723
1854
|
drew(running, frame.done, snapshot.now());
|
|
@@ -2165,7 +2296,7 @@ export const makeElementSpine = (options) => {
|
|
|
2165
2296
|
// Its transition asked last, for a key already there alone: per key, per Retarget. A quiet
|
|
2166
2297
|
// mount's never asks (#475): Motion animates nothing at a first render that starts at its
|
|
2167
2298
|
// `animate`, whatever velocity its transition gives (`animation-state.ts`, `shouldAnimate`).
|
|
2168
|
-
if (still && Predicate.isUndefined(stops) && (quiet || !givesVelocity(keyTransitionOf(resolution, groups, key, transition, elementTransition), key))) {
|
|
2299
|
+
if (still && Predicate.isUndefined(stops) && (quiet || !RetargetLegs.givesVelocity(keyTransitionOf(resolution, groups, key, transition, elementTransition), key))) {
|
|
2169
2300
|
if (Predicate.isUndefined(stays))
|
|
2170
2301
|
stays = new Set();
|
|
2171
2302
|
stays.add(key);
|
|
@@ -2189,6 +2320,21 @@ export const makeElementSpine = (options) => {
|
|
|
2189
2320
|
resolvedNow = t;
|
|
2190
2321
|
owners.forEach(giveUpUnresolved);
|
|
2191
2322
|
keepTheRest();
|
|
2323
|
+
// A key only `initial` sets stays where it put it (#1022), as Motion keeps it: at the first Retarget, one
|
|
2324
|
+
// the resolved target doesn't name joins the keys already there, written with them as the element's first
|
|
2325
|
+
// commit takes its Starting style off. The gate keeps it after; a later layer that sets it returns it as
|
|
2326
|
+
// any. A Batch member's are its Batch's, which draws its groups.
|
|
2327
|
+
if (Predicate.isUndefined(lastResolution)) {
|
|
2328
|
+
if (Predicate.isUndefined(member)) {
|
|
2329
|
+
Arr.forEach(Rec.keys(initialValues), (key) => {
|
|
2330
|
+
if (Object.hasOwn(resolved, key))
|
|
2331
|
+
return;
|
|
2332
|
+
if (Predicate.isUndefined(there))
|
|
2333
|
+
there = {};
|
|
2334
|
+
there[key] = UndefinedOr.getOrThrow(snapshot.values[key]);
|
|
2335
|
+
});
|
|
2336
|
+
}
|
|
2337
|
+
}
|
|
2192
2338
|
// The keys this Retarget starts legs for: all of them, unless some stay.
|
|
2193
2339
|
let fresh = t;
|
|
2194
2340
|
if (Predicate.isNotUndefined(stays)) {
|
|
@@ -2271,7 +2417,7 @@ export const makeElementSpine = (options) => {
|
|
|
2271
2417
|
// animation is skipped (#468): the keys found above, and those Keyframes of two stops start from their first.
|
|
2272
2418
|
let measured;
|
|
2273
2419
|
if (!reduce && !skipped && (Predicate.isNotUndefined(measuring) || Predicate.isNotUndefined(keyframesNow))) {
|
|
2274
|
-
measured = measuredOf(measuredPairs, element, measuringOf(measuring, keyframesNow), from, fresh, snapshot.values, manyStops);
|
|
2420
|
+
measured = measuredOf(measuredPairs, element, measuringOf(measuring, keyframesNow), from, fresh, snapshot.values, manyStops, runtime, id);
|
|
2275
2421
|
}
|
|
2276
2422
|
let told;
|
|
2277
2423
|
if (!silent)
|
|
@@ -2291,12 +2437,16 @@ export const makeElementSpine = (options) => {
|
|
|
2291
2437
|
legGroups = split.tags;
|
|
2292
2438
|
}
|
|
2293
2439
|
// The Handoff (#48, ADR-0044 decision 6): the first Retarget that starts picks the Appear
|
|
2294
|
-
// animation up as far in as it has got, read at the legs' first tick.
|
|
2440
|
+
// animation up as far in as it has got, read at the legs' first tick. Its legs keep the frame
|
|
2441
|
+
// timeline's time, where the Appear animation's `currentTime` is (#1026).
|
|
2442
|
+
let takenOver = false;
|
|
2295
2443
|
if (Predicate.isNotUndefined(handoff)) {
|
|
2444
|
+
takenOver = true;
|
|
2296
2445
|
const taken = handoff;
|
|
2297
2446
|
handoff = undefined;
|
|
2298
2447
|
if (Predicate.isNotUndefined(diagnostics)) {
|
|
2299
|
-
|
|
2448
|
+
// With the keys it leaves where they are (#1004), which the server's rule holds beside the moving ones.
|
|
2449
|
+
diagnostics.checkHandoff(runtime, id, taken, { tag, from, to: fresh, transition: baseTransition, reduced: reduce, layout: isLayoutNode(c), stops: manyStops, ...AppearHandoff.skippedField(skipped), ...templateField(c.transformTemplate), held: there });
|
|
2300
2450
|
}
|
|
2301
2451
|
const at = AppearHandoff.startAtOf(taken, baseTransition, delayOf(transition));
|
|
2302
2452
|
retargetLegs = Arr.map(retargetLegs, (one) => RetargetLegs.startingAt(one, at));
|
|
@@ -2341,7 +2491,7 @@ export const makeElementSpine = (options) => {
|
|
|
2341
2491
|
Arr.forEach(retargetLegs, (leg, i) => {
|
|
2342
2492
|
if (Predicate.isNotUndefined(legGates))
|
|
2343
2493
|
gateNow = legGates[i];
|
|
2344
|
-
const running = runningOf(leg.to, resolution, landing, leg._tag);
|
|
2494
|
+
const running = runningOf(leg.to, resolution, landing, leg._tag, takenOver);
|
|
2345
2495
|
own(running);
|
|
2346
2496
|
runLeg(running, legProgram(leg, running, variables));
|
|
2347
2497
|
});
|