@unrulysystems/native-motion-core 0.1.0-alpha.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/CHANGELOG.md +9 -0
- package/LICENSE +21 -0
- package/README.md +48 -0
- package/dist/clock.cjs +71 -0
- package/dist/clock.d.cts +23 -0
- package/dist/clock.d.ts +23 -0
- package/dist/clock.js +66 -0
- package/dist/collect-reads.cjs +68 -0
- package/dist/collect-reads.d.cts +23 -0
- package/dist/collect-reads.d.ts +23 -0
- package/dist/collect-reads.js +62 -0
- package/dist/component/boundedArray.cjs +74 -0
- package/dist/component/boundedArray.d.cts +25 -0
- package/dist/component/boundedArray.d.ts +25 -0
- package/dist/component/boundedArray.js +68 -0
- package/dist/component/index.cjs +57 -0
- package/dist/component/index.d.cts +12 -0
- package/dist/component/index.d.ts +12 -0
- package/dist/component/index.js +22 -0
- package/dist/component/orchestration.cjs +129 -0
- package/dist/component/orchestration.d.cts +66 -0
- package/dist/component/orchestration.d.ts +66 -0
- package/dist/component/orchestration.js +124 -0
- package/dist/component/resolve.cjs +104 -0
- package/dist/component/resolve.d.cts +11 -0
- package/dist/component/resolve.d.ts +11 -0
- package/dist/component/resolve.js +97 -0
- package/dist/component/transition.cjs +352 -0
- package/dist/component/transition.d.cts +33 -0
- package/dist/component/transition.d.ts +33 -0
- package/dist/component/transition.js +339 -0
- package/dist/component/types.cjs +114 -0
- package/dist/component/types.d.cts +60 -0
- package/dist/component/types.d.ts +60 -0
- package/dist/component/types.js +111 -0
- package/dist/component/validate.cjs +1015 -0
- package/dist/component/validate.d.cts +37 -0
- package/dist/component/validate.d.ts +37 -0
- package/dist/component/validate.js +1002 -0
- package/dist/component/variants.cjs +333 -0
- package/dist/component/variants.d.cts +106 -0
- package/dist/component/variants.d.ts +106 -0
- package/dist/component/variants.js +321 -0
- package/dist/config/constants.cjs +41 -0
- package/dist/config/constants.d.cts +29 -0
- package/dist/config/constants.d.ts +29 -0
- package/dist/config/constants.js +38 -0
- package/dist/delay.cjs +72 -0
- package/dist/delay.d.cts +26 -0
- package/dist/delay.d.ts +26 -0
- package/dist/delay.js +70 -0
- package/dist/derived.cjs +143 -0
- package/dist/derived.d.cts +41 -0
- package/dist/derived.d.ts +41 -0
- package/dist/derived.js +139 -0
- package/dist/driver/index.cjs +22 -0
- package/dist/driver/index.d.cts +7 -0
- package/dist/driver/index.d.ts +7 -0
- package/dist/driver/index.js +14 -0
- package/dist/driver/keyframeTiming.cjs +130 -0
- package/dist/driver/keyframeTiming.d.cts +18 -0
- package/dist/driver/keyframeTiming.d.ts +18 -0
- package/dist/driver/keyframeTiming.js +124 -0
- package/dist/driver/keyframeTimingConfig.cjs +24 -0
- package/dist/driver/keyframeTimingConfig.d.cts +5 -0
- package/dist/driver/keyframeTimingConfig.d.ts +5 -0
- package/dist/driver/keyframeTimingConfig.js +22 -0
- package/dist/driver/prepare.cjs +459 -0
- package/dist/driver/prepare.d.cts +4 -0
- package/dist/driver/prepare.d.ts +4 -0
- package/dist/driver/prepare.js +454 -0
- package/dist/driver/reference.cjs +762 -0
- package/dist/driver/reference.d.cts +53 -0
- package/dist/driver/reference.d.ts +53 -0
- package/dist/driver/reference.js +757 -0
- package/dist/driver/step.cjs +55 -0
- package/dist/driver/step.d.cts +9 -0
- package/dist/driver/step.d.ts +9 -0
- package/dist/driver/step.js +52 -0
- package/dist/driver/tiers.cjs +40 -0
- package/dist/driver/tiers.d.cts +2 -0
- package/dist/driver/tiers.d.ts +2 -0
- package/dist/driver/tiers.js +37 -0
- package/dist/driver/types.cjs +9 -0
- package/dist/driver/types.d.cts +68 -0
- package/dist/driver/types.d.ts +68 -0
- package/dist/driver/types.js +8 -0
- package/dist/external-animation-ledger.cjs +1250 -0
- package/dist/external-animation-ledger.d.cts +416 -0
- package/dist/external-animation-ledger.d.ts +416 -0
- package/dist/external-animation-ledger.js +1243 -0
- package/dist/gesture/directionLock.cjs +25 -0
- package/dist/gesture/directionLock.d.cts +8 -0
- package/dist/gesture/directionLock.d.ts +8 -0
- package/dist/gesture/directionLock.js +21 -0
- package/dist/gesture/dragConfig.cjs +634 -0
- package/dist/gesture/dragConfig.d.cts +298 -0
- package/dist/gesture/dragConfig.d.ts +298 -0
- package/dist/gesture/dragConfig.js +624 -0
- package/dist/gesture/elastic.cjs +44 -0
- package/dist/gesture/elastic.d.cts +4 -0
- package/dist/gesture/elastic.d.ts +4 -0
- package/dist/gesture/elastic.js +39 -0
- package/dist/gesture/handoffSession.cjs +161 -0
- package/dist/gesture/handoffSession.d.cts +35 -0
- package/dist/gesture/handoffSession.d.ts +35 -0
- package/dist/gesture/handoffSession.js +158 -0
- package/dist/gesture/index.cjs +37 -0
- package/dist/gesture/index.d.cts +12 -0
- package/dist/gesture/index.d.ts +12 -0
- package/dist/gesture/index.js +11 -0
- package/dist/gesture/projection.cjs +95 -0
- package/dist/gesture/projection.d.cts +7 -0
- package/dist/gesture/projection.d.ts +7 -0
- package/dist/gesture/projection.js +87 -0
- package/dist/gesture/session.cjs +162 -0
- package/dist/gesture/session.d.cts +29 -0
- package/dist/gesture/session.d.ts +29 -0
- package/dist/gesture/session.js +158 -0
- package/dist/gesture/types.cjs +5 -0
- package/dist/gesture/types.d.cts +13 -0
- package/dist/gesture/types.d.ts +13 -0
- package/dist/gesture/types.js +4 -0
- package/dist/gesture/viewportConstraints.cjs +38 -0
- package/dist/gesture/viewportConstraints.d.cts +6 -0
- package/dist/gesture/viewportConstraints.d.ts +6 -0
- package/dist/gesture/viewportConstraints.js +34 -0
- package/dist/graph.cjs +226 -0
- package/dist/graph.d.cts +2 -0
- package/dist/graph.d.ts +2 -0
- package/dist/graph.js +223 -0
- package/dist/index.cjs +140 -0
- package/dist/index.d.cts +33 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +70 -0
- package/dist/inertia.cjs +214 -0
- package/dist/inertia.d.cts +53 -0
- package/dist/inertia.d.ts +53 -0
- package/dist/inertia.js +212 -0
- package/dist/instant.cjs +66 -0
- package/dist/instant.d.cts +16 -0
- package/dist/instant.d.ts +16 -0
- package/dist/instant.js +63 -0
- package/dist/internal-driver.cjs +81 -0
- package/dist/internal-driver.d.cts +19 -0
- package/dist/internal-driver.d.ts +19 -0
- package/dist/internal-driver.js +35 -0
- package/dist/keyframes.cjs +191 -0
- package/dist/keyframes.d.cts +13 -0
- package/dist/keyframes.d.ts +13 -0
- package/dist/keyframes.js +188 -0
- package/dist/layout/commitDetector.cjs +67 -0
- package/dist/layout/commitDetector.d.cts +21 -0
- package/dist/layout/commitDetector.d.ts +21 -0
- package/dist/layout/commitDetector.js +64 -0
- package/dist/layout/compose.cjs +67 -0
- package/dist/layout/compose.d.cts +30 -0
- package/dist/layout/compose.d.ts +30 -0
- package/dist/layout/compose.js +65 -0
- package/dist/layout/constants.cjs +13 -0
- package/dist/layout/constants.d.cts +6 -0
- package/dist/layout/constants.d.ts +6 -0
- package/dist/layout/constants.js +10 -0
- package/dist/layout/identity.cjs +700 -0
- package/dist/layout/identity.d.cts +67 -0
- package/dist/layout/identity.d.ts +67 -0
- package/dist/layout/identity.js +698 -0
- package/dist/layout/index.cjs +36 -0
- package/dist/layout/index.d.cts +18 -0
- package/dist/layout/index.d.ts +18 -0
- package/dist/layout/index.js +13 -0
- package/dist/layout/measure.cjs +81 -0
- package/dist/layout/measure.d.cts +43 -0
- package/dist/layout/measure.d.ts +43 -0
- package/dist/layout/measure.js +78 -0
- package/dist/layout/projection.cjs +99 -0
- package/dist/layout/projection.d.cts +23 -0
- package/dist/layout/projection.d.ts +23 -0
- package/dist/layout/projection.js +97 -0
- package/dist/layout/scroll.cjs +27 -0
- package/dist/layout/scroll.d.cts +13 -0
- package/dist/layout/scroll.d.ts +13 -0
- package/dist/layout/scroll.js +24 -0
- package/dist/layout/session.cjs +207 -0
- package/dist/layout/session.d.cts +73 -0
- package/dist/layout/session.d.ts +73 -0
- package/dist/layout/session.js +205 -0
- package/dist/layout/tree.cjs +826 -0
- package/dist/layout/tree.d.cts +70 -0
- package/dist/layout/tree.d.ts +70 -0
- package/dist/layout/tree.js +823 -0
- package/dist/layout/types.cjs +36 -0
- package/dist/layout/types.d.cts +31 -0
- package/dist/layout/types.d.ts +31 -0
- package/dist/layout/types.js +35 -0
- package/dist/motion-arc.cjs +184 -0
- package/dist/motion-arc.d.cts +78 -0
- package/dist/motion-arc.d.ts +78 -0
- package/dist/motion-arc.js +183 -0
- package/dist/motion-mix.cjs +205 -0
- package/dist/motion-mix.d.cts +3 -0
- package/dist/motion-mix.d.ts +3 -0
- package/dist/motion-mix.js +202 -0
- package/dist/motion-value-driver-port.cjs +636 -0
- package/dist/motion-value-driver-port.d.cts +406 -0
- package/dist/motion-value-driver-port.d.ts +406 -0
- package/dist/motion-value-driver-port.js +627 -0
- package/dist/motion-value.cjs +189 -0
- package/dist/motion-value.d.cts +51 -0
- package/dist/motion-value.d.ts +51 -0
- package/dist/motion-value.js +185 -0
- package/dist/presence/controller.cjs +657 -0
- package/dist/presence/controller.d.cts +6 -0
- package/dist/presence/controller.d.ts +6 -0
- package/dist/presence/controller.js +652 -0
- package/dist/presence/index.cjs +19 -0
- package/dist/presence/index.d.cts +4 -0
- package/dist/presence/index.d.ts +4 -0
- package/dist/presence/index.js +12 -0
- package/dist/presence/machine.cjs +50 -0
- package/dist/presence/machine.d.cts +10 -0
- package/dist/presence/machine.d.ts +10 -0
- package/dist/presence/machine.js +46 -0
- package/dist/presence/types.cjs +6 -0
- package/dist/presence/types.d.cts +32 -0
- package/dist/presence/types.d.ts +32 -0
- package/dist/presence/types.js +5 -0
- package/dist/repeat.cjs +311 -0
- package/dist/repeat.d.cts +174 -0
- package/dist/repeat.d.ts +174 -0
- package/dist/repeat.js +300 -0
- package/dist/spring.cjs +128 -0
- package/dist/spring.d.cts +18 -0
- package/dist/spring.d.ts +18 -0
- package/dist/spring.js +125 -0
- package/dist/subscriptions.cjs +74 -0
- package/dist/subscriptions.d.cts +19 -0
- package/dist/subscriptions.d.ts +19 -0
- package/dist/subscriptions.js +69 -0
- package/dist/subset/index.cjs +23 -0
- package/dist/subset/index.d.cts +6 -0
- package/dist/subset/index.d.ts +6 -0
- package/dist/subset/index.js +13 -0
- package/dist/subset/normalize.cjs +90 -0
- package/dist/subset/normalize.d.cts +10 -0
- package/dist/subset/normalize.d.ts +10 -0
- package/dist/subset/normalize.js +85 -0
- package/dist/subset/registry.cjs +259 -0
- package/dist/subset/registry.d.cts +25 -0
- package/dist/subset/registry.d.ts +25 -0
- package/dist/subset/registry.js +256 -0
- package/dist/subset/resolve.cjs +98 -0
- package/dist/subset/resolve.d.cts +24 -0
- package/dist/subset/resolve.d.ts +24 -0
- package/dist/subset/resolve.js +90 -0
- package/dist/timing.cjs +206 -0
- package/dist/timing.d.cts +17 -0
- package/dist/timing.d.ts +17 -0
- package/dist/timing.js +201 -0
- package/dist/transformTemplate.cjs +219 -0
- package/dist/transformTemplate.d.cts +29 -0
- package/dist/transformTemplate.d.ts +29 -0
- package/dist/transformTemplate.js +215 -0
- package/dist/transition.cjs +231 -0
- package/dist/transition.d.cts +89 -0
- package/dist/transition.d.ts +89 -0
- package/dist/transition.js +223 -0
- package/dist/types.cjs +4 -0
- package/dist/types.d.cts +175 -0
- package/dist/types.d.ts +175 -0
- package/dist/types.js +3 -0
- package/dist/value-types/color.cjs +220 -0
- package/dist/value-types/color.d.cts +19 -0
- package/dist/value-types/color.d.ts +19 -0
- package/dist/value-types/color.js +218 -0
- package/dist/value-types/complex.cjs +160 -0
- package/dist/value-types/complex.d.cts +19 -0
- package/dist/value-types/complex.d.ts +19 -0
- package/dist/value-types/complex.js +155 -0
- package/dist/value-types/constants.cjs +15 -0
- package/dist/value-types/constants.d.cts +6 -0
- package/dist/value-types/constants.d.ts +6 -0
- package/dist/value-types/constants.js +12 -0
- package/dist/value-types/discrete.cjs +62 -0
- package/dist/value-types/discrete.d.cts +4 -0
- package/dist/value-types/discrete.d.ts +4 -0
- package/dist/value-types/discrete.js +56 -0
- package/dist/value-types/index.cjs +59 -0
- package/dist/value-types/index.d.cts +14 -0
- package/dist/value-types/index.d.ts +14 -0
- package/dist/value-types/index.js +24 -0
- package/dist/value-types/measure-resolve.cjs +325 -0
- package/dist/value-types/measure-resolve.d.cts +91 -0
- package/dist/value-types/measure-resolve.d.ts +91 -0
- package/dist/value-types/measure-resolve.js +313 -0
- package/dist/value-types/mix.cjs +90 -0
- package/dist/value-types/mix.d.cts +27 -0
- package/dist/value-types/mix.d.ts +27 -0
- package/dist/value-types/mix.js +85 -0
- package/dist/value-types/named-colors.cjs +61 -0
- package/dist/value-types/named-colors.d.cts +2 -0
- package/dist/value-types/named-colors.d.ts +2 -0
- package/dist/value-types/named-colors.js +58 -0
- package/dist/value-types/numeric.cjs +86 -0
- package/dist/value-types/numeric.d.cts +16 -0
- package/dist/value-types/numeric.d.ts +16 -0
- package/dist/value-types/numeric.js +79 -0
- package/dist/worklet-layout/config/constants.js +39 -0
- package/dist/worklet-layout/layout/constants.js +11 -0
- package/dist/worklet-layout/layout/identity.js +699 -0
- package/dist/worklet-layout/layout/projection.js +98 -0
- package/dist/worklet-layout/layout/session.js +206 -0
- package/dist/worklet-layout/layout/tree.js +824 -0
- package/dist/worklet-layout/layout/types.js +36 -0
- package/dist/worklet-layout/spring.js +125 -0
- package/dist/worklet-layout/timing.js +201 -0
- package/dist/worklet-layout/transition.js +223 -0
- package/dist/worklet-layout.cjs +47 -0
- package/dist/worklet-layout.d.cts +15 -0
- package/dist/worklet-layout.d.ts +15 -0
- package/dist/worklet-layout.js +28 -0
- package/dist/wrap.cjs +7 -0
- package/dist/wrap.d.cts +1 -0
- package/dist/wrap.d.ts +1 -0
- package/dist/wrap.js +4 -0
- package/package.json +45 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @frame-path — executes inside the UI-runtime frame step; allocation-gated (REQ-DRIVER-021).
|
|
3
|
+
// SPEC-NATIVE-DRIVER §Requirements — the pure, time-integrated per-frame step (REQ-DRIVER-012/015). Each
|
|
4
|
+
// animated property advances by ACCUMULATED elapsed time and reads its value off a generator — the
|
|
5
|
+
// SPRING/TIMING analytic trajectory, single-sourced (REQ-DRIVER-003: the driver executes motion, it never
|
|
6
|
+
// defines it). The step is a pure function of `(state, elapsedMs)`: it mutates the passed-in state in place
|
|
7
|
+
// (allocation-free hot path, REQ-DRIVER-015 — the "shared-value write") and reads no clock, host, or
|
|
8
|
+
// wall-clock time. Because the value is sampled at accumulated elapsed time, the trajectory at simulated
|
|
9
|
+
// `t` is invariant to how `[0, t]` is partitioned into frames. Host-agnostic (REQ-CORE-003): relative
|
|
10
|
+
// imports only.
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.clampElapsed = clampElapsed;
|
|
13
|
+
exports.stepProp = stepProp;
|
|
14
|
+
const constants_1 = require("../config/constants.cjs");
|
|
15
|
+
// Clamp one frame's elapsed time to the core dt-ceiling (REQ-CLOCK-003 / REQ-DRIVER-012), single-sourced in
|
|
16
|
+
// `config/constants` — consumed here, never re-declared. A post-background gap advances the trajectory by
|
|
17
|
+
// at most the ceiling, so a large real-time jump cannot teleport a value past its target.
|
|
18
|
+
function clampElapsed(elapsedMs) {
|
|
19
|
+
return elapsedMs > constants_1.DT_CLAMP_MS ? constants_1.DT_CLAMP_MS : elapsedMs;
|
|
20
|
+
}
|
|
21
|
+
// Advance one property by a single (clamped) frame. Mutates `prop` in place; deterministic in
|
|
22
|
+
// `(prop, elapsedMs)`. A settled property holds — it neither advances nor re-samples (REQ-DRIVER-020
|
|
23
|
+
// quiesce, and O(active) work, REQ-DRIVER-015). Sampling at the accumulated elapsed time is what makes the
|
|
24
|
+
// trajectory dt-cadence invariant (REQ-DRIVER-012).
|
|
25
|
+
function stepProp(prop, elapsedMs) {
|
|
26
|
+
if (prop.done)
|
|
27
|
+
return;
|
|
28
|
+
const delta = clampElapsed(elapsedMs);
|
|
29
|
+
const next = prop.elapsed + delta;
|
|
30
|
+
if (delta > 0 && next === prop.elapsed) {
|
|
31
|
+
// Precision-freeze termination (r12 major 4f6e2d1b8a70; sampling corrected r13 major
|
|
32
|
+
// 7f1c9e2a4b60): the accumulator has exhausted float precision at this cadence
|
|
33
|
+
// (ulp(elapsed) > delta) — no future frame can advance it, so an un-done trajectory
|
|
34
|
+
// would stay active FOREVER. Terminate at the trajectory's settled state: sampled at
|
|
35
|
+
// max(elapsed, SETTLE_HORIZON_MS) — never a REWIND (a pre-seeded elapsed beyond the
|
|
36
|
+
// horizon keeps its own, already-final sample) and always at-or-past the instant
|
|
37
|
+
// validateTransition guarantees every accepted config is done. Zero-delta frames are
|
|
38
|
+
// untouched (the tick-count purity pin).
|
|
39
|
+
prop.value =
|
|
40
|
+
prop.generator.finalValue ??
|
|
41
|
+
prop.generator.sample(Math.max(prop.elapsed, constants_1.SETTLE_HORIZON_MS)).value;
|
|
42
|
+
prop.done = true;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
prop.elapsed = next;
|
|
46
|
+
const sample = prop.generator.sample(prop.elapsed);
|
|
47
|
+
// The pin's `getFinalKeyframe` position: `JSAnimation` applies it INSIDE `tick`, gated on
|
|
48
|
+
// `holdTime === null && (state === 'finished' || (state === 'running' && done))`, and only then
|
|
49
|
+
// calls `finish()`, which never touches the value. So a trajectory whose resting value differs
|
|
50
|
+
// from its terminal sample commits the former. Only a fractional `repeat` fold declares one today (REQ-TIMING-003) — everything else
|
|
51
|
+
// leaves `finalValue` absent and is untouched. Applied here rather than in the fold so BOTH
|
|
52
|
+
// drivers inherit it from one implementation, and so `sample` stays a faithful seek.
|
|
53
|
+
prop.value = sample.done ? (prop.generator.finalValue ?? sample.value) : sample.value;
|
|
54
|
+
prop.done = sample.done;
|
|
55
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Generator } from "../types.cjs";
|
|
2
|
+
export interface PropStep {
|
|
3
|
+
readonly generator: Generator;
|
|
4
|
+
elapsed: number;
|
|
5
|
+
value: number;
|
|
6
|
+
done: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function clampElapsed(elapsedMs: number): number;
|
|
9
|
+
export declare function stepProp(prop: PropStep, elapsedMs: number): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Generator } from "../types.js";
|
|
2
|
+
export interface PropStep {
|
|
3
|
+
readonly generator: Generator;
|
|
4
|
+
elapsed: number;
|
|
5
|
+
value: number;
|
|
6
|
+
done: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function clampElapsed(elapsedMs: number): number;
|
|
9
|
+
export declare function stepProp(prop: PropStep, elapsedMs: number): void;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'worklet';
|
|
2
|
+
// @frame-path — executes inside the UI-runtime frame step; allocation-gated (REQ-DRIVER-021).
|
|
3
|
+
// SPEC-NATIVE-DRIVER §Requirements — the pure, time-integrated per-frame step (REQ-DRIVER-012/015). Each
|
|
4
|
+
// animated property advances by ACCUMULATED elapsed time and reads its value off a generator — the
|
|
5
|
+
// SPRING/TIMING analytic trajectory, single-sourced (REQ-DRIVER-003: the driver executes motion, it never
|
|
6
|
+
// defines it). The step is a pure function of `(state, elapsedMs)`: it mutates the passed-in state in place
|
|
7
|
+
// (allocation-free hot path, REQ-DRIVER-015 — the "shared-value write") and reads no clock, host, or
|
|
8
|
+
// wall-clock time. Because the value is sampled at accumulated elapsed time, the trajectory at simulated
|
|
9
|
+
// `t` is invariant to how `[0, t]` is partitioned into frames. Host-agnostic (REQ-CORE-003): relative
|
|
10
|
+
// imports only.
|
|
11
|
+
import { DT_CLAMP_MS, SETTLE_HORIZON_MS } from "../config/constants.js";
|
|
12
|
+
// Clamp one frame's elapsed time to the core dt-ceiling (REQ-CLOCK-003 / REQ-DRIVER-012), single-sourced in
|
|
13
|
+
// `config/constants` — consumed here, never re-declared. A post-background gap advances the trajectory by
|
|
14
|
+
// at most the ceiling, so a large real-time jump cannot teleport a value past its target.
|
|
15
|
+
export function clampElapsed(elapsedMs) {
|
|
16
|
+
return elapsedMs > DT_CLAMP_MS ? DT_CLAMP_MS : elapsedMs;
|
|
17
|
+
}
|
|
18
|
+
// Advance one property by a single (clamped) frame. Mutates `prop` in place; deterministic in
|
|
19
|
+
// `(prop, elapsedMs)`. A settled property holds — it neither advances nor re-samples (REQ-DRIVER-020
|
|
20
|
+
// quiesce, and O(active) work, REQ-DRIVER-015). Sampling at the accumulated elapsed time is what makes the
|
|
21
|
+
// trajectory dt-cadence invariant (REQ-DRIVER-012).
|
|
22
|
+
export function stepProp(prop, elapsedMs) {
|
|
23
|
+
if (prop.done)
|
|
24
|
+
return;
|
|
25
|
+
const delta = clampElapsed(elapsedMs);
|
|
26
|
+
const next = prop.elapsed + delta;
|
|
27
|
+
if (delta > 0 && next === prop.elapsed) {
|
|
28
|
+
// Precision-freeze termination (r12 major 4f6e2d1b8a70; sampling corrected r13 major
|
|
29
|
+
// 7f1c9e2a4b60): the accumulator has exhausted float precision at this cadence
|
|
30
|
+
// (ulp(elapsed) > delta) — no future frame can advance it, so an un-done trajectory
|
|
31
|
+
// would stay active FOREVER. Terminate at the trajectory's settled state: sampled at
|
|
32
|
+
// max(elapsed, SETTLE_HORIZON_MS) — never a REWIND (a pre-seeded elapsed beyond the
|
|
33
|
+
// horizon keeps its own, already-final sample) and always at-or-past the instant
|
|
34
|
+
// validateTransition guarantees every accepted config is done. Zero-delta frames are
|
|
35
|
+
// untouched (the tick-count purity pin).
|
|
36
|
+
prop.value =
|
|
37
|
+
prop.generator.finalValue ??
|
|
38
|
+
prop.generator.sample(Math.max(prop.elapsed, SETTLE_HORIZON_MS)).value;
|
|
39
|
+
prop.done = true;
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
prop.elapsed = next;
|
|
43
|
+
const sample = prop.generator.sample(prop.elapsed);
|
|
44
|
+
// The pin's `getFinalKeyframe` position: `JSAnimation` applies it INSIDE `tick`, gated on
|
|
45
|
+
// `holdTime === null && (state === 'finished' || (state === 'running' && done))`, and only then
|
|
46
|
+
// calls `finish()`, which never touches the value. So a trajectory whose resting value differs
|
|
47
|
+
// from its terminal sample commits the former. Only a fractional `repeat` fold declares one today (REQ-TIMING-003) — everything else
|
|
48
|
+
// leaves `finalValue` absent and is untouched. Applied here rather than in the fold so BOTH
|
|
49
|
+
// drivers inherit it from one implementation, and so `sample` stays a faithful seek.
|
|
50
|
+
prop.value = sample.done ? (prop.generator.finalValue ?? sample.value) : sample.value;
|
|
51
|
+
prop.done = sample.done;
|
|
52
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPEC-NATIVE-DRIVER §Requirements — prop-tier classification (REQ-DRIVER-017). The driver routes each
|
|
3
|
+
// animatable property to one of two substrate execution paths, DERIVED from the SUBSET registry class (a
|
|
4
|
+
// single source — never a second hand-list) so a new prop key auto-tiers by its class. Host-agnostic
|
|
5
|
+
// (REQ-CORE-003): relative imports only.
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.tierFor = tierFor;
|
|
8
|
+
const subset_1 = require("../subset/index.cjs");
|
|
9
|
+
// CapabilityClass → tier. This is a `Record` over the CLOSED class union, so adding a class to the registry
|
|
10
|
+
// breaks this build until it is tiered here — a compile-time drift guard. `null` means the class carries no
|
|
11
|
+
// execution tier: `gesture` is not an animatable value; `webEffect` has no native execution strategy yet.
|
|
12
|
+
// The commit-tier membership of visual-but-layout-classed props (e.g. `borderRadius`) is the §G vetoable —
|
|
13
|
+
// conservatively commit here (registry-class-derived), a candidate fast-tier promotion pending human review.
|
|
14
|
+
const TIER_BY_CLASS = {
|
|
15
|
+
transform: 'fast',
|
|
16
|
+
opacity: 'fast',
|
|
17
|
+
color: 'fast',
|
|
18
|
+
layoutProp: 'commit',
|
|
19
|
+
// Discrete keywords (T23 B) execute on the color-lane pattern — a shared-value progress channel
|
|
20
|
+
// projected in the style worklet, no per-frame Yoga commit and no settle-reconcile obligation
|
|
21
|
+
// (the step writes the keyword at most twice per animation). `display: none↔flex` reflows when
|
|
22
|
+
// the step FIRES, but that is the property's own semantic, not a commit-tier animation.
|
|
23
|
+
discrete: 'fast',
|
|
24
|
+
gesture: null,
|
|
25
|
+
webEffect: null,
|
|
26
|
+
};
|
|
27
|
+
// Resolve a property's execution tier, or fail loud (REQ-DRIVER-017 / REQ-API-005): an unknown property and
|
|
28
|
+
// a non-animatable class both throw a descriptive error naming the property — the driver never silently
|
|
29
|
+
// mis-routes or drops a prop.
|
|
30
|
+
function tierFor(key) {
|
|
31
|
+
const entry = subset_1.UNIVERSAL_SUBSET.get(key);
|
|
32
|
+
if (entry === undefined) {
|
|
33
|
+
throw new Error(`no driver execution tier for '${key}': it is not a Universal-Subset property.`);
|
|
34
|
+
}
|
|
35
|
+
const tier = TIER_BY_CLASS[entry.class];
|
|
36
|
+
if (tier === null) {
|
|
37
|
+
throw new Error(`'${key}' (class '${entry.class}') is not a driver-animatable value; it has no execution tier.`);
|
|
38
|
+
}
|
|
39
|
+
return tier;
|
|
40
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// SPEC-NATIVE-DRIVER §Requirements — prop-tier classification (REQ-DRIVER-017). The driver routes each
|
|
2
|
+
// animatable property to one of two substrate execution paths, DERIVED from the SUBSET registry class (a
|
|
3
|
+
// single source — never a second hand-list) so a new prop key auto-tiers by its class. Host-agnostic
|
|
4
|
+
// (REQ-CORE-003): relative imports only.
|
|
5
|
+
import { UNIVERSAL_SUBSET } from "../subset/index.js";
|
|
6
|
+
// CapabilityClass → tier. This is a `Record` over the CLOSED class union, so adding a class to the registry
|
|
7
|
+
// breaks this build until it is tiered here — a compile-time drift guard. `null` means the class carries no
|
|
8
|
+
// execution tier: `gesture` is not an animatable value; `webEffect` has no native execution strategy yet.
|
|
9
|
+
// The commit-tier membership of visual-but-layout-classed props (e.g. `borderRadius`) is the §G vetoable —
|
|
10
|
+
// conservatively commit here (registry-class-derived), a candidate fast-tier promotion pending human review.
|
|
11
|
+
const TIER_BY_CLASS = {
|
|
12
|
+
transform: 'fast',
|
|
13
|
+
opacity: 'fast',
|
|
14
|
+
color: 'fast',
|
|
15
|
+
layoutProp: 'commit',
|
|
16
|
+
// Discrete keywords (T23 B) execute on the color-lane pattern — a shared-value progress channel
|
|
17
|
+
// projected in the style worklet, no per-frame Yoga commit and no settle-reconcile obligation
|
|
18
|
+
// (the step writes the keyword at most twice per animation). `display: none↔flex` reflows when
|
|
19
|
+
// the step FIRES, but that is the property's own semantic, not a commit-tier animation.
|
|
20
|
+
discrete: 'fast',
|
|
21
|
+
gesture: null,
|
|
22
|
+
webEffect: null,
|
|
23
|
+
};
|
|
24
|
+
// Resolve a property's execution tier, or fail loud (REQ-DRIVER-017 / REQ-API-005): an unknown property and
|
|
25
|
+
// a non-animatable class both throw a descriptive error naming the property — the driver never silently
|
|
26
|
+
// mis-routes or drops a prop.
|
|
27
|
+
export function tierFor(key) {
|
|
28
|
+
const entry = UNIVERSAL_SUBSET.get(key);
|
|
29
|
+
if (entry === undefined) {
|
|
30
|
+
throw new Error(`no driver execution tier for '${key}': it is not a Universal-Subset property.`);
|
|
31
|
+
}
|
|
32
|
+
const tier = TIER_BY_CLASS[entry.class];
|
|
33
|
+
if (tier === null) {
|
|
34
|
+
throw new Error(`'${key}' (class '${entry.class}') is not a driver-animatable value; it has no execution tier.`);
|
|
35
|
+
}
|
|
36
|
+
return tier;
|
|
37
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPEC-NATIVE-DRIVER §Requirements — the host-agnostic Driver interface + command types (REQ-DRIVER-010/
|
|
3
|
+
// 013). `core` DEFINES this interface; the native worklet driver and the web driver are peers that
|
|
4
|
+
// IMPLEMENT it (they import core; core imports no driver, no host, no `react-native-*`). The interface is
|
|
5
|
+
// the sole coupling point, so the substrate is replaceable without changing the public contract. The
|
|
6
|
+
// command surface is a discriminated union — an illegal command is unrepresentable, no permissive index
|
|
7
|
+
// signature, no `any` (REQ-DRIVER-015 type discipline). Host-agnostic (REQ-CORE-003): imports only the
|
|
8
|
+
// public `Transition` shape (relative).
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Transition } from "../component/index.cjs";
|
|
2
|
+
import type { PathChannelGeometry } from "../motion-arc.cjs";
|
|
3
|
+
import type { DefaultTransition, InertiaTransition } from "../transition.cjs";
|
|
4
|
+
export type InternalDriverTransition = Transition | DefaultTransition | InertiaTransition;
|
|
5
|
+
export type PropTransition = InternalDriverTransition;
|
|
6
|
+
export interface PathChannelSpec extends PathChannelGeometry {
|
|
7
|
+
readonly transition: PropTransition;
|
|
8
|
+
}
|
|
9
|
+
export type ElementHandle = number & {
|
|
10
|
+
readonly __elementHandle: unique symbol;
|
|
11
|
+
};
|
|
12
|
+
export type PropTargetTo = number | readonly (number | null)[];
|
|
13
|
+
export interface PropTarget {
|
|
14
|
+
readonly to: PropTargetTo;
|
|
15
|
+
readonly from: number;
|
|
16
|
+
readonly velocity?: number;
|
|
17
|
+
readonly transition?: PropTransition;
|
|
18
|
+
}
|
|
19
|
+
export interface PreparedPropTarget {
|
|
20
|
+
readonly to: PropTargetTo;
|
|
21
|
+
readonly from: number;
|
|
22
|
+
readonly velocity: number;
|
|
23
|
+
readonly transition: PropTransition;
|
|
24
|
+
}
|
|
25
|
+
export interface LivePropState {
|
|
26
|
+
readonly value: number;
|
|
27
|
+
readonly velocity: number;
|
|
28
|
+
}
|
|
29
|
+
export type DriverCommand = {
|
|
30
|
+
readonly kind: 'start';
|
|
31
|
+
readonly targets: Readonly<Record<string, PropTarget>>;
|
|
32
|
+
readonly transition: Transition;
|
|
33
|
+
readonly releasesGesture?: boolean;
|
|
34
|
+
readonly path?: PathChannelSpec;
|
|
35
|
+
} | {
|
|
36
|
+
readonly kind: 'retarget';
|
|
37
|
+
readonly targets: Readonly<Record<string, number>>;
|
|
38
|
+
readonly transition: Transition;
|
|
39
|
+
readonly targetTransitions?: Readonly<Record<string, PropTransition>>;
|
|
40
|
+
} | {
|
|
41
|
+
readonly kind: 'stop';
|
|
42
|
+
};
|
|
43
|
+
export type PreparedDriverCommand = {
|
|
44
|
+
readonly kind: 'start';
|
|
45
|
+
readonly targets: Readonly<Record<string, PreparedPropTarget>>;
|
|
46
|
+
readonly releasesGesture: boolean;
|
|
47
|
+
readonly path?: PathChannelSpec;
|
|
48
|
+
} | {
|
|
49
|
+
readonly kind: 'retarget';
|
|
50
|
+
readonly targets: Readonly<Record<string, number>>;
|
|
51
|
+
readonly transition: Transition;
|
|
52
|
+
readonly targetTransitions?: Readonly<Record<string, PropTransition>>;
|
|
53
|
+
} | {
|
|
54
|
+
readonly kind: 'stop';
|
|
55
|
+
};
|
|
56
|
+
export interface Driver {
|
|
57
|
+
register(initial: Readonly<Record<string, number>>): ElementHandle;
|
|
58
|
+
command(handle: ElementHandle, command: DriverCommand): void;
|
|
59
|
+
step(elapsedMs: number): void;
|
|
60
|
+
committed(handle: ElementHandle): Readonly<Record<string, number>>;
|
|
61
|
+
setActive(handle: ElementHandle, active: boolean): void;
|
|
62
|
+
isActive(handle: ElementHandle): boolean;
|
|
63
|
+
write(handle: ElementHandle, values: Readonly<Record<string, number>>, velocities?: Readonly<Record<string, number>>): void;
|
|
64
|
+
liveFor(handle: ElementHandle, key: string): LivePropState;
|
|
65
|
+
}
|
|
66
|
+
export type PreparedDriver = Omit<Driver, 'command'> & {
|
|
67
|
+
command(handle: ElementHandle, command: PreparedDriverCommand): void;
|
|
68
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Transition } from "../component/index.js";
|
|
2
|
+
import type { PathChannelGeometry } from "../motion-arc.js";
|
|
3
|
+
import type { DefaultTransition, InertiaTransition } from "../transition.js";
|
|
4
|
+
export type InternalDriverTransition = Transition | DefaultTransition | InertiaTransition;
|
|
5
|
+
export type PropTransition = InternalDriverTransition;
|
|
6
|
+
export interface PathChannelSpec extends PathChannelGeometry {
|
|
7
|
+
readonly transition: PropTransition;
|
|
8
|
+
}
|
|
9
|
+
export type ElementHandle = number & {
|
|
10
|
+
readonly __elementHandle: unique symbol;
|
|
11
|
+
};
|
|
12
|
+
export type PropTargetTo = number | readonly (number | null)[];
|
|
13
|
+
export interface PropTarget {
|
|
14
|
+
readonly to: PropTargetTo;
|
|
15
|
+
readonly from: number;
|
|
16
|
+
readonly velocity?: number;
|
|
17
|
+
readonly transition?: PropTransition;
|
|
18
|
+
}
|
|
19
|
+
export interface PreparedPropTarget {
|
|
20
|
+
readonly to: PropTargetTo;
|
|
21
|
+
readonly from: number;
|
|
22
|
+
readonly velocity: number;
|
|
23
|
+
readonly transition: PropTransition;
|
|
24
|
+
}
|
|
25
|
+
export interface LivePropState {
|
|
26
|
+
readonly value: number;
|
|
27
|
+
readonly velocity: number;
|
|
28
|
+
}
|
|
29
|
+
export type DriverCommand = {
|
|
30
|
+
readonly kind: 'start';
|
|
31
|
+
readonly targets: Readonly<Record<string, PropTarget>>;
|
|
32
|
+
readonly transition: Transition;
|
|
33
|
+
readonly releasesGesture?: boolean;
|
|
34
|
+
readonly path?: PathChannelSpec;
|
|
35
|
+
} | {
|
|
36
|
+
readonly kind: 'retarget';
|
|
37
|
+
readonly targets: Readonly<Record<string, number>>;
|
|
38
|
+
readonly transition: Transition;
|
|
39
|
+
readonly targetTransitions?: Readonly<Record<string, PropTransition>>;
|
|
40
|
+
} | {
|
|
41
|
+
readonly kind: 'stop';
|
|
42
|
+
};
|
|
43
|
+
export type PreparedDriverCommand = {
|
|
44
|
+
readonly kind: 'start';
|
|
45
|
+
readonly targets: Readonly<Record<string, PreparedPropTarget>>;
|
|
46
|
+
readonly releasesGesture: boolean;
|
|
47
|
+
readonly path?: PathChannelSpec;
|
|
48
|
+
} | {
|
|
49
|
+
readonly kind: 'retarget';
|
|
50
|
+
readonly targets: Readonly<Record<string, number>>;
|
|
51
|
+
readonly transition: Transition;
|
|
52
|
+
readonly targetTransitions?: Readonly<Record<string, PropTransition>>;
|
|
53
|
+
} | {
|
|
54
|
+
readonly kind: 'stop';
|
|
55
|
+
};
|
|
56
|
+
export interface Driver {
|
|
57
|
+
register(initial: Readonly<Record<string, number>>): ElementHandle;
|
|
58
|
+
command(handle: ElementHandle, command: DriverCommand): void;
|
|
59
|
+
step(elapsedMs: number): void;
|
|
60
|
+
committed(handle: ElementHandle): Readonly<Record<string, number>>;
|
|
61
|
+
setActive(handle: ElementHandle, active: boolean): void;
|
|
62
|
+
isActive(handle: ElementHandle): boolean;
|
|
63
|
+
write(handle: ElementHandle, values: Readonly<Record<string, number>>, velocities?: Readonly<Record<string, number>>): void;
|
|
64
|
+
liveFor(handle: ElementHandle, key: string): LivePropState;
|
|
65
|
+
}
|
|
66
|
+
export type PreparedDriver = Omit<Driver, 'command'> & {
|
|
67
|
+
command(handle: ElementHandle, command: PreparedDriverCommand): void;
|
|
68
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// SPEC-NATIVE-DRIVER §Requirements — the host-agnostic Driver interface + command types (REQ-DRIVER-010/
|
|
2
|
+
// 013). `core` DEFINES this interface; the native worklet driver and the web driver are peers that
|
|
3
|
+
// IMPLEMENT it (they import core; core imports no driver, no host, no `react-native-*`). The interface is
|
|
4
|
+
// the sole coupling point, so the substrate is replaceable without changing the public contract. The
|
|
5
|
+
// command surface is a discriminated union — an illegal command is unrepresentable, no permissive index
|
|
6
|
+
// signature, no `any` (REQ-DRIVER-015 type discipline). Host-agnostic (REQ-CORE-003): imports only the
|
|
7
|
+
// public `Transition` shape (relative).
|
|
8
|
+
export {};
|