@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
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { MotionBinding, MotionOptions, MotionPlayback } from './experimental.js'
|
|
2
|
+
import type { MotionControlledPlayback } from './experimental-playback.js'
|
|
3
|
+
|
|
4
|
+
/** The common renderer subset. Distances are CSS pixels on Web and DIPs on native. */
|
|
5
|
+
export interface MotionParticleOptions {
|
|
6
|
+
colors?: readonly string[]
|
|
7
|
+
shape?: 'circle' | 'rectangle' | 'ring'
|
|
8
|
+
source?: 'center' | 'top' | 'bottom'
|
|
9
|
+
rate?: number
|
|
10
|
+
lifetime?: number
|
|
11
|
+
size?: number
|
|
12
|
+
velocity?: number
|
|
13
|
+
velocityRange?: number
|
|
14
|
+
angle?: number
|
|
15
|
+
spread?: number
|
|
16
|
+
gravity?: number
|
|
17
|
+
spin?: number
|
|
18
|
+
spinRange?: number
|
|
19
|
+
fadeOut?: boolean
|
|
20
|
+
duration?: number
|
|
21
|
+
}
|
|
22
|
+
export interface MotionConfettiOptions {
|
|
23
|
+
count?: number
|
|
24
|
+
colors?: readonly string[]
|
|
25
|
+
}
|
|
26
|
+
export interface MotionDecoration extends MotionBinding {
|
|
27
|
+
readonly supported: boolean
|
|
28
|
+
}
|
|
29
|
+
export interface MotionBlurOptions {
|
|
30
|
+
amount?: number
|
|
31
|
+
radius?: number
|
|
32
|
+
style?: 'system' | 'light' | 'dark'
|
|
33
|
+
}
|
|
34
|
+
export interface MotionBlur extends MotionBinding {
|
|
35
|
+
animate(amount: number, options?: MotionOptions): MotionControlledPlayback
|
|
36
|
+
set(amount: number): void
|
|
37
|
+
stop(): void
|
|
38
|
+
snapshot(): { amount: number; appliedAmount: number; backend: string; attached: boolean }
|
|
39
|
+
}
|
|
40
|
+
export interface MotionShapeValues {
|
|
41
|
+
d?: string
|
|
42
|
+
strokeStart?: number
|
|
43
|
+
strokeEnd?: number
|
|
44
|
+
}
|
|
45
|
+
export interface MotionShapeOptions extends MotionShapeValues {
|
|
46
|
+
d: string
|
|
47
|
+
viewBox: readonly [number, number, number, number]
|
|
48
|
+
stroke?: string
|
|
49
|
+
fill?: string
|
|
50
|
+
strokeWidth?: number
|
|
51
|
+
lineCap?: 'butt' | 'round' | 'square'
|
|
52
|
+
lineJoin?: 'miter' | 'round' | 'bevel'
|
|
53
|
+
fillRule?: 'nonzero' | 'evenodd'
|
|
54
|
+
}
|
|
55
|
+
export interface MotionShape extends MotionBinding {
|
|
56
|
+
animate(values: MotionShapeValues, options?: MotionOptions): MotionControlledPlayback
|
|
57
|
+
set(values: MotionShapeValues): void
|
|
58
|
+
stop(): void
|
|
59
|
+
}
|
|
60
|
+
export interface MotionLiquid extends MotionDecoration {
|
|
61
|
+
pause(): void
|
|
62
|
+
resume(): void
|
|
63
|
+
}
|
|
64
|
+
export interface MotionLiquidOptions {
|
|
65
|
+
intensity?: number
|
|
66
|
+
duration?: number
|
|
67
|
+
}
|
|
68
|
+
export type MotionImageEffectName = 'ripple' | 'distortion' | 'dissolve'
|
|
69
|
+
export interface MotionImagePlayback extends MotionControlledPlayback {
|
|
70
|
+
reverse(): void
|
|
71
|
+
finish(): void
|
|
72
|
+
}
|
|
73
|
+
export interface MotionImageEffectOptions {
|
|
74
|
+
origin?: { x: number; y: number }
|
|
75
|
+
amplitude?: number
|
|
76
|
+
radius?: number
|
|
77
|
+
duration?: number
|
|
78
|
+
seed?: number
|
|
79
|
+
/** A source URL, prepared by MImage before starting. Success emits update:src. */
|
|
80
|
+
to?: string
|
|
81
|
+
paused?: boolean
|
|
82
|
+
}
|
|
83
|
+
export type MotionSymbolEffectName = 'bounce' | 'pulse' | 'scale' | 'variableColor'
|
|
84
|
+
export interface MotionSymbolOptions {
|
|
85
|
+
speed?: number
|
|
86
|
+
repeat?: boolean
|
|
87
|
+
}
|
|
88
|
+
export interface MotionKeyboardFollowOptions {
|
|
89
|
+
offset?: number
|
|
90
|
+
}
|
|
91
|
+
export interface MotionSurfaceEffects {
|
|
92
|
+
particles(options?: MotionParticleOptions): MotionDecoration
|
|
93
|
+
confetti(options?: MotionConfettiOptions): MotionDecoration
|
|
94
|
+
blur(options?: MotionBlurOptions): MotionBlur
|
|
95
|
+
shape(options: MotionShapeOptions): MotionShape
|
|
96
|
+
/** Only a loaded MImage target, not its layout wrapper. */
|
|
97
|
+
liquid(options?: MotionLiquidOptions): MotionLiquid
|
|
98
|
+
imageEffect(
|
|
99
|
+
name: MotionImageEffectName,
|
|
100
|
+
options?: MotionImageEffectOptions,
|
|
101
|
+
): Promise<MotionImagePlayback>
|
|
102
|
+
/** MIcon artwork: Web supports glyphs; native requires an iOS system-symbol image. */
|
|
103
|
+
symbolEffect(name: MotionSymbolEffectName, options?: MotionSymbolOptions): MotionPlayback
|
|
104
|
+
/** Use a dedicated, untranslated composer surface. */
|
|
105
|
+
followKeyboard(options?: MotionKeyboardFollowOptions): MotionBinding
|
|
106
|
+
}
|
|
107
|
+
export interface MotionSurfaceEffectsAdapter {
|
|
108
|
+
particles(options?: MotionParticleOptions): Omit<MotionDecoration, 'disposed'>
|
|
109
|
+
confetti(options?: MotionConfettiOptions): Omit<MotionDecoration, 'disposed'>
|
|
110
|
+
blur(options?: MotionBlurOptions): Omit<MotionBlur, 'disposed' | 'animate'> & {
|
|
111
|
+
animate(amount: number, options?: MotionOptions): MotionPlayback
|
|
112
|
+
}
|
|
113
|
+
shape(options: MotionShapeOptions): Omit<MotionShape, 'disposed' | 'animate'> & {
|
|
114
|
+
animate(values: MotionShapeValues, options?: MotionOptions): MotionPlayback
|
|
115
|
+
}
|
|
116
|
+
liquid(options?: MotionLiquidOptions): Omit<MotionLiquid, 'disposed'>
|
|
117
|
+
imageEffect(
|
|
118
|
+
name: MotionImageEffectName,
|
|
119
|
+
options: MotionImageEffectOptions | undefined,
|
|
120
|
+
live: () => boolean,
|
|
121
|
+
): Promise<MotionPlayback>
|
|
122
|
+
symbolEffect(name: MotionSymbolEffectName, options?: MotionSymbolOptions): MotionPlayback
|
|
123
|
+
followKeyboard(options?: MotionKeyboardFollowOptions): { dispose(): void }
|
|
124
|
+
}
|
package/src/experimental.ts
CHANGED
|
@@ -6,6 +6,17 @@ import {
|
|
|
6
6
|
type MotionDecayOptions,
|
|
7
7
|
} from './experimental-playback.js'
|
|
8
8
|
export * from './experimental-playback.js'
|
|
9
|
+
export * from './experimental-effects.js'
|
|
10
|
+
export * from './experimental-collections.js'
|
|
11
|
+
export * from './experimental-surfaces.js'
|
|
12
|
+
export * from './experimental-platforms.js'
|
|
13
|
+
import {
|
|
14
|
+
mapGradientBindings,
|
|
15
|
+
type MotionVisualSurface,
|
|
16
|
+
type MotionVisualAdapter,
|
|
17
|
+
type MotionGradient,
|
|
18
|
+
type MotionCircular,
|
|
19
|
+
} from './experimental-effects.js'
|
|
9
20
|
/** Experimental, single-surface motion contract. No platform objects cross this boundary. */
|
|
10
21
|
import {
|
|
11
22
|
regionState,
|
|
@@ -17,22 +28,51 @@ import {
|
|
|
17
28
|
type MotionPointerAdapter,
|
|
18
29
|
} from './experimental-regions.js'
|
|
19
30
|
export * from './experimental-regions.js'
|
|
31
|
+
export * from './experimental-sensors.js'
|
|
32
|
+
import type {
|
|
33
|
+
MotionSensor,
|
|
34
|
+
MotionSensorKind,
|
|
35
|
+
MotionSensorOptions,
|
|
36
|
+
MotionSensorAdapter,
|
|
37
|
+
} from './experimental-sensors.js'
|
|
20
38
|
export type MotionValues = Partial<
|
|
21
39
|
Record<'scale' | 'scaleX' | 'scaleY' | 'x' | 'y' | 'rotate' | 'opacity', number>
|
|
22
40
|
>
|
|
23
41
|
export type MotionFrames = { [K in keyof MotionValues]?: number | readonly (number | null)[] }
|
|
24
|
-
export
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
42
|
+
export type MotionOptions = (
|
|
43
|
+
| {
|
|
44
|
+
type?: 'spring' | 'tween'
|
|
45
|
+
duration?: number
|
|
46
|
+
bounce?: number
|
|
47
|
+
ease?: 'linear' | 'easeIn' | 'easeOut' | 'easeInOut'
|
|
48
|
+
acceleration?: never
|
|
49
|
+
restitution?: never
|
|
50
|
+
}
|
|
51
|
+
| {
|
|
52
|
+
type: 'gravity'
|
|
53
|
+
acceleration?: number
|
|
54
|
+
restitution?: number
|
|
55
|
+
duration?: never
|
|
56
|
+
bounce?: never
|
|
57
|
+
ease?: never
|
|
58
|
+
}
|
|
59
|
+
) & {
|
|
60
|
+
velocity?: number
|
|
29
61
|
delay?: number
|
|
62
|
+
haptic?:
|
|
63
|
+
| 'light'
|
|
64
|
+
| 'medium'
|
|
65
|
+
| 'heavy'
|
|
66
|
+
| false
|
|
67
|
+
| { style: 'light' | 'medium' | 'heavy'; times?: readonly number[] }
|
|
30
68
|
}
|
|
69
|
+
|
|
31
70
|
export interface MotionPlayback {
|
|
32
71
|
readonly finished: Promise<boolean>
|
|
33
72
|
stop(): void
|
|
34
73
|
}
|
|
35
|
-
export interface MotionSurface {
|
|
74
|
+
export interface MotionSurface extends MotionVisualSurface {
|
|
75
|
+
sensor(kind: MotionSensorKind, options?: MotionSensorOptions): MotionSensor
|
|
36
76
|
readonly available: boolean
|
|
37
77
|
animate(values: MotionFrames, options?: MotionOptions): MotionControlledPlayback
|
|
38
78
|
set(values: MotionValues): MotionPlayback
|
|
@@ -120,7 +160,8 @@ export interface MotionDrag extends MotionBinding {
|
|
|
120
160
|
export type MotionValueAdapter = Pick<MotionValue, 'get' | 'set' | 'dispose'>
|
|
121
161
|
export type MotionSpringAdapter = Omit<MotionSpring, 'disposed' | 'to'>
|
|
122
162
|
export type MotionDragAdapter = Omit<MotionDrag, 'disposed'>
|
|
123
|
-
export interface MotionSurfaceAdapter {
|
|
163
|
+
export interface MotionSurfaceAdapter extends Partial<MotionVisualAdapter> {
|
|
164
|
+
sensor?(kind: MotionSensorKind, options?: MotionSensorOptions): MotionSensorAdapter
|
|
124
165
|
/** The renderer borrows its host runtime and owns only this child's resources. */
|
|
125
166
|
use?(setup: (adapter: MotionSurfaceAdapter) => () => void): () => void
|
|
126
167
|
pointerFollow?(region: MotionRegionAdapter, options: MotionPointerOptions): MotionPointerAdapter
|
|
@@ -449,6 +490,39 @@ function ownValue<T extends Pick<MotionReadable, 'get' | 'dispose'>>(
|
|
|
449
490
|
}
|
|
450
491
|
|
|
451
492
|
export function createMotionSurface(): MotionSurface {
|
|
493
|
+
// Validate the portable gravity contract before a renderer relinquishes scroll ownership.
|
|
494
|
+
// Trajectory compilation, velocity inheritance and playback remain entirely in Jolt.
|
|
495
|
+
const gravityFrames = (frames: readonly unknown[], options?: MotionOptions) => {
|
|
496
|
+
if (options?.type !== 'gravity') return
|
|
497
|
+
if (
|
|
498
|
+
frames.length < 1 ||
|
|
499
|
+
frames.length > 2 ||
|
|
500
|
+
frames.some(
|
|
501
|
+
(value, index) =>
|
|
502
|
+
!(index === 0 && frames.length === 2 && value === null) &&
|
|
503
|
+
(typeof value !== 'number' || !Number.isFinite(value)),
|
|
504
|
+
)
|
|
505
|
+
)
|
|
506
|
+
throw new TypeError('Gravity needs one fixed numeric landing position.')
|
|
507
|
+
if (
|
|
508
|
+
options.acceleration !== undefined &&
|
|
509
|
+
(!Number.isFinite(options.acceleration) || options.acceleration <= 0)
|
|
510
|
+
)
|
|
511
|
+
throw new RangeError('Gravity acceleration must be finite and positive.')
|
|
512
|
+
if (
|
|
513
|
+
options.restitution !== undefined &&
|
|
514
|
+
(!Number.isFinite(options.restitution) || options.restitution < 0 || options.restitution >= 1)
|
|
515
|
+
)
|
|
516
|
+
throw new RangeError('Gravity restitution must be in [0, 1).')
|
|
517
|
+
if (options.velocity !== undefined && !Number.isFinite(options.velocity))
|
|
518
|
+
throw new RangeError('Gravity velocity must be finite.')
|
|
519
|
+
if (
|
|
520
|
+
options.duration !== undefined ||
|
|
521
|
+
options.ease !== undefined ||
|
|
522
|
+
options.bounce !== undefined
|
|
523
|
+
)
|
|
524
|
+
throw new TypeError('Gravity timing comes from physics.')
|
|
525
|
+
}
|
|
452
526
|
const current = () => {
|
|
453
527
|
const binding = bindings.get(surface)
|
|
454
528
|
if (!binding?.valid)
|
|
@@ -484,8 +558,171 @@ export function createMotionSurface(): MotionSurface {
|
|
|
484
558
|
get available() {
|
|
485
559
|
return Boolean(bindings.get(surface)?.valid)
|
|
486
560
|
},
|
|
487
|
-
animate
|
|
561
|
+
animate(values, options) {
|
|
562
|
+
if (options?.type === 'gravity') {
|
|
563
|
+
const keys = Object.keys(values)
|
|
564
|
+
if (!keys.length || keys.some((key) => key !== 'x' && key !== 'y'))
|
|
565
|
+
throw new TypeError('Gravity applies only to x/y or a numeric motion value.')
|
|
566
|
+
for (const value of Object.values(values))
|
|
567
|
+
gravityFrames(Array.isArray(value) ? value : [value], options)
|
|
568
|
+
}
|
|
569
|
+
return run((adapter) => adapter.animate(values, options))
|
|
570
|
+
},
|
|
488
571
|
set: (values) => run((adapter) => adapter.set(values)),
|
|
572
|
+
supports: (effect) => current().adapter.supports?.(effect) ?? false,
|
|
573
|
+
particles(options) {
|
|
574
|
+
const binding = current()
|
|
575
|
+
if (!binding.adapter.particles) throw new Error('Particles are unavailable.')
|
|
576
|
+
return own(binding, binding.adapter.particles(options))
|
|
577
|
+
},
|
|
578
|
+
confetti(options) {
|
|
579
|
+
const binding = current()
|
|
580
|
+
if (!binding.adapter.confetti) throw new Error('Confetti is unavailable.')
|
|
581
|
+
return own(binding, binding.adapter.confetti(options))
|
|
582
|
+
},
|
|
583
|
+
blur(options) {
|
|
584
|
+
const binding = current()
|
|
585
|
+
if (!binding.adapter.blur) throw new Error('Blur is unavailable.')
|
|
586
|
+
const raw = binding.adapter.blur(options)
|
|
587
|
+
return own(binding, {
|
|
588
|
+
animate: (amount: number, timing?: MotionOptions) => run(() => raw.animate(amount, timing)),
|
|
589
|
+
set: (amount: number) => raw.set(amount),
|
|
590
|
+
stop: () => raw.stop(),
|
|
591
|
+
snapshot: () => raw.snapshot(),
|
|
592
|
+
dispose: () => raw.dispose(),
|
|
593
|
+
})
|
|
594
|
+
},
|
|
595
|
+
shape(options) {
|
|
596
|
+
const binding = current()
|
|
597
|
+
if (!binding.adapter.shape) throw new Error('Shapes are unavailable.')
|
|
598
|
+
const raw = binding.adapter.shape(options)
|
|
599
|
+
return own(binding, {
|
|
600
|
+
animate: (
|
|
601
|
+
values: import('./experimental-surfaces.js').MotionShapeValues,
|
|
602
|
+
timing?: MotionOptions,
|
|
603
|
+
) => run(() => raw.animate(values, timing)),
|
|
604
|
+
set: (values: import('./experimental-surfaces.js').MotionShapeValues) => raw.set(values),
|
|
605
|
+
stop: () => raw.stop(),
|
|
606
|
+
dispose: () => raw.dispose(),
|
|
607
|
+
})
|
|
608
|
+
},
|
|
609
|
+
liquid(options) {
|
|
610
|
+
const binding = current()
|
|
611
|
+
if (!binding.adapter.liquid) throw new Error('Liquid images are unavailable.')
|
|
612
|
+
return own(binding, binding.adapter.liquid(options))
|
|
613
|
+
},
|
|
614
|
+
async imageEffect(name, options) {
|
|
615
|
+
const binding = current()
|
|
616
|
+
if (!binding.adapter.imageEffect) throw new Error('Image effects are unavailable.')
|
|
617
|
+
const raw = await binding.adapter.imageEffect(name, options, () => binding.valid)
|
|
618
|
+
if (!binding.valid) {
|
|
619
|
+
raw.stop()
|
|
620
|
+
throw new Error('Image presentation changed while preparing the effect.')
|
|
621
|
+
}
|
|
622
|
+
const control = run(() => raw)
|
|
623
|
+
// Keep the controlled playback accessors live while adding image-specific controls.
|
|
624
|
+
return Object.defineProperties(control, {
|
|
625
|
+
reverse: {
|
|
626
|
+
value: () => {
|
|
627
|
+
if (!binding.valid) throw new Error('Image presentation is disposed.')
|
|
628
|
+
;(raw as MotionPlayback & { reverse(): void }).reverse()
|
|
629
|
+
},
|
|
630
|
+
},
|
|
631
|
+
finish: {
|
|
632
|
+
value: () => {
|
|
633
|
+
if (!binding.valid) throw new Error('Image presentation is disposed.')
|
|
634
|
+
;(raw as MotionPlayback & { finish(): void }).finish()
|
|
635
|
+
},
|
|
636
|
+
},
|
|
637
|
+
}) as import('./experimental-surfaces.js').MotionImagePlayback
|
|
638
|
+
},
|
|
639
|
+
symbolEffect: (name, options) =>
|
|
640
|
+
run((adapter) => {
|
|
641
|
+
if (!adapter.symbolEffect) throw new Error('Icon effects are unavailable.')
|
|
642
|
+
return adapter.symbolEffect(name, options)
|
|
643
|
+
}),
|
|
644
|
+
followKeyboard(options) {
|
|
645
|
+
const binding = current()
|
|
646
|
+
if (!binding.adapter.followKeyboard) throw new Error('Keyboard following is unavailable.')
|
|
647
|
+
if (options?.offset !== undefined && (!Number.isFinite(options.offset) || options.offset < 0))
|
|
648
|
+
throw new RangeError('Keyboard offset must be finite and nonnegative.')
|
|
649
|
+
return own(binding, binding.adapter.followKeyboard(options))
|
|
650
|
+
},
|
|
651
|
+
gradient(options) {
|
|
652
|
+
const binding = current()
|
|
653
|
+
if (!binding.adapter.gradient) throw new Error('Gradients are unavailable.')
|
|
654
|
+
const raw = binding.adapter.gradient(options)
|
|
655
|
+
const children = new Set<MotionBinding>()
|
|
656
|
+
return own<Omit<MotionGradient, 'disposed'>>(binding, {
|
|
657
|
+
type: raw.type,
|
|
658
|
+
get suspended() {
|
|
659
|
+
return raw.suspended
|
|
660
|
+
},
|
|
661
|
+
animate: (values, options) => run(() => raw.animate(values, options)),
|
|
662
|
+
set: (values) => raw.set(values),
|
|
663
|
+
stop: () => raw.stop(),
|
|
664
|
+
suspend: () => raw.suspend(),
|
|
665
|
+
resume: () => raw.resume(),
|
|
666
|
+
bind(input) {
|
|
667
|
+
const parents = new Set<ValueState>()
|
|
668
|
+
const unwrap = (value: MotionReadable | MotionColor) => {
|
|
669
|
+
const state = source(value, binding)
|
|
670
|
+
parents.add(state)
|
|
671
|
+
return state.raw
|
|
672
|
+
}
|
|
673
|
+
const values = mapGradientBindings(
|
|
674
|
+
input,
|
|
675
|
+
(value) => unwrap(value) as Pick<MotionReadable, 'get' | 'dispose'>,
|
|
676
|
+
(value) => unwrap(value) as Pick<MotionColor, 'get' | 'dispose'>,
|
|
677
|
+
)
|
|
678
|
+
const linked = raw.bind(values)
|
|
679
|
+
const handle = own(binding, {
|
|
680
|
+
dispose() {
|
|
681
|
+
children.delete(handle)
|
|
682
|
+
linked.dispose()
|
|
683
|
+
},
|
|
684
|
+
})
|
|
685
|
+
children.add(handle)
|
|
686
|
+
for (const parent of parents) depend(parent, handle)
|
|
687
|
+
return handle
|
|
688
|
+
},
|
|
689
|
+
dispose() {
|
|
690
|
+
for (const child of [...children]) child.dispose()
|
|
691
|
+
raw.dispose()
|
|
692
|
+
},
|
|
693
|
+
})
|
|
694
|
+
},
|
|
695
|
+
shimmer(options) {
|
|
696
|
+
const binding = current()
|
|
697
|
+
if (!binding.adapter.shimmer) throw new Error('Shimmer is unavailable.')
|
|
698
|
+
return own(binding, binding.adapter.shimmer(options))
|
|
699
|
+
},
|
|
700
|
+
loader(options) {
|
|
701
|
+
const binding = current()
|
|
702
|
+
if (!binding.adapter.loader) throw new Error('Loaders are unavailable.')
|
|
703
|
+
return own(binding, binding.adapter.loader(options))
|
|
704
|
+
},
|
|
705
|
+
circular() {
|
|
706
|
+
const binding = current()
|
|
707
|
+
if (!binding.adapter.circular) throw new Error('Circular visibility is unavailable.')
|
|
708
|
+
const raw = binding.adapter.circular()
|
|
709
|
+
return own<Omit<MotionCircular, 'disposed'>>(binding, {
|
|
710
|
+
supported: raw.supported,
|
|
711
|
+
reveal: (options) => run(() => raw.reveal(options)),
|
|
712
|
+
conceal: (options) => run(() => raw.conceal(options)),
|
|
713
|
+
dispose: () => raw.dispose(),
|
|
714
|
+
})
|
|
715
|
+
},
|
|
716
|
+
animateText: (options) =>
|
|
717
|
+
run((adapter) => {
|
|
718
|
+
if (!adapter.animateText) throw new Error('Text entrance is unavailable.')
|
|
719
|
+
return adapter.animateText(options)
|
|
720
|
+
}),
|
|
721
|
+
rollTo: (value, options) =>
|
|
722
|
+
run((adapter) => {
|
|
723
|
+
if (!adapter.rollTo) throw new Error('Rolling text is unavailable.')
|
|
724
|
+
return adapter.rollTo(value, options)
|
|
725
|
+
}),
|
|
489
726
|
use(setup) {
|
|
490
727
|
return surface.onAvailable(() => {
|
|
491
728
|
const binding = current()
|
|
@@ -512,6 +749,69 @@ export function createMotionSurface(): MotionSurface {
|
|
|
512
749
|
return binding.adapter.use?.(start) ?? start(binding.adapter)
|
|
513
750
|
})
|
|
514
751
|
},
|
|
752
|
+
sensor(kind, options) {
|
|
753
|
+
const binding = current()
|
|
754
|
+
if (!binding.adapter.sensor) throw new Error('Sensor input is unavailable.')
|
|
755
|
+
const raw = binding.adapter.sensor(kind, options)
|
|
756
|
+
const values: MotionReadable[] = []
|
|
757
|
+
const wrap = (value: Pick<MotionValueAdapter, 'get' | 'dispose'>) => {
|
|
758
|
+
const result = ownValue(binding, value, false)
|
|
759
|
+
values.push(result)
|
|
760
|
+
return result
|
|
761
|
+
}
|
|
762
|
+
const x = wrap(raw.x),
|
|
763
|
+
y = wrap(raw.y),
|
|
764
|
+
z = wrap(raw.z)
|
|
765
|
+
const quaternion = raw.quaternion && {
|
|
766
|
+
x: wrap(raw.quaternion.x),
|
|
767
|
+
y: wrap(raw.quaternion.y),
|
|
768
|
+
z: wrap(raw.quaternion.z),
|
|
769
|
+
w: wrap(raw.quaternion.w),
|
|
770
|
+
}
|
|
771
|
+
let disposed = false
|
|
772
|
+
const assert = () => {
|
|
773
|
+
if (disposed || !binding.valid) throw new Error('Sensor presentation is disposed.')
|
|
774
|
+
}
|
|
775
|
+
return own(binding, {
|
|
776
|
+
kind: raw.kind,
|
|
777
|
+
x,
|
|
778
|
+
y,
|
|
779
|
+
z,
|
|
780
|
+
quaternion,
|
|
781
|
+
get status() {
|
|
782
|
+
return disposed ? ('disposed' as const) : raw.status
|
|
783
|
+
},
|
|
784
|
+
get available() {
|
|
785
|
+
return !disposed && raw.available
|
|
786
|
+
},
|
|
787
|
+
get paused() {
|
|
788
|
+
return raw.paused
|
|
789
|
+
},
|
|
790
|
+
pause() {
|
|
791
|
+
assert()
|
|
792
|
+
raw.pause()
|
|
793
|
+
},
|
|
794
|
+
resume() {
|
|
795
|
+
assert()
|
|
796
|
+
raw.resume()
|
|
797
|
+
},
|
|
798
|
+
recenter() {
|
|
799
|
+
assert()
|
|
800
|
+
raw.recenter()
|
|
801
|
+
},
|
|
802
|
+
async requestPermission() {
|
|
803
|
+
assert()
|
|
804
|
+
const result = await raw.requestPermission()
|
|
805
|
+
return disposed || !binding.valid ? ('unavailable' as const) : result
|
|
806
|
+
},
|
|
807
|
+
snapshot: () => raw.snapshot(),
|
|
808
|
+
dispose() {
|
|
809
|
+
disposed = true
|
|
810
|
+
for (const value of values) value.dispose()
|
|
811
|
+
raw.dispose()
|
|
812
|
+
},
|
|
813
|
+
})
|
|
814
|
+
},
|
|
515
815
|
pointerFollow(region, options = {}) {
|
|
516
816
|
const binding = current()
|
|
517
817
|
validatePointer(options)
|
|
@@ -597,6 +897,7 @@ export function createMotionSurface(): MotionSurface {
|
|
|
597
897
|
}
|
|
598
898
|
},
|
|
599
899
|
animateValue(value, frames, options) {
|
|
900
|
+
gravityFrames(Array.isArray(frames) ? frames : [frames], options)
|
|
600
901
|
const binding = current()
|
|
601
902
|
const parent = source(value, binding, true)
|
|
602
903
|
if (!binding.adapter.animateValue) throw new Error('Scalar playback is unavailable.')
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PropType } from '@vue/runtime-core'
|
|
2
2
|
import type { ChoiceOption, ChoiceValue } from '../choice.js'
|
|
3
3
|
import type { NumberLocale } from '../number-input.js'
|
|
4
|
+
import type { MotionSurface } from '../experimental.js'
|
|
4
5
|
import { inputProps, boxProps } from './props.js'
|
|
5
6
|
|
|
6
7
|
const field = {
|
|
@@ -45,6 +46,7 @@ export const multiSelectProps = {
|
|
|
45
46
|
}
|
|
46
47
|
export const imageProps = {
|
|
47
48
|
...boxProps,
|
|
49
|
+
motionSurface: { type: Object as PropType<MotionSurface>, default: undefined },
|
|
48
50
|
src: { type: String, required: true as const },
|
|
49
51
|
alt: { type: String, required: true as const },
|
|
50
52
|
aspectRatio: { type: Number, default: 4 / 3 },
|
package/src/vue/index.ts
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { watch, onScopeDispose } from '@vue/runtime-core'
|
|
2
|
+
import { markRaw } from '@vue/reactivity'
|
|
3
|
+
import {
|
|
4
|
+
createMotionSurface,
|
|
5
|
+
type MotionLoadingEffect,
|
|
6
|
+
type MotionLoaderOptions,
|
|
7
|
+
} from '../experimental.js'
|
|
8
|
+
|
|
9
|
+
/** Internal decoration; the declared presentation and Jolt own its lifetime. */
|
|
10
|
+
export function useLoadingDecoration(
|
|
11
|
+
settings: () => MotionLoaderOptions & {
|
|
12
|
+
kind: 'shimmer' | 'dots' | 'bars' | 'ring'
|
|
13
|
+
animated: boolean
|
|
14
|
+
},
|
|
15
|
+
) {
|
|
16
|
+
const surface = markRaw(createMotionSurface())
|
|
17
|
+
const off = surface.use((motion) => {
|
|
18
|
+
let resource: MotionLoadingEffect | undefined
|
|
19
|
+
const stop = watch(
|
|
20
|
+
settings,
|
|
21
|
+
(options) => {
|
|
22
|
+
resource?.dispose()
|
|
23
|
+
resource = undefined
|
|
24
|
+
if (!options.animated) return
|
|
25
|
+
resource =
|
|
26
|
+
options.kind === 'shimmer'
|
|
27
|
+
? motion.shimmer({ duration: options.duration })
|
|
28
|
+
: motion.loader({
|
|
29
|
+
style: options.kind,
|
|
30
|
+
size: options.size,
|
|
31
|
+
color: options.color,
|
|
32
|
+
duration: options.duration,
|
|
33
|
+
})
|
|
34
|
+
},
|
|
35
|
+
{ immediate: true },
|
|
36
|
+
)
|
|
37
|
+
return () => {
|
|
38
|
+
stop()
|
|
39
|
+
resource?.dispose()
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
onScopeDispose(off)
|
|
43
|
+
return surface
|
|
44
|
+
}
|
package/src/vue/props.ts
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from '../contracts.js'
|
|
17
17
|
import { vueProps, vueProperty } from './contracts.js'
|
|
18
18
|
export type { Align, Justify } from '../contracts.js'
|
|
19
|
-
import type { MotionSurface, MotionScrollSource } from '../experimental.js'
|
|
19
|
+
import type { MotionSurface, MotionScrollSource, MotionRegion } from '../experimental.js'
|
|
20
20
|
import type { AccordionItem } from '../accordion.js'
|
|
21
21
|
import type { SegmentedOption } from '../segmented.js'
|
|
22
22
|
import type { TabOption } from '../tabs.js'
|
|
@@ -166,6 +166,7 @@ export const skeletonProps = {
|
|
|
166
166
|
height: { ...dimensionProp, default: 16 },
|
|
167
167
|
radius: { ...radiusProp, default: 'sm' },
|
|
168
168
|
animated: { type: Boolean, default: true },
|
|
169
|
+
effect: choice(['pulse', 'shimmer'] as const, 'pulse'),
|
|
169
170
|
}
|
|
170
171
|
export const rowProps = vueProps(rowContract)
|
|
171
172
|
export const columnProps = vueProps(columnContract)
|
|
@@ -281,6 +282,8 @@ export const segmentedEmits = radioGroupEmits
|
|
|
281
282
|
export const dialogProps = {
|
|
282
283
|
id: viewProps.id,
|
|
283
284
|
open: Boolean,
|
|
285
|
+
/** Opt-in Web drag presentation. Native retains its existing in-page modal owner. */
|
|
286
|
+
interactive: Boolean,
|
|
284
287
|
title: { type: String, required: true as const },
|
|
285
288
|
description: { type: String, default: '' },
|
|
286
289
|
confirmLabel: { type: String, default: 'Continue' },
|
|
@@ -319,6 +322,9 @@ export const inputEmits = {
|
|
|
319
322
|
}
|
|
320
323
|
export const iconProps = {
|
|
321
324
|
id: viewProps.id,
|
|
325
|
+
motionSurface: { type: Object as PropType<MotionSurface>, default: undefined },
|
|
326
|
+
/** Optional native iOS SF Symbol artwork; name remains the portable fallback. */
|
|
327
|
+
systemName: { type: String, default: undefined },
|
|
322
328
|
name: { type: String as PropType<IconName>, required: true as const },
|
|
323
329
|
size: {
|
|
324
330
|
type: [String, Number] as PropType<IconSize>,
|
|
@@ -330,6 +336,7 @@ export const iconProps = {
|
|
|
330
336
|
label: { type: String, default: undefined },
|
|
331
337
|
}
|
|
332
338
|
export const screenProps = {
|
|
339
|
+
motionRegion: { type: Object as PropType<MotionRegion>, default: undefined },
|
|
333
340
|
motionScroll: { type: Object as PropType<MotionScrollSource>, default: undefined },
|
|
334
341
|
...viewProps,
|
|
335
342
|
scroll: Boolean,
|