@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,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPEC-GESTURE §2 — drag constraint application: hard clamp and Motion's linear rubber-band transfer. Pure
|
|
3
|
+
// functions (REQ-GESTURE-015/016, G-INV-6/8); host-agnostic (REQ-CORE-003): only a type import.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.elasticTransfer = elasticTransfer;
|
|
6
|
+
exports.assertLegalConstraintBounds = assertLegalConstraintBounds;
|
|
7
|
+
exports.applyConstraints = applyConstraints;
|
|
8
|
+
// Motion's linear rubber-band mix (REQ-GESTURE-016): overshoot = e · excess. Monotone non-decreasing in
|
|
9
|
+
// `excess` for e ≥ 0, exactly 0 at e = 0, continuous at the boundary (excess → 0 ⇒ overshoot → 0).
|
|
10
|
+
function elasticTransfer(excess, elastic) {
|
|
11
|
+
return elastic * excess;
|
|
12
|
+
}
|
|
13
|
+
// Open-side sentinels for one-sided numeric constraints (REQ-API-024 shipping slice, Motion parity):
|
|
14
|
+
// only `min = -Infinity` and/or `max = +Infinity` mean "no bound on that side". Wrong-polarity
|
|
15
|
+
// infinity (`min = +∞` or `max = -∞`) is illegal — it would make every release target Infinity and
|
|
16
|
+
// start a non-converging spring (G-INV-8). Shared by applyConstraints + selectReleaseTarget so the
|
|
17
|
+
// live clamp and the release seam never disagree on legality.
|
|
18
|
+
function assertLegalConstraintBounds(c, where = 'constraints') {
|
|
19
|
+
const minOk = Number.isFinite(c.min) || c.min === Number.NEGATIVE_INFINITY;
|
|
20
|
+
const maxOk = Number.isFinite(c.max) || c.max === Number.POSITIVE_INFINITY;
|
|
21
|
+
if (!minOk || !maxOk) {
|
|
22
|
+
throw new Error(`${where}: open-side sentinels must be min=-Infinity and/or max=+Infinity ` +
|
|
23
|
+
`(got min=${c.min}, max=${c.max}); wrong-polarity or NaN bounds are refused (G-INV-8, REQ-API-024).`);
|
|
24
|
+
}
|
|
25
|
+
if (c.min > c.max) {
|
|
26
|
+
throw new Error(`${where}: min (${c.min}) must be <= max (${c.max})`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// Validate + apply drag constraints (REQ-GESTURE-015/016, G-INV-8). Inside `[min, max]`: pass through. Past a
|
|
30
|
+
// bound: a hard clamp when elastic is 0/absent (`min ≤ value ≤ max`), else `bound ± e·excess` (rubber-band,
|
|
31
|
+
// symmetric on both bounds). Open sides (legal ±Infinity) skip that side's clamp. Malformed config —
|
|
32
|
+
// wrong-polarity sentinels, NaN bounds, `min > max`, or `elastic ∉ [0, 1]` — throws at the call site.
|
|
33
|
+
function applyConstraints(value, c) {
|
|
34
|
+
const elastic = c.elastic ?? 0;
|
|
35
|
+
assertLegalConstraintBounds(c, 'applyConstraints');
|
|
36
|
+
if (!Number.isFinite(elastic) || elastic < 0 || elastic > 1) {
|
|
37
|
+
throw new Error(`applyConstraints: elastic must be in [0, 1], got ${elastic}`);
|
|
38
|
+
}
|
|
39
|
+
if (Number.isFinite(c.max) && value > c.max)
|
|
40
|
+
return c.max + elasticTransfer(value - c.max, elastic);
|
|
41
|
+
if (Number.isFinite(c.min) && value < c.min)
|
|
42
|
+
return c.min - elasticTransfer(c.min - value, elastic);
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DragConstraints } from "./types.cjs";
|
|
2
|
+
export declare function elasticTransfer(excess: number, elastic: number): number;
|
|
3
|
+
export declare function assertLegalConstraintBounds(c: DragConstraints, where?: string): void;
|
|
4
|
+
export declare function applyConstraints(value: number, c: DragConstraints): number;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DragConstraints } from "./types.js";
|
|
2
|
+
export declare function elasticTransfer(excess: number, elastic: number): number;
|
|
3
|
+
export declare function assertLegalConstraintBounds(c: DragConstraints, where?: string): void;
|
|
4
|
+
export declare function applyConstraints(value: number, c: DragConstraints): number;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// SPEC-GESTURE §2 — drag constraint application: hard clamp and Motion's linear rubber-band transfer. Pure
|
|
2
|
+
// functions (REQ-GESTURE-015/016, G-INV-6/8); host-agnostic (REQ-CORE-003): only a type import.
|
|
3
|
+
// Motion's linear rubber-band mix (REQ-GESTURE-016): overshoot = e · excess. Monotone non-decreasing in
|
|
4
|
+
// `excess` for e ≥ 0, exactly 0 at e = 0, continuous at the boundary (excess → 0 ⇒ overshoot → 0).
|
|
5
|
+
export function elasticTransfer(excess, elastic) {
|
|
6
|
+
return elastic * excess;
|
|
7
|
+
}
|
|
8
|
+
// Open-side sentinels for one-sided numeric constraints (REQ-API-024 shipping slice, Motion parity):
|
|
9
|
+
// only `min = -Infinity` and/or `max = +Infinity` mean "no bound on that side". Wrong-polarity
|
|
10
|
+
// infinity (`min = +∞` or `max = -∞`) is illegal — it would make every release target Infinity and
|
|
11
|
+
// start a non-converging spring (G-INV-8). Shared by applyConstraints + selectReleaseTarget so the
|
|
12
|
+
// live clamp and the release seam never disagree on legality.
|
|
13
|
+
export function assertLegalConstraintBounds(c, where = 'constraints') {
|
|
14
|
+
const minOk = Number.isFinite(c.min) || c.min === Number.NEGATIVE_INFINITY;
|
|
15
|
+
const maxOk = Number.isFinite(c.max) || c.max === Number.POSITIVE_INFINITY;
|
|
16
|
+
if (!minOk || !maxOk) {
|
|
17
|
+
throw new Error(`${where}: open-side sentinels must be min=-Infinity and/or max=+Infinity ` +
|
|
18
|
+
`(got min=${c.min}, max=${c.max}); wrong-polarity or NaN bounds are refused (G-INV-8, REQ-API-024).`);
|
|
19
|
+
}
|
|
20
|
+
if (c.min > c.max) {
|
|
21
|
+
throw new Error(`${where}: min (${c.min}) must be <= max (${c.max})`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
// Validate + apply drag constraints (REQ-GESTURE-015/016, G-INV-8). Inside `[min, max]`: pass through. Past a
|
|
25
|
+
// bound: a hard clamp when elastic is 0/absent (`min ≤ value ≤ max`), else `bound ± e·excess` (rubber-band,
|
|
26
|
+
// symmetric on both bounds). Open sides (legal ±Infinity) skip that side's clamp. Malformed config —
|
|
27
|
+
// wrong-polarity sentinels, NaN bounds, `min > max`, or `elastic ∉ [0, 1]` — throws at the call site.
|
|
28
|
+
export function applyConstraints(value, c) {
|
|
29
|
+
const elastic = c.elastic ?? 0;
|
|
30
|
+
assertLegalConstraintBounds(c, 'applyConstraints');
|
|
31
|
+
if (!Number.isFinite(elastic) || elastic < 0 || elastic > 1) {
|
|
32
|
+
throw new Error(`applyConstraints: elastic must be in [0, 1], got ${elastic}`);
|
|
33
|
+
}
|
|
34
|
+
if (Number.isFinite(c.max) && value > c.max)
|
|
35
|
+
return c.max + elasticTransfer(value - c.max, elastic);
|
|
36
|
+
if (Number.isFinite(c.min) && value < c.min)
|
|
37
|
+
return c.min - elasticTransfer(c.min - value, elastic);
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// REQ-GESTURE-022 (FLAG 5a, specs/SPEC-GESTURE.md) — the DRIVER-INTEGRATED
|
|
3
|
+
// handoff session. The M1 session (`session.ts`) runs its release spring on its own graph — the
|
|
4
|
+
// deterministic M1 stand-in. The live public path may not: G-INV-9 puts gesture motion on the
|
|
5
|
+
// worklet/UI-thread path, and REQ-DRIVER-003 makes the driver the integrator. This variant keeps
|
|
6
|
+
// the SAME total state machine and per-event semantics (dead-zone REQ-GESTURE-011, clamp/elastic
|
|
7
|
+
// REQ-GESTURE-015/-016, shared release-target selection REQ-GESTURE-016/-017) but `end`/`cancel`/
|
|
8
|
+
// `fail` RETURN the `ReleaseHandoff` seed — discriminated by `curve`: the snap release and
|
|
9
|
+
// cancel/fail seed the driver's velocity-seeded spring (REQ-DRIVER-023); the free-drag release
|
|
10
|
+
// returns the two-phase inertia descriptor (REQ-GESTURE-023, R16) — and the machine goes
|
|
11
|
+
// straight `active → idle`: the integrator owns settling.
|
|
12
|
+
// A pure event fold — no graph, no clock, no spring; composes ONLY the exported seams the M1
|
|
13
|
+
// session composes, so the semantics can never fork.
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.createGestureHandoffSession = createGestureHandoffSession;
|
|
16
|
+
const elastic_1 = require("./elastic.cjs");
|
|
17
|
+
const projection_1 = require("./projection.cjs");
|
|
18
|
+
function createGestureHandoffSession(options) {
|
|
19
|
+
// The CONSTRUCTED config is the baseline: a per-grab begin override replaces it for THAT
|
|
20
|
+
// grab only — an unoverridden later begin restores it (review minor 6; native-motion
|
|
21
|
+
// re-measures at every grab but never forgets the prop-level config).
|
|
22
|
+
const baseConstraints = options.constraints;
|
|
23
|
+
let constraints = baseConstraints;
|
|
24
|
+
const snap = options.snap;
|
|
25
|
+
const momentum = options.momentum !== false;
|
|
26
|
+
let state = 'idle';
|
|
27
|
+
let current = 0; // the constrained drag value while active; meaningless when idle (integrator-owned)
|
|
28
|
+
let grabValue = 0; // the value at the grab (P0)
|
|
29
|
+
let activationTranslation = 0; // recognizer translation captured at activation (dead-zone subtraction)
|
|
30
|
+
let preGrabValue = 0; // the value before the current grab — the cancel target (REQ-GESTURE-018)
|
|
31
|
+
// P0 + (translation − activation), then hard-clamp / rubber-band (REQ-GESTURE-011/-015/-016).
|
|
32
|
+
// Delta-since-activation gives C0 across a non-zero activeOffset dead zone.
|
|
33
|
+
function applyTranslation(translation) {
|
|
34
|
+
const raw = grabValue + (translation - activationTranslation);
|
|
35
|
+
current = constraints === undefined ? raw : (0, elastic_1.applyConstraints)(raw, constraints);
|
|
36
|
+
}
|
|
37
|
+
function requireActive(entry) {
|
|
38
|
+
if (state !== 'active') {
|
|
39
|
+
throw new Error(`gesture: ${entry} in state '${state}' — begin() a gesture first`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// Cancel and fail share one path (REQ-GESTURE-018): a zero-velocity return to the pre-grab value,
|
|
43
|
+
// handed to the integrator. The ORIGIN is the driver's LIVE value at this instant (`releaseOrigin`),
|
|
44
|
+
// symmetric to end() — starting the return spring from the finger-tracked `current` would rewind a
|
|
45
|
+
// contending declarative drift (REQ-DRIVER-026), a visible backward jump violating C0 (r11 major 31,
|
|
46
|
+
// G-INV-2). In the no-contention case releaseOrigin == current, so this is the pre-fix behavior. The
|
|
47
|
+
// recognizer cannot cancel after a successful end, so (unlike the M1 session) there is no settling-
|
|
48
|
+
// phase redirect to model here.
|
|
49
|
+
function cancelHandoff(entry, releaseOrigin) {
|
|
50
|
+
requireActive(entry);
|
|
51
|
+
const handoff = {
|
|
52
|
+
curve: 'spring',
|
|
53
|
+
from: releaseOrigin,
|
|
54
|
+
velocity: 0,
|
|
55
|
+
target: preGrabValue,
|
|
56
|
+
};
|
|
57
|
+
state = 'idle';
|
|
58
|
+
return handoff;
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
begin(activationTranslation_, seed, beginOptions) {
|
|
62
|
+
if (state === 'active') {
|
|
63
|
+
throw new Error('gesture: begin() during an active gesture — end() or cancel() first');
|
|
64
|
+
}
|
|
65
|
+
// Per-grab constraints (REQ-GESTURE-028): the grab-time measured bounds replace the
|
|
66
|
+
// constructed config for THIS grab; an unoverridden begin restores the baseline.
|
|
67
|
+
constraints =
|
|
68
|
+
beginOptions !== undefined && 'constraints' in beginOptions
|
|
69
|
+
? beginOptions.constraints
|
|
70
|
+
: baseConstraints;
|
|
71
|
+
grabValue = seed.value;
|
|
72
|
+
preGrabValue = seed.value;
|
|
73
|
+
current = seed.value;
|
|
74
|
+
activationTranslation = activationTranslation_;
|
|
75
|
+
state = 'active';
|
|
76
|
+
},
|
|
77
|
+
active(translation) {
|
|
78
|
+
requireActive('active()');
|
|
79
|
+
applyTranslation(translation);
|
|
80
|
+
},
|
|
81
|
+
end(platformVelocity, releaseOrigin) {
|
|
82
|
+
requireActive('end()');
|
|
83
|
+
// The REQ-GESTURE-010 typed refusal reads the RAW recognizer sample first — the momentum
|
|
84
|
+
// gate below may zero a FINITE velocity but must never launder a corrupt one into a
|
|
85
|
+
// silent 0 (R16 review minor 6).
|
|
86
|
+
const platform = (0, projection_1.normalizeVelocity)(platformVelocity);
|
|
87
|
+
// dragMomentum (REQ-GESTURE-027): false zeroes the release velocity BEFORE any projection —
|
|
88
|
+
// the pin's `velocity: dragMomentum ? v : 0` — so a momentumless release settles at the
|
|
89
|
+
// release point (inertia ideal = origin; snap selection = nearest-to-origin), never slides
|
|
90
|
+
// to a projected landing.
|
|
91
|
+
const velocity = momentum ? platform : 0;
|
|
92
|
+
// REQ-GESTURE-022 release-origin symmetry: the ORIGIN of the handoff is the driver's LIVE value
|
|
93
|
+
// at release (`releaseOrigin`), passed in by the wiring via REQ-DRIVER-025. It reflects any
|
|
94
|
+
// contending declarative drift on the axis (REQ-DRIVER-026), which the finger-tracked `current`
|
|
95
|
+
// does NOT — so the release decision reads the value the element actually reached. Resolve
|
|
96
|
+
// BEFORE the state transition so a malformed config fails loud and leaves the session active.
|
|
97
|
+
let handoff;
|
|
98
|
+
if (snap !== undefined) {
|
|
99
|
+
// Snap release stays the project-then-snap spring at this rung (R16 recorded residual).
|
|
100
|
+
handoff = {
|
|
101
|
+
curve: 'spring',
|
|
102
|
+
from: releaseOrigin,
|
|
103
|
+
velocity,
|
|
104
|
+
target: (0, projection_1.selectReleaseTarget)(releaseOrigin, velocity, constraints, snap),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
// Free-drag (REQ-GESTURE-023, R16): the pinned two-phase inertia generator owns the curve.
|
|
109
|
+
// The descriptor carries the UNCLAMPED ideal's mirror terminal (the ideal clamped into the
|
|
110
|
+
// constraints) plus the bounds themselves, so the integrator runs the decay with the
|
|
111
|
+
// boundary spring at the walls instead of a spring to a pre-clamped target. The mirror
|
|
112
|
+
// terminal is not the settle point: an out-of-bounds origin settles AT the violated bound
|
|
113
|
+
// via the t=0 latch, which can diverge from the clamped ideal — harmless, since the
|
|
114
|
+
// drivers commit the generator's own settle value (see the ReleaseHandoff contract).
|
|
115
|
+
const ideal = (0, projection_1.project)(releaseOrigin, velocity);
|
|
116
|
+
let terminal = ideal;
|
|
117
|
+
if (constraints !== undefined) {
|
|
118
|
+
if (Number.isFinite(constraints.max) && terminal > constraints.max) {
|
|
119
|
+
terminal = constraints.max;
|
|
120
|
+
}
|
|
121
|
+
if (Number.isFinite(constraints.min) && terminal < constraints.min) {
|
|
122
|
+
terminal = constraints.min;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
handoff = {
|
|
126
|
+
curve: 'inertia',
|
|
127
|
+
from: releaseOrigin,
|
|
128
|
+
velocity,
|
|
129
|
+
target: terminal,
|
|
130
|
+
...(constraints === undefined ? {} : { min: constraints.min, max: constraints.max }),
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
state = 'idle';
|
|
134
|
+
return handoff;
|
|
135
|
+
},
|
|
136
|
+
cancel(releaseOrigin) {
|
|
137
|
+
return cancelHandoff('cancel()', releaseOrigin);
|
|
138
|
+
},
|
|
139
|
+
fail(releaseOrigin) {
|
|
140
|
+
return cancelHandoff('fail()', releaseOrigin);
|
|
141
|
+
},
|
|
142
|
+
updateConstraints(constraints_, value) {
|
|
143
|
+
requireActive('updateConstraints()');
|
|
144
|
+
constraints = constraints_;
|
|
145
|
+
// Re-anchor: shift the grab base by the rescale delta so the NEXT update's raw
|
|
146
|
+
// (grabValue + translation delta) continues FROM the rescaled value — the pin's
|
|
147
|
+
// originPoint += delta semantics exactly (C0, review major 3).
|
|
148
|
+
grabValue += value - current;
|
|
149
|
+
current = value;
|
|
150
|
+
},
|
|
151
|
+
value() {
|
|
152
|
+
// Outside an active drag the INTEGRATOR owns the value; a session read would be stale
|
|
153
|
+
// state masquerading as truth (the getter/mutator-skew class) — fail loud instead.
|
|
154
|
+
if (state !== 'active') {
|
|
155
|
+
throw new Error(`gesture: value() in state '${state}' — the integrator owns the value outside an active drag (REQ-GESTURE-022)`);
|
|
156
|
+
}
|
|
157
|
+
return current;
|
|
158
|
+
},
|
|
159
|
+
state: () => state,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { DragConstraints, SnapConfig } from "./types.cjs";
|
|
2
|
+
export type ReleaseHandoff = {
|
|
3
|
+
readonly curve: 'spring';
|
|
4
|
+
readonly from: number;
|
|
5
|
+
readonly velocity: number;
|
|
6
|
+
readonly target: number;
|
|
7
|
+
} | {
|
|
8
|
+
readonly curve: 'inertia';
|
|
9
|
+
readonly from: number;
|
|
10
|
+
readonly velocity: number;
|
|
11
|
+
readonly target: number;
|
|
12
|
+
readonly min?: number;
|
|
13
|
+
readonly max?: number;
|
|
14
|
+
};
|
|
15
|
+
export interface GestureHandoffSessionOptions {
|
|
16
|
+
readonly constraints?: DragConstraints;
|
|
17
|
+
readonly snap?: SnapConfig;
|
|
18
|
+
readonly momentum?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export type GestureHandoffSessionState = 'idle' | 'active';
|
|
21
|
+
export interface GestureHandoffSession {
|
|
22
|
+
begin(activationTranslation: number, seed: {
|
|
23
|
+
readonly value: number;
|
|
24
|
+
}, options?: {
|
|
25
|
+
readonly constraints?: DragConstraints;
|
|
26
|
+
}): void;
|
|
27
|
+
active(translation: number): void;
|
|
28
|
+
end(platformVelocity: number, releaseOrigin: number): ReleaseHandoff;
|
|
29
|
+
cancel(releaseOrigin: number): ReleaseHandoff;
|
|
30
|
+
fail(releaseOrigin: number): ReleaseHandoff;
|
|
31
|
+
updateConstraints(constraints: DragConstraints, value: number): void;
|
|
32
|
+
value(): number;
|
|
33
|
+
state(): GestureHandoffSessionState;
|
|
34
|
+
}
|
|
35
|
+
export declare function createGestureHandoffSession(options: GestureHandoffSessionOptions): GestureHandoffSession;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { DragConstraints, SnapConfig } from "./types.js";
|
|
2
|
+
export type ReleaseHandoff = {
|
|
3
|
+
readonly curve: 'spring';
|
|
4
|
+
readonly from: number;
|
|
5
|
+
readonly velocity: number;
|
|
6
|
+
readonly target: number;
|
|
7
|
+
} | {
|
|
8
|
+
readonly curve: 'inertia';
|
|
9
|
+
readonly from: number;
|
|
10
|
+
readonly velocity: number;
|
|
11
|
+
readonly target: number;
|
|
12
|
+
readonly min?: number;
|
|
13
|
+
readonly max?: number;
|
|
14
|
+
};
|
|
15
|
+
export interface GestureHandoffSessionOptions {
|
|
16
|
+
readonly constraints?: DragConstraints;
|
|
17
|
+
readonly snap?: SnapConfig;
|
|
18
|
+
readonly momentum?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export type GestureHandoffSessionState = 'idle' | 'active';
|
|
21
|
+
export interface GestureHandoffSession {
|
|
22
|
+
begin(activationTranslation: number, seed: {
|
|
23
|
+
readonly value: number;
|
|
24
|
+
}, options?: {
|
|
25
|
+
readonly constraints?: DragConstraints;
|
|
26
|
+
}): void;
|
|
27
|
+
active(translation: number): void;
|
|
28
|
+
end(platformVelocity: number, releaseOrigin: number): ReleaseHandoff;
|
|
29
|
+
cancel(releaseOrigin: number): ReleaseHandoff;
|
|
30
|
+
fail(releaseOrigin: number): ReleaseHandoff;
|
|
31
|
+
updateConstraints(constraints: DragConstraints, value: number): void;
|
|
32
|
+
value(): number;
|
|
33
|
+
state(): GestureHandoffSessionState;
|
|
34
|
+
}
|
|
35
|
+
export declare function createGestureHandoffSession(options: GestureHandoffSessionOptions): GestureHandoffSession;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// REQ-GESTURE-022 (FLAG 5a, specs/SPEC-GESTURE.md) — the DRIVER-INTEGRATED
|
|
2
|
+
// handoff session. The M1 session (`session.ts`) runs its release spring on its own graph — the
|
|
3
|
+
// deterministic M1 stand-in. The live public path may not: G-INV-9 puts gesture motion on the
|
|
4
|
+
// worklet/UI-thread path, and REQ-DRIVER-003 makes the driver the integrator. This variant keeps
|
|
5
|
+
// the SAME total state machine and per-event semantics (dead-zone REQ-GESTURE-011, clamp/elastic
|
|
6
|
+
// REQ-GESTURE-015/-016, shared release-target selection REQ-GESTURE-016/-017) but `end`/`cancel`/
|
|
7
|
+
// `fail` RETURN the `ReleaseHandoff` seed — discriminated by `curve`: the snap release and
|
|
8
|
+
// cancel/fail seed the driver's velocity-seeded spring (REQ-DRIVER-023); the free-drag release
|
|
9
|
+
// returns the two-phase inertia descriptor (REQ-GESTURE-023, R16) — and the machine goes
|
|
10
|
+
// straight `active → idle`: the integrator owns settling.
|
|
11
|
+
// A pure event fold — no graph, no clock, no spring; composes ONLY the exported seams the M1
|
|
12
|
+
// session composes, so the semantics can never fork.
|
|
13
|
+
import { applyConstraints } from "./elastic.js";
|
|
14
|
+
import { normalizeVelocity, project, selectReleaseTarget } from "./projection.js";
|
|
15
|
+
export function createGestureHandoffSession(options) {
|
|
16
|
+
// The CONSTRUCTED config is the baseline: a per-grab begin override replaces it for THAT
|
|
17
|
+
// grab only — an unoverridden later begin restores it (review minor 6; native-motion
|
|
18
|
+
// re-measures at every grab but never forgets the prop-level config).
|
|
19
|
+
const baseConstraints = options.constraints;
|
|
20
|
+
let constraints = baseConstraints;
|
|
21
|
+
const snap = options.snap;
|
|
22
|
+
const momentum = options.momentum !== false;
|
|
23
|
+
let state = 'idle';
|
|
24
|
+
let current = 0; // the constrained drag value while active; meaningless when idle (integrator-owned)
|
|
25
|
+
let grabValue = 0; // the value at the grab (P0)
|
|
26
|
+
let activationTranslation = 0; // recognizer translation captured at activation (dead-zone subtraction)
|
|
27
|
+
let preGrabValue = 0; // the value before the current grab — the cancel target (REQ-GESTURE-018)
|
|
28
|
+
// P0 + (translation − activation), then hard-clamp / rubber-band (REQ-GESTURE-011/-015/-016).
|
|
29
|
+
// Delta-since-activation gives C0 across a non-zero activeOffset dead zone.
|
|
30
|
+
function applyTranslation(translation) {
|
|
31
|
+
const raw = grabValue + (translation - activationTranslation);
|
|
32
|
+
current = constraints === undefined ? raw : applyConstraints(raw, constraints);
|
|
33
|
+
}
|
|
34
|
+
function requireActive(entry) {
|
|
35
|
+
if (state !== 'active') {
|
|
36
|
+
throw new Error(`gesture: ${entry} in state '${state}' — begin() a gesture first`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// Cancel and fail share one path (REQ-GESTURE-018): a zero-velocity return to the pre-grab value,
|
|
40
|
+
// handed to the integrator. The ORIGIN is the driver's LIVE value at this instant (`releaseOrigin`),
|
|
41
|
+
// symmetric to end() — starting the return spring from the finger-tracked `current` would rewind a
|
|
42
|
+
// contending declarative drift (REQ-DRIVER-026), a visible backward jump violating C0 (r11 major 31,
|
|
43
|
+
// G-INV-2). In the no-contention case releaseOrigin == current, so this is the pre-fix behavior. The
|
|
44
|
+
// recognizer cannot cancel after a successful end, so (unlike the M1 session) there is no settling-
|
|
45
|
+
// phase redirect to model here.
|
|
46
|
+
function cancelHandoff(entry, releaseOrigin) {
|
|
47
|
+
requireActive(entry);
|
|
48
|
+
const handoff = {
|
|
49
|
+
curve: 'spring',
|
|
50
|
+
from: releaseOrigin,
|
|
51
|
+
velocity: 0,
|
|
52
|
+
target: preGrabValue,
|
|
53
|
+
};
|
|
54
|
+
state = 'idle';
|
|
55
|
+
return handoff;
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
begin(activationTranslation_, seed, beginOptions) {
|
|
59
|
+
if (state === 'active') {
|
|
60
|
+
throw new Error('gesture: begin() during an active gesture — end() or cancel() first');
|
|
61
|
+
}
|
|
62
|
+
// Per-grab constraints (REQ-GESTURE-028): the grab-time measured bounds replace the
|
|
63
|
+
// constructed config for THIS grab; an unoverridden begin restores the baseline.
|
|
64
|
+
constraints =
|
|
65
|
+
beginOptions !== undefined && 'constraints' in beginOptions
|
|
66
|
+
? beginOptions.constraints
|
|
67
|
+
: baseConstraints;
|
|
68
|
+
grabValue = seed.value;
|
|
69
|
+
preGrabValue = seed.value;
|
|
70
|
+
current = seed.value;
|
|
71
|
+
activationTranslation = activationTranslation_;
|
|
72
|
+
state = 'active';
|
|
73
|
+
},
|
|
74
|
+
active(translation) {
|
|
75
|
+
requireActive('active()');
|
|
76
|
+
applyTranslation(translation);
|
|
77
|
+
},
|
|
78
|
+
end(platformVelocity, releaseOrigin) {
|
|
79
|
+
requireActive('end()');
|
|
80
|
+
// The REQ-GESTURE-010 typed refusal reads the RAW recognizer sample first — the momentum
|
|
81
|
+
// gate below may zero a FINITE velocity but must never launder a corrupt one into a
|
|
82
|
+
// silent 0 (R16 review minor 6).
|
|
83
|
+
const platform = normalizeVelocity(platformVelocity);
|
|
84
|
+
// dragMomentum (REQ-GESTURE-027): false zeroes the release velocity BEFORE any projection —
|
|
85
|
+
// the pin's `velocity: dragMomentum ? v : 0` — so a momentumless release settles at the
|
|
86
|
+
// release point (inertia ideal = origin; snap selection = nearest-to-origin), never slides
|
|
87
|
+
// to a projected landing.
|
|
88
|
+
const velocity = momentum ? platform : 0;
|
|
89
|
+
// REQ-GESTURE-022 release-origin symmetry: the ORIGIN of the handoff is the driver's LIVE value
|
|
90
|
+
// at release (`releaseOrigin`), passed in by the wiring via REQ-DRIVER-025. It reflects any
|
|
91
|
+
// contending declarative drift on the axis (REQ-DRIVER-026), which the finger-tracked `current`
|
|
92
|
+
// does NOT — so the release decision reads the value the element actually reached. Resolve
|
|
93
|
+
// BEFORE the state transition so a malformed config fails loud and leaves the session active.
|
|
94
|
+
let handoff;
|
|
95
|
+
if (snap !== undefined) {
|
|
96
|
+
// Snap release stays the project-then-snap spring at this rung (R16 recorded residual).
|
|
97
|
+
handoff = {
|
|
98
|
+
curve: 'spring',
|
|
99
|
+
from: releaseOrigin,
|
|
100
|
+
velocity,
|
|
101
|
+
target: selectReleaseTarget(releaseOrigin, velocity, constraints, snap),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
// Free-drag (REQ-GESTURE-023, R16): the pinned two-phase inertia generator owns the curve.
|
|
106
|
+
// The descriptor carries the UNCLAMPED ideal's mirror terminal (the ideal clamped into the
|
|
107
|
+
// constraints) plus the bounds themselves, so the integrator runs the decay with the
|
|
108
|
+
// boundary spring at the walls instead of a spring to a pre-clamped target. The mirror
|
|
109
|
+
// terminal is not the settle point: an out-of-bounds origin settles AT the violated bound
|
|
110
|
+
// via the t=0 latch, which can diverge from the clamped ideal — harmless, since the
|
|
111
|
+
// drivers commit the generator's own settle value (see the ReleaseHandoff contract).
|
|
112
|
+
const ideal = project(releaseOrigin, velocity);
|
|
113
|
+
let terminal = ideal;
|
|
114
|
+
if (constraints !== undefined) {
|
|
115
|
+
if (Number.isFinite(constraints.max) && terminal > constraints.max) {
|
|
116
|
+
terminal = constraints.max;
|
|
117
|
+
}
|
|
118
|
+
if (Number.isFinite(constraints.min) && terminal < constraints.min) {
|
|
119
|
+
terminal = constraints.min;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
handoff = {
|
|
123
|
+
curve: 'inertia',
|
|
124
|
+
from: releaseOrigin,
|
|
125
|
+
velocity,
|
|
126
|
+
target: terminal,
|
|
127
|
+
...(constraints === undefined ? {} : { min: constraints.min, max: constraints.max }),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
state = 'idle';
|
|
131
|
+
return handoff;
|
|
132
|
+
},
|
|
133
|
+
cancel(releaseOrigin) {
|
|
134
|
+
return cancelHandoff('cancel()', releaseOrigin);
|
|
135
|
+
},
|
|
136
|
+
fail(releaseOrigin) {
|
|
137
|
+
return cancelHandoff('fail()', releaseOrigin);
|
|
138
|
+
},
|
|
139
|
+
updateConstraints(constraints_, value) {
|
|
140
|
+
requireActive('updateConstraints()');
|
|
141
|
+
constraints = constraints_;
|
|
142
|
+
// Re-anchor: shift the grab base by the rescale delta so the NEXT update's raw
|
|
143
|
+
// (grabValue + translation delta) continues FROM the rescaled value — the pin's
|
|
144
|
+
// originPoint += delta semantics exactly (C0, review major 3).
|
|
145
|
+
grabValue += value - current;
|
|
146
|
+
current = value;
|
|
147
|
+
},
|
|
148
|
+
value() {
|
|
149
|
+
// Outside an active drag the INTEGRATOR owns the value; a session read would be stale
|
|
150
|
+
// state masquerading as truth (the getter/mutator-skew class) — fail loud instead.
|
|
151
|
+
if (state !== 'active') {
|
|
152
|
+
throw new Error(`gesture: value() in state '${state}' — the integrator owns the value outside an active drag (REQ-GESTURE-022)`);
|
|
153
|
+
}
|
|
154
|
+
return current;
|
|
155
|
+
},
|
|
156
|
+
state: () => state,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPEC-GESTURE host-agnostic gesture subsystem (REQ-GESTURE-*): the pure gesture math (Milestone 1) — the
|
|
3
|
+
// projection function, project-then-snap selection, velocity normalization, and constraint transfer. The
|
|
4
|
+
// gesture SESSION (state machine + grab/release/cancel over the MotionGraph) joins here as it lands
|
|
5
|
+
// (Milestones 2-4). Host-agnostic — no react/react-native/Gesture-Handler/driver import.
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.resolveViewportConstraints = exports.progressWithinSpan = exports.resolveDirectionLockAxis = exports.DIRECTION_LOCK_THRESHOLD_PX = exports.validateMeasureReplacementBox = exports.validateDragControlOptions = exports.resolvedDragAxes = exports.resolveDragConfig = exports.gateOrphanDragCallbacks = exports.dragConfigMountSignature = exports.describeValue = exports.DEFAULT_DRAG_ELASTIC = exports.createGestureHandoffSession = exports.GESTURE_RELEASE_SPRING = exports.createGestureSession = exports.applyConstraints = exports.elasticTransfer = exports.selectReleaseTarget = exports.absoluteDragOrigin = exports.normalizeVelocity = exports.selectSnap = exports.project = exports.PROJECTION_POWER = void 0;
|
|
8
|
+
var projection_1 = require("./projection.cjs");
|
|
9
|
+
Object.defineProperty(exports, "PROJECTION_POWER", { enumerable: true, get: function () { return projection_1.PROJECTION_POWER; } });
|
|
10
|
+
Object.defineProperty(exports, "project", { enumerable: true, get: function () { return projection_1.project; } });
|
|
11
|
+
Object.defineProperty(exports, "selectSnap", { enumerable: true, get: function () { return projection_1.selectSnap; } });
|
|
12
|
+
Object.defineProperty(exports, "normalizeVelocity", { enumerable: true, get: function () { return projection_1.normalizeVelocity; } });
|
|
13
|
+
Object.defineProperty(exports, "absoluteDragOrigin", { enumerable: true, get: function () { return projection_1.absoluteDragOrigin; } });
|
|
14
|
+
Object.defineProperty(exports, "selectReleaseTarget", { enumerable: true, get: function () { return projection_1.selectReleaseTarget; } });
|
|
15
|
+
var elastic_1 = require("./elastic.cjs");
|
|
16
|
+
Object.defineProperty(exports, "elasticTransfer", { enumerable: true, get: function () { return elastic_1.elasticTransfer; } });
|
|
17
|
+
Object.defineProperty(exports, "applyConstraints", { enumerable: true, get: function () { return elastic_1.applyConstraints; } });
|
|
18
|
+
var session_1 = require("./session.cjs");
|
|
19
|
+
Object.defineProperty(exports, "createGestureSession", { enumerable: true, get: function () { return session_1.createGestureSession; } });
|
|
20
|
+
Object.defineProperty(exports, "GESTURE_RELEASE_SPRING", { enumerable: true, get: function () { return session_1.GESTURE_RELEASE_SPRING; } });
|
|
21
|
+
var handoffSession_1 = require("./handoffSession.cjs");
|
|
22
|
+
Object.defineProperty(exports, "createGestureHandoffSession", { enumerable: true, get: function () { return handoffSession_1.createGestureHandoffSession; } });
|
|
23
|
+
var dragConfig_1 = require("./dragConfig.cjs");
|
|
24
|
+
Object.defineProperty(exports, "DEFAULT_DRAG_ELASTIC", { enumerable: true, get: function () { return dragConfig_1.DEFAULT_DRAG_ELASTIC; } });
|
|
25
|
+
Object.defineProperty(exports, "describeValue", { enumerable: true, get: function () { return dragConfig_1.describeValue; } });
|
|
26
|
+
Object.defineProperty(exports, "dragConfigMountSignature", { enumerable: true, get: function () { return dragConfig_1.dragConfigMountSignature; } });
|
|
27
|
+
Object.defineProperty(exports, "gateOrphanDragCallbacks", { enumerable: true, get: function () { return dragConfig_1.gateOrphanDragCallbacks; } });
|
|
28
|
+
Object.defineProperty(exports, "resolveDragConfig", { enumerable: true, get: function () { return dragConfig_1.resolveDragConfig; } });
|
|
29
|
+
Object.defineProperty(exports, "resolvedDragAxes", { enumerable: true, get: function () { return dragConfig_1.resolvedDragAxes; } });
|
|
30
|
+
Object.defineProperty(exports, "validateDragControlOptions", { enumerable: true, get: function () { return dragConfig_1.validateDragControlOptions; } });
|
|
31
|
+
Object.defineProperty(exports, "validateMeasureReplacementBox", { enumerable: true, get: function () { return dragConfig_1.validateMeasureReplacementBox; } });
|
|
32
|
+
var directionLock_1 = require("./directionLock.cjs");
|
|
33
|
+
Object.defineProperty(exports, "DIRECTION_LOCK_THRESHOLD_PX", { enumerable: true, get: function () { return directionLock_1.DIRECTION_LOCK_THRESHOLD_PX; } });
|
|
34
|
+
Object.defineProperty(exports, "resolveDirectionLockAxis", { enumerable: true, get: function () { return directionLock_1.resolveDirectionLockAxis; } });
|
|
35
|
+
var viewportConstraints_1 = require("./viewportConstraints.cjs");
|
|
36
|
+
Object.defineProperty(exports, "progressWithinSpan", { enumerable: true, get: function () { return viewportConstraints_1.progressWithinSpan; } });
|
|
37
|
+
Object.defineProperty(exports, "resolveViewportConstraints", { enumerable: true, get: function () { return viewportConstraints_1.resolveViewportConstraints; } });
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type { GestureSample, DragConstraints, SnapConfig } from "./types.cjs";
|
|
2
|
+
export { PROJECTION_POWER, project, selectSnap, normalizeVelocity, absoluteDragOrigin, selectReleaseTarget, } from "./projection.cjs";
|
|
3
|
+
export { elasticTransfer, applyConstraints } from "./elastic.cjs";
|
|
4
|
+
export type { GestureSession, GestureSessionOptions, GestureSessionState } from "./session.cjs";
|
|
5
|
+
export { createGestureSession, GESTURE_RELEASE_SPRING } from "./session.cjs";
|
|
6
|
+
export type { GestureHandoffSession, GestureHandoffSessionOptions, GestureHandoffSessionState, ReleaseHandoff, } from "./handoffSession.cjs";
|
|
7
|
+
export { createGestureHandoffSession } from "./handoffSession.cjs";
|
|
8
|
+
export type { DragAxis, DragCallback, DragConfigInput, DragConfigSeverity, DragConstraintsBoth, DragConstraintsInput, DragConstraintsRef, DragConstraintsX, DragConstraintsY, DragControlOptions, DragControlsHandle, DragInfo, DragProp, TapCallback, TapInfo, DragProps, DragSnapPointsInput, DragSnapPointsX, DragSnapPointsY, MeasuredDragConstraints, MeasureDragConstraintsCallback, ResolvedDragAxisConfig, ResolvedDragConfig, } from "./dragConfig.cjs";
|
|
9
|
+
export { DEFAULT_DRAG_ELASTIC, describeValue, dragConfigMountSignature, gateOrphanDragCallbacks, resolveDragConfig, resolvedDragAxes, validateDragControlOptions, validateMeasureReplacementBox, } from "./dragConfig.cjs";
|
|
10
|
+
export { DIRECTION_LOCK_THRESHOLD_PX, resolveDirectionLockAxis } from "./directionLock.cjs";
|
|
11
|
+
export type { AxisSpan } from "./viewportConstraints.cjs";
|
|
12
|
+
export { progressWithinSpan, resolveViewportConstraints } from "./viewportConstraints.cjs";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type { GestureSample, DragConstraints, SnapConfig } from "./types.js";
|
|
2
|
+
export { PROJECTION_POWER, project, selectSnap, normalizeVelocity, absoluteDragOrigin, selectReleaseTarget, } from "./projection.js";
|
|
3
|
+
export { elasticTransfer, applyConstraints } from "./elastic.js";
|
|
4
|
+
export type { GestureSession, GestureSessionOptions, GestureSessionState } from "./session.js";
|
|
5
|
+
export { createGestureSession, GESTURE_RELEASE_SPRING } from "./session.js";
|
|
6
|
+
export type { GestureHandoffSession, GestureHandoffSessionOptions, GestureHandoffSessionState, ReleaseHandoff, } from "./handoffSession.js";
|
|
7
|
+
export { createGestureHandoffSession } from "./handoffSession.js";
|
|
8
|
+
export type { DragAxis, DragCallback, DragConfigInput, DragConfigSeverity, DragConstraintsBoth, DragConstraintsInput, DragConstraintsRef, DragConstraintsX, DragConstraintsY, DragControlOptions, DragControlsHandle, DragInfo, DragProp, TapCallback, TapInfo, DragProps, DragSnapPointsInput, DragSnapPointsX, DragSnapPointsY, MeasuredDragConstraints, MeasureDragConstraintsCallback, ResolvedDragAxisConfig, ResolvedDragConfig, } from "./dragConfig.js";
|
|
9
|
+
export { DEFAULT_DRAG_ELASTIC, describeValue, dragConfigMountSignature, gateOrphanDragCallbacks, resolveDragConfig, resolvedDragAxes, validateDragControlOptions, validateMeasureReplacementBox, } from "./dragConfig.js";
|
|
10
|
+
export { DIRECTION_LOCK_THRESHOLD_PX, resolveDirectionLockAxis } from "./directionLock.js";
|
|
11
|
+
export type { AxisSpan } from "./viewportConstraints.js";
|
|
12
|
+
export { progressWithinSpan, resolveViewportConstraints } from "./viewportConstraints.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// SPEC-GESTURE host-agnostic gesture subsystem (REQ-GESTURE-*): the pure gesture math (Milestone 1) — the
|
|
2
|
+
// projection function, project-then-snap selection, velocity normalization, and constraint transfer. The
|
|
3
|
+
// gesture SESSION (state machine + grab/release/cancel over the MotionGraph) joins here as it lands
|
|
4
|
+
// (Milestones 2-4). Host-agnostic — no react/react-native/Gesture-Handler/driver import.
|
|
5
|
+
export { PROJECTION_POWER, project, selectSnap, normalizeVelocity, absoluteDragOrigin, selectReleaseTarget, } from "./projection.js";
|
|
6
|
+
export { elasticTransfer, applyConstraints } from "./elastic.js";
|
|
7
|
+
export { createGestureSession, GESTURE_RELEASE_SPRING } from "./session.js";
|
|
8
|
+
export { createGestureHandoffSession } from "./handoffSession.js";
|
|
9
|
+
export { DEFAULT_DRAG_ELASTIC, describeValue, dragConfigMountSignature, gateOrphanDragCallbacks, resolveDragConfig, resolvedDragAxes, validateDragControlOptions, validateMeasureReplacementBox, } from "./dragConfig.js";
|
|
10
|
+
export { DIRECTION_LOCK_THRESHOLD_PX, resolveDirectionLockAxis } from "./directionLock.js";
|
|
11
|
+
export { progressWithinSpan, resolveViewportConstraints } from "./viewportConstraints.js";
|