Skip to content

Commit 38007d4

Browse files
committed
feat(core): experimental motion and gesture subpaths for touch presentations
@astryxdesign/core/motion/experimental exports the compositor animator (createAnimator, useAnimator), the spring, rubber-band and cubic-bezier math, and the UIKit constants table as the read-only uikit namespace. @astryxdesign/core/gestures/experimental exports the gesture recognizers, useGestureRecognizer, usePressTracker, the touch presentation resolver and playHaptic. Both follow spec:AST-017's experimental boundary: never re-exported from the package root or an ordinary subpath, @experimental on every exposed declaration, stability: 'experimental' docs. The internal gestures barrel gets no subpath.
1 parent 235bd81 commit 38007d4

39 files changed

Lines changed: 1084 additions & 20 deletions
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@astryxdesign/core': patch
3+
---
4+
5+
[experimental] Two experimental subpaths for building touch presentations, outside the stable compatibility promise (they may change or be removed in a patch release). `@astryxdesign/core/motion/experimental` exports the compositor animator (`createAnimator`, `useAnimator`), UIKit's spring, rubber-band and cubic-bézier math, and the UIKit constants table as the read-only `uikit` namespace. `@astryxdesign/core/gestures/experimental` exports UIKit-style gesture recognizers (tap, long press, pan, screen-edge pan, swipe, pinch, rotation, hover), `useGestureRecognizer`, `usePressTracker`, `useTouchPresentation`, `readTouchPresentation` and `playHaptic`. Nothing is added to the package root or to any other subpath.
6+
7+
@vjeux

‎internal/shadcn-registry/routes.lock.json‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3744,6 +3744,11 @@
37443744
"path": "examples/visually-hidden/supplementary-context",
37453745
"aliases": []
37463746
},
3747+
{
3748+
"name": "hook-use-animator",
3749+
"path": "hooks/use-animator",
3750+
"aliases": []
3751+
},
37473752
{
37483753
"name": "hook-use-announce",
37493754
"path": "hooks/use-announce",
@@ -3799,6 +3804,11 @@
37993804
"path": "hooks/use-focus-trap",
38003805
"aliases": []
38013806
},
3807+
{
3808+
"name": "hook-use-gesture-recognizer",
3809+
"path": "hooks/use-gesture-recognizer",
3810+
"aliases": []
3811+
},
38023812
{
38033813
"name": "hook-use-grid-focus",
38043814
"path": "hooks/use-grid-focus",
@@ -3909,6 +3919,11 @@
39093919
"path": "hooks/use-press-feedback",
39103920
"aliases": []
39113921
},
3922+
{
3923+
"name": "hook-use-press-tracker",
3924+
"path": "hooks/use-press-tracker",
3925+
"aliases": []
3926+
},
39123927
{
39133928
"name": "hook-use-resizable",
39143929
"path": "hooks/use-resizable",
@@ -4024,6 +4039,11 @@
40244039
"path": "hooks/use-tooltip",
40254040
"aliases": []
40264041
},
4042+
{
4043+
"name": "hook-use-touch-presentation",
4044+
"path": "hooks/use-touch-presentation",
4045+
"aliases": []
4046+
},
40274047
{
40284048
"name": "hook-use-translator",
40294049
"path": "hooks/use-translator",

‎packages/cli/test/__golden__/no-icon-set/search-experimental.json‎

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,68 @@
33
"type": "search",
44
"data": {
55
"query": "experimental",
6-
"matchCount": 3,
6+
"matchCount": 7,
77
"results": [
8+
{
9+
"domain": "hook",
10+
"name": "useAnimator",
11+
"package": "@astryxdesign/core",
12+
"score": "<text>",
13+
"reason": "<text>",
14+
"description": "<text>",
15+
"import": "@astryxdesign/core/motion/experimental",
16+
"command": "astryx hook useAnimator",
17+
"mentions": [
18+
"@astryxdesign/core/motion/experimental",
19+
"Experimental: this hook and everything exported from `@astryxdesign/core/motion/experimental` are outside the stable compatibility promise and may change or be removed in a patch release.",
20+
"keyword \"experimental\""
21+
]
22+
},
23+
{
24+
"domain": "hook",
25+
"name": "useGestureRecognizer",
26+
"package": "@astryxdesign/core",
27+
"score": "<text>",
28+
"reason": "<text>",
29+
"description": "<text>",
30+
"import": "@astryxdesign/core/gestures/experimental",
31+
"command": "astryx hook useGestureRecognizer",
32+
"mentions": [
33+
"@astryxdesign/core/gestures/experimental",
34+
"Experimental: this hook may change or be removed in a patch release.",
35+
"description mentions \"experimental\""
36+
]
37+
},
38+
{
39+
"domain": "hook",
40+
"name": "usePressTracker",
41+
"package": "@astryxdesign/core",
42+
"score": "<text>",
43+
"reason": "<text>",
44+
"description": "<text>",
45+
"import": "@astryxdesign/core/gestures/experimental",
46+
"command": "astryx hook usePressTracker",
47+
"mentions": [
48+
"@astryxdesign/core/gestures/experimental",
49+
"Experimental: this hook may change or be removed in a patch release.",
50+
"description mentions \"experimental\""
51+
]
52+
},
53+
{
54+
"domain": "hook",
55+
"name": "useTouchPresentation",
56+
"package": "@astryxdesign/core",
57+
"score": "<text>",
58+
"reason": "<text>",
59+
"description": "<text>",
60+
"import": "@astryxdesign/core/gestures/experimental",
61+
"command": "astryx hook useTouchPresentation",
62+
"mentions": [
63+
"@astryxdesign/core/gestures/experimental",
64+
"Experimental: this hook may change or be removed in a patch release.",
65+
"description mentions \"experimental\""
66+
]
67+
},
868
{
969
"domain": "doc",
1070
"name": "authoring/field-reference",

‎packages/cli/test/__golden__/no-icon-set/search-experimental.txt‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
1-
Results for "experimental" (3)
1+
Results for "experimental" (7)
2+
name: useAnimator
3+
domain: hook
4+
package: @astryxdesign/core
5+
import: @astryxdesign/core/motion/experimental
6+
command: pnpm exec astryx hook useAnimator
7+
name: useGestureRecognizer
8+
domain: hook
9+
package: @astryxdesign/core
10+
import: @astryxdesign/core/gestures/experimental
11+
command: pnpm exec astryx hook useGestureRecognizer
12+
name: usePressTracker
13+
domain: hook
14+
package: @astryxdesign/core
15+
import: @astryxdesign/core/gestures/experimental
16+
command: pnpm exec astryx hook usePressTracker
17+
name: useTouchPresentation
18+
domain: hook
19+
package: @astryxdesign/core
20+
import: @astryxdesign/core/gestures/experimental
21+
command: pnpm exec astryx hook useTouchPresentation
222
name: authoring/field-reference
323
section: config
424
domain: doc

‎packages/core/package.json‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@
6161
"types": "./dist/naming.d.ts",
6262
"default": "./dist/naming.js"
6363
},
64+
"./motion/experimental": {
65+
"source": "./src/motion/experimental.ts",
66+
"types": "./dist/motion/experimental.d.ts",
67+
"default": "./dist/motion/experimental.js"
68+
},
69+
"./gestures/experimental": {
70+
"source": "./src/gestures/experimental.ts",
71+
"types": "./dist/gestures/experimental.d.ts",
72+
"default": "./dist/gestures/experimental.js"
73+
},
6474
"./theme/tokens": {
6575
"source": "./src/theme/tokens.ts",
6676
"types": "./dist/theme/tokens.d.ts",

‎packages/core/src/gestures/GestureRecognizer.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import type {
3838
} from './types';
3939
import {DEFAULT_ENVIRONMENT} from './types';
4040

41+
/** @experimental */
4142
export interface GestureRecognizerOptions<R = GestureRecognizer> {
4243
/** A name for debugging and test output. */
4344
name?: string;
@@ -78,8 +79,10 @@ export interface GestureRecognizerOptions<R = GestureRecognizer> {
7879
) => boolean;
7980
}
8081

82+
/** @experimental */
8183
export type GestureListener<R> = (recognizer: R) => void;
8284

85+
/** @experimental */
8386
export type GestureTransitionListener<R> = (
8487
recognizer: R,
8588
from: GestureState,
@@ -110,15 +113,20 @@ export function isTransitionAllowed(
110113
return ALLOWED[from].includes(to);
111114
}
112115

116+
/** @experimental */
113117
export function isTerminal(state: GestureState): boolean {
114118
return state === 'ended' || state === 'cancelled' || state === 'failed';
115119
}
116120

121+
/** @experimental */
117122
export function isActive(state: GestureState): boolean {
118123
return state === 'began' || state === 'changed';
119124
}
120125

121-
/** The browser behaviors `touch-action` can keep or remove. */
126+
/**
127+
* The browser behaviors `touch-action` can keep or remove.
128+
* @experimental
129+
*/
122130
export interface NativeTouchBehavior {
123131
readonly panX: boolean;
124132
readonly panY: boolean;
@@ -144,6 +152,7 @@ export const MANIPULATION: NativeTouchBehavior = {
144152

145153
let nextRecognizerId = 1;
146154

155+
/** @experimental */
147156
export abstract class GestureRecognizer {
148157
/** Stable id, for ordering and debugging. */
149158
readonly id = nextRecognizerId++;

‎packages/core/src/gestures/HoverGestureRecognizer.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
} from './GestureRecognizer';
2222
import type {Point, PointerKind} from './types';
2323

24+
/** @experimental */
2425
export class HoverGestureRecognizer extends GestureRecognizer {
2526
private point: Point = {x: 0, y: 0};
2627
/** The kind of pointer hovering: a mouse, or a pen in range. */

‎packages/core/src/gestures/LongPressGestureRecognizer.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
} from './GestureRecognizer';
3232
import type {GestureEventContext, GestureTouch} from './types';
3333

34+
/** @experimental */
3435
export interface LongPressGestureRecognizerOptions extends GestureRecognizerOptions<LongPressGestureRecognizer> {
3536
minimumPressDuration?: number;
3637
allowableMovement?: number;
@@ -40,6 +41,7 @@ export interface LongPressGestureRecognizerOptions extends GestureRecognizerOpti
4041
numberOfTouchesRequired?: number;
4142
}
4243

44+
/** @experimental */
4345
export class LongPressGestureRecognizer extends GestureRecognizer {
4446
minimumPressDuration: number;
4547
allowableMovement: number;

‎packages/core/src/gestures/PanGestureRecognizer.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ import {
5151
import type {GestureEventContext, GestureTouch, Point} from './types';
5252
import {VelocityTracker, type VelocityStrategy} from './VelocityTracker';
5353

54+
/** @experimental */
5455
export type PanDirection =
5556
'any' | 'horizontal' | 'vertical' | 'left' | 'right' | 'up' | 'down';
5657

58+
/** @experimental */
5759
export interface PanGestureRecognizerOptions extends GestureRecognizerOptions<PanGestureRecognizer> {
5860
/** @default 1 */
5961
minimumNumberOfTouches?: number;
@@ -118,6 +120,7 @@ const DIRECTION_VECTORS: Partial<Record<PanDirection, Point>> = {
118120
down: {x: 0, y: 1},
119121
};
120122

123+
/** @experimental */
121124
export class PanGestureRecognizer extends GestureRecognizer {
122125
minimumNumberOfTouches: number;
123126
maximumNumberOfTouches: number;

‎packages/core/src/gestures/PinchGestureRecognizer.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ import {
3030
import type {GestureEventContext, GestureTouch, Point} from './types';
3131
import {VelocityTracker} from './VelocityTracker';
3232

33+
/** @experimental */
3334
export interface PinchGestureRecognizerOptions extends GestureRecognizerOptions<PinchGestureRecognizer> {
3435
hysteresis?: number;
3536
}
3637

38+
/** @experimental */
3739
export class PinchGestureRecognizer extends GestureRecognizer {
3840
hysteresis: number;
3941
private initialSpan = 0;

0 commit comments

Comments
 (0)