@symbiote-native/vue 3.0.4 → 3.1.0
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.
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type VNode } from '@vue/runtime-core';
|
|
2
|
+
export interface ITransitionProps {
|
|
3
|
+
duration?: number;
|
|
4
|
+
appear?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const Transition: import("vue").DefineComponent<{
|
|
7
|
+
duration: number;
|
|
8
|
+
appear: boolean;
|
|
9
|
+
}, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
|
|
12
|
+
duration: number;
|
|
13
|
+
appear: boolean;
|
|
14
|
+
}> & Readonly<{}>, {
|
|
15
|
+
duration: number;
|
|
16
|
+
appear: boolean;
|
|
17
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
18
|
+
export declare const TransitionGroup: import("vue").DefineComponent<{
|
|
19
|
+
duration: number;
|
|
20
|
+
appear: boolean;
|
|
21
|
+
}, () => VNode, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
|
|
22
|
+
duration: number;
|
|
23
|
+
appear: boolean;
|
|
24
|
+
}> & Readonly<{}>, {
|
|
25
|
+
duration: number;
|
|
26
|
+
appear: boolean;
|
|
27
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Vue's own <Transition>/<TransitionGroup> live in @vue/runtime-dom (CSS class
|
|
2
|
+
// toggling), unreachable through this adapter's runtime-core-only "vue" import.
|
|
3
|
+
// Wires BaseTransition's (runtime-core) enter/leave hooks to Animated instead.
|
|
4
|
+
import { BaseTransition, defineComponent, Fragment, getCurrentInstance, getTransitionRawChildren, h, resolveTransitionHooks, setTransitionHooks, useTransitionState, } from '@vue/runtime-core';
|
|
5
|
+
import { AnimatedValue, isSymbioteNode, propOf, requestCommitFor, routeProp, timing, } from '@symbiote-native/engine';
|
|
6
|
+
const DEFAULT_DURATION_MS = 300;
|
|
7
|
+
const opacityOf = new WeakMap();
|
|
8
|
+
// routeProp, not setProp/setNativeProps: an AnimatedNode is only recognized and kept
|
|
9
|
+
// subscribed to per-frame updates through routeProp's own resolution
|
|
10
|
+
// (core/engine/src/animated/host-binding.ts).
|
|
11
|
+
function animatedOpacity(el, initial) {
|
|
12
|
+
const value = new AnimatedValue(initial);
|
|
13
|
+
opacityOf.set(el, value);
|
|
14
|
+
const style = propOf(el, 'style');
|
|
15
|
+
routeProp(el, 'style', {
|
|
16
|
+
...(typeof style === 'object' && style !== null ? style : {}),
|
|
17
|
+
opacity: value,
|
|
18
|
+
});
|
|
19
|
+
requestCommitFor(el);
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
function fadeTo(el, toValue, duration, done) {
|
|
23
|
+
const value = opacityOf.get(el) ?? animatedOpacity(el, toValue === 1 ? 0 : 1);
|
|
24
|
+
timing(value, { toValue, duration }).start(({ finished }) => {
|
|
25
|
+
if (finished)
|
|
26
|
+
done();
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
// This project's native equivalent of Vue's CSS transition classes. Named per-`name`
|
|
30
|
+
// enter/leave effects are not implemented (see the gap-list for that decision).
|
|
31
|
+
function fadeHooks(duration) {
|
|
32
|
+
return {
|
|
33
|
+
onBeforeEnter: el => {
|
|
34
|
+
if (isSymbioteNode(el))
|
|
35
|
+
animatedOpacity(el, 0);
|
|
36
|
+
},
|
|
37
|
+
onEnter: (el, done) => {
|
|
38
|
+
if (isSymbioteNode(el))
|
|
39
|
+
fadeTo(el, 1, duration, done);
|
|
40
|
+
else
|
|
41
|
+
done();
|
|
42
|
+
},
|
|
43
|
+
onLeave: (el, done) => {
|
|
44
|
+
if (isSymbioteNode(el))
|
|
45
|
+
fadeTo(el, 0, duration, done);
|
|
46
|
+
else
|
|
47
|
+
done();
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export const Transition = defineComponent({
|
|
52
|
+
name: 'Transition',
|
|
53
|
+
props: {
|
|
54
|
+
duration: { type: Number, default: DEFAULT_DURATION_MS },
|
|
55
|
+
appear: { type: Boolean, default: false },
|
|
56
|
+
},
|
|
57
|
+
setup(props, { slots }) {
|
|
58
|
+
return () => h(BaseTransition, { appear: props.appear, ...fadeHooks(props.duration) }, slots);
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
// The move/reorder FLIP animation Vue's own TransitionGroup does over
|
|
62
|
+
// offsetLeft/offsetTop is DOM-measurement-specific and not implemented here.
|
|
63
|
+
export const TransitionGroup = defineComponent({
|
|
64
|
+
name: 'TransitionGroup',
|
|
65
|
+
props: {
|
|
66
|
+
duration: { type: Number, default: DEFAULT_DURATION_MS },
|
|
67
|
+
appear: { type: Boolean, default: false },
|
|
68
|
+
},
|
|
69
|
+
setup(props, { slots }) {
|
|
70
|
+
const instance = getCurrentInstance();
|
|
71
|
+
const state = useTransitionState();
|
|
72
|
+
return () => {
|
|
73
|
+
const children = slots.default
|
|
74
|
+
? getTransitionRawChildren(slots.default())
|
|
75
|
+
: [];
|
|
76
|
+
for (const child of children) {
|
|
77
|
+
if (child.key == null || !instance)
|
|
78
|
+
continue;
|
|
79
|
+
setTransitionHooks(child, resolveTransitionHooks(child, { appear: props.appear, ...fadeHooks(props.duration) }, state, instance));
|
|
80
|
+
}
|
|
81
|
+
return h(Fragment, null, children);
|
|
82
|
+
};
|
|
83
|
+
},
|
|
84
|
+
});
|
package/build/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { mount, unmount, setAppConfigurator } from './render';
|
|
|
4
4
|
export type { IAppConfigurator } from './render';
|
|
5
5
|
export { Teleport, type ITeleportTarget } from './create-portal';
|
|
6
6
|
export { createTunnel, type ITunnel } from './create-tunnel';
|
|
7
|
+
export { Transition, TransitionGroup, type ITransitionProps, } from './create-transition';
|
|
7
8
|
export type { IViewProps } from './components/view-props';
|
|
8
9
|
export type { ITextProps } from './components/text-props';
|
|
9
10
|
export type { ISymbioteIntrinsicTag, ISymbioteHostAttributes, } from './intrinsic-elements';
|
package/build/index.js
CHANGED
|
@@ -36,6 +36,10 @@ export { mount, unmount, setAppConfigurator } from './render.js';
|
|
|
36
36
|
// into an <Out/> the destination has to render. See create-portal/index.ts.
|
|
37
37
|
export { Teleport } from './create-portal/index.js';
|
|
38
38
|
export { createTunnel } from './create-tunnel/index.js';
|
|
39
|
+
// Vue's own Transition/TransitionGroup are runtime-dom-only (CSS class toggling) and
|
|
40
|
+
// would otherwise come from the wildcard above as unusable DOM stubs. These fade over
|
|
41
|
+
// the engine's Animated graph instead. See create-transition/index.ts.
|
|
42
|
+
export { Transition, TransitionGroup, } from './create-transition/index.js';
|
|
39
43
|
// IHostInstance is the raw engine node (Vue host refs fall through to it; imperative methods
|
|
40
44
|
// live on each component's expose() handle).
|
|
41
45
|
export { findNodeHandle } from './host-instance/index.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from '@vue/runtime-core';
|
|
2
|
+
export { Transition, TransitionGroup } from '../create-transition';
|
|
2
3
|
import { type ObjectDirective } from '@vue/runtime-core';
|
|
3
4
|
import { type ISymbioteNode } from '@symbiote-native/engine';
|
|
4
5
|
export declare function normalizeProps(props: Record<string, unknown> | null | undefined): Record<string, unknown> | null;
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
// Scope: Vue's own template directives (v-show, Teleport) and `v-model` on an ELEMENT — see
|
|
10
10
|
// vModelText below for why that is in scope.
|
|
11
11
|
export * from '@vue/runtime-core';
|
|
12
|
+
export { Transition, TransitionGroup } from '../create-transition/index.js';
|
|
12
13
|
import { getCurrentInstance, mergeProps as baseMergeProps, normalizeClass, normalizeStyle as baseNormalizeStyle, warn, } from '@vue/runtime-core';
|
|
13
14
|
import { componentOf, propOf, requestCommitFor, setNativeProps, setProp, whenCommitted, } from '@symbiote-native/engine';
|
|
14
15
|
import { descriptorFor, SWITCH_TAG } from '@symbiote-native/components';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbiote-native/vue",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "SymbioteNative's Vue adapter — a @vue/runtime-core createRenderer driving real native iOS/Android views through the same engine as the React adapter.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -70,18 +70,18 @@
|
|
|
70
70
|
"@vue/compiler-sfc": "^3.5.13",
|
|
71
71
|
"@vue/runtime-core": "^3.5.13",
|
|
72
72
|
"typescript": "~6.0.0",
|
|
73
|
-
"@symbiote-native/components": "3.1.
|
|
73
|
+
"@symbiote-native/components": "3.1.3",
|
|
74
74
|
"@symbiote-native/css-parser": "0.5.2"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"vue": ">=3.5.0",
|
|
78
78
|
"react-native": ">=0.86",
|
|
79
|
-
"@symbiote-native/engine": "^1.
|
|
79
|
+
"@symbiote-native/engine": "^1.4.0"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@babel/core": "^7.25.2",
|
|
83
|
-
"@symbiote-native/engine": "1.
|
|
84
|
-
"@symbiote-native/test-utils": "0.4.
|
|
83
|
+
"@symbiote-native/engine": "1.4.0",
|
|
84
|
+
"@symbiote-native/test-utils": "0.4.5"
|
|
85
85
|
},
|
|
86
86
|
"scripts": {
|
|
87
87
|
"typecheck": "tsc --build",
|