@tamagui/animation-helpers 2.7.7 → 3.0.0-beta.1097.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/index.cjs +32 -21
- package/dist/cjs/index.native.cjs +46 -0
- package/dist/cjs/index.native.js +33 -21
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/presets.cjs +77 -0
- package/dist/cjs/presets.native.cjs +79 -0
- package/dist/cjs/presets.native.js +81 -0
- package/dist/cjs/presets.native.js.map +1 -0
- package/dist/cjs/propertyNames.cjs +91 -0
- package/dist/cjs/propertyNames.native.cjs +95 -0
- package/dist/cjs/propertyNames.native.js +97 -0
- package/dist/cjs/propertyNames.native.js.map +1 -0
- package/dist/cjs/resolveTransition.cjs +345 -0
- package/dist/cjs/resolveTransition.native.cjs +424 -0
- package/dist/cjs/resolveTransition.native.js +426 -0
- package/dist/cjs/resolveTransition.native.js.map +1 -0
- package/dist/cjs/transitionResolver.cjs +34 -0
- package/dist/cjs/transitionResolver.native.cjs +37 -0
- package/dist/cjs/transitionResolver.native.js +39 -0
- package/dist/cjs/transitionResolver.native.js.map +1 -0
- package/dist/cjs/types.cjs +9 -11
- package/dist/cjs/types.native.cjs +18 -0
- package/dist/cjs/types.native.js +9 -10
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/esm/index.js +6 -3
- package/dist/esm/index.mjs +6 -3
- package/dist/esm/index.native.js +6 -3
- package/dist/esm/presets.mjs +57 -0
- package/dist/esm/presets.mjs.map +1 -0
- package/dist/esm/presets.native.js +57 -0
- package/dist/esm/presets.native.js.map +1 -0
- package/dist/esm/propertyNames.mjs +67 -0
- package/dist/esm/propertyNames.mjs.map +1 -0
- package/dist/esm/propertyNames.native.js +69 -0
- package/dist/esm/propertyNames.native.js.map +1 -0
- package/dist/esm/resolveTransition.mjs +315 -0
- package/dist/esm/resolveTransition.mjs.map +1 -0
- package/dist/esm/resolveTransition.native.js +392 -0
- package/dist/esm/resolveTransition.native.js.map +1 -0
- package/dist/esm/transitionResolver.mjs +11 -0
- package/dist/esm/transitionResolver.mjs.map +1 -0
- package/dist/esm/transitionResolver.native.js +12 -0
- package/dist/esm/transitionResolver.native.js.map +1 -0
- package/dist/esm/types.mjs +0 -2
- package/dist/esm/types.native.js +0 -2
- package/package.json +23 -2
- package/src/index.ts +39 -9
- package/src/presets.ts +40 -0
- package/src/propertyNames.ts +78 -0
- package/src/resolveTransition.ts +503 -0
- package/src/transitionResolver.ts +35 -0
- package/src/types.ts +42 -46
- package/types/index.d.ts +6 -2
- package/types/index.d.ts.map +2 -2
- package/types/presets.d.ts +79 -0
- package/types/presets.d.ts.map +11 -0
- package/types/propertyNames.d.ts +13 -0
- package/types/propertyNames.d.ts.map +11 -0
- package/types/resolveTransition.d.ts +108 -0
- package/types/resolveTransition.d.ts.map +11 -0
- package/types/transitionResolver.d.ts +30 -0
- package/types/transitionResolver.d.ts.map +11 -0
- package/types/types.d.ts +35 -42
- package/types/types.d.ts.map +2 -2
- package/dist/cjs/normalizeTransition.cjs +0 -164
- package/dist/cjs/normalizeTransition.native.js +0 -231
- package/dist/cjs/normalizeTransition.native.js.map +0 -1
- 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
- package/dist/esm/normalizeTransition.mjs +0 -134
- package/dist/esm/normalizeTransition.mjs.map +0 -1
- package/dist/esm/normalizeTransition.native.js +0 -198
- package/dist/esm/normalizeTransition.native.js.map +0 -1
- package/dist/esm/types.mjs.map +0 -1
- package/dist/esm/types.native.js.map +0 -1
- package/src/normalizeTransition.ts +0 -255
- package/types/normalizeTransition.d.ts +0 -54
- package/types/normalizeTransition.d.ts.map +0 -11
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var resolveTransition_exports = {};
|
|
24
|
+
__export(resolveTransition_exports, {
|
|
25
|
+
easingToBezier: () => easingToBezier,
|
|
26
|
+
entryToCSS: () => entryToCSS,
|
|
27
|
+
forAnimationState: () => forAnimationState,
|
|
28
|
+
getMaxDurationMs: () => getMaxDurationMs,
|
|
29
|
+
getSettleMs: () => getSettleMs,
|
|
30
|
+
getTransitionForKey: () => getTransitionForKey,
|
|
31
|
+
hasTransition: () => hasTransition,
|
|
32
|
+
presetToTiming: () => presetToTiming,
|
|
33
|
+
resolveTransition: () => resolveTransition,
|
|
34
|
+
toCSSTransition: () => toCSSTransition
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(resolveTransition_exports);
|
|
37
|
+
var import_transitions = require("@tamagui/style-grammar/transitions");
|
|
38
|
+
var import_propertyNames = require("./propertyNames.native.js");
|
|
39
|
+
var import_transitionResolver = require("./transitionResolver.native.js");
|
|
40
|
+
var emptyResolved = {
|
|
41
|
+
entries: [],
|
|
42
|
+
all: null,
|
|
43
|
+
byProperty: {},
|
|
44
|
+
none: false,
|
|
45
|
+
fused: false,
|
|
46
|
+
enter: null,
|
|
47
|
+
exit: null,
|
|
48
|
+
diagnostics: []
|
|
49
|
+
};
|
|
50
|
+
function forAnimationState(resolved, state) {
|
|
51
|
+
if (state === "enter" && resolved.enter) return resolved.enter;
|
|
52
|
+
if (state === "exit" && resolved.exit) return resolved.exit;
|
|
53
|
+
return resolved;
|
|
54
|
+
}
|
|
55
|
+
function timeToMs(value) {
|
|
56
|
+
return value.endsWith("ms") ? Number.parseFloat(value) : Number.parseFloat(value) * 1e3;
|
|
57
|
+
}
|
|
58
|
+
function springTiming(durationMs, bounce, extra) {
|
|
59
|
+
var mass = typeof (extra === null || extra === void 0 ? void 0 : extra.mass) === "number" ? extra.mass : 1;
|
|
60
|
+
var physics = (0, import_transitions.springFromDurationBounce)({
|
|
61
|
+
duration: durationMs,
|
|
62
|
+
bounce
|
|
63
|
+
}, mass);
|
|
64
|
+
return {
|
|
65
|
+
kind: "spring",
|
|
66
|
+
durationMs,
|
|
67
|
+
bounce,
|
|
68
|
+
stiffness: typeof (extra === null || extra === void 0 ? void 0 : extra.stiffness) === "number" ? extra.stiffness : physics.stiffness,
|
|
69
|
+
damping: typeof (extra === null || extra === void 0 ? void 0 : extra.damping) === "number" ? extra.damping : physics.damping,
|
|
70
|
+
mass,
|
|
71
|
+
extra
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function presetToTiming(preset) {
|
|
75
|
+
if (typeof preset === "string") {
|
|
76
|
+
var parsed = (0, import_transitions.parseTransition)(preset);
|
|
77
|
+
if (!parsed.ok || parsed.value.kind !== "transition") return null;
|
|
78
|
+
var entry = parsed.value.entries[0];
|
|
79
|
+
if (!entry) return null;
|
|
80
|
+
return timingToDriver(entry.timing, null);
|
|
81
|
+
}
|
|
82
|
+
if (!preset || typeof preset !== "object") return null;
|
|
83
|
+
var config = preset;
|
|
84
|
+
var duration = typeof config.duration === "number" ? config.duration : void 0;
|
|
85
|
+
var hasPhysics = typeof config.stiffness === "number" || typeof config.damping === "number";
|
|
86
|
+
var stiffness = typeof config.stiffness === "number" ? config.stiffness : void 0;
|
|
87
|
+
var damping = typeof config.damping === "number" ? config.damping : void 0;
|
|
88
|
+
var isSpring = config.type === "spring" || typeof config.bounce === "number" || hasPhysics;
|
|
89
|
+
if (isSpring) {
|
|
90
|
+
var mass = typeof config.mass === "number" ? config.mass : 1;
|
|
91
|
+
if (stiffness !== void 0) {
|
|
92
|
+
var canonical = (0, import_transitions.springToDurationBounce)({
|
|
93
|
+
stiffness,
|
|
94
|
+
damping: damping !== null && damping !== void 0 ? damping : 2 * Math.sqrt(stiffness * mass),
|
|
95
|
+
mass
|
|
96
|
+
});
|
|
97
|
+
return {
|
|
98
|
+
kind: "spring",
|
|
99
|
+
durationMs: duration !== null && duration !== void 0 ? duration : canonical.duration,
|
|
100
|
+
bounce: typeof config.bounce === "number" ? config.bounce : canonical.bounce,
|
|
101
|
+
stiffness,
|
|
102
|
+
damping: damping !== null && damping !== void 0 ? damping : 2 * Math.sqrt(stiffness * mass),
|
|
103
|
+
mass,
|
|
104
|
+
extra: config
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
if (duration !== void 0) {
|
|
108
|
+
return springTiming(duration, typeof config.bounce === "number" ? config.bounce : 0, config);
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
if (duration === void 0) return null;
|
|
113
|
+
var easing = typeof config.easing === "string" ? config.easing : "ease";
|
|
114
|
+
return {
|
|
115
|
+
kind: "timing",
|
|
116
|
+
durationMs: duration,
|
|
117
|
+
easing
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function timingToDriver(timing, animations) {
|
|
121
|
+
if (timing.type === "css") {
|
|
122
|
+
return {
|
|
123
|
+
kind: "timing",
|
|
124
|
+
durationMs: timeToMs(timing.duration),
|
|
125
|
+
easing: timing.timingFunction
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
if (timing.type === "spring") {
|
|
129
|
+
return springTiming(timeToMs(timing.duration), timing.bounce, timing.config);
|
|
130
|
+
}
|
|
131
|
+
var preset = animations === null || animations === void 0 ? void 0 : animations[timing.name];
|
|
132
|
+
if (preset === void 0) return null;
|
|
133
|
+
var base = presetToTiming(preset);
|
|
134
|
+
if (!base || !timing.config) return base;
|
|
135
|
+
var overrides = timing.config;
|
|
136
|
+
if (base.kind === "spring" || typeof overrides.bounce === "number") {
|
|
137
|
+
var overrideDuration = typeof overrides.duration === "number" ? overrides.duration : typeof overrides.duration === "string" ? timeToMs(overrides.duration) : void 0;
|
|
138
|
+
var overrideBounce = typeof overrides.bounce === "number" ? overrides.bounce : void 0;
|
|
139
|
+
var durationMs = overrideDuration !== null && overrideDuration !== void 0 ? overrideDuration : base.durationMs;
|
|
140
|
+
var bounce = overrideBounce !== null && overrideBounce !== void 0 ? overrideBounce : base.kind === "spring" ? base.bounce : 0;
|
|
141
|
+
var carried = base.kind === "spring" ? base.extra : void 0;
|
|
142
|
+
if (carried && (overrideDuration !== void 0 || overrideBounce !== void 0)) {
|
|
143
|
+
var { stiffness, damping, ...rest } = carried;
|
|
144
|
+
carried = rest;
|
|
145
|
+
}
|
|
146
|
+
return springTiming(durationMs, bounce, {
|
|
147
|
+
...carried,
|
|
148
|
+
...overrides
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
kind: "timing",
|
|
153
|
+
durationMs: typeof overrides.duration === "number" ? overrides.duration : typeof overrides.duration === "string" ? timeToMs(overrides.duration) : base.durationMs,
|
|
154
|
+
easing: typeof overrides.easing === "string" ? overrides.easing : base.easing
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
var namedEasings = {
|
|
158
|
+
linear: [
|
|
159
|
+
0,
|
|
160
|
+
0,
|
|
161
|
+
1,
|
|
162
|
+
1
|
|
163
|
+
],
|
|
164
|
+
ease: [
|
|
165
|
+
.25,
|
|
166
|
+
.1,
|
|
167
|
+
.25,
|
|
168
|
+
1
|
|
169
|
+
],
|
|
170
|
+
"ease-in": [
|
|
171
|
+
.42,
|
|
172
|
+
0,
|
|
173
|
+
1,
|
|
174
|
+
1
|
|
175
|
+
],
|
|
176
|
+
"ease-out": [
|
|
177
|
+
0,
|
|
178
|
+
0,
|
|
179
|
+
.58,
|
|
180
|
+
1
|
|
181
|
+
],
|
|
182
|
+
"ease-in-out": [
|
|
183
|
+
.42,
|
|
184
|
+
0,
|
|
185
|
+
.58,
|
|
186
|
+
1
|
|
187
|
+
]
|
|
188
|
+
};
|
|
189
|
+
function easingToBezier(easing) {
|
|
190
|
+
var named = namedEasings[easing];
|
|
191
|
+
if (named) return named;
|
|
192
|
+
if (!easing.startsWith("cubic-bezier(")) return null;
|
|
193
|
+
var parts = easing.slice("cubic-bezier(".length, -1).split(",");
|
|
194
|
+
if (parts.length !== 4) return null;
|
|
195
|
+
var points = parts.map(function(part) {
|
|
196
|
+
return Number.parseFloat(part);
|
|
197
|
+
});
|
|
198
|
+
if (points.some(function(point) {
|
|
199
|
+
return !Number.isFinite(point);
|
|
200
|
+
})) return null;
|
|
201
|
+
return points;
|
|
202
|
+
}
|
|
203
|
+
var cacheByAnimations = /* @__PURE__ */ new WeakMap();
|
|
204
|
+
var objectCache = /* @__PURE__ */ new WeakMap();
|
|
205
|
+
var noAnimations = {};
|
|
206
|
+
function resolveTransition(transition) {
|
|
207
|
+
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
208
|
+
if (transition == null || transition === "") return emptyResolved;
|
|
209
|
+
var _options_animations;
|
|
210
|
+
var animations = (_options_animations = options.animations) !== null && _options_animations !== void 0 ? _options_animations : null;
|
|
211
|
+
var cacheKey = animations !== null && animations !== void 0 ? animations : noAnimations;
|
|
212
|
+
if (typeof transition === "string") {
|
|
213
|
+
var byValue = cacheByAnimations.get(cacheKey);
|
|
214
|
+
if (!byValue) {
|
|
215
|
+
byValue = /* @__PURE__ */ new Map();
|
|
216
|
+
cacheByAnimations.set(cacheKey, byValue);
|
|
217
|
+
}
|
|
218
|
+
var hit = byValue.get(transition);
|
|
219
|
+
if (hit) return hit;
|
|
220
|
+
var _options_shorthands;
|
|
221
|
+
var built = buildResolved(transition, animations, (_options_shorthands = options.shorthands) !== null && _options_shorthands !== void 0 ? _options_shorthands : null);
|
|
222
|
+
if (byValue.size > 2048) byValue.clear();
|
|
223
|
+
byValue.set(transition, built);
|
|
224
|
+
return built;
|
|
225
|
+
}
|
|
226
|
+
if (typeof transition !== "object") return emptyResolved;
|
|
227
|
+
var hit1 = objectCache.get(transition);
|
|
228
|
+
if (hit1) return hit1;
|
|
229
|
+
var _options_shorthands1;
|
|
230
|
+
var built1 = buildResolved(transition, animations, (_options_shorthands1 = options.shorthands) !== null && _options_shorthands1 !== void 0 ? _options_shorthands1 : null);
|
|
231
|
+
objectCache.set(transition, built1);
|
|
232
|
+
return built1;
|
|
233
|
+
}
|
|
234
|
+
function buildResolved(transition, animations, shorthands) {
|
|
235
|
+
var presetNames = animations ? new Set(Object.keys(animations)) : void 0;
|
|
236
|
+
var parsed = (0, import_transitions.parseTransitionObject)(transition, presetNames);
|
|
237
|
+
if (!parsed.ok) {
|
|
238
|
+
return {
|
|
239
|
+
...emptyResolved,
|
|
240
|
+
diagnostics: parsed.diagnostics
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
if (parsed.value.kind !== "transition") return emptyResolved;
|
|
244
|
+
return fromEntries(parsed.value.entries, animations, shorthands, parsed.value.enter ? fromEntries(parsed.value.enter, animations, shorthands, null, null) : null, parsed.value.exit ? fromEntries(parsed.value.exit, animations, shorthands, null, null) : null);
|
|
245
|
+
}
|
|
246
|
+
var transformFamily = [
|
|
247
|
+
"transform",
|
|
248
|
+
"translate",
|
|
249
|
+
"scale",
|
|
250
|
+
"rotate"
|
|
251
|
+
];
|
|
252
|
+
function fromEntries(source, animations, shorthands, enter, exit) {
|
|
253
|
+
var entries = [];
|
|
254
|
+
var byProperty = {};
|
|
255
|
+
var diagnostics = [];
|
|
256
|
+
var all = null;
|
|
257
|
+
var none = false;
|
|
258
|
+
var fused = false;
|
|
259
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
260
|
+
try {
|
|
261
|
+
for (var _iterator = source[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
262
|
+
var entry = _step.value;
|
|
263
|
+
if (entry.property === "none") {
|
|
264
|
+
none = true;
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
if (entry.timing.type !== "css") fused = true;
|
|
268
|
+
var timing = timingToDriver(entry.timing, animations);
|
|
269
|
+
if (!timing) {
|
|
270
|
+
diagnostics.push({
|
|
271
|
+
code: "transition-invalid-token",
|
|
272
|
+
token: entry.timing.type === "preset" ? entry.timing.name : void 0,
|
|
273
|
+
message: entry.timing.type === "preset" ? `"${entry.timing.name}" is not a configured animation` : "transition timing could not be resolved"
|
|
274
|
+
});
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
var _shorthands_entry_property;
|
|
278
|
+
var expanded = (_shorthands_entry_property = shorthands === null || shorthands === void 0 ? void 0 : shorthands[entry.property]) !== null && _shorthands_entry_property !== void 0 ? _shorthands_entry_property : entry.property;
|
|
279
|
+
var property = (0, import_propertyNames.canonicalTransitionProperty)(expanded);
|
|
280
|
+
var delayMs = timeToMs(entry.delay);
|
|
281
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
282
|
+
try {
|
|
283
|
+
for (var _iterator1 = (expanded === "transform" ? transformFamily : [property])[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
284
|
+
var name = _step1.value;
|
|
285
|
+
var resolved = {
|
|
286
|
+
property: name,
|
|
287
|
+
timing,
|
|
288
|
+
delayMs,
|
|
289
|
+
behavior: entry.behavior
|
|
290
|
+
};
|
|
291
|
+
entries.push(resolved);
|
|
292
|
+
if (name === "all") all = resolved;
|
|
293
|
+
else byProperty[name] = resolved;
|
|
294
|
+
}
|
|
295
|
+
} catch (err) {
|
|
296
|
+
_didIteratorError1 = true;
|
|
297
|
+
_iteratorError1 = err;
|
|
298
|
+
} finally {
|
|
299
|
+
try {
|
|
300
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
301
|
+
_iterator1.return();
|
|
302
|
+
}
|
|
303
|
+
} finally {
|
|
304
|
+
if (_didIteratorError1) {
|
|
305
|
+
throw _iteratorError1;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
} catch (err) {
|
|
311
|
+
_didIteratorError = true;
|
|
312
|
+
_iteratorError = err;
|
|
313
|
+
} finally {
|
|
314
|
+
try {
|
|
315
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
316
|
+
_iterator.return();
|
|
317
|
+
}
|
|
318
|
+
} finally {
|
|
319
|
+
if (_didIteratorError) {
|
|
320
|
+
throw _iteratorError;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
return {
|
|
325
|
+
entries,
|
|
326
|
+
all,
|
|
327
|
+
byProperty,
|
|
328
|
+
none,
|
|
329
|
+
fused,
|
|
330
|
+
enter,
|
|
331
|
+
exit,
|
|
332
|
+
diagnostics
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
function getTransitionForKey(resolved, key) {
|
|
336
|
+
if (resolved.none) return null;
|
|
337
|
+
var direct = resolved.byProperty[(0, import_propertyNames.canonicalTransitionProperty)(key)];
|
|
338
|
+
if (direct) return direct;
|
|
339
|
+
return resolved.all;
|
|
340
|
+
}
|
|
341
|
+
function hasTransition(resolved) {
|
|
342
|
+
return !resolved.none && resolved.entries.length > 0;
|
|
343
|
+
}
|
|
344
|
+
function getSettleMs(timing) {
|
|
345
|
+
if (timing.kind === "timing") return timing.durationMs;
|
|
346
|
+
return (0, import_transitions.springSettleTime)({
|
|
347
|
+
duration: timing.durationMs,
|
|
348
|
+
bounce: timing.bounce
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
function getMaxDurationMs(resolved) {
|
|
352
|
+
var max = 0;
|
|
353
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
354
|
+
try {
|
|
355
|
+
for (var _iterator = resolved.entries[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
356
|
+
var entry = _step.value;
|
|
357
|
+
var total = getSettleMs(entry.timing) + entry.delayMs;
|
|
358
|
+
if (total > max) max = total;
|
|
359
|
+
}
|
|
360
|
+
} catch (err) {
|
|
361
|
+
_didIteratorError = true;
|
|
362
|
+
_iteratorError = err;
|
|
363
|
+
} finally {
|
|
364
|
+
try {
|
|
365
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
366
|
+
_iterator.return();
|
|
367
|
+
}
|
|
368
|
+
} finally {
|
|
369
|
+
if (_didIteratorError) {
|
|
370
|
+
throw _iteratorError;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
return max;
|
|
375
|
+
}
|
|
376
|
+
var linearEasingCache = /* @__PURE__ */ new Map();
|
|
377
|
+
function entryToCSS(entry) {
|
|
378
|
+
var delay = entry.delayMs ? ` ${entry.delayMs}ms` : "";
|
|
379
|
+
var behavior = entry.behavior === "allow-discrete" ? " allow-discrete" : "";
|
|
380
|
+
if (entry.timing.kind === "timing") {
|
|
381
|
+
return `${entry.property} ${entry.timing.durationMs}ms ${entry.timing.easing}${delay}${behavior}`;
|
|
382
|
+
}
|
|
383
|
+
var key = `${entry.timing.durationMs}/${entry.timing.bounce}`;
|
|
384
|
+
var spring = linearEasingCache.get(key);
|
|
385
|
+
if (!spring) {
|
|
386
|
+
spring = (0, import_transitions.springToLinearEasing)({
|
|
387
|
+
duration: entry.timing.durationMs,
|
|
388
|
+
bounce: entry.timing.bounce
|
|
389
|
+
});
|
|
390
|
+
if (linearEasingCache.size > 256) linearEasingCache.clear();
|
|
391
|
+
linearEasingCache.set(key, spring);
|
|
392
|
+
}
|
|
393
|
+
return `${entry.property} ${Math.round(spring.durationMs)}ms ${spring.easing}${delay}${behavior}`;
|
|
394
|
+
}
|
|
395
|
+
function toCSSTransition(resolved) {
|
|
396
|
+
if (resolved.none) return "none";
|
|
397
|
+
if (!resolved.entries.length) return void 0;
|
|
398
|
+
var out = "";
|
|
399
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
400
|
+
try {
|
|
401
|
+
for (var _iterator = resolved.entries[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
402
|
+
var entry = _step.value;
|
|
403
|
+
out += `${out ? ", " : ""}${entryToCSS(entry)}`;
|
|
404
|
+
}
|
|
405
|
+
} catch (err) {
|
|
406
|
+
_didIteratorError = true;
|
|
407
|
+
_iteratorError = err;
|
|
408
|
+
} finally {
|
|
409
|
+
try {
|
|
410
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
411
|
+
_iterator.return();
|
|
412
|
+
}
|
|
413
|
+
} finally {
|
|
414
|
+
if (_didIteratorError) {
|
|
415
|
+
throw _iteratorError;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
return out || void 0;
|
|
420
|
+
}
|
|
421
|
+
(0, import_transitionResolver.setTransitionResolver)({
|
|
422
|
+
resolve: resolveTransition,
|
|
423
|
+
toCSS: toCSSTransition
|
|
424
|
+
});
|