tailwind-styled-v4 5.0.9 → 5.0.10

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 (137) hide show
  1. package/CHANGELOG.md +15 -1
  2. package/dist/{analyzeWorkspace-DuJKh7Ty.d.mts → analyzeWorkspace-BS5O4rhC.d.mts} +47 -2
  3. package/dist/{analyzeWorkspace-Ct_NTAWt.d.ts → analyzeWorkspace-DDOQdzzI.d.ts} +47 -2
  4. package/dist/analyzer.d.mts +5 -3
  5. package/dist/analyzer.d.ts +5 -3
  6. package/dist/analyzer.js +563 -468
  7. package/dist/analyzer.js.map +1 -1
  8. package/dist/analyzer.mjs +562 -467
  9. package/dist/analyzer.mjs.map +1 -1
  10. package/dist/animate.d.mts +4 -7
  11. package/dist/animate.d.ts +4 -7
  12. package/dist/animate.js +171 -265
  13. package/dist/animate.js.map +1 -1
  14. package/dist/animate.mjs +165 -264
  15. package/dist/animate.mjs.map +1 -1
  16. package/dist/atomic.d.mts +22 -1
  17. package/dist/atomic.d.ts +22 -1
  18. package/dist/atomic.js +221 -165
  19. package/dist/atomic.js.map +1 -1
  20. package/dist/atomic.mjs +200 -165
  21. package/dist/atomic.mjs.map +1 -1
  22. package/dist/cli.d.mts +60 -1
  23. package/dist/cli.d.ts +60 -1
  24. package/dist/cli.js +1261 -1517
  25. package/dist/cli.js.map +1 -1
  26. package/dist/cli.mjs +1238 -1513
  27. package/dist/cli.mjs.map +1 -1
  28. package/dist/compiler.d.mts +38 -7
  29. package/dist/compiler.d.ts +38 -7
  30. package/dist/compiler.js +174 -197
  31. package/dist/compiler.js.map +1 -1
  32. package/dist/compiler.mjs +151 -194
  33. package/dist/compiler.mjs.map +1 -1
  34. package/dist/devtools.js +7 -31
  35. package/dist/devtools.js.map +1 -1
  36. package/dist/devtools.mjs +7 -31
  37. package/dist/devtools.mjs.map +1 -1
  38. package/dist/engine.d.mts +134 -63
  39. package/dist/engine.d.ts +134 -63
  40. package/dist/engine.js +2863 -2482
  41. package/dist/engine.js.map +1 -1
  42. package/dist/engine.mjs +2852 -2485
  43. package/dist/engine.mjs.map +1 -1
  44. package/dist/{index-eWAocnD2.d.mts → index-NDINUhLN.d.mts} +3 -1
  45. package/dist/{index-eWAocnD2.d.ts → index-NDINUhLN.d.ts} +3 -1
  46. package/dist/index.d.mts +45 -32
  47. package/dist/index.d.ts +45 -32
  48. package/dist/index.js +271 -158
  49. package/dist/index.js.map +1 -1
  50. package/dist/index.mjs +251 -158
  51. package/dist/index.mjs.map +1 -1
  52. package/dist/{liveTokenEngine-DSUk88P6.d.ts → liveTokenEngine-CN9ian1R.d.ts} +1 -1
  53. package/dist/{liveTokenEngine-CX5_0c4q.d.mts → liveTokenEngine-DKoWRtqH.d.mts} +1 -1
  54. package/dist/next.js +20 -39
  55. package/dist/next.js.map +1 -1
  56. package/dist/next.mjs +18 -37
  57. package/dist/next.mjs.map +1 -1
  58. package/dist/plugin-api.d.mts +8 -2
  59. package/dist/plugin-api.d.ts +8 -2
  60. package/dist/plugin-api.js +14 -2
  61. package/dist/plugin-api.js.map +1 -1
  62. package/dist/plugin-api.mjs +14 -3
  63. package/dist/plugin-api.mjs.map +1 -1
  64. package/dist/plugin-registry.js +51 -11
  65. package/dist/plugin-registry.js.map +1 -1
  66. package/dist/plugin-registry.mjs +51 -11
  67. package/dist/plugin-registry.mjs.map +1 -1
  68. package/dist/plugin.d.mts +5 -7
  69. package/dist/plugin.d.ts +5 -7
  70. package/dist/plugin.js +16 -15
  71. package/dist/plugin.js.map +1 -1
  72. package/dist/plugin.mjs +16 -16
  73. package/dist/plugin.mjs.map +1 -1
  74. package/dist/rspack.js +17 -38
  75. package/dist/rspack.js.map +1 -1
  76. package/dist/rspack.mjs +15 -36
  77. package/dist/rspack.mjs.map +1 -1
  78. package/dist/runtime.d.mts +2 -2
  79. package/dist/runtime.d.ts +2 -2
  80. package/dist/scanner.d.mts +10 -1
  81. package/dist/scanner.d.ts +10 -1
  82. package/dist/scanner.js +298 -124
  83. package/dist/scanner.js.map +1 -1
  84. package/dist/scanner.mjs +296 -124
  85. package/dist/scanner.mjs.map +1 -1
  86. package/dist/shared.d.mts +1 -1
  87. package/dist/shared.d.ts +1 -1
  88. package/dist/shared.js +104 -176
  89. package/dist/shared.js.map +1 -1
  90. package/dist/shared.mjs +85 -176
  91. package/dist/shared.mjs.map +1 -1
  92. package/dist/storybook-addon.d.mts +1 -1
  93. package/dist/storybook-addon.d.ts +1 -1
  94. package/dist/svelte.d.mts +1 -1
  95. package/dist/svelte.d.ts +1 -1
  96. package/dist/svelte.js +166 -3
  97. package/dist/svelte.js.map +1 -1
  98. package/dist/svelte.mjs +143 -1
  99. package/dist/svelte.mjs.map +1 -1
  100. package/dist/syntax.js +21 -21
  101. package/dist/syntax.js.map +1 -1
  102. package/dist/syntax.mjs +21 -21
  103. package/dist/syntax.mjs.map +1 -1
  104. package/dist/testing.js +9 -1
  105. package/dist/testing.js.map +1 -1
  106. package/dist/testing.mjs +9 -1
  107. package/dist/testing.mjs.map +1 -1
  108. package/dist/theme.d.mts +2 -2
  109. package/dist/theme.d.ts +2 -2
  110. package/dist/theme.js +40 -112
  111. package/dist/theme.js.map +1 -1
  112. package/dist/theme.mjs +37 -110
  113. package/dist/theme.mjs.map +1 -1
  114. package/dist/turbopackLoader.js +79 -124
  115. package/dist/turbopackLoader.js.map +1 -1
  116. package/dist/turbopackLoader.mjs +63 -122
  117. package/dist/turbopackLoader.mjs.map +1 -1
  118. package/dist/tw.js +1256 -1517
  119. package/dist/tw.js.map +1 -1
  120. package/dist/tw.mjs +1236 -1513
  121. package/dist/tw.mjs.map +1 -1
  122. package/dist/vite.js +1783 -823
  123. package/dist/vite.js.map +1 -1
  124. package/dist/vite.mjs +1767 -821
  125. package/dist/vite.mjs.map +1 -1
  126. package/dist/vue.d.mts +1 -1
  127. package/dist/vue.d.ts +1 -1
  128. package/dist/vue.js +165 -4
  129. package/dist/vue.js.map +1 -1
  130. package/dist/vue.mjs +141 -1
  131. package/dist/vue.mjs.map +1 -1
  132. package/dist/webpackLoader.js +65 -108
  133. package/dist/webpackLoader.js.map +1 -1
  134. package/dist/webpackLoader.mjs +45 -104
  135. package/dist/webpackLoader.mjs.map +1 -1
  136. package/native/tailwind-styled-native.node +0 -0
  137. package/package.json +22 -24
package/dist/animate.mjs CHANGED
@@ -1,52 +1,15 @@
1
- import 'fs';
1
+ import 'crypto';
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+ import { fileURLToPath } from 'url';
5
+ import { createRequire } from 'module';
2
6
  import { z } from 'zod';
3
7
 
4
8
  /* tailwind-styled-v4 v5.0.4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
5
9
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
7
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
8
- }) : x)(function(x) {
9
- if (typeof require !== "undefined") return require.apply(this, arguments);
10
- throw Error('Dynamic require of "' + x + '" is not supported');
11
- });
12
10
  var __esm = (fn, res) => function __init() {
13
11
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
14
12
  };
15
-
16
- // packages/domain/shared/src/index.ts
17
- function getNodeModuleRef() {
18
- if (isBrowser) return null;
19
- if (nodeModuleRef !== null) return nodeModuleRef;
20
- try {
21
- const test = typeof __require === "function" ? __require("module") : null;
22
- nodeModuleRef = test;
23
- return test;
24
- } catch {
25
- nodeModuleRef = null;
26
- return null;
27
- }
28
- }
29
- function getNodeFs() {
30
- if (isBrowser) throw new Error("node:fs not available in browser");
31
- const nodeRequire = getNodeModuleRef();
32
- if (!nodeRequire) throw new Error("require not available");
33
- if (!_nodeFs) _nodeFs = nodeRequire.createRequire(import.meta.url)("node:fs");
34
- return _nodeFs;
35
- }
36
- function getNodePath() {
37
- if (isBrowser) throw new Error("node:path not available in browser");
38
- const nodeRequire = getNodeModuleRef();
39
- if (!nodeRequire) throw new Error("require not available");
40
- if (!_nodePath) _nodePath = nodeRequire.createRequire(import.meta.url)("node:path");
41
- return _nodePath;
42
- }
43
- function getNodeUrl() {
44
- if (isBrowser) throw new Error("node:url not available in browser");
45
- const nodeRequire = getNodeModuleRef();
46
- if (!nodeRequire) throw new Error("require not available");
47
- if (!_nodeUrl) _nodeUrl = nodeRequire.createRequire(import.meta.url)("node:url");
48
- return _nodeUrl;
49
- }
50
13
  function createDebugLogger(namespace, label) {
51
14
  const prefix = label ? `[${namespace}:${label}]` : `[${namespace}]`;
52
15
  return (msg) => {
@@ -55,24 +18,19 @@ function createDebugLogger(namespace, label) {
55
18
  }
56
19
  };
57
20
  }
58
- function formatIssuePath(path) {
59
- if (!path || path.length === 0) return "(root)";
60
- return path.map(
21
+ function formatIssuePath(path2) {
22
+ if (!path2 || path2.length === 0) return "(root)";
23
+ return path2.map(
61
24
  (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
62
25
  ).join(".");
63
26
  }
64
27
  function loadNativeBinding(options) {
65
- if (isBrowser) {
66
- return { binding: null, loadErrors: [{ path: "", message: "Native bindings not available in browser" }] };
67
- }
68
28
  const { runtimeDir, candidates, isValid } = options;
69
29
  const loadErrors = [];
70
- const path = getNodePath();
71
- const fs2 = getNodeFs();
72
30
  for (const candidate of candidates) {
73
31
  const candidatePath = path.resolve(runtimeDir, candidate);
74
32
  try {
75
- if (!fs2.existsSync(candidatePath) && !fs2.existsSync(candidatePath + ".node")) {
33
+ if (!fs.existsSync(candidatePath) && !fs.existsSync(candidatePath + ".node")) {
76
34
  continue;
77
35
  }
78
36
  const mod = requireNativeModule(candidatePath);
@@ -86,77 +44,56 @@ function loadNativeBinding(options) {
86
44
  }
87
45
  return { binding: null, loadErrors };
88
46
  }
89
- function getRequire() {
90
- if (isBrowser) return (() => {
91
- throw new Error("require not available in browser");
92
- });
93
- const nodeRequire = getNodeModuleRef();
94
- if (!nodeRequire) return (() => {
95
- throw new Error("require not available");
96
- });
97
- return nodeRequire.createRequire(import.meta.url);
98
- }
99
- function requireNativeModule(path) {
100
- return _require(path);
47
+ function requireNativeModule(p) {
48
+ return _require(p);
101
49
  }
102
50
  function resolveNativeBindingCandidates(options) {
103
- if (isBrowser) return [];
104
- const { runtimeDir, envVarNames = [], includeDefaultCandidates = true, enforceNodeExtensionForEnvPath = false } = options;
51
+ const {
52
+ envVarNames = ["TW_NATIVE_PATH", "TWS_NATIVE_PATH"],
53
+ includeDefaultCandidates = true,
54
+ enforceNodeExtensionForEnvPath = false
55
+ } = options;
56
+ const runtimeDir = options.runtimeDir || process.cwd();
105
57
  const candidates = [];
106
- const path = getNodePath();
107
- const fs2 = getNodeFs();
108
58
  for (const envVar of envVarNames) {
109
59
  const envPath = process.env[envVar];
110
60
  if (envPath) {
111
- if (enforceNodeExtensionForEnvPath && !envPath.endsWith(".node")) {
112
- candidates.push(envPath + ".node");
113
- } else {
114
- candidates.push(envPath);
115
- }
61
+ candidates.push(enforceNodeExtensionForEnvPath && !envPath.endsWith(".node") ? envPath + ".node" : envPath);
116
62
  }
117
63
  }
118
64
  if (!includeDefaultCandidates) return candidates;
119
- if (fs2.existsSync(runtimeDir)) {
65
+ if (fs.existsSync(runtimeDir)) {
120
66
  try {
121
- const entries = fs2.readdirSync(runtimeDir);
122
- for (const entry of entries) {
123
- if (entry.endsWith(".node")) {
124
- candidates.push(entry);
125
- }
67
+ for (const entry of fs.readdirSync(runtimeDir)) {
68
+ if (entry.endsWith(".node")) candidates.push(entry);
126
69
  }
127
70
  } catch {
128
71
  }
129
72
  }
130
- const platform = typeof process !== "undefined" ? process.platform : "";
131
- const ext = platform === "win32" ? ".dll" : platform === "darwin" ? ".dylib" : ".so";
132
- const defaultBindingName = `tailwind_styled_parser${ext}`;
133
- candidates.push(path.resolve(runtimeDir, "..", "..", "..", "native", defaultBindingName));
134
- candidates.push(path.resolve(runtimeDir, "..", "..", "..", "..", "native", defaultBindingName));
135
- candidates.push(path.resolve(process.cwd(), "native", defaultBindingName));
73
+ const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
74
+ const napiPlatform = process.platform === "linux" && process.arch === "x64" ? "linux-x64-gnu" : process.platform === "linux" && process.arch === "arm64" ? "linux-arm64-gnu" : `${process.platform}-${process.arch}`;
75
+ for (const bin of BINARY_NAMES) {
76
+ candidates.push(path.resolve(runtimeDir, `${bin}.node`));
77
+ candidates.push(path.resolve(runtimeDir, `${bin}.${napiPlatform}.node`));
78
+ candidates.push(path.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.node`));
79
+ candidates.push(path.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.${napiPlatform}.node`));
80
+ candidates.push(path.resolve(runtimeDir, "..", "..", "..", "native", `${bin}.node`));
81
+ candidates.push(path.resolve(process.cwd(), "native", `${bin}.node`));
82
+ candidates.push(path.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
83
+ }
136
84
  return Array.from(new Set(candidates));
137
85
  }
138
86
  function resolveRuntimeDir(dir, importMetaUrl) {
139
- if (isBrowser) return "";
140
- if (dir) return getNodePath().resolve(dir);
87
+ if (dir) return path.resolve(dir);
141
88
  try {
142
- return getNodeUrl().fileURLToPath(importMetaUrl);
89
+ return path.dirname(fileURLToPath(importMetaUrl));
143
90
  } catch {
144
91
  return process.cwd();
145
92
  }
146
93
  }
147
- function formatErrorMessage(error) {
148
- if (error instanceof TwError) return error.toString();
149
- if (error instanceof Error) return error.message;
150
- return String(error);
151
- }
152
- var isBrowser, nodeModuleRef, _nodeFs, _nodePath, _nodeUrl, TwError, _require, LRUCache;
94
+ var TwError, _require, LRUCache;
153
95
  var init_src = __esm({
154
96
  "packages/domain/shared/src/index.ts"() {
155
- isBrowser = typeof window !== "undefined" || typeof document !== "undefined";
156
- nodeModuleRef = null;
157
- _nodeFs = null;
158
- _nodePath = null;
159
- _nodeUrl = null;
160
97
  TwError = class _TwError extends Error {
161
98
  /** @deprecated Gunakan source */
162
99
  domain;
@@ -190,8 +127,8 @@ var init_src = __esm({
190
127
  /** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */
191
128
  static fromZod(err) {
192
129
  const first = err.issues?.[0] ?? err.errors?.[0];
193
- const path = formatIssuePath(first?.path);
194
- const message = first ? `${path}: ${first.message}` : "Schema validation failed";
130
+ const path2 = formatIssuePath(first?.path);
131
+ const message = first ? `${path2}: ${first.message}` : "Schema validation failed";
195
132
  return new _TwError("validation", "SCHEMA_VALIDATION_FAILED", message, err);
196
133
  }
197
134
  static wrap(source, code, err) {
@@ -209,7 +146,7 @@ var init_src = __esm({
209
146
  return `[${this.source.toUpperCase()}:${this.code}] ${this.message}`;
210
147
  }
211
148
  };
212
- _require = getRequire();
149
+ _require = createRequire(import.meta.url);
213
150
  LRUCache = class {
214
151
  capacity;
215
152
  cache;
@@ -439,7 +376,7 @@ init_src();
439
376
  // packages/domain/analyzer/src/utils.ts
440
377
  init_src();
441
378
  var DEBUG_NAMESPACE2 = "tailwind-styled:analyzer";
442
- function formatErrorMessage2(error) {
379
+ function formatErrorMessage(error) {
443
380
  return error instanceof Error ? error.message : String(error);
444
381
  }
445
382
  var debugLog2 = createDebugLogger(DEBUG_NAMESPACE2, "tailwind-styled/analyzer");
@@ -529,7 +466,7 @@ async function requireNativeCssCompiler() {
529
466
 
530
467
  // packages/domain/analyzer/src/schemas.ts
531
468
  init_src();
532
- var formatIssuePath2 = (path) => path.length > 0 ? path.map(
469
+ var formatIssuePath2 = (path2) => path2.length > 0 ? path2.map(
533
470
  (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
534
471
  ).join(".") : "<root>";
535
472
  var isPlainObject = (value) => {
@@ -538,8 +475,8 @@ var isPlainObject = (value) => {
538
475
  return proto === Object.prototype || proto === null;
539
476
  };
540
477
  var formatIssues = (error) => error.issues.map((issue) => {
541
- const path = formatIssuePath2(issue.path);
542
- return `${path}: ${issue.message}`;
478
+ const path2 = formatIssuePath2(issue.path);
479
+ return `${path2}: ${issue.message}`;
543
480
  }).join("; ");
544
481
  var parseWithSchema = (schema, data, label) => {
545
482
  const parsed = schema.safeParse(data);
@@ -633,8 +570,11 @@ var parseNativeCssCompileResult = (result, className) => parseWithSchema(
633
570
  var parseClassToCssOptions = (options) => parseWithSchema(ClassToCssOptionsSchema, options ?? {}, "classToCss options are invalid");
634
571
 
635
572
  // packages/domain/analyzer/src/classToCss.ts
636
- var normalizeClassInput = (input) => {
573
+ var normalizeClassInput = (input, _binding) => {
637
574
  if (typeof input === "string") {
575
+ if (_binding?.normalizeClassInput) {
576
+ return _binding.normalizeClassInput(input);
577
+ }
638
578
  return input.split(/\s+/).map((item) => item.trim()).filter((item) => item.length > 0);
639
579
  }
640
580
  if (!Array.isArray(input)) {
@@ -656,27 +596,26 @@ var normalizeClassToCssOptions = (options) => {
656
596
  const prefix = parsed.prefix ?? null;
657
597
  return { prefix, strict };
658
598
  };
659
- var mergeDeclarationMap = (target, css) => {
660
- for (const ruleMatch of css.matchAll(/\{([^}]*)\}/g)) {
661
- const body = ruleMatch[1];
662
- for (const raw of body.split(";")) {
663
- const declaration = raw.trim();
664
- if (declaration.length === 0) continue;
665
- const colonIndex = declaration.indexOf(":");
666
- if (colonIndex <= 0) continue;
667
- const property = declaration.slice(0, colonIndex).trim();
668
- const value = declaration.slice(colonIndex + 1).trim();
669
- if (property.length === 0 || value.length === 0) continue;
670
- if (target.has(property)) target.delete(property);
671
- target.set(property, value);
672
- }
599
+ var mergeDeclarationMap = (target, css, binding) => {
600
+ if (!binding.parseCssRules) {
601
+ throw new Error("FATAL: Native binding 'parseCssRules' is required but not available.");
602
+ }
603
+ const rules = binding.parseCssRules(css);
604
+ for (const rule of rules) {
605
+ if (target.has(rule.property)) target.delete(rule.property);
606
+ target.set(rule.property, rule.isImportant ? `${rule.value} !important` : rule.value);
673
607
  }
674
608
  };
675
- var declarationMapToString = (declarationMap) => {
676
- return Array.from(declarationMap.entries()).map(([property, value]) => `${property}: ${value}`).join("; ");
609
+ var declarationMapToString = (declarationMap, binding) => {
610
+ const entries = Array.from(declarationMap.entries()).map(([property, value]) => ({ property, value }));
611
+ if (binding?.declarationMapToString) {
612
+ return binding.declarationMapToString(entries);
613
+ }
614
+ return entries.map(({ property, value }) => `${property}: ${value}`).join("; ");
677
615
  };
678
616
  var classToCss = async (input, options = {}) => {
679
- const inputClasses = normalizeClassInput(input);
617
+ const binding = await requireNativeCssCompiler();
618
+ const inputClasses = normalizeClassInput(input, binding);
680
619
  const normalizedOptions = normalizeClassToCssOptions(options);
681
620
  if (inputClasses.length === 0) {
682
621
  return {
@@ -688,7 +627,6 @@ var classToCss = async (input, options = {}) => {
688
627
  sizeBytes: 0
689
628
  };
690
629
  }
691
- const binding = await requireNativeCssCompiler();
692
630
  const prefix = normalizedOptions.prefix;
693
631
  const results = await Promise.all(
694
632
  inputClasses.map(async (className) => {
@@ -697,7 +635,7 @@ var classToCss = async (input, options = {}) => {
697
635
  return binding.compileCss([className], prefix);
698
636
  } catch (error) {
699
637
  throw new Error(
700
- `Native analyzer failed while compiling class "${className}": ${formatErrorMessage2(error)}`,
638
+ `Native analyzer failed while compiling class "${className}": ${formatErrorMessage(error)}`,
701
639
  { cause: error }
702
640
  );
703
641
  }
@@ -721,7 +659,7 @@ var classToCss = async (input, options = {}) => {
721
659
  const sizeBytes = results.reduce((sum, r) => sum + r.sizeBytes, 0);
722
660
  const declarationMap = /* @__PURE__ */ new Map();
723
661
  for (const result of results) {
724
- mergeDeclarationMap(declarationMap, result.css);
662
+ mergeDeclarationMap(declarationMap, result.css, binding);
725
663
  }
726
664
  const uniqueUnknown = Array.from(new Set(unknownClasses));
727
665
  if (normalizedOptions.strict && uniqueUnknown.length > 0) {
@@ -730,7 +668,7 @@ var classToCss = async (input, options = {}) => {
730
668
  return {
731
669
  inputClasses,
732
670
  css: cssChunks.filter((chunk) => chunk.length > 0).join("\n"),
733
- declarations: declarationMapToString(declarationMap),
671
+ declarations: declarationMapToString(declarationMap, binding),
734
672
  resolvedClasses: Array.from(new Set(resolvedClasses)),
735
673
  unknownClasses: uniqueUnknown,
736
674
  sizeBytes
@@ -764,8 +702,8 @@ function stableKeyframesEntries(stops) {
764
702
  }
765
703
  function animationCacheKey(opts) {
766
704
  const normalized = {
767
- from: opts.from.trim(),
768
- to: opts.to.trim(),
705
+ from: (opts.from ?? "").trim(),
706
+ to: (opts.to ?? "").trim(),
769
707
  duration: normalizeNumber(opts.duration, DEFAULT_DURATION),
770
708
  easing: (opts.easing ?? DEFAULT_EASING).trim(),
771
709
  delay: normalizeNumber(opts.delay, DEFAULT_DELAY),
@@ -779,7 +717,10 @@ function animationCacheKey(opts) {
779
717
  function keyframesCacheKey(name, stops) {
780
718
  return `${name}::${JSON.stringify(stableKeyframesEntries(stops))}`;
781
719
  }
782
- function splitClasses(classList) {
720
+ function splitClasses(classList, binding) {
721
+ if (binding?.splitAnimateClasses) {
722
+ return binding.splitAnimateClasses(classList);
723
+ }
783
724
  return classList.split(/\s+/).map((item) => item.trim()).filter((item) => item.length > 0);
784
725
  }
785
726
  async function validateTailwindClasses(entries) {
@@ -787,147 +728,101 @@ async function validateTailwindClasses(entries) {
787
728
  const unknownByContext = /* @__PURE__ */ new Map();
788
729
  const failures = [];
789
730
  for (const entry of entries) {
790
- const classes = splitClasses(entry.classList);
731
+ const classes = splitClasses(entry.classList, binding);
791
732
  if (classes.length === 0) continue;
792
- try {
793
- if (typeof binding.compileCss === "function") {
794
- const compiled = binding.compileCss(classes, null);
795
- if (!compiled) {
796
- failures.push(
797
- `Animation ${entry.context} failed validation: native compileCss returned no result.`
798
- );
799
- continue;
800
- }
801
- if (compiled.unknownClasses.length > 0) {
802
- const bucket = unknownByContext.get(entry.context) ?? /* @__PURE__ */ new Set();
803
- for (const className of compiled.unknownClasses) bucket.add(className);
804
- unknownByContext.set(entry.context, bucket);
805
- }
806
- continue;
807
- }
808
- const checked = await classToCss(classes, { strict: false });
809
- if (checked.unknownClasses.length > 0) {
810
- const bucket = unknownByContext.get(entry.context) ?? /* @__PURE__ */ new Set();
811
- for (const className of checked.unknownClasses) bucket.add(className);
812
- unknownByContext.set(entry.context, bucket);
813
- }
814
- } catch (error) {
815
- failures.push(`Animation ${entry.context} failed validation: ${formatErrorMessage(error)}`);
733
+ const result = await classToCss(classes);
734
+ if (result.unknownClasses.length > 0) {
735
+ unknownByContext.set(entry.context, new Set(result.unknownClasses));
816
736
  }
817
737
  }
818
- const issues = [];
819
- for (const [context, classes] of unknownByContext.entries()) {
820
- issues.push(
821
- `Animation ${context} contains unknown Tailwind classes: ${Array.from(classes).join(", ")}`
822
- );
738
+ for (const [context, unknownSet] of unknownByContext.entries()) {
739
+ failures.push(`[${context}] unknown classes: ${Array.from(unknownSet).join(", ")}`);
823
740
  }
824
- issues.push(...failures);
825
- if (issues.length > 0) {
826
- throw new Error(issues.join("\n"));
741
+ if (failures.length > 0) {
742
+ throw new Error(`Animation validation failed:
743
+ ${failures.join("\n")}`);
827
744
  }
828
745
  }
829
- var AnimationRegistry = class {
830
- animations;
831
- animationBySignature;
832
- keyframesBySignature;
833
- constructor(options = {}) {
834
- const cacheLimit = normalizeCacheLimit(options.cacheLimit);
835
- this.animations = new LRUCache(cacheLimit);
836
- this.animationBySignature = new LRUCache(cacheLimit);
837
- this.keyframesBySignature = new LRUCache(cacheLimit);
838
- }
839
- async compileAnimation(opts) {
840
- const signature = animationCacheKey(opts);
841
- const existingClassName = this.animationBySignature.get(signature);
842
- if (existingClassName) {
843
- const cached = this.animations.get(existingClassName);
746
+ function createAnimationRegistry(options = {}) {
747
+ const cacheLimit = normalizeCacheLimit(options.cacheLimit);
748
+ const cache = new LRUCache(cacheLimit);
749
+ const cssChunks = [];
750
+ const classNames = /* @__PURE__ */ new Set();
751
+ return {
752
+ async compileAnimation(opts) {
753
+ const key = animationCacheKey(opts);
754
+ const cached = cache.get(key);
844
755
  if (cached) return cached;
845
- this.animationBySignature.delete(signature);
846
- }
847
- await validateTailwindClasses([
848
- { classList: opts.from, context: `"from" in ${opts.name ?? "anonymous animation"}` },
849
- { classList: opts.to, context: `"to" in ${opts.name ?? "anonymous animation"}` }
850
- ]);
851
- const binding = await getAnimateBinding();
852
- const duration = normalizeNumber(opts.duration, DEFAULT_DURATION);
853
- const easing = opts.easing ?? DEFAULT_EASING;
854
- const delay = normalizeNumber(opts.delay, DEFAULT_DELAY);
855
- const fill = opts.fill ?? DEFAULT_FILL;
856
- const iterations = normalizeIterations(opts.iterations);
857
- const direction = opts.direction ?? DEFAULT_DIRECTION;
858
- const compiled = binding.compileAnimation?.(
859
- opts.from,
860
- opts.to,
861
- opts.name ?? null,
862
- duration,
863
- easing,
864
- delay,
865
- fill,
866
- iterations,
867
- direction
868
- );
869
- if (!compiled) {
870
- throw new Error(
871
- `Native animate backend failed to compile animation "${opts.name ?? "anonymous animation"}".`
756
+ const binding = await getAnimateBinding();
757
+ const classesToValidate = [
758
+ { classList: opts.from ?? "", context: "from" },
759
+ { classList: opts.to ?? "", context: "to" }
760
+ ].filter((entry) => entry.classList.trim().length > 0);
761
+ if (classesToValidate.length > 0) {
762
+ await validateTailwindClasses(classesToValidate);
763
+ }
764
+ if (!binding.compileAnimation) {
765
+ throw new Error("FATAL: Native binding 'compileAnimation' is required but not available.");
766
+ }
767
+ const result = binding.compileAnimation(
768
+ opts.from,
769
+ opts.to,
770
+ opts.name ?? null,
771
+ normalizeNumber(opts.duration, DEFAULT_DURATION),
772
+ opts.easing ?? DEFAULT_EASING,
773
+ normalizeNumber(opts.delay, DEFAULT_DELAY),
774
+ opts.fill ?? DEFAULT_FILL,
775
+ normalizeIterations(opts.iterations),
776
+ opts.direction ?? DEFAULT_DIRECTION
872
777
  );
873
- }
874
- const result = {
875
- className: compiled.className,
876
- keyframesCss: compiled.keyframesCss,
877
- animationCss: compiled.animationCss
878
- };
879
- this.animations.set(result.className, result);
880
- this.animationBySignature.set(signature, result.className);
881
- return result;
882
- }
883
- async compileKeyframes(name, stops) {
884
- const signature = keyframesCacheKey(name, stops);
885
- const existingClassName = this.keyframesBySignature.get(signature);
886
- if (existingClassName) {
887
- const cached = this.animations.get(existingClassName);
778
+ if (!result) {
779
+ throw new Error(`compileAnimation returned null for opts: ${JSON.stringify(opts)}`);
780
+ }
781
+ const compiled = {
782
+ className: result.className,
783
+ keyframesCss: result.keyframesCss,
784
+ animationCss: result.animationCss
785
+ };
786
+ cache.set(key, compiled);
787
+ if (result.keyframesCss) cssChunks.push(result.keyframesCss);
788
+ if (result.animationCss) cssChunks.push(result.animationCss);
789
+ return compiled;
790
+ },
791
+ async compileKeyframes(name, stops) {
792
+ const key = keyframesCacheKey(name, stops);
793
+ const cached = cache.get(key);
888
794
  if (cached) return cached;
889
- this.keyframesBySignature.delete(signature);
890
- }
891
- await validateTailwindClasses(
892
- Object.entries(stops).map(([offset, classes]) => ({
893
- classList: classes,
894
- context: `"${offset}" stop in keyframes "${name}"`
895
- }))
896
- );
897
- const binding = await getAnimateBinding();
898
- const stopsJson = JSON.stringify(stableKeyframesEntries(stops));
899
- const compiled = binding.compileKeyframes?.(name, stopsJson);
900
- if (!compiled) {
901
- throw new Error(`Native animate backend failed to compile keyframes "${name}".`);
902
- }
903
- const result = {
904
- className: compiled.className,
905
- keyframesCss: compiled.keyframesCss,
906
- animationCss: compiled.animationCss
907
- };
908
- this.animations.set(result.className, result);
909
- this.keyframesBySignature.set(signature, result.className);
910
- return result;
911
- }
912
- extractCss() {
913
- const lines = [];
914
- for (const [, compiled] of this.animations.entries()) {
915
- lines.push(compiled.keyframesCss);
916
- lines.push(`.${compiled.className} { ${compiled.animationCss} }`);
795
+ const binding = await getAnimateBinding();
796
+ const stopsJson = JSON.stringify(stableKeyframesEntries(stops));
797
+ if (!binding.compileKeyframes) {
798
+ throw new Error("FATAL: Native binding 'compileKeyframes' is required but not available.");
799
+ }
800
+ const result = binding.compileKeyframes(name, stopsJson);
801
+ if (!result) {
802
+ throw new Error(`compileKeyframes returned null for name: ${name}`);
803
+ }
804
+ const compiled = {
805
+ className: result.className,
806
+ keyframesCss: result.keyframesCss,
807
+ animationCss: result.animationCss
808
+ };
809
+ cache.set(key, compiled);
810
+ if (result.keyframesCss) cssChunks.push(result.keyframesCss);
811
+ if (result.animationCss) cssChunks.push(result.animationCss);
812
+ return compiled;
813
+ },
814
+ extractCss() {
815
+ return cssChunks.join("\n");
816
+ },
817
+ reset() {
818
+ cache.clear?.();
819
+ cssChunks.length = 0;
820
+ classNames.clear();
821
+ },
822
+ has(className) {
823
+ return classNames.has(className);
917
824
  }
918
- return lines.join("\n\n");
919
- }
920
- reset() {
921
- this.animations.clear();
922
- this.animationBySignature.clear();
923
- this.keyframesBySignature.clear();
924
- }
925
- has(className) {
926
- return this.animations.has(className);
927
- }
928
- };
929
- function createAnimationRegistry(options = {}) {
930
- return new AnimationRegistry(options);
825
+ };
931
826
  }
932
827
 
933
828
  // packages/domain/animate/src/index.ts
@@ -938,8 +833,14 @@ async function initAnimate2() {
938
833
  function getDefaultAnimationRegistry() {
939
834
  return defaultRegistry;
940
835
  }
941
- async function compileAnimation(opts, registry = defaultRegistry) {
942
- return registry.compileAnimation(opts);
836
+ async function compileAnimation(optsOrName, secondArg) {
837
+ if (typeof optsOrName === "string") {
838
+ const partialOpts = secondArg && typeof secondArg.compileAnimation !== "function" ? secondArg : {};
839
+ const opts = { from: "", to: "", ...partialOpts, name: optsOrName };
840
+ return defaultRegistry.compileAnimation(opts);
841
+ }
842
+ const registry = secondArg && typeof secondArg.compileAnimation === "function" ? secondArg : defaultRegistry;
843
+ return registry.compileAnimation(optsOrName);
943
844
  }
944
845
  async function compileKeyframes(name, stops, registry = defaultRegistry) {
945
846
  return registry.compileKeyframes(name, stops);
@@ -980,6 +881,6 @@ function injectAnimationCss(registry = defaultRegistry, options = {}) {
980
881
  }
981
882
  var animations = createAnimationPresets(defaultRegistry);
982
883
 
983
- export { AnimationRegistry, animate, animations, compileAnimation, compileKeyframes, createAnimationRegistry, extractAnimationCss, getDefaultAnimationRegistry, initAnimate2 as initAnimate, injectAnimationCss, keyframes, resetAnimationRegistry };
884
+ export { createAnimationRegistry as AnimationRegistry, animate, animations, compileAnimation, compileKeyframes, createAnimationRegistry, extractAnimationCss, getDefaultAnimationRegistry, initAnimate2 as initAnimate, injectAnimationCss, keyframes, resetAnimationRegistry };
984
885
  //# sourceMappingURL=animate.mjs.map
985
886
  //# sourceMappingURL=animate.mjs.map