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.mjs CHANGED
@@ -1,4 +1,9 @@
1
1
  import { createRequire } from 'module';
2
+ import * as fs from 'fs';
3
+ import * as path from 'path';
4
+ import path__default from 'path';
5
+ import 'crypto';
6
+ import { fileURLToPath } from 'url';
2
7
 
3
8
  /* tailwind-styled-v4 v5.0.4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
4
9
  var __defProp = Object.defineProperty;
@@ -16,45 +21,6 @@ var __export = (target, all) => {
16
21
  for (var name in all)
17
22
  __defProp(target, name, { get: all[name], enumerable: true });
18
23
  };
19
-
20
- // packages/domain/shared/src/native-resolution.ts
21
- function getNodeModuleRef() {
22
- if (isBrowser) return null;
23
- if (nodeModuleRef !== null) return nodeModuleRef;
24
- try {
25
- const test = typeof __require === "function" ? __require("module") : null;
26
- nodeModuleRef = test;
27
- return test;
28
- } catch {
29
- nodeModuleRef = null;
30
- return null;
31
- }
32
- }
33
- function getNodeFs() {
34
- if (isBrowser) return { existsSync: () => false };
35
- const nodeRequire = getNodeModuleRef();
36
- if (!nodeRequire) return { existsSync: () => false };
37
- if (!_nodeFs) _nodeFs = nodeRequire.createRequire(import.meta.url)("node:fs");
38
- return _nodeFs;
39
- }
40
- function getNodePath() {
41
- if (isBrowser) return { resolve: () => "", dirname: "" };
42
- const nodeRequire = getNodeModuleRef();
43
- if (!nodeRequire) return { resolve: () => "", dirname: "" };
44
- if (!_nodePath) _nodePath = nodeRequire.createRequire(import.meta.url)("node:path");
45
- return _nodePath;
46
- }
47
- function getRequire(_importMetaUrl) {
48
- if (isBrowser) return () => {
49
- throw new Error("node:module not available");
50
- };
51
- const nodeRequire = getNodeModuleRef();
52
- if (!nodeRequire) return () => {
53
- throw new Error("require not available");
54
- };
55
- if (!_require) _require = nodeRequire.createRequire(_importMetaUrl);
56
- return _require;
57
- }
58
24
  function platformKey() {
59
25
  if (isBrowser) return "browser";
60
26
  return `${process.platform}-${process.arch}`;
@@ -65,9 +31,9 @@ function resolveNativeBinary(runtimeDir) {
65
31
  if (isBrowser) {
66
32
  return { path: null, source: "not-found", platform, tried: ["not available in browser"] };
67
33
  }
68
- const fs = getNodeFs();
69
- const path = getNodePath();
70
- const _req = getRequire(import.meta.url);
34
+ if (process.env.TWS_DISABLE_NATIVE === "1") {
35
+ return { path: null, source: "not-found", platform, tried: [] };
36
+ }
71
37
  const envPath = process.env.TW_NATIVE_PATH?.trim();
72
38
  if (envPath) {
73
39
  if (fs.existsSync(envPath)) {
@@ -75,13 +41,10 @@ function resolveNativeBinary(runtimeDir) {
75
41
  }
76
42
  tried.push(`env:${envPath} (not found)`);
77
43
  }
78
- if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_NO_RUST === "1" || process.env.TWS_DISABLE_NATIVE === "1") {
79
- return { path: null, source: "not-found", platform, tried: ["disabled by env"] };
80
- }
81
44
  const prebuiltPkgs = PLATFORM_MAP[platform] ?? [];
82
45
  for (const pkg of prebuiltPkgs) {
83
46
  try {
84
- const candidate = _req.resolve(`${pkg}/tailwind_styled_parser.node`);
47
+ const candidate = _require.resolve(`${pkg}/tailwind_styled_parser.node`);
85
48
  if (fs.existsSync(candidate)) {
86
49
  return { path: candidate, source: "prebuilt", platform, tried };
87
50
  }
@@ -92,14 +55,30 @@ function resolveNativeBinary(runtimeDir) {
92
55
  }
93
56
  const cwd = process.cwd();
94
57
  const base = runtimeDir ?? cwd;
95
- const localCandidates = [
96
- path.resolve(base, "tailwind_styled_parser.node"),
97
- path.resolve(base, "..", "tailwind_styled_parser.node"),
98
- path.resolve(cwd, "native", "tailwind_styled_parser.node"),
99
- path.resolve(cwd, "native", "target", "release", "tailwind_styled_parser.node"),
100
- // napi-rs conventional output
101
- path.resolve(base, `tailwind_styled_parser.${platform}.node`)
102
- ];
58
+ const napiPlatform = platform === "linux-x64" ? "linux-x64-gnu" : platform === "linux-arm64" ? "linux-arm64-gnu" : platform;
59
+ const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
60
+ const localCandidates = [];
61
+ for (const bin of BINARY_NAMES) {
62
+ localCandidates.push(path.resolve(base, `${bin}.node`));
63
+ localCandidates.push(path.resolve(base, "..", `${bin}.node`));
64
+ localCandidates.push(path.resolve(base, `${bin}.${platform}.node`));
65
+ localCandidates.push(path.resolve(base, `${bin}.${napiPlatform}.node`));
66
+ }
67
+ for (const startDir of [cwd, base]) {
68
+ let dir = startDir;
69
+ for (let i = 0; i < 6; i++) {
70
+ const nativeDir = path.resolve(dir, "native");
71
+ for (const bin of BINARY_NAMES) {
72
+ localCandidates.push(path.resolve(nativeDir, `${bin}.node`));
73
+ localCandidates.push(path.resolve(nativeDir, `${bin}.${platform}.node`));
74
+ localCandidates.push(path.resolve(nativeDir, `${bin}.${napiPlatform}.node`));
75
+ localCandidates.push(path.resolve(nativeDir, "target", "release", `${bin}.node`));
76
+ }
77
+ const parent = path.resolve(dir, "..");
78
+ if (parent === dir) break;
79
+ dir = parent;
80
+ }
81
+ }
103
82
  for (const candidate of localCandidates) {
104
83
  tried.push(`local:${candidate}`);
105
84
  if (fs.existsSync(candidate)) {
@@ -108,14 +87,11 @@ function resolveNativeBinary(runtimeDir) {
108
87
  }
109
88
  return { path: null, source: "not-found", platform, tried };
110
89
  }
111
- var isBrowser, nodeModuleRef, _nodeFs, _nodePath, _require, PLATFORM_MAP;
90
+ var isBrowser, _require, PLATFORM_MAP;
112
91
  var init_native_resolution = __esm({
113
92
  "packages/domain/shared/src/native-resolution.ts"() {
114
93
  isBrowser = typeof window !== "undefined" || typeof document !== "undefined";
115
- nodeModuleRef = null;
116
- _nodeFs = null;
117
- _nodePath = null;
118
- _require = null;
94
+ _require = typeof __require !== "undefined" ? __require : createRequire(import.meta.url);
119
95
  PLATFORM_MAP = {
120
96
  "linux-x64": ["@tailwind-styled/native-linux-x64"],
121
97
  "linux-arm64": ["@tailwind-styled/native-linux-arm64"],
@@ -126,59 +102,26 @@ var init_native_resolution = __esm({
126
102
  };
127
103
  }
128
104
  });
129
-
130
- // packages/domain/shared/src/index.ts
131
- function getNodeModuleRef2() {
132
- if (isBrowser2) return null;
133
- if (nodeModuleRef2 !== null) return nodeModuleRef2;
134
- try {
135
- const test = typeof __require === "function" ? __require("module") : null;
136
- nodeModuleRef2 = test;
137
- return test;
138
- } catch {
139
- nodeModuleRef2 = null;
140
- return null;
141
- }
142
- }
143
- function getNodeUrl() {
144
- if (isBrowser2) throw new Error("node:url not available in browser");
145
- const nodeRequire = getNodeModuleRef2();
146
- if (!nodeRequire) throw new Error("require not available");
147
- if (!_nodeUrl) _nodeUrl = nodeRequire.createRequire(import.meta.url)("node:url");
148
- return _nodeUrl;
149
- }
150
- function getRequire2() {
151
- if (isBrowser2) return (() => {
152
- throw new Error("require not available in browser");
153
- });
154
- const nodeRequire = getNodeModuleRef2();
155
- if (!nodeRequire) return (() => {
156
- throw new Error("require not available");
157
- });
158
- return nodeRequire.createRequire(import.meta.url);
159
- }
160
105
  function resolveRuntimeDir(dir, importMetaUrl) {
161
- if (isBrowser2) return "";
162
106
  try {
163
- return getNodeUrl().fileURLToPath(importMetaUrl);
107
+ return path__default.dirname(fileURLToPath(importMetaUrl));
164
108
  } catch {
165
109
  return process.cwd();
166
110
  }
167
111
  }
168
- var isBrowser2, nodeModuleRef2, _nodeUrl;
169
112
  var init_src = __esm({
170
113
  "packages/domain/shared/src/index.ts"() {
171
114
  init_native_resolution();
172
- isBrowser2 = typeof window !== "undefined" || typeof document !== "undefined";
173
- nodeModuleRef2 = null;
174
- _nodeUrl = null;
175
- getRequire2();
115
+ createRequire(import.meta.url);
176
116
  }
177
117
  });
178
- var log, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttempted, bridgeLoadError, isValidNativeBridge, getNativeBridge, resetNativeBridgeCache, adaptNativeResult;
118
+
119
+ // packages/domain/compiler/src/nativeBridge.ts
120
+ var _loadNative, log, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttempted, bridgeLoadError, isValidNativeBridge, getNativeBridge, resetNativeBridgeCache, adaptNativeResult;
179
121
  var init_nativeBridge = __esm({
180
122
  "packages/domain/compiler/src/nativeBridge.ts"() {
181
123
  init_src();
124
+ _loadNative = (path3) => __require(path3);
182
125
  log = (...args) => {
183
126
  if (process.env.DEBUG?.includes("compiler:native")) {
184
127
  console.log("[compiler:native]", ...args);
@@ -205,11 +148,10 @@ var init_nativeBridge = __esm({
205
148
  bridgeLoadAttempted = true;
206
149
  try {
207
150
  const runtimeDir = resolveRuntimeDir(void 0, import.meta.url);
208
- const require3 = createRequire(import.meta.url);
209
151
  const result = resolveNativeBinary(runtimeDir);
210
152
  if (result.path && result.path.endsWith(".node")) {
211
153
  try {
212
- const binding = require3(result.path);
154
+ const binding = _loadNative(result.path);
213
155
  if (isValidNativeBridge(binding)) {
214
156
  nativeBridge = binding;
215
157
  log("Native bridge loaded successfully from:", result.path);
@@ -256,6 +198,7 @@ Tried paths: ${result.tried.join("\n")}`);
256
198
  var tailwindEngine_exports = {};
257
199
  __export(tailwindEngine_exports, {
258
200
  generateRawCss: () => generateRawCss,
201
+ processTailwindCssWithTargets: () => processTailwindCssWithTargets,
259
202
  runCssPipeline: () => runCssPipeline,
260
203
  runCssPipelineSync: () => runCssPipelineSync
261
204
  });
@@ -283,12 +226,11 @@ function generateRawCss(classes) {
283
226
  function postProcessWithLightning(rawCss) {
284
227
  if (!rawCss) return "";
285
228
  const native = getNativeBridge();
286
- if (typeof native.processTailwindCssLightning === "function") {
287
- const result = native.processTailwindCssLightning(rawCss);
288
- return result?.css ?? rawCss;
229
+ if (typeof native.processTailwindCssLightning !== "function") {
230
+ throw new Error("FATAL: Native binding 'processTailwindCssLightning' is required but not available.");
289
231
  }
290
- console.warn("[tailwind-styled] processTailwindCssLightning tidak tersedia \u2014 gunakan raw CSS");
291
- return rawCss;
232
+ const result = native.processTailwindCssLightning(rawCss);
233
+ return result?.css ?? rawCss;
292
234
  }
293
235
  async function runCssPipeline(classes) {
294
236
  const unique = [...new Set(classes.filter(Boolean))];
@@ -322,6 +264,14 @@ function runCssPipelineSync(classes) {
322
264
  optimized: hasLightning
323
265
  };
324
266
  }
267
+ function processTailwindCssWithTargets(css, targets) {
268
+ const native = getNativeBridge();
269
+ if (!native?.processTailwindCssWithTargets) {
270
+ throw new Error("FATAL: Native binding 'processTailwindCssWithTargets' is required but not available.");
271
+ }
272
+ const result = native.processTailwindCssWithTargets(css, targets ?? null);
273
+ return (result?.css ?? css).trim();
274
+ }
325
275
  var require2, _twEngine, _twEngineError;
326
276
  var init_tailwindEngine = __esm({
327
277
  "packages/domain/compiler/src/tailwindEngine.ts"() {
@@ -410,18 +360,10 @@ var astExtractClasses = (source, filename) => {
410
360
  var parseClasses = (raw) => {
411
361
  const native = getNativeBridge();
412
362
  if (!native?.parseClasses) {
413
- return parseClassesJs(raw);
363
+ throw new Error("FATAL: Native binding 'parseClasses' is required but not available.");
414
364
  }
415
365
  return native.parseClasses(raw) || [];
416
366
  };
417
- function parseClassesJs(raw) {
418
- if (!raw || typeof raw !== "string") return [];
419
- const classes = raw.split(/\s+/).filter(Boolean);
420
- return classes.map((cls) => ({
421
- raw: cls,
422
- type: cls.includes(":") ? "variant" : cls.includes("/") ? "arbitrary" : "utility"
423
- }));
424
- }
425
367
  var normalizeClasses = (raw) => {
426
368
  const result = normalizeAndDedupClasses(raw);
427
369
  return result?.normalized || "";
@@ -430,75 +372,81 @@ var mergeClassesStatic = (classes) => {
430
372
  const result = normalizeAndDedupClasses(classes);
431
373
  return result?.normalized || "";
432
374
  };
433
- function normalizeAndDedupClassesJs(raw) {
434
- const seen = /* @__PURE__ */ new Set();
435
- const result = [];
436
- let duplicatesRemoved = 0;
437
- for (const token of raw.split(/\s+/)) {
438
- if (token.length === 0) continue;
439
- if (seen.has(token)) {
440
- duplicatesRemoved++;
441
- } else {
442
- seen.add(token);
443
- result.push(token);
444
- }
445
- }
446
- return {
447
- normalized: result.join(" "),
448
- duplicatesRemoved,
449
- uniqueCount: result.length
450
- };
451
- }
452
375
  var normalizeAndDedupClasses = (raw) => {
453
376
  const native = getNativeBridge();
454
377
  if (!native?.normalizeAndDedupClasses) {
455
- return normalizeAndDedupClassesJs(raw);
378
+ throw new Error("FATAL: Native binding 'normalizeAndDedupClasses' is required but not available.");
456
379
  }
457
380
  const result = native.normalizeAndDedupClasses(raw);
458
381
  return result || { normalized: "", duplicatesRemoved: 0, uniqueCount: 0 };
459
382
  };
460
383
  var eliminateDeadCss = (css, deadClasses) => {
461
- let result = css;
462
- for (const dead of deadClasses) {
463
- result = result.replace(new RegExp(`\\.${dead.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}[^{]*\\{[^}]*\\}`, "g"), "");
384
+ const native = getNativeBridge();
385
+ if (!native?.processTailwindCssLightning) {
386
+ throw new Error("FATAL: Native binding 'processTailwindCssLightning' is required but not available.");
464
387
  }
465
- return result;
388
+ const deadSet = deadClasses;
389
+ const pruned = css.split(/(?<=\})\s*/).filter((rule) => {
390
+ const m = rule.match(/\.([a-zA-Z0-9_-]+)/);
391
+ return !m || !deadSet.has(m[1]);
392
+ }).join("\n");
393
+ const compiled = native.processTailwindCssLightning(pruned);
394
+ return (compiled?.css ?? pruned).trim();
466
395
  };
467
396
  var findDeadVariants = (variantConfig, usage) => {
468
397
  const unused = [];
469
- const variants = variantConfig;
470
- for (const [key, values] of Object.entries(variants)) {
471
- for (const [value] of Object.entries(values)) {
472
- const keyValue = `${key}:${value}`;
473
- if (!usage[key]?.has(value)) {
474
- unused.push(keyValue);
398
+ const configs = Array.isArray(variantConfig) ? variantConfig : [{ name: "__root__", variants: variantConfig }];
399
+ for (const component of configs) {
400
+ const componentUsage = usage[component.name] ?? /* @__PURE__ */ new Set();
401
+ const variants = component.variants;
402
+ for (const [key, values] of Object.entries(variants)) {
403
+ for (const [value] of Object.entries(values)) {
404
+ if (!componentUsage.has(`${key}:${value}`)) {
405
+ unused.push(`${component.name !== "__root__" ? `${component.name}/` : ""}${key}:${value}`);
406
+ }
475
407
  }
476
408
  }
477
409
  }
478
- return unused;
410
+ return {
411
+ unusedCount: unused.length,
412
+ unused
413
+ };
479
414
  };
480
415
  var runElimination = (css, scanResult) => {
481
- const scanJson = JSON.stringify(scanResult);
482
- const classes = extractAllClasses(css);
483
- const usage = analyzeClassUsage(classes, scanJson, css) || [];
484
- const deadClasses = new Set(usage.filter((u) => u.isDeadCode).map((u) => u.className));
485
- return eliminateDeadCss(css, deadClasses);
416
+ const native = getNativeBridge();
417
+ if (!native?.detectDeadCode) {
418
+ throw new Error("FATAL: Native binding 'detectDeadCode' is required but not available.");
419
+ }
420
+ const dead = native.detectDeadCode(
421
+ JSON.stringify(scanResult),
422
+ css
423
+ );
424
+ return eliminateDeadCss(css, new Set(dead.deadInCss ?? []));
486
425
  };
487
426
  var optimizeCss = (css) => {
488
- const classes = extractAllClasses(css);
489
- const usage = analyzeClassUsage(classes, "[]", css) || [];
490
- const usedClasses = new Set(usage.filter((u) => !u.isDeadCode).map((u) => u.className));
491
- let result = css;
492
- const classRegex = /\.([a-zA-Z0-9_-]+)/g;
493
- result = result.replace(classRegex, (match, className) => {
494
- return usedClasses.has(className) ? match : "";
495
- });
496
- result = result.replace(/[^{}]*\{\s*\}/g, "");
497
- return result.trim();
427
+ const native = getNativeBridge();
428
+ if (!native?.detectDeadCode) {
429
+ throw new Error("FATAL: Native binding 'detectDeadCode' is required but not available.");
430
+ }
431
+ const deadResult = native.detectDeadCode(
432
+ JSON.stringify({ uniqueClasses: [] }),
433
+ css
434
+ );
435
+ if (!native?.processTailwindCssLightning) {
436
+ throw new Error("FATAL: Native binding 'processTailwindCssLightning' is required but not available.");
437
+ }
438
+ const deadSet = new Set(deadResult.deadInCss ?? []);
439
+ const pruned = css.split(/(?<=\})\s*/).filter((rule) => {
440
+ const selectorMatch = rule.match(/\.([a-zA-Z0-9_-]+)/);
441
+ if (!selectorMatch) return true;
442
+ return !deadSet.has(selectorMatch[1]);
443
+ }).join("\n");
444
+ const compiled = native.processTailwindCssLightning(pruned);
445
+ return (compiled?.css ?? pruned).trim();
498
446
  };
499
447
  var scanProjectUsage = (dirs, cwd) => {
500
- const path = __require("path");
501
- const files = dirs.map((dir) => path.resolve(cwd, dir));
448
+ const path3 = __require("path");
449
+ const files = dirs.map((dir) => path3.resolve(cwd, dir));
502
450
  const results = batchExtractClasses(files) || [];
503
451
  const combined = {};
504
452
  for (const result of results) {
@@ -622,23 +570,23 @@ var generateSafelist = (scanDirs, outputPath, cwd) => {
622
570
  const classes = scanProjectUsage(scanDirs, cwd || process.cwd());
623
571
  const allClasses = Object.keys(classes).sort();
624
572
  if (outputPath) {
625
- const fs = __require("fs");
626
- fs.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
573
+ const fs3 = __require("fs");
574
+ fs3.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
627
575
  }
628
576
  return allClasses;
629
577
  };
630
578
  var loadSafelist = (safelistPath) => {
631
- const fs = __require("fs");
579
+ const fs3 = __require("fs");
632
580
  try {
633
- const content = fs.readFileSync(safelistPath, "utf-8");
581
+ const content = fs3.readFileSync(safelistPath, "utf-8");
634
582
  return JSON.parse(content);
635
583
  } catch {
636
584
  return [];
637
585
  }
638
586
  };
639
587
  var loadTailwindConfig = (cwd = process.cwd()) => {
640
- const fs = __require("fs");
641
- const path = __require("path");
588
+ const fs3 = __require("fs");
589
+ const path3 = __require("path");
642
590
  const configFiles = [
643
591
  "tailwind.config.ts",
644
592
  "tailwind.config.js",
@@ -646,8 +594,8 @@ var loadTailwindConfig = (cwd = process.cwd()) => {
646
594
  "tailwind.config.cjs"
647
595
  ];
648
596
  for (const file of configFiles) {
649
- const fullPath = path.join(cwd, file);
650
- if (fs.existsSync(fullPath)) {
597
+ const fullPath = path3.join(cwd, file);
598
+ if (fs3.existsSync(fullPath)) {
651
599
  const mod = __require(fullPath);
652
600
  return mod.default || mod;
653
601
  }
@@ -655,12 +603,12 @@ var loadTailwindConfig = (cwd = process.cwd()) => {
655
603
  return {};
656
604
  };
657
605
  var getContentPaths = (cwd = process.cwd()) => {
658
- const path = __require("path");
606
+ const path3 = __require("path");
659
607
  return {
660
608
  content: [
661
- path.join(cwd, "src/**/*.{js,ts,jsx,tsx}"),
662
- path.join(cwd, "app/**/*.{js,ts,jsx,tsx}"),
663
- path.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
609
+ path3.join(cwd, "src/**/*.{js,ts,jsx,tsx}"),
610
+ path3.join(cwd, "app/**/*.{js,ts,jsx,tsx}"),
611
+ path3.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
664
612
  ]
665
613
  };
666
614
  };
@@ -696,58 +644,67 @@ var fileToRoute = (filepath) => {
696
644
  return null;
697
645
  };
698
646
  var getAllRoutes = () => {
647
+ const native = getNativeBridge();
648
+ if (!native?.analyzeClasses) {
649
+ throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
650
+ }
699
651
  return ["/", "__global"];
700
652
  };
701
- var getRouteClasses = (route) => {
653
+ var getRouteClasses = (_route) => {
702
654
  return /* @__PURE__ */ new Set();
703
655
  };
704
- var registerFileClasses = (filepath, classes) => {
656
+ var registerFileClasses = (_filepath, _classes) => {
705
657
  };
706
- var registerGlobalClasses = (classes) => {
658
+ var registerGlobalClasses = (_classes) => {
707
659
  };
708
- var incrementalEngineInstance = null;
660
+ var _incrementalEngineInstance = null;
709
661
  var getIncrementalEngine = () => {
710
- if (!incrementalEngineInstance) {
711
- incrementalEngineInstance = {
712
- compile: (source) => transformSource(source)
713
- };
662
+ if (!_incrementalEngineInstance) {
663
+ _incrementalEngineInstance = new IncrementalEngine();
714
664
  }
715
- return incrementalEngineInstance;
665
+ return _incrementalEngineInstance;
716
666
  };
717
667
  var resetIncrementalEngine = () => {
718
- incrementalEngineInstance = null;
668
+ _incrementalEngineInstance = null;
719
669
  };
720
670
  var IncrementalEngine = class {
721
671
  compile(source) {
722
672
  return transformSource(source);
723
673
  }
724
674
  };
725
- var bucketEngineInstance = null;
726
675
  var getBucketEngine = () => {
727
- if (!bucketEngineInstance) {
728
- bucketEngineInstance = {
729
- add: (className) => className,
730
- get: (bucket) => []
731
- };
676
+ const native = getNativeBridge();
677
+ if (!native?.classifyAndSortClasses) {
678
+ throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
732
679
  }
733
- return bucketEngineInstance;
680
+ return {
681
+ add: (className) => className,
682
+ get: (_bucket) => []
683
+ };
734
684
  };
735
685
  var resetBucketEngine = () => {
736
- bucketEngineInstance = null;
737
686
  };
738
687
  var BucketEngine = class {
739
688
  add(className) {
740
689
  return className;
741
690
  }
742
691
  };
743
- var classifyNode = (node) => {
692
+ var classifyNode = (_node) => {
693
+ const native = getNativeBridge();
694
+ if (!native?.classifyAndSortClasses) {
695
+ throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
696
+ }
744
697
  return "unknown";
745
698
  };
746
699
  var detectConflicts = (classes) => {
700
+ const native = getNativeBridge();
701
+ if (!native?.analyzeClassUsage) {
702
+ throw new Error("FATAL: Native binding 'analyzeClassUsage' is required but not available.");
703
+ }
747
704
  return [];
748
705
  };
749
706
  var bucketSort = (classes) => {
750
- return classes;
707
+ return classifyAndSortClasses(classes).map((c) => c.raw ?? c);
751
708
  };
752
709
 
753
710
  export { BucketEngine, IncrementalEngine, adaptNativeResult, analyzeClassUsage, analyzeClasses, analyzeFile, analyzeRsc, analyzeVariantUsage, astExtractClasses, batchExtractClasses, bucketSort, buildStyleTag, checkAgainstSafelist, classifyAndSortClasses, classifyNode, compileCssFromClasses, compileCssNative, compileVariantTable, compileVariants, detectConflicts, diffClassLists, eliminateDeadCss, extractAllClasses, extractClassesFromSource, extractComponentUsage, fileToRoute, findDeadVariants, generateCssForClasses, generateSafelist, getAllRoutes, getBucketEngine, getContentPaths, getIncrementalEngine, getNativeBridge, getRouteClasses, hasTwUsage, hoistComponents, injectClientDirective, injectServerOnlyComment, isAlreadyTransformed, loadSafelist, loadTailwindConfig, mergeClassesStatic, mergeCssDeclarations, normalizeAndDedupClasses, normalizeClasses, optimizeCss, parseClasses, registerFileClasses, registerGlobalClasses, resetBucketEngine, resetIncrementalEngine, resetNativeBridgeCache, runElimination, runLoaderTransform, scanProjectUsage, shouldProcess, shouldSkipFile, transformSource };