@wardic/core 1.3.2 → 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/Arc.d.ts +2 -2
- package/dist/Arc.js +1 -1
- package/dist/BaseValue.d.ts +11 -10
- package/dist/BaseValue.d.ts.map +1 -1
- package/dist/BaseValue.js +12 -15
- package/dist/BaseValue.js.map +1 -1
- package/dist/Batch.d.ts +15 -5
- package/dist/Batch.d.ts.map +1 -1
- package/dist/Batch.js +218 -20
- package/dist/Batch.js.map +1 -1
- package/dist/Clock.d.ts +7 -7
- package/dist/Clock.d.ts.map +1 -1
- package/dist/Clock.js +17 -16
- package/dist/Clock.js.map +1 -1
- package/dist/DefaultTransition.d.ts +3 -2
- package/dist/DefaultTransition.d.ts.map +1 -1
- package/dist/DefaultTransition.js +5 -3
- package/dist/DefaultTransition.js.map +1 -1
- package/dist/Drag.d.ts +24 -9
- package/dist/Drag.d.ts.map +1 -1
- package/dist/Drag.js +10 -10
- package/dist/Drag.js.map +1 -1
- package/dist/DragActivity.js +3 -3
- package/dist/DragRecognizer.d.ts +5 -4
- package/dist/DragRecognizer.d.ts.map +1 -1
- package/dist/DragRecognizer.js +37 -14
- package/dist/DragRecognizer.js.map +1 -1
- package/dist/Easing.d.ts +1 -1
- package/dist/Easing.js +1 -1
- package/dist/Frame.d.ts.map +1 -1
- package/dist/Frame.js +5 -3
- package/dist/Frame.js.map +1 -1
- package/dist/InputFeed.d.ts +1 -1
- package/dist/InputFeed.js +2 -2
- package/dist/InputSource.d.ts +3 -3
- package/dist/InputSource.js +2 -2
- package/dist/Interpolator.d.ts +2 -2
- package/dist/Interpolator.js +2 -2
- package/dist/InterpolatorRegistry.d.ts +29 -15
- package/dist/InterpolatorRegistry.d.ts.map +1 -1
- package/dist/InterpolatorRegistry.js +17 -8
- package/dist/InterpolatorRegistry.js.map +1 -1
- package/dist/LiveValue.d.ts +7 -6
- package/dist/LiveValue.d.ts.map +1 -1
- package/dist/LiveValue.js +45 -14
- package/dist/LiveValue.js.map +1 -1
- package/dist/Machine.d.ts +7 -4
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +146 -45
- package/dist/Machine.js.map +1 -1
- package/dist/Playback.d.ts.map +1 -1
- package/dist/Playback.js +6 -1
- package/dist/Playback.js.map +1 -1
- package/dist/Projection.d.ts +9 -9
- package/dist/Projection.js +2 -2
- package/dist/Recognizer.d.ts +1 -1
- package/dist/Recognizer.js +6 -6
- package/dist/Recognizer.js.map +1 -1
- package/dist/ReducedMotion.d.ts +4 -4
- package/dist/ReducedMotion.js +6 -6
- package/dist/Renderer.d.ts +5 -5
- package/dist/Renderer.js +6 -6
- package/dist/Renderer.js.map +1 -1
- package/dist/Reorder.d.ts +1 -1
- package/dist/Reorder.d.ts.map +1 -1
- package/dist/Reorder.js +2 -1
- package/dist/Reorder.js.map +1 -1
- package/dist/ScrollSource.d.ts +1 -1
- package/dist/ScrollSource.d.ts.map +1 -1
- package/dist/Sequence.d.ts +1 -1
- package/dist/SharedSource.d.ts +3 -3
- package/dist/SharedSource.js +5 -5
- package/dist/SharedSource.js.map +1 -1
- package/dist/Spring.d.ts.map +1 -1
- package/dist/Spring.js +2 -1
- package/dist/Spring.js.map +1 -1
- package/dist/Values.d.ts +2 -2
- package/dist/Values.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/carried.d.ts +13 -0
- package/dist/internal/carried.d.ts.map +1 -0
- package/dist/internal/carried.js +23 -0
- package/dist/internal/carried.js.map +1 -0
- package/dist/internal/firstSteps.d.ts +66 -0
- package/dist/internal/firstSteps.d.ts.map +1 -0
- package/dist/internal/firstSteps.js +107 -0
- package/dist/internal/firstSteps.js.map +1 -0
- package/dist/internal/frameLoop.d.ts +1 -1
- package/dist/internal/frameLoop.d.ts.map +1 -1
- package/dist/internal/frameLoop.js +102 -81
- package/dist/internal/frameLoop.js.map +1 -1
- package/dist/internal/lerpsNumbers.d.ts +11 -0
- package/dist/internal/lerpsNumbers.d.ts.map +1 -0
- package/dist/internal/lerpsNumbers.js +38 -0
- package/dist/internal/lerpsNumbers.js.map +1 -0
- package/dist/internal/options.d.ts +7 -7
- package/dist/internal/options.d.ts.map +1 -1
- package/dist/internal/options.js +10 -10
- package/dist/internal/options.js.map +1 -1
- package/dist/internal/stepper.d.ts +13 -2
- package/dist/internal/stepper.d.ts.map +1 -1
- package/dist/internal/stepper.js +16 -1
- package/dist/internal/stepper.js.map +1 -1
- package/dist/internal/tracing.d.ts +1 -1
- package/dist/internal/tracing.js +1 -1
- package/dist/unstable/AnimationControls.d.ts +37 -38
- package/dist/unstable/AnimationControls.d.ts.map +1 -1
- package/dist/unstable/AnimationControls.js +39 -36
- package/dist/unstable/AnimationControls.js.map +1 -1
- package/dist/unstable/AppearHandoff.d.ts +5 -5
- package/dist/unstable/AppearHandoff.d.ts.map +1 -1
- package/dist/unstable/BatchCalls.d.ts +2 -2
- package/dist/unstable/BatchCalls.js +5 -5
- package/dist/unstable/Config.d.ts +19 -19
- package/dist/unstable/Config.d.ts.map +1 -1
- package/dist/unstable/FirstSteps.d.ts +25 -0
- package/dist/unstable/FirstSteps.d.ts.map +1 -0
- package/dist/unstable/FirstSteps.js +2 -0
- package/dist/unstable/FirstSteps.js.map +1 -0
- package/dist/unstable/FlushGate.d.ts +53 -51
- package/dist/unstable/FlushGate.d.ts.map +1 -1
- package/dist/unstable/FlushGate.js +56 -49
- package/dist/unstable/FlushGate.js.map +1 -1
- package/dist/unstable/FrameEffects.d.ts +2 -2
- package/dist/unstable/FrameEffects.js +2 -2
- package/dist/unstable/FrameTime.d.ts +1 -1
- package/dist/unstable/FrameTime.js +1 -1
- package/dist/unstable/Imperative.d.ts +29 -9
- package/dist/unstable/Imperative.d.ts.map +1 -1
- package/dist/unstable/Imperative.js +79 -47
- package/dist/unstable/Imperative.js.map +1 -1
- package/dist/unstable/OwnValues.js +1 -1
- package/dist/unstable/PresenceRecord.d.ts +26 -26
- package/dist/unstable/PresenceRecord.d.ts.map +1 -1
- package/dist/unstable/PresenceRecord.js +8 -8
- package/dist/unstable/PresenceRecord.js.map +1 -1
- package/dist/unstable/Projector.d.ts +34 -0
- package/dist/unstable/Projector.d.ts.map +1 -0
- package/dist/unstable/Projector.js +9 -0
- package/dist/unstable/Projector.js.map +1 -0
- package/dist/unstable/Report.d.ts +1 -1
- package/dist/unstable/Report.js +1 -1
- package/dist/unstable/RetargetLegs.d.ts +1 -1
- package/dist/unstable/RetargetLegs.d.ts.map +1 -1
- package/dist/unstable/RetargetLegs.js +9 -8
- package/dist/unstable/RetargetLegs.js.map +1 -1
- package/dist/unstable/Spine.d.ts +81 -72
- package/dist/unstable/Spine.d.ts.map +1 -1
- package/dist/unstable/Spine.js +152 -150
- package/dist/unstable/Spine.js.map +1 -1
- package/dist/unstable/Stops.d.ts +3 -3
- package/dist/unstable/Stops.js +4 -4
- package/dist/unstable/Subject.d.ts +2 -2
- package/dist/unstable/Subject.js +2 -2
- package/dist/unstable/Timelines.d.ts +11 -11
- package/dist/unstable/Timelines.d.ts.map +1 -1
- package/dist/unstable/Timelines.js +3 -3
- package/dist/unstable/VariantTarget.d.ts +7 -7
- package/dist/unstable/VariantTarget.d.ts.map +1 -1
- package/dist/unstable/VariantTarget.js +11 -11
- package/dist/unstable/VariantTarget.js.map +1 -1
- package/dist/unstable/VariantTree.d.ts +36 -36
- package/dist/unstable/VariantTree.d.ts.map +1 -1
- package/dist/unstable/VariantTree.js +33 -33
- package/dist/unstable/VariantTree.js.map +1 -1
- package/dist/unstable/WardicConfigValue.d.ts +13 -13
- package/dist/unstable/WardicConfigValue.d.ts.map +1 -1
- package/dist/unstable/WardicConfigValue.js +4 -4
- package/dist/unstable/WardicConfigValue.js.map +1 -1
- package/package.json +1 -1
- package/src/Arc.ts +3 -3
- package/src/BaseValue.ts +18 -21
- package/src/Batch.ts +236 -22
- package/src/Clock.ts +18 -17
- package/src/DefaultTransition.ts +5 -3
- package/src/Drag.ts +32 -14
- package/src/DragActivity.ts +3 -3
- package/src/DragRecognizer.ts +41 -16
- package/src/Easing.ts +1 -1
- package/src/Frame.ts +5 -3
- package/src/InputFeed.ts +2 -2
- package/src/InputSource.ts +5 -5
- package/src/Interpolator.ts +3 -3
- package/src/InterpolatorRegistry.ts +22 -13
- package/src/LiveValue.ts +47 -17
- package/src/Machine.ts +199 -61
- package/src/Playback.ts +5 -1
- package/src/Projection.ts +9 -9
- package/src/Recognizer.ts +7 -7
- package/src/ReducedMotion.ts +6 -6
- package/src/Renderer.ts +6 -6
- package/src/Reorder.ts +3 -2
- package/src/ScrollSource.ts +1 -1
- package/src/Sequence.ts +1 -1
- package/src/SharedSource.ts +5 -5
- package/src/Spring.ts +2 -1
- package/src/Values.ts +2 -2
- package/src/index.ts +1 -1
- package/src/internal/carried.ts +22 -0
- package/src/internal/firstSteps.ts +139 -0
- package/src/internal/frameLoop.ts +103 -87
- package/src/internal/lerpsNumbers.ts +53 -0
- package/src/internal/options.ts +10 -10
- package/src/internal/stepper.ts +20 -2
- package/src/internal/tracing.ts +1 -1
- package/src/unstable/AnimationControls.ts +59 -56
- package/src/unstable/AppearHandoff.ts +6 -6
- package/src/unstable/BatchCalls.ts +5 -5
- package/src/unstable/Config.ts +19 -19
- package/src/unstable/FirstSteps.ts +26 -0
- package/src/unstable/FlushGate.ts +92 -82
- package/src/unstable/FrameEffects.ts +2 -2
- package/src/unstable/FrameTime.ts +1 -1
- package/src/unstable/Imperative.ts +126 -56
- package/src/unstable/OwnValues.ts +1 -1
- package/src/unstable/PresenceRecord.ts +29 -29
- package/src/unstable/Projector.ts +45 -0
- package/src/unstable/Report.ts +1 -1
- package/src/unstable/RetargetLegs.ts +10 -9
- package/src/unstable/Spine.ts +190 -188
- package/src/unstable/Stops.ts +6 -6
- package/src/unstable/Subject.ts +2 -2
- package/src/unstable/Timelines.ts +12 -12
- package/src/unstable/VariantTarget.ts +13 -13
- package/src/unstable/VariantTree.ts +42 -42
- package/src/unstable/WardicConfigValue.ts +13 -13
package/src/Machine.ts
CHANGED
|
@@ -51,6 +51,7 @@ import * as Frame from "./Frame.ts"
|
|
|
51
51
|
import * as FrameLoop from "./FrameLoop.ts"
|
|
52
52
|
import * as InterpolatorRegistry from "./InterpolatorRegistry.ts"
|
|
53
53
|
import { sourceOf } from "./internal/driven.ts"
|
|
54
|
+
import * as LerpsNumbers from "./internal/lerpsNumbers.ts"
|
|
54
55
|
import { cachedResolver, checked, finite } from "./internal/options.ts"
|
|
55
56
|
import {
|
|
56
57
|
initDecay,
|
|
@@ -72,8 +73,10 @@ import {
|
|
|
72
73
|
stepTween,
|
|
73
74
|
type WritableFrame,
|
|
74
75
|
TweenFields,
|
|
76
|
+
TweenFrame,
|
|
75
77
|
} from "./internal/stepper.ts"
|
|
76
78
|
import * as Inertia from "./Inertia.ts"
|
|
79
|
+
import * as Scalar from "./Scalar.ts"
|
|
77
80
|
import type * as Point from "./Point.ts"
|
|
78
81
|
import * as Spring from "./Spring.ts"
|
|
79
82
|
import * as UnitScale from "./UnitScale.ts"
|
|
@@ -167,7 +170,7 @@ export const isMachine = (u: unknown): u is Machine<Frame.Frame<unknown>> => Pre
|
|
|
167
170
|
*/
|
|
168
171
|
// Every constructor clamps each step's `dt` here once (#78), in its leaves' steps and in `delay`'s hold,
|
|
169
172
|
// so both drivers clamp and no stepper needs to defend itself; dom's projection pass clamps its own.
|
|
170
|
-
// Inline, not a `clampDt` layer: a layer is one more call per
|
|
173
|
+
// Inline, not a `clampDt` layer: a layer is one more call per Subject per frame, which V8 doesn't
|
|
171
174
|
// inline (ADR-0028, *Implementation in #94*). Why 500 ms (#23, ADR-0017 *Amendment (#23)*): a stall up
|
|
172
175
|
// to it reaches each consumer whole, so a tween, a spring, decay, inertia or a layout animation lands
|
|
173
176
|
// where wall time puts it, as Motion's time-based animations do; a longer one advances it 500 ms. It
|
|
@@ -763,7 +766,7 @@ export type Streamed<F> = F extends Frame.SpringValues ? Frame.MultiPhysics : F
|
|
|
763
766
|
// with its attributes; per-frame work is unlogged. Every Frame is copied (`owned`) before it's
|
|
764
767
|
// emitted, so a consumer that collects Frames never sees one rewritten (ADR-0030, decision 11; #895). A
|
|
765
768
|
// Stream, not a Channel: measured 2026-11-02, Stream's own layers were ~5% of a pull of the Clock's
|
|
766
|
-
// ticks, and
|
|
769
|
+
// ticks, and Subjects never use `toStream`, so a Channel would gain nothing measurable (#618, M5).
|
|
767
770
|
export const toStream = <F extends Frame.Frame<unknown>>(self: Machine<F>): Stream.Stream<Streamed<F>, never, Clock.Clock> =>
|
|
768
771
|
Stream.unwrap(
|
|
769
772
|
Effect.gen(function* () {
|
|
@@ -794,8 +797,8 @@ export const toStream = <F extends Frame.Frame<unknown>>(self: Machine<F>): Stre
|
|
|
794
797
|
// A plain call, typed `(frame) => undefined`, so a sink that returns an Effect doesn't compile
|
|
795
798
|
// (ADR-0027, decision 8). Dies if the step or the sink throws, or with the loop's own failure. One span
|
|
796
799
|
// per run, with a `<name>: start` debug log. The token (#200, ADR-0027 *Amendment (#200)*): it leaves the
|
|
797
|
-
// loop at once, as an interrupted run does, about a sixth of the cost. `springValues`, a tween
|
|
798
|
-
// blends rewrite one Frame per run (ADR-0030, decision 11 and *
|
|
800
|
+
// loop at once, as an interrupted run does, about a sixth of the cost. `springValues`, a tween, the
|
|
801
|
+
// blends and `keyframesValues` rewrite one Frame per run (ADR-0030, decision 11 and *Amendments (#895, #1031)*). A machine built with a service: `Effect.flatMap(Machine.run(sink))`.
|
|
799
802
|
export const run: {
|
|
800
803
|
<F extends Frame.Frame<unknown>>(sink: FrameLoop.Sink<F>): (self: Machine<F>) => Effect.Effect<F, never, FrameLoop.FrameLoop>
|
|
801
804
|
<F extends Frame.Frame<unknown>>(
|
|
@@ -817,11 +820,13 @@ export const run: {
|
|
|
817
820
|
|
|
818
821
|
/**
|
|
819
822
|
* `run`'s options: the token the run joins, so `Supersede.end` ends it with the others; and whether the
|
|
820
|
-
* run keeps the frame timeline's time,
|
|
821
|
-
*
|
|
823
|
+
* run keeps the frame timeline's time, so the Frame loop never leaves a late frame's time out of its first
|
|
824
|
+
* steps (`Clock.LateFrames`): one whose start is read from it (an Appear animation's `currentTime`), or one
|
|
825
|
+
* that reports the frames' time rather than animating from a start (`LiveValue.time`, `eachFrame` and
|
|
826
|
+
* `velocity`).
|
|
822
827
|
*/
|
|
823
|
-
// #200; #1026: a run on
|
|
824
|
-
// out, and is right that way.
|
|
828
|
+
// #200; #1026: a run on a clock of its own (a video's `currentTime`, its own `performance.now()` reads) leaves
|
|
829
|
+
// `onFrameTimeline` out, and is right that way: the Frame loop's dt isn't its time.
|
|
825
830
|
export interface RunOptions {
|
|
826
831
|
readonly supersede?: Supersede.Supersede | undefined
|
|
827
832
|
readonly onFrameTimeline?: boolean | undefined
|
|
@@ -838,7 +843,7 @@ const tweenLeaf = (from: number, to: number, tween: ResolvedTween, span: Span):
|
|
|
838
843
|
span,
|
|
839
844
|
start: () => {
|
|
840
845
|
const state = initTween()
|
|
841
|
-
const frame
|
|
846
|
+
const frame = new TweenFrame(from)
|
|
842
847
|
// Per frame (ADR-0025): the tween resolved when the machine is built, `dt` clamped (#78).
|
|
843
848
|
return (dt) => {
|
|
844
849
|
stepTween(state, frame, Math.min(dt, MAX_DT), from, to, tween)
|
|
@@ -1386,7 +1391,7 @@ const resolveAnimate: (options: AnimateOptions) => ResolvedAnimate = cachedResol
|
|
|
1386
1391
|
*/
|
|
1387
1392
|
// #77, #91. One leaf over one frame time, as Motion's `JSAnimation` is (#226): each step adds its `dt`
|
|
1388
1393
|
// (clamped at `MAX_DT`) and reads the run's pass, the time into it and its direction off the total, so a
|
|
1389
|
-
// tick across a turn
|
|
1394
|
+
// tick across a turn draws that tick's value, not the turn. Then `delay(options.delay)`, and its own
|
|
1390
1395
|
// span, `wardic.animate`.
|
|
1391
1396
|
export const animate = (from: number, to: number, options: AnimateOptions = NO_OPTIONS): Machine<Frame.Frame<number>> => {
|
|
1392
1397
|
const resolved = resolveAnimate(options)
|
|
@@ -1483,27 +1488,82 @@ export const keyframes = (stops: ReadonlyArray<number>, options: KeyframesOption
|
|
|
1483
1488
|
/** One key's blend at a progress `t`, given whether that progress Frame is the run's last. */
|
|
1484
1489
|
type Blender = InterpolatorRegistry.KeyBlend
|
|
1485
1490
|
|
|
1491
|
+
/** An `InterpolatorRegistry`'s service. */
|
|
1492
|
+
type Registry = InterpolatorRegistry.InterpolatorRegistry["Service"]
|
|
1493
|
+
|
|
1494
|
+
/**
|
|
1495
|
+
* How a key moves from one value to the next, decided once per leg: a `Lerp` is a pair of numbers core's
|
|
1496
|
+
* number blend takes, computed in the run's loop from its ends; a `Blend` is any other, through its blender.
|
|
1497
|
+
*/
|
|
1498
|
+
// #1036 (ADR-0030, *Amendment (#1036)*): the number blend's frames with no call to make.
|
|
1499
|
+
type Plan =
|
|
1500
|
+
| { readonly _tag: "Lerp"; readonly from: number; readonly to: number }
|
|
1501
|
+
| { readonly _tag: "Blend"; readonly blend: Blender }
|
|
1502
|
+
|
|
1503
|
+
/** A key's plan through its blender. */
|
|
1504
|
+
const blendPlan = (blend: Blender): Plan => ({ _tag: "Blend", blend })
|
|
1505
|
+
|
|
1506
|
+
/** A key's plan computed in the loop, from `from` to `to`. */
|
|
1507
|
+
const lerpPlan = (from: number, to: number): Plan => ({ _tag: "Lerp", from, to })
|
|
1508
|
+
|
|
1509
|
+
/**
|
|
1510
|
+
* A leg's plans laid out for its run's loop: key `i`'s blender at `blenders[i]`, `null` for a `Lerp`, whose
|
|
1511
|
+
* ends are at `2i` and `2i + 1` of `ends`.
|
|
1512
|
+
*/
|
|
1513
|
+
// #1036: the layout measured fastest. A key that isn't a `Lerp` reads what it read before; a flag and each end in
|
|
1514
|
+
// arrays of their own lost most of keyframes' gain, and cost 4–9% where no key was a `Lerp`. The ends in a plain
|
|
1515
|
+
// array: a `Float64Array` cost each start 230–565 B more, and no less a frame.
|
|
1516
|
+
interface Lanes {
|
|
1517
|
+
readonly blenders: ReadonlyArray<Blender | null>
|
|
1518
|
+
readonly ends: ReadonlyArray<number>
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1521
|
+
/** A plan's blender, `null` for a `Lerp`. */
|
|
1522
|
+
const blenderOf = (plan: Plan): Blender | null => {
|
|
1523
|
+
if (plan._tag === "Lerp") return null
|
|
1524
|
+
return plan.blend
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
/** `plans`, laid out. */
|
|
1528
|
+
const lanesOf = (plans: ReadonlyArray<Plan>): Lanes => {
|
|
1529
|
+
// Per leg (#460): `Arr`'s loops.
|
|
1530
|
+
const ends = new Array<number>(2 * plans.length).fill(0)
|
|
1531
|
+
Arr.forEach(plans, (plan, i) => {
|
|
1532
|
+
if (plan._tag === "Blend") return
|
|
1533
|
+
ends[2 * i] = plan.from
|
|
1534
|
+
ends[2 * i + 1] = plan.to
|
|
1535
|
+
})
|
|
1536
|
+
return { blenders: Arr.map(plans, blenderOf), ends }
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
/** Each key of a leg, in `to`'s order, and its lanes. */
|
|
1540
|
+
interface KeyLanes {
|
|
1541
|
+
readonly keys: ReadonlyArray<string>
|
|
1542
|
+
readonly lanes: Lanes
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1486
1545
|
/**
|
|
1487
|
-
* Each key's
|
|
1546
|
+
* Each key's plan from `from[key]` (its target when absent) to `to[key]`, built once through the
|
|
1488
1547
|
* `InterpolatorRegistry`.
|
|
1489
1548
|
*
|
|
1490
1549
|
* - **A Key rule first** (ADR-0035): the Environment's rule for the key by name, when one takes the
|
|
1491
1550
|
* pair, gives the key's whole blend. Core holds none. `@wardic/dom`'s keep a key that hides an
|
|
1492
|
-
*
|
|
1551
|
+
* Subject at its old value until the run's last Frame (ADR-0024, decision 4), grow a value from its
|
|
1493
1552
|
* Animatable none (ADR-0015, *Amendment (#61)*), and blend a list item by item.
|
|
1494
1553
|
* - **Else by value**: the registry's blend. A pair it can't blend is a Discrete pair and switches
|
|
1495
|
-
* at the first Frame past 0 (ADR-0024, decision 3).
|
|
1554
|
+
* at the first Frame past 0 (ADR-0024, decision 3). A pair of numbers the registry blends with
|
|
1555
|
+
* core's number blend is a `Lerp`.
|
|
1496
1556
|
*/
|
|
1497
|
-
const
|
|
1557
|
+
const keyLanesFor: (
|
|
1498
1558
|
from: Readonly<Values.Values>,
|
|
1499
1559
|
to: Readonly<Values.Values>,
|
|
1500
|
-
) => Effect.Effect<
|
|
1560
|
+
) => Effect.Effect<KeyLanes, never, InterpolatorRegistry.InterpolatorRegistry> =
|
|
1501
1561
|
// Per leg (#460): one Effect a key, in `to`'s order, and no record built between.
|
|
1502
1562
|
Effect.fnUntraced(function* (from: Readonly<Values.Values>, to: Readonly<Values.Values>) {
|
|
1503
|
-
const
|
|
1563
|
+
const plan = yield* planner
|
|
1504
1564
|
const keys = Rec.keys(to)
|
|
1505
|
-
const
|
|
1506
|
-
return
|
|
1565
|
+
const plans = yield* Effect.forEach(keys, (key) => plan(key, startOf(from, key, to[key]), to[key]))
|
|
1566
|
+
return { keys, lanes: lanesOf(plans) }
|
|
1507
1567
|
})
|
|
1508
1568
|
|
|
1509
1569
|
/** `key`'s start in `from`, else its target `b`: a statement (#460), as `Rec.get` reads an own key. */
|
|
@@ -1512,23 +1572,69 @@ const startOf = (from: Values.Values, key: string, b: number | string): number |
|
|
|
1512
1572
|
return from[key]
|
|
1513
1573
|
}
|
|
1514
1574
|
|
|
1515
|
-
/** `key`'s
|
|
1516
|
-
|
|
1575
|
+
/** A leg's planner: `key`'s plan from `a` to `b` ({@link keyLanesFor}'s, and each of a keyframes Interval's, #429). */
|
|
1576
|
+
type Planner = (key: string, a: number | string, b: number | string) => Effect.Effect<Plan>
|
|
1577
|
+
|
|
1578
|
+
/** `registry`'s planner, its number check read once a leg. */
|
|
1579
|
+
const plannerOf = (registry: Registry): Planner => {
|
|
1580
|
+
const lerps = LerpsNumbers.lerpsNumbersOf(registry)
|
|
1581
|
+
// Per key, each leg (#460): statements. #1036: a Key rule is asked first, and keeps any pair it takes; the
|
|
1582
|
+
// registry then says whether core's number blend reads a pair of numbers, not a kind an app registered ahead.
|
|
1583
|
+
return (key, a, b) => {
|
|
1584
|
+
const ruled = registry.keyBlendOf(key, a, b)
|
|
1585
|
+
if (Option.isSome(ruled)) return Effect.map(ruled.value, blendPlan)
|
|
1586
|
+
if (Predicate.isString(a)) return resolvedPlan(registry, a, b)
|
|
1587
|
+
if (Predicate.isString(b)) return resolvedPlan(registry, a, b)
|
|
1588
|
+
if (lerps(a, b)) return Effect.succeed(lerpPlan(a, b))
|
|
1589
|
+
return resolvedPlan(registry, a, b)
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
/** The Environment's planner. */
|
|
1594
|
+
const planner: Effect.Effect<Planner, never, InterpolatorRegistry.InterpolatorRegistry> = Effect.map(InterpolatorRegistry.InterpolatorRegistry, plannerOf)
|
|
1595
|
+
|
|
1596
|
+
/** The registry's blend of `a` and `b`, as a plan. */
|
|
1597
|
+
const resolvedPlan = (registry: Registry, a: number | string, b: number | string): Effect.Effect<Plan> =>
|
|
1517
1598
|
// No rule takes it: the registry's blend, through a blender made here, as before #61. A blender
|
|
1518
1599
|
// made by one shared factory for every key made its call site megamorphic, and Node's string
|
|
1519
1600
|
// workloads 7–9% slower per frame (#61's bench).
|
|
1520
|
-
|
|
1601
|
+
Effect.map(registry.resolve(a, b), (blend) => blendPlan((t) => blend(t)))
|
|
1602
|
+
|
|
1603
|
+
/**
|
|
1604
|
+
* A blend run's record of `keys`, each key there from the start, unset: a number stored there each frame is
|
|
1605
|
+
* boxed once, and every copy of the record takes that box as it is. Made empty, V8 would keep a number
|
|
1606
|
+
* key's field a raw number, and a copy that reads it would box it again.
|
|
1607
|
+
*/
|
|
1608
|
+
// #1031 (ADR-0030, *Amendment (#1031)*): Chromium's `Object.assign` boxed each number at each of the Blend
|
|
1609
|
+
// sink's three copies a frame (the Snapshot, `keepFrame`'s record, the gate's `write`), 12 B a key each. V8
|
|
1610
|
+
// decides a field's form from its first value: `null` keeps it one that holds anything.
|
|
1611
|
+
// Per Subject at mount (#540): a loop. It runs at each run's start, a mount's and a Retarget's, over the items, each
|
|
1612
|
+
// key read by a function made once, so a start makes its record and nothing else: an `Arr.map` of the keys and an
|
|
1613
|
+
// `Arr.reduce` cost each start 300 B, and bench:solid's bytes per element per round +2% (#1031).
|
|
1614
|
+
const seededRecordOf = <A>(items: ReadonlyArray<A>, keyOf: (item: A) => string): Record<string, number | string> => {
|
|
1615
|
+
const record: Record<string, number | string | null> = {}
|
|
1616
|
+
for (let i = 0; i < items.length; i++) {
|
|
1617
|
+
const key = keyOf(items[i])
|
|
1618
|
+
// `__proto__` would set the record's prototype, not add a key: its first store meets it as before.
|
|
1619
|
+
if (key !== "__proto__") record[key] = null
|
|
1620
|
+
}
|
|
1621
|
+
return record as Record<string, number | string>
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
/** A keyframes Track's key. */
|
|
1625
|
+
const trackKey = (track: Track): string => track.key
|
|
1521
1626
|
|
|
1522
1627
|
/**
|
|
1523
1628
|
* `progress`'s run with every key blended at the progress `at` reads off its Frame. On the per-frame path
|
|
1524
|
-
* (ADR-0025): a loop over the
|
|
1525
|
-
* record and then reassigns every key
|
|
1629
|
+
* (ADR-0025): a loop over the keys and their lanes, laid out with the leg, not `Rec.map`, which spreads the
|
|
1630
|
+
* record and then reassigns every key.
|
|
1526
1631
|
*/
|
|
1632
|
+
// #63 measured `Rec.map` 1.6× this loop in Chromium, 2.3× in JSC.
|
|
1527
1633
|
// In place (#895, ADR-0030 *Amendment (#895)*): its record and its Frame are its run's, made at `start()` and
|
|
1528
1634
|
// rewritten each tick, as `springValues`' are (decision 11); `toStream` copies what it emits.
|
|
1529
1635
|
const blendedBy = <F extends Frame.Frame<unknown>>(
|
|
1530
1636
|
progress: Machine<F>,
|
|
1531
|
-
|
|
1637
|
+
{ keys, lanes }: KeyLanes,
|
|
1532
1638
|
at: (frame: F) => number,
|
|
1533
1639
|
): Machine<Frame.Frame<Values.Values>> =>
|
|
1534
1640
|
make({
|
|
@@ -1536,13 +1642,23 @@ const blendedBy = <F extends Frame.Frame<unknown>>(
|
|
|
1536
1642
|
span: progress.span,
|
|
1537
1643
|
start: () => {
|
|
1538
1644
|
const step = progress.start()
|
|
1539
|
-
const frame: WritableFrame<Record<string, number | string>> = { value:
|
|
1645
|
+
const frame: WritableFrame<Record<string, number | string>> = { value: seededRecordOf(keys, identity), done: false }
|
|
1646
|
+
const { blenders, ends } = lanes
|
|
1540
1647
|
return (dt) => {
|
|
1541
1648
|
const stepped = step(dt)
|
|
1542
1649
|
const t = at(stepped)
|
|
1543
1650
|
const done = stepped.done
|
|
1544
1651
|
const value = frame.value
|
|
1545
|
-
|
|
1652
|
+
// A `Lerp` through `Scalar.lerp`, the number blend's own step, so its frames are that blend's. In each
|
|
1653
|
+
// loop, not a function both call: called, one key's frame allocated 36.8 B in Node, not 20.8 (#1036).
|
|
1654
|
+
for (let i = 0; i < keys.length; i++) {
|
|
1655
|
+
const blend = blenders[i]
|
|
1656
|
+
if (Predicate.isNull(blend)) {
|
|
1657
|
+
value[keys[i]] = Scalar.lerp(ends[2 * i], ends[2 * i + 1], t)
|
|
1658
|
+
continue
|
|
1659
|
+
}
|
|
1660
|
+
value[keys[i]] = blend(t, done)
|
|
1661
|
+
}
|
|
1546
1662
|
frame.done = done
|
|
1547
1663
|
return frame
|
|
1548
1664
|
}
|
|
@@ -1559,7 +1675,7 @@ const springProgressOf = (frame: Frame.SpringValues): number => frame.positions[
|
|
|
1559
1675
|
* A bag of values tweened from `from` to `to`, each key blended as its Environment blends it: numbers,
|
|
1560
1676
|
* unit strings, complex values, and its own kinds, such as `@wardic/dom`'s colours. One tween drives every
|
|
1561
1677
|
* key, so the repeats and `delay` apply to the whole bag. A pair that can't blend switches at the first
|
|
1562
|
-
* frame; the Environment can hold a key until the last, as `@wardic/dom` does a key that hides
|
|
1678
|
+
* frame; the Environment can hold a key until the last, as `@wardic/dom` does a key that hides a Subject.
|
|
1563
1679
|
* Building it needs the `InterpolatorRegistry`, once. Its Frame and its record are the run's, rewritten
|
|
1564
1680
|
* every tick: copy one to keep it.
|
|
1565
1681
|
*
|
|
@@ -1567,19 +1683,19 @@ const springProgressOf = (frame: Frame.SpringValues): number => frame.positions[
|
|
|
1567
1683
|
* const fade = yield* Machine.animateValues({ opacity: 0, color: "#bf616a" }, { opacity: 1, color: "#a3be8c" }, { duration: 0.3 })
|
|
1568
1684
|
*/
|
|
1569
1685
|
// One `animate(0, 1, options)` progress drives every key; `done` is its Frame's. Key rules: ADR-0024,
|
|
1570
|
-
// ADR-0035. The registry is consulted once: each key resolves to a pure blender
|
|
1571
|
-
//
|
|
1686
|
+
// ADR-0035. The registry is consulted once: each key resolves to a pure blender, or, a pair of numbers
|
|
1687
|
+
// core's number blend takes, to its ends (#1036); per tick, a direct call for each key but those.
|
|
1572
1688
|
export const animateValues = (
|
|
1573
1689
|
from: Readonly<Values.Values>,
|
|
1574
1690
|
to: Readonly<Values.Values>,
|
|
1575
1691
|
options: AnimateOptions = NO_OPTIONS,
|
|
1576
1692
|
): Effect.Effect<Machine<Frame.Frame<Values.Values>>, never, InterpolatorRegistry.InterpolatorRegistry> =>
|
|
1577
1693
|
// Per leg (#460): the combinators called data-first.
|
|
1578
|
-
Effect.map(
|
|
1694
|
+
Effect.map(keyLanesFor(from, to), (keyed) =>
|
|
1579
1695
|
withSpan(
|
|
1580
|
-
blendedBy(animate(0, 1, options),
|
|
1696
|
+
blendedBy(animate(0, 1, options), keyed, tweenProgressOf),
|
|
1581
1697
|
"wardic.animateValues",
|
|
1582
|
-
{ attributes: { keys:
|
|
1698
|
+
{ attributes: { keys: keyed.keys.length } },
|
|
1583
1699
|
))
|
|
1584
1700
|
|
|
1585
1701
|
/**
|
|
@@ -1603,40 +1719,40 @@ export const springBlend = (
|
|
|
1603
1719
|
options: SpringOptions = NO_OPTIONS,
|
|
1604
1720
|
): Effect.Effect<Machine<Frame.Frame<Values.Values>>, never, InterpolatorRegistry.InterpolatorRegistry> =>
|
|
1605
1721
|
// Per leg (#460): the combinators called data-first.
|
|
1606
|
-
Effect.map(
|
|
1722
|
+
Effect.map(keyLanesFor(from, to), (keyed) =>
|
|
1607
1723
|
withSpan(
|
|
1608
1724
|
// Its one key read by index (#663).
|
|
1609
|
-
blendedBy(springValues({ progress: 100 }, options, { from: { progress: 0 }, velocity: { progress: 0 }, records: "value" }),
|
|
1725
|
+
blendedBy(springValues({ progress: 100 }, options, { from: { progress: 0 }, velocity: { progress: 0 }, records: "value" }), keyed, springProgressOf),
|
|
1610
1726
|
"wardic.springBlend",
|
|
1611
|
-
{ attributes: { keys:
|
|
1727
|
+
{ attributes: { keys: keyed.keys.length } },
|
|
1612
1728
|
))
|
|
1613
1729
|
|
|
1614
1730
|
/**
|
|
1615
|
-
* One key's keyframes in a bag (#429): its stops' times in a pass, and
|
|
1616
|
-
* read from first to last (`forward`) and, when a pass can read them from last to first,
|
|
1617
|
-
* too (`backward`), as Motion's mirrored generator builds its own.
|
|
1731
|
+
* One key's keyframes in a bag (#429): its stops' times in a pass, and each Interval's plan, laid out,
|
|
1732
|
+
* read from first to last (`forward`, `forwardEnds`) and, when a pass can read them from last to first,
|
|
1733
|
+
* that way too (`backward`, `backwardEnds`), as Motion's mirrored generator builds its own.
|
|
1618
1734
|
*/
|
|
1735
|
+
// #1036: each direction's lanes flat on the Track, read in one step a frame. Read through a `Lanes` record,
|
|
1736
|
+
// keyframes with no `Lerp` (an app's number kind registered ahead) ran 7% slower a frame in Bun.
|
|
1619
1737
|
interface Track {
|
|
1620
1738
|
readonly key: string
|
|
1621
1739
|
readonly stopTimes: ReadonlyArray<number>
|
|
1622
|
-
readonly forward:
|
|
1623
|
-
readonly
|
|
1740
|
+
readonly forward: Lanes["blenders"]
|
|
1741
|
+
readonly forwardEnds: Lanes["ends"]
|
|
1742
|
+
readonly backward: Lanes["blenders"]
|
|
1743
|
+
readonly backwardEnds: Lanes["ends"]
|
|
1624
1744
|
}
|
|
1625
1745
|
|
|
1626
|
-
/** No
|
|
1627
|
-
const
|
|
1746
|
+
/** No lanes: a Track whose passes never read its stops from last to first. */
|
|
1747
|
+
const NO_LANES: Lanes = { blenders: [], ends: [] }
|
|
1628
1748
|
|
|
1629
|
-
/** `key`'s
|
|
1630
|
-
const
|
|
1631
|
-
|
|
1632
|
-
key: string,
|
|
1633
|
-
stops: ReadonlyArray<number | string>,
|
|
1634
|
-
): Effect.Effect<ReadonlyArray<Blender>> =>
|
|
1635
|
-
Effect.all(Arr.map(Arr.range(0, stops.length - 2), (i) => blenderFor(registry, key, stops[i], stops[i + 1])))
|
|
1749
|
+
/** `key`'s plan for each Interval through `stops` (two or more), laid out. */
|
|
1750
|
+
const intervalLanes = (plan: Planner, key: string, stops: ReadonlyArray<number | string>): Effect.Effect<Lanes> =>
|
|
1751
|
+
Effect.map(Effect.all(Arr.map(Arr.range(0, stops.length - 2), (i) => plan(key, stops[i], stops[i + 1]))), lanesOf)
|
|
1636
1752
|
|
|
1637
1753
|
/** `key`'s Track through `given` in a pass of `duration` seconds, its stops at `times` when there's one each. */
|
|
1638
1754
|
const trackFor = (
|
|
1639
|
-
|
|
1755
|
+
plan: Planner,
|
|
1640
1756
|
key: string,
|
|
1641
1757
|
given: Arr.NonEmptyReadonlyArray<number | string>,
|
|
1642
1758
|
times: ReadonlyArray<number> | undefined,
|
|
@@ -1645,9 +1761,16 @@ const trackFor = (
|
|
|
1645
1761
|
): Effect.Effect<Track> => {
|
|
1646
1762
|
const stops = stopsOf(given, given[0])
|
|
1647
1763
|
return Effect.all({
|
|
1648
|
-
forward:
|
|
1649
|
-
backward: Bool.match(flips, { onTrue: () =>
|
|
1650
|
-
}).pipe(Effect.map(({ forward, backward }): Track => ({
|
|
1764
|
+
forward: intervalLanes(plan, key, stops),
|
|
1765
|
+
backward: Bool.match(flips, { onTrue: () => intervalLanes(plan, key, Arr.reverse(stops)), onFalse: () => Effect.succeed(NO_LANES) }),
|
|
1766
|
+
}).pipe(Effect.map(({ forward, backward }): Track => ({
|
|
1767
|
+
key,
|
|
1768
|
+
stopTimes: stopTimesOf(stops.length, times, duration),
|
|
1769
|
+
forward: forward.blenders,
|
|
1770
|
+
forwardEnds: forward.ends,
|
|
1771
|
+
backward: backward.blenders,
|
|
1772
|
+
backwardEnds: backward.ends,
|
|
1773
|
+
})))
|
|
1651
1774
|
}
|
|
1652
1775
|
|
|
1653
1776
|
/**
|
|
@@ -1655,7 +1778,8 @@ const trackFor = (
|
|
|
1655
1778
|
* blends it, as `animateValues`' are. One run drives every key: its `duration`, `ease` (one, or one per
|
|
1656
1779
|
* stretch) and repeats are the bag's. Each key has its own stops, at their places in `times` when there's
|
|
1657
1780
|
* one per stop, evenly spaced otherwise. A key with one stop holds it, and one with none is left out.
|
|
1658
|
-
* Building it needs the `InterpolatorRegistry`, once.
|
|
1781
|
+
* Building it needs the `InterpolatorRegistry`, once. Its Frame and its record are the run's, rewritten
|
|
1782
|
+
* every tick: copy one to keep it.
|
|
1659
1783
|
*/
|
|
1660
1784
|
// #429. An Interval blends as a pair does: a Discrete pair switches at its first Frame past 0, and a Key
|
|
1661
1785
|
// rule that holds a key until the run's last Frame (`@wardic/dom`'s for a key that hides an element) sees only the
|
|
@@ -1668,36 +1792,50 @@ export const keyframesValues: (
|
|
|
1668
1792
|
function* (stops: Readonly<Record<string, ReadonlyArray<number | string>>>, options: KeyframesOptions = NO_OPTIONS) {
|
|
1669
1793
|
const resolved = resolveKeyframes(options)
|
|
1670
1794
|
const { run, eases, reverse } = resolved
|
|
1671
|
-
const
|
|
1795
|
+
const plan = yield* planner
|
|
1672
1796
|
const flips = Bool.or(reverse, run.mirrors)
|
|
1673
1797
|
const duration = run.tween.duration
|
|
1674
1798
|
const tracks = yield* Effect.all(
|
|
1675
1799
|
Arr.filterMap(Rec.toEntries(stops), ([key, given]) =>
|
|
1676
1800
|
Arr.match(given, {
|
|
1677
1801
|
onEmpty: () => Result.failVoid,
|
|
1678
|
-
onNonEmpty: (some) => Result.succeed(trackFor(
|
|
1802
|
+
onNonEmpty: (some) => Result.succeed(trackFor(plan, key, some, resolved.times, duration, flips)),
|
|
1679
1803
|
})),
|
|
1680
1804
|
)
|
|
1681
1805
|
const machine = make({
|
|
1682
1806
|
settles: Number.isFinite(resolved.repeat),
|
|
1683
1807
|
span: { name: "wardic.keyframesValues", attributes: {} },
|
|
1684
1808
|
start: () => {
|
|
1685
|
-
let
|
|
1809
|
+
// Its time on a field, which V8 rewrites where it is: a closure's `let` boxed each frame's number (#1031).
|
|
1810
|
+
const state = initTween()
|
|
1686
1811
|
const pass: Pass = { within: 0, reversed: false, flipped: false }
|
|
1812
|
+
// In place (#1031): its record and its Frame are its run's, rewritten each tick, as `blendedBy`'s are.
|
|
1813
|
+
const frame: WritableFrame<Record<string, number | string>> = { value: seededRecordOf(tracks, trackKey), done: false }
|
|
1687
1814
|
// Per frame (ADR-0025): one time, `dt` clamped (#78); a loop over the Tracks built with the machine.
|
|
1688
1815
|
return (dt): Frame.Frame<Values.Values> => {
|
|
1689
|
-
elapsed
|
|
1816
|
+
const elapsed = state.elapsed + Math.min(dt, MAX_DT)
|
|
1817
|
+
state.elapsed = elapsed
|
|
1690
1818
|
const done = passAt(elapsed, run, reverse, pass)
|
|
1691
1819
|
const time = timeIn(pass, duration)
|
|
1692
|
-
const value
|
|
1820
|
+
const value = frame.value
|
|
1693
1821
|
for (const track of tracks) {
|
|
1694
1822
|
const i = intervalAt(time, track.stopTimes)
|
|
1695
1823
|
const eased = eases[i % eases.length](intervalProgress(time, track.stopTimes, i))
|
|
1696
1824
|
let blenders = track.forward
|
|
1697
1825
|
if (pass.flipped) blenders = track.backward
|
|
1698
|
-
|
|
1826
|
+
// A `Lerp` through `Scalar.lerp`, as `blendedBy`'s loop computes one (#1036). Its ends are read
|
|
1827
|
+
// only for a `Lerp`: read for every Interval, a bag of string keys ran 5–6% slower a frame in Bun.
|
|
1828
|
+
const blend = blenders[i]
|
|
1829
|
+
if (Predicate.isNull(blend)) {
|
|
1830
|
+
let ends = track.forwardEnds
|
|
1831
|
+
if (pass.flipped) ends = track.backwardEnds
|
|
1832
|
+
value[track.key] = Scalar.lerp(ends[2 * i], ends[2 * i + 1], eased)
|
|
1833
|
+
continue
|
|
1834
|
+
}
|
|
1835
|
+
value[track.key] = blend(eased, done)
|
|
1699
1836
|
}
|
|
1700
|
-
|
|
1837
|
+
frame.done = done
|
|
1838
|
+
return frame
|
|
1701
1839
|
}
|
|
1702
1840
|
},
|
|
1703
1841
|
})
|
package/src/Playback.ts
CHANGED
|
@@ -149,7 +149,11 @@ export const drive: {
|
|
|
149
149
|
return held
|
|
150
150
|
}
|
|
151
151
|
held = undefined
|
|
152
|
-
|
|
152
|
+
// At speed 1 within the clamp, the frame's own `dt` (#1031): a number made here is boxed again as it's
|
|
153
|
+
// passed to a step V8 hasn't inlined, 16 B a run a frame, and whether it's inlined turns on when its
|
|
154
|
+
// optimised code was compiled. `tickOf` gives that same number.
|
|
155
|
+
let by = dt
|
|
156
|
+
if (head.speed !== 1 || dt > Machine.MAX_DT) by = tickOf(head, dt, Machine.MAX_DT)
|
|
153
157
|
if (by >= 0) {
|
|
154
158
|
own.time += by
|
|
155
159
|
writable.time = own.time
|
package/src/Projection.ts
CHANGED
|
@@ -48,7 +48,7 @@ export interface Delta {
|
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* The key a projection pass writes each node's `Value` under, each frame, for its Environment's renderer
|
|
51
|
-
* to draw as one transform with the
|
|
51
|
+
* to draw as one transform with the Subject's own rotation and skew. Namespaced, `@projection`, so it
|
|
52
52
|
* never collides with an animated key.
|
|
53
53
|
*/
|
|
54
54
|
// ADR-0009. `@wardic/dom`'s renderer's `project()` reads it in place of its normal transform grouping.
|
|
@@ -69,27 +69,27 @@ export interface Value {
|
|
|
69
69
|
/** Its ancestors' scale, multiplied together. */
|
|
70
70
|
readonly treeScale: Point.Point
|
|
71
71
|
/**
|
|
72
|
-
* A twin's Crossfade, from 0 to 1: the
|
|
72
|
+
* A twin's Crossfade, from 0 to 1: the Subject's own opacity is multiplied by it. The lead
|
|
73
73
|
* fades in, the followers fade out. Absent for a plain layout node, so its own opacity shows.
|
|
74
74
|
*/
|
|
75
75
|
// ADR-0010.
|
|
76
76
|
readonly opacity?: number
|
|
77
77
|
/**
|
|
78
|
-
* A handover's blended opacity, from 0 to 1: drawn as the
|
|
79
|
-
* any crossfade, from the leaving
|
|
78
|
+
* A handover's blended opacity, from 0 to 1: drawn as the Subject's opacity in place of its own and of
|
|
79
|
+
* any crossfade, from the leaving Subject's opacity to its own over the handover. Absent otherwise.
|
|
80
80
|
*/
|
|
81
81
|
// A Switch's (ADR-0010, *Amendment (#166)*).
|
|
82
82
|
readonly blendOpacity?: number
|
|
83
83
|
/**
|
|
84
|
-
* A handover's blended rotation, in degrees: drawn in place of the
|
|
84
|
+
* A handover's blended rotation, in degrees: drawn in place of the Subject's own `rotate`, from its
|
|
85
85
|
* twin's to its own over the handover. A follower is drawn with its lead's. Absent otherwise, so the
|
|
86
|
-
*
|
|
86
|
+
* Subject's own `rotate` shows.
|
|
87
87
|
*/
|
|
88
88
|
// ADR-0010, *Amendment (#166)*.
|
|
89
89
|
readonly rotate?: number
|
|
90
90
|
/**
|
|
91
91
|
* A raise above its siblings: while it's set, the renderer draws the node above them, as a dragged
|
|
92
|
-
* Reorder item is while it's off its place. Absent at rest, so the
|
|
92
|
+
* Reorder item is while it's off its place. Absent at rest, so the Subject's own stacking shows.
|
|
93
93
|
*/
|
|
94
94
|
// ADR-0016, *Amendment (Reorder)*: Motion's Reorder item, `zIndex: 1`; `@wardic/dom` writes it as
|
|
95
95
|
// `z-index`.
|
|
@@ -97,7 +97,7 @@ export interface Value {
|
|
|
97
97
|
/**
|
|
98
98
|
* Set on a follower: pointer input passes through it to what's beneath, so a follower drawn on its
|
|
99
99
|
* lead's box never takes the lead's input, fading out or hidden at rest, as Motion's. How a renderer
|
|
100
|
-
* lets it through is its Environment's. Absent on a lead, so the
|
|
100
|
+
* lets it through is its Environment's. Absent on a lead, so the Subject's own value shows.
|
|
101
101
|
*/
|
|
102
102
|
// ADR-0010, *Amendment (#165)*; `@wardic/dom`'s renderer.
|
|
103
103
|
readonly passesPointer?: true
|
|
@@ -107,7 +107,7 @@ export interface Value {
|
|
|
107
107
|
const REST_AXIS: AxisDelta = { translate: 0, scale: 1, origin: 0.5, originPoint: 0 }
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
|
-
* A node drawn at its own box: no delta, no ancestors' scale. The renderer draws it with the
|
|
110
|
+
* A node drawn at its own box: no delta, no ancestors' scale. The renderer draws it with the Subject's
|
|
111
111
|
* own rotation, skew and scale, and leaves its own move out, as it draws a layout node at rest. What a
|
|
112
112
|
* server, which measures nothing, draws a layout node's starting style and mount animation with.
|
|
113
113
|
*/
|
package/src/Recognizer.ts
CHANGED
|
@@ -125,14 +125,14 @@ const isUnpressedMove: Predicate.Predicate<InputSource.PointerLikeEvent> = /*#__
|
|
|
125
125
|
const endsPress: Predicate.Predicate<InputSource.PointerLikeEvent> = /*#__PURE__*/ Predicate.some([ofType("up"), ofType("cancel"), isUnpressedMove])
|
|
126
126
|
|
|
127
127
|
/**
|
|
128
|
-
* Hover's fold, after Motion's `hover
|
|
129
|
-
* ADR-0019): touch never hovers; an enter while a drag is active (**Drag activity**)
|
|
128
|
+
* Hover's fold, after Motion's `hover`: touch never hovers; an enter while a drag is active (**Drag activity**)
|
|
130
129
|
* starts nothing; a leave while a pointer that went down on the target is held waits
|
|
131
130
|
* for that pointer's release, its cancel or its first unpressed move, then ends the
|
|
132
131
|
* hover unless the pointer came back in first. An enter during a drag doesn't count,
|
|
133
|
-
* so a dragged
|
|
134
|
-
*
|
|
132
|
+
* so a dragged Subject whose pointer left and came back ends its hover at the release,
|
|
133
|
+
* as Motion's does.
|
|
135
134
|
*/
|
|
135
|
+
// `motion-dom/src/gestures/hover.ts` @ `16c6122` (ADR-0019); the release, its `hover.ts:78-81, 109-112`.
|
|
136
136
|
const hoverFold = (activity: DragActivity.Shape): Fold<HoverState, InputSource.PointerLikeEvent> => ({
|
|
137
137
|
initial: noHover,
|
|
138
138
|
active: (s) => Bool.or(s.inside, s.deferred),
|
|
@@ -215,7 +215,7 @@ export type { AmongHandlers } from "./internal/watch.ts"
|
|
|
215
215
|
|
|
216
216
|
/**
|
|
217
217
|
* Each target's state in a watch over many targets: held weakly by a target that's an object, so a
|
|
218
|
-
* target gone mid-gesture (
|
|
218
|
+
* target gone mid-gesture (a Subject removed under the pointer, which hears no leave) keeps nothing.
|
|
219
219
|
*/
|
|
220
220
|
interface TargetStates<S> {
|
|
221
221
|
readonly get: (target: unknown) => S | undefined
|
|
@@ -491,7 +491,7 @@ const keysOnOf = (options: PressOptions | undefined): LazyArg<boolean> => flagNo
|
|
|
491
491
|
|
|
492
492
|
/**
|
|
493
493
|
* `handle` for the keys a target's `keys` lets press it now (#712, Q32): a key's down while they're off is
|
|
494
|
-
* left to the
|
|
494
|
+
* left to the Environment, unstepped; a key's up is always stepped, so a press its down started ends.
|
|
495
495
|
*/
|
|
496
496
|
const whileKeysOn = (keysOn: LazyArg<boolean>) => (handle: (event: InputSource.KeyboardLikeEvent) => boolean) => (event: InputSource.KeyboardLikeEvent): boolean => {
|
|
497
497
|
if (event.type !== "down") return handle(event)
|
|
@@ -536,7 +536,7 @@ export const pressEvents = (target: unknown, options?: PressOptions): Stream.Str
|
|
|
536
536
|
* `handlers.onEnd` is told once every feed it watches has run out.
|
|
537
537
|
*
|
|
538
538
|
* Where the Environment says where focus is, its keys are watched only while focus is within the target,
|
|
539
|
-
* as Motion's press listens for keys once its
|
|
539
|
+
* as Motion's press listens for keys once its Subject has focus: a Subject at rest holds only its focus
|
|
540
540
|
* feed.
|
|
541
541
|
*/
|
|
542
542
|
// #318, ADR-0055. One fold over the target's pointer, keys and focus, each feed watched with its own
|
package/src/ReducedMotion.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Reduced motion, as Motion does it: under it, a run's positional keys, the transforms and
|
|
2
|
+
* Reduced motion, as Motion does it: under it, a run's positional keys, the transforms and a Subject's
|
|
3
3
|
* position and size, land where the run would end, and every other key, an opacity or a colour, animates
|
|
4
4
|
* as ever. `applies` says whether it's on, `split` divides a target by its Environment's
|
|
5
5
|
* `PositionalKeys`, and `snap` lands the positional ones.
|
|
@@ -35,10 +35,10 @@ export type Config = "user" | "always" | "never"
|
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* Whether reduced motion applies under `config`, given whether the user prefers reduced motion. A binding
|
|
38
|
-
* reads it as each
|
|
38
|
+
* reads it as each Subject's animation starts.
|
|
39
39
|
*/
|
|
40
40
|
export const applies = (config: Config, prefersReducedMotion: boolean): boolean => {
|
|
41
|
-
// Per
|
|
41
|
+
// Per Subject at mount (#540): statements.
|
|
42
42
|
if (config === "always") return true
|
|
43
43
|
if (config === "never") return false
|
|
44
44
|
return prefersReducedMotion
|
|
@@ -48,9 +48,9 @@ export const applies = (config: Config, prefersReducedMotion: boolean): boolean
|
|
|
48
48
|
export const isTransform = (key: string): boolean => Option.isSome(BaseValue.transformIdentity(key))
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
|
-
* An Environment's Positional keys: the keys that move or resize its
|
|
52
|
-
* at once. Core names only
|
|
53
|
-
* adds the keys that size and place
|
|
51
|
+
* An Environment's Positional keys: the keys that move or resize its Subjects, which reduced motion lands
|
|
52
|
+
* at once. Core names only its transforms (`transformsOnly`); an Environment adds its own, as `@wardic/dom`
|
|
53
|
+
* adds its own transform keys and the keys that size and place a Subject's box.
|
|
54
54
|
*/
|
|
55
55
|
// CONTEXT.md; ADR-0029, ADR-0036; `@wardic/dom`'s `PositionalKeysDomLive`. A binding reads it
|
|
56
56
|
// once, as it reads the Probe, and passes it to `split`.
|