@getcortexlabs/mavis-core 0.1.0-alpha.7 → 0.1.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/capabilities.d.ts +16 -3
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/capabilities.js +16 -3
- package/dist/capabilities.js.map +1 -1
- package/dist/contracts.d.ts +42 -2
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +17 -0
- package/dist/contracts.js.map +1 -1
- package/dist/dialog.d.ts +1 -1
- package/dist/dialog.d.ts.map +1 -1
- package/dist/dialog.js +1 -0
- package/dist/dialog.js.map +1 -1
- package/dist/experimental-collections.d.ts +82 -0
- package/dist/experimental-collections.d.ts.map +1 -0
- package/dist/experimental-collections.js +8 -0
- package/dist/experimental-collections.js.map +1 -0
- package/dist/experimental-effects.d.ts +107 -0
- package/dist/experimental-effects.d.ts.map +1 -0
- package/dist/experimental-effects.js +24 -0
- package/dist/experimental-effects.js.map +1 -0
- package/dist/experimental-platforms.d.ts +94 -0
- package/dist/experimental-platforms.d.ts.map +1 -0
- package/dist/experimental-platforms.js +2 -0
- package/dist/experimental-platforms.js.map +1 -0
- package/dist/experimental-playback.d.ts +2 -2
- package/dist/experimental-playback.d.ts.map +1 -1
- package/dist/experimental-regions.d.ts +17 -2
- package/dist/experimental-regions.d.ts.map +1 -1
- package/dist/experimental-regions.js +91 -0
- package/dist/experimental-regions.js.map +1 -1
- package/dist/experimental-sensors.d.ts +42 -0
- package/dist/experimental-sensors.d.ts.map +1 -0
- package/dist/experimental-sensors.js +2 -0
- package/dist/experimental-sensors.js.map +1 -0
- package/dist/experimental-surfaces.d.ts +127 -0
- package/dist/experimental-surfaces.d.ts.map +1 -0
- package/dist/experimental-surfaces.js +2 -0
- package/dist/experimental-surfaces.js.map +1 -0
- package/dist/experimental.d.ts +28 -4
- package/dist/experimental.d.ts.map +1 -1
- package/dist/experimental.js +266 -1
- package/dist/experimental.js.map +1 -1
- package/dist/vue/component-props.d.ts +62 -20
- package/dist/vue/component-props.d.ts.map +1 -1
- package/dist/vue/configurator-props.d.ts +5 -0
- package/dist/vue/configurator-props.d.ts.map +1 -1
- package/dist/vue/configurator-props.js +1 -0
- package/dist/vue/configurator-props.js.map +1 -1
- package/dist/vue/index.d.ts +1 -0
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +1 -0
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/loading-effect.d.ts +7 -0
- package/dist/vue/loading-effect.d.ts.map +1 -0
- package/dist/vue/loading-effect.js +32 -0
- package/dist/vue/loading-effect.js.map +1 -0
- package/dist/vue/props.d.ts +123 -43
- package/dist/vue/props.d.ts.map +1 -1
- package/dist/vue/props.js +7 -0
- package/dist/vue/props.js.map +1 -1
- package/package.json +1 -1
- package/src/capabilities.ts +16 -3
- package/src/contracts.ts +17 -0
- package/src/dialog.ts +3 -1
- package/src/experimental-collections.ts +87 -0
- package/src/experimental-effects.ts +146 -0
- package/src/experimental-platforms.ts +96 -0
- package/src/experimental-playback.ts +1 -1
- package/src/experimental-regions.ts +136 -2
- package/src/experimental-sensors.ts +50 -0
- package/src/experimental-surfaces.ts +124 -0
- package/src/experimental.ts +309 -8
- package/src/vue/configurator-props.ts +2 -0
- package/src/vue/index.ts +1 -0
- package/src/vue/loading-effect.ts +44 -0
- package/src/vue/props.ts +8 -1
package/src/contracts.ts
CHANGED
|
@@ -83,6 +83,11 @@ export const boxContract = {
|
|
|
83
83
|
}
|
|
84
84
|
export const motionBoxContract = {
|
|
85
85
|
...boxContract,
|
|
86
|
+
motionSurface: property<MotionSurface>()({
|
|
87
|
+
kind: 'object',
|
|
88
|
+
default: undefined,
|
|
89
|
+
runtimeOnly: true,
|
|
90
|
+
}),
|
|
86
91
|
motionRegion: property<MotionRegion>()({ kind: 'object', default: undefined, runtimeOnly: true }),
|
|
87
92
|
}
|
|
88
93
|
export type Align = 'start' | 'center' | 'end' | 'stretch'
|
|
@@ -123,6 +128,8 @@ export const navigationContract = {
|
|
|
123
128
|
|
|
124
129
|
export const buttonContract = {
|
|
125
130
|
...navigationContract,
|
|
131
|
+
/** Experimental retained-reorder handle; native keyboard input belongs to Jolt. */
|
|
132
|
+
reorderHandle: flag,
|
|
126
133
|
motionSurface: property<MotionSurface>()({
|
|
127
134
|
kind: 'object',
|
|
128
135
|
default: undefined,
|
|
@@ -151,6 +158,11 @@ export const buttonContract = {
|
|
|
151
158
|
}),
|
|
152
159
|
disabled: flag,
|
|
153
160
|
loading: flag,
|
|
161
|
+
loadingIndicator: property<'none' | 'dots' | 'bars' | 'ring'>()({
|
|
162
|
+
kind: 'string',
|
|
163
|
+
values: ['none', 'dots', 'bars', 'ring'],
|
|
164
|
+
default: 'none',
|
|
165
|
+
}),
|
|
154
166
|
loadingText: text({ kind: 'string', default: 'Loading…' }),
|
|
155
167
|
icon,
|
|
156
168
|
trailingIcon: icon,
|
|
@@ -174,6 +186,11 @@ export const paletteTones: readonly (keyof Palette)[] = [
|
|
|
174
186
|
'danger',
|
|
175
187
|
]
|
|
176
188
|
export const textContract = {
|
|
189
|
+
motionSurface: property<MotionSurface>()({
|
|
190
|
+
kind: 'object',
|
|
191
|
+
default: undefined,
|
|
192
|
+
runtimeOnly: true,
|
|
193
|
+
}),
|
|
177
194
|
weight: weightProperty,
|
|
178
195
|
...viewContract,
|
|
179
196
|
...flexContract,
|
package/src/dialog.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export type DialogCloseReason =
|
|
1
|
+
export type DialogCloseReason =
|
|
2
|
+
'cancel' | 'backdrop' | 'escape' | 'back' | 'program' | 'navigation' | 'swipe'
|
|
2
3
|
export const dialogCloseReasons: readonly DialogCloseReason[] = [
|
|
3
4
|
'cancel',
|
|
4
5
|
'backdrop',
|
|
@@ -6,6 +7,7 @@ export const dialogCloseReasons: readonly DialogCloseReason[] = [
|
|
|
6
7
|
'back',
|
|
7
8
|
'program',
|
|
8
9
|
'navigation',
|
|
10
|
+
'swipe',
|
|
9
11
|
]
|
|
10
12
|
export function checkDialogLabels(title: string, confirm: string, cancel: string, loading: string) {
|
|
11
13
|
for (const [name, value] of Object.entries({
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { MotionBinding, MotionSurface, MotionScrollSource } from './experimental.js'
|
|
2
|
+
|
|
3
|
+
export interface MotionCollectionItem<T = MotionSurface> {
|
|
4
|
+
key: string
|
|
5
|
+
target: T
|
|
6
|
+
handle?: T
|
|
7
|
+
}
|
|
8
|
+
export interface MotionRefreshContext {
|
|
9
|
+
readonly cancelled: boolean
|
|
10
|
+
commit(change: () => void | Promise<void>): Promise<boolean>
|
|
11
|
+
}
|
|
12
|
+
export interface MotionHeaderOptions<T = MotionSurface> {
|
|
13
|
+
header: T
|
|
14
|
+
artwork: T
|
|
15
|
+
title: T
|
|
16
|
+
toolbar: T
|
|
17
|
+
toolbarTitle: T
|
|
18
|
+
section: T
|
|
19
|
+
items(): readonly MotionCollectionItem<T>[]
|
|
20
|
+
expanded?: number
|
|
21
|
+
minimum?: number
|
|
22
|
+
parallax?: number
|
|
23
|
+
titleFade?: readonly [number, number]
|
|
24
|
+
toolbarFade?: readonly [number, number]
|
|
25
|
+
onRefresh?: (context: MotionRefreshContext) => void | Promise<void>
|
|
26
|
+
onRefreshError?: (error: unknown) => void
|
|
27
|
+
refreshThreshold?: number
|
|
28
|
+
}
|
|
29
|
+
export interface MotionHeader extends MotionBinding {
|
|
30
|
+
readonly ready: boolean
|
|
31
|
+
readonly state: { readonly offset: number; readonly refreshing: boolean }
|
|
32
|
+
refresh(): Promise<boolean>
|
|
33
|
+
cancelRefresh(): void
|
|
34
|
+
remeasure(): Promise<void>
|
|
35
|
+
preserveAnchor(change: () => void | Promise<void>): Promise<void>
|
|
36
|
+
scrollToItem(key: string, animated?: boolean): boolean
|
|
37
|
+
scrollToTop(animated?: boolean): void
|
|
38
|
+
pause(): void
|
|
39
|
+
play(): void
|
|
40
|
+
}
|
|
41
|
+
export interface MotionReorderMove {
|
|
42
|
+
key: string
|
|
43
|
+
beforeKey: string | null
|
|
44
|
+
fromIndex: number
|
|
45
|
+
toIndex: number
|
|
46
|
+
}
|
|
47
|
+
export interface MotionReorderOptions<T = MotionSurface, S = MotionScrollSource> {
|
|
48
|
+
container: T
|
|
49
|
+
items(): readonly MotionCollectionItem<T>[]
|
|
50
|
+
scroll: S
|
|
51
|
+
onCommit(move: MotionReorderMove): void
|
|
52
|
+
onStart?: (key: string) => void
|
|
53
|
+
onCancel?: (event: { key: string; reason: string }) => void
|
|
54
|
+
longPress?: number
|
|
55
|
+
edge?: { size?: number; speed?: number }
|
|
56
|
+
accessibility?: {
|
|
57
|
+
moveUp?: string
|
|
58
|
+
moveDown?: string
|
|
59
|
+
label?: (key: string) => string
|
|
60
|
+
announcement?: (
|
|
61
|
+
key: string,
|
|
62
|
+
position: number,
|
|
63
|
+
total: number,
|
|
64
|
+
phase: 'picked-up' | 'moved' | 'dropped' | 'cancelled',
|
|
65
|
+
) => string
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export interface MotionReorder extends MotionBinding {
|
|
69
|
+
readonly activeKey: string | undefined
|
|
70
|
+
move(key: string, beforeKey: string | null): boolean
|
|
71
|
+
moveUp(key: string): boolean
|
|
72
|
+
moveDown(key: string): boolean
|
|
73
|
+
refresh(): void
|
|
74
|
+
cancel(): void
|
|
75
|
+
pause(): void
|
|
76
|
+
play(): void
|
|
77
|
+
}
|
|
78
|
+
export function mapMotionItems<T, R>(
|
|
79
|
+
items: readonly MotionCollectionItem<T>[],
|
|
80
|
+
resolve: (target: T) => R,
|
|
81
|
+
): MotionCollectionItem<R>[] {
|
|
82
|
+
return items.map((item) => ({
|
|
83
|
+
key: item.key,
|
|
84
|
+
target: resolve(item.target),
|
|
85
|
+
...(item.handle ? { handle: resolve(item.handle) } : {}),
|
|
86
|
+
}))
|
|
87
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
MotionBinding,
|
|
3
|
+
MotionColor,
|
|
4
|
+
MotionOptions,
|
|
5
|
+
MotionPlayback,
|
|
6
|
+
MotionReadable,
|
|
7
|
+
} from './experimental.js'
|
|
8
|
+
import type { MotionSurfaceEffects, MotionSurfaceEffectsAdapter } from './experimental-surfaces.js'
|
|
9
|
+
|
|
10
|
+
/** Availability of the actual renderer backend; no simulated native fallback. */
|
|
11
|
+
export type MotionEffectKind =
|
|
12
|
+
| 'gradient'
|
|
13
|
+
| 'shimmer'
|
|
14
|
+
| 'loader'
|
|
15
|
+
| 'circular'
|
|
16
|
+
| 'text'
|
|
17
|
+
| 'particles'
|
|
18
|
+
| 'confetti'
|
|
19
|
+
| 'blur'
|
|
20
|
+
| 'shape'
|
|
21
|
+
| 'liquid'
|
|
22
|
+
| 'image'
|
|
23
|
+
| 'symbol'
|
|
24
|
+
| 'keyboard'
|
|
25
|
+
export interface MotionGradientValues {
|
|
26
|
+
colors?: readonly string[]
|
|
27
|
+
stops?: readonly number[]
|
|
28
|
+
angle?: number
|
|
29
|
+
center?: { x: number; y: number }
|
|
30
|
+
radius?: number
|
|
31
|
+
}
|
|
32
|
+
export interface MotionGradientOptions extends MotionGradientValues {
|
|
33
|
+
type: 'linear' | 'radial' | 'conic'
|
|
34
|
+
colors: readonly string[]
|
|
35
|
+
}
|
|
36
|
+
export interface MotionGradientBindings<N = MotionReadable, C = MotionColor> {
|
|
37
|
+
colors?: readonly (string | C)[]
|
|
38
|
+
stops?: readonly (number | N)[]
|
|
39
|
+
angle?: number | N
|
|
40
|
+
center?: { x?: number | N; y?: number | N }
|
|
41
|
+
radius?: number | N
|
|
42
|
+
}
|
|
43
|
+
export interface MotionGradient extends MotionBinding {
|
|
44
|
+
readonly type: MotionGradientOptions['type']
|
|
45
|
+
readonly suspended: boolean
|
|
46
|
+
animate(values: MotionGradientValues, options?: MotionOptions): MotionPlayback
|
|
47
|
+
set(values: MotionGradientValues): void
|
|
48
|
+
bind(values: MotionGradientBindings): MotionBinding
|
|
49
|
+
stop(): void
|
|
50
|
+
suspend(): void
|
|
51
|
+
resume(): void
|
|
52
|
+
}
|
|
53
|
+
export interface MotionLoadingEffect extends MotionBinding {
|
|
54
|
+
readonly supported: boolean
|
|
55
|
+
}
|
|
56
|
+
export interface MotionShimmerOptions {
|
|
57
|
+
duration?: number
|
|
58
|
+
}
|
|
59
|
+
export interface MotionLoaderOptions {
|
|
60
|
+
style?: 'dots' | 'bars' | 'ring'
|
|
61
|
+
color?: string
|
|
62
|
+
size?: number
|
|
63
|
+
duration?: number
|
|
64
|
+
}
|
|
65
|
+
export interface MotionCircularOptions {
|
|
66
|
+
/** Local CSS pixels on Web, DIPs on native. Omit to preserve a reversing circle. */
|
|
67
|
+
origin?: { x: number; y: number }
|
|
68
|
+
duration?: number
|
|
69
|
+
}
|
|
70
|
+
export interface MotionCircular extends MotionBinding {
|
|
71
|
+
readonly supported: boolean
|
|
72
|
+
/** Move focus outside interactive content before conceal; the resource owns inert state. */
|
|
73
|
+
conceal(options?: MotionCircularOptions): MotionPlayback
|
|
74
|
+
reveal(options?: MotionCircularOptions): MotionPlayback
|
|
75
|
+
}
|
|
76
|
+
export interface MotionTextOptions {
|
|
77
|
+
by?: 'letter' | 'word'
|
|
78
|
+
duration?: number
|
|
79
|
+
stagger?: number
|
|
80
|
+
delay?: number
|
|
81
|
+
y?: number
|
|
82
|
+
}
|
|
83
|
+
export interface MotionRollOptions {
|
|
84
|
+
format?: (value: number) => string
|
|
85
|
+
duration?: number
|
|
86
|
+
bounce?: number
|
|
87
|
+
stagger?: number
|
|
88
|
+
delay?: number
|
|
89
|
+
direction?: 'auto' | 'up' | 'down'
|
|
90
|
+
tabular?: boolean
|
|
91
|
+
}
|
|
92
|
+
export interface MotionVisualSurface extends MotionSurfaceEffects {
|
|
93
|
+
supports(effect: MotionEffectKind): boolean
|
|
94
|
+
gradient(options: MotionGradientOptions): MotionGradient
|
|
95
|
+
shimmer(options?: MotionShimmerOptions): MotionLoadingEffect
|
|
96
|
+
loader(options?: MotionLoaderOptions): MotionLoadingEffect
|
|
97
|
+
circular(): MotionCircular
|
|
98
|
+
/** Only explicit MText text targets; rich/slotted content is rejected. */
|
|
99
|
+
animateText(options?: MotionTextOptions): MotionPlayback
|
|
100
|
+
rollTo(value: number | string, options?: MotionRollOptions): MotionPlayback
|
|
101
|
+
}
|
|
102
|
+
type NumericSource = Pick<MotionReadable, 'get' | 'dispose'>
|
|
103
|
+
type ColorSource = Pick<MotionColor, 'get' | 'dispose'>
|
|
104
|
+
export interface MotionGradientAdapter extends Omit<MotionGradient, 'disposed' | 'bind'> {
|
|
105
|
+
bind(values: MotionGradientBindings<NumericSource, ColorSource>): { dispose(): void }
|
|
106
|
+
}
|
|
107
|
+
export interface MotionVisualAdapter
|
|
108
|
+
extends
|
|
109
|
+
MotionSurfaceEffectsAdapter,
|
|
110
|
+
Omit<
|
|
111
|
+
MotionVisualSurface,
|
|
112
|
+
'gradient' | 'shimmer' | 'loader' | 'circular' | keyof MotionSurfaceEffects
|
|
113
|
+
> {
|
|
114
|
+
gradient(options: MotionGradientOptions): MotionGradientAdapter
|
|
115
|
+
shimmer(options?: MotionShimmerOptions): Omit<MotionLoadingEffect, 'disposed'>
|
|
116
|
+
loader(options?: MotionLoaderOptions): Omit<MotionLoadingEffect, 'disposed'>
|
|
117
|
+
circular(): Omit<MotionCircular, 'disposed'>
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Structural translation only: validation, interpolation and scheduling stay in Jolt. */
|
|
121
|
+
export function mapGradientBindings<N, C, RN, RC>(
|
|
122
|
+
values: MotionGradientBindings<N, C>,
|
|
123
|
+
numeric: (value: N) => RN,
|
|
124
|
+
color: (value: C) => RC,
|
|
125
|
+
): MotionGradientBindings<RN, RC> {
|
|
126
|
+
const number = (value: number | N) => (typeof value === 'number' ? value : numeric(value))
|
|
127
|
+
return {
|
|
128
|
+
...values,
|
|
129
|
+
...(values.colors === undefined
|
|
130
|
+
? {}
|
|
131
|
+
: {
|
|
132
|
+
colors: values.colors.map((value) => (typeof value === 'string' ? value : color(value))),
|
|
133
|
+
}),
|
|
134
|
+
...(values.stops === undefined ? {} : { stops: values.stops.map(number) }),
|
|
135
|
+
...(values.angle === undefined ? {} : { angle: number(values.angle) }),
|
|
136
|
+
...(values.radius === undefined ? {} : { radius: number(values.radius) }),
|
|
137
|
+
...(values.center === undefined
|
|
138
|
+
? {}
|
|
139
|
+
: {
|
|
140
|
+
center: {
|
|
141
|
+
...(values.center.x === undefined ? {} : { x: number(values.center.x) }),
|
|
142
|
+
...(values.center.y === undefined ? {} : { y: number(values.center.y) }),
|
|
143
|
+
},
|
|
144
|
+
}),
|
|
145
|
+
} as MotionGradientBindings<RN, RC>
|
|
146
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { MotionBinding, MotionSurface } from './experimental.js'
|
|
2
|
+
|
|
3
|
+
export interface MotionKeyboardState {
|
|
4
|
+
readonly visible: boolean
|
|
5
|
+
readonly height: number
|
|
6
|
+
readonly duration: number
|
|
7
|
+
readonly backend: 'native' | 'virtual-keyboard' | 'visual-viewport' | 'none'
|
|
8
|
+
readonly accuracy: 'native' | 'exact' | 'estimated' | 'unavailable'
|
|
9
|
+
}
|
|
10
|
+
export interface MotionKeyboard extends MotionBinding {
|
|
11
|
+
snapshot(): MotionKeyboardState
|
|
12
|
+
}
|
|
13
|
+
export interface MotionVector {
|
|
14
|
+
x: number
|
|
15
|
+
y: number
|
|
16
|
+
}
|
|
17
|
+
export interface MotionPhysicsLine {
|
|
18
|
+
color: string
|
|
19
|
+
width?: number
|
|
20
|
+
}
|
|
21
|
+
export interface MotionAttachment {
|
|
22
|
+
anchor: MotionVector
|
|
23
|
+
length?: number
|
|
24
|
+
stiffness?: number
|
|
25
|
+
damping?: number
|
|
26
|
+
line?: MotionPhysicsLine
|
|
27
|
+
}
|
|
28
|
+
export interface MotionPhysicsSnap {
|
|
29
|
+
points: readonly MotionVector[]
|
|
30
|
+
stiffness?: number
|
|
31
|
+
damping?: number
|
|
32
|
+
projection?: number
|
|
33
|
+
}
|
|
34
|
+
export interface MotionPhysicsSpring {
|
|
35
|
+
id: string
|
|
36
|
+
from: string
|
|
37
|
+
to: string
|
|
38
|
+
length: number
|
|
39
|
+
stiffness?: number
|
|
40
|
+
damping?: number
|
|
41
|
+
line?: MotionPhysicsLine
|
|
42
|
+
}
|
|
43
|
+
export interface MotionCircleBody<T = MotionSurface> {
|
|
44
|
+
id: string
|
|
45
|
+
target: T
|
|
46
|
+
radius: number
|
|
47
|
+
x: number
|
|
48
|
+
y: number
|
|
49
|
+
mass?: number
|
|
50
|
+
velocity?: MotionVector
|
|
51
|
+
attachment?: MotionAttachment
|
|
52
|
+
snap?: MotionPhysicsSnap
|
|
53
|
+
drag?:
|
|
54
|
+
| 'direct'
|
|
55
|
+
| {
|
|
56
|
+
type: 'spring'
|
|
57
|
+
length?: number
|
|
58
|
+
stiffness?: number
|
|
59
|
+
damping?: number
|
|
60
|
+
line?: MotionPhysicsLine
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export interface MotionPhysicsOptions {
|
|
64
|
+
gravity?: MotionVector
|
|
65
|
+
restitution?: number
|
|
66
|
+
damping?: number
|
|
67
|
+
reducedMotion?: 'pause' | 'continue'
|
|
68
|
+
springs?: readonly MotionPhysicsSpring[]
|
|
69
|
+
}
|
|
70
|
+
export interface MotionPhysicsSnapshot {
|
|
71
|
+
status: 'running' | 'sleeping' | 'paused' | 'detached' | 'invalid-bounds' | 'disposed'
|
|
72
|
+
frames: number
|
|
73
|
+
steps: number
|
|
74
|
+
contacts: number
|
|
75
|
+
droppedMs: number
|
|
76
|
+
bodies: {
|
|
77
|
+
id: string
|
|
78
|
+
x: number
|
|
79
|
+
y: number
|
|
80
|
+
vx: number
|
|
81
|
+
vy: number
|
|
82
|
+
radius: number
|
|
83
|
+
held: boolean
|
|
84
|
+
}[]
|
|
85
|
+
}
|
|
86
|
+
export interface MotionPhysicsWorld extends MotionBinding {
|
|
87
|
+
readonly paused: boolean
|
|
88
|
+
pause(): void
|
|
89
|
+
resume(): void
|
|
90
|
+
reset(): void
|
|
91
|
+
impulse(id: string, impulse: MotionVector): void
|
|
92
|
+
attach(id: string, attachment: MotionAttachment | null): void
|
|
93
|
+
spring(id: string, spring: Omit<MotionPhysicsSpring, 'id'> | null): void
|
|
94
|
+
snapTo(id: string, index: number): void
|
|
95
|
+
snapshot(): MotionPhysicsSnapshot
|
|
96
|
+
}
|
|
@@ -22,7 +22,7 @@ export interface MotionTimeline extends MotionPlayback {
|
|
|
22
22
|
pause(): void
|
|
23
23
|
resume(): void
|
|
24
24
|
}
|
|
25
|
-
export
|
|
25
|
+
export type MotionValueOptions = MotionOptions & {
|
|
26
26
|
layer?: string
|
|
27
27
|
}
|
|
28
28
|
export interface MotionDecayOptions {
|
|
@@ -10,6 +10,20 @@ import {
|
|
|
10
10
|
type MotionStatesAdapter,
|
|
11
11
|
} from './experimental-playback.js'
|
|
12
12
|
import type { MotionPlayback } from './experimental.js'
|
|
13
|
+
import type {
|
|
14
|
+
MotionKeyboardState,
|
|
15
|
+
MotionKeyboard,
|
|
16
|
+
MotionCircleBody,
|
|
17
|
+
MotionPhysicsOptions,
|
|
18
|
+
MotionPhysicsWorld,
|
|
19
|
+
} from './experimental-platforms.js'
|
|
20
|
+
import {
|
|
21
|
+
mapMotionItems,
|
|
22
|
+
type MotionHeaderOptions,
|
|
23
|
+
type MotionHeader,
|
|
24
|
+
type MotionReorderOptions,
|
|
25
|
+
type MotionReorder,
|
|
26
|
+
} from './experimental-collections.js'
|
|
13
27
|
import {
|
|
14
28
|
motionSurfaceAdapter,
|
|
15
29
|
motionScrollAdapter,
|
|
@@ -82,7 +96,7 @@ export interface MotionSharedPlayback {
|
|
|
82
96
|
stop(): void
|
|
83
97
|
}
|
|
84
98
|
export interface MotionSharedOptions {
|
|
85
|
-
transition?: MotionOptions
|
|
99
|
+
transition?: Exclude<MotionOptions, { type: 'gravity' }>
|
|
86
100
|
layoutTimeout?: number
|
|
87
101
|
}
|
|
88
102
|
export interface MotionSharedLayout extends MotionBinding {
|
|
@@ -90,7 +104,10 @@ export interface MotionSharedLayout extends MotionBinding {
|
|
|
90
104
|
/** Explicit identity; follows replacement of this declared surface. */
|
|
91
105
|
attach(surface: MotionSurface, identity: string): () => void
|
|
92
106
|
/** Host mutation is synchronous; Jolt waits for renderer layout. */
|
|
93
|
-
transition(
|
|
107
|
+
transition(
|
|
108
|
+
change: () => void,
|
|
109
|
+
options?: Exclude<MotionOptions, { type: 'gravity' }>,
|
|
110
|
+
): MotionSharedPlayback
|
|
94
111
|
cancel(): void
|
|
95
112
|
}
|
|
96
113
|
export interface MotionDiagnosticsOptions {
|
|
@@ -134,6 +151,14 @@ type Available = {
|
|
|
134
151
|
onAvailable(setup: () => void | (() => void)): () => void
|
|
135
152
|
}
|
|
136
153
|
export interface MotionRegion extends Available {
|
|
154
|
+
onKeyboard(callback: (state: MotionKeyboardState) => void): MotionKeyboard
|
|
155
|
+
/** Waits for initial native layout; the engine owns simulation and later geometry. */
|
|
156
|
+
physicsWorld(
|
|
157
|
+
bodies: readonly MotionCircleBody[],
|
|
158
|
+
options?: MotionPhysicsOptions,
|
|
159
|
+
): Promise<MotionPhysicsWorld>
|
|
160
|
+
scrollHeader(source: MotionScrollSource, options: MotionHeaderOptions): MotionHeader
|
|
161
|
+
reorder(options: MotionReorderOptions): MotionReorder
|
|
137
162
|
sequence(steps: readonly MotionStep[]): MotionPlayback
|
|
138
163
|
timeline(steps: readonly MotionTimelineStep[]): MotionTimeline
|
|
139
164
|
states<const S extends MotionStateDefinitions>(
|
|
@@ -146,6 +171,18 @@ export interface MotionRegion extends Available {
|
|
|
146
171
|
diagnostics(options: MotionDiagnosticsOptions): MotionDiagnostics
|
|
147
172
|
}
|
|
148
173
|
export interface MotionRegionAdapter {
|
|
174
|
+
onKeyboard?(callback: (state: MotionKeyboardState) => void): Omit<MotionKeyboard, 'disposed'>
|
|
175
|
+
physicsWorld?(
|
|
176
|
+
bodies: readonly MotionCircleBody<MotionSurfaceAdapter>[],
|
|
177
|
+
options?: MotionPhysicsOptions,
|
|
178
|
+
): Promise<Omit<MotionPhysicsWorld, 'disposed'>>
|
|
179
|
+
scrollHeader?(
|
|
180
|
+
source: MotionScrollAdapter,
|
|
181
|
+
options: MotionHeaderOptions<MotionSurfaceAdapter>,
|
|
182
|
+
): Omit<MotionHeader, 'disposed'>
|
|
183
|
+
reorder?(
|
|
184
|
+
options: MotionReorderOptions<MotionSurfaceAdapter, MotionScrollAdapter>,
|
|
185
|
+
): Omit<MotionReorder, 'disposed'>
|
|
149
186
|
readonly kind: 'web' | 'native'
|
|
150
187
|
sequence?(steps: readonly MotionStep<MotionSurfaceAdapter>[]): MotionPlayback
|
|
151
188
|
timeline?(steps: readonly MotionTimelineStep<MotionSurfaceAdapter>[]): MotionPlayback
|
|
@@ -362,6 +399,46 @@ export function createMotionRegion(): MotionRegion {
|
|
|
362
399
|
get available() {
|
|
363
400
|
return Boolean(entry.state?.valid)
|
|
364
401
|
},
|
|
402
|
+
onKeyboard(callback) {
|
|
403
|
+
const state = regionState(region)
|
|
404
|
+
if (!state.adapter.onKeyboard) throw new Error('Keyboard observation is unavailable.')
|
|
405
|
+
return owned(state, state.adapter.onKeyboard(callback))
|
|
406
|
+
},
|
|
407
|
+
async physicsWorld(bodies, options) {
|
|
408
|
+
const state = regionState(region)
|
|
409
|
+
if (!state.adapter.physicsWorld) throw new Error('Circle physics is unavailable.')
|
|
410
|
+
const mapped = bodies.map(({ target, ...body }) => ({
|
|
411
|
+
...body,
|
|
412
|
+
target: motionSurfaceAdapter(target),
|
|
413
|
+
}))
|
|
414
|
+
const raw = await state.adapter.physicsWorld(mapped, options)
|
|
415
|
+
if (
|
|
416
|
+
!state.valid ||
|
|
417
|
+
bodies.some(
|
|
418
|
+
(body, index) =>
|
|
419
|
+
!body.target.available || motionSurfaceAdapter(body.target) !== mapped[index]!.target,
|
|
420
|
+
)
|
|
421
|
+
) {
|
|
422
|
+
raw.dispose()
|
|
423
|
+
throw new Error('Physics presentation changed while waiting for layout.')
|
|
424
|
+
}
|
|
425
|
+
let stop: (() => void) | undefined
|
|
426
|
+
const control = owned(state, {
|
|
427
|
+
...raw,
|
|
428
|
+
get paused() {
|
|
429
|
+
return raw.paused
|
|
430
|
+
},
|
|
431
|
+
dispose() {
|
|
432
|
+
stop?.()
|
|
433
|
+
raw.dispose()
|
|
434
|
+
},
|
|
435
|
+
})
|
|
436
|
+
stop = whenMotionAvailable(
|
|
437
|
+
bodies.map((body) => body.target),
|
|
438
|
+
() => () => control.dispose(),
|
|
439
|
+
)
|
|
440
|
+
return control
|
|
441
|
+
},
|
|
365
442
|
onAvailable(setup) {
|
|
366
443
|
let cleanup: (() => void) | undefined
|
|
367
444
|
const invoke = () => {
|
|
@@ -409,6 +486,63 @@ export function createMotionRegion(): MotionRegion {
|
|
|
409
486
|
}
|
|
410
487
|
},
|
|
411
488
|
sequence: (steps) => group(region, steps, false),
|
|
489
|
+
scrollHeader(source, options) {
|
|
490
|
+
const state = regionState(region)
|
|
491
|
+
if (!state.adapter.scrollHeader) throw new Error('Scroll headers are unavailable.')
|
|
492
|
+
const { header, artwork, title, toolbar, toolbarTitle, section, items, ...rest } = options
|
|
493
|
+
const raw = state.adapter.scrollHeader(motionScrollAdapter(source), {
|
|
494
|
+
...rest,
|
|
495
|
+
header: motionSurfaceAdapter(header),
|
|
496
|
+
artwork: motionSurfaceAdapter(artwork),
|
|
497
|
+
title: motionSurfaceAdapter(title),
|
|
498
|
+
toolbar: motionSurfaceAdapter(toolbar),
|
|
499
|
+
toolbarTitle: motionSurfaceAdapter(toolbarTitle),
|
|
500
|
+
section: motionSurfaceAdapter(section),
|
|
501
|
+
items: () => mapMotionItems(items(), motionSurfaceAdapter),
|
|
502
|
+
})
|
|
503
|
+
let off: (() => void) | undefined
|
|
504
|
+
const control = owned(state, {
|
|
505
|
+
...raw,
|
|
506
|
+
get ready() {
|
|
507
|
+
return raw.ready
|
|
508
|
+
},
|
|
509
|
+
get state() {
|
|
510
|
+
return raw.state
|
|
511
|
+
},
|
|
512
|
+
dispose() {
|
|
513
|
+
off?.()
|
|
514
|
+
raw.dispose()
|
|
515
|
+
},
|
|
516
|
+
})
|
|
517
|
+
off = whenMotionAvailable(
|
|
518
|
+
[source, header, artwork, title, toolbar, toolbarTitle, section],
|
|
519
|
+
() => () => control.dispose(),
|
|
520
|
+
)
|
|
521
|
+
return control
|
|
522
|
+
},
|
|
523
|
+
reorder(options) {
|
|
524
|
+
const state = regionState(region)
|
|
525
|
+
if (!state.adapter.reorder) throw new Error('Interactive reorder is unavailable.')
|
|
526
|
+
const raw = state.adapter.reorder({
|
|
527
|
+
...options,
|
|
528
|
+
scroll: motionScrollAdapter(options.scroll),
|
|
529
|
+
container: motionSurfaceAdapter(options.container),
|
|
530
|
+
items: () => mapMotionItems(options.items(), motionSurfaceAdapter),
|
|
531
|
+
})
|
|
532
|
+
let off: (() => void) | undefined
|
|
533
|
+
const control = owned(state, {
|
|
534
|
+
...raw,
|
|
535
|
+
get activeKey() {
|
|
536
|
+
return raw.activeKey
|
|
537
|
+
},
|
|
538
|
+
dispose() {
|
|
539
|
+
off?.()
|
|
540
|
+
raw.dispose()
|
|
541
|
+
},
|
|
542
|
+
})
|
|
543
|
+
off = whenMotionAvailable([options.scroll, options.container], () => () => control.dispose())
|
|
544
|
+
return control
|
|
545
|
+
},
|
|
412
546
|
timeline: (steps) => group(region, steps, true) as MotionTimeline,
|
|
413
547
|
states(targets, definitions, options) {
|
|
414
548
|
const state = regionState(region)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { MotionBinding, MotionReadable, MotionValueAdapter } from './experimental.js'
|
|
2
|
+
|
|
3
|
+
export type MotionSensorKind = 'rotation' | 'gravity'
|
|
4
|
+
export type MotionSensorStatus =
|
|
5
|
+
| 'idle'
|
|
6
|
+
| 'permission-required'
|
|
7
|
+
| 'starting'
|
|
8
|
+
| 'active'
|
|
9
|
+
| 'paused'
|
|
10
|
+
| 'unavailable'
|
|
11
|
+
| 'denied'
|
|
12
|
+
| 'error'
|
|
13
|
+
| 'replaying'
|
|
14
|
+
| 'disposed'
|
|
15
|
+
export interface MotionSensorOptions {
|
|
16
|
+
interval?: number | 'auto'
|
|
17
|
+
coordinates?: 'device' | 'interface'
|
|
18
|
+
reducedMotion?: 'pause' | 'continue'
|
|
19
|
+
onStatus?: (status: MotionSensorStatus) => void
|
|
20
|
+
}
|
|
21
|
+
export interface MotionSensorSnapshot {
|
|
22
|
+
status: MotionSensorStatus
|
|
23
|
+
available: boolean
|
|
24
|
+
timestamp: number | null
|
|
25
|
+
samples: number
|
|
26
|
+
values: number[]
|
|
27
|
+
backend: 'native' | 'device-orientation' | 'device-motion' | 'none'
|
|
28
|
+
reason?: string
|
|
29
|
+
}
|
|
30
|
+
export interface MotionSensor<T = MotionReadable> extends MotionBinding {
|
|
31
|
+
readonly kind: MotionSensorKind
|
|
32
|
+
readonly status: MotionSensorStatus
|
|
33
|
+
readonly available: boolean
|
|
34
|
+
readonly paused: boolean
|
|
35
|
+
readonly x: T
|
|
36
|
+
readonly y: T
|
|
37
|
+
readonly z: T
|
|
38
|
+
/** Only rotation provides a Hamilton quaternion (xyzw) and recenter. */
|
|
39
|
+
readonly quaternion?: Readonly<{ x: T; y: T; z: T; w: T }>
|
|
40
|
+
recenter(): void
|
|
41
|
+
/** Web may prompt. Native returns not-required, which is not availability. */
|
|
42
|
+
requestPermission(): Promise<'granted' | 'denied' | 'unavailable' | 'not-required'>
|
|
43
|
+
snapshot(): MotionSensorSnapshot
|
|
44
|
+
pause(): void
|
|
45
|
+
resume(): void
|
|
46
|
+
}
|
|
47
|
+
export type MotionSensorAdapter = Omit<
|
|
48
|
+
MotionSensor<Pick<MotionValueAdapter, 'get' | 'dispose'>>,
|
|
49
|
+
'disposed'
|
|
50
|
+
>
|