@tamagui/animations-reanimated 2.7.7 → 3.0.0-beta.643.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.
- package/dist/cjs/createAnimations.cjs +940 -897
- package/dist/cjs/createAnimations.native.cjs +1196 -0
- package/dist/cjs/createAnimations.native.js +1138 -1115
- package/dist/cjs/createAnimations.native.js.map +1 -1
- package/dist/cjs/index.cjs +10 -11
- package/dist/cjs/index.native.cjs +21 -0
- package/dist/cjs/index.native.js +10 -10
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/createAnimations.mjs +926 -873
- package/dist/esm/createAnimations.mjs.map +1 -1
- package/dist/esm/createAnimations.native.js +1125 -1093
- package/dist/esm/createAnimations.native.js.map +1 -1
- package/dist/esm/index.js +1 -2
- package/dist/esm/index.mjs +1 -2
- package/dist/esm/index.native.js +1 -2
- package/package.json +8 -8
- package/src/createAnimations.tsx +264 -89
- package/types/createAnimations.d.ts.map +2 -2
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -5,36 +6,27 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
5
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
8
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
12
13
|
};
|
|
13
14
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
21
22
|
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
-
value: mod,
|
|
29
|
-
enumerable: true
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
30
26
|
}) : target, mod));
|
|
31
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
-
value: true
|
|
33
|
-
}), mod);
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
34
28
|
var createAnimations_exports = {};
|
|
35
|
-
__export(createAnimations_exports, {
|
|
36
|
-
createAnimations: () => createAnimations
|
|
37
|
-
});
|
|
29
|
+
__export(createAnimations_exports, { createAnimations: () => createAnimations });
|
|
38
30
|
module.exports = __toCommonJS(createAnimations_exports);
|
|
39
31
|
var import_animation_helpers = require("@tamagui/animation-helpers");
|
|
40
32
|
var import_core = require("@tamagui/core");
|
|
@@ -43,917 +35,968 @@ var import_normalize_colors = __toESM(require("@react-native/normalize-colors"),
|
|
|
43
35
|
var import_react = __toESM(require("react"), 1);
|
|
44
36
|
var import_react_native_reanimated = __toESM(require("react-native-reanimated"), 1);
|
|
45
37
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
46
|
-
const getDefaultExport = module2 => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
38
|
+
const getDefaultExport = (module2) => {
|
|
39
|
+
const mod = module2;
|
|
40
|
+
if (mod.__esModule || mod[Symbol.toStringTag] === "Module") {
|
|
41
|
+
return mod.default || mod;
|
|
42
|
+
}
|
|
43
|
+
return mod;
|
|
52
44
|
};
|
|
53
45
|
const Animated = getDefaultExport(import_react_native_reanimated.default);
|
|
54
|
-
const silenceAnimatedComponentDevCheck = style => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
46
|
+
const silenceAnimatedComponentDevCheck = (style) => {
|
|
47
|
+
if (process.env.NODE_ENV !== "development" || import_core.isWeb || !style || typeof style !== "object") {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
Object.defineProperty(style, "_requiresAnimatedComponent", {
|
|
51
|
+
configurable: true,
|
|
52
|
+
enumerable: false,
|
|
53
|
+
value: true
|
|
54
|
+
});
|
|
63
55
|
};
|
|
64
56
|
const resolveDynamicValue = (value, isDark) => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
57
|
+
if (value !== null && typeof value === "object" && "dynamic" in value && typeof value.dynamic === "object") {
|
|
58
|
+
const dynamic = value.dynamic;
|
|
59
|
+
return isDark ? dynamic.dark : dynamic.light;
|
|
60
|
+
}
|
|
61
|
+
return value;
|
|
70
62
|
};
|
|
71
63
|
const updateMapperState = import_core.isWeb ? (state, emitted) => {
|
|
72
|
-
|
|
64
|
+
state.value.emitted = emitted;
|
|
73
65
|
} : (state, emitted) => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}, false);
|
|
66
|
+
"worklet";
|
|
67
|
+
if (!globalThis._WORKLET) return;
|
|
68
|
+
state.modify((current) => {
|
|
69
|
+
current.emitted = emitted;
|
|
70
|
+
return current;
|
|
71
|
+
}, false);
|
|
81
72
|
};
|
|
82
|
-
const cloneAnimationValue = value => {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
73
|
+
const cloneAnimationValue = (value) => {
|
|
74
|
+
if (Array.isArray(value)) {
|
|
75
|
+
return value.map(cloneAnimationValue);
|
|
76
|
+
}
|
|
77
|
+
if (value && typeof value === "object") {
|
|
78
|
+
const next = {};
|
|
79
|
+
for (const key in value) {
|
|
80
|
+
next[key] = cloneAnimationValue(value[key]);
|
|
81
|
+
}
|
|
82
|
+
return next;
|
|
83
|
+
}
|
|
84
|
+
return value;
|
|
94
85
|
};
|
|
95
|
-
const cloneStyleRecord = style => {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
86
|
+
const cloneStyleRecord = (style) => {
|
|
87
|
+
const next = {};
|
|
88
|
+
for (const key in style) {
|
|
89
|
+
next[key] = cloneAnimationValue(style[key]);
|
|
90
|
+
}
|
|
91
|
+
return next;
|
|
101
92
|
};
|
|
102
|
-
const cloneTransitionConfig = config => {
|
|
103
|
-
|
|
93
|
+
const cloneTransitionConfig = (config) => {
|
|
94
|
+
return cloneAnimationValue(config);
|
|
104
95
|
};
|
|
105
|
-
const getAnimatedTransforms = value => {
|
|
106
|
-
|
|
107
|
-
|
|
96
|
+
const getAnimatedTransforms = (value) => {
|
|
97
|
+
if (!Array.isArray(value)) return [];
|
|
98
|
+
return value.filter((item) => item !== null && typeof item === "object" && !Array.isArray(item));
|
|
108
99
|
};
|
|
109
100
|
const getRemovedAnimatedKeys = (current, previous) => {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
101
|
+
const removedKeys = {};
|
|
102
|
+
for (const key of previous) {
|
|
103
|
+
if (!current.has(key)) removedKeys[key] = true;
|
|
104
|
+
}
|
|
105
|
+
return removedKeys;
|
|
115
106
|
};
|
|
116
107
|
const getImplicitDefault = (key, targetValue) => {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return suffixIndex > 0 ? `${value}${targetValue.slice(suffixIndex)}` : value;
|
|
108
|
+
"worklet";
|
|
109
|
+
const value = key === "opacity" || key === "scale" || key === "scaleX" || key === "scaleY" ? 1 : 0;
|
|
110
|
+
if (typeof targetValue !== "string") return value;
|
|
111
|
+
let suffixIndex = 0;
|
|
112
|
+
while (suffixIndex < targetValue.length) {
|
|
113
|
+
const character = targetValue[suffixIndex];
|
|
114
|
+
const code = character.charCodeAt(0);
|
|
115
|
+
if (code >= 48 && code <= 57 || character === "." || character === "-" || character === "+") {
|
|
116
|
+
suffixIndex++;
|
|
117
|
+
} else {
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return suffixIndex > 0 ? `${value}${targetValue.slice(suffixIndex)}` : value;
|
|
132
122
|
};
|
|
133
123
|
const COLOR_STYLE_KEYS = {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
124
|
+
backgroundColor: true,
|
|
125
|
+
borderColor: true,
|
|
126
|
+
borderLeftColor: true,
|
|
127
|
+
borderRightColor: true,
|
|
128
|
+
borderTopColor: true,
|
|
129
|
+
borderBottomColor: true,
|
|
130
|
+
color: true
|
|
141
131
|
};
|
|
142
|
-
const toReanimatedColor = value => {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return trimmed;
|
|
132
|
+
const toReanimatedColor = (value) => {
|
|
133
|
+
"worklet";
|
|
134
|
+
if (typeof value === "number") {
|
|
135
|
+
const color = value >>> 0;
|
|
136
|
+
const alpha = (color >>> 24 & 255) / 255;
|
|
137
|
+
const red = color >>> 16 & 255;
|
|
138
|
+
const green = color >>> 8 & 255;
|
|
139
|
+
const blue = color & 255;
|
|
140
|
+
return `rgba(${red}, ${green}, ${blue}, ${alpha})`;
|
|
141
|
+
}
|
|
142
|
+
if (typeof value !== "string") return value;
|
|
143
|
+
const trimmed = value.trim();
|
|
144
|
+
if (trimmed === "transparent") return "rgba(0, 0, 0, 0)";
|
|
145
|
+
return trimmed;
|
|
157
146
|
};
|
|
158
|
-
const isReanimatedColorHistory = value => {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
return typeof normalized === "string" && normalized.startsWith("rgba(");
|
|
147
|
+
const isReanimatedColorHistory = (value) => {
|
|
148
|
+
"worklet";
|
|
149
|
+
const normalized = toReanimatedColor(value);
|
|
150
|
+
return typeof normalized === "string" && normalized.startsWith("rgba(");
|
|
163
151
|
};
|
|
164
|
-
const normalizeAnimationColor = value => {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
152
|
+
const normalizeAnimationColor = (value) => {
|
|
153
|
+
if (typeof value === "number") {
|
|
154
|
+
return toReanimatedColor(value);
|
|
155
|
+
}
|
|
156
|
+
if (typeof value !== "string") return;
|
|
157
|
+
const color = (0, import_normalize_colors.default)(value);
|
|
158
|
+
if (color == null) return;
|
|
159
|
+
const red = Math.round((color & 4278190080) >>> 24);
|
|
160
|
+
const green = Math.round((color & 16711680) >>> 16);
|
|
161
|
+
const blue = Math.round((color & 65280) >>> 8);
|
|
162
|
+
const alpha = (color & 255) / 255;
|
|
163
|
+
return `rgba(${red}, ${green}, ${blue}, ${alpha})`;
|
|
176
164
|
};
|
|
177
165
|
const buildSnapshot = (animated, statics, transforms, previousKeys, lastPainted) => {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
166
|
+
const snapshotAnimated = {};
|
|
167
|
+
const snapshotStatics = cloneStyleRecord(statics);
|
|
168
|
+
for (const key in snapshotStatics) {
|
|
169
|
+
if (!COLOR_STYLE_KEYS[key]) continue;
|
|
170
|
+
const normalized = normalizeAnimationColor(snapshotStatics[key]);
|
|
171
|
+
if (normalized !== void 0) snapshotStatics[key] = normalized;
|
|
172
|
+
}
|
|
173
|
+
for (const key in animated) {
|
|
174
|
+
if (key === "transform") continue;
|
|
175
|
+
const value = animated[key];
|
|
176
|
+
if (COLOR_STYLE_KEYS[key]) {
|
|
177
|
+
const normalized = normalizeAnimationColor(value);
|
|
178
|
+
if (normalized === void 0) {
|
|
179
|
+
snapshotStatics[key] = cloneAnimationValue(value);
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
snapshotAnimated[key] = normalized;
|
|
183
|
+
} else {
|
|
184
|
+
snapshotAnimated[key] = cloneAnimationValue(value);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
const snapshotTransforms = transforms.map(cloneStyleRecord);
|
|
188
|
+
const keys = new Set(Object.keys(snapshotAnimated));
|
|
189
|
+
for (const transform of snapshotTransforms) {
|
|
190
|
+
const key = Object.keys(transform)[0];
|
|
191
|
+
const value = key ? transform[key] : void 0;
|
|
192
|
+
if (key && (typeof value === "number" || typeof value === "string")) {
|
|
193
|
+
keys.add(`transform:${key}`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
const seeds = {};
|
|
197
|
+
for (const key of keys) {
|
|
198
|
+
let value = lastPainted[key];
|
|
199
|
+
if (typeof value !== "number" && typeof value !== "string") continue;
|
|
200
|
+
if (value === "auto" || typeof value === "string" && value.startsWith("calc")) {
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
if (COLOR_STYLE_KEYS[key]) value = normalizeAnimationColor(value);
|
|
204
|
+
if (value !== void 0) seeds[key] = value;
|
|
205
|
+
}
|
|
206
|
+
const gatedKeys = {};
|
|
207
|
+
for (const key of keys) gatedKeys[key] = true;
|
|
208
|
+
const removedKeys = getRemovedAnimatedKeys(keys, previousKeys);
|
|
209
|
+
const painted = {
|
|
210
|
+
...snapshotStatics,
|
|
211
|
+
...snapshotAnimated
|
|
212
|
+
};
|
|
213
|
+
const staticTransforms = getAnimatedTransforms(snapshotStatics.transform);
|
|
214
|
+
delete painted.transform;
|
|
215
|
+
for (const transform of staticTransforms) {
|
|
216
|
+
const key = Object.keys(transform)[0];
|
|
217
|
+
if (key) painted[`transform:${key}`] = transform[key];
|
|
218
|
+
}
|
|
219
|
+
for (const transform of snapshotTransforms) {
|
|
220
|
+
const key = Object.keys(transform)[0];
|
|
221
|
+
if (key) painted[`transform:${key}`] = transform[key];
|
|
222
|
+
}
|
|
223
|
+
return {
|
|
224
|
+
value: {
|
|
225
|
+
animated: snapshotAnimated,
|
|
226
|
+
statics: snapshotStatics,
|
|
227
|
+
transforms: snapshotTransforms,
|
|
228
|
+
gatedKeys,
|
|
229
|
+
seeds,
|
|
230
|
+
removedKeys,
|
|
231
|
+
removeTransform: Object.keys(removedKeys).some((key) => key.startsWith("transform:")),
|
|
232
|
+
clearValue: import_core.isWeb ? "" : null
|
|
233
|
+
},
|
|
234
|
+
painted,
|
|
235
|
+
keys
|
|
236
|
+
};
|
|
249
237
|
};
|
|
250
|
-
const getGatedKeys = snapshot => Object.keys(snapshot.gatedKeys);
|
|
251
|
-
const createReanimatedConfig = config => {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
return next;
|
|
238
|
+
const getGatedKeys = (snapshot) => Object.keys(snapshot.gatedKeys);
|
|
239
|
+
const createReanimatedConfig = (config) => {
|
|
240
|
+
"worklet";
|
|
241
|
+
const next = {};
|
|
242
|
+
const source = config;
|
|
243
|
+
for (const key in source) {
|
|
244
|
+
if (key === "type" || key === "delay") continue;
|
|
245
|
+
const value = source[key];
|
|
246
|
+
if (value !== void 0) {
|
|
247
|
+
next[key] = value;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return next;
|
|
264
251
|
};
|
|
265
252
|
const applyAnimation = (targetValue, config, callback, seedValue, validateStartAsColor = false) => {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
253
|
+
"worklet";
|
|
254
|
+
const delay = config.delay;
|
|
255
|
+
const reanimatedConfig = createReanimatedConfig(config);
|
|
256
|
+
let animatedValue;
|
|
257
|
+
if (config.type === "timing") {
|
|
258
|
+
animatedValue = (0, import_react_native_reanimated.withTiming)(targetValue, reanimatedConfig, callback);
|
|
259
|
+
} else {
|
|
260
|
+
animatedValue = (0, import_react_native_reanimated.withSpring)(targetValue, reanimatedConfig, callback);
|
|
261
|
+
const innerOnFrame = animatedValue.onFrame;
|
|
262
|
+
animatedValue.onFrame = (animation, now) => {
|
|
263
|
+
"worklet";
|
|
264
|
+
return innerOnFrame(animation, now < animation.lastTimestamp ? animation.lastTimestamp : now);
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
if (seedValue !== void 0 || validateStartAsColor) {
|
|
268
|
+
const innerOnStart = animatedValue.onStart;
|
|
269
|
+
animatedValue.onStart = (animation, value, timestamp, previousAnimation) => {
|
|
270
|
+
"worklet";
|
|
271
|
+
const startValue = validateStartAsColor ? isReanimatedColorHistory(value) ? toReanimatedColor(value) : seedValue ?? targetValue : seedValue;
|
|
272
|
+
innerOnStart(animation, startValue, timestamp, previousAnimation);
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
if (delay && delay > 0) {
|
|
276
|
+
animatedValue = (0, import_react_native_reanimated.withDelay)(delay, animatedValue);
|
|
277
|
+
}
|
|
278
|
+
return animatedValue;
|
|
289
279
|
};
|
|
290
|
-
const animateSnapshotValue = (key, implicitKey, targetValue, config, previouslyEmitted, seedValue, gated, currentlyExiting, exitCycleId,
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
280
|
+
const animateSnapshotValue = (key, implicitKey, targetValue, config, previouslyEmitted, seedValue, gated, currentlyExiting, exitCycleId, currentlyCompletingEnter, enterCycleId, currentlyCompletingUpdate, updateCycleId, markExitKeyDone, markEnterKeyDone, markUpdateKeyDone, validateStartAsColor = false) => {
|
|
281
|
+
"worklet";
|
|
282
|
+
const cycleGated = gated && (currentlyExiting || currentlyCompletingEnter || currentlyCompletingUpdate);
|
|
283
|
+
if (!previouslyEmitted && seedValue === void 0 && !cycleGated) {
|
|
284
|
+
return targetValue;
|
|
285
|
+
}
|
|
286
|
+
let callback;
|
|
287
|
+
if (gated && currentlyExiting) {
|
|
288
|
+
callback = (finished) => {
|
|
289
|
+
"worklet";
|
|
290
|
+
(0, import_react_native_reanimated.runOnJS)(markExitKeyDone)(key, exitCycleId, finished ?? false);
|
|
291
|
+
};
|
|
292
|
+
} else if (gated && currentlyCompletingEnter) {
|
|
293
|
+
callback = () => {
|
|
294
|
+
"worklet";
|
|
295
|
+
(0, import_react_native_reanimated.runOnJS)(markEnterKeyDone)(key, enterCycleId);
|
|
296
|
+
};
|
|
297
|
+
} else if (gated && currentlyCompletingUpdate) {
|
|
298
|
+
callback = (finished) => {
|
|
299
|
+
"worklet";
|
|
300
|
+
(0, import_react_native_reanimated.runOnJS)(markUpdateKeyDone)(key, updateCycleId, finished ?? false);
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
return applyAnimation(targetValue, config, callback, previouslyEmitted ? void 0 : seedValue ?? getImplicitDefault(implicitKey, targetValue), validateStartAsColor);
|
|
312
304
|
};
|
|
313
305
|
const ANIMATABLE_PROPERTIES = {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
paddingBottom: true,
|
|
368
|
-
paddingLeft: true,
|
|
369
|
-
paddingRight: true,
|
|
370
|
-
paddingHorizontal: true,
|
|
371
|
-
paddingVertical: true,
|
|
372
|
-
// Flex/Gap
|
|
373
|
-
gap: true,
|
|
374
|
-
rowGap: true,
|
|
375
|
-
columnGap: true,
|
|
376
|
-
flex: true,
|
|
377
|
-
flexGrow: true,
|
|
378
|
-
flexShrink: true
|
|
306
|
+
transform: true,
|
|
307
|
+
opacity: true,
|
|
308
|
+
height: true,
|
|
309
|
+
width: true,
|
|
310
|
+
minWidth: true,
|
|
311
|
+
minHeight: true,
|
|
312
|
+
maxWidth: true,
|
|
313
|
+
maxHeight: true,
|
|
314
|
+
backgroundColor: true,
|
|
315
|
+
borderColor: true,
|
|
316
|
+
borderLeftColor: true,
|
|
317
|
+
borderRightColor: true,
|
|
318
|
+
borderTopColor: true,
|
|
319
|
+
borderBottomColor: true,
|
|
320
|
+
borderRadius: true,
|
|
321
|
+
borderTopLeftRadius: true,
|
|
322
|
+
borderTopRightRadius: true,
|
|
323
|
+
borderBottomLeftRadius: true,
|
|
324
|
+
borderBottomRightRadius: true,
|
|
325
|
+
borderWidth: true,
|
|
326
|
+
borderLeftWidth: true,
|
|
327
|
+
borderRightWidth: true,
|
|
328
|
+
borderTopWidth: true,
|
|
329
|
+
borderBottomWidth: true,
|
|
330
|
+
color: true,
|
|
331
|
+
fontSize: true,
|
|
332
|
+
fontWeight: true,
|
|
333
|
+
lineHeight: true,
|
|
334
|
+
letterSpacing: true,
|
|
335
|
+
left: true,
|
|
336
|
+
right: true,
|
|
337
|
+
top: true,
|
|
338
|
+
bottom: true,
|
|
339
|
+
margin: true,
|
|
340
|
+
marginTop: true,
|
|
341
|
+
marginBottom: true,
|
|
342
|
+
marginLeft: true,
|
|
343
|
+
marginRight: true,
|
|
344
|
+
marginHorizontal: true,
|
|
345
|
+
marginVertical: true,
|
|
346
|
+
padding: true,
|
|
347
|
+
paddingTop: true,
|
|
348
|
+
paddingBottom: true,
|
|
349
|
+
paddingLeft: true,
|
|
350
|
+
paddingRight: true,
|
|
351
|
+
paddingHorizontal: true,
|
|
352
|
+
paddingVertical: true,
|
|
353
|
+
gap: true,
|
|
354
|
+
rowGap: true,
|
|
355
|
+
columnGap: true,
|
|
356
|
+
flex: true,
|
|
357
|
+
flexGrow: true,
|
|
358
|
+
flexShrink: true
|
|
379
359
|
};
|
|
380
360
|
const canAnimateProperty = (key, value, animateOnly) => {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
361
|
+
if (!ANIMATABLE_PROPERTIES[key]) return false;
|
|
362
|
+
if (value === "auto") return false;
|
|
363
|
+
if (typeof value === "string" && value.startsWith("calc")) return false;
|
|
364
|
+
if (animateOnly && !animateOnly.includes(key)) return false;
|
|
365
|
+
return true;
|
|
386
366
|
};
|
|
387
367
|
const splitAnimationStyles = (style, isDark, disableAnimation, animateOnly) => {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
368
|
+
const animated = {};
|
|
369
|
+
const statics = {};
|
|
370
|
+
for (const key in style) {
|
|
371
|
+
const value = resolveDynamicValue(style[key], isDark);
|
|
372
|
+
if (value === void 0) continue;
|
|
373
|
+
if (!disableAnimation && canAnimateProperty(key, value, animateOnly)) {
|
|
374
|
+
animated[key] = cloneAnimationValue(value);
|
|
375
|
+
} else {
|
|
376
|
+
statics[key] = cloneAnimationValue(value);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return {
|
|
380
|
+
animated,
|
|
381
|
+
statics
|
|
382
|
+
};
|
|
403
383
|
};
|
|
404
384
|
function createWebAnimatedComponent(defaultTag) {
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Element, {
|
|
430
|
-
...transformedProps,
|
|
431
|
-
ref: composedRefs
|
|
432
|
-
});
|
|
433
|
-
}));
|
|
434
|
-
Component.acceptRenderProp = true;
|
|
435
|
-
return Component;
|
|
385
|
+
const isText = defaultTag === "span";
|
|
386
|
+
const Component = Animated.createAnimatedComponent((0, import_core.createRefComponent)((propsIn, ref) => {
|
|
387
|
+
const { forwardedRef, render = defaultTag, ...rest } = propsIn;
|
|
388
|
+
const hostRef = (0, import_react.useRef)(null);
|
|
389
|
+
const composedRefs = (0, import_core.useComposedRefs)(forwardedRef, ref, hostRef);
|
|
390
|
+
const stateRef = (0, import_react.useRef)({ get host() {
|
|
391
|
+
return hostRef.current;
|
|
392
|
+
} });
|
|
393
|
+
const [, themeState] = (0, import_core.useThemeWithState)({});
|
|
394
|
+
const result = (0, import_core.getSplitStyles)(rest, isText ? import_core.Text.staticConfig : import_core.View.staticConfig, themeState?.theme ?? {}, themeState?.name ?? "", { unmounted: false }, {
|
|
395
|
+
isAnimated: false,
|
|
396
|
+
noClass: true
|
|
397
|
+
});
|
|
398
|
+
const viewProps = result?.viewProps ?? {};
|
|
399
|
+
const Element = render;
|
|
400
|
+
const transformedProps = import_core.hooks.usePropsTransform?.(render, viewProps, stateRef, false);
|
|
401
|
+
const { nativeID, ...webProps } = transformedProps ?? viewProps;
|
|
402
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Element, {
|
|
403
|
+
...webProps,
|
|
404
|
+
ref: composedRefs
|
|
405
|
+
});
|
|
406
|
+
}));
|
|
407
|
+
Component.acceptRenderProp = true;
|
|
408
|
+
return Component;
|
|
436
409
|
}
|
|
437
410
|
const AnimatedView = createWebAnimatedComponent("div");
|
|
438
411
|
const AnimatedText = createWebAnimatedComponent("span");
|
|
439
412
|
function buildTransitionConfig(transition, animations, animationState, styleKeys) {
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
return {
|
|
482
|
-
baseConfig: base,
|
|
483
|
-
propertyConfigs
|
|
484
|
-
};
|
|
413
|
+
const normalized = (0, import_animation_helpers.normalizeTransition)(transition);
|
|
414
|
+
const effectiveKey = (0, import_animation_helpers.getEffectiveAnimation)(normalized, animationState);
|
|
415
|
+
let base = cloneTransitionConfig(effectiveKey ? animations[effectiveKey] ?? { type: "spring" } : { type: "spring" });
|
|
416
|
+
if (normalized.delay) {
|
|
417
|
+
base = cloneTransitionConfig({
|
|
418
|
+
...base,
|
|
419
|
+
delay: normalized.delay
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
if (normalized.config) {
|
|
423
|
+
base = cloneTransitionConfig({
|
|
424
|
+
...base,
|
|
425
|
+
...normalized.config
|
|
426
|
+
});
|
|
427
|
+
if (base.type !== "timing" && normalized.config.duration !== void 0 && normalized.config.damping === void 0 && normalized.config.stiffness === void 0 && normalized.config.mass === void 0) {
|
|
428
|
+
base = cloneTransitionConfig({
|
|
429
|
+
...base,
|
|
430
|
+
type: "timing"
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
const propertyConfigs = {};
|
|
435
|
+
for (const key of styleKeys) {
|
|
436
|
+
const propAnimation = normalized.properties[key];
|
|
437
|
+
if (typeof propAnimation === "string") {
|
|
438
|
+
propertyConfigs[key] = cloneTransitionConfig(animations[propAnimation] ?? base);
|
|
439
|
+
} else if (propAnimation && typeof propAnimation === "object") {
|
|
440
|
+
const configType = propAnimation.type;
|
|
441
|
+
const baseForProp = configType ? animations[configType] ?? base : base;
|
|
442
|
+
propertyConfigs[key] = cloneTransitionConfig({
|
|
443
|
+
...baseForProp,
|
|
444
|
+
...propAnimation
|
|
445
|
+
});
|
|
446
|
+
} else {
|
|
447
|
+
propertyConfigs[key] = cloneTransitionConfig(base);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
return {
|
|
451
|
+
baseConfig: base,
|
|
452
|
+
propertyConfigs
|
|
453
|
+
};
|
|
485
454
|
}
|
|
486
455
|
function getStyleKeys(style) {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
456
|
+
const keys = new Set(Object.keys(style));
|
|
457
|
+
if (style.transform && Array.isArray(style.transform)) {
|
|
458
|
+
for (const t of style.transform) {
|
|
459
|
+
if (t && typeof t === "object") {
|
|
460
|
+
keys.add(Object.keys(t)[0]);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
return keys;
|
|
496
465
|
}
|
|
497
466
|
function createAnimations(animationsConfig) {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
467
|
+
const animations = {};
|
|
468
|
+
for (const key in animationsConfig) {
|
|
469
|
+
animations[key] = cloneTransitionConfig({
|
|
470
|
+
type: "spring",
|
|
471
|
+
...animationsConfig[key]
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
return {
|
|
475
|
+
needsCustomComponent: true,
|
|
476
|
+
View: import_core.isWeb ? AnimatedView : Animated.View,
|
|
477
|
+
Text: import_core.isWeb ? AnimatedText : Animated.Text,
|
|
478
|
+
isReactNative: true,
|
|
479
|
+
inputStyle: "value",
|
|
480
|
+
outputStyle: "inline",
|
|
481
|
+
avoidReRenders: true,
|
|
482
|
+
animations,
|
|
483
|
+
usePresence: import_use_presence.usePresence,
|
|
484
|
+
ResetPresence: import_use_presence.ResetPresence,
|
|
485
|
+
useAnimatedNumber(initial) {
|
|
486
|
+
const sharedValue = (0, import_react_native_reanimated.useSharedValue)(initial);
|
|
487
|
+
return (0, import_react.useMemo)(() => ({
|
|
488
|
+
getInstance() {
|
|
489
|
+
"worklet";
|
|
490
|
+
return sharedValue;
|
|
491
|
+
},
|
|
492
|
+
getValue() {
|
|
493
|
+
"worklet";
|
|
494
|
+
return sharedValue.value;
|
|
495
|
+
},
|
|
496
|
+
setValue(next, config = { type: "spring" }, onFinish) {
|
|
497
|
+
if (config.type === "direct") {
|
|
498
|
+
sharedValue.value = next;
|
|
499
|
+
onFinish?.();
|
|
500
|
+
} else {
|
|
501
|
+
const cb = onFinish ? (finished) => {
|
|
502
|
+
"worklet";
|
|
503
|
+
if (finished !== false) {
|
|
504
|
+
(0, import_react_native_reanimated.runOnJS)(onFinish)();
|
|
505
|
+
}
|
|
506
|
+
} : void 0;
|
|
507
|
+
const animationConfig = cloneTransitionConfig(config);
|
|
508
|
+
if (import_core.isWeb) {
|
|
509
|
+
sharedValue.value = applyAnimation(next, animationConfig, cb);
|
|
510
|
+
} else {
|
|
511
|
+
(0, import_react_native_reanimated.runOnUI)((targetValue, animationConfig2) => {
|
|
512
|
+
"worklet";
|
|
513
|
+
sharedValue.value = applyAnimation(targetValue, animationConfig2, cb);
|
|
514
|
+
})(next, animationConfig);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
},
|
|
518
|
+
stop() {
|
|
519
|
+
(0, import_react_native_reanimated.cancelAnimation)(sharedValue);
|
|
520
|
+
}
|
|
521
|
+
}), [sharedValue]);
|
|
522
|
+
},
|
|
523
|
+
useAnimatedNumberReaction({ value }, onValue) {
|
|
524
|
+
const instance = value.getInstance();
|
|
525
|
+
return (0, import_react_native_reanimated.useAnimatedReaction)(() => instance.value, (next, prev) => {
|
|
526
|
+
if (prev !== next) {
|
|
527
|
+
(0, import_react_native_reanimated.runOnJS)(onValue)(next);
|
|
528
|
+
}
|
|
529
|
+
}, [onValue, instance]);
|
|
530
|
+
},
|
|
531
|
+
useAnimatedNumberStyle(val, getStyle) {
|
|
532
|
+
const instance = val.getInstance();
|
|
533
|
+
if (import_core.isWeb) {
|
|
534
|
+
return (0, import_react_native_reanimated.useAnimatedStyle)(() => {
|
|
535
|
+
"worklet";
|
|
536
|
+
return getStyle(instance.value);
|
|
537
|
+
}, [instance, getStyle]);
|
|
538
|
+
}
|
|
539
|
+
const styleVal = (0, import_react_native_reanimated.useDerivedValue)(() => {
|
|
540
|
+
"worklet";
|
|
541
|
+
return getStyle(instance.value);
|
|
542
|
+
});
|
|
543
|
+
const animatedStyle = (0, import_react_native_reanimated.useAnimatedStyle)(() => {
|
|
544
|
+
"worklet";
|
|
545
|
+
return styleVal.value;
|
|
546
|
+
});
|
|
547
|
+
silenceAnimatedComponentDevCheck(animatedStyle);
|
|
548
|
+
return animatedStyle;
|
|
549
|
+
},
|
|
550
|
+
useAnimatedNumbersStyle(vals, getStyle) {
|
|
551
|
+
const instances = vals.map((v) => v.getInstance());
|
|
552
|
+
const animatedStyle = (0, import_react_native_reanimated.useAnimatedStyle)(() => {
|
|
553
|
+
"worklet";
|
|
554
|
+
const currentValues = instances.map((inst) => inst.value);
|
|
555
|
+
return getStyle(...currentValues);
|
|
556
|
+
}, import_core.isWeb ? [getStyle, ...instances] : void 0);
|
|
557
|
+
silenceAnimatedComponentDevCheck(animatedStyle);
|
|
558
|
+
return animatedStyle;
|
|
559
|
+
},
|
|
560
|
+
useAnimations(animationProps) {
|
|
561
|
+
const { props, presence, style, componentState, useStyleEmitter, themeName, stateRef, styleState, onTransition } = animationProps;
|
|
562
|
+
const isHydrating = componentState.unmounted === true;
|
|
563
|
+
const isMounting = componentState.unmounted === "should-enter";
|
|
564
|
+
const isEntering = !!componentState.unmounted;
|
|
565
|
+
const isExiting = presence?.[0] === false;
|
|
566
|
+
const wasEnteringRef = (0, import_react.useRef)(isEntering);
|
|
567
|
+
const justFinishedEntering = wasEnteringRef.current && !isEntering;
|
|
568
|
+
import_react.default.useEffect(() => {
|
|
569
|
+
wasEnteringRef.current = isEntering;
|
|
570
|
+
});
|
|
571
|
+
const effectiveTransition = styleState?.effectiveTransition ?? props.transition;
|
|
572
|
+
const normalized = (0, import_animation_helpers.normalizeTransition)(effectiveTransition);
|
|
573
|
+
const animationState = isExiting ? "exit" : isMounting || justFinishedEntering ? "enter" : "default";
|
|
574
|
+
const animationKey = (0, import_animation_helpers.getEffectiveAnimation)(normalized, animationState);
|
|
575
|
+
const disableAnimation = isHydrating || !animationKey;
|
|
576
|
+
const isDark = themeName?.startsWith("dark") || false;
|
|
577
|
+
const sendExitComplete = presence?.[1];
|
|
578
|
+
const onTransitionRef = (0, import_react.useRef)(onTransition);
|
|
579
|
+
onTransitionRef.current = onTransition;
|
|
580
|
+
const emit = (phase, cause, finished) => {
|
|
581
|
+
onTransitionRef.current?.(phase === "end" ? {
|
|
582
|
+
phase,
|
|
583
|
+
cause,
|
|
584
|
+
finished
|
|
585
|
+
} : {
|
|
586
|
+
phase,
|
|
587
|
+
cause
|
|
588
|
+
});
|
|
589
|
+
};
|
|
590
|
+
const enterStartedRef = (0, import_react.useRef)(false);
|
|
591
|
+
const exitStartedRef = (0, import_react.useRef)(false);
|
|
592
|
+
const updateStartedRef = (0, import_react.useRef)(false);
|
|
593
|
+
const isExitingJSRef = (0, import_react.useRef)(false);
|
|
594
|
+
isExitingJSRef.current = isExiting;
|
|
595
|
+
const updateCycleIdRef = (0, import_react.useRef)(0);
|
|
596
|
+
const pendingUpdateKeysRef = (0, import_react.useRef)(/* @__PURE__ */ new Set());
|
|
597
|
+
const updateCompletedRef = (0, import_react.useRef)(false);
|
|
598
|
+
const isCompletingUpdateRef = (0, import_react_native_reanimated.useSharedValue)(false);
|
|
599
|
+
const updateCycleIdShared = (0, import_react_native_reanimated.useSharedValue)(0);
|
|
600
|
+
const markUpdateKeyDone = (0, import_core.useEvent)((key, cycleId, finished) => {
|
|
601
|
+
if (!finished || cycleId !== updateCycleIdRef.current) return;
|
|
602
|
+
if (updateCompletedRef.current) return;
|
|
603
|
+
pendingUpdateKeysRef.current.delete(key);
|
|
604
|
+
if (pendingUpdateKeysRef.current.size === 0) {
|
|
605
|
+
updateCompletedRef.current = true;
|
|
606
|
+
isCompletingUpdateRef.value = false;
|
|
607
|
+
if (updateStartedRef.current) {
|
|
608
|
+
updateStartedRef.current = false;
|
|
609
|
+
emit("end", "update", true);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
});
|
|
613
|
+
const exitCycleIdRef = (0, import_react.useRef)(0);
|
|
614
|
+
const pendingExitKeysRef = (0, import_react.useRef)(/* @__PURE__ */ new Set());
|
|
615
|
+
const exitCompletedRef = (0, import_react.useRef)(false);
|
|
616
|
+
const wasExitingRef = (0, import_react.useRef)(false);
|
|
617
|
+
const justStartedExiting = isExiting && !wasExitingRef.current;
|
|
618
|
+
const justStoppedExiting = !isExiting && wasExitingRef.current;
|
|
619
|
+
const markExitKeyDone = (0, import_core.useEvent)((key, cycleId, finished) => {
|
|
620
|
+
if (cycleId !== exitCycleIdRef.current) return;
|
|
621
|
+
if (exitCompletedRef.current) return;
|
|
622
|
+
pendingExitKeysRef.current.delete(key);
|
|
623
|
+
if (pendingExitKeysRef.current.size === 0) {
|
|
624
|
+
exitCompletedRef.current = true;
|
|
625
|
+
if (exitStartedRef.current) {
|
|
626
|
+
exitStartedRef.current = false;
|
|
627
|
+
emit("end", "exit", true);
|
|
628
|
+
}
|
|
629
|
+
sendExitComplete?.();
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
const enterCycleIdRef = (0, import_react.useRef)(0);
|
|
633
|
+
const pendingEnterKeysRef = (0, import_react.useRef)(/* @__PURE__ */ new Set());
|
|
634
|
+
const enterCompletedRef = (0, import_react.useRef)(false);
|
|
635
|
+
const markEnterKeyDone = (0, import_core.useEvent)((key, cycleId) => {
|
|
636
|
+
if (cycleId !== enterCycleIdRef.current) return;
|
|
637
|
+
if (enterCompletedRef.current) return;
|
|
638
|
+
if (isExitingJSRef.current) return;
|
|
639
|
+
pendingEnterKeysRef.current.delete(key);
|
|
640
|
+
if (pendingEnterKeysRef.current.size === 0) {
|
|
641
|
+
enterCompletedRef.current = true;
|
|
642
|
+
if (enterStartedRef.current) {
|
|
643
|
+
enterStartedRef.current = false;
|
|
644
|
+
emit("end", "enter", true);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
});
|
|
648
|
+
const isExitingRef = (0, import_react_native_reanimated.useSharedValue)(isExiting);
|
|
649
|
+
const exitCycleIdShared = (0, import_react_native_reanimated.useSharedValue)(exitCycleIdRef.current);
|
|
650
|
+
const isCompletingEnterRef = (0, import_react_native_reanimated.useSharedValue)(false);
|
|
651
|
+
const enterCycleIdShared = (0, import_react_native_reanimated.useSharedValue)(enterCycleIdRef.current);
|
|
652
|
+
if (justStartedExiting) {
|
|
653
|
+
exitCycleIdRef.current++;
|
|
654
|
+
exitCompletedRef.current = false;
|
|
655
|
+
pendingExitKeysRef.current.clear();
|
|
656
|
+
enterCycleIdRef.current++;
|
|
657
|
+
pendingEnterKeysRef.current.clear();
|
|
658
|
+
updateCycleIdRef.current++;
|
|
659
|
+
pendingUpdateKeysRef.current.clear();
|
|
660
|
+
updateCompletedRef.current = true;
|
|
661
|
+
}
|
|
662
|
+
if (justStoppedExiting) {
|
|
663
|
+
exitCycleIdRef.current++;
|
|
664
|
+
pendingExitKeysRef.current.clear();
|
|
665
|
+
}
|
|
666
|
+
(0, import_core.useIsomorphicLayoutEffect)(() => {
|
|
667
|
+
isExitingRef.value = isExiting;
|
|
668
|
+
exitCycleIdShared.value = exitCycleIdRef.current;
|
|
669
|
+
isCompletingEnterRef.value = !isExiting && justFinishedEntering && Boolean(onTransitionRef.current);
|
|
670
|
+
enterCycleIdShared.value = enterCycleIdRef.current;
|
|
671
|
+
if (justStartedExiting) {
|
|
672
|
+
isCompletingUpdateRef.value = false;
|
|
673
|
+
updateCycleIdShared.value = updateCycleIdRef.current;
|
|
674
|
+
}
|
|
675
|
+
}, [
|
|
676
|
+
isExiting,
|
|
677
|
+
justFinishedEntering,
|
|
678
|
+
exitCycleIdRef.current,
|
|
679
|
+
enterCycleIdRef.current,
|
|
680
|
+
justStartedExiting
|
|
681
|
+
]);
|
|
682
|
+
(0, import_core.useIsomorphicLayoutEffect)(() => {
|
|
683
|
+
if (justStoppedExiting && exitStartedRef.current && !exitCompletedRef.current) {
|
|
684
|
+
exitStartedRef.current = false;
|
|
685
|
+
emit("end", "exit", false);
|
|
686
|
+
}
|
|
687
|
+
}, [justStoppedExiting]);
|
|
688
|
+
import_react.default.useEffect(() => {
|
|
689
|
+
wasExitingRef.current = isExiting;
|
|
690
|
+
});
|
|
691
|
+
const committedRenderKeysRef = (0, import_react.useRef)(/* @__PURE__ */ new Set());
|
|
692
|
+
const lastPaintedRef = (0, import_react.useRef)({});
|
|
693
|
+
const carryRef = (0, import_react.useRef)({});
|
|
694
|
+
const { animatedStyles, staticStyles, nextCarry } = (0, import_react.useMemo)(() => {
|
|
695
|
+
const animateOnly = props.animateOnly;
|
|
696
|
+
const { animated, statics } = splitAnimationStyles(style, isDark, disableAnimation, animateOnly);
|
|
697
|
+
const nextCarry2 = cloneStyleRecord(carryRef.current);
|
|
698
|
+
for (const key in nextCarry2) {
|
|
699
|
+
if (!(key in animated)) delete nextCarry2[key];
|
|
700
|
+
}
|
|
701
|
+
for (const key in animated) {
|
|
702
|
+
if (!(key in nextCarry2)) {
|
|
703
|
+
nextCarry2[key] = cloneAnimationValue(animated[key]);
|
|
704
|
+
}
|
|
705
|
+
statics[key] = nextCarry2[key];
|
|
706
|
+
}
|
|
707
|
+
return {
|
|
708
|
+
animatedStyles: animated,
|
|
709
|
+
staticStyles: statics,
|
|
710
|
+
nextCarry: nextCarry2
|
|
711
|
+
};
|
|
712
|
+
}, [
|
|
713
|
+
disableAnimation,
|
|
714
|
+
style,
|
|
715
|
+
isDark,
|
|
716
|
+
props.animateOnly
|
|
717
|
+
]);
|
|
718
|
+
const renderSnapshot = (0, import_react.useMemo)(() => buildSnapshot(animatedStyles, staticStyles, getAnimatedTransforms(animatedStyles.transform), committedRenderKeysRef.current, lastPaintedRef.current), [animatedStyles, staticStyles]);
|
|
719
|
+
const renderSnapshotRef = (0, import_react_native_reanimated.useSharedValue)({
|
|
720
|
+
animated: {},
|
|
721
|
+
statics: {},
|
|
722
|
+
transforms: [],
|
|
723
|
+
gatedKeys: {},
|
|
724
|
+
seeds: {},
|
|
725
|
+
removedKeys: {},
|
|
726
|
+
removeTransform: false,
|
|
727
|
+
clearValue: import_core.isWeb ? "" : null
|
|
728
|
+
});
|
|
729
|
+
const emitterSnapshotRef = (0, import_react_native_reanimated.useSharedValue)(null);
|
|
730
|
+
const emitterKeysRef = (0, import_react.useRef)(null);
|
|
731
|
+
(0, import_core.useIsomorphicLayoutEffect)(() => {
|
|
732
|
+
carryRef.current = nextCarry;
|
|
733
|
+
committedRenderKeysRef.current = renderSnapshot.keys;
|
|
734
|
+
lastPaintedRef.current = renderSnapshot.painted;
|
|
735
|
+
}, [nextCarry, renderSnapshot]);
|
|
736
|
+
const pseudoActiveRef = (0, import_react.useRef)(false);
|
|
737
|
+
const publishedSnapshotRef = (0, import_react.useRef)(null);
|
|
738
|
+
(0, import_core.useIsomorphicLayoutEffect)(() => {
|
|
739
|
+
const renderChanged = publishedSnapshotRef.current !== renderSnapshot.value;
|
|
740
|
+
const droppingLatch = (isExiting || !pseudoActiveRef.current && publishedSnapshotRef.current !== null && renderChanged) && emitterSnapshotRef.value !== null;
|
|
741
|
+
const emitterKeys = droppingLatch ? emitterKeysRef.current : null;
|
|
742
|
+
if (droppingLatch || renderChanged) {
|
|
743
|
+
const removedKeys = emitterKeys ? {
|
|
744
|
+
...renderSnapshot.value.removedKeys,
|
|
745
|
+
...getRemovedAnimatedKeys(renderSnapshot.keys, emitterKeys)
|
|
746
|
+
} : renderSnapshot.value.removedKeys;
|
|
747
|
+
renderSnapshotRef.value = {
|
|
748
|
+
...renderSnapshot.value,
|
|
749
|
+
removedKeys,
|
|
750
|
+
removeTransform: Object.keys(removedKeys).some((key) => key.startsWith("transform:"))
|
|
751
|
+
};
|
|
752
|
+
publishedSnapshotRef.current = renderSnapshot.value;
|
|
753
|
+
}
|
|
754
|
+
if (droppingLatch) {
|
|
755
|
+
emitterSnapshotRef.value = null;
|
|
756
|
+
emitterKeysRef.current = null;
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
const { baseConfig, propertyConfigs } = (0, import_react.useMemo)(() => {
|
|
760
|
+
if (isHydrating) {
|
|
761
|
+
return {
|
|
762
|
+
baseConfig: {
|
|
763
|
+
type: "timing",
|
|
764
|
+
duration: 0
|
|
765
|
+
},
|
|
766
|
+
propertyConfigs: {}
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
return buildTransitionConfig(effectiveTransition, animations, animationState, getStyleKeys(animatedStyles));
|
|
770
|
+
}, [
|
|
771
|
+
isHydrating,
|
|
772
|
+
effectiveTransition,
|
|
773
|
+
animatedStyles,
|
|
774
|
+
animationState
|
|
775
|
+
]);
|
|
776
|
+
const configRef = (0, import_react_native_reanimated.useSharedValue)({
|
|
777
|
+
baseConfig,
|
|
778
|
+
propertyConfigs,
|
|
779
|
+
disableAnimation,
|
|
780
|
+
isHydrating
|
|
781
|
+
});
|
|
782
|
+
(0, import_core.useIsomorphicLayoutEffect)(() => {
|
|
783
|
+
configRef.value = {
|
|
784
|
+
baseConfig,
|
|
785
|
+
propertyConfigs,
|
|
786
|
+
disableAnimation,
|
|
787
|
+
isHydrating
|
|
788
|
+
};
|
|
789
|
+
}, [
|
|
790
|
+
baseConfig,
|
|
791
|
+
propertyConfigs,
|
|
792
|
+
disableAnimation,
|
|
793
|
+
isHydrating
|
|
794
|
+
]);
|
|
795
|
+
useStyleEmitter?.((nextStyle, effectiveTransition2, pseudoActive) => {
|
|
796
|
+
if (isExitingJSRef.current) return;
|
|
797
|
+
pseudoActiveRef.current = pseudoActive === true;
|
|
798
|
+
const animateOnly = props.animateOnly;
|
|
799
|
+
const transitionToUse = effectiveTransition2 ?? props.transition;
|
|
800
|
+
const { baseConfig: newBase, propertyConfigs: newPropertyConfigs } = buildTransitionConfig(transitionToUse, animations, animationState, getStyleKeys(nextStyle));
|
|
801
|
+
configRef.value = {
|
|
802
|
+
baseConfig: newBase,
|
|
803
|
+
propertyConfigs: newPropertyConfigs,
|
|
804
|
+
disableAnimation: configRef.value.disableAnimation,
|
|
805
|
+
isHydrating: configRef.value.isHydrating
|
|
806
|
+
};
|
|
807
|
+
const previousKeys = emitterKeysRef.current ?? committedRenderKeysRef.current;
|
|
808
|
+
const { animated, statics } = splitAnimationStyles(nextStyle, isDark, configRef.value.disableAnimation, animateOnly);
|
|
809
|
+
const snapshot = buildSnapshot(animated, statics, getAnimatedTransforms(animated.transform), previousKeys, lastPaintedRef.current);
|
|
810
|
+
emitterSnapshotRef.value = snapshot.value;
|
|
811
|
+
emitterKeysRef.current = snapshot.keys;
|
|
812
|
+
lastPaintedRef.current = snapshot.painted;
|
|
813
|
+
if (process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile") {
|
|
814
|
+
console.info("[animations-reanimated] useStyleEmitter update", {
|
|
815
|
+
animated,
|
|
816
|
+
statics,
|
|
817
|
+
transforms: snapshot.value.transforms
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
});
|
|
821
|
+
const exitKeysRegistered = (0, import_react.useRef)(false);
|
|
822
|
+
const enterKeysRegistered = (0, import_react.useRef)(false);
|
|
823
|
+
if (!isExiting && justFinishedEntering && onTransition) {
|
|
824
|
+
const enterKeys = getGatedKeys(renderSnapshot.value);
|
|
825
|
+
enterCycleIdRef.current++;
|
|
826
|
+
enterCompletedRef.current = false;
|
|
827
|
+
pendingEnterKeysRef.current = new Set(enterKeys);
|
|
828
|
+
enterKeysRegistered.current = enterKeys.length > 0;
|
|
829
|
+
}
|
|
830
|
+
if (justStartedExiting && sendExitComplete) {
|
|
831
|
+
const exitKeys = getGatedKeys(renderSnapshot.value);
|
|
832
|
+
pendingExitKeysRef.current = new Set(exitKeys);
|
|
833
|
+
exitKeysRegistered.current = exitKeys.length > 0;
|
|
834
|
+
}
|
|
835
|
+
const previousUpdateStyleRef = (0, import_react.useRef)(null);
|
|
836
|
+
const updateStyle = onTransition ? JSON.stringify(style) : null;
|
|
837
|
+
const previousUpdateStyle = previousUpdateStyleRef.current;
|
|
838
|
+
const shouldRegisterUpdate = updateStyle !== null && previousUpdateStyle !== null && previousUpdateStyle !== updateStyle && !isExiting && !isEntering && !justFinishedEntering;
|
|
839
|
+
const updateKeys = shouldRegisterUpdate ? getGatedKeys(renderSnapshot.value) : [];
|
|
840
|
+
(0, import_core.useIsomorphicLayoutEffect)(() => {
|
|
841
|
+
if (updateStyle === null) {
|
|
842
|
+
previousUpdateStyleRef.current = null;
|
|
843
|
+
isCompletingUpdateRef.value = false;
|
|
844
|
+
return;
|
|
845
|
+
}
|
|
846
|
+
const previousStyleStillCurrent = previousUpdateStyleRef.current === previousUpdateStyle;
|
|
847
|
+
previousUpdateStyleRef.current = updateStyle;
|
|
848
|
+
if (!shouldRegisterUpdate || !previousStyleStillCurrent) return;
|
|
849
|
+
const cycleId = ++updateCycleIdRef.current;
|
|
850
|
+
pendingUpdateKeysRef.current = new Set(updateKeys);
|
|
851
|
+
updateCompletedRef.current = updateKeys.length === 0;
|
|
852
|
+
isCompletingUpdateRef.value = updateKeys.length > 0;
|
|
853
|
+
updateCycleIdShared.value = cycleId;
|
|
854
|
+
if (updateStartedRef.current) {
|
|
855
|
+
emit("end", "update", false);
|
|
856
|
+
}
|
|
857
|
+
updateStartedRef.current = true;
|
|
858
|
+
emit("start", "update");
|
|
859
|
+
if (updateKeys.length === 0) {
|
|
860
|
+
updateStartedRef.current = false;
|
|
861
|
+
emit("end", "update", true);
|
|
862
|
+
}
|
|
863
|
+
}, [updateStyle, shouldRegisterUpdate]);
|
|
864
|
+
import_react.default.useEffect(() => {
|
|
865
|
+
if (!justStartedExiting || !sendExitComplete) return;
|
|
866
|
+
if (enterStartedRef.current) {
|
|
867
|
+
enterStartedRef.current = false;
|
|
868
|
+
emit("end", "enter", false);
|
|
869
|
+
}
|
|
870
|
+
if (updateStartedRef.current) {
|
|
871
|
+
updateStartedRef.current = false;
|
|
872
|
+
emit("end", "update", false);
|
|
873
|
+
}
|
|
874
|
+
if (onTransitionRef.current && !exitStartedRef.current) {
|
|
875
|
+
exitStartedRef.current = true;
|
|
876
|
+
emit("start", "exit");
|
|
877
|
+
}
|
|
878
|
+
if (!exitKeysRegistered.current && pendingExitKeysRef.current.size === 0) {
|
|
879
|
+
if (!exitCompletedRef.current) {
|
|
880
|
+
exitCompletedRef.current = true;
|
|
881
|
+
if (exitStartedRef.current) {
|
|
882
|
+
exitStartedRef.current = false;
|
|
883
|
+
emit("end", "exit", true);
|
|
884
|
+
}
|
|
885
|
+
sendExitComplete();
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
}, [justStartedExiting, sendExitComplete]);
|
|
889
|
+
import_react.default.useEffect(() => {
|
|
890
|
+
if (isExiting || !justFinishedEntering || !onTransition) return;
|
|
891
|
+
if (!enterStartedRef.current) {
|
|
892
|
+
enterStartedRef.current = true;
|
|
893
|
+
emit("start", "enter");
|
|
894
|
+
}
|
|
895
|
+
if (!enterKeysRegistered.current && pendingEnterKeysRef.current.size === 0) {
|
|
896
|
+
if (!enterCompletedRef.current) {
|
|
897
|
+
enterCompletedRef.current = true;
|
|
898
|
+
if (enterStartedRef.current) {
|
|
899
|
+
enterStartedRef.current = false;
|
|
900
|
+
emit("end", "enter", true);
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
}, [
|
|
905
|
+
isExiting,
|
|
906
|
+
justFinishedEntering,
|
|
907
|
+
onTransition
|
|
908
|
+
]);
|
|
909
|
+
const mapperStateRef = (0, import_react_native_reanimated.useSharedValue)({ emitted: {} });
|
|
910
|
+
const animatedStyle = (0, import_react_native_reanimated.useAnimatedStyle)(() => {
|
|
911
|
+
"worklet";
|
|
912
|
+
const mapperState = mapperStateRef.value;
|
|
913
|
+
const config = configRef.value;
|
|
914
|
+
if (config.disableAnimation || config.isHydrating) {
|
|
915
|
+
updateMapperState(mapperStateRef, {});
|
|
916
|
+
return {};
|
|
917
|
+
}
|
|
918
|
+
const previouslyEmitted = mapperState.emitted;
|
|
919
|
+
const emitted = {};
|
|
920
|
+
const result = {};
|
|
921
|
+
const emitterSnapshot = emitterSnapshotRef.value;
|
|
922
|
+
const snapshot = emitterSnapshot ?? renderSnapshotRef.value;
|
|
923
|
+
const animatedValues = snapshot.animated;
|
|
924
|
+
const staticValues = snapshot.statics;
|
|
925
|
+
const currentlyExiting = isExitingRef.value;
|
|
926
|
+
const currentCycleId = exitCycleIdShared.value;
|
|
927
|
+
const currentlyCompletingEnter = isCompletingEnterRef.value;
|
|
928
|
+
const currentEnterCycleId = enterCycleIdShared.value;
|
|
929
|
+
const currentlyCompletingUpdate = isCompletingUpdateRef.value;
|
|
930
|
+
const currentUpdateCycleId = updateCycleIdShared.value;
|
|
931
|
+
for (const key in staticValues) {
|
|
932
|
+
result[key] = staticValues[key];
|
|
933
|
+
}
|
|
934
|
+
for (const key in snapshot.removedKeys) {
|
|
935
|
+
if (!key.startsWith("transform:") && !(key in staticValues)) {
|
|
936
|
+
result[key] = snapshot.clearValue;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
for (const key in animatedValues) {
|
|
940
|
+
if (key === "transform") continue;
|
|
941
|
+
const targetValue = animatedValues[key];
|
|
942
|
+
emitted[key] = true;
|
|
943
|
+
if (typeof targetValue !== "number" && typeof targetValue !== "string") {
|
|
944
|
+
result[key] = targetValue;
|
|
945
|
+
continue;
|
|
946
|
+
}
|
|
947
|
+
result[key] = animateSnapshotValue(key, key, targetValue, config.propertyConfigs[key] ?? config.baseConfig, !!previouslyEmitted[key], snapshot.seeds[key], !!snapshot.gatedKeys[key], currentlyExiting, currentCycleId, currentlyCompletingEnter, currentEnterCycleId, currentlyCompletingUpdate, currentUpdateCycleId, markExitKeyDone, markEnterKeyDone, markUpdateKeyDone, !!COLOR_STYLE_KEYS[key]);
|
|
948
|
+
}
|
|
949
|
+
const transforms = snapshot.transforms;
|
|
950
|
+
if (transforms.length > 0 || snapshot.removeTransform) {
|
|
951
|
+
const validTransforms = [];
|
|
952
|
+
for (const t of transforms) {
|
|
953
|
+
if (!t) continue;
|
|
954
|
+
const keys = Object.keys(t);
|
|
955
|
+
if (keys.length === 0) continue;
|
|
956
|
+
const transformKey = keys[0];
|
|
957
|
+
const value = t[transformKey];
|
|
958
|
+
if (typeof value === "number" || typeof value === "string") {
|
|
959
|
+
const propConfig = config.propertyConfigs[transformKey] ?? config.baseConfig;
|
|
960
|
+
const subKey = `transform:${transformKey}`;
|
|
961
|
+
emitted[subKey] = true;
|
|
962
|
+
validTransforms.push({ [transformKey]: animateSnapshotValue(subKey, transformKey, value, propConfig, !!previouslyEmitted[subKey], snapshot.seeds[subKey], !!snapshot.gatedKeys[subKey], currentlyExiting, currentCycleId, currentlyCompletingEnter, currentEnterCycleId, currentlyCompletingUpdate, currentUpdateCycleId, markExitKeyDone, markEnterKeyDone, markUpdateKeyDone) });
|
|
963
|
+
} else {
|
|
964
|
+
validTransforms.push(t);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
if (validTransforms.length > 0 || !("transform" in staticValues)) {
|
|
968
|
+
result.transform = validTransforms;
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
updateMapperState(mapperStateRef, emitted);
|
|
972
|
+
return result;
|
|
973
|
+
}, import_core.isWeb ? [
|
|
974
|
+
renderSnapshotRef,
|
|
975
|
+
emitterSnapshotRef,
|
|
976
|
+
configRef,
|
|
977
|
+
isExitingRef,
|
|
978
|
+
exitCycleIdShared,
|
|
979
|
+
markExitKeyDone,
|
|
980
|
+
isCompletingEnterRef,
|
|
981
|
+
enterCycleIdShared,
|
|
982
|
+
markEnterKeyDone,
|
|
983
|
+
isCompletingUpdateRef,
|
|
984
|
+
updateCycleIdShared,
|
|
985
|
+
markUpdateKeyDone
|
|
986
|
+
] : void 0);
|
|
987
|
+
silenceAnimatedComponentDevCheck(animatedStyle);
|
|
988
|
+
if (process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile") {
|
|
989
|
+
console.info("[animations-reanimated] useAnimations", {
|
|
990
|
+
animationKey,
|
|
991
|
+
componentState,
|
|
992
|
+
isExiting,
|
|
993
|
+
animatedStyles,
|
|
994
|
+
staticStyles,
|
|
995
|
+
baseConfig,
|
|
996
|
+
propertyConfigs
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
return { style: [staticStyles, animatedStyle] };
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
}
|