@getcortexlabs/mavis 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/README.md +5 -5
- package/dist/native/collection-motion.d.ts +5 -0
- package/dist/native/collection-motion.d.ts.map +1 -0
- package/dist/native/collection-motion.js +157 -0
- package/dist/native/collection-motion.js.map +1 -0
- package/dist/native/image-effects.d.ts +11 -0
- package/dist/native/image-effects.d.ts.map +1 -0
- package/dist/native/image-effects.js +61 -0
- package/dist/native/image-effects.js.map +1 -0
- package/dist/native/motion-region.d.ts.map +1 -1
- package/dist/native/motion-region.js +7 -2
- package/dist/native/motion-region.js.map +1 -1
- package/dist/native/motion-surface.d.ts +2 -2
- package/dist/native/motion-surface.d.ts.map +1 -1
- package/dist/native/motion-surface.js +44 -1
- package/dist/native/motion-surface.js.map +1 -1
- package/dist/native/platform-motion.d.ts +5 -0
- package/dist/native/platform-motion.d.ts.map +1 -0
- package/dist/native/platform-motion.js +90 -0
- package/dist/native/platform-motion.js.map +1 -0
- package/dist/native/surface-effects.d.ts +4 -0
- package/dist/native/surface-effects.d.ts.map +1 -0
- package/dist/native/surface-effects.js +31 -0
- package/dist/native/surface-effects.js.map +1 -0
- package/dist/native/visual-effects.d.ts +5 -0
- package/dist/native/visual-effects.d.ts.map +1 -0
- package/dist/native/visual-effects.js +126 -0
- package/dist/native/visual-effects.js.map +1 -0
- package/dist/vue/components/LoadingDecoration.d.ts +116 -0
- package/dist/vue/components/LoadingDecoration.d.ts.map +1 -0
- package/dist/vue/components/LoadingDecoration.js +34 -0
- package/dist/vue/components/LoadingDecoration.js.map +1 -0
- package/dist/vue/components/MAlert.d.ts +1 -1
- package/dist/vue/components/MAvatar.d.ts +1 -1
- package/dist/vue/components/MButton.d.ts +32 -10
- package/dist/vue/components/MButton.d.ts.map +1 -1
- package/dist/vue/components/MButton.js +29 -2
- package/dist/vue/components/MButton.js.map +1 -1
- package/dist/vue/components/MCard.d.ts +4 -4
- package/dist/vue/components/MChip.d.ts +1 -1
- package/dist/vue/components/MCombobox.d.ts +2 -2
- package/dist/vue/components/MDialog.d.ts +3 -0
- package/dist/vue/components/MDialog.d.ts.map +1 -1
- package/dist/vue/components/MEmptyState.d.ts +1 -1
- package/dist/vue/components/MIcon.d.ts +18 -0
- package/dist/vue/components/MIcon.d.ts.map +1 -1
- package/dist/vue/components/MIcon.js +13 -2
- package/dist/vue/components/MIcon.js.map +1 -1
- package/dist/vue/components/MImage.d.ts +12 -1
- package/dist/vue/components/MImage.d.ts.map +1 -1
- package/dist/vue/components/MImage.js +58 -3
- package/dist/vue/components/MImage.js.map +1 -1
- package/dist/vue/components/MInput.d.ts +4 -4
- package/dist/vue/components/MLink.d.ts +2 -2
- package/dist/vue/components/MListItem.d.ts +1 -1
- package/dist/vue/components/MReveal.d.ts +9 -9
- package/dist/vue/components/MScreen.d.ts +11 -1
- package/dist/vue/components/MScreen.d.ts.map +1 -1
- package/dist/vue/components/MScreen.js +26 -4
- package/dist/vue/components/MScreen.js.map +1 -1
- package/dist/vue/components/MSelect.d.ts +1 -1
- package/dist/vue/components/MSheet.d.ts +4 -4
- package/dist/vue/components/MSkeleton.d.ts +12 -1
- package/dist/vue/components/MSkeleton.d.ts.map +1 -1
- package/dist/vue/components/MSkeleton.js +5 -3
- package/dist/vue/components/MSkeleton.js.map +1 -1
- package/dist/vue/components/MStack.d.ts +9 -9
- package/dist/vue/components/MText.d.ts +11 -0
- package/dist/vue/components/MText.d.ts.map +1 -1
- package/dist/vue/components/MText.js +3 -1
- package/dist/vue/components/MText.js.map +1 -1
- package/dist/vue/components/layout.d.ts +30 -19
- package/dist/vue/components/layout.d.ts.map +1 -1
- package/dist/vue/components/layout.js +3 -1
- package/dist/vue/components/layout.js.map +1 -1
- package/dist/vue/use-motion-surface.d.ts +1 -1
- package/dist/vue/use-motion-surface.d.ts.map +1 -1
- package/dist/vue/use-motion-surface.js +31 -2
- package/dist/vue/use-motion-surface.js.map +1 -1
- package/package.json +3 -3
- package/src/native/collection-motion.ts +166 -0
- package/src/native/image-effects.ts +71 -0
- package/src/native/motion-region.ts +7 -2
- package/src/native/motion-surface.ts +51 -2
- package/src/native/platform-motion.ts +103 -0
- package/src/native/surface-effects.ts +33 -0
- package/src/native/visual-effects.ts +147 -0
- package/src/vue/components/LoadingDecoration.ts +38 -0
- package/src/vue/components/MButton.ts +33 -2
- package/src/vue/components/MIcon.ts +14 -2
- package/src/vue/components/MImage.ts +66 -2
- package/src/vue/components/MScreen.ts +31 -3
- package/src/vue/components/MSkeleton.ts +5 -3
- package/src/vue/components/MText.ts +7 -0
- package/src/vue/components/layout.ts +3 -0
- package/src/vue/use-motion-surface.ts +32 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EventData } from '@nativescript/core';
|
|
2
2
|
import { type MotionSurface } from '@getcortexlabs/mavis-core/experimental';
|
|
3
|
-
export declare function useMotionSurface(surface: () => MotionSurface | undefined, enabled?: () => boolean): {
|
|
3
|
+
export declare function useMotionSurface(surface: () => MotionSurface | undefined, enabled?: () => boolean, plainText?: () => boolean, afterLayout?: boolean): {
|
|
4
4
|
allowsActivation: () => boolean;
|
|
5
5
|
onLoaded(event: EventData): void;
|
|
6
6
|
onUnloaded: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-motion-surface.d.ts","sourceRoot":"","sources":["../../src/vue/use-motion-surface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAQ,MAAM,oBAAoB,CAAA;AAGzD,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,wCAAwC,CAAA;AAI/C,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,aAAa,GAAG,SAAS,EACxC,OAAO,GAAE,MAAM,OAAoB;;
|
|
1
|
+
{"version":3,"file":"use-motion-surface.d.ts","sourceRoot":"","sources":["../../src/vue/use-motion-surface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAQ,MAAM,oBAAoB,CAAA;AAGzD,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,wCAAwC,CAAA;AAI/C,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,aAAa,GAAG,SAAS,EACxC,OAAO,GAAE,MAAM,OAAoB,EACnC,SAAS,GAAE,MAAM,OAAqB,EACtC,WAAW,UAAQ;;oBA6FD,SAAS;;EAM5B"}
|
|
@@ -3,12 +3,18 @@ import { animate, set, onReducedMotion } from '@rafaelaugusto/jolt';
|
|
|
3
3
|
import { bindMotionSurface, } from '@getcortexlabs/mavis-core/experimental';
|
|
4
4
|
import { nativeContinuousSurface } from '../native/motion-surface.js';
|
|
5
5
|
import { nativeMotionOwner } from '../native/motion-owner.js';
|
|
6
|
-
export function useMotionSurface(surface, enabled = () => true) {
|
|
6
|
+
export function useMotionSurface(surface, enabled = () => true, plainText = () => false, afterLayout = false) {
|
|
7
7
|
let view;
|
|
8
8
|
let unbind;
|
|
9
9
|
let offPreference;
|
|
10
10
|
let continuous;
|
|
11
11
|
const active = new Map();
|
|
12
|
+
let layoutView;
|
|
13
|
+
let layoutQueued = false;
|
|
14
|
+
const clearLayout = () => {
|
|
15
|
+
layoutView?.off('layoutChanged', laidOut);
|
|
16
|
+
layoutView = undefined;
|
|
17
|
+
};
|
|
12
18
|
const release = () => {
|
|
13
19
|
unbind?.();
|
|
14
20
|
unbind = undefined;
|
|
@@ -25,7 +31,19 @@ export function useMotionSurface(surface, enabled = () => true) {
|
|
|
25
31
|
const reference = surface();
|
|
26
32
|
if (!target || !reference)
|
|
27
33
|
return;
|
|
28
|
-
|
|
34
|
+
if (afterLayout &&
|
|
35
|
+
(!target.isLayoutValid ||
|
|
36
|
+
target.getActualSize().width <= 0 ||
|
|
37
|
+
target.getActualSize().height <= 0)) {
|
|
38
|
+
if (layoutView !== target) {
|
|
39
|
+
clearLayout();
|
|
40
|
+
layoutView = target;
|
|
41
|
+
target.on('layoutChanged', laidOut);
|
|
42
|
+
}
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
clearLayout();
|
|
46
|
+
continuous = nativeContinuousSurface(target, enabled, plainText);
|
|
29
47
|
unbind = bindMotionSurface(reference, nativeMotionOwner({
|
|
30
48
|
...continuous.adapter,
|
|
31
49
|
animate(values, options) {
|
|
@@ -57,7 +75,18 @@ export function useMotionSurface(surface, enabled = () => true) {
|
|
|
57
75
|
set(target, values);
|
|
58
76
|
});
|
|
59
77
|
};
|
|
78
|
+
const laidOut = () => {
|
|
79
|
+
if (layoutQueued)
|
|
80
|
+
return;
|
|
81
|
+
layoutQueued = true;
|
|
82
|
+
void Promise.resolve().then(() => {
|
|
83
|
+
layoutQueued = false;
|
|
84
|
+
if (view)
|
|
85
|
+
bind();
|
|
86
|
+
});
|
|
87
|
+
};
|
|
60
88
|
const unloaded = () => {
|
|
89
|
+
clearLayout();
|
|
61
90
|
release();
|
|
62
91
|
view = undefined;
|
|
63
92
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-motion-surface.js","sourceRoot":"","sources":["../../src/vue/use-motion-surface.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACnE,OAAO,EACL,iBAAiB,GAGlB,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAE7D,MAAM,UAAU,gBAAgB,CAC9B,OAAwC,EACxC,UAAyB,GAAG,EAAE,CAAC,IAAI;
|
|
1
|
+
{"version":3,"file":"use-motion-surface.js","sourceRoot":"","sources":["../../src/vue/use-motion-surface.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,kBA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,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;IACvC,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;IAC9D,eAAe,CAAC,QAAQ,CAAC,CAAA;IACzB,OAAO;QACL,gBAAgB,EAAE,GAAG,EAAE,CAAC,UAAU,EAAE,gBAAgB,EAAE,IAAI,IAAI;QAC9D,QAAQ,CAAC,KAAgB;YACvB,IAAI,GAAG,KAAK,CAAC,MAAc,CAAA;YAC3B,IAAI,EAAE,CAAA;QACR,CAAC;QACD,UAAU,EAAE,QAAQ;KACrB,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getcortexlabs/mavis",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.8",
|
|
4
4
|
"description": "Mavis UI foundations for NativeScript, with a Vue integration.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"@nativescript/core": "^9.1.3",
|
|
35
|
-
"@rafaelaugusto/jolt": "^0.1.0-rc.
|
|
35
|
+
"@rafaelaugusto/jolt": "^0.1.0-rc.10",
|
|
36
36
|
"nativescript-vue": "^3.1.3"
|
|
37
37
|
},
|
|
38
38
|
"peerDependenciesMeta": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@getcortexlabs/mavis-core": "0.1.0-alpha.
|
|
44
|
+
"@getcortexlabs/mavis-core": "0.1.0-alpha.8"
|
|
45
45
|
},
|
|
46
46
|
"nativescript": {
|
|
47
47
|
"platforms": {
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { LayoutBase, isIOS, type View } from '@nativescript/core'
|
|
2
|
+
import { scrollHeader, type MotionScope } from '@rafaelaugusto/jolt'
|
|
3
|
+
import { reorder, type Reorder } from '@rafaelaugusto/jolt/reorder'
|
|
4
|
+
import {
|
|
5
|
+
mapMotionItems,
|
|
6
|
+
type MotionRegionAdapter,
|
|
7
|
+
type MotionSurfaceAdapter,
|
|
8
|
+
} from '@getcortexlabs/mavis-core/experimental'
|
|
9
|
+
import { nativeScrollElement } from './scroll-motion.js'
|
|
10
|
+
|
|
11
|
+
const headerInsets = new WeakMap<LayoutBase, { previous: boolean; owners: number }>()
|
|
12
|
+
function retainHeaderLayout(header: LayoutBase) {
|
|
13
|
+
if (!isIOS) return () => {}
|
|
14
|
+
const state = headerInsets.get(header) ?? { previous: header.iosIgnoreSafeArea, owners: 0 }
|
|
15
|
+
state.owners++
|
|
16
|
+
headerInsets.set(header, state)
|
|
17
|
+
header.iosIgnoreSafeArea = true
|
|
18
|
+
let released = false
|
|
19
|
+
return () => {
|
|
20
|
+
if (released) return
|
|
21
|
+
released = true
|
|
22
|
+
if (--state.owners) return
|
|
23
|
+
headerInsets.delete(header)
|
|
24
|
+
if (header.iosIgnoreSafeArea === true) header.iosIgnoreSafeArea = state.previous
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function nativeCollectionMotion(
|
|
29
|
+
target: View,
|
|
30
|
+
resolve: (surface: MotionSurfaceAdapter) => View,
|
|
31
|
+
scope: MotionScope,
|
|
32
|
+
): Pick<MotionRegionAdapter, 'scrollHeader' | 'reorder'> {
|
|
33
|
+
return {
|
|
34
|
+
scrollHeader(source, options) {
|
|
35
|
+
const {
|
|
36
|
+
header,
|
|
37
|
+
artwork,
|
|
38
|
+
title,
|
|
39
|
+
toolbar,
|
|
40
|
+
toolbarTitle,
|
|
41
|
+
section,
|
|
42
|
+
items,
|
|
43
|
+
expanded,
|
|
44
|
+
minimum,
|
|
45
|
+
...rest
|
|
46
|
+
} = options
|
|
47
|
+
const headerView = resolve(header)
|
|
48
|
+
if (!(headerView instanceof LayoutBase))
|
|
49
|
+
throw new TypeError('Use a layout surface for the header.')
|
|
50
|
+
const artworkView = resolve(artwork)
|
|
51
|
+
// The moving header already sits inside MScreen's safe area. Reapplying
|
|
52
|
+
// UIKit's changing insets to its children would shift them during reflow.
|
|
53
|
+
const restoreHeader = retainHeaderLayout(headerView)
|
|
54
|
+
let headerControl: ReturnType<typeof scrollHeader>
|
|
55
|
+
try {
|
|
56
|
+
headerControl = scrollHeader(nativeScrollElement(source), {
|
|
57
|
+
...rest,
|
|
58
|
+
header: headerView,
|
|
59
|
+
artwork: artworkView,
|
|
60
|
+
title: resolve(title),
|
|
61
|
+
toolbar: resolve(toolbar),
|
|
62
|
+
toolbarTitle: resolve(toolbarTitle),
|
|
63
|
+
section: resolve(section),
|
|
64
|
+
expandedHeight: expanded,
|
|
65
|
+
minimumHeight: minimum,
|
|
66
|
+
items: () => mapMotionItems(items(), resolve),
|
|
67
|
+
})
|
|
68
|
+
} catch (error) {
|
|
69
|
+
restoreHeader()
|
|
70
|
+
throw error
|
|
71
|
+
}
|
|
72
|
+
const control = headerControl
|
|
73
|
+
let released = false
|
|
74
|
+
const lifetime = scope.add({
|
|
75
|
+
dispose() {
|
|
76
|
+
if (released) return
|
|
77
|
+
released = true
|
|
78
|
+
try {
|
|
79
|
+
control.dispose()
|
|
80
|
+
} finally {
|
|
81
|
+
restoreHeader()
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
})
|
|
85
|
+
return {
|
|
86
|
+
get ready() {
|
|
87
|
+
return control.ready
|
|
88
|
+
},
|
|
89
|
+
get state() {
|
|
90
|
+
return {
|
|
91
|
+
offset: control.state.offset,
|
|
92
|
+
refreshing: control.state.refresh === 'refreshing',
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
refresh: () => control.refresh(),
|
|
96
|
+
cancelRefresh: () => control.cancelRefresh(),
|
|
97
|
+
remeasure: () => control.remeasure(),
|
|
98
|
+
preserveAnchor: (change) => control.preserveAnchor(change),
|
|
99
|
+
scrollToItem(key, animated = true) {
|
|
100
|
+
const index = items().findIndex((item) => item.key === key)
|
|
101
|
+
if (index < 0) return false
|
|
102
|
+
control.scrollToItem(index, animated)
|
|
103
|
+
return true
|
|
104
|
+
},
|
|
105
|
+
scrollToTop: (animated = true) => control.scrollToTop(animated),
|
|
106
|
+
pause: () => control.pause(),
|
|
107
|
+
play: () => control.play(),
|
|
108
|
+
dispose: () => lifetime.dispose(),
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
reorder(options) {
|
|
112
|
+
const { container, items, scroll, accessibility, ...rest } = options
|
|
113
|
+
const layout = resolve(container)
|
|
114
|
+
if (!(layout instanceof LayoutBase))
|
|
115
|
+
throw new TypeError('Use a layout motion surface for retained rows.')
|
|
116
|
+
let control: Reorder<string> | undefined
|
|
117
|
+
let disposed = false,
|
|
118
|
+
paused = false,
|
|
119
|
+
queued = false
|
|
120
|
+
const attach = () => {
|
|
121
|
+
if (disposed || control) return
|
|
122
|
+
layout.off('layoutChanged', laidOut)
|
|
123
|
+
control = reorder(layout, {
|
|
124
|
+
...rest,
|
|
125
|
+
scroll: nativeScrollElement(scroll),
|
|
126
|
+
items: () => mapMotionItems(items(), resolve),
|
|
127
|
+
accessibility: { moveUp: accessibility?.moveUp, moveDown: accessibility?.moveDown },
|
|
128
|
+
})
|
|
129
|
+
if (paused) control.pause()
|
|
130
|
+
}
|
|
131
|
+
// `loaded` precedes native layout. Wait for that lifecycle boundary once;
|
|
132
|
+
// Jolt owns subsequent geometry updates, gestures and animation scheduling.
|
|
133
|
+
const laidOut = () => {
|
|
134
|
+
if (queued) return
|
|
135
|
+
queued = true
|
|
136
|
+
void Promise.resolve().then(attach)
|
|
137
|
+
}
|
|
138
|
+
if (layout.isLayoutValid && layout.getActualSize().height > 0) attach()
|
|
139
|
+
else layout.on('layoutChanged', laidOut)
|
|
140
|
+
return scope.add({
|
|
141
|
+
get activeKey() {
|
|
142
|
+
return control?.activeKey
|
|
143
|
+
},
|
|
144
|
+
move: (key: string, before: string | null) => control?.move(key, before) ?? false,
|
|
145
|
+
moveUp: (key: string) => control?.moveUp(key) ?? false,
|
|
146
|
+
moveDown: (key: string) => control?.moveDown(key) ?? false,
|
|
147
|
+
refresh: () => control?.refresh(),
|
|
148
|
+
cancel: () => control?.cancel(),
|
|
149
|
+
pause() {
|
|
150
|
+
paused = true
|
|
151
|
+
control?.pause()
|
|
152
|
+
},
|
|
153
|
+
play() {
|
|
154
|
+
paused = false
|
|
155
|
+
control?.play()
|
|
156
|
+
},
|
|
157
|
+
dispose() {
|
|
158
|
+
disposed = true
|
|
159
|
+
layout.off('layoutChanged', laidOut)
|
|
160
|
+
control?.dispose()
|
|
161
|
+
control = undefined
|
|
162
|
+
},
|
|
163
|
+
})
|
|
164
|
+
},
|
|
165
|
+
}
|
|
166
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Image, type View } from '@nativescript/core'
|
|
2
|
+
import { imageEffect } from '@rafaelaugusto/jolt'
|
|
3
|
+
import type {
|
|
4
|
+
MotionImageEffectName,
|
|
5
|
+
MotionImageEffectOptions,
|
|
6
|
+
MotionPlayback,
|
|
7
|
+
} from '@getcortexlabs/mavis-core/experimental'
|
|
8
|
+
import { loadAvatarImage } from './avatar-image.js'
|
|
9
|
+
|
|
10
|
+
type Presentation = {
|
|
11
|
+
current(): boolean
|
|
12
|
+
commit(src: string, image: Image['imageSource']): Promise<boolean>
|
|
13
|
+
}
|
|
14
|
+
const images = new WeakMap<Image, Presentation>()
|
|
15
|
+
const preparations = new WeakMap<Image, object>()
|
|
16
|
+
export function registerMotionImage(target: Image, presentation: Presentation) {
|
|
17
|
+
images.set(target, presentation)
|
|
18
|
+
return () => {
|
|
19
|
+
if (images.get(target) === presentation) images.delete(target)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function loadedMotionImage(target: View): Image {
|
|
23
|
+
if (!(target instanceof Image) || !images.has(target) || !target.imageSource)
|
|
24
|
+
throw new TypeError('Use the ready motionSurface of MImage for pixel effects.')
|
|
25
|
+
return target
|
|
26
|
+
}
|
|
27
|
+
export async function nativeImageEffect(
|
|
28
|
+
target: View,
|
|
29
|
+
name: MotionImageEffectName,
|
|
30
|
+
options: MotionImageEffectOptions = {},
|
|
31
|
+
live: () => boolean = () => true,
|
|
32
|
+
) {
|
|
33
|
+
const image = loadedMotionImage(target),
|
|
34
|
+
presentation = images.get(image)!
|
|
35
|
+
const { to, ...rest } = options
|
|
36
|
+
if (to !== undefined && (name !== 'dissolve' || !to.trim()))
|
|
37
|
+
throw new TypeError('Only dissolve accepts a nonempty destination source.')
|
|
38
|
+
const preparation = {}
|
|
39
|
+
preparations.set(image, preparation)
|
|
40
|
+
const destination = to === undefined ? undefined : await loadAvatarImage(to)
|
|
41
|
+
if (to !== undefined && !destination) throw new Error('Destination image could not be decoded.')
|
|
42
|
+
if (
|
|
43
|
+
!live() ||
|
|
44
|
+
preparations.get(image) !== preparation ||
|
|
45
|
+
!presentation.current() ||
|
|
46
|
+
images.get(image) !== presentation ||
|
|
47
|
+
!image.isLoaded
|
|
48
|
+
)
|
|
49
|
+
throw new Error('Image presentation changed while preparing the effect.')
|
|
50
|
+
const previous = image.imageSource
|
|
51
|
+
const raw = imageEffect(image, name, { ...rest, ...(destination ? { to: destination } : {}) })
|
|
52
|
+
const finished = raw.finished.then(async (success) => {
|
|
53
|
+
if (!success || !to || raw.progress !== 1) return success
|
|
54
|
+
if (!presentation.current() || images.get(image) !== presentation) return false
|
|
55
|
+
if (!live()) {
|
|
56
|
+
if (image.imageSource === destination) image.imageSource = previous
|
|
57
|
+
return false
|
|
58
|
+
}
|
|
59
|
+
return presentation.commit(to, destination!)
|
|
60
|
+
})
|
|
61
|
+
return new Proxy(raw as MotionPlayback, {
|
|
62
|
+
get(target, key) {
|
|
63
|
+
// Native animations are thenable; returning one from an async factory would await completion.
|
|
64
|
+
if (key === 'then') return undefined
|
|
65
|
+
if (key === 'finished') return finished
|
|
66
|
+
const value = Reflect.get(target, key, target)
|
|
67
|
+
return typeof value === 'function' ? value.bind(target) : value
|
|
68
|
+
},
|
|
69
|
+
set: (target, key, value) => Reflect.set(target, key, value, target),
|
|
70
|
+
})
|
|
71
|
+
}
|
|
@@ -8,6 +8,8 @@ import {
|
|
|
8
8
|
type MotionSurfaceAdapter,
|
|
9
9
|
} from '@getcortexlabs/mavis-core/experimental'
|
|
10
10
|
import { nativeScrollElement } from './scroll-motion.js'
|
|
11
|
+
import { nativeCollectionMotion } from './collection-motion.js'
|
|
12
|
+
import { nativePlatformMotion } from './platform-motion.js'
|
|
11
13
|
|
|
12
14
|
const targets = new WeakMap<MotionSurfaceAdapter, View>()
|
|
13
15
|
const regions = new WeakMap<MotionRegionAdapter, View>()
|
|
@@ -103,8 +105,9 @@ function viewportEnter(
|
|
|
103
105
|
if (!visible) stop(state)
|
|
104
106
|
if (visible && !state.visible && !state.animation) {
|
|
105
107
|
const animation = animate(state.target, options.frames ?? { opacity: [0, 1], y: [20, 0] }, {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
...(options.transition?.type === 'gravity'
|
|
109
|
+
? options.transition
|
|
110
|
+
: { duration: 450, ...options.transition }),
|
|
108
111
|
delay: (options.transition?.delay ?? 0) + state.index * (options.stagger ?? 70),
|
|
109
112
|
})
|
|
110
113
|
state.animation = animation
|
|
@@ -190,6 +193,8 @@ export function attachNativeMotionRegion(reference: MotionRegion, target: View)
|
|
|
190
193
|
: ([resolveChild(step[0]), step[1], step[2]] as const),
|
|
191
194
|
)
|
|
192
195
|
const adapter: MotionRegionAdapter = {
|
|
196
|
+
...nativePlatformMotion(target, resolveChild, scope),
|
|
197
|
+
...nativeCollectionMotion(target, resolveChild, scope),
|
|
193
198
|
sequence: (items) =>
|
|
194
199
|
scope.sequence(steps(items) as unknown as Parameters<typeof scope.sequence>[0]),
|
|
195
200
|
timeline: (items) =>
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { nativeScrollMotion } from './scroll-motion.js'
|
|
2
2
|
import { assertNativeRegion } from './motion-region.js'
|
|
3
|
+
import { nativeVisualEffects } from './visual-effects.js'
|
|
4
|
+
import { sensor } from '@rafaelaugusto/jolt/sensors'
|
|
3
5
|
import type { View, EventData, TouchGestureEventData } from '@nativescript/core'
|
|
4
6
|
import {
|
|
5
7
|
animate,
|
|
@@ -18,7 +20,11 @@ import type {
|
|
|
18
20
|
MotionValueAdapter,
|
|
19
21
|
} from '@getcortexlabs/mavis-core/experimental'
|
|
20
22
|
|
|
21
|
-
export function nativeContinuousSurface(
|
|
23
|
+
export function nativeContinuousSurface(
|
|
24
|
+
target: View,
|
|
25
|
+
enabled: () => boolean,
|
|
26
|
+
plainText: () => boolean = () => false,
|
|
27
|
+
) {
|
|
22
28
|
const sources = new WeakMap<object, DerivedValue>()
|
|
23
29
|
const colorSources = new WeakMap<object, import('@rafaelaugusto/jolt').DerivedColor>()
|
|
24
30
|
const refreshes = new Set<() => void>()
|
|
@@ -42,7 +48,50 @@ export function nativeContinuousSurface(target: View, enabled: () => boolean) {
|
|
|
42
48
|
| 'refresh'
|
|
43
49
|
| 'scrollLinked'
|
|
44
50
|
| 'pointerFollow'
|
|
45
|
-
|
|
51
|
+
| 'sensor'
|
|
52
|
+
> &
|
|
53
|
+
import('@getcortexlabs/mavis-core/experimental').MotionVisualAdapter = {
|
|
54
|
+
...nativeVisualEffects(target, sources, colorSources, plainText),
|
|
55
|
+
sensor(kind, options) {
|
|
56
|
+
const input = sensor(kind, options)
|
|
57
|
+
const wrap = (source: DerivedValue) => {
|
|
58
|
+
const value = { get: () => source.get(), dispose() {} }
|
|
59
|
+
sources.set(value, source)
|
|
60
|
+
return value
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
kind,
|
|
64
|
+
x: wrap(input.x),
|
|
65
|
+
y: wrap(input.y),
|
|
66
|
+
z: wrap(input.z),
|
|
67
|
+
quaternion:
|
|
68
|
+
input.kind === 'rotation'
|
|
69
|
+
? {
|
|
70
|
+
x: wrap(input.quaternion.x),
|
|
71
|
+
y: wrap(input.quaternion.y),
|
|
72
|
+
z: wrap(input.quaternion.z),
|
|
73
|
+
w: wrap(input.quaternion.w),
|
|
74
|
+
}
|
|
75
|
+
: undefined,
|
|
76
|
+
get status() {
|
|
77
|
+
return input.status
|
|
78
|
+
},
|
|
79
|
+
get available() {
|
|
80
|
+
return input.available
|
|
81
|
+
},
|
|
82
|
+
get paused() {
|
|
83
|
+
return input.paused
|
|
84
|
+
},
|
|
85
|
+
pause: () => input.pause(),
|
|
86
|
+
resume: () => input.play(),
|
|
87
|
+
recenter: () => {
|
|
88
|
+
if (input.kind === 'rotation') input.recenter()
|
|
89
|
+
},
|
|
90
|
+
requestPermission: async () => 'not-required' as const,
|
|
91
|
+
snapshot: () => ({ ...input.snapshot(), backend: 'native' as const }),
|
|
92
|
+
dispose: () => input.dispose(),
|
|
93
|
+
}
|
|
94
|
+
},
|
|
46
95
|
pointerFollow(region, options) {
|
|
47
96
|
assertNativeRegion(region, target)
|
|
48
97
|
const x = adapter.motionValue!(options.rest?.x ?? 0)
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { View } from '@nativescript/core'
|
|
2
|
+
import { onKeyboard, type MotionScope } from '@rafaelaugusto/jolt'
|
|
3
|
+
import { physicsWorld } from '@rafaelaugusto/jolt/physics'
|
|
4
|
+
import type {
|
|
5
|
+
MotionRegionAdapter,
|
|
6
|
+
MotionSurfaceAdapter,
|
|
7
|
+
MotionKeyboardState,
|
|
8
|
+
} from '@getcortexlabs/mavis-core/experimental'
|
|
9
|
+
|
|
10
|
+
function afterLayout(targets: readonly View[], scope: MotionScope): Promise<void> {
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
let settled = false,
|
|
13
|
+
release: (() => void) | undefined
|
|
14
|
+
const clear = () => {
|
|
15
|
+
settled = true
|
|
16
|
+
for (const target of targets) {
|
|
17
|
+
target.off('layoutChanged', changed)
|
|
18
|
+
target.off('unloaded', unloaded)
|
|
19
|
+
}
|
|
20
|
+
release?.()
|
|
21
|
+
}
|
|
22
|
+
const check = () => {
|
|
23
|
+
if (settled) return
|
|
24
|
+
if (
|
|
25
|
+
targets.every(
|
|
26
|
+
(target) =>
|
|
27
|
+
target.isLoaded &&
|
|
28
|
+
target.isLayoutValid &&
|
|
29
|
+
target.getActualSize().width > 0 &&
|
|
30
|
+
target.getActualSize().height > 0,
|
|
31
|
+
)
|
|
32
|
+
) {
|
|
33
|
+
clear()
|
|
34
|
+
resolve()
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const changed = () => {
|
|
38
|
+
void Promise.resolve().then(check)
|
|
39
|
+
}
|
|
40
|
+
const unloaded = () => {
|
|
41
|
+
if (settled) return
|
|
42
|
+
clear()
|
|
43
|
+
reject(new Error('Physics presentation released before layout.'))
|
|
44
|
+
}
|
|
45
|
+
if (scope.disposed || scope.suspended) {
|
|
46
|
+
unloaded()
|
|
47
|
+
return
|
|
48
|
+
}
|
|
49
|
+
for (const target of targets) {
|
|
50
|
+
target.on('layoutChanged', changed)
|
|
51
|
+
target.on('unloaded', unloaded)
|
|
52
|
+
}
|
|
53
|
+
release = scope.use(() => unloaded)
|
|
54
|
+
check()
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
export function nativePlatformMotion(
|
|
58
|
+
target: View,
|
|
59
|
+
resolve: (surface: MotionSurfaceAdapter) => View,
|
|
60
|
+
scope: MotionScope,
|
|
61
|
+
): Pick<MotionRegionAdapter, 'onKeyboard' | 'physicsWorld'> {
|
|
62
|
+
return {
|
|
63
|
+
onKeyboard(callback) {
|
|
64
|
+
let state: MotionKeyboardState = {
|
|
65
|
+
visible: false,
|
|
66
|
+
height: 0,
|
|
67
|
+
duration: 0,
|
|
68
|
+
backend: 'native',
|
|
69
|
+
accuracy: 'unavailable',
|
|
70
|
+
}
|
|
71
|
+
const read = () => state
|
|
72
|
+
const release = scope.use(() => {
|
|
73
|
+
const off = onKeyboard((value) => {
|
|
74
|
+
state = { ...value, backend: 'native', accuracy: 'native' }
|
|
75
|
+
callback(state)
|
|
76
|
+
})
|
|
77
|
+
callback(read())
|
|
78
|
+
return off
|
|
79
|
+
})
|
|
80
|
+
return { snapshot: read, dispose: release }
|
|
81
|
+
},
|
|
82
|
+
async physicsWorld(bodies, options) {
|
|
83
|
+
const mapped = bodies.map(({ target, ...body }) => ({ ...body, view: resolve(target) }))
|
|
84
|
+
await afterLayout([target, ...mapped.map((body) => body.view)], scope)
|
|
85
|
+
if (scope.disposed || scope.suspended) throw new Error('Physics presentation is inactive.')
|
|
86
|
+
const world = physicsWorld(target, mapped, { ...options, scope })
|
|
87
|
+
return {
|
|
88
|
+
get paused() {
|
|
89
|
+
return world.paused
|
|
90
|
+
},
|
|
91
|
+
pause: () => world.pause(),
|
|
92
|
+
resume: () => world.play(),
|
|
93
|
+
reset: () => world.reset(),
|
|
94
|
+
impulse: (id, value) => world.impulse(id, value),
|
|
95
|
+
attach: (id, value) => world.attach(id, value),
|
|
96
|
+
spring: (id, value) => world.spring(id, value),
|
|
97
|
+
snapTo: (id, index) => world.snapTo(id, index),
|
|
98
|
+
snapshot: () => world.snapshot(),
|
|
99
|
+
dispose: () => world.dispose(),
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Image, isIOS, isAndroid, type View } from '@nativescript/core'
|
|
2
|
+
import { particles, confetti, liquid, symbolEffect, followKeyboard } from '@rafaelaugusto/jolt'
|
|
3
|
+
import { blur } from '@rafaelaugusto/jolt/blur'
|
|
4
|
+
import { shape } from '@rafaelaugusto/jolt/shapes'
|
|
5
|
+
import type { MotionSurfaceEffectsAdapter } from '@getcortexlabs/mavis-core/experimental'
|
|
6
|
+
import { loadedMotionImage, nativeImageEffect } from './image-effects.js'
|
|
7
|
+
|
|
8
|
+
export function nativeSurfaceEffects(target: View): MotionSurfaceEffectsAdapter {
|
|
9
|
+
return {
|
|
10
|
+
particles: (options) => ({
|
|
11
|
+
supported: isIOS || isAndroid,
|
|
12
|
+
dispose: particles(target, options),
|
|
13
|
+
}),
|
|
14
|
+
confetti: (options) => ({ supported: isIOS || isAndroid, dispose: confetti(target, options) }),
|
|
15
|
+
blur: (options) => blur(target, options),
|
|
16
|
+
shape: (options) => shape(target, options),
|
|
17
|
+
liquid(options) {
|
|
18
|
+
const effect = liquid(loadedMotionImage(target), options)
|
|
19
|
+
return {
|
|
20
|
+
supported: isIOS,
|
|
21
|
+
pause: () => effect.pause(),
|
|
22
|
+
resume: () => effect.resume(),
|
|
23
|
+
dispose: () => effect.stop(),
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
imageEffect: (name, options, live) => nativeImageEffect(target, name, options, live),
|
|
27
|
+
symbolEffect: (name, options) =>
|
|
28
|
+
target instanceof Image
|
|
29
|
+
? symbolEffect(target, name, options)
|
|
30
|
+
: { finished: Promise.resolve(false), stop() {} },
|
|
31
|
+
followKeyboard: (options) => ({ dispose: followKeyboard(target, options) }),
|
|
32
|
+
}
|
|
33
|
+
}
|