@getcortexlabs/mavis-core 0.1.0-rc.12.2 → 0.1.0-rc.14
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/README.md +2 -2
- package/dist/capabilities.d.ts +1814 -5
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/capabilities.js +87 -4
- package/dist/capabilities.js.map +1 -1
- package/dist/collections.d.ts +2 -0
- package/dist/collections.d.ts.map +1 -1
- package/dist/collections.js +9 -0
- package/dist/collections.js.map +1 -1
- package/dist/contracts.d.ts +12 -4
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +1 -0
- package/dist/contracts.js.map +1 -1
- package/dist/date.d.ts.map +1 -1
- package/dist/date.js +1 -1
- package/dist/date.js.map +1 -1
- package/dist/experimental-depth.d.ts +45 -0
- package/dist/experimental-depth.d.ts.map +1 -0
- package/dist/experimental-depth.js +179 -0
- package/dist/experimental-depth.js.map +1 -0
- package/dist/experimental-effects.d.ts +1 -1
- package/dist/experimental-effects.d.ts.map +1 -1
- package/dist/experimental-effects.js.map +1 -1
- package/dist/experimental-playback.d.ts +3 -3
- package/dist/experimental-playback.d.ts.map +1 -1
- package/dist/experimental-playback.js.map +1 -1
- package/dist/experimental-regions.d.ts +25 -3
- package/dist/experimental-regions.d.ts.map +1 -1
- package/dist/experimental-regions.js +37 -7
- package/dist/experimental-regions.js.map +1 -1
- package/dist/experimental-sensors.d.ts +2 -1
- package/dist/experimental-sensors.d.ts.map +1 -1
- package/dist/experimental.d.ts +45 -9
- package/dist/experimental.d.ts.map +1 -1
- package/dist/experimental.js +94 -9
- package/dist/experimental.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/macos-capabilities.generated.d.ts +1738 -0
- package/dist/macos-capabilities.generated.d.ts.map +1 -0
- package/dist/macos-capabilities.generated.js +4191 -0
- package/dist/macos-capabilities.generated.js.map +1 -0
- package/dist/motion.d.ts +1 -1
- package/dist/section-scroll.d.ts +2 -0
- package/dist/section-scroll.d.ts.map +1 -1
- package/dist/section-scroll.js +2 -0
- package/dist/section-scroll.js.map +1 -1
- package/dist/vue/advanced-collections.d.ts +16 -16
- package/dist/vue/advanced-collections.d.ts.map +1 -1
- package/dist/vue/advanced-collections.js +24 -3
- package/dist/vue/advanced-collections.js.map +1 -1
- package/dist/vue/animated-text.d.ts +4 -4
- package/dist/vue/chart.d.ts +5 -5
- package/dist/vue/chart.d.ts.map +1 -1
- package/dist/vue/chart.js +28 -7
- package/dist/vue/chart.js.map +1 -1
- package/dist/vue/combobox.d.ts.map +1 -1
- package/dist/vue/combobox.js +13 -11
- package/dist/vue/combobox.js.map +1 -1
- package/dist/vue/command-palette.d.ts +5 -5
- package/dist/vue/component-motion.d.ts.map +1 -1
- package/dist/vue/component-motion.js +4 -2
- package/dist/vue/component-motion.js.map +1 -1
- package/dist/vue/component-props.d.ts +30 -21
- package/dist/vue/component-props.d.ts.map +1 -1
- package/dist/vue/composer.d.ts +10 -10
- package/dist/vue/configurator.d.ts +15 -15
- package/dist/vue/creative-controls.d.ts +10 -10
- package/dist/vue/dashboard-charts.d.ts +6 -6
- package/dist/vue/dashboard-effects.d.ts +6 -6
- package/dist/vue/date-picker.d.ts +48 -48
- package/dist/vue/discovery-controls.d.ts +7 -7
- package/dist/vue/image-cropper.d.ts +8 -8
- package/dist/vue/image-cropper.d.ts.map +1 -1
- package/dist/vue/kanban.d.ts +25 -7
- package/dist/vue/kanban.d.ts.map +1 -1
- package/dist/vue/kanban.js +73 -44
- package/dist/vue/kanban.js.map +1 -1
- package/dist/vue/list-motion.d.ts.map +1 -1
- package/dist/vue/list-motion.js +24 -7
- package/dist/vue/list-motion.js.map +1 -1
- package/dist/vue/marquee.d.ts +4 -4
- package/dist/vue/menu.d.ts +4 -4
- package/dist/vue/navigation-props.d.ts +5 -0
- package/dist/vue/navigation-props.d.ts.map +1 -1
- package/dist/vue/navigation-props.js +2 -0
- package/dist/vue/navigation-props.js.map +1 -1
- package/dist/vue/number-flow.d.ts +3 -3
- package/dist/vue/platform.d.ts +7 -1
- package/dist/vue/platform.d.ts.map +1 -1
- package/dist/vue/platform.js +5 -4
- package/dist/vue/platform.js.map +1 -1
- package/dist/vue/props.d.ts +52 -42
- package/dist/vue/props.d.ts.map +1 -1
- package/dist/vue/reveal-state.d.ts +1 -1
- package/dist/vue/scheduler.d.ts +10 -10
- package/dist/vue/scroll-frame.d.ts +6 -6
- package/dist/vue/speed-dial.d.ts +3 -3
- package/dist/vue/swipe-actions.d.ts +3 -3
- package/dist/vue/swipe-deck.d.ts +3 -3
- package/dist/vue/theme-provider.d.ts +1 -1
- package/dist/vue/time-picker.d.ts +20 -20
- package/dist/vue/tour.d.ts +3 -3
- package/dist/vue/tree-view.d.ts +3 -3
- package/dist/vue/wayfinding-controls.d.ts +1 -1
- package/dist/vue/workflows.d.ts +5 -5
- package/package.json +1 -1
- package/src/capabilities.ts +89 -5
- package/src/collections.ts +22 -0
- package/src/contracts.ts +1 -0
- package/src/date.ts +2 -1
- package/src/experimental-depth.ts +215 -0
- package/src/experimental-effects.ts +1 -0
- package/src/experimental-playback.ts +4 -3
- package/src/experimental-regions.ts +60 -10
- package/src/experimental-sensors.ts +2 -1
- package/src/experimental.ts +166 -19
- package/src/index.ts +6 -1
- package/src/macos-capabilities.generated.ts +4190 -0
- package/src/section-scroll.ts +4 -0
- package/src/vue/advanced-collections.ts +29 -7
- package/src/vue/chart.ts +34 -9
- package/src/vue/combobox.ts +15 -14
- package/src/vue/component-motion.ts +4 -2
- package/src/vue/kanban.ts +99 -59
- package/src/vue/list-motion.ts +23 -7
- package/src/vue/navigation-props.ts +2 -0
- package/src/vue/platform.ts +13 -5
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
type MotionSurfaceAdapter,
|
|
32
32
|
type MotionBinding,
|
|
33
33
|
type MotionReadable,
|
|
34
|
-
type
|
|
34
|
+
type MotionChannelFrames,
|
|
35
35
|
type MotionOptions,
|
|
36
36
|
type MotionSpringOptions,
|
|
37
37
|
type MotionScrollSource,
|
|
@@ -47,19 +47,29 @@ export interface MotionPointerOptions {
|
|
|
47
47
|
disabled?: boolean
|
|
48
48
|
}
|
|
49
49
|
export interface MotionPointer extends MotionBinding {
|
|
50
|
+
/** Web: viewport CSS pixels from the region's center. NativeScript: the region's local DIPs. */
|
|
50
51
|
readonly x: MotionReadable
|
|
51
52
|
readonly y: MotionReadable
|
|
53
|
+
/** 1 while a hovering pointer is inside the region; 0 outside, disabled, suspended or without hover. */
|
|
54
|
+
readonly presence: MotionReadable
|
|
52
55
|
readonly active: boolean
|
|
56
|
+
/**
|
|
57
|
+
* Whether the mounted region has a hover API on this platform. It does not detect a connected
|
|
58
|
+
* mouse: an iPad without a pointer is available and stays at rest; an iPhone is not available.
|
|
59
|
+
*/
|
|
60
|
+
readonly available: boolean
|
|
61
|
+
/** `hover` while input can arrive; `static` when the values only ever hold their resting state. */
|
|
53
62
|
readonly execution: 'hover' | 'static'
|
|
54
63
|
update(state: { disabled: boolean }): void
|
|
55
64
|
refresh(): void
|
|
56
65
|
}
|
|
57
|
-
export type MotionPointerAdapter = Omit<MotionPointer, 'disposed' | 'x' | 'y'> & {
|
|
66
|
+
export type MotionPointerAdapter = Omit<MotionPointer, 'disposed' | 'x' | 'y' | 'presence'> & {
|
|
58
67
|
x: Pick<MotionReadable, 'get' | 'dispose'>
|
|
59
68
|
y: Pick<MotionReadable, 'get' | 'dispose'>
|
|
69
|
+
presence: Pick<MotionReadable, 'get' | 'dispose'>
|
|
60
70
|
}
|
|
61
71
|
export interface MotionViewportOptions {
|
|
62
|
-
frames?:
|
|
72
|
+
frames?: MotionChannelFrames
|
|
63
73
|
transition?: MotionOptions
|
|
64
74
|
stagger?: number
|
|
65
75
|
root?: MotionScrollSource
|
|
@@ -103,6 +113,48 @@ export interface MotionLayoutOptions {
|
|
|
103
113
|
transition?: Exclude<MotionOptions, { type: 'gravity' }>
|
|
104
114
|
size?: 'scale' | false
|
|
105
115
|
enter?: boolean
|
|
116
|
+
/** Removed direct children leave as static copies. Disabled by default; never for recycled rows. */
|
|
117
|
+
exit?: false | 'fadeOut' | { opacity?: number; x?: number; y?: number; scale?: number }
|
|
118
|
+
/** Concurrent exit copies share this pixel budget (1–32,000,000; default 8,000,000). */
|
|
119
|
+
maxSnapshotPixels?: number
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Keep the shared recipe bounded before a host mutation, including the SSR fallback. */
|
|
123
|
+
export function validateMotionLayoutOptions(options: MotionLayoutOptions) {
|
|
124
|
+
if (!options || typeof options !== 'object' || Array.isArray(options))
|
|
125
|
+
throw new TypeError('Layout options must be an object.')
|
|
126
|
+
if (options.size !== undefined && options.size !== false && options.size !== 'scale')
|
|
127
|
+
throw new TypeError('Layout size must be scale or false.')
|
|
128
|
+
if (options.enter !== undefined && typeof options.enter !== 'boolean')
|
|
129
|
+
throw new TypeError('Layout enter must be a boolean.')
|
|
130
|
+
const exit = options.exit
|
|
131
|
+
if (exit !== undefined && exit !== false && exit !== 'fadeOut') {
|
|
132
|
+
if (
|
|
133
|
+
!exit ||
|
|
134
|
+
typeof exit !== 'object' ||
|
|
135
|
+
Array.isArray(exit) ||
|
|
136
|
+
Object.keys(exit).some((key) => !['opacity', 'x', 'y', 'scale'].includes(key))
|
|
137
|
+
)
|
|
138
|
+
throw new TypeError('Layout exit must be false, fadeOut, or opacity/x/y/scale.')
|
|
139
|
+
if (
|
|
140
|
+
Object.values(exit).some((value) => value !== undefined && !Number.isFinite(value)) ||
|
|
141
|
+
(exit.opacity !== undefined && (exit.opacity < 0 || exit.opacity > 1)) ||
|
|
142
|
+
(exit.scale !== undefined && exit.scale <= 0)
|
|
143
|
+
)
|
|
144
|
+
throw new RangeError('Layout exit needs finite values, opacity in [0,1] and positive scale.')
|
|
145
|
+
}
|
|
146
|
+
if (
|
|
147
|
+
options.maxSnapshotPixels !== undefined &&
|
|
148
|
+
(!Number.isSafeInteger(options.maxSnapshotPixels) ||
|
|
149
|
+
options.maxSnapshotPixels <= 0 ||
|
|
150
|
+
options.maxSnapshotPixels > 32_000_000)
|
|
151
|
+
)
|
|
152
|
+
throw new RangeError('Layout maxSnapshotPixels must be an integer in [1,32000000].')
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export function validateMotionLayoutChange(change: unknown): asserts change is () => void {
|
|
156
|
+
if (typeof change !== 'function' || change.constructor?.name === 'AsyncFunction')
|
|
157
|
+
throw new TypeError('Layout motion needs a synchronous change callback.')
|
|
106
158
|
}
|
|
107
159
|
export interface MotionSharedLayout extends MotionBinding {
|
|
108
160
|
readonly active: boolean
|
|
@@ -406,16 +458,14 @@ export function createMotionRegion(): MotionRegion {
|
|
|
406
458
|
const region: MotionRegion = {
|
|
407
459
|
animateLayout(change, options = {}) {
|
|
408
460
|
const state = regionState(region)
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
if (options.size !== undefined && options.size !== false && options.size !== 'scale')
|
|
412
|
-
throw new TypeError('Layout size must be scale or false.')
|
|
413
|
-
if (options.enter !== undefined && typeof options.enter !== 'boolean')
|
|
414
|
-
throw new TypeError('Layout enter must be a boolean.')
|
|
461
|
+
validateMotionLayoutChange(change)
|
|
462
|
+
validateMotionLayoutOptions(options)
|
|
415
463
|
if (!state.adapter.animateLayout) throw new Error('Layout motion is unavailable.')
|
|
416
464
|
const raw = state.adapter.animateLayout(change, options)
|
|
417
465
|
const resource = { dispose: () => raw.stop() }
|
|
418
|
-
|
|
466
|
+
// A synchronous mutation may also remove its host. Do not attach work to that old owner.
|
|
467
|
+
if (state.valid) state.resources.add(resource)
|
|
468
|
+
else raw.stop()
|
|
419
469
|
const forget = () => state.resources.delete(resource)
|
|
420
470
|
void raw.finished.then(forget, forget)
|
|
421
471
|
return {
|
|
@@ -24,7 +24,8 @@ export interface MotionSensorSnapshot {
|
|
|
24
24
|
timestamp: number | null
|
|
25
25
|
samples: number
|
|
26
26
|
values: number[]
|
|
27
|
-
|
|
27
|
+
/** `replay` means Jolt is playing synthetic samples; it never proves hardware availability. */
|
|
28
|
+
backend: 'native' | 'device-orientation' | 'device-motion' | 'replay' | 'none'
|
|
28
29
|
reason?: string
|
|
29
30
|
}
|
|
30
31
|
export interface MotionSensor<T = MotionReadable> extends MotionBinding {
|
package/src/experimental.ts
CHANGED
|
@@ -13,6 +13,18 @@ export * from './experimental-effects.js'
|
|
|
13
13
|
export * from './experimental-collections.js'
|
|
14
14
|
export * from './experimental-surfaces.js'
|
|
15
15
|
export * from './experimental-platforms.js'
|
|
16
|
+
export {
|
|
17
|
+
motionPath,
|
|
18
|
+
motionChannels,
|
|
19
|
+
motionKeyframes,
|
|
20
|
+
resolvePerspective,
|
|
21
|
+
elevationMotion,
|
|
22
|
+
type MotionPath,
|
|
23
|
+
type MotionPathBounds,
|
|
24
|
+
type MotionPathSegment,
|
|
25
|
+
type MotionShadowValues,
|
|
26
|
+
} from './experimental-depth.js'
|
|
27
|
+
import { validateMotion, type MotionPath, type MotionShadowValues } from './experimental-depth.js'
|
|
16
28
|
import {
|
|
17
29
|
mapGradientBindings,
|
|
18
30
|
type MotionVisualSurface,
|
|
@@ -38,10 +50,25 @@ import type {
|
|
|
38
50
|
MotionSensorOptions,
|
|
39
51
|
MotionSensorAdapter,
|
|
40
52
|
} from './experimental-sensors.js'
|
|
41
|
-
export type
|
|
53
|
+
export type MotionPlanarValues = Partial<
|
|
42
54
|
Record<'scale' | 'scaleX' | 'scaleY' | 'x' | 'y' | 'rotate' | 'opacity', number>
|
|
43
55
|
>
|
|
44
|
-
|
|
56
|
+
/** rotateX and rotateY read their projection from the nearest box that declares `perspective`. */
|
|
57
|
+
export type MotionValues = MotionPlanarValues & Partial<Record<'rotateX' | 'rotateY', number>>
|
|
58
|
+
/** Shadow channels animate one existing shadow where `supports('shadow')` is true. */
|
|
59
|
+
export type MotionPoseValues = MotionValues & MotionShadowValues
|
|
60
|
+
/** Region sequences, timelines and states take these numeric channels. */
|
|
61
|
+
export type MotionChannelFrames = {
|
|
62
|
+
[K in keyof MotionValues]?: number | readonly (number | null)[]
|
|
63
|
+
}
|
|
64
|
+
export type MotionFrames = MotionChannelFrames & {
|
|
65
|
+
[K in keyof MotionShadowValues]?: number | readonly (number | null)[]
|
|
66
|
+
} & {
|
|
67
|
+
/** Owns x and y for the whole playback. */
|
|
68
|
+
path?: MotionPath
|
|
69
|
+
/** Faces the path's forward tangent, and then also owns rotate. */
|
|
70
|
+
orient?: boolean
|
|
71
|
+
}
|
|
45
72
|
export type MotionOptions = (
|
|
46
73
|
| {
|
|
47
74
|
type?: 'spring' | 'tween'
|
|
@@ -78,7 +105,7 @@ export interface MotionSurface extends MotionVisualSurface {
|
|
|
78
105
|
sensor(kind: MotionSensorKind, options?: MotionSensorOptions): MotionSensor
|
|
79
106
|
readonly available: boolean
|
|
80
107
|
animate(values: MotionFrames, options?: MotionOptions): MotionControlledPlayback
|
|
81
|
-
set(values:
|
|
108
|
+
set(values: MotionPoseValues): MotionPlayback
|
|
82
109
|
/** Runs once per mount/load. Its resources belong to that presentation. */
|
|
83
110
|
onAvailable(setup: () => void | (() => void)): () => void
|
|
84
111
|
/** A child owner, recreated on mount/load. Late work must use the supplied child. */
|
|
@@ -96,7 +123,7 @@ export interface MotionSurface extends MotionVisualSurface {
|
|
|
96
123
|
options?: MotionDecayOptions,
|
|
97
124
|
): MotionControlledPlayback
|
|
98
125
|
motionValue(initial: number): MotionValue
|
|
99
|
-
springValue(source:
|
|
126
|
+
springValue(source: MotionReadable, options?: MotionSpringOptions): MotionSpring
|
|
100
127
|
bind(values: MotionBindings): MotionBinding
|
|
101
128
|
drag(options: MotionDragOptions): MotionDrag
|
|
102
129
|
/** Re-read a supported size/pivot change without replacing this presentation. */
|
|
@@ -120,8 +147,26 @@ export interface MotionBinding {
|
|
|
120
147
|
export interface MotionColor extends MotionBinding {
|
|
121
148
|
get(): string
|
|
122
149
|
}
|
|
123
|
-
|
|
150
|
+
/** Jolt evaluates these operations. Angles use radians; velocity uses source units/second. */
|
|
151
|
+
export interface MotionScalarOperations {
|
|
152
|
+
add(value: MotionReadable | number): MotionReadable
|
|
153
|
+
sub(value: MotionReadable | number): MotionReadable
|
|
154
|
+
mul(value: MotionReadable | number): MotionReadable
|
|
155
|
+
div(value: MotionReadable | number): MotionReadable
|
|
156
|
+
min(value: MotionReadable | number): MotionReadable
|
|
157
|
+
max(value: MotionReadable | number): MotionReadable
|
|
158
|
+
clamp(minimum: number, maximum: number): MotionReadable
|
|
159
|
+
abs(): MotionReadable
|
|
160
|
+
sin(): MotionReadable
|
|
161
|
+
cos(): MotionReadable
|
|
162
|
+
/** A first-derivative source. Its own velocity is zero, not estimated acceleration. */
|
|
163
|
+
velocity(): MotionReadable
|
|
164
|
+
}
|
|
165
|
+
export type MotionScalarOperation = keyof MotionScalarOperations
|
|
166
|
+
export interface MotionReadable extends MotionBinding, MotionScalarOperations {
|
|
124
167
|
get(): number
|
|
168
|
+
/** Snapshot of the derivative; reading installs no subscription or frame loop. */
|
|
169
|
+
getVelocity(): number
|
|
125
170
|
to(
|
|
126
171
|
input: readonly number[],
|
|
127
172
|
output: readonly number[],
|
|
@@ -166,8 +211,12 @@ export interface MotionDrag extends MotionBinding {
|
|
|
166
211
|
}
|
|
167
212
|
|
|
168
213
|
/** Renderer contracts. Values never expose their DOM/native target. */
|
|
214
|
+
export type MotionReadableAdapter = Pick<MotionReadable, 'get' | 'dispose'>
|
|
169
215
|
export type MotionValueAdapter = Pick<MotionValue, 'get' | 'set' | 'dispose'>
|
|
170
|
-
export type MotionSpringAdapter =
|
|
216
|
+
export type MotionSpringAdapter = Pick<
|
|
217
|
+
MotionSpring,
|
|
218
|
+
'get' | 'getVelocity' | 'dispose' | 'moving' | 'paused' | 'pause' | 'resume'
|
|
219
|
+
>
|
|
171
220
|
export type MotionDragAdapter = Omit<MotionDrag, 'disposed'>
|
|
172
221
|
export interface MotionSurfaceAdapter extends Partial<MotionVisualAdapter> {
|
|
173
222
|
sensor?(kind: MotionSensorKind, options?: MotionSensorOptions): MotionSensorAdapter
|
|
@@ -175,7 +224,7 @@ export interface MotionSurfaceAdapter extends Partial<MotionVisualAdapter> {
|
|
|
175
224
|
use?(setup: (adapter: MotionSurfaceAdapter) => () => void): () => void
|
|
176
225
|
pointerFollow?(region: MotionRegionAdapter, options: MotionPointerOptions): MotionPointerAdapter
|
|
177
226
|
animate(values: MotionFrames, options?: MotionOptions): MotionPlayback
|
|
178
|
-
set(values:
|
|
227
|
+
set(values: MotionPoseValues): MotionPlayback
|
|
179
228
|
animateValue?(
|
|
180
229
|
value: MotionValueAdapter,
|
|
181
230
|
frames: number | readonly (number | null)[],
|
|
@@ -185,7 +234,14 @@ export interface MotionSurfaceAdapter extends Partial<MotionVisualAdapter> {
|
|
|
185
234
|
playbackProgress?(playback: MotionPlayback): Pick<MotionReadable, 'get' | 'dispose'>
|
|
186
235
|
decay?(velocity: { x?: number; y?: number }, options?: MotionDecayOptions): MotionPlayback
|
|
187
236
|
motionValue?(initial: number): MotionValueAdapter
|
|
188
|
-
springValue?(source:
|
|
237
|
+
springValue?(source: MotionReadableAdapter, options?: MotionSpringOptions): MotionSpringAdapter
|
|
238
|
+
scalar?(
|
|
239
|
+
source: MotionReadableAdapter,
|
|
240
|
+
operation: MotionScalarOperation,
|
|
241
|
+
operand?: MotionReadableAdapter | number,
|
|
242
|
+
maximum?: number,
|
|
243
|
+
): MotionReadableAdapter
|
|
244
|
+
readVelocity?(source: MotionReadableAdapter): number
|
|
189
245
|
bind?(values: {
|
|
190
246
|
[K in keyof MotionBindings]?: Pick<NonNullable<MotionBindings[K]>, 'get' | 'dispose'>
|
|
191
247
|
}): {
|
|
@@ -218,7 +274,7 @@ export interface MotionSurfaceAdapter extends Partial<MotionVisualAdapter> {
|
|
|
218
274
|
}
|
|
219
275
|
|
|
220
276
|
/** CSS pixels on Web, device-independent pixels on NativeScript. Vertical only. */
|
|
221
|
-
export type MotionScrollFrames = Partial<Record<keyof
|
|
277
|
+
export type MotionScrollFrames = Partial<Record<keyof MotionPlanarValues, readonly number[]>>
|
|
222
278
|
export interface MotionScrollOptions {
|
|
223
279
|
range: readonly [number, number]
|
|
224
280
|
execution?: 'auto' | 'scheduler'
|
|
@@ -370,6 +426,7 @@ type ValueState = {
|
|
|
370
426
|
binding: Binding
|
|
371
427
|
raw: Pick<MotionReadable, 'get' | 'dispose'> | Pick<MotionColor, 'get' | 'dispose'>
|
|
372
428
|
input: boolean
|
|
429
|
+
numeric: boolean
|
|
373
430
|
depth: number
|
|
374
431
|
dependents: Set<Resource>
|
|
375
432
|
}
|
|
@@ -430,9 +487,66 @@ function ownValue<T extends Pick<MotionReadable, 'get' | 'dispose'>>(
|
|
|
430
487
|
binding: Binding,
|
|
431
488
|
raw: T,
|
|
432
489
|
input: boolean,
|
|
433
|
-
|
|
490
|
+
parents: readonly ValueState[] = [],
|
|
434
491
|
): T & MotionReadable {
|
|
492
|
+
const scalar = (
|
|
493
|
+
operation: MotionScalarOperation,
|
|
494
|
+
operand?: MotionReadable | number,
|
|
495
|
+
maximum?: number,
|
|
496
|
+
) => {
|
|
497
|
+
const state = values.get(value)!
|
|
498
|
+
const dependencies = [state]
|
|
499
|
+
let other: MotionReadableAdapter | number | undefined
|
|
500
|
+
if (typeof operand === 'number') {
|
|
501
|
+
if (!Number.isFinite(operand)) throw new RangeError('A scalar operand must be finite.')
|
|
502
|
+
other = operand
|
|
503
|
+
} else if (operand !== undefined) {
|
|
504
|
+
const candidate = values.get(operand)
|
|
505
|
+
if (
|
|
506
|
+
!candidate?.numeric ||
|
|
507
|
+
!candidate.binding.valid ||
|
|
508
|
+
candidate.binding.context !== binding.context ||
|
|
509
|
+
operand.disposed
|
|
510
|
+
)
|
|
511
|
+
throw new TypeError('Use a live numeric value from this surface and presentation.')
|
|
512
|
+
other = candidate.raw as MotionReadableAdapter
|
|
513
|
+
dependencies.push(candidate)
|
|
514
|
+
} else if (['add', 'sub', 'mul', 'div', 'min', 'max', 'clamp'].includes(operation)) {
|
|
515
|
+
throw new TypeError('A scalar operation needs an operand.')
|
|
516
|
+
}
|
|
517
|
+
if (
|
|
518
|
+
operation === 'clamp' &&
|
|
519
|
+
(typeof operand !== 'number' || !Number.isFinite(maximum) || operand > maximum!)
|
|
520
|
+
)
|
|
521
|
+
throw new RangeError('Scalar bounds must be finite and ordered.')
|
|
522
|
+
if (dependencies.some((parent) => parent.depth >= 32))
|
|
523
|
+
throw new RangeError('Motion values support at most 32 derived levels.')
|
|
524
|
+
if (!binding.adapter.scalar) throw new Error('Combined motion values are unavailable.')
|
|
525
|
+
return ownValue(
|
|
526
|
+
binding,
|
|
527
|
+
binding.adapter.scalar(raw, operation, other, maximum),
|
|
528
|
+
false,
|
|
529
|
+
dependencies,
|
|
530
|
+
)
|
|
531
|
+
}
|
|
435
532
|
const mapped = Object.assign({}, raw, {
|
|
533
|
+
add: (operand: MotionReadable | number) => scalar('add', operand),
|
|
534
|
+
sub: (operand: MotionReadable | number) => scalar('sub', operand),
|
|
535
|
+
mul: (operand: MotionReadable | number) => scalar('mul', operand),
|
|
536
|
+
div: (operand: MotionReadable | number) => scalar('div', operand),
|
|
537
|
+
min: (operand: MotionReadable | number) => scalar('min', operand),
|
|
538
|
+
max: (operand: MotionReadable | number) => scalar('max', operand),
|
|
539
|
+
clamp: (minimum: number, maximum: number) => scalar('clamp', minimum, maximum),
|
|
540
|
+
abs: () => scalar('abs'),
|
|
541
|
+
sin: () => scalar('sin'),
|
|
542
|
+
cos: () => scalar('cos'),
|
|
543
|
+
velocity: () => scalar('velocity'),
|
|
544
|
+
getVelocity() {
|
|
545
|
+
if (binding.adapter.readVelocity) return binding.adapter.readVelocity(raw)
|
|
546
|
+
if ('getVelocity' in raw && typeof raw.getVelocity === 'function')
|
|
547
|
+
return raw.getVelocity() as number
|
|
548
|
+
throw new Error('Motion velocity is unavailable.')
|
|
549
|
+
},
|
|
436
550
|
to(
|
|
437
551
|
input: readonly number[],
|
|
438
552
|
output: readonly (number | string)[],
|
|
@@ -473,6 +587,7 @@ function ownValue<T extends Pick<MotionReadable, 'get' | 'dispose'>>(
|
|
|
473
587
|
binding,
|
|
474
588
|
raw: rawColor,
|
|
475
589
|
input: false,
|
|
590
|
+
numeric: false,
|
|
476
591
|
depth: state.depth + 1,
|
|
477
592
|
dependents: new Set(),
|
|
478
593
|
})
|
|
@@ -484,23 +599,39 @@ function ownValue<T extends Pick<MotionReadable, 'get' | 'dispose'>>(
|
|
|
484
599
|
binding,
|
|
485
600
|
binding.adapter.map(raw, input, output as readonly number[], options),
|
|
486
601
|
false,
|
|
487
|
-
state,
|
|
602
|
+
[state],
|
|
488
603
|
)
|
|
489
604
|
},
|
|
490
605
|
})
|
|
491
606
|
// Preserve getters such as moving/paused; Object.assign would snapshot them.
|
|
492
607
|
const descriptors = Object.getOwnPropertyDescriptors(raw)
|
|
493
|
-
|
|
608
|
+
for (const key of [
|
|
609
|
+
'to',
|
|
610
|
+
'getVelocity',
|
|
611
|
+
'add',
|
|
612
|
+
'sub',
|
|
613
|
+
'mul',
|
|
614
|
+
'div',
|
|
615
|
+
'min',
|
|
616
|
+
'max',
|
|
617
|
+
'clamp',
|
|
618
|
+
'abs',
|
|
619
|
+
'sin',
|
|
620
|
+
'cos',
|
|
621
|
+
'velocity',
|
|
622
|
+
])
|
|
623
|
+
delete (descriptors as Record<string, PropertyDescriptor>)[key]
|
|
494
624
|
Object.defineProperties(mapped, descriptors)
|
|
495
625
|
const value = own(binding, mapped) as T & MotionReadable
|
|
496
626
|
values.set(value, {
|
|
497
627
|
binding,
|
|
498
628
|
raw,
|
|
499
629
|
input,
|
|
500
|
-
|
|
630
|
+
numeric: true,
|
|
631
|
+
depth: parents.length ? Math.max(...parents.map((parent) => parent.depth)) + 1 : 0,
|
|
501
632
|
dependents: new Set(),
|
|
502
633
|
})
|
|
503
|
-
|
|
634
|
+
for (const parent of parents) depend(parent, value)
|
|
504
635
|
return value as T & MotionReadable
|
|
505
636
|
}
|
|
506
637
|
|
|
@@ -581,9 +712,15 @@ export function createMotionSurface(): MotionSurface {
|
|
|
581
712
|
for (const value of Object.values(values))
|
|
582
713
|
gravityFrames(Array.isArray(value) ? value : [value], options)
|
|
583
714
|
}
|
|
715
|
+
const binding = current()
|
|
716
|
+
validateMotion(values, true, () => binding.adapter.supports?.('shadow') ?? false)
|
|
584
717
|
return run((adapter) => adapter.animate(values, options))
|
|
585
718
|
},
|
|
586
|
-
set
|
|
719
|
+
set(values) {
|
|
720
|
+
const binding = current()
|
|
721
|
+
validateMotion(values, false, () => binding.adapter.supports?.('shadow') ?? false)
|
|
722
|
+
return run((adapter) => adapter.set(values))
|
|
723
|
+
},
|
|
587
724
|
supports: (effect) => current().adapter.supports?.(effect) ?? false,
|
|
588
725
|
particles(options) {
|
|
589
726
|
const binding = current()
|
|
@@ -835,10 +972,18 @@ export function createMotionSurface(): MotionSurface {
|
|
|
835
972
|
const raw = binding.adapter.pointerFollow(state.adapter, options)
|
|
836
973
|
const x = ownValue(binding, raw.x, false)
|
|
837
974
|
const y = ownValue(binding, raw.y, false)
|
|
975
|
+
const presence = ownValue(binding, raw.presence, false)
|
|
838
976
|
const control = own(binding, {
|
|
839
977
|
x,
|
|
840
978
|
y,
|
|
841
|
-
|
|
979
|
+
presence,
|
|
980
|
+
// Hover can become available after the native view loads.
|
|
981
|
+
get execution() {
|
|
982
|
+
return raw.execution
|
|
983
|
+
},
|
|
984
|
+
get available() {
|
|
985
|
+
return raw.available
|
|
986
|
+
},
|
|
842
987
|
get active() {
|
|
843
988
|
return raw.active
|
|
844
989
|
},
|
|
@@ -848,6 +993,7 @@ export function createMotionSurface(): MotionSurface {
|
|
|
848
993
|
state.resources.delete(control)
|
|
849
994
|
x.dispose()
|
|
850
995
|
y.dispose()
|
|
996
|
+
presence.dispose()
|
|
851
997
|
raw.dispose()
|
|
852
998
|
},
|
|
853
999
|
})
|
|
@@ -960,10 +1106,11 @@ export function createMotionSurface(): MotionSurface {
|
|
|
960
1106
|
},
|
|
961
1107
|
springValue(input, options) {
|
|
962
1108
|
const binding = current()
|
|
963
|
-
const parent = source(input, binding
|
|
1109
|
+
const parent = source(input, binding)
|
|
1110
|
+
if (!parent.numeric) throw new TypeError('A spring needs a live numeric value.')
|
|
964
1111
|
if (!binding.adapter.springValue) throw new Error('Continuous motion is unavailable.')
|
|
965
|
-
const raw = binding.adapter.springValue(parent.raw as
|
|
966
|
-
return ownValue(binding, raw, false, parent)
|
|
1112
|
+
const raw = binding.adapter.springValue(parent.raw as MotionReadableAdapter, options)
|
|
1113
|
+
return ownValue(binding, raw, false, [parent])
|
|
967
1114
|
},
|
|
968
1115
|
bind(input) {
|
|
969
1116
|
const binding = current()
|
package/src/index.ts
CHANGED
|
@@ -78,7 +78,12 @@ export type {
|
|
|
78
78
|
ButtonEvents,
|
|
79
79
|
TextInputHandle,
|
|
80
80
|
} from './contracts.js'
|
|
81
|
-
export {
|
|
81
|
+
export {
|
|
82
|
+
targetCapabilities,
|
|
83
|
+
componentNames,
|
|
84
|
+
themeContract,
|
|
85
|
+
macosCapabilities,
|
|
86
|
+
} from './capabilities.js'
|
|
82
87
|
export type { ComponentName, CapabilityStatus } from './capabilities.js'
|
|
83
88
|
|
|
84
89
|
export * from './date.js'
|