tailwind-styled-v4 4.0.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/animate.cjs +754 -235
  2. package/dist/animate.cjs.map +1 -1
  3. package/dist/animate.d.cts +55 -99
  4. package/dist/animate.d.ts +55 -99
  5. package/dist/animate.js +742 -235
  6. package/dist/animate.js.map +1 -1
  7. package/dist/chunk-VZEJV27B.js +11 -0
  8. package/dist/chunk-VZEJV27B.js.map +1 -0
  9. package/dist/chunk-Y5D3E72P.cjs +13 -0
  10. package/dist/chunk-Y5D3E72P.cjs.map +1 -0
  11. package/dist/css.cjs +61 -11
  12. package/dist/css.cjs.map +1 -1
  13. package/dist/css.d.cts +3 -18
  14. package/dist/css.d.ts +3 -18
  15. package/dist/css.js +61 -11
  16. package/dist/css.js.map +1 -1
  17. package/dist/devtools.cjs +200 -88
  18. package/dist/devtools.cjs.map +1 -1
  19. package/dist/devtools.js +200 -88
  20. package/dist/devtools.js.map +1 -1
  21. package/dist/index.cjs +430 -135
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +74 -3
  24. package/dist/index.d.ts +74 -3
  25. package/dist/index.js +415 -132
  26. package/dist/index.js.map +1 -1
  27. package/dist/next.cjs +118 -138
  28. package/dist/next.cjs.map +1 -1
  29. package/dist/next.d.cts +28 -19
  30. package/dist/next.d.ts +28 -19
  31. package/dist/next.js +111 -131
  32. package/dist/next.js.map +1 -1
  33. package/dist/preset.cjs +312 -18
  34. package/dist/preset.cjs.map +1 -1
  35. package/dist/preset.d.cts +29 -2
  36. package/dist/preset.d.ts +29 -2
  37. package/dist/preset.js +311 -19
  38. package/dist/preset.js.map +1 -1
  39. package/dist/turbopackLoader.cjs +24 -2676
  40. package/dist/turbopackLoader.cjs.map +1 -1
  41. package/dist/turbopackLoader.d.cts +3 -13
  42. package/dist/turbopackLoader.d.ts +3 -13
  43. package/dist/turbopackLoader.js +24 -2670
  44. package/dist/turbopackLoader.js.map +1 -1
  45. package/dist/vite.cjs +90 -57
  46. package/dist/vite.cjs.map +1 -1
  47. package/dist/vite.d.cts +35 -6
  48. package/dist/vite.d.ts +35 -6
  49. package/dist/vite.js +90 -58
  50. package/dist/vite.js.map +1 -1
  51. package/dist/webpackLoader.cjs +27 -2646
  52. package/dist/webpackLoader.cjs.map +1 -1
  53. package/dist/webpackLoader.d.cts +3 -10
  54. package/dist/webpackLoader.d.ts +3 -10
  55. package/dist/webpackLoader.js +27 -2640
  56. package/dist/webpackLoader.js.map +1 -1
  57. package/package.json +31 -28
  58. package/dist/astTransform-ua-eapqs.d.cts +0 -41
  59. package/dist/astTransform-ua-eapqs.d.ts +0 -41
  60. package/dist/compiler.cjs +0 -3594
  61. package/dist/compiler.cjs.map +0 -1
  62. package/dist/compiler.d.cts +0 -716
  63. package/dist/compiler.d.ts +0 -716
  64. package/dist/compiler.js +0 -3535
  65. package/dist/compiler.js.map +0 -1
  66. package/dist/plugins.cjs +0 -396
  67. package/dist/plugins.cjs.map +0 -1
  68. package/dist/plugins.d.cts +0 -231
  69. package/dist/plugins.d.ts +0 -231
  70. package/dist/plugins.js +0 -381
  71. package/dist/plugins.js.map +0 -1
  72. package/dist/theme.cjs +0 -154
  73. package/dist/theme.cjs.map +0 -1
  74. package/dist/theme.d.cts +0 -181
  75. package/dist/theme.d.ts +0 -181
  76. package/dist/theme.js +0 -148
  77. package/dist/theme.js.map +0 -1
package/dist/animate.cjs CHANGED
@@ -1,252 +1,771 @@
1
1
  'use strict';
2
2
 
3
- /* tailwind-styled-v4 v4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
3
+ require('./chunk-Y5D3E72P.cjs');
4
+ var fs = require('fs');
5
+ var module$1 = require('module');
6
+ var path = require('path');
7
+ var url = require('url');
8
+ require('crypto');
9
+ require('@tailwind-styled/scanner');
4
10
 
5
- // ../animate/src/index.ts
6
- var TW_TO_CSS = {
7
- // Opacity
8
- "opacity-0": "opacity: 0",
9
- "opacity-5": "opacity: 0.05",
10
- "opacity-10": "opacity: 0.1",
11
- "opacity-20": "opacity: 0.2",
12
- "opacity-25": "opacity: 0.25",
13
- "opacity-30": "opacity: 0.3",
14
- "opacity-40": "opacity: 0.4",
15
- "opacity-50": "opacity: 0.5",
16
- "opacity-60": "opacity: 0.6",
17
- "opacity-70": "opacity: 0.7",
18
- "opacity-75": "opacity: 0.75",
19
- "opacity-80": "opacity: 0.8",
20
- "opacity-90": "opacity: 0.9",
21
- "opacity-95": "opacity: 0.95",
22
- "opacity-100": "opacity: 1",
23
- // Translate Y
24
- "translate-y-0": "transform: translateY(0px)",
25
- "translate-y-0.5": "transform: translateY(0.125rem)",
26
- "translate-y-1": "transform: translateY(0.25rem)",
27
- "translate-y-2": "transform: translateY(0.5rem)",
28
- "translate-y-3": "transform: translateY(0.75rem)",
29
- "translate-y-4": "transform: translateY(1rem)",
30
- "translate-y-6": "transform: translateY(1.5rem)",
31
- "translate-y-8": "transform: translateY(2rem)",
32
- "-translate-y-1": "transform: translateY(-0.25rem)",
33
- "-translate-y-2": "transform: translateY(-0.5rem)",
34
- "-translate-y-4": "transform: translateY(-1rem)",
35
- "-translate-y-8": "transform: translateY(-2rem)",
36
- // Translate X
37
- "translate-x-0": "transform: translateX(0px)",
38
- "translate-x-1": "transform: translateX(0.25rem)",
39
- "translate-x-2": "transform: translateX(0.5rem)",
40
- "translate-x-4": "transform: translateX(1rem)",
41
- "-translate-x-1": "transform: translateX(-0.25rem)",
42
- "-translate-x-2": "transform: translateX(-0.5rem)",
43
- "-translate-x-4": "transform: translateX(-1rem)",
44
- // Scale
45
- "scale-0": "transform: scale(0)",
46
- "scale-50": "transform: scale(0.5)",
47
- "scale-75": "transform: scale(0.75)",
48
- "scale-90": "transform: scale(0.9)",
49
- "scale-95": "transform: scale(0.95)",
50
- "scale-100": "transform: scale(1)",
51
- "scale-105": "transform: scale(1.05)",
52
- "scale-110": "transform: scale(1.1)",
53
- "scale-125": "transform: scale(1.25)",
54
- "scale-150": "transform: scale(1.5)",
55
- // Rotate
56
- "rotate-0": "transform: rotate(0deg)",
57
- "rotate-1": "transform: rotate(1deg)",
58
- "rotate-2": "transform: rotate(2deg)",
59
- "rotate-3": "transform: rotate(3deg)",
60
- "rotate-6": "transform: rotate(6deg)",
61
- "rotate-12": "transform: rotate(12deg)",
62
- "rotate-45": "transform: rotate(45deg)",
63
- "rotate-90": "transform: rotate(90deg)",
64
- "rotate-180": "transform: rotate(180deg)",
65
- "-rotate-1": "transform: rotate(-1deg)",
66
- "-rotate-2": "transform: rotate(-2deg)",
67
- "-rotate-6": "transform: rotate(-6deg)",
68
- "-rotate-12": "transform: rotate(-12deg)",
69
- "-rotate-45": "transform: rotate(-45deg)",
70
- "-rotate-90": "transform: rotate(-90deg)",
71
- // Blur
72
- "blur-none": "filter: blur(0)",
73
- "blur-sm": "filter: blur(4px)",
74
- blur: "filter: blur(8px)",
75
- "blur-md": "filter: blur(12px)",
76
- "blur-lg": "filter: blur(16px)",
77
- "blur-xl": "filter: blur(24px)",
78
- "blur-2xl": "filter: blur(40px)",
79
- "blur-3xl": "filter: blur(64px)"
11
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
12
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
+
14
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
15
+ var path__default = /*#__PURE__*/_interopDefault(path);
16
+
17
+ /* tailwind-styled-v4 v4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
18
+ var LRUCache = class {
19
+ constructor(max = 256, ttlMs = null) {
20
+ this.map = /* @__PURE__ */ new Map();
21
+ this.max = max;
22
+ this.ttlMs = ttlMs;
23
+ }
24
+ get(key) {
25
+ const entry = this.map.get(key);
26
+ if (!entry) return void 0;
27
+ if (this.ttlMs !== null && Date.now() - entry.ts > this.ttlMs) {
28
+ this.map.delete(key);
29
+ return void 0;
30
+ }
31
+ this.map.delete(key);
32
+ this.map.set(key, entry);
33
+ return entry.value;
34
+ }
35
+ set(key, value) {
36
+ if (this.map.has(key)) this.map.delete(key);
37
+ else if (this.map.size >= this.max) {
38
+ this.map.delete(this.map.keys().next().value);
39
+ }
40
+ this.map.set(key, { value, ts: Date.now() });
41
+ }
42
+ has(key) {
43
+ return this.get(key) !== void 0;
44
+ }
45
+ delete(key) {
46
+ this.map.delete(key);
47
+ }
48
+ clear() {
49
+ this.map.clear();
50
+ }
51
+ get size() {
52
+ return this.map.size;
53
+ }
54
+ keys() {
55
+ return this.map.keys();
56
+ }
57
+ *values() {
58
+ for (const entry of this.map.values()) {
59
+ yield entry.value;
60
+ }
61
+ }
62
+ *entries() {
63
+ for (const [key, entry] of this.map.entries()) {
64
+ yield [key, entry.value];
65
+ }
66
+ }
80
67
  };
81
- function classesToCss(classes) {
82
- const parts = classes.split(/\s+/).filter(Boolean);
83
- const transforms = [];
84
- const others = [];
85
- for (const cls of parts) {
86
- const css = TW_TO_CSS[cls];
87
- if (!css) continue;
88
- if (css.startsWith("transform:")) {
89
- transforms.push(css.replace("transform: ", ""));
90
- } else {
91
- others.push(css);
92
- }
93
- }
94
- const result = [...others];
95
- if (transforms.length > 0) {
96
- result.push(`transform: ${transforms.join(" ")}`);
97
- }
98
- return result.join("; ");
99
- }
100
- var _animCounter = 0;
101
- function genAnimId(name) {
102
- if (name) return `tw-${name.replace(/[^a-zA-Z0-9]/g, "-")}`;
103
- return `tw-anim-${++_animCounter}`;
104
- }
105
- var _animRegistry = /* @__PURE__ */ new Map();
106
- function getAnimationRegistry() {
107
- return _animRegistry;
108
- }
109
- function compileAnimation(opts) {
110
- const {
111
- from,
112
- to,
113
- duration = 300,
114
- easing = "ease-out",
115
- delay = 0,
116
- fill = "both",
117
- iterations = 1,
118
- direction = "normal",
119
- name
120
- } = opts;
121
- const animId = genAnimId(
122
- name != null ? name : `${from.replace(/\s+/g, "-")}-${to.replace(/\s+/g, "-")}`.slice(0, 30)
68
+ function formatErrorMessage(error) {
69
+ return error instanceof Error ? error.message : String(error);
70
+ }
71
+ function resolveRuntimeDir(dirnameValue, moduleImportUrl) {
72
+ if (typeof dirnameValue === "string" && dirnameValue.length > 0) return dirnameValue;
73
+ return path__default.default.dirname(url.fileURLToPath(moduleImportUrl));
74
+ }
75
+ function resolveNativeBindingCandidates(options) {
76
+ const out = [];
77
+ const envVarNames = options.envVarNames ?? [];
78
+ for (const envVarName of envVarNames) {
79
+ const raw = process.env[envVarName]?.trim();
80
+ if (!raw) continue;
81
+ const resolved = path__default.default.resolve(raw);
82
+ if (options.enforceNodeExtensionForEnvPath) {
83
+ if (path__default.default.extname(resolved).toLowerCase() !== ".node") {
84
+ throw new Error(
85
+ `Invalid native binding path from ${envVarName}="${raw}". Expected a .node file.`
86
+ );
87
+ }
88
+ }
89
+ out.push(resolved);
90
+ }
91
+ if (options.includeDefaultCandidates !== false) {
92
+ out.push(path__default.default.resolve(process.cwd(), "native", "tailwind_styled_parser.node"));
93
+ out.push(path__default.default.resolve(options.runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node"));
94
+ }
95
+ return Array.from(new Set(out));
96
+ }
97
+ function parseDebugToken(namespace, token) {
98
+ if (token === "*" || token === namespace || token === "tailwind-styled:*") return true;
99
+ return token.endsWith("*") && namespace.startsWith(token.slice(0, -1));
100
+ }
101
+ function isDebugNamespaceEnabled(namespace) {
102
+ if (process.env.TWS_DEBUG === "1" || process.env.TAILWIND_STYLED_DEBUG === "1") return true;
103
+ const raw = process.env.DEBUG;
104
+ if (!raw) return false;
105
+ return raw.split(",").map((token) => token.trim()).some((token) => parseDebugToken(namespace, token));
106
+ }
107
+ function createDebugLogger(namespace, label = namespace) {
108
+ const debugEnabled = isDebugNamespaceEnabled(namespace);
109
+ return (message) => {
110
+ if (!debugEnabled) return;
111
+ console.debug(`[${label}] ${message}`);
112
+ };
113
+ }
114
+ function loadNativeBinding(options) {
115
+ const req = module$1.createRequire(path__default.default.join(options.runtimeDir, "noop.cjs"));
116
+ const loadErrors = [];
117
+ for (const candidate of options.candidates) {
118
+ if (!fs__default.default.existsSync(candidate)) continue;
119
+ try {
120
+ const mod = req(candidate);
121
+ if (options.isValid(mod)) {
122
+ return {
123
+ binding: mod,
124
+ loadedPath: candidate,
125
+ loadErrors
126
+ };
127
+ }
128
+ loadErrors.push({
129
+ path: candidate,
130
+ message: options.invalidExportMessage
131
+ });
132
+ } catch (error) {
133
+ loadErrors.push({
134
+ path: candidate,
135
+ message: formatErrorMessage(error)
136
+ });
137
+ }
138
+ }
139
+ return {
140
+ binding: null,
141
+ loadedPath: null,
142
+ loadErrors
143
+ };
144
+ }
145
+ var LEVELS = { silent: 0, error: 1, warn: 2, info: 3, debug: 4 };
146
+ function getEnvLevel() {
147
+ const env = process.env.TWS_LOG_LEVEL?.toLowerCase();
148
+ if (env && env in LEVELS) return env;
149
+ return process.env.TWS_DEBUG_SCANNER === "1" ? "debug" : "info";
150
+ }
151
+ function createLogger(prefix, level) {
152
+ let currentLevel = getEnvLevel();
153
+ const log = (msgLevel, stream, args) => {
154
+ if (LEVELS[msgLevel] > LEVELS[currentLevel]) return;
155
+ const line = `[${prefix}] ${args.map(String).join(" ")}
156
+ `;
157
+ process[stream].write(line);
158
+ };
159
+ return {
160
+ error: (...a) => log("error", "stderr", a),
161
+ warn: (...a) => log("warn", "stderr", a),
162
+ info: (...a) => log("info", "stdout", a),
163
+ debug: (...a) => log("debug", "stderr", a),
164
+ setLevel: (l) => {
165
+ currentLevel = l;
166
+ }
167
+ };
168
+ }
169
+ createLogger("tailwind-styled");
170
+
171
+ // ../animate/src/binding.ts
172
+ var bindingPromise = null;
173
+ var DEBUG_NAMESPACE = "tailwind-styled:animate";
174
+ var debugLog = createDebugLogger(DEBUG_NAMESPACE, "tailwind-styled/animate");
175
+ function isAnimateModule(module) {
176
+ const candidate = module;
177
+ return typeof candidate?.compileAnimation === "function" && typeof candidate?.compileKeyframes === "function";
178
+ }
179
+ function resolveBindingCandidates(runtimeDir) {
180
+ return resolveNativeBindingCandidates({
181
+ runtimeDir,
182
+ envVarNames: ["TWS_ANIMATE_NATIVE_PATH", "TWS_NATIVE_PATH"],
183
+ enforceNodeExtensionForEnvPath: true
184
+ });
185
+ }
186
+ function loadAnimateBinding() {
187
+ if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_NO_RUST === "1") {
188
+ throw new Error("Native animate backend is required in v5. TWS_NO_NATIVE/TWS_NO_RUST is not supported.");
189
+ }
190
+ const runtimeDir = resolveRuntimeDir(
191
+ typeof __dirname === "string" ? __dirname : void 0,
192
+ (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('animate.cjs', document.baseURI).href))
193
+ );
194
+ const candidates = resolveBindingCandidates(runtimeDir);
195
+ const { binding, loadErrors, loadedPath } = loadNativeBinding({
196
+ runtimeDir,
197
+ candidates,
198
+ isValid: isAnimateModule,
199
+ invalidExportMessage: "Module loaded but missing compileAnimation/compileKeyframes exports."
200
+ });
201
+ if (binding) {
202
+ debugLog(`native animate binding loaded from: ${loadedPath}`);
203
+ return binding;
204
+ }
205
+ if (loadErrors.length > 0) {
206
+ debugLog(
207
+ `native animate binding load failed for ${loadErrors.length} candidate(s): ${loadErrors.map((entry) => `${entry.path} (${entry.message})`).join("; ")}`
208
+ );
209
+ } else {
210
+ debugLog("native animate binding not found in any candidate path");
211
+ }
212
+ const lines = [
213
+ "Native animate backend not found. Ensure `tailwind_styled_parser.node` is built.",
214
+ "Checked paths:",
215
+ ...candidates.map((candidate) => `- ${candidate}`)
216
+ ];
217
+ if (loadErrors.length > 0) {
218
+ lines.push("Load errors:");
219
+ for (const error of loadErrors) lines.push(`- ${error.path}: ${error.message}`);
220
+ }
221
+ throw new Error(lines.join("\n"));
222
+ }
223
+ async function getAnimateBinding() {
224
+ if (!bindingPromise) {
225
+ bindingPromise = Promise.resolve().then(loadAnimateBinding);
226
+ }
227
+ return bindingPromise;
228
+ }
229
+ async function initAnimate() {
230
+ await getAnimateBinding();
231
+ }
232
+
233
+ // ../animate/src/preset.ts
234
+ var DEFAULT_PRESET_CACHE_LIMIT = 32;
235
+ function createAnimationPresets(registry) {
236
+ const cache = new LRUCache(DEFAULT_PRESET_CACHE_LIMIT);
237
+ const withCache = (cacheKey, factory) => async () => {
238
+ const cached = cache.get(cacheKey);
239
+ if (cached) {
240
+ const className = await cached;
241
+ if (registry.has(className)) return className;
242
+ cache.delete(cacheKey);
243
+ }
244
+ const pending = factory();
245
+ cache.set(cacheKey, pending);
246
+ try {
247
+ return await pending;
248
+ } catch (error) {
249
+ cache.delete(cacheKey);
250
+ throw error;
251
+ }
252
+ };
253
+ return {
254
+ fadeIn: withCache(
255
+ "fadeIn",
256
+ async () => (await registry.compileAnimation({ from: "opacity-0", to: "opacity-100", duration: 200 })).className
257
+ ),
258
+ fadeOut: withCache(
259
+ "fadeOut",
260
+ async () => (await registry.compileAnimation({ from: "opacity-100", to: "opacity-0", duration: 200 })).className
261
+ ),
262
+ slideUp: withCache(
263
+ "slideUp",
264
+ async () => (await registry.compileAnimation({
265
+ from: "opacity-0 translate-y-4",
266
+ to: "opacity-100 translate-y-0",
267
+ duration: 300
268
+ })).className
269
+ ),
270
+ slideDown: withCache(
271
+ "slideDown",
272
+ async () => (await registry.compileAnimation({
273
+ from: "opacity-0 -translate-y-4",
274
+ to: "opacity-100 translate-y-0",
275
+ duration: 300
276
+ })).className
277
+ ),
278
+ slideLeft: withCache(
279
+ "slideLeft",
280
+ async () => (await registry.compileAnimation({
281
+ from: "opacity-0 translate-x-4",
282
+ to: "opacity-100 translate-x-0",
283
+ duration: 300
284
+ })).className
285
+ ),
286
+ slideRight: withCache(
287
+ "slideRight",
288
+ async () => (await registry.compileAnimation({
289
+ from: "opacity-0 -translate-x-4",
290
+ to: "opacity-100 translate-x-0",
291
+ duration: 300
292
+ })).className
293
+ ),
294
+ scaleIn: withCache(
295
+ "scaleIn",
296
+ async () => (await registry.compileAnimation({
297
+ from: "opacity-0 scale-95",
298
+ to: "opacity-100 scale-100",
299
+ duration: 200,
300
+ easing: "cubic-bezier(0.16,1,0.3,1)"
301
+ })).className
302
+ ),
303
+ scaleOut: withCache(
304
+ "scaleOut",
305
+ async () => (await registry.compileAnimation({
306
+ from: "opacity-100 scale-100",
307
+ to: "opacity-0 scale-95",
308
+ duration: 150
309
+ })).className
310
+ ),
311
+ blurIn: withCache(
312
+ "blurIn",
313
+ async () => (await registry.compileAnimation({
314
+ from: "opacity-0 blur-sm",
315
+ to: "opacity-100 blur-none",
316
+ duration: 300
317
+ })).className
318
+ ),
319
+ bounceIn: withCache(
320
+ "bounceIn",
321
+ async () => (await registry.compileAnimation({
322
+ from: "opacity-0 scale-50",
323
+ to: "opacity-100 scale-100",
324
+ duration: 400,
325
+ easing: "cubic-bezier(0.34,1.56,0.64,1)"
326
+ })).className
327
+ ),
328
+ spinIn: withCache(
329
+ "spinIn",
330
+ async () => (await registry.compileAnimation({
331
+ from: "opacity-0 rotate-180 scale-50",
332
+ to: "opacity-100 rotate-0 scale-100",
333
+ duration: 400,
334
+ easing: "cubic-bezier(0.16,1,0.3,1)"
335
+ })).className
336
+ )
337
+ };
338
+ }
339
+ var DEBUG_NAMESPACE2 = "tailwind-styled:analyzer";
340
+ function formatErrorMessage2(error) {
341
+ return error instanceof Error ? error.message : String(error);
342
+ }
343
+ var debugLog2 = createDebugLogger(DEBUG_NAMESPACE2, "tailwind-styled/analyzer");
344
+ var bindingCache;
345
+ var bindingCandidateCache = [];
346
+ var bindingLoadErrorsCache = [];
347
+ var loadedBindingPathCache = null;
348
+ function isAnalyzerModule(module) {
349
+ const candidate = module;
350
+ return typeof candidate?.analyzeClasses === "function";
351
+ }
352
+ function getNativeBinding() {
353
+ if (bindingCache !== void 0) return bindingCache;
354
+ if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_NO_RUST === "1") {
355
+ bindingCandidateCache = [];
356
+ bindingLoadErrorsCache = [];
357
+ loadedBindingPathCache = null;
358
+ debugLog2("native binding disabled by TWS_NO_NATIVE/TWS_NO_RUST");
359
+ bindingCache = null;
360
+ return bindingCache;
361
+ }
362
+ const runtimeDir = resolveRuntimeDir(
363
+ typeof __dirname === "string" ? __dirname : void 0,
364
+ (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('animate.cjs', document.baseURI).href))
123
365
  );
124
- if (_animRegistry.has(animId)) {
125
- return _animRegistry.get(animId);
126
- }
127
- const fromCss = classesToCss(from);
128
- const toCss = classesToCss(to);
129
- const keyframesCss = [
130
- `@keyframes ${animId} {`,
131
- fromCss ? ` from { ${fromCss} }` : ` from {}`,
132
- toCss ? ` to { ${toCss} }` : ` to {}`,
133
- `}`
134
- ].join("\n");
135
- const iterStr = iterations === "infinite" ? "infinite" : String(iterations);
136
- const animationCss = [
137
- `animation-name: ${animId}`,
138
- `animation-duration: ${duration}ms`,
139
- `animation-timing-function: ${easing}`,
140
- `animation-delay: ${delay}ms`,
141
- `animation-fill-mode: ${fill}`,
142
- `animation-iteration-count: ${iterStr}`,
143
- `animation-direction: ${direction}`
144
- ].join("; ");
145
- const className = animId;
146
- const compiled = { className, keyframesCss, animationCss };
147
- _animRegistry.set(animId, compiled);
148
- return compiled;
149
- }
150
- function animate(opts) {
151
- const compiled = compileAnimation(opts);
152
- if (typeof document !== "undefined") {
153
- const styleId = `__tw_anim_${compiled.className}`;
154
- if (!document.getElementById(styleId)) {
155
- const style = document.createElement("style");
156
- style.id = styleId;
157
- style.textContent = `${compiled.keyframesCss}
158
- .${compiled.className}{${compiled.animationCss}}`;
159
- document.head.appendChild(style);
160
- }
161
- }
162
- return compiled.className;
163
- }
164
- function keyframes(name, stops) {
165
- const animId = genAnimId(name);
166
- if (_animRegistry.has(animId)) {
167
- return animId;
168
- }
169
- const stopLines = Object.entries(stops).map(([stop, classes]) => {
170
- const css = classesToCss(classes);
171
- return ` ${stop} { ${css} }`;
172
- }).join("\n");
173
- const keyframesCss = `@keyframes ${animId} {
174
- ${stopLines}
175
- }`;
176
- if (typeof document !== "undefined") {
177
- const styleId = `__tw_kf_${animId}`;
178
- if (!document.getElementById(styleId)) {
179
- const style = document.createElement("style");
180
- style.id = styleId;
181
- style.textContent = keyframesCss;
182
- document.head.appendChild(style);
183
- }
184
- }
185
- _animRegistry.set(animId, {
186
- className: animId,
187
- keyframesCss,
188
- animationCss: `animation-name: ${animId}`
366
+ const candidates = resolveNativeBindingCandidates({
367
+ runtimeDir,
368
+ envVarNames: ["TWS_NATIVE_PATH"]
189
369
  });
190
- return animId;
191
- }
192
- var animations = {
193
- fadeIn: animate({ from: "opacity-0", to: "opacity-100", duration: 200 }),
194
- fadeOut: animate({ from: "opacity-100", to: "opacity-0", duration: 200 }),
195
- slideUp: animate({
196
- from: "opacity-0 translate-y-4",
197
- to: "opacity-100 translate-y-0",
198
- duration: 300
199
- }),
200
- slideDown: animate({
201
- from: "opacity-0 -translate-y-4",
202
- to: "opacity-100 translate-y-0",
203
- duration: 300
204
- }),
205
- slideLeft: animate({
206
- from: "opacity-0 translate-x-4",
207
- to: "opacity-100 translate-x-0",
208
- duration: 300
209
- }),
210
- slideRight: animate({
211
- from: "opacity-0 -translate-x-4",
212
- to: "opacity-100 translate-x-0",
213
- duration: 300
214
- }),
215
- scaleIn: animate({
216
- from: "opacity-0 scale-95",
217
- to: "opacity-100 scale-100",
218
- duration: 200,
219
- easing: "cubic-bezier(0.16,1,0.3,1)"
220
- }),
221
- scaleOut: animate({ from: "opacity-100 scale-100", to: "opacity-0 scale-95", duration: 150 }),
222
- blurIn: animate({ from: "opacity-0 blur-sm", to: "opacity-100 blur-none", duration: 300 }),
223
- bounceIn: animate({
224
- from: "opacity-0 scale-50",
225
- to: "opacity-100 scale-100",
226
- duration: 400,
227
- easing: "cubic-bezier(0.34,1.56,0.64,1)"
228
- }),
229
- spinIn: animate({
230
- from: "opacity-0 rotate-180 scale-50",
231
- to: "opacity-100 rotate-0 scale-100",
232
- duration: 400,
233
- easing: "cubic-bezier(0.16,1,0.3,1)"
234
- })
370
+ const { binding, loadErrors, loadedPath } = loadNativeBinding({
371
+ runtimeDir,
372
+ candidates,
373
+ isValid: isAnalyzerModule,
374
+ invalidExportMessage: "Module loaded but missing `analyzeClasses` export."
375
+ });
376
+ bindingCandidateCache = candidates;
377
+ bindingLoadErrorsCache = loadErrors;
378
+ loadedBindingPathCache = loadedPath;
379
+ if (binding) {
380
+ debugLog2(`native binding loaded from: ${loadedPath}`);
381
+ bindingCache = binding;
382
+ return bindingCache;
383
+ }
384
+ if (bindingLoadErrorsCache.length > 0) {
385
+ debugLog2(
386
+ `native binding load failed for ${bindingLoadErrorsCache.length} candidate(s): ${bindingLoadErrorsCache.map((entry) => `${entry.path} (${entry.message})`).join("; ")}`
387
+ );
388
+ } else {
389
+ debugLog2("native binding not found in any candidate path");
390
+ }
391
+ bindingCache = null;
392
+ return bindingCache;
393
+ }
394
+ function requireNativeBinding() {
395
+ const binding = getNativeBinding();
396
+ if (binding?.analyzeClasses) return binding;
397
+ const lines = [
398
+ "Native analyzer binding not found. Ensure `tailwind_styled_parser.node` is built."
399
+ ];
400
+ if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_NO_RUST === "1") {
401
+ lines.push("Native loading is disabled by TWS_NO_NATIVE/TWS_NO_RUST.");
402
+ } else {
403
+ lines.push("Checked paths:");
404
+ for (const candidate of bindingCandidateCache) lines.push(`- ${candidate}`);
405
+ if (bindingLoadErrorsCache.length > 0) {
406
+ lines.push("Load errors:");
407
+ for (const failure of bindingLoadErrorsCache) {
408
+ lines.push(`- ${failure.path}: ${failure.message}`);
409
+ }
410
+ }
411
+ }
412
+ throw new Error(lines.join("\n"));
413
+ }
414
+ function requireNativeCssCompiler() {
415
+ const binding = requireNativeBinding();
416
+ if (typeof binding.compileCss === "function") return binding;
417
+ const loadedPathText = loadedBindingPathCache ? ` (${loadedBindingPathCache})` : "";
418
+ throw new Error(`Native analyzer compileCss binding is missing in v5${loadedPathText}.`);
419
+ }
420
+ function normalizeClassInput(input) {
421
+ if (typeof input === "string") {
422
+ return input.split(/\s+/).map((item) => item.trim()).filter((item) => item.length > 0);
423
+ }
424
+ if (!Array.isArray(input)) {
425
+ throw new TypeError("classToCss input must be a string or an array of strings.");
426
+ }
427
+ const out = [];
428
+ for (const item of input) {
429
+ if (typeof item !== "string") {
430
+ throw new TypeError("classToCss input array must contain only strings.");
431
+ }
432
+ const value = item.trim();
433
+ if (value.length > 0) out.push(value);
434
+ }
435
+ return out;
436
+ }
437
+ function normalizeClassToCssOptions(options) {
438
+ if (!options || typeof options !== "object" || Array.isArray(options)) {
439
+ throw new TypeError("classToCss options must be an object.");
440
+ }
441
+ const strict = options.strict ?? false;
442
+ if (typeof strict !== "boolean") {
443
+ throw new TypeError("classToCss options.strict must be a boolean when provided.");
444
+ }
445
+ const prefix = options.prefix ?? null;
446
+ if (prefix !== null && typeof prefix !== "string") {
447
+ throw new TypeError("classToCss options.prefix must be a string or null when provided.");
448
+ }
449
+ return { prefix, strict };
450
+ }
451
+ function mergeDeclarationMap(target, css) {
452
+ const ruleRegex = /\{([^}]*)\}/g;
453
+ let ruleMatch = ruleRegex.exec(css);
454
+ while (ruleMatch) {
455
+ const body = ruleMatch[1];
456
+ for (const raw of body.split(";")) {
457
+ const declaration = raw.trim();
458
+ if (declaration.length === 0) continue;
459
+ const colonIndex = declaration.indexOf(":");
460
+ if (colonIndex <= 0) continue;
461
+ const property = declaration.slice(0, colonIndex).trim();
462
+ const value = declaration.slice(colonIndex + 1).trim();
463
+ if (property.length === 0 || value.length === 0) continue;
464
+ if (target.has(property)) target.delete(property);
465
+ target.set(property, value);
466
+ }
467
+ ruleMatch = ruleRegex.exec(css);
468
+ }
469
+ }
470
+ function declarationMapToString(declarationMap) {
471
+ return Array.from(declarationMap.entries()).map(([property, value]) => `${property}: ${value}`).join("; ");
472
+ }
473
+ async function classToCss(input, options = {}) {
474
+ const inputClasses = normalizeClassInput(input);
475
+ const normalizedOptions = normalizeClassToCssOptions(options);
476
+ if (inputClasses.length === 0) {
477
+ return {
478
+ inputClasses: [],
479
+ css: "",
480
+ declarations: "",
481
+ resolvedClasses: [],
482
+ unknownClasses: [],
483
+ sizeBytes: 0
484
+ };
485
+ }
486
+ const binding = requireNativeCssCompiler();
487
+ const prefix = normalizedOptions.prefix;
488
+ const cssChunks = [];
489
+ const resolvedClasses = [];
490
+ const unknownClasses = [];
491
+ let sizeBytes = 0;
492
+ const declarationMap = /* @__PURE__ */ new Map();
493
+ for (const className of inputClasses) {
494
+ let compiled = null;
495
+ try {
496
+ compiled = binding.compileCss([className], prefix);
497
+ } catch (error) {
498
+ throw new Error(
499
+ `Native analyzer failed while compiling class "${className}": ${formatErrorMessage2(error)}`,
500
+ { cause: error }
501
+ );
502
+ }
503
+ if (!compiled) {
504
+ throw new Error(`Native analyzer returned no result for class "${className}".`);
505
+ }
506
+ cssChunks.push(compiled.css);
507
+ resolvedClasses.push(...compiled.resolvedClasses);
508
+ unknownClasses.push(...compiled.unknownClasses);
509
+ sizeBytes += compiled.sizeBytes;
510
+ mergeDeclarationMap(declarationMap, compiled.css);
511
+ }
512
+ const uniqueUnknown = Array.from(new Set(unknownClasses));
513
+ if (normalizedOptions.strict && uniqueUnknown.length > 0) {
514
+ throw new Error(`Unknown Tailwind classes: ${uniqueUnknown.join(", ")}`);
515
+ }
516
+ return {
517
+ inputClasses,
518
+ css: cssChunks.filter((chunk) => chunk.length > 0).join("\n"),
519
+ declarations: declarationMapToString(declarationMap),
520
+ resolvedClasses: Array.from(new Set(resolvedClasses)),
521
+ unknownClasses: uniqueUnknown,
522
+ sizeBytes
523
+ };
524
+ }
525
+
526
+ // ../animate/src/registry.ts
527
+ var DEFAULT_DURATION = 300;
528
+ var DEFAULT_EASING = "ease-out";
529
+ var DEFAULT_DELAY = 0;
530
+ var DEFAULT_FILL = "both";
531
+ var DEFAULT_ITERATIONS = 1;
532
+ var DEFAULT_DIRECTION = "normal";
533
+ var DEFAULT_CACHE_LIMIT = 512;
534
+ function normalizeNumber(value, fallback) {
535
+ if (!Number.isFinite(value)) return fallback;
536
+ return Math.max(0, Math.trunc(value));
537
+ }
538
+ function normalizeCacheLimit(value) {
539
+ if (!Number.isFinite(value)) return DEFAULT_CACHE_LIMIT;
540
+ return Math.max(1, Math.trunc(value));
541
+ }
542
+ function normalizeIterations(value) {
543
+ if (value === "infinite") return "infinite";
544
+ if (!Number.isFinite(value)) return String(DEFAULT_ITERATIONS);
545
+ return String(Math.max(0, Math.trunc(value)));
546
+ }
547
+ function stableKeyframesEntries(stops) {
548
+ return Object.entries(stops).map(([offset, classes]) => ({ offset, classes })).sort((left, right) => left.offset.localeCompare(right.offset));
549
+ }
550
+ function animationCacheKey(opts) {
551
+ const normalized = {
552
+ from: opts.from.trim(),
553
+ to: opts.to.trim(),
554
+ duration: normalizeNumber(opts.duration, DEFAULT_DURATION),
555
+ easing: (opts.easing ?? DEFAULT_EASING).trim(),
556
+ delay: normalizeNumber(opts.delay, DEFAULT_DELAY),
557
+ fill: opts.fill ?? DEFAULT_FILL,
558
+ iterations: normalizeIterations(opts.iterations),
559
+ direction: opts.direction ?? DEFAULT_DIRECTION,
560
+ name: opts.name ?? ""
561
+ };
562
+ return JSON.stringify(normalized);
563
+ }
564
+ function keyframesCacheKey(name, stops) {
565
+ return `${name}::${JSON.stringify(stableKeyframesEntries(stops))}`;
566
+ }
567
+ function splitClasses(classList) {
568
+ return classList.split(/\s+/).map((item) => item.trim()).filter((item) => item.length > 0);
569
+ }
570
+ async function validateTailwindClasses(entries) {
571
+ const binding = await getAnimateBinding();
572
+ const unknownByContext = /* @__PURE__ */ new Map();
573
+ const failures = [];
574
+ for (const entry of entries) {
575
+ const classes = splitClasses(entry.classList);
576
+ if (classes.length === 0) continue;
577
+ try {
578
+ if (typeof binding.compileCss === "function") {
579
+ const compiled = binding.compileCss(classes, null);
580
+ if (!compiled) {
581
+ failures.push(`Animation ${entry.context} failed validation: native compileCss returned no result.`);
582
+ continue;
583
+ }
584
+ if (compiled.unknownClasses.length > 0) {
585
+ const bucket = unknownByContext.get(entry.context) ?? /* @__PURE__ */ new Set();
586
+ for (const className of compiled.unknownClasses) bucket.add(className);
587
+ unknownByContext.set(entry.context, bucket);
588
+ }
589
+ continue;
590
+ }
591
+ const checked = await classToCss(classes, { strict: false });
592
+ if (checked.unknownClasses.length > 0) {
593
+ const bucket = unknownByContext.get(entry.context) ?? /* @__PURE__ */ new Set();
594
+ for (const className of checked.unknownClasses) bucket.add(className);
595
+ unknownByContext.set(entry.context, bucket);
596
+ }
597
+ } catch (error) {
598
+ failures.push(`Animation ${entry.context} failed validation: ${formatErrorMessage(error)}`);
599
+ }
600
+ }
601
+ const issues = [];
602
+ for (const [context, classes] of unknownByContext.entries()) {
603
+ issues.push(`Animation ${context} contains unknown Tailwind classes: ${Array.from(classes).join(", ")}`);
604
+ }
605
+ issues.push(...failures);
606
+ if (issues.length > 0) {
607
+ throw new Error(issues.join("\n"));
608
+ }
609
+ }
610
+ var AnimationRegistry = class {
611
+ constructor(options = {}) {
612
+ const cacheLimit = normalizeCacheLimit(options.cacheLimit);
613
+ this.animations = new LRUCache(cacheLimit);
614
+ this.animationBySignature = new LRUCache(cacheLimit);
615
+ this.keyframesBySignature = new LRUCache(cacheLimit);
616
+ }
617
+ async compileAnimation(opts) {
618
+ const signature = animationCacheKey(opts);
619
+ const existingClassName = this.animationBySignature.get(signature);
620
+ if (existingClassName) {
621
+ const cached = this.animations.get(existingClassName);
622
+ if (cached) return cached;
623
+ this.animationBySignature.delete(signature);
624
+ }
625
+ await validateTailwindClasses([
626
+ { classList: opts.from, context: `"from" in ${opts.name ?? "anonymous animation"}` },
627
+ { classList: opts.to, context: `"to" in ${opts.name ?? "anonymous animation"}` }
628
+ ]);
629
+ const binding = await getAnimateBinding();
630
+ const duration = normalizeNumber(opts.duration, DEFAULT_DURATION);
631
+ const easing = opts.easing ?? DEFAULT_EASING;
632
+ const delay = normalizeNumber(opts.delay, DEFAULT_DELAY);
633
+ const fill = opts.fill ?? DEFAULT_FILL;
634
+ const iterations = normalizeIterations(opts.iterations);
635
+ const direction = opts.direction ?? DEFAULT_DIRECTION;
636
+ const compiled = binding.compileAnimation?.(
637
+ opts.from,
638
+ opts.to,
639
+ opts.name ?? null,
640
+ duration,
641
+ easing,
642
+ delay,
643
+ fill,
644
+ iterations,
645
+ direction
646
+ );
647
+ if (!compiled) {
648
+ throw new Error(
649
+ `Native animate backend failed to compile animation "${opts.name ?? "anonymous animation"}".`
650
+ );
651
+ }
652
+ const result = {
653
+ className: compiled.className,
654
+ keyframesCss: compiled.keyframesCss,
655
+ animationCss: compiled.animationCss
656
+ };
657
+ this.animations.set(result.className, result);
658
+ this.animationBySignature.set(signature, result.className);
659
+ return result;
660
+ }
661
+ async compileKeyframes(name, stops) {
662
+ const signature = keyframesCacheKey(name, stops);
663
+ const existingClassName = this.keyframesBySignature.get(signature);
664
+ if (existingClassName) {
665
+ const cached = this.animations.get(existingClassName);
666
+ if (cached) return cached;
667
+ this.keyframesBySignature.delete(signature);
668
+ }
669
+ await validateTailwindClasses(
670
+ Object.entries(stops).map(([offset, classes]) => ({
671
+ classList: classes,
672
+ context: `"${offset}" stop in keyframes "${name}"`
673
+ }))
674
+ );
675
+ const binding = await getAnimateBinding();
676
+ const stopsJson = JSON.stringify(stableKeyframesEntries(stops));
677
+ const compiled = binding.compileKeyframes?.(name, stopsJson);
678
+ if (!compiled) {
679
+ throw new Error(`Native animate backend failed to compile keyframes "${name}".`);
680
+ }
681
+ const result = {
682
+ className: compiled.className,
683
+ keyframesCss: compiled.keyframesCss,
684
+ animationCss: compiled.animationCss
685
+ };
686
+ this.animations.set(result.className, result);
687
+ this.keyframesBySignature.set(signature, result.className);
688
+ return result;
689
+ }
690
+ extractCss() {
691
+ const lines = [];
692
+ for (const [, compiled] of this.animations.entries()) {
693
+ lines.push(compiled.keyframesCss);
694
+ lines.push(`.${compiled.className} { ${compiled.animationCss} }`);
695
+ }
696
+ return lines.join("\n\n");
697
+ }
698
+ reset() {
699
+ this.animations.clear();
700
+ this.animationBySignature.clear();
701
+ this.keyframesBySignature.clear();
702
+ }
703
+ has(className) {
704
+ return this.animations.has(className);
705
+ }
235
706
  };
236
- function extractAnimationCss() {
237
- const lines = [];
238
- for (const [, compiled] of _animRegistry) {
239
- lines.push(compiled.keyframesCss);
240
- lines.push(`.${compiled.className} { ${compiled.animationCss} }`);
707
+ function createAnimationRegistry(options = {}) {
708
+ return new AnimationRegistry(options);
709
+ }
710
+
711
+ // ../animate/src/index.ts
712
+ var defaultRegistry = createAnimationRegistry();
713
+ async function initAnimate2() {
714
+ await initAnimate();
715
+ }
716
+ function getDefaultAnimationRegistry() {
717
+ return defaultRegistry;
718
+ }
719
+ async function compileAnimation(opts, registry = defaultRegistry) {
720
+ return registry.compileAnimation(opts);
721
+ }
722
+ async function compileKeyframes(name, stops, registry = defaultRegistry) {
723
+ return registry.compileKeyframes(name, stops);
724
+ }
725
+ async function animate(opts, registry = defaultRegistry) {
726
+ return (await registry.compileAnimation(opts)).className;
727
+ }
728
+ async function keyframes(name, stops, registry = defaultRegistry) {
729
+ return (await registry.compileKeyframes(name, stops)).className;
730
+ }
731
+ function extractAnimationCss(registry = defaultRegistry) {
732
+ return registry.extractCss();
733
+ }
734
+ function resetAnimationRegistry(registry = defaultRegistry) {
735
+ registry.reset();
736
+ }
737
+ function injectAnimationCss(registry = defaultRegistry, options = {}) {
738
+ const targetDocument = options.document ?? (typeof document !== "undefined" ? document : void 0);
739
+ if (!targetDocument) {
740
+ if (options.silent) return;
741
+ throw new Error("injectAnimationCss requires a browser Document.");
742
+ }
743
+ const styleId = options.styleId ?? "__tw_animate_styles__";
744
+ let styleEl = targetDocument.getElementById(styleId);
745
+ if (!styleEl) {
746
+ if (!targetDocument.head) {
747
+ if (options.silent) return;
748
+ throw new Error("injectAnimationCss requires document.head to exist.");
749
+ }
750
+ styleEl = targetDocument.createElement("style");
751
+ styleEl.id = styleId;
752
+ targetDocument.head.appendChild(styleEl);
241
753
  }
242
- return lines.join("\n\n");
754
+ styleEl.textContent = registry.extractCss();
243
755
  }
756
+ var animations = createAnimationPresets(defaultRegistry);
244
757
 
758
+ exports.AnimationRegistry = AnimationRegistry;
245
759
  exports.animate = animate;
246
760
  exports.animations = animations;
247
761
  exports.compileAnimation = compileAnimation;
762
+ exports.compileKeyframes = compileKeyframes;
763
+ exports.createAnimationRegistry = createAnimationRegistry;
248
764
  exports.extractAnimationCss = extractAnimationCss;
249
- exports.getAnimationRegistry = getAnimationRegistry;
765
+ exports.getDefaultAnimationRegistry = getDefaultAnimationRegistry;
766
+ exports.initAnimate = initAnimate2;
767
+ exports.injectAnimationCss = injectAnimationCss;
250
768
  exports.keyframes = keyframes;
769
+ exports.resetAnimationRegistry = resetAnimationRegistry;
251
770
  //# sourceMappingURL=animate.cjs.map
252
771
  //# sourceMappingURL=animate.cjs.map