@tamagui/animation-helpers 2.7.7 → 3.0.0-beta.1093.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.
Files changed (79) hide show
  1. package/dist/cjs/index.cjs +32 -21
  2. package/dist/cjs/index.native.cjs +46 -0
  3. package/dist/cjs/index.native.js +33 -21
  4. package/dist/cjs/index.native.js.map +1 -1
  5. package/dist/cjs/presets.cjs +77 -0
  6. package/dist/cjs/presets.native.cjs +79 -0
  7. package/dist/cjs/presets.native.js +81 -0
  8. package/dist/cjs/presets.native.js.map +1 -0
  9. package/dist/cjs/propertyNames.cjs +91 -0
  10. package/dist/cjs/propertyNames.native.cjs +95 -0
  11. package/dist/cjs/propertyNames.native.js +97 -0
  12. package/dist/cjs/propertyNames.native.js.map +1 -0
  13. package/dist/cjs/resolveTransition.cjs +345 -0
  14. package/dist/cjs/resolveTransition.native.cjs +424 -0
  15. package/dist/cjs/resolveTransition.native.js +426 -0
  16. package/dist/cjs/resolveTransition.native.js.map +1 -0
  17. package/dist/cjs/transitionResolver.cjs +34 -0
  18. package/dist/cjs/transitionResolver.native.cjs +37 -0
  19. package/dist/cjs/transitionResolver.native.js +39 -0
  20. package/dist/cjs/transitionResolver.native.js.map +1 -0
  21. package/dist/cjs/types.cjs +9 -11
  22. package/dist/cjs/types.native.cjs +18 -0
  23. package/dist/cjs/types.native.js +9 -10
  24. package/dist/cjs/types.native.js.map +1 -1
  25. package/dist/esm/index.js +6 -3
  26. package/dist/esm/index.mjs +6 -3
  27. package/dist/esm/index.native.js +6 -3
  28. package/dist/esm/presets.mjs +57 -0
  29. package/dist/esm/presets.mjs.map +1 -0
  30. package/dist/esm/presets.native.js +57 -0
  31. package/dist/esm/presets.native.js.map +1 -0
  32. package/dist/esm/propertyNames.mjs +67 -0
  33. package/dist/esm/propertyNames.mjs.map +1 -0
  34. package/dist/esm/propertyNames.native.js +69 -0
  35. package/dist/esm/propertyNames.native.js.map +1 -0
  36. package/dist/esm/resolveTransition.mjs +315 -0
  37. package/dist/esm/resolveTransition.mjs.map +1 -0
  38. package/dist/esm/resolveTransition.native.js +392 -0
  39. package/dist/esm/resolveTransition.native.js.map +1 -0
  40. package/dist/esm/transitionResolver.mjs +11 -0
  41. package/dist/esm/transitionResolver.mjs.map +1 -0
  42. package/dist/esm/transitionResolver.native.js +12 -0
  43. package/dist/esm/transitionResolver.native.js.map +1 -0
  44. package/dist/esm/types.mjs +0 -2
  45. package/dist/esm/types.native.js +0 -2
  46. package/package.json +23 -2
  47. package/src/index.ts +39 -9
  48. package/src/presets.ts +40 -0
  49. package/src/propertyNames.ts +78 -0
  50. package/src/resolveTransition.ts +503 -0
  51. package/src/transitionResolver.ts +35 -0
  52. package/src/types.ts +42 -46
  53. package/types/index.d.ts +6 -2
  54. package/types/index.d.ts.map +2 -2
  55. package/types/presets.d.ts +79 -0
  56. package/types/presets.d.ts.map +11 -0
  57. package/types/propertyNames.d.ts +13 -0
  58. package/types/propertyNames.d.ts.map +11 -0
  59. package/types/resolveTransition.d.ts +108 -0
  60. package/types/resolveTransition.d.ts.map +11 -0
  61. package/types/transitionResolver.d.ts +30 -0
  62. package/types/transitionResolver.d.ts.map +11 -0
  63. package/types/types.d.ts +35 -42
  64. package/types/types.d.ts.map +2 -2
  65. package/dist/cjs/normalizeTransition.cjs +0 -164
  66. package/dist/cjs/normalizeTransition.native.js +0 -231
  67. package/dist/cjs/normalizeTransition.native.js.map +0 -1
  68. package/dist/esm/index.js.map +0 -1
  69. package/dist/esm/index.mjs.map +0 -1
  70. package/dist/esm/index.native.js.map +0 -1
  71. package/dist/esm/normalizeTransition.mjs +0 -134
  72. package/dist/esm/normalizeTransition.mjs.map +0 -1
  73. package/dist/esm/normalizeTransition.native.js +0 -198
  74. package/dist/esm/normalizeTransition.native.js.map +0 -1
  75. package/dist/esm/types.mjs.map +0 -1
  76. package/dist/esm/types.native.js.map +0 -1
  77. package/src/normalizeTransition.ts +0 -255
  78. package/types/normalizeTransition.d.ts +0 -54
  79. package/types/normalizeTransition.d.ts.map +0 -11
@@ -0,0 +1,97 @@
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 propertyNames_exports = {};
24
+ __export(propertyNames_exports, {
25
+ canonicalTransitionProperty: () => canonicalTransitionProperty,
26
+ isTransformProperty: () => isTransformProperty,
27
+ styleKeysForProperty: () => styleKeysForProperty
28
+ });
29
+ module.exports = __toCommonJS(propertyNames_exports);
30
+ var transformProperties = {
31
+ x: "translate",
32
+ y: "translate",
33
+ z: "translate",
34
+ translate: "translate",
35
+ translateX: "translate",
36
+ translateY: "translate",
37
+ translateZ: "translate",
38
+ scale: "scale",
39
+ scaleX: "scale",
40
+ scaleY: "scale",
41
+ scaleZ: "scale",
42
+ rotate: "rotate",
43
+ rotateX: "transform",
44
+ rotateY: "transform",
45
+ rotateZ: "transform",
46
+ skewX: "transform",
47
+ skewY: "transform",
48
+ perspective: "transform",
49
+ matrix: "transform",
50
+ transform: "transform"
51
+ };
52
+ function canonicalTransitionProperty(key) {
53
+ if (key === "all" || key === "none") return key;
54
+ var transform = transformProperties[key];
55
+ if (transform) return transform;
56
+ return key.includes("-") ? key : key.replace(/[A-Z]/g, "-$&").toLowerCase();
57
+ }
58
+ function isTransformProperty(key) {
59
+ return key in transformProperties;
60
+ }
61
+ var styleKeysByProperty = {
62
+ translate: [
63
+ "translate",
64
+ "translateX",
65
+ "translateY",
66
+ "translateZ",
67
+ "x",
68
+ "y",
69
+ "z"
70
+ ],
71
+ scale: [
72
+ "scale",
73
+ "scaleX",
74
+ "scaleY",
75
+ "scaleZ"
76
+ ],
77
+ rotate: ["rotate"],
78
+ transform: [
79
+ "transform",
80
+ "rotateX",
81
+ "rotateY",
82
+ "rotateZ",
83
+ "skewX",
84
+ "skewY",
85
+ "perspective",
86
+ "matrix"
87
+ ]
88
+ };
89
+ function styleKeysForProperty(property) {
90
+ var transform = styleKeysByProperty[property];
91
+ if (transform) return transform;
92
+ return [property.replace(/-([a-z])/g, function(_, letter) {
93
+ return letter.toUpperCase();
94
+ })];
95
+ }
96
+
97
+ //# sourceMappingURL=propertyNames.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"propertyNames.native.js","names":[],"sources":["cjs/propertyNames.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar propertyNames_exports = {};\n__export(propertyNames_exports, {\n canonicalTransitionProperty: () => canonicalTransitionProperty,\n isTransformProperty: () => isTransformProperty,\n styleKeysForProperty: () => styleKeysForProperty\n});\nmodule.exports = __toCommonJS(propertyNames_exports);\nvar transformProperties = {\n x: \"translate\",\n y: \"translate\",\n z: \"translate\",\n translate: \"translate\",\n translateX: \"translate\",\n translateY: \"translate\",\n translateZ: \"translate\",\n scale: \"scale\",\n scaleX: \"scale\",\n scaleY: \"scale\",\n scaleZ: \"scale\",\n rotate: \"rotate\",\n rotateX: \"transform\",\n rotateY: \"transform\",\n rotateZ: \"transform\",\n skewX: \"transform\",\n skewY: \"transform\",\n perspective: \"transform\",\n matrix: \"transform\",\n transform: \"transform\"\n};\nfunction canonicalTransitionProperty(key) {\n if (key === \"all\" || key === \"none\") return key;\n var transform = transformProperties[key];\n if (transform) return transform;\n return key.includes(\"-\") ? key : key.replace(/[A-Z]/g, \"-$&\").toLowerCase();\n}\nfunction isTransformProperty(key) {\n return key in transformProperties;\n}\nvar styleKeysByProperty = {\n translate: [\n \"translate\",\n \"translateX\",\n \"translateY\",\n \"translateZ\",\n \"x\",\n \"y\",\n \"z\"\n ],\n scale: [\n \"scale\",\n \"scaleX\",\n \"scaleY\",\n \"scaleZ\"\n ],\n rotate: [\n \"rotate\"\n ],\n transform: [\n \"transform\",\n \"rotateX\",\n \"rotateY\",\n \"rotateZ\",\n \"skewX\",\n \"skewY\",\n \"perspective\",\n \"matrix\"\n ]\n};\nfunction styleKeysForProperty(property) {\n var transform = styleKeysByProperty[property];\n if (transform) return transform;\n return [\n property.replace(/-([a-z])/g, function(_, letter) {\n return letter.toUpperCase();\n })\n ];\n}\n//# sourceMappingURL=propertyNames.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,wBAAwB,CAAC;AAC7B,SAAS,uBAAuB;CAC9B,mCAAmC;CACnC,2BAA2B;CAC3B,4BAA4B;AAC9B,CAAC;AACD,OAAO,UAAU,aAAa,qBAAqB;AACnD,IAAI,sBAAsB;CACxB,GAAG;CACH,GAAG;CACH,GAAG;CACH,WAAW;CACX,YAAY;CACZ,YAAY;CACZ,YAAY;CACZ,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,SAAS;CACT,SAAS;CACT,OAAO;CACP,OAAO;CACP,aAAa;CACb,QAAQ;CACR,WAAW;AACb;AACA,SAAS,4BAA4B,KAAK;CACxC,IAAI,QAAQ,SAAS,QAAQ,QAAQ,OAAO;CAC5C,IAAI,YAAY,oBAAoB;CACpC,IAAI,WAAW,OAAO;CACtB,OAAO,IAAI,SAAS,GAAG,IAAI,MAAM,IAAI,QAAQ,UAAU,KAAK,CAAC,CAAC,YAAY;AAC5E;AACA,SAAS,oBAAoB,KAAK;CAChC,OAAO,OAAO;AAChB;AACA,IAAI,sBAAsB;CACxB,WAAW;EACT;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,OAAO;EACL;EACA;EACA;EACA;CACF;CACA,QAAQ,CACN,QACF;CACA,WAAW;EACT;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF;AACA,SAAS,qBAAqB,UAAU;CACtC,IAAI,YAAY,oBAAoB;CACpC,IAAI,WAAW,OAAO;CACtB,OAAO,CACL,SAAS,QAAQ,aAAa,SAAS,GAAG,QAAQ;EAChD,OAAO,OAAO,YAAY;CAC5B,CAAC,CACH;AACF"}
@@ -0,0 +1,345 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
+ get: () => from[key],
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+ var resolveTransition_exports = {};
22
+ __export(resolveTransition_exports, {
23
+ easingToBezier: () => easingToBezier,
24
+ entryToCSS: () => entryToCSS,
25
+ forAnimationState: () => forAnimationState,
26
+ getMaxDurationMs: () => getMaxDurationMs,
27
+ getSettleMs: () => getSettleMs,
28
+ getTransitionForKey: () => getTransitionForKey,
29
+ hasTransition: () => hasTransition,
30
+ presetToTiming: () => presetToTiming,
31
+ resolveTransition: () => resolveTransition,
32
+ toCSSTransition: () => toCSSTransition
33
+ });
34
+ module.exports = __toCommonJS(resolveTransition_exports);
35
+ var import_transitions = require("@tamagui/style-grammar/transitions");
36
+ var import_propertyNames = require("./propertyNames.cjs");
37
+ var import_transitionResolver = require("./transitionResolver.cjs");
38
+ const emptyResolved = {
39
+ entries: [],
40
+ all: null,
41
+ byProperty: {},
42
+ none: false,
43
+ fused: false,
44
+ enter: null,
45
+ exit: null,
46
+ diagnostics: []
47
+ };
48
+ function forAnimationState(resolved, state) {
49
+ if (state === "enter" && resolved.enter) return resolved.enter;
50
+ if (state === "exit" && resolved.exit) return resolved.exit;
51
+ return resolved;
52
+ }
53
+ function timeToMs(value) {
54
+ return value.endsWith("ms") ? Number.parseFloat(value) : Number.parseFloat(value) * 1e3;
55
+ }
56
+ function springTiming(durationMs, bounce, extra) {
57
+ const mass = typeof extra?.mass === "number" ? extra.mass : 1;
58
+ const physics = (0, import_transitions.springFromDurationBounce)({
59
+ duration: durationMs,
60
+ bounce
61
+ }, mass);
62
+ return {
63
+ kind: "spring",
64
+ durationMs,
65
+ bounce,
66
+ stiffness: typeof extra?.stiffness === "number" ? extra.stiffness : physics.stiffness,
67
+ damping: typeof extra?.damping === "number" ? extra.damping : physics.damping,
68
+ mass,
69
+ extra
70
+ };
71
+ }
72
+ function presetToTiming(preset) {
73
+ if (typeof preset === "string") {
74
+ const parsed = (0, import_transitions.parseTransition)(preset);
75
+ if (!parsed.ok || parsed.value.kind !== "transition") return null;
76
+ const entry = parsed.value.entries[0];
77
+ if (!entry) return null;
78
+ return timingToDriver(entry.timing, null);
79
+ }
80
+ if (!preset || typeof preset !== "object") return null;
81
+ const config = preset;
82
+ const duration = typeof config.duration === "number" ? config.duration : void 0;
83
+ const hasPhysics = typeof config.stiffness === "number" || typeof config.damping === "number";
84
+ const stiffness = typeof config.stiffness === "number" ? config.stiffness : void 0;
85
+ const damping = typeof config.damping === "number" ? config.damping : void 0;
86
+ const isSpring = config.type === "spring" || typeof config.bounce === "number" || hasPhysics;
87
+ if (isSpring) {
88
+ const mass = typeof config.mass === "number" ? config.mass : 1;
89
+ if (stiffness !== void 0) {
90
+ const canonical = (0, import_transitions.springToDurationBounce)({
91
+ stiffness,
92
+ damping: damping ?? 2 * Math.sqrt(stiffness * mass),
93
+ mass
94
+ });
95
+ return {
96
+ kind: "spring",
97
+ durationMs: duration ?? canonical.duration,
98
+ bounce: typeof config.bounce === "number" ? config.bounce : canonical.bounce,
99
+ stiffness,
100
+ damping: damping ?? 2 * Math.sqrt(stiffness * mass),
101
+ mass,
102
+ extra: config
103
+ };
104
+ }
105
+ if (duration !== void 0) {
106
+ return springTiming(duration, typeof config.bounce === "number" ? config.bounce : 0, config);
107
+ }
108
+ return null;
109
+ }
110
+ if (duration === void 0) return null;
111
+ const easing = typeof config.easing === "string" ? config.easing : "ease";
112
+ return {
113
+ kind: "timing",
114
+ durationMs: duration,
115
+ easing
116
+ };
117
+ }
118
+ function timingToDriver(timing, animations) {
119
+ if (timing.type === "css") {
120
+ return {
121
+ kind: "timing",
122
+ durationMs: timeToMs(timing.duration),
123
+ easing: timing.timingFunction
124
+ };
125
+ }
126
+ if (timing.type === "spring") {
127
+ return springTiming(timeToMs(timing.duration), timing.bounce, timing.config);
128
+ }
129
+ const preset = animations?.[timing.name];
130
+ if (preset === void 0) return null;
131
+ const base = presetToTiming(preset);
132
+ if (!base || !timing.config) return base;
133
+ const overrides = timing.config;
134
+ if (base.kind === "spring" || typeof overrides.bounce === "number") {
135
+ const overrideDuration = typeof overrides.duration === "number" ? overrides.duration : typeof overrides.duration === "string" ? timeToMs(overrides.duration) : void 0;
136
+ const overrideBounce = typeof overrides.bounce === "number" ? overrides.bounce : void 0;
137
+ const durationMs = overrideDuration ?? base.durationMs;
138
+ const bounce = overrideBounce ?? (base.kind === "spring" ? base.bounce : 0);
139
+ let carried = base.kind === "spring" ? base.extra : void 0;
140
+ if (carried && (overrideDuration !== void 0 || overrideBounce !== void 0)) {
141
+ const { stiffness, damping, ...rest } = carried;
142
+ carried = rest;
143
+ }
144
+ return springTiming(durationMs, bounce, {
145
+ ...carried,
146
+ ...overrides
147
+ });
148
+ }
149
+ return {
150
+ kind: "timing",
151
+ durationMs: typeof overrides.duration === "number" ? overrides.duration : typeof overrides.duration === "string" ? timeToMs(overrides.duration) : base.durationMs,
152
+ easing: typeof overrides.easing === "string" ? overrides.easing : base.easing
153
+ };
154
+ }
155
+ const namedEasings = {
156
+ linear: [
157
+ 0,
158
+ 0,
159
+ 1,
160
+ 1
161
+ ],
162
+ ease: [
163
+ .25,
164
+ .1,
165
+ .25,
166
+ 1
167
+ ],
168
+ "ease-in": [
169
+ .42,
170
+ 0,
171
+ 1,
172
+ 1
173
+ ],
174
+ "ease-out": [
175
+ 0,
176
+ 0,
177
+ .58,
178
+ 1
179
+ ],
180
+ "ease-in-out": [
181
+ .42,
182
+ 0,
183
+ .58,
184
+ 1
185
+ ]
186
+ };
187
+ function easingToBezier(easing) {
188
+ const named = namedEasings[easing];
189
+ if (named) return named;
190
+ if (!easing.startsWith("cubic-bezier(")) return null;
191
+ const parts = easing.slice("cubic-bezier(".length, -1).split(",");
192
+ if (parts.length !== 4) return null;
193
+ const points = parts.map((part) => Number.parseFloat(part));
194
+ if (points.some((point) => !Number.isFinite(point))) return null;
195
+ return points;
196
+ }
197
+ const cacheByAnimations = /* @__PURE__ */ new WeakMap();
198
+ const objectCache = /* @__PURE__ */ new WeakMap();
199
+ const noAnimations = {};
200
+ function resolveTransition(transition, options = {}) {
201
+ if (transition == null || transition === "") return emptyResolved;
202
+ const animations = options.animations ?? null;
203
+ const cacheKey = animations ?? noAnimations;
204
+ if (typeof transition === "string") {
205
+ let byValue = cacheByAnimations.get(cacheKey);
206
+ if (!byValue) {
207
+ byValue = /* @__PURE__ */ new Map();
208
+ cacheByAnimations.set(cacheKey, byValue);
209
+ }
210
+ const hit2 = byValue.get(transition);
211
+ if (hit2) return hit2;
212
+ const built2 = buildResolved(transition, animations, options.shorthands ?? null);
213
+ if (byValue.size > 2048) byValue.clear();
214
+ byValue.set(transition, built2);
215
+ return built2;
216
+ }
217
+ if (typeof transition !== "object") return emptyResolved;
218
+ const hit = objectCache.get(transition);
219
+ if (hit) return hit;
220
+ const built = buildResolved(transition, animations, options.shorthands ?? null);
221
+ objectCache.set(transition, built);
222
+ return built;
223
+ }
224
+ function buildResolved(transition, animations, shorthands) {
225
+ const presetNames = animations ? new Set(Object.keys(animations)) : void 0;
226
+ const parsed = (0, import_transitions.parseTransitionObject)(transition, presetNames);
227
+ if (!parsed.ok) {
228
+ return {
229
+ ...emptyResolved,
230
+ diagnostics: parsed.diagnostics
231
+ };
232
+ }
233
+ if (parsed.value.kind !== "transition") return emptyResolved;
234
+ 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);
235
+ }
236
+ const transformFamily = [
237
+ "transform",
238
+ "translate",
239
+ "scale",
240
+ "rotate"
241
+ ];
242
+ function fromEntries(source, animations, shorthands, enter, exit) {
243
+ const entries = [];
244
+ const byProperty = {};
245
+ const diagnostics = [];
246
+ let all = null;
247
+ let none = false;
248
+ let fused = false;
249
+ for (const entry of source) {
250
+ if (entry.property === "none") {
251
+ none = true;
252
+ continue;
253
+ }
254
+ if (entry.timing.type !== "css") fused = true;
255
+ const timing = timingToDriver(entry.timing, animations);
256
+ if (!timing) {
257
+ diagnostics.push({
258
+ code: "transition-invalid-token",
259
+ token: entry.timing.type === "preset" ? entry.timing.name : void 0,
260
+ message: entry.timing.type === "preset" ? `"${entry.timing.name}" is not a configured animation` : "transition timing could not be resolved"
261
+ });
262
+ continue;
263
+ }
264
+ const expanded = shorthands?.[entry.property] ?? entry.property;
265
+ const property = (0, import_propertyNames.canonicalTransitionProperty)(expanded);
266
+ const delayMs = timeToMs(entry.delay);
267
+ for (const name of expanded === "transform" ? transformFamily : [property]) {
268
+ const resolved = {
269
+ property: name,
270
+ timing,
271
+ delayMs,
272
+ behavior: entry.behavior
273
+ };
274
+ entries.push(resolved);
275
+ if (name === "all") all = resolved;
276
+ else byProperty[name] = resolved;
277
+ }
278
+ }
279
+ return {
280
+ entries,
281
+ all,
282
+ byProperty,
283
+ none,
284
+ fused,
285
+ enter,
286
+ exit,
287
+ diagnostics
288
+ };
289
+ }
290
+ function getTransitionForKey(resolved, key) {
291
+ if (resolved.none) return null;
292
+ const direct = resolved.byProperty[(0, import_propertyNames.canonicalTransitionProperty)(key)];
293
+ if (direct) return direct;
294
+ return resolved.all;
295
+ }
296
+ function hasTransition(resolved) {
297
+ return !resolved.none && resolved.entries.length > 0;
298
+ }
299
+ function getSettleMs(timing) {
300
+ if (timing.kind === "timing") return timing.durationMs;
301
+ return (0, import_transitions.springSettleTime)({
302
+ duration: timing.durationMs,
303
+ bounce: timing.bounce
304
+ });
305
+ }
306
+ function getMaxDurationMs(resolved) {
307
+ let max = 0;
308
+ for (const entry of resolved.entries) {
309
+ const total = getSettleMs(entry.timing) + entry.delayMs;
310
+ if (total > max) max = total;
311
+ }
312
+ return max;
313
+ }
314
+ const linearEasingCache = /* @__PURE__ */ new Map();
315
+ function entryToCSS(entry) {
316
+ const delay = entry.delayMs ? ` ${entry.delayMs}ms` : "";
317
+ const behavior = entry.behavior === "allow-discrete" ? " allow-discrete" : "";
318
+ if (entry.timing.kind === "timing") {
319
+ return `${entry.property} ${entry.timing.durationMs}ms ${entry.timing.easing}${delay}${behavior}`;
320
+ }
321
+ const key = `${entry.timing.durationMs}/${entry.timing.bounce}`;
322
+ let spring = linearEasingCache.get(key);
323
+ if (!spring) {
324
+ spring = (0, import_transitions.springToLinearEasing)({
325
+ duration: entry.timing.durationMs,
326
+ bounce: entry.timing.bounce
327
+ });
328
+ if (linearEasingCache.size > 256) linearEasingCache.clear();
329
+ linearEasingCache.set(key, spring);
330
+ }
331
+ return `${entry.property} ${Math.round(spring.durationMs)}ms ${spring.easing}${delay}${behavior}`;
332
+ }
333
+ function toCSSTransition(resolved) {
334
+ if (resolved.none) return "none";
335
+ if (!resolved.entries.length) return void 0;
336
+ let out = "";
337
+ for (const entry of resolved.entries) {
338
+ out += `${out ? ", " : ""}${entryToCSS(entry)}`;
339
+ }
340
+ return out || void 0;
341
+ }
342
+ (0, import_transitionResolver.setTransitionResolver)({
343
+ resolve: resolveTransition,
344
+ toCSS: toCSSTransition
345
+ });