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.js CHANGED
@@ -1,55 +1,23 @@
1
1
  'use strict';
2
2
 
3
- require('fs');
3
+ require('crypto');
4
+ var fs = require('fs');
5
+ var path = require('path');
6
+ var url = require('url');
7
+ var module$1 = require('module');
4
8
  var zod = require('zod');
5
9
 
6
10
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
11
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
+
13
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
14
+ var path__default = /*#__PURE__*/_interopDefault(path);
15
+
7
16
  /* tailwind-styled-v4 v5.0.4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
8
17
  var __getOwnPropNames = Object.getOwnPropertyNames;
9
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
10
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
11
- }) : x)(function(x) {
12
- if (typeof require !== "undefined") return require.apply(this, arguments);
13
- throw Error('Dynamic require of "' + x + '" is not supported');
14
- });
15
18
  var __esm = (fn, res) => function __init() {
16
19
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
17
20
  };
18
-
19
- // packages/domain/shared/src/index.ts
20
- function getNodeModuleRef() {
21
- if (isBrowser) return null;
22
- if (nodeModuleRef !== null) return nodeModuleRef;
23
- try {
24
- const test = typeof __require === "function" ? __require("module") : null;
25
- nodeModuleRef = test;
26
- return test;
27
- } catch {
28
- nodeModuleRef = null;
29
- return null;
30
- }
31
- }
32
- function getNodeFs() {
33
- if (isBrowser) throw new Error("node:fs not available in browser");
34
- const nodeRequire = getNodeModuleRef();
35
- if (!nodeRequire) throw new Error("require not available");
36
- if (!_nodeFs) _nodeFs = nodeRequire.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('animate.js', document.baseURI).href)))("node:fs");
37
- return _nodeFs;
38
- }
39
- function getNodePath() {
40
- if (isBrowser) throw new Error("node:path not available in browser");
41
- const nodeRequire = getNodeModuleRef();
42
- if (!nodeRequire) throw new Error("require not available");
43
- if (!_nodePath) _nodePath = nodeRequire.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('animate.js', document.baseURI).href)))("node:path");
44
- return _nodePath;
45
- }
46
- function getNodeUrl() {
47
- if (isBrowser) throw new Error("node:url not available in browser");
48
- const nodeRequire = getNodeModuleRef();
49
- if (!nodeRequire) throw new Error("require not available");
50
- if (!_nodeUrl) _nodeUrl = nodeRequire.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('animate.js', document.baseURI).href)))("node:url");
51
- return _nodeUrl;
52
- }
53
21
  function createDebugLogger(namespace, label) {
54
22
  const prefix = label ? `[${namespace}:${label}]` : `[${namespace}]`;
55
23
  return (msg) => {
@@ -58,24 +26,19 @@ function createDebugLogger(namespace, label) {
58
26
  }
59
27
  };
60
28
  }
61
- function formatIssuePath(path) {
62
- if (!path || path.length === 0) return "(root)";
63
- return path.map(
29
+ function formatIssuePath(path2) {
30
+ if (!path2 || path2.length === 0) return "(root)";
31
+ return path2.map(
64
32
  (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
65
33
  ).join(".");
66
34
  }
67
35
  function loadNativeBinding(options) {
68
- if (isBrowser) {
69
- return { binding: null, loadErrors: [{ path: "", message: "Native bindings not available in browser" }] };
70
- }
71
36
  const { runtimeDir, candidates, isValid } = options;
72
37
  const loadErrors = [];
73
- const path = getNodePath();
74
- const fs2 = getNodeFs();
75
38
  for (const candidate of candidates) {
76
- const candidatePath = path.resolve(runtimeDir, candidate);
39
+ const candidatePath = path__default.default.resolve(runtimeDir, candidate);
77
40
  try {
78
- if (!fs2.existsSync(candidatePath) && !fs2.existsSync(candidatePath + ".node")) {
41
+ if (!fs__default.default.existsSync(candidatePath) && !fs__default.default.existsSync(candidatePath + ".node")) {
79
42
  continue;
80
43
  }
81
44
  const mod = requireNativeModule(candidatePath);
@@ -89,77 +52,56 @@ function loadNativeBinding(options) {
89
52
  }
90
53
  return { binding: null, loadErrors };
91
54
  }
92
- function getRequire() {
93
- if (isBrowser) return (() => {
94
- throw new Error("require not available in browser");
95
- });
96
- const nodeRequire = getNodeModuleRef();
97
- if (!nodeRequire) return (() => {
98
- throw new Error("require not available");
99
- });
100
- return nodeRequire.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('animate.js', document.baseURI).href)));
101
- }
102
- function requireNativeModule(path) {
103
- return _require(path);
55
+ function requireNativeModule(p) {
56
+ return _require(p);
104
57
  }
105
58
  function resolveNativeBindingCandidates(options) {
106
- if (isBrowser) return [];
107
- const { runtimeDir, envVarNames = [], includeDefaultCandidates = true, enforceNodeExtensionForEnvPath = false } = options;
59
+ const {
60
+ envVarNames = ["TW_NATIVE_PATH", "TWS_NATIVE_PATH"],
61
+ includeDefaultCandidates = true,
62
+ enforceNodeExtensionForEnvPath = false
63
+ } = options;
64
+ const runtimeDir = options.runtimeDir || process.cwd();
108
65
  const candidates = [];
109
- const path = getNodePath();
110
- const fs2 = getNodeFs();
111
66
  for (const envVar of envVarNames) {
112
67
  const envPath = process.env[envVar];
113
68
  if (envPath) {
114
- if (enforceNodeExtensionForEnvPath && !envPath.endsWith(".node")) {
115
- candidates.push(envPath + ".node");
116
- } else {
117
- candidates.push(envPath);
118
- }
69
+ candidates.push(enforceNodeExtensionForEnvPath && !envPath.endsWith(".node") ? envPath + ".node" : envPath);
119
70
  }
120
71
  }
121
72
  if (!includeDefaultCandidates) return candidates;
122
- if (fs2.existsSync(runtimeDir)) {
73
+ if (fs__default.default.existsSync(runtimeDir)) {
123
74
  try {
124
- const entries = fs2.readdirSync(runtimeDir);
125
- for (const entry of entries) {
126
- if (entry.endsWith(".node")) {
127
- candidates.push(entry);
128
- }
75
+ for (const entry of fs__default.default.readdirSync(runtimeDir)) {
76
+ if (entry.endsWith(".node")) candidates.push(entry);
129
77
  }
130
78
  } catch {
131
79
  }
132
80
  }
133
- const platform = typeof process !== "undefined" ? process.platform : "";
134
- const ext = platform === "win32" ? ".dll" : platform === "darwin" ? ".dylib" : ".so";
135
- const defaultBindingName = `tailwind_styled_parser${ext}`;
136
- candidates.push(path.resolve(runtimeDir, "..", "..", "..", "native", defaultBindingName));
137
- candidates.push(path.resolve(runtimeDir, "..", "..", "..", "..", "native", defaultBindingName));
138
- candidates.push(path.resolve(process.cwd(), "native", defaultBindingName));
81
+ const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
82
+ const napiPlatform = process.platform === "linux" && process.arch === "x64" ? "linux-x64-gnu" : process.platform === "linux" && process.arch === "arm64" ? "linux-arm64-gnu" : `${process.platform}-${process.arch}`;
83
+ for (const bin of BINARY_NAMES) {
84
+ candidates.push(path__default.default.resolve(runtimeDir, `${bin}.node`));
85
+ candidates.push(path__default.default.resolve(runtimeDir, `${bin}.${napiPlatform}.node`));
86
+ candidates.push(path__default.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.node`));
87
+ candidates.push(path__default.default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.${napiPlatform}.node`));
88
+ candidates.push(path__default.default.resolve(runtimeDir, "..", "..", "..", "native", `${bin}.node`));
89
+ candidates.push(path__default.default.resolve(process.cwd(), "native", `${bin}.node`));
90
+ candidates.push(path__default.default.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
91
+ }
139
92
  return Array.from(new Set(candidates));
140
93
  }
141
94
  function resolveRuntimeDir(dir, importMetaUrl) {
142
- if (isBrowser) return "";
143
- if (dir) return getNodePath().resolve(dir);
95
+ if (dir) return path__default.default.resolve(dir);
144
96
  try {
145
- return getNodeUrl().fileURLToPath(importMetaUrl);
97
+ return path__default.default.dirname(url.fileURLToPath(importMetaUrl));
146
98
  } catch {
147
99
  return process.cwd();
148
100
  }
149
101
  }
150
- function formatErrorMessage(error) {
151
- if (error instanceof TwError) return error.toString();
152
- if (error instanceof Error) return error.message;
153
- return String(error);
154
- }
155
- var isBrowser, nodeModuleRef, _nodeFs, _nodePath, _nodeUrl, TwError, _require, LRUCache;
102
+ var TwError, _require, LRUCache;
156
103
  var init_src = __esm({
157
104
  "packages/domain/shared/src/index.ts"() {
158
- isBrowser = typeof window !== "undefined" || typeof document !== "undefined";
159
- nodeModuleRef = null;
160
- _nodeFs = null;
161
- _nodePath = null;
162
- _nodeUrl = null;
163
105
  TwError = class _TwError extends Error {
164
106
  /** @deprecated Gunakan source */
165
107
  domain;
@@ -193,8 +135,8 @@ var init_src = __esm({
193
135
  /** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */
194
136
  static fromZod(err) {
195
137
  const first = err.issues?.[0] ?? err.errors?.[0];
196
- const path = formatIssuePath(first?.path);
197
- const message = first ? `${path}: ${first.message}` : "Schema validation failed";
138
+ const path2 = formatIssuePath(first?.path);
139
+ const message = first ? `${path2}: ${first.message}` : "Schema validation failed";
198
140
  return new _TwError("validation", "SCHEMA_VALIDATION_FAILED", message, err);
199
141
  }
200
142
  static wrap(source, code, err) {
@@ -212,7 +154,7 @@ var init_src = __esm({
212
154
  return `[${this.source.toUpperCase()}:${this.code}] ${this.message}`;
213
155
  }
214
156
  };
215
- _require = getRequire();
157
+ _require = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('animate.js', document.baseURI).href)));
216
158
  LRUCache = class {
217
159
  capacity;
218
160
  cache;
@@ -442,7 +384,7 @@ init_src();
442
384
  // packages/domain/analyzer/src/utils.ts
443
385
  init_src();
444
386
  var DEBUG_NAMESPACE2 = "tailwind-styled:analyzer";
445
- function formatErrorMessage2(error) {
387
+ function formatErrorMessage(error) {
446
388
  return error instanceof Error ? error.message : String(error);
447
389
  }
448
390
  var debugLog2 = createDebugLogger(DEBUG_NAMESPACE2, "tailwind-styled/analyzer");
@@ -532,7 +474,7 @@ async function requireNativeCssCompiler() {
532
474
 
533
475
  // packages/domain/analyzer/src/schemas.ts
534
476
  init_src();
535
- var formatIssuePath2 = (path) => path.length > 0 ? path.map(
477
+ var formatIssuePath2 = (path2) => path2.length > 0 ? path2.map(
536
478
  (segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
537
479
  ).join(".") : "<root>";
538
480
  var isPlainObject = (value) => {
@@ -541,8 +483,8 @@ var isPlainObject = (value) => {
541
483
  return proto === Object.prototype || proto === null;
542
484
  };
543
485
  var formatIssues = (error) => error.issues.map((issue) => {
544
- const path = formatIssuePath2(issue.path);
545
- return `${path}: ${issue.message}`;
486
+ const path2 = formatIssuePath2(issue.path);
487
+ return `${path2}: ${issue.message}`;
546
488
  }).join("; ");
547
489
  var parseWithSchema = (schema, data, label) => {
548
490
  const parsed = schema.safeParse(data);
@@ -636,8 +578,11 @@ var parseNativeCssCompileResult = (result, className) => parseWithSchema(
636
578
  var parseClassToCssOptions = (options) => parseWithSchema(ClassToCssOptionsSchema, options ?? {}, "classToCss options are invalid");
637
579
 
638
580
  // packages/domain/analyzer/src/classToCss.ts
639
- var normalizeClassInput = (input) => {
581
+ var normalizeClassInput = (input, _binding) => {
640
582
  if (typeof input === "string") {
583
+ if (_binding?.normalizeClassInput) {
584
+ return _binding.normalizeClassInput(input);
585
+ }
641
586
  return input.split(/\s+/).map((item) => item.trim()).filter((item) => item.length > 0);
642
587
  }
643
588
  if (!Array.isArray(input)) {
@@ -659,27 +604,26 @@ var normalizeClassToCssOptions = (options) => {
659
604
  const prefix = parsed.prefix ?? null;
660
605
  return { prefix, strict };
661
606
  };
662
- var mergeDeclarationMap = (target, css) => {
663
- for (const ruleMatch of css.matchAll(/\{([^}]*)\}/g)) {
664
- const body = ruleMatch[1];
665
- for (const raw of body.split(";")) {
666
- const declaration = raw.trim();
667
- if (declaration.length === 0) continue;
668
- const colonIndex = declaration.indexOf(":");
669
- if (colonIndex <= 0) continue;
670
- const property = declaration.slice(0, colonIndex).trim();
671
- const value = declaration.slice(colonIndex + 1).trim();
672
- if (property.length === 0 || value.length === 0) continue;
673
- if (target.has(property)) target.delete(property);
674
- target.set(property, value);
675
- }
607
+ var mergeDeclarationMap = (target, css, binding) => {
608
+ if (!binding.parseCssRules) {
609
+ throw new Error("FATAL: Native binding 'parseCssRules' is required but not available.");
610
+ }
611
+ const rules = binding.parseCssRules(css);
612
+ for (const rule of rules) {
613
+ if (target.has(rule.property)) target.delete(rule.property);
614
+ target.set(rule.property, rule.isImportant ? `${rule.value} !important` : rule.value);
676
615
  }
677
616
  };
678
- var declarationMapToString = (declarationMap) => {
679
- return Array.from(declarationMap.entries()).map(([property, value]) => `${property}: ${value}`).join("; ");
617
+ var declarationMapToString = (declarationMap, binding) => {
618
+ const entries = Array.from(declarationMap.entries()).map(([property, value]) => ({ property, value }));
619
+ if (binding?.declarationMapToString) {
620
+ return binding.declarationMapToString(entries);
621
+ }
622
+ return entries.map(({ property, value }) => `${property}: ${value}`).join("; ");
680
623
  };
681
624
  var classToCss = async (input, options = {}) => {
682
- const inputClasses = normalizeClassInput(input);
625
+ const binding = await requireNativeCssCompiler();
626
+ const inputClasses = normalizeClassInput(input, binding);
683
627
  const normalizedOptions = normalizeClassToCssOptions(options);
684
628
  if (inputClasses.length === 0) {
685
629
  return {
@@ -691,7 +635,6 @@ var classToCss = async (input, options = {}) => {
691
635
  sizeBytes: 0
692
636
  };
693
637
  }
694
- const binding = await requireNativeCssCompiler();
695
638
  const prefix = normalizedOptions.prefix;
696
639
  const results = await Promise.all(
697
640
  inputClasses.map(async (className) => {
@@ -700,7 +643,7 @@ var classToCss = async (input, options = {}) => {
700
643
  return binding.compileCss([className], prefix);
701
644
  } catch (error) {
702
645
  throw new Error(
703
- `Native analyzer failed while compiling class "${className}": ${formatErrorMessage2(error)}`,
646
+ `Native analyzer failed while compiling class "${className}": ${formatErrorMessage(error)}`,
704
647
  { cause: error }
705
648
  );
706
649
  }
@@ -724,7 +667,7 @@ var classToCss = async (input, options = {}) => {
724
667
  const sizeBytes = results.reduce((sum, r) => sum + r.sizeBytes, 0);
725
668
  const declarationMap = /* @__PURE__ */ new Map();
726
669
  for (const result of results) {
727
- mergeDeclarationMap(declarationMap, result.css);
670
+ mergeDeclarationMap(declarationMap, result.css, binding);
728
671
  }
729
672
  const uniqueUnknown = Array.from(new Set(unknownClasses));
730
673
  if (normalizedOptions.strict && uniqueUnknown.length > 0) {
@@ -733,7 +676,7 @@ var classToCss = async (input, options = {}) => {
733
676
  return {
734
677
  inputClasses,
735
678
  css: cssChunks.filter((chunk) => chunk.length > 0).join("\n"),
736
- declarations: declarationMapToString(declarationMap),
679
+ declarations: declarationMapToString(declarationMap, binding),
737
680
  resolvedClasses: Array.from(new Set(resolvedClasses)),
738
681
  unknownClasses: uniqueUnknown,
739
682
  sizeBytes
@@ -767,8 +710,8 @@ function stableKeyframesEntries(stops) {
767
710
  }
768
711
  function animationCacheKey(opts) {
769
712
  const normalized = {
770
- from: opts.from.trim(),
771
- to: opts.to.trim(),
713
+ from: (opts.from ?? "").trim(),
714
+ to: (opts.to ?? "").trim(),
772
715
  duration: normalizeNumber(opts.duration, DEFAULT_DURATION),
773
716
  easing: (opts.easing ?? DEFAULT_EASING).trim(),
774
717
  delay: normalizeNumber(opts.delay, DEFAULT_DELAY),
@@ -782,7 +725,10 @@ function animationCacheKey(opts) {
782
725
  function keyframesCacheKey(name, stops) {
783
726
  return `${name}::${JSON.stringify(stableKeyframesEntries(stops))}`;
784
727
  }
785
- function splitClasses(classList) {
728
+ function splitClasses(classList, binding) {
729
+ if (binding?.splitAnimateClasses) {
730
+ return binding.splitAnimateClasses(classList);
731
+ }
786
732
  return classList.split(/\s+/).map((item) => item.trim()).filter((item) => item.length > 0);
787
733
  }
788
734
  async function validateTailwindClasses(entries) {
@@ -790,147 +736,101 @@ async function validateTailwindClasses(entries) {
790
736
  const unknownByContext = /* @__PURE__ */ new Map();
791
737
  const failures = [];
792
738
  for (const entry of entries) {
793
- const classes = splitClasses(entry.classList);
739
+ const classes = splitClasses(entry.classList, binding);
794
740
  if (classes.length === 0) continue;
795
- try {
796
- if (typeof binding.compileCss === "function") {
797
- const compiled = binding.compileCss(classes, null);
798
- if (!compiled) {
799
- failures.push(
800
- `Animation ${entry.context} failed validation: native compileCss returned no result.`
801
- );
802
- continue;
803
- }
804
- if (compiled.unknownClasses.length > 0) {
805
- const bucket = unknownByContext.get(entry.context) ?? /* @__PURE__ */ new Set();
806
- for (const className of compiled.unknownClasses) bucket.add(className);
807
- unknownByContext.set(entry.context, bucket);
808
- }
809
- continue;
810
- }
811
- const checked = await classToCss(classes, { strict: false });
812
- if (checked.unknownClasses.length > 0) {
813
- const bucket = unknownByContext.get(entry.context) ?? /* @__PURE__ */ new Set();
814
- for (const className of checked.unknownClasses) bucket.add(className);
815
- unknownByContext.set(entry.context, bucket);
816
- }
817
- } catch (error) {
818
- failures.push(`Animation ${entry.context} failed validation: ${formatErrorMessage(error)}`);
741
+ const result = await classToCss(classes);
742
+ if (result.unknownClasses.length > 0) {
743
+ unknownByContext.set(entry.context, new Set(result.unknownClasses));
819
744
  }
820
745
  }
821
- const issues = [];
822
- for (const [context, classes] of unknownByContext.entries()) {
823
- issues.push(
824
- `Animation ${context} contains unknown Tailwind classes: ${Array.from(classes).join(", ")}`
825
- );
746
+ for (const [context, unknownSet] of unknownByContext.entries()) {
747
+ failures.push(`[${context}] unknown classes: ${Array.from(unknownSet).join(", ")}`);
826
748
  }
827
- issues.push(...failures);
828
- if (issues.length > 0) {
829
- throw new Error(issues.join("\n"));
749
+ if (failures.length > 0) {
750
+ throw new Error(`Animation validation failed:
751
+ ${failures.join("\n")}`);
830
752
  }
831
753
  }
832
- var AnimationRegistry = class {
833
- animations;
834
- animationBySignature;
835
- keyframesBySignature;
836
- constructor(options = {}) {
837
- const cacheLimit = normalizeCacheLimit(options.cacheLimit);
838
- this.animations = new LRUCache(cacheLimit);
839
- this.animationBySignature = new LRUCache(cacheLimit);
840
- this.keyframesBySignature = new LRUCache(cacheLimit);
841
- }
842
- async compileAnimation(opts) {
843
- const signature = animationCacheKey(opts);
844
- const existingClassName = this.animationBySignature.get(signature);
845
- if (existingClassName) {
846
- const cached = this.animations.get(existingClassName);
754
+ function createAnimationRegistry(options = {}) {
755
+ const cacheLimit = normalizeCacheLimit(options.cacheLimit);
756
+ const cache = new LRUCache(cacheLimit);
757
+ const cssChunks = [];
758
+ const classNames = /* @__PURE__ */ new Set();
759
+ return {
760
+ async compileAnimation(opts) {
761
+ const key = animationCacheKey(opts);
762
+ const cached = cache.get(key);
847
763
  if (cached) return cached;
848
- this.animationBySignature.delete(signature);
849
- }
850
- await validateTailwindClasses([
851
- { classList: opts.from, context: `"from" in ${opts.name ?? "anonymous animation"}` },
852
- { classList: opts.to, context: `"to" in ${opts.name ?? "anonymous animation"}` }
853
- ]);
854
- const binding = await getAnimateBinding();
855
- const duration = normalizeNumber(opts.duration, DEFAULT_DURATION);
856
- const easing = opts.easing ?? DEFAULT_EASING;
857
- const delay = normalizeNumber(opts.delay, DEFAULT_DELAY);
858
- const fill = opts.fill ?? DEFAULT_FILL;
859
- const iterations = normalizeIterations(opts.iterations);
860
- const direction = opts.direction ?? DEFAULT_DIRECTION;
861
- const compiled = binding.compileAnimation?.(
862
- opts.from,
863
- opts.to,
864
- opts.name ?? null,
865
- duration,
866
- easing,
867
- delay,
868
- fill,
869
- iterations,
870
- direction
871
- );
872
- if (!compiled) {
873
- throw new Error(
874
- `Native animate backend failed to compile animation "${opts.name ?? "anonymous animation"}".`
764
+ const binding = await getAnimateBinding();
765
+ const classesToValidate = [
766
+ { classList: opts.from ?? "", context: "from" },
767
+ { classList: opts.to ?? "", context: "to" }
768
+ ].filter((entry) => entry.classList.trim().length > 0);
769
+ if (classesToValidate.length > 0) {
770
+ await validateTailwindClasses(classesToValidate);
771
+ }
772
+ if (!binding.compileAnimation) {
773
+ throw new Error("FATAL: Native binding 'compileAnimation' is required but not available.");
774
+ }
775
+ const result = binding.compileAnimation(
776
+ opts.from,
777
+ opts.to,
778
+ opts.name ?? null,
779
+ normalizeNumber(opts.duration, DEFAULT_DURATION),
780
+ opts.easing ?? DEFAULT_EASING,
781
+ normalizeNumber(opts.delay, DEFAULT_DELAY),
782
+ opts.fill ?? DEFAULT_FILL,
783
+ normalizeIterations(opts.iterations),
784
+ opts.direction ?? DEFAULT_DIRECTION
875
785
  );
876
- }
877
- const result = {
878
- className: compiled.className,
879
- keyframesCss: compiled.keyframesCss,
880
- animationCss: compiled.animationCss
881
- };
882
- this.animations.set(result.className, result);
883
- this.animationBySignature.set(signature, result.className);
884
- return result;
885
- }
886
- async compileKeyframes(name, stops) {
887
- const signature = keyframesCacheKey(name, stops);
888
- const existingClassName = this.keyframesBySignature.get(signature);
889
- if (existingClassName) {
890
- const cached = this.animations.get(existingClassName);
786
+ if (!result) {
787
+ throw new Error(`compileAnimation returned null for opts: ${JSON.stringify(opts)}`);
788
+ }
789
+ const compiled = {
790
+ className: result.className,
791
+ keyframesCss: result.keyframesCss,
792
+ animationCss: result.animationCss
793
+ };
794
+ cache.set(key, compiled);
795
+ if (result.keyframesCss) cssChunks.push(result.keyframesCss);
796
+ if (result.animationCss) cssChunks.push(result.animationCss);
797
+ return compiled;
798
+ },
799
+ async compileKeyframes(name, stops) {
800
+ const key = keyframesCacheKey(name, stops);
801
+ const cached = cache.get(key);
891
802
  if (cached) return cached;
892
- this.keyframesBySignature.delete(signature);
893
- }
894
- await validateTailwindClasses(
895
- Object.entries(stops).map(([offset, classes]) => ({
896
- classList: classes,
897
- context: `"${offset}" stop in keyframes "${name}"`
898
- }))
899
- );
900
- const binding = await getAnimateBinding();
901
- const stopsJson = JSON.stringify(stableKeyframesEntries(stops));
902
- const compiled = binding.compileKeyframes?.(name, stopsJson);
903
- if (!compiled) {
904
- throw new Error(`Native animate backend failed to compile keyframes "${name}".`);
905
- }
906
- const result = {
907
- className: compiled.className,
908
- keyframesCss: compiled.keyframesCss,
909
- animationCss: compiled.animationCss
910
- };
911
- this.animations.set(result.className, result);
912
- this.keyframesBySignature.set(signature, result.className);
913
- return result;
914
- }
915
- extractCss() {
916
- const lines = [];
917
- for (const [, compiled] of this.animations.entries()) {
918
- lines.push(compiled.keyframesCss);
919
- lines.push(`.${compiled.className} { ${compiled.animationCss} }`);
803
+ const binding = await getAnimateBinding();
804
+ const stopsJson = JSON.stringify(stableKeyframesEntries(stops));
805
+ if (!binding.compileKeyframes) {
806
+ throw new Error("FATAL: Native binding 'compileKeyframes' is required but not available.");
807
+ }
808
+ const result = binding.compileKeyframes(name, stopsJson);
809
+ if (!result) {
810
+ throw new Error(`compileKeyframes returned null for name: ${name}`);
811
+ }
812
+ const compiled = {
813
+ className: result.className,
814
+ keyframesCss: result.keyframesCss,
815
+ animationCss: result.animationCss
816
+ };
817
+ cache.set(key, compiled);
818
+ if (result.keyframesCss) cssChunks.push(result.keyframesCss);
819
+ if (result.animationCss) cssChunks.push(result.animationCss);
820
+ return compiled;
821
+ },
822
+ extractCss() {
823
+ return cssChunks.join("\n");
824
+ },
825
+ reset() {
826
+ cache.clear?.();
827
+ cssChunks.length = 0;
828
+ classNames.clear();
829
+ },
830
+ has(className) {
831
+ return classNames.has(className);
920
832
  }
921
- return lines.join("\n\n");
922
- }
923
- reset() {
924
- this.animations.clear();
925
- this.animationBySignature.clear();
926
- this.keyframesBySignature.clear();
927
- }
928
- has(className) {
929
- return this.animations.has(className);
930
- }
931
- };
932
- function createAnimationRegistry(options = {}) {
933
- return new AnimationRegistry(options);
833
+ };
934
834
  }
935
835
 
936
836
  // packages/domain/animate/src/index.ts
@@ -941,8 +841,14 @@ async function initAnimate2() {
941
841
  function getDefaultAnimationRegistry() {
942
842
  return defaultRegistry;
943
843
  }
944
- async function compileAnimation(opts, registry = defaultRegistry) {
945
- return registry.compileAnimation(opts);
844
+ async function compileAnimation(optsOrName, secondArg) {
845
+ if (typeof optsOrName === "string") {
846
+ const partialOpts = secondArg && typeof secondArg.compileAnimation !== "function" ? secondArg : {};
847
+ const opts = { from: "", to: "", ...partialOpts, name: optsOrName };
848
+ return defaultRegistry.compileAnimation(opts);
849
+ }
850
+ const registry = secondArg && typeof secondArg.compileAnimation === "function" ? secondArg : defaultRegistry;
851
+ return registry.compileAnimation(optsOrName);
946
852
  }
947
853
  async function compileKeyframes(name, stops, registry = defaultRegistry) {
948
854
  return registry.compileKeyframes(name, stops);
@@ -983,7 +889,7 @@ function injectAnimationCss(registry = defaultRegistry, options = {}) {
983
889
  }
984
890
  var animations = createAnimationPresets(defaultRegistry);
985
891
 
986
- exports.AnimationRegistry = AnimationRegistry;
892
+ exports.AnimationRegistry = createAnimationRegistry;
987
893
  exports.animate = animate;
988
894
  exports.animations = animations;
989
895
  exports.compileAnimation = compileAnimation;