@tamagui/animations-moti 1.114.4 → 1.115.1

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,191 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf,
6
+ __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: !0
28
+ }) : target, mod)),
29
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
+ value: !0
31
+ }), mod);
32
+ var createAnimations_exports = {};
33
+ __export(createAnimations_exports, {
34
+ createAnimations: () => createAnimations
35
+ });
36
+ module.exports = __toCommonJS(createAnimations_exports);
37
+ var import_react = __toESM(require("react")),
38
+ import_use_presence = require("@tamagui/use-presence"),
39
+ import_author = require("moti/author"),
40
+ import_react_native_reanimated = __toESM(require("react-native-reanimated"));
41
+ const onlyAnimateKeys = {
42
+ transform: !0,
43
+ opacity: !0,
44
+ height: !0,
45
+ width: !0,
46
+ backgroundColor: !0,
47
+ borderColor: !0,
48
+ borderLeftColor: !0,
49
+ borderRightColor: !0,
50
+ borderTopColor: !0,
51
+ borderBottomColor: !0,
52
+ borderRadius: !0,
53
+ borderTopLeftRadius: !0,
54
+ borderTopRightRadius: !0,
55
+ borderBottomLeftRadius: !0,
56
+ borderBottomRightRadius: !0,
57
+ borderLeftWidth: !0,
58
+ borderRightWidth: !0,
59
+ borderTopWidth: !0,
60
+ borderBottomWidth: !0,
61
+ color: !0,
62
+ left: !0,
63
+ right: !0,
64
+ top: !0,
65
+ bottom: !0,
66
+ fontSize: !0,
67
+ fontWeight: !0,
68
+ lineHeight: !0,
69
+ letterSpacing: !0
70
+ };
71
+ function createAnimations(animations) {
72
+ return {
73
+ // View: isWeb ? AnimatedView : Animated.View,
74
+ // Text: isWeb ? AnimatedText : Animated.Text,
75
+ View: import_react_native_reanimated.default.View,
76
+ Text: import_react_native_reanimated.default.Text,
77
+ isReactNative: !0,
78
+ animations,
79
+ usePresence: import_use_presence.usePresence,
80
+ ResetPresence: import_use_presence.ResetPresence,
81
+ useAnimatedNumber(initial) {
82
+ const sharedValue = (0, import_react_native_reanimated.useSharedValue)(initial);
83
+ return import_react.default.useMemo(() => ({
84
+ getInstance() {
85
+ "worklet";
86
+
87
+ return sharedValue;
88
+ },
89
+ getValue() {
90
+ "worklet";
91
+
92
+ return sharedValue.value;
93
+ },
94
+ setValue(next, config = {
95
+ type: "spring"
96
+ }, onFinish) {
97
+ "worklet";
98
+
99
+ config.type === "direct" ? (sharedValue.value = next, onFinish?.()) : config.type === "spring" ? sharedValue.value = (0, import_react_native_reanimated.withSpring)(next, config, onFinish ? () => {
100
+ "worklet";
101
+
102
+ (0, import_react_native_reanimated.runOnJS)(onFinish)();
103
+ } : void 0) : sharedValue.value = (0, import_react_native_reanimated.withTiming)(next, config, onFinish ? () => {
104
+ "worklet";
105
+
106
+ (0, import_react_native_reanimated.runOnJS)(onFinish)();
107
+ } : void 0);
108
+ },
109
+ stop() {
110
+ "worklet";
111
+
112
+ (0, import_react_native_reanimated.cancelAnimation)(sharedValue);
113
+ }
114
+ }), [sharedValue]);
115
+ },
116
+ useAnimatedNumberReaction({
117
+ value
118
+ }, onValue) {
119
+ const instance = value.getInstance();
120
+ return (0, import_react_native_reanimated.useAnimatedReaction)(() => instance.value, (next, prev) => {
121
+ prev !== next && (0, import_react_native_reanimated.runOnJS)(onValue)(next);
122
+ },
123
+ // dependency array is very important here
124
+ [onValue, instance]);
125
+ },
126
+ /**
127
+ * `getStyle` must be a worklet
128
+ */
129
+ useAnimatedNumberStyle(val, getStyle) {
130
+ const instance = val.getInstance(),
131
+ derivedValue = (0, import_react_native_reanimated.useDerivedValue)(() => instance.value, [instance, getStyle]);
132
+ return (0, import_react_native_reanimated.useAnimatedStyle)(() => getStyle(derivedValue.value), [val, getStyle, derivedValue, instance]);
133
+ },
134
+ useAnimations: animationProps => {
135
+ const {
136
+ props,
137
+ presence,
138
+ style,
139
+ componentState
140
+ } = animationProps,
141
+ animationKey = Array.isArray(props.animation) ? props.animation[0] : props.animation,
142
+ isHydrating = componentState.unmounted === !0,
143
+ disableAnimation = isHydrating || !animationKey;
144
+ let animate = {},
145
+ dontAnimate = {};
146
+ if (disableAnimation) dontAnimate = style;else {
147
+ const animateOnly = props.animateOnly;
148
+ for (const key in style) {
149
+ const value = style[key];
150
+ !onlyAnimateKeys[key] || value === "auto" || typeof value == "string" && value.startsWith("calc") || animateOnly && !animateOnly.includes(key) ? dontAnimate[key] = value : animate[key] = value;
151
+ }
152
+ }
153
+ componentState.unmounted === "should-enter" && (dontAnimate = style);
154
+ const animateStr = JSON.stringify(animate),
155
+ styles = import_react.default.useMemo(() => JSON.parse(animateStr), [animateStr]),
156
+ isExiting = !!presence?.[1],
157
+ presenceContext = import_react.default.useContext(import_use_presence.PresenceContext),
158
+ usePresenceValue = presence || void 0;
159
+ let transition = isHydrating ? {
160
+ type: "transition",
161
+ duration: 0
162
+ } : animations[animationKey],
163
+ hasClonedTransition = !1;
164
+ if (Array.isArray(props.animation)) {
165
+ const config = props.animation[1];
166
+ if (config && typeof config == "object") for (const key in config) {
167
+ const val = config[key];
168
+ hasClonedTransition || (transition = Object.assign({}, transition), hasClonedTransition = !0), typeof val == "string" ? transition[key] = animations[val] : transition[key] = val;
169
+ }
170
+ }
171
+ const motiProps = {
172
+ animate: isExiting || componentState.unmounted === !0 ? {} : styles,
173
+ transition: componentState.unmounted ? {
174
+ duration: 0
175
+ } : transition,
176
+ usePresenceValue,
177
+ presenceContext,
178
+ exit: isExiting ? styles : void 0
179
+ },
180
+ moti = (0, import_author.useMotify)(motiProps);
181
+ return process.env.NODE_ENV === "development" && props.debug && console.info("useMotify(", JSON.stringify(motiProps, null, 2) + ")", {
182
+ animationProps,
183
+ motiProps,
184
+ moti,
185
+ style: [dontAnimate, moti.style]
186
+ }), {
187
+ style: [dontAnimate, moti.style]
188
+ };
189
+ }
190
+ };
191
+ }
@@ -0,0 +1,19 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
7
+ get: () => from[key],
8
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
9
+ });
10
+ return to;
11
+ },
12
+ __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
13
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
14
+ value: !0
15
+ }), mod);
16
+ var src_exports = {};
17
+ module.exports = __toCommonJS(src_exports);
18
+ var import_polyfill = require("./polyfill.cjs");
19
+ __reExport(src_exports, require("./createAnimations.cjs"), module.exports);
@@ -0,0 +1,2 @@
1
+ typeof requestAnimationFrame > "u" && (globalThis.requestAnimationFrame = setTimeout);
2
+ typeof global > "u" && (globalThis.global = globalThis);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/animations-moti",
3
- "version": "1.114.4",
3
+ "version": "1.115.1",
4
4
  "source": "src/index.ts",
5
5
  "license": "MIT",
6
6
  "types": "./types/index.d.ts",
@@ -15,12 +15,12 @@
15
15
  "dist"
16
16
  ],
17
17
  "dependencies": {
18
- "@tamagui/use-presence": "1.114.4",
19
- "@tamagui/web": "1.114.4",
18
+ "@tamagui/use-presence": "1.115.1",
19
+ "@tamagui/web": "1.115.1",
20
20
  "moti": "^0.29.0"
21
21
  },
22
22
  "devDependencies": {
23
- "@tamagui/build": "1.114.4",
23
+ "@tamagui/build": "1.115.1",
24
24
  "react": "^18.2.0 || ^19.0.0",
25
25
  "react-native-reanimated": "~3.11.0"
26
26
  },
@@ -1,166 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
15
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
- // If the importer is in node compatibility mode or this is not an ESM
17
- // file that has been converted to a CommonJS file using a Babel-
18
- // compatible transform (i.e. "__esModule" has not been set), then set
19
- // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
- var createAnimations_exports = {};
24
- __export(createAnimations_exports, {
25
- createAnimations: () => createAnimations
26
- });
27
- module.exports = __toCommonJS(createAnimations_exports);
28
- var import_react = __toESM(require("react")), import_use_presence = require("@tamagui/use-presence"), import_author = require("moti/author"), import_react_native_reanimated = __toESM(require("react-native-reanimated"));
29
- const onlyAnimateKeys = {
30
- transform: !0,
31
- opacity: !0,
32
- height: !0,
33
- width: !0,
34
- backgroundColor: !0,
35
- borderColor: !0,
36
- borderLeftColor: !0,
37
- borderRightColor: !0,
38
- borderTopColor: !0,
39
- borderBottomColor: !0,
40
- borderRadius: !0,
41
- borderTopLeftRadius: !0,
42
- borderTopRightRadius: !0,
43
- borderBottomLeftRadius: !0,
44
- borderBottomRightRadius: !0,
45
- borderLeftWidth: !0,
46
- borderRightWidth: !0,
47
- borderTopWidth: !0,
48
- borderBottomWidth: !0,
49
- color: !0,
50
- left: !0,
51
- right: !0,
52
- top: !0,
53
- bottom: !0,
54
- fontSize: !0,
55
- fontWeight: !0,
56
- lineHeight: !0,
57
- letterSpacing: !0
58
- };
59
- function createAnimations(animations) {
60
- return {
61
- // View: isWeb ? AnimatedView : Animated.View,
62
- // Text: isWeb ? AnimatedText : Animated.Text,
63
- View: import_react_native_reanimated.default.View,
64
- Text: import_react_native_reanimated.default.Text,
65
- isReactNative: !0,
66
- animations,
67
- usePresence: import_use_presence.usePresence,
68
- ResetPresence: import_use_presence.ResetPresence,
69
- useAnimatedNumber(initial) {
70
- const sharedValue = (0, import_react_native_reanimated.useSharedValue)(initial);
71
- return import_react.default.useMemo(
72
- () => ({
73
- getInstance() {
74
- "worklet";
75
- return sharedValue;
76
- },
77
- getValue() {
78
- "worklet";
79
- return sharedValue.value;
80
- },
81
- setValue(next, config = { type: "spring" }, onFinish) {
82
- "worklet";
83
- config.type === "direct" ? (sharedValue.value = next, onFinish?.()) : config.type === "spring" ? sharedValue.value = (0, import_react_native_reanimated.withSpring)(
84
- next,
85
- config,
86
- onFinish ? () => {
87
- "worklet";
88
- (0, import_react_native_reanimated.runOnJS)(onFinish)();
89
- } : void 0
90
- ) : sharedValue.value = (0, import_react_native_reanimated.withTiming)(
91
- next,
92
- config,
93
- onFinish ? () => {
94
- "worklet";
95
- (0, import_react_native_reanimated.runOnJS)(onFinish)();
96
- } : void 0
97
- );
98
- },
99
- stop() {
100
- "worklet";
101
- (0, import_react_native_reanimated.cancelAnimation)(sharedValue);
102
- }
103
- }),
104
- [sharedValue]
105
- );
106
- },
107
- useAnimatedNumberReaction({ value }, onValue) {
108
- const instance = value.getInstance();
109
- return (0, import_react_native_reanimated.useAnimatedReaction)(
110
- () => instance.value,
111
- (next, prev) => {
112
- prev !== next && (0, import_react_native_reanimated.runOnJS)(onValue)(next);
113
- },
114
- // dependency array is very important here
115
- [onValue, instance]
116
- );
117
- },
118
- /**
119
- * `getStyle` must be a worklet
120
- */
121
- useAnimatedNumberStyle(val, getStyle) {
122
- const instance = val.getInstance(), derivedValue = (0, import_react_native_reanimated.useDerivedValue)(() => instance.value, [instance, getStyle]);
123
- return (0, import_react_native_reanimated.useAnimatedStyle)(() => getStyle(derivedValue.value), [val, getStyle, derivedValue, instance]);
124
- },
125
- useAnimations: (animationProps) => {
126
- const { props, presence, style, componentState } = animationProps, animationKey = Array.isArray(props.animation) ? props.animation[0] : props.animation, isHydrating = componentState.unmounted === !0, disableAnimation = isHydrating || !animationKey;
127
- let animate = {}, dontAnimate = {};
128
- if (disableAnimation)
129
- dontAnimate = style;
130
- else {
131
- const animateOnly = props.animateOnly;
132
- for (const key in style) {
133
- const value = style[key];
134
- !onlyAnimateKeys[key] || value === "auto" || typeof value == "string" && value.startsWith("calc") || animateOnly && !animateOnly.includes(key) ? dontAnimate[key] = value : animate[key] = value;
135
- }
136
- }
137
- componentState.unmounted === "should-enter" && (dontAnimate = style);
138
- const animateStr = JSON.stringify(animate), styles = import_react.default.useMemo(() => JSON.parse(animateStr), [animateStr]), isExiting = !!presence?.[1], presenceContext = import_react.default.useContext(import_use_presence.PresenceContext), usePresenceValue = presence || void 0;
139
- let transition = isHydrating ? { type: "transition", duration: 0 } : animations[animationKey], hasClonedTransition = !1;
140
- if (Array.isArray(props.animation)) {
141
- const config = props.animation[1];
142
- if (config && typeof config == "object")
143
- for (const key in config) {
144
- const val = config[key];
145
- hasClonedTransition || (transition = Object.assign({}, transition), hasClonedTransition = !0), typeof val == "string" ? transition[key] = animations[val] : transition[key] = val;
146
- }
147
- }
148
- const motiProps = {
149
- animate: isExiting || componentState.unmounted === !0 ? {} : styles,
150
- transition: componentState.unmounted ? { duration: 0 } : transition,
151
- usePresenceValue,
152
- presenceContext,
153
- exit: isExiting ? styles : void 0
154
- }, moti = (0, import_author.useMotify)(motiProps);
155
- return process.env.NODE_ENV === "development" && props.debug && console.info("useMotify(", JSON.stringify(motiProps, null, 2) + ")", {
156
- animationProps,
157
- motiProps,
158
- moti,
159
- style: [dontAnimate, moti.style]
160
- }), {
161
- style: [dontAnimate, moti.style]
162
- };
163
- }
164
- };
165
- }
166
- //# sourceMappingURL=createAnimations.js.map
package/dist/cjs/index.js DELETED
@@ -1,16 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from == "object" || typeof from == "function")
7
- for (let key of __getOwnPropNames(from))
8
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
- return to;
10
- }, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
11
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
12
- var src_exports = {};
13
- module.exports = __toCommonJS(src_exports);
14
- var import_polyfill = require("./polyfill");
15
- __reExport(src_exports, require("./createAnimations"), module.exports);
16
- //# sourceMappingURL=index.js.map
@@ -1,3 +0,0 @@
1
- typeof requestAnimationFrame > "u" && (globalThis.requestAnimationFrame = setTimeout);
2
- typeof global > "u" && (globalThis.global = globalThis);
3
- //# sourceMappingURL=polyfill.js.map
File without changes
File without changes