tailwind-styled-v4 5.0.8 → 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 (140) hide show
  1. package/CHANGELOG.md +204 -416
  2. package/README.md +45 -15
  3. package/dist/{analyzeWorkspace-DuJKh7Ty.d.mts → analyzeWorkspace-BS5O4rhC.d.mts} +47 -2
  4. package/dist/{analyzeWorkspace-Ct_NTAWt.d.ts → analyzeWorkspace-DDOQdzzI.d.ts} +47 -2
  5. package/dist/analyzer.d.mts +5 -3
  6. package/dist/analyzer.d.ts +5 -3
  7. package/dist/analyzer.js +563 -468
  8. package/dist/analyzer.js.map +1 -1
  9. package/dist/analyzer.mjs +562 -467
  10. package/dist/analyzer.mjs.map +1 -1
  11. package/dist/animate.d.mts +4 -7
  12. package/dist/animate.d.ts +4 -7
  13. package/dist/animate.js +171 -265
  14. package/dist/animate.js.map +1 -1
  15. package/dist/animate.mjs +165 -264
  16. package/dist/animate.mjs.map +1 -1
  17. package/dist/atomic.d.mts +22 -1
  18. package/dist/atomic.d.ts +22 -1
  19. package/dist/atomic.js +221 -165
  20. package/dist/atomic.js.map +1 -1
  21. package/dist/atomic.mjs +200 -165
  22. package/dist/atomic.mjs.map +1 -1
  23. package/dist/cli.d.mts +60 -1
  24. package/dist/cli.d.ts +60 -1
  25. package/dist/cli.js +1261 -1517
  26. package/dist/cli.js.map +1 -1
  27. package/dist/cli.mjs +1238 -1513
  28. package/dist/cli.mjs.map +1 -1
  29. package/dist/compiler.d.mts +38 -7
  30. package/dist/compiler.d.ts +38 -7
  31. package/dist/compiler.js +174 -197
  32. package/dist/compiler.js.map +1 -1
  33. package/dist/compiler.mjs +151 -194
  34. package/dist/compiler.mjs.map +1 -1
  35. package/dist/devtools.js +7 -31
  36. package/dist/devtools.js.map +1 -1
  37. package/dist/devtools.mjs +7 -31
  38. package/dist/devtools.mjs.map +1 -1
  39. package/dist/engine.d.mts +134 -63
  40. package/dist/engine.d.ts +134 -63
  41. package/dist/engine.js +2863 -2482
  42. package/dist/engine.js.map +1 -1
  43. package/dist/engine.mjs +2852 -2485
  44. package/dist/engine.mjs.map +1 -1
  45. package/dist/{index-eWAocnD2.d.mts → index-NDINUhLN.d.mts} +3 -1
  46. package/dist/{index-eWAocnD2.d.ts → index-NDINUhLN.d.ts} +3 -1
  47. package/dist/index.d.mts +63 -32
  48. package/dist/index.d.ts +63 -32
  49. package/dist/index.js +335 -169
  50. package/dist/index.js.map +1 -1
  51. package/dist/index.mjs +315 -169
  52. package/dist/index.mjs.map +1 -1
  53. package/dist/{liveTokenEngine-DSUk88P6.d.ts → liveTokenEngine-CN9ian1R.d.ts} +1 -1
  54. package/dist/{liveTokenEngine-CX5_0c4q.d.mts → liveTokenEngine-DKoWRtqH.d.mts} +1 -1
  55. package/dist/next.d.mts +10 -4
  56. package/dist/next.d.ts +10 -4
  57. package/dist/next.js +32 -45
  58. package/dist/next.js.map +1 -1
  59. package/dist/next.mjs +30 -43
  60. package/dist/next.mjs.map +1 -1
  61. package/dist/plugin-api.d.mts +8 -2
  62. package/dist/plugin-api.d.ts +8 -2
  63. package/dist/plugin-api.js +14 -2
  64. package/dist/plugin-api.js.map +1 -1
  65. package/dist/plugin-api.mjs +14 -3
  66. package/dist/plugin-api.mjs.map +1 -1
  67. package/dist/plugin-registry.js +51 -11
  68. package/dist/plugin-registry.js.map +1 -1
  69. package/dist/plugin-registry.mjs +51 -11
  70. package/dist/plugin-registry.mjs.map +1 -1
  71. package/dist/plugin.d.mts +5 -7
  72. package/dist/plugin.d.ts +5 -7
  73. package/dist/plugin.js +16 -15
  74. package/dist/plugin.js.map +1 -1
  75. package/dist/plugin.mjs +16 -16
  76. package/dist/plugin.mjs.map +1 -1
  77. package/dist/rspack.js +17 -38
  78. package/dist/rspack.js.map +1 -1
  79. package/dist/rspack.mjs +15 -36
  80. package/dist/rspack.mjs.map +1 -1
  81. package/dist/runtime.d.mts +2 -2
  82. package/dist/runtime.d.ts +2 -2
  83. package/dist/scanner.d.mts +10 -1
  84. package/dist/scanner.d.ts +10 -1
  85. package/dist/scanner.js +298 -124
  86. package/dist/scanner.js.map +1 -1
  87. package/dist/scanner.mjs +296 -124
  88. package/dist/scanner.mjs.map +1 -1
  89. package/dist/shared.d.mts +1 -1
  90. package/dist/shared.d.ts +1 -1
  91. package/dist/shared.js +104 -176
  92. package/dist/shared.js.map +1 -1
  93. package/dist/shared.mjs +85 -176
  94. package/dist/shared.mjs.map +1 -1
  95. package/dist/storybook-addon.d.mts +1 -1
  96. package/dist/storybook-addon.d.ts +1 -1
  97. package/dist/svelte.d.mts +1 -1
  98. package/dist/svelte.d.ts +1 -1
  99. package/dist/svelte.js +166 -3
  100. package/dist/svelte.js.map +1 -1
  101. package/dist/svelte.mjs +143 -1
  102. package/dist/svelte.mjs.map +1 -1
  103. package/dist/syntax.js +21 -21
  104. package/dist/syntax.js.map +1 -1
  105. package/dist/syntax.mjs +21 -21
  106. package/dist/syntax.mjs.map +1 -1
  107. package/dist/testing.js +9 -1
  108. package/dist/testing.js.map +1 -1
  109. package/dist/testing.mjs +9 -1
  110. package/dist/testing.mjs.map +1 -1
  111. package/dist/theme.d.mts +2 -2
  112. package/dist/theme.d.ts +2 -2
  113. package/dist/theme.js +40 -112
  114. package/dist/theme.js.map +1 -1
  115. package/dist/theme.mjs +37 -110
  116. package/dist/theme.mjs.map +1 -1
  117. package/dist/turbopackLoader.js +84 -126
  118. package/dist/turbopackLoader.js.map +1 -1
  119. package/dist/turbopackLoader.mjs +68 -124
  120. package/dist/turbopackLoader.mjs.map +1 -1
  121. package/dist/tw.js +1256 -1517
  122. package/dist/tw.js.map +1 -1
  123. package/dist/tw.mjs +1236 -1513
  124. package/dist/tw.mjs.map +1 -1
  125. package/dist/vite.js +1783 -823
  126. package/dist/vite.js.map +1 -1
  127. package/dist/vite.mjs +1767 -821
  128. package/dist/vite.mjs.map +1 -1
  129. package/dist/vue.d.mts +1 -1
  130. package/dist/vue.d.ts +1 -1
  131. package/dist/vue.js +165 -4
  132. package/dist/vue.js.map +1 -1
  133. package/dist/vue.mjs +141 -1
  134. package/dist/vue.mjs.map +1 -1
  135. package/dist/webpackLoader.js +69 -108
  136. package/dist/webpackLoader.js.map +1 -1
  137. package/dist/webpackLoader.mjs +49 -104
  138. package/dist/webpackLoader.mjs.map +1 -1
  139. package/native/tailwind-styled-native.node +0 -0
  140. package/package.json +22 -24
package/dist/compiler.js CHANGED
@@ -1,8 +1,33 @@
1
1
  'use strict';
2
2
 
3
3
  var module$1 = require('module');
4
+ var fs = require('fs');
5
+ var path = require('path');
6
+ require('crypto');
7
+ var url = require('url');
4
8
 
5
9
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
10
+ function _interopNamespace(e) {
11
+ if (e && e.__esModule) return e;
12
+ var n = Object.create(null);
13
+ if (e) {
14
+ Object.keys(e).forEach(function (k) {
15
+ if (k !== 'default') {
16
+ var d = Object.getOwnPropertyDescriptor(e, k);
17
+ Object.defineProperty(n, k, d.get ? d : {
18
+ enumerable: true,
19
+ get: function () { return e[k]; }
20
+ });
21
+ }
22
+ });
23
+ }
24
+ n.default = e;
25
+ return Object.freeze(n);
26
+ }
27
+
28
+ var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
29
+ var path__namespace = /*#__PURE__*/_interopNamespace(path);
30
+
6
31
  /* tailwind-styled-v4 v5.0.4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
7
32
  var __defProp = Object.defineProperty;
8
33
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -19,45 +44,6 @@ var __export = (target, all) => {
19
44
  for (var name in all)
20
45
  __defProp(target, name, { get: all[name], enumerable: true });
21
46
  };
22
-
23
- // packages/domain/shared/src/native-resolution.ts
24
- function getNodeModuleRef() {
25
- if (isBrowser) return null;
26
- if (nodeModuleRef !== null) return nodeModuleRef;
27
- try {
28
- const test = typeof __require === "function" ? __require("module") : null;
29
- nodeModuleRef = test;
30
- return test;
31
- } catch {
32
- nodeModuleRef = null;
33
- return null;
34
- }
35
- }
36
- function getNodeFs() {
37
- if (isBrowser) return { existsSync: () => false };
38
- const nodeRequire = getNodeModuleRef();
39
- if (!nodeRequire) return { existsSync: () => false };
40
- if (!_nodeFs) _nodeFs = nodeRequire.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('compiler.js', document.baseURI).href)))("node:fs");
41
- return _nodeFs;
42
- }
43
- function getNodePath() {
44
- if (isBrowser) return { resolve: () => "", dirname: "" };
45
- const nodeRequire = getNodeModuleRef();
46
- if (!nodeRequire) return { resolve: () => "", dirname: "" };
47
- if (!_nodePath) _nodePath = nodeRequire.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('compiler.js', document.baseURI).href)))("node:path");
48
- return _nodePath;
49
- }
50
- function getRequire(_importMetaUrl) {
51
- if (isBrowser) return () => {
52
- throw new Error("node:module not available");
53
- };
54
- const nodeRequire = getNodeModuleRef();
55
- if (!nodeRequire) return () => {
56
- throw new Error("require not available");
57
- };
58
- if (!_require) _require = nodeRequire.createRequire(_importMetaUrl);
59
- return _require;
60
- }
61
47
  function platformKey() {
62
48
  if (isBrowser) return "browser";
63
49
  return `${process.platform}-${process.arch}`;
@@ -68,24 +54,21 @@ function resolveNativeBinary(runtimeDir) {
68
54
  if (isBrowser) {
69
55
  return { path: null, source: "not-found", platform, tried: ["not available in browser"] };
70
56
  }
71
- const fs = getNodeFs();
72
- const path = getNodePath();
73
- const _req = getRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('compiler.js', document.baseURI).href)));
57
+ if (process.env.TWS_DISABLE_NATIVE === "1") {
58
+ return { path: null, source: "not-found", platform, tried: [] };
59
+ }
74
60
  const envPath = process.env.TW_NATIVE_PATH?.trim();
75
61
  if (envPath) {
76
- if (fs.existsSync(envPath)) {
62
+ if (fs__namespace.existsSync(envPath)) {
77
63
  return { path: envPath, source: "env", platform, tried };
78
64
  }
79
65
  tried.push(`env:${envPath} (not found)`);
80
66
  }
81
- if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_NO_RUST === "1" || process.env.TWS_DISABLE_NATIVE === "1") {
82
- return { path: null, source: "not-found", platform, tried: ["disabled by env"] };
83
- }
84
67
  const prebuiltPkgs = PLATFORM_MAP[platform] ?? [];
85
68
  for (const pkg of prebuiltPkgs) {
86
69
  try {
87
- const candidate = _req.resolve(`${pkg}/tailwind_styled_parser.node`);
88
- if (fs.existsSync(candidate)) {
70
+ const candidate = _require.resolve(`${pkg}/tailwind_styled_parser.node`);
71
+ if (fs__namespace.existsSync(candidate)) {
89
72
  return { path: candidate, source: "prebuilt", platform, tried };
90
73
  }
91
74
  tried.push(`prebuilt:${pkg} (resolved but missing)`);
@@ -95,30 +78,43 @@ function resolveNativeBinary(runtimeDir) {
95
78
  }
96
79
  const cwd = process.cwd();
97
80
  const base = runtimeDir ?? cwd;
98
- const localCandidates = [
99
- path.resolve(base, "tailwind_styled_parser.node"),
100
- path.resolve(base, "..", "tailwind_styled_parser.node"),
101
- path.resolve(cwd, "native", "tailwind_styled_parser.node"),
102
- path.resolve(cwd, "native", "target", "release", "tailwind_styled_parser.node"),
103
- // napi-rs conventional output
104
- path.resolve(base, `tailwind_styled_parser.${platform}.node`)
105
- ];
81
+ const napiPlatform = platform === "linux-x64" ? "linux-x64-gnu" : platform === "linux-arm64" ? "linux-arm64-gnu" : platform;
82
+ const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
83
+ const localCandidates = [];
84
+ for (const bin of BINARY_NAMES) {
85
+ localCandidates.push(path__namespace.resolve(base, `${bin}.node`));
86
+ localCandidates.push(path__namespace.resolve(base, "..", `${bin}.node`));
87
+ localCandidates.push(path__namespace.resolve(base, `${bin}.${platform}.node`));
88
+ localCandidates.push(path__namespace.resolve(base, `${bin}.${napiPlatform}.node`));
89
+ }
90
+ for (const startDir of [cwd, base]) {
91
+ let dir = startDir;
92
+ for (let i = 0; i < 6; i++) {
93
+ const nativeDir = path__namespace.resolve(dir, "native");
94
+ for (const bin of BINARY_NAMES) {
95
+ localCandidates.push(path__namespace.resolve(nativeDir, `${bin}.node`));
96
+ localCandidates.push(path__namespace.resolve(nativeDir, `${bin}.${platform}.node`));
97
+ localCandidates.push(path__namespace.resolve(nativeDir, `${bin}.${napiPlatform}.node`));
98
+ localCandidates.push(path__namespace.resolve(nativeDir, "target", "release", `${bin}.node`));
99
+ }
100
+ const parent = path__namespace.resolve(dir, "..");
101
+ if (parent === dir) break;
102
+ dir = parent;
103
+ }
104
+ }
106
105
  for (const candidate of localCandidates) {
107
106
  tried.push(`local:${candidate}`);
108
- if (fs.existsSync(candidate)) {
107
+ if (fs__namespace.existsSync(candidate)) {
109
108
  return { path: candidate, source: "local", platform, tried };
110
109
  }
111
110
  }
112
111
  return { path: null, source: "not-found", platform, tried };
113
112
  }
114
- var isBrowser, nodeModuleRef, _nodeFs, _nodePath, _require, PLATFORM_MAP;
113
+ var isBrowser, _require, PLATFORM_MAP;
115
114
  var init_native_resolution = __esm({
116
115
  "packages/domain/shared/src/native-resolution.ts"() {
117
116
  isBrowser = typeof window !== "undefined" || typeof document !== "undefined";
118
- nodeModuleRef = null;
119
- _nodeFs = null;
120
- _nodePath = null;
121
- _require = null;
117
+ _require = typeof __require !== "undefined" ? __require : module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('compiler.js', document.baseURI).href)));
122
118
  PLATFORM_MAP = {
123
119
  "linux-x64": ["@tailwind-styled/native-linux-x64"],
124
120
  "linux-arm64": ["@tailwind-styled/native-linux-arm64"],
@@ -129,59 +125,26 @@ var init_native_resolution = __esm({
129
125
  };
130
126
  }
131
127
  });
132
-
133
- // packages/domain/shared/src/index.ts
134
- function getNodeModuleRef2() {
135
- if (isBrowser2) return null;
136
- if (nodeModuleRef2 !== null) return nodeModuleRef2;
137
- try {
138
- const test = typeof __require === "function" ? __require("module") : null;
139
- nodeModuleRef2 = test;
140
- return test;
141
- } catch {
142
- nodeModuleRef2 = null;
143
- return null;
144
- }
145
- }
146
- function getNodeUrl() {
147
- if (isBrowser2) throw new Error("node:url not available in browser");
148
- const nodeRequire = getNodeModuleRef2();
149
- if (!nodeRequire) throw new Error("require not available");
150
- if (!_nodeUrl) _nodeUrl = nodeRequire.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('compiler.js', document.baseURI).href)))("node:url");
151
- return _nodeUrl;
152
- }
153
- function getRequire2() {
154
- if (isBrowser2) return (() => {
155
- throw new Error("require not available in browser");
156
- });
157
- const nodeRequire = getNodeModuleRef2();
158
- if (!nodeRequire) return (() => {
159
- throw new Error("require not available");
160
- });
161
- return nodeRequire.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('compiler.js', document.baseURI).href)));
162
- }
163
128
  function resolveRuntimeDir(dir, importMetaUrl) {
164
- if (isBrowser2) return "";
165
129
  try {
166
- return getNodeUrl().fileURLToPath(importMetaUrl);
130
+ return path__namespace.default.dirname(url.fileURLToPath(importMetaUrl));
167
131
  } catch {
168
132
  return process.cwd();
169
133
  }
170
134
  }
171
- var isBrowser2, nodeModuleRef2, _nodeUrl;
172
135
  var init_src = __esm({
173
136
  "packages/domain/shared/src/index.ts"() {
174
137
  init_native_resolution();
175
- isBrowser2 = typeof window !== "undefined" || typeof document !== "undefined";
176
- nodeModuleRef2 = null;
177
- _nodeUrl = null;
178
- getRequire2();
138
+ module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('compiler.js', document.baseURI).href)));
179
139
  }
180
140
  });
181
- var log, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttempted, bridgeLoadError, isValidNativeBridge; exports.getNativeBridge = void 0; exports.resetNativeBridgeCache = void 0; exports.adaptNativeResult = void 0;
141
+
142
+ // packages/domain/compiler/src/nativeBridge.ts
143
+ var _loadNative, log, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttempted, bridgeLoadError, isValidNativeBridge; exports.getNativeBridge = void 0; exports.resetNativeBridgeCache = void 0; exports.adaptNativeResult = void 0;
182
144
  var init_nativeBridge = __esm({
183
145
  "packages/domain/compiler/src/nativeBridge.ts"() {
184
146
  init_src();
147
+ _loadNative = (path3) => __require(path3);
185
148
  log = (...args) => {
186
149
  if (process.env.DEBUG?.includes("compiler:native")) {
187
150
  console.log("[compiler:native]", ...args);
@@ -208,11 +171,10 @@ var init_nativeBridge = __esm({
208
171
  bridgeLoadAttempted = true;
209
172
  try {
210
173
  const runtimeDir = resolveRuntimeDir(void 0, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('compiler.js', document.baseURI).href)));
211
- const require3 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('compiler.js', document.baseURI).href)));
212
174
  const result = resolveNativeBinary(runtimeDir);
213
175
  if (result.path && result.path.endsWith(".node")) {
214
176
  try {
215
- const binding = require3(result.path);
177
+ const binding = _loadNative(result.path);
216
178
  if (isValidNativeBridge(binding)) {
217
179
  nativeBridge = binding;
218
180
  log("Native bridge loaded successfully from:", result.path);
@@ -259,6 +221,7 @@ Tried paths: ${result.tried.join("\n")}`);
259
221
  var tailwindEngine_exports = {};
260
222
  __export(tailwindEngine_exports, {
261
223
  generateRawCss: () => generateRawCss,
224
+ processTailwindCssWithTargets: () => processTailwindCssWithTargets,
262
225
  runCssPipeline: () => runCssPipeline,
263
226
  runCssPipelineSync: () => runCssPipelineSync
264
227
  });
@@ -286,12 +249,11 @@ function generateRawCss(classes) {
286
249
  function postProcessWithLightning(rawCss) {
287
250
  if (!rawCss) return "";
288
251
  const native = exports.getNativeBridge();
289
- if (typeof native.processTailwindCssLightning === "function") {
290
- const result = native.processTailwindCssLightning(rawCss);
291
- return result?.css ?? rawCss;
252
+ if (typeof native.processTailwindCssLightning !== "function") {
253
+ throw new Error("FATAL: Native binding 'processTailwindCssLightning' is required but not available.");
292
254
  }
293
- console.warn("[tailwind-styled] processTailwindCssLightning tidak tersedia \u2014 gunakan raw CSS");
294
- return rawCss;
255
+ const result = native.processTailwindCssLightning(rawCss);
256
+ return result?.css ?? rawCss;
295
257
  }
296
258
  async function runCssPipeline(classes) {
297
259
  const unique = [...new Set(classes.filter(Boolean))];
@@ -325,6 +287,14 @@ function runCssPipelineSync(classes) {
325
287
  optimized: hasLightning
326
288
  };
327
289
  }
290
+ function processTailwindCssWithTargets(css, targets) {
291
+ const native = exports.getNativeBridge();
292
+ if (!native?.processTailwindCssWithTargets) {
293
+ throw new Error("FATAL: Native binding 'processTailwindCssWithTargets' is required but not available.");
294
+ }
295
+ const result = native.processTailwindCssWithTargets(css, targets ?? null);
296
+ return (result?.css ?? css).trim();
297
+ }
328
298
  var require2, _twEngine, _twEngineError;
329
299
  var init_tailwindEngine = __esm({
330
300
  "packages/domain/compiler/src/tailwindEngine.ts"() {
@@ -413,18 +383,10 @@ var astExtractClasses = (source, filename) => {
413
383
  var parseClasses = (raw) => {
414
384
  const native = exports.getNativeBridge();
415
385
  if (!native?.parseClasses) {
416
- return parseClassesJs(raw);
386
+ throw new Error("FATAL: Native binding 'parseClasses' is required but not available.");
417
387
  }
418
388
  return native.parseClasses(raw) || [];
419
389
  };
420
- function parseClassesJs(raw) {
421
- if (!raw || typeof raw !== "string") return [];
422
- const classes = raw.split(/\s+/).filter(Boolean);
423
- return classes.map((cls) => ({
424
- raw: cls,
425
- type: cls.includes(":") ? "variant" : cls.includes("/") ? "arbitrary" : "utility"
426
- }));
427
- }
428
390
  var normalizeClasses = (raw) => {
429
391
  const result = normalizeAndDedupClasses(raw);
430
392
  return result?.normalized || "";
@@ -433,75 +395,81 @@ var mergeClassesStatic = (classes) => {
433
395
  const result = normalizeAndDedupClasses(classes);
434
396
  return result?.normalized || "";
435
397
  };
436
- function normalizeAndDedupClassesJs(raw) {
437
- const seen = /* @__PURE__ */ new Set();
438
- const result = [];
439
- let duplicatesRemoved = 0;
440
- for (const token of raw.split(/\s+/)) {
441
- if (token.length === 0) continue;
442
- if (seen.has(token)) {
443
- duplicatesRemoved++;
444
- } else {
445
- seen.add(token);
446
- result.push(token);
447
- }
448
- }
449
- return {
450
- normalized: result.join(" "),
451
- duplicatesRemoved,
452
- uniqueCount: result.length
453
- };
454
- }
455
398
  var normalizeAndDedupClasses = (raw) => {
456
399
  const native = exports.getNativeBridge();
457
400
  if (!native?.normalizeAndDedupClasses) {
458
- return normalizeAndDedupClassesJs(raw);
401
+ throw new Error("FATAL: Native binding 'normalizeAndDedupClasses' is required but not available.");
459
402
  }
460
403
  const result = native.normalizeAndDedupClasses(raw);
461
404
  return result || { normalized: "", duplicatesRemoved: 0, uniqueCount: 0 };
462
405
  };
463
406
  var eliminateDeadCss = (css, deadClasses) => {
464
- let result = css;
465
- for (const dead of deadClasses) {
466
- result = result.replace(new RegExp(`\\.${dead.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}[^{]*\\{[^}]*\\}`, "g"), "");
407
+ const native = exports.getNativeBridge();
408
+ if (!native?.processTailwindCssLightning) {
409
+ throw new Error("FATAL: Native binding 'processTailwindCssLightning' is required but not available.");
467
410
  }
468
- return result;
411
+ const deadSet = deadClasses;
412
+ const pruned = css.split(/(?<=\})\s*/).filter((rule) => {
413
+ const m = rule.match(/\.([a-zA-Z0-9_-]+)/);
414
+ return !m || !deadSet.has(m[1]);
415
+ }).join("\n");
416
+ const compiled = native.processTailwindCssLightning(pruned);
417
+ return (compiled?.css ?? pruned).trim();
469
418
  };
470
419
  var findDeadVariants = (variantConfig, usage) => {
471
420
  const unused = [];
472
- const variants = variantConfig;
473
- for (const [key, values] of Object.entries(variants)) {
474
- for (const [value] of Object.entries(values)) {
475
- const keyValue = `${key}:${value}`;
476
- if (!usage[key]?.has(value)) {
477
- unused.push(keyValue);
421
+ const configs = Array.isArray(variantConfig) ? variantConfig : [{ name: "__root__", variants: variantConfig }];
422
+ for (const component of configs) {
423
+ const componentUsage = usage[component.name] ?? /* @__PURE__ */ new Set();
424
+ const variants = component.variants;
425
+ for (const [key, values] of Object.entries(variants)) {
426
+ for (const [value] of Object.entries(values)) {
427
+ if (!componentUsage.has(`${key}:${value}`)) {
428
+ unused.push(`${component.name !== "__root__" ? `${component.name}/` : ""}${key}:${value}`);
429
+ }
478
430
  }
479
431
  }
480
432
  }
481
- return unused;
433
+ return {
434
+ unusedCount: unused.length,
435
+ unused
436
+ };
482
437
  };
483
438
  var runElimination = (css, scanResult) => {
484
- const scanJson = JSON.stringify(scanResult);
485
- const classes = extractAllClasses(css);
486
- const usage = analyzeClassUsage(classes, scanJson, css) || [];
487
- const deadClasses = new Set(usage.filter((u) => u.isDeadCode).map((u) => u.className));
488
- return eliminateDeadCss(css, deadClasses);
439
+ const native = exports.getNativeBridge();
440
+ if (!native?.detectDeadCode) {
441
+ throw new Error("FATAL: Native binding 'detectDeadCode' is required but not available.");
442
+ }
443
+ const dead = native.detectDeadCode(
444
+ JSON.stringify(scanResult),
445
+ css
446
+ );
447
+ return eliminateDeadCss(css, new Set(dead.deadInCss ?? []));
489
448
  };
490
449
  var optimizeCss = (css) => {
491
- const classes = extractAllClasses(css);
492
- const usage = analyzeClassUsage(classes, "[]", css) || [];
493
- const usedClasses = new Set(usage.filter((u) => !u.isDeadCode).map((u) => u.className));
494
- let result = css;
495
- const classRegex = /\.([a-zA-Z0-9_-]+)/g;
496
- result = result.replace(classRegex, (match, className) => {
497
- return usedClasses.has(className) ? match : "";
498
- });
499
- result = result.replace(/[^{}]*\{\s*\}/g, "");
500
- return result.trim();
450
+ const native = exports.getNativeBridge();
451
+ if (!native?.detectDeadCode) {
452
+ throw new Error("FATAL: Native binding 'detectDeadCode' is required but not available.");
453
+ }
454
+ const deadResult = native.detectDeadCode(
455
+ JSON.stringify({ uniqueClasses: [] }),
456
+ css
457
+ );
458
+ if (!native?.processTailwindCssLightning) {
459
+ throw new Error("FATAL: Native binding 'processTailwindCssLightning' is required but not available.");
460
+ }
461
+ const deadSet = new Set(deadResult.deadInCss ?? []);
462
+ const pruned = css.split(/(?<=\})\s*/).filter((rule) => {
463
+ const selectorMatch = rule.match(/\.([a-zA-Z0-9_-]+)/);
464
+ if (!selectorMatch) return true;
465
+ return !deadSet.has(selectorMatch[1]);
466
+ }).join("\n");
467
+ const compiled = native.processTailwindCssLightning(pruned);
468
+ return (compiled?.css ?? pruned).trim();
501
469
  };
502
470
  var scanProjectUsage = (dirs, cwd) => {
503
- const path = __require("path");
504
- const files = dirs.map((dir) => path.resolve(cwd, dir));
471
+ const path3 = __require("path");
472
+ const files = dirs.map((dir) => path3.resolve(cwd, dir));
505
473
  const results = batchExtractClasses(files) || [];
506
474
  const combined = {};
507
475
  for (const result of results) {
@@ -625,23 +593,23 @@ var generateSafelist = (scanDirs, outputPath, cwd) => {
625
593
  const classes = scanProjectUsage(scanDirs, cwd || process.cwd());
626
594
  const allClasses = Object.keys(classes).sort();
627
595
  if (outputPath) {
628
- const fs = __require("fs");
629
- fs.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
596
+ const fs3 = __require("fs");
597
+ fs3.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
630
598
  }
631
599
  return allClasses;
632
600
  };
633
601
  var loadSafelist = (safelistPath) => {
634
- const fs = __require("fs");
602
+ const fs3 = __require("fs");
635
603
  try {
636
- const content = fs.readFileSync(safelistPath, "utf-8");
604
+ const content = fs3.readFileSync(safelistPath, "utf-8");
637
605
  return JSON.parse(content);
638
606
  } catch {
639
607
  return [];
640
608
  }
641
609
  };
642
610
  var loadTailwindConfig = (cwd = process.cwd()) => {
643
- const fs = __require("fs");
644
- const path = __require("path");
611
+ const fs3 = __require("fs");
612
+ const path3 = __require("path");
645
613
  const configFiles = [
646
614
  "tailwind.config.ts",
647
615
  "tailwind.config.js",
@@ -649,8 +617,8 @@ var loadTailwindConfig = (cwd = process.cwd()) => {
649
617
  "tailwind.config.cjs"
650
618
  ];
651
619
  for (const file of configFiles) {
652
- const fullPath = path.join(cwd, file);
653
- if (fs.existsSync(fullPath)) {
620
+ const fullPath = path3.join(cwd, file);
621
+ if (fs3.existsSync(fullPath)) {
654
622
  const mod = __require(fullPath);
655
623
  return mod.default || mod;
656
624
  }
@@ -658,12 +626,12 @@ var loadTailwindConfig = (cwd = process.cwd()) => {
658
626
  return {};
659
627
  };
660
628
  var getContentPaths = (cwd = process.cwd()) => {
661
- const path = __require("path");
629
+ const path3 = __require("path");
662
630
  return {
663
631
  content: [
664
- path.join(cwd, "src/**/*.{js,ts,jsx,tsx}"),
665
- path.join(cwd, "app/**/*.{js,ts,jsx,tsx}"),
666
- path.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
632
+ path3.join(cwd, "src/**/*.{js,ts,jsx,tsx}"),
633
+ path3.join(cwd, "app/**/*.{js,ts,jsx,tsx}"),
634
+ path3.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
667
635
  ]
668
636
  };
669
637
  };
@@ -699,58 +667,67 @@ var fileToRoute = (filepath) => {
699
667
  return null;
700
668
  };
701
669
  var getAllRoutes = () => {
670
+ const native = exports.getNativeBridge();
671
+ if (!native?.analyzeClasses) {
672
+ throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
673
+ }
702
674
  return ["/", "__global"];
703
675
  };
704
- var getRouteClasses = (route) => {
676
+ var getRouteClasses = (_route) => {
705
677
  return /* @__PURE__ */ new Set();
706
678
  };
707
- var registerFileClasses = (filepath, classes) => {
679
+ var registerFileClasses = (_filepath, _classes) => {
708
680
  };
709
- var registerGlobalClasses = (classes) => {
681
+ var registerGlobalClasses = (_classes) => {
710
682
  };
711
- var incrementalEngineInstance = null;
683
+ var _incrementalEngineInstance = null;
712
684
  var getIncrementalEngine = () => {
713
- if (!incrementalEngineInstance) {
714
- incrementalEngineInstance = {
715
- compile: (source) => transformSource(source)
716
- };
685
+ if (!_incrementalEngineInstance) {
686
+ _incrementalEngineInstance = new IncrementalEngine();
717
687
  }
718
- return incrementalEngineInstance;
688
+ return _incrementalEngineInstance;
719
689
  };
720
690
  var resetIncrementalEngine = () => {
721
- incrementalEngineInstance = null;
691
+ _incrementalEngineInstance = null;
722
692
  };
723
693
  var IncrementalEngine = class {
724
694
  compile(source) {
725
695
  return transformSource(source);
726
696
  }
727
697
  };
728
- var bucketEngineInstance = null;
729
698
  var getBucketEngine = () => {
730
- if (!bucketEngineInstance) {
731
- bucketEngineInstance = {
732
- add: (className) => className,
733
- get: (bucket) => []
734
- };
699
+ const native = exports.getNativeBridge();
700
+ if (!native?.classifyAndSortClasses) {
701
+ throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
735
702
  }
736
- return bucketEngineInstance;
703
+ return {
704
+ add: (className) => className,
705
+ get: (_bucket) => []
706
+ };
737
707
  };
738
708
  var resetBucketEngine = () => {
739
- bucketEngineInstance = null;
740
709
  };
741
710
  var BucketEngine = class {
742
711
  add(className) {
743
712
  return className;
744
713
  }
745
714
  };
746
- var classifyNode = (node) => {
715
+ var classifyNode = (_node) => {
716
+ const native = exports.getNativeBridge();
717
+ if (!native?.classifyAndSortClasses) {
718
+ throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
719
+ }
747
720
  return "unknown";
748
721
  };
749
722
  var detectConflicts = (classes) => {
723
+ const native = exports.getNativeBridge();
724
+ if (!native?.analyzeClassUsage) {
725
+ throw new Error("FATAL: Native binding 'analyzeClassUsage' is required but not available.");
726
+ }
750
727
  return [];
751
728
  };
752
729
  var bucketSort = (classes) => {
753
- return classes;
730
+ return classifyAndSortClasses(classes).map((c) => c.raw ?? c);
754
731
  };
755
732
 
756
733
  exports.BucketEngine = BucketEngine;