tailwind-styled-v4 4.0.0 → 5.0.1

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 (194) hide show
  1. package/CHANGELOG.md +398 -0
  2. package/LICENSE +21 -0
  3. package/README.md +532 -0
  4. package/dist/analyzer.d.mts +114 -0
  5. package/dist/analyzer.d.ts +114 -0
  6. package/dist/analyzer.js +1555 -0
  7. package/dist/analyzer.js.map +1 -0
  8. package/dist/analyzer.mjs +1544 -0
  9. package/dist/analyzer.mjs.map +1 -0
  10. package/dist/animate.d.mts +46 -0
  11. package/dist/animate.d.ts +41 -112
  12. package/dist/animate.js +792 -235
  13. package/dist/animate.js.map +1 -1
  14. package/dist/animate.mjs +782 -0
  15. package/dist/animate.mjs.map +1 -0
  16. package/dist/atomic.d.mts +18 -0
  17. package/dist/atomic.d.ts +18 -0
  18. package/dist/atomic.js +191 -0
  19. package/dist/atomic.js.map +1 -0
  20. package/dist/atomic.mjs +185 -0
  21. package/dist/atomic.mjs.map +1 -0
  22. package/dist/cli.d.mts +1 -0
  23. package/dist/cli.d.ts +1 -0
  24. package/dist/cli.js +6063 -0
  25. package/dist/cli.js.map +1 -0
  26. package/dist/cli.mjs +6053 -0
  27. package/dist/cli.mjs.map +1 -0
  28. package/dist/{compiler.d.cts → compiler.d.mts} +503 -210
  29. package/dist/compiler.d.ts +503 -210
  30. package/dist/compiler.js +1549 -566
  31. package/dist/compiler.js.map +1 -1
  32. package/dist/{compiler.cjs → compiler.mjs} +1476 -627
  33. package/dist/compiler.mjs.map +1 -0
  34. package/dist/dashboard.d.mts +272 -0
  35. package/dist/dashboard.d.ts +272 -0
  36. package/dist/dashboard.js +249 -0
  37. package/dist/dashboard.js.map +1 -0
  38. package/dist/dashboard.mjs +239 -0
  39. package/dist/dashboard.mjs.map +1 -0
  40. package/dist/devtools.js +336 -211
  41. package/dist/devtools.js.map +1 -1
  42. package/dist/{devtools.cjs → devtools.mjs} +331 -220
  43. package/dist/devtools.mjs.map +1 -0
  44. package/dist/engine.d.mts +84 -0
  45. package/dist/engine.d.ts +84 -0
  46. package/dist/engine.js +3014 -0
  47. package/dist/engine.js.map +1 -0
  48. package/dist/engine.mjs +3005 -0
  49. package/dist/engine.mjs.map +1 -0
  50. package/dist/{index.d.cts → index.d.mts} +75 -4
  51. package/dist/index.d.ts +75 -4
  52. package/dist/index.js +1341 -149
  53. package/dist/index.js.map +1 -1
  54. package/dist/index.mjs +2162 -0
  55. package/dist/index.mjs.map +1 -0
  56. package/dist/liveTokenEngine-DYN3Zale.d.mts +34 -0
  57. package/dist/liveTokenEngine-DYN3Zale.d.ts +34 -0
  58. package/dist/next.d.mts +55 -0
  59. package/dist/next.d.ts +30 -20
  60. package/dist/next.js +6947 -149
  61. package/dist/next.js.map +1 -1
  62. package/dist/next.mjs +7050 -0
  63. package/dist/next.mjs.map +1 -0
  64. package/dist/plugin.d.mts +90 -0
  65. package/dist/plugin.d.ts +90 -0
  66. package/dist/plugin.js +185 -0
  67. package/dist/plugin.js.map +1 -0
  68. package/dist/plugin.mjs +174 -0
  69. package/dist/plugin.mjs.map +1 -0
  70. package/dist/pluginRegistry.d.mts +83 -0
  71. package/dist/pluginRegistry.d.ts +83 -0
  72. package/dist/pluginRegistry.js +303 -0
  73. package/dist/pluginRegistry.js.map +1 -0
  74. package/dist/pluginRegistry.mjs +298 -0
  75. package/dist/pluginRegistry.mjs.map +1 -0
  76. package/dist/{preset.d.cts → preset.d.mts} +29 -2
  77. package/dist/preset.d.ts +29 -2
  78. package/dist/preset.js +318 -21
  79. package/dist/preset.js.map +1 -1
  80. package/dist/preset.mjs +414 -0
  81. package/dist/preset.mjs.map +1 -0
  82. package/dist/rspack.d.mts +33 -0
  83. package/dist/rspack.d.ts +33 -0
  84. package/dist/rspack.js +55 -0
  85. package/dist/rspack.js.map +1 -0
  86. package/dist/rspack.mjs +45 -0
  87. package/dist/rspack.mjs.map +1 -0
  88. package/dist/runtime.d.mts +62 -0
  89. package/dist/runtime.d.ts +62 -0
  90. package/dist/runtime.js +207 -0
  91. package/dist/runtime.js.map +1 -0
  92. package/dist/runtime.mjs +188 -0
  93. package/dist/runtime.mjs.map +1 -0
  94. package/dist/runtimeCss.d.mts +65 -0
  95. package/dist/runtimeCss.d.ts +65 -0
  96. package/dist/runtimeCss.js +188 -0
  97. package/dist/runtimeCss.js.map +1 -0
  98. package/dist/runtimeCss.mjs +173 -0
  99. package/dist/runtimeCss.mjs.map +1 -0
  100. package/dist/scanner.d.mts +25 -0
  101. package/dist/scanner.d.ts +25 -0
  102. package/dist/scanner.js +717 -0
  103. package/dist/scanner.js.map +1 -0
  104. package/dist/scanner.mjs +703 -0
  105. package/dist/scanner.mjs.map +1 -0
  106. package/dist/shared.d.mts +85 -0
  107. package/dist/shared.d.ts +85 -0
  108. package/dist/shared.js +255 -0
  109. package/dist/shared.js.map +1 -0
  110. package/dist/shared.mjs +233 -0
  111. package/dist/shared.mjs.map +1 -0
  112. package/dist/storybookAddon.d.mts +108 -0
  113. package/dist/storybookAddon.d.ts +108 -0
  114. package/dist/storybookAddon.js +95 -0
  115. package/dist/storybookAddon.js.map +1 -0
  116. package/dist/storybookAddon.mjs +88 -0
  117. package/dist/storybookAddon.mjs.map +1 -0
  118. package/dist/svelte.d.mts +114 -0
  119. package/dist/svelte.d.ts +114 -0
  120. package/dist/svelte.js +67 -0
  121. package/dist/svelte.js.map +1 -0
  122. package/dist/svelte.mjs +59 -0
  123. package/dist/svelte.mjs.map +1 -0
  124. package/dist/testing.d.mts +185 -0
  125. package/dist/testing.d.ts +185 -0
  126. package/dist/testing.js +173 -0
  127. package/dist/testing.js.map +1 -0
  128. package/dist/testing.mjs +158 -0
  129. package/dist/testing.mjs.map +1 -0
  130. package/dist/{theme.d.cts → theme.d.mts} +18 -11
  131. package/dist/theme.d.ts +18 -11
  132. package/dist/theme.js +205 -19
  133. package/dist/theme.js.map +1 -1
  134. package/dist/theme.mjs +311 -0
  135. package/dist/theme.mjs.map +1 -0
  136. package/dist/types-DXr2PmGP.d.mts +31 -0
  137. package/dist/types-DXr2PmGP.d.ts +31 -0
  138. package/dist/vite.d.mts +51 -0
  139. package/dist/vite.d.ts +35 -6
  140. package/dist/vite.js +4254 -57
  141. package/dist/vite.js.map +1 -1
  142. package/dist/vite.mjs +4281 -0
  143. package/dist/vite.mjs.map +1 -0
  144. package/dist/vue.d.mts +89 -0
  145. package/dist/vue.d.ts +89 -0
  146. package/dist/vue.js +104 -0
  147. package/dist/vue.js.map +1 -0
  148. package/dist/vue.mjs +96 -0
  149. package/dist/vue.mjs.map +1 -0
  150. package/package.json +173 -67
  151. package/dist/animate.cjs +0 -252
  152. package/dist/animate.cjs.map +0 -1
  153. package/dist/animate.d.cts +0 -117
  154. package/dist/astTransform-ua-eapqs.d.cts +0 -41
  155. package/dist/astTransform-ua-eapqs.d.ts +0 -41
  156. package/dist/compiler.cjs.map +0 -1
  157. package/dist/css.cjs +0 -71
  158. package/dist/css.cjs.map +0 -1
  159. package/dist/css.d.cts +0 -45
  160. package/dist/css.d.ts +0 -45
  161. package/dist/css.js +0 -62
  162. package/dist/css.js.map +0 -1
  163. package/dist/devtools.cjs.map +0 -1
  164. package/dist/index.cjs +0 -1058
  165. package/dist/index.cjs.map +0 -1
  166. package/dist/next.cjs +0 -268
  167. package/dist/next.cjs.map +0 -1
  168. package/dist/next.d.cts +0 -45
  169. package/dist/plugins.cjs +0 -396
  170. package/dist/plugins.cjs.map +0 -1
  171. package/dist/plugins.d.cts +0 -231
  172. package/dist/plugins.d.ts +0 -231
  173. package/dist/plugins.js +0 -381
  174. package/dist/plugins.js.map +0 -1
  175. package/dist/preset.cjs +0 -129
  176. package/dist/preset.cjs.map +0 -1
  177. package/dist/theme.cjs +0 -154
  178. package/dist/theme.cjs.map +0 -1
  179. package/dist/turbopackLoader.cjs +0 -2689
  180. package/dist/turbopackLoader.cjs.map +0 -1
  181. package/dist/turbopackLoader.d.cts +0 -22
  182. package/dist/turbopackLoader.d.ts +0 -22
  183. package/dist/turbopackLoader.js +0 -2681
  184. package/dist/turbopackLoader.js.map +0 -1
  185. package/dist/vite.cjs +0 -105
  186. package/dist/vite.cjs.map +0 -1
  187. package/dist/vite.d.cts +0 -22
  188. package/dist/webpackLoader.cjs +0 -2670
  189. package/dist/webpackLoader.cjs.map +0 -1
  190. package/dist/webpackLoader.d.cts +0 -24
  191. package/dist/webpackLoader.d.ts +0 -24
  192. package/dist/webpackLoader.js +0 -2662
  193. package/dist/webpackLoader.js.map +0 -1
  194. /package/dist/{devtools.d.cts → devtools.d.mts} +0 -0
@@ -0,0 +1,1544 @@
1
+ import fs2 from 'fs';
2
+ import { createRequire } from 'module';
3
+ import os from 'os';
4
+ import path5 from 'path';
5
+ import { pathToFileURL, fileURLToPath } from 'url';
6
+ import { Worker } from 'worker_threads';
7
+
8
+ /* tailwind-styled-v4 v5.0.1 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
9
+ var __defProp = Object.defineProperty;
10
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11
+ var __getOwnPropNames = Object.getOwnPropertyNames;
12
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
13
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
14
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
15
+ }) : x)(function(x) {
16
+ if (typeof require !== "undefined") return require.apply(this, arguments);
17
+ throw Error('Dynamic require of "' + x + '" is not supported');
18
+ });
19
+ var __esm = (fn, res) => function __init() {
20
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
21
+ };
22
+ var __export = (target, all) => {
23
+ for (var name in all)
24
+ __defProp(target, name, { get: all[name], enumerable: true });
25
+ };
26
+ var __copyProps = (to, from, except, desc) => {
27
+ if (from && typeof from === "object" || typeof from === "function") {
28
+ for (let key of __getOwnPropNames(from))
29
+ if (!__hasOwnProp.call(to, key) && key !== except)
30
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
31
+ }
32
+ return to;
33
+ };
34
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
+ function getPlatformExtension() {
36
+ const platform = os.platform();
37
+ switch (platform) {
38
+ case "win32":
39
+ return ".node";
40
+ case "darwin":
41
+ return ".dylib";
42
+ case "linux":
43
+ return ".so";
44
+ default:
45
+ return ".node";
46
+ }
47
+ }
48
+ function formatErrorMessage(error) {
49
+ return error instanceof Error ? error.message : String(error);
50
+ }
51
+ function resolveRuntimeDir(dirnameValue, moduleImportUrl) {
52
+ if (typeof dirnameValue === "string" && dirnameValue.length > 0) return dirnameValue;
53
+ return path5.dirname(fileURLToPath(moduleImportUrl));
54
+ }
55
+ function resolveNativeBindingCandidates(options) {
56
+ const out = [];
57
+ const envVarNames = options.envVarNames ?? ["TWS_NATIVE_PATH"];
58
+ for (const envVarName of envVarNames) {
59
+ const raw = process.env[envVarName]?.trim();
60
+ if (!raw) continue;
61
+ const resolved = path5.resolve(raw);
62
+ if (options.enforceNodeExtensionForEnvPath) {
63
+ if (path5.extname(resolved).toLowerCase() !== ".node") {
64
+ throw new Error(
65
+ `Invalid native binding path from ${envVarName}="${raw}". Expected a .node file.`
66
+ );
67
+ }
68
+ }
69
+ out.push(resolved);
70
+ }
71
+ if (options.includeDefaultCandidates !== false) {
72
+ const ext = options.platformExtension ?? getPlatformExtension();
73
+ const defaultBindingName = `tailwind_styled_parser${ext}`;
74
+ out.push(path5.resolve(process.cwd(), "native", defaultBindingName));
75
+ out.push(path5.resolve(options.runtimeDir, "..", "..", "..", "native", defaultBindingName));
76
+ }
77
+ return Array.from(new Set(out));
78
+ }
79
+ function parseDebugToken(namespace, token) {
80
+ if (token === "*" || token === namespace || token === "tailwind-styled:*") return true;
81
+ return token.endsWith("*") && namespace.startsWith(token.slice(0, -1));
82
+ }
83
+ function isDebugNamespaceEnabled(namespace) {
84
+ if (process.env.TWS_DEBUG === "1" || process.env.TAILWIND_STYLED_DEBUG === "1") return true;
85
+ const raw = process.env.DEBUG;
86
+ if (!raw) return false;
87
+ return raw.split(",").map((token) => token.trim()).some((token) => parseDebugToken(namespace, token));
88
+ }
89
+ function createDebugLogger(namespace, label = namespace) {
90
+ const debugEnabled = isDebugNamespaceEnabled(namespace);
91
+ return (message) => {
92
+ if (!debugEnabled) return;
93
+ console.debug(`[${label}] ${message}`);
94
+ };
95
+ }
96
+ function loadNativeBinding(options) {
97
+ const req = createRequire(path5.join(options.runtimeDir, "noop.cjs"));
98
+ const loadErrors = [];
99
+ for (const candidate of options.candidates) {
100
+ if (!fs2.existsSync(candidate)) continue;
101
+ try {
102
+ const mod = req(candidate);
103
+ if (options.isValid(mod)) {
104
+ return {
105
+ binding: mod,
106
+ loadedPath: candidate,
107
+ loadErrors
108
+ };
109
+ }
110
+ loadErrors.push({
111
+ path: candidate,
112
+ message: options.invalidExportMessage
113
+ });
114
+ } catch (error) {
115
+ loadErrors.push({
116
+ path: candidate,
117
+ message: formatErrorMessage(error)
118
+ });
119
+ }
120
+ }
121
+ return {
122
+ binding: null,
123
+ loadedPath: null,
124
+ loadErrors
125
+ };
126
+ }
127
+ var init_nativeBinding = __esm({
128
+ "packages/shared/src/nativeBinding.ts"() {
129
+ }
130
+ });
131
+
132
+ // packages/shared/src/logger.ts
133
+ function getEnvLevel() {
134
+ const env = process.env.TWS_LOG_LEVEL?.toLowerCase();
135
+ if (env && env in LEVELS) return env;
136
+ return process.env.TWS_DEBUG_SCANNER === "1" ? "debug" : "info";
137
+ }
138
+ function createLogger(prefix, level) {
139
+ let currentLevel = getEnvLevel();
140
+ const log3 = (msgLevel, stream, args) => {
141
+ if (LEVELS[msgLevel] > LEVELS[currentLevel]) return;
142
+ const line = `[${prefix}] ${args.map(String).join(" ")}
143
+ `;
144
+ process[stream].write(line);
145
+ };
146
+ return {
147
+ error: (...a) => log3("error", "stderr", a),
148
+ warn: (...a) => log3("warn", "stderr", a),
149
+ info: (...a) => log3("info", "stdout", a),
150
+ debug: (...a) => log3("debug", "stderr", a),
151
+ setLevel: (l) => {
152
+ currentLevel = l;
153
+ }
154
+ };
155
+ }
156
+ var LEVELS;
157
+ var init_logger = __esm({
158
+ "packages/shared/src/logger.ts"() {
159
+ LEVELS = { silent: 0, error: 1, warn: 2, info: 3, debug: 4 };
160
+ createLogger("tailwind-styled");
161
+ }
162
+ });
163
+
164
+ // packages/shared/src/index.ts
165
+ var init_src = __esm({
166
+ "packages/shared/src/index.ts"() {
167
+ init_nativeBinding();
168
+ init_logger();
169
+ }
170
+ });
171
+
172
+ // packages/compiler/src/nativeBridge.ts
173
+ var nativeBridge_exports = {};
174
+ __export(nativeBridge_exports, {
175
+ adaptNativeResult: () => adaptNativeResult,
176
+ getNativeBridge: () => getNativeBridge,
177
+ resetNativeBridgeCache: () => resetNativeBridgeCache
178
+ });
179
+ function tryRequire(id) {
180
+ try {
181
+ const mod = requireFromRuntime(id);
182
+ return mod ?? null;
183
+ } catch (error) {
184
+ log.debug(
185
+ `native bridge load miss ${id}: ${error instanceof Error ? error.message : String(error)}`
186
+ );
187
+ return null;
188
+ }
189
+ }
190
+ function getNativeBridge() {
191
+ if (cachedBridge !== void 0) {
192
+ if (cachedBridge === null) {
193
+ throw new Error(
194
+ `[tailwind-styled/compiler v5] Native binding is required but not available.
195
+ Please ensure:
196
+ 1. The native module is properly installed
197
+ 2. You have run: npm run build:native (or use prebuilt binary)
198
+ 3. TWS_NO_NATIVE environment variable is not set
199
+
200
+ For help, see: https://tailwind-styled.dev/docs/install`
201
+ );
202
+ }
203
+ return cachedBridge;
204
+ }
205
+ if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_NO_RUST === "1") {
206
+ cachedBridge = null;
207
+ throw new Error(
208
+ `[tailwind-styled/compiler v5] Native binding is required.
209
+ The TWS_NO_NATIVE or TWS_NO_RUST environment variable is set, which disables native binding.
210
+ Please unset this environment variable to use the native compiler.`
211
+ );
212
+ }
213
+ const candidates = [
214
+ "@tailwind-styled/native",
215
+ path5.resolve(process.cwd(), "native", "index.mjs"),
216
+ path5.resolve(runtimeDir, "..", "..", "native", "index.mjs"),
217
+ path5.resolve(runtimeDir, "..", "..", "..", "native", "index.mjs"),
218
+ path5.resolve(process.cwd(), "native", "index.node"),
219
+ path5.resolve(runtimeDir, "..", "..", "native", "index.node"),
220
+ path5.resolve(runtimeDir, "..", "..", "..", "native", "index.node")
221
+ ];
222
+ for (const candidate of candidates) {
223
+ const bridge = tryRequire(candidate);
224
+ if (bridge) {
225
+ log.debug(`native bridge loaded from ${candidate}`);
226
+ cachedBridge = bridge;
227
+ return cachedBridge;
228
+ }
229
+ }
230
+ cachedBridge = null;
231
+ throw new Error(
232
+ `[tailwind-styled/compiler v5] Native binding not found.
233
+ Tried loading from:
234
+ ` + candidates.map((c) => ` - ${c}`).join("\n") + `
235
+
236
+ Please build the native module:
237
+ npm run build:native
238
+
239
+ Or install a prebuilt binary for your platform.`
240
+ );
241
+ }
242
+ function resetNativeBridgeCache() {
243
+ cachedBridge = void 0;
244
+ }
245
+ function adaptNativeResult(raw) {
246
+ let rsc;
247
+ if (raw.rscJson) {
248
+ try {
249
+ const parsed = JSON.parse(raw.rscJson);
250
+ rsc = {
251
+ isServer: parsed.isServer,
252
+ needsClientDirective: parsed.needsClientDirective,
253
+ clientReasons: []
254
+ };
255
+ } catch {
256
+ }
257
+ }
258
+ let metadata;
259
+ if (raw.metadataJson) {
260
+ try {
261
+ metadata = JSON.parse(raw.metadataJson);
262
+ } catch {
263
+ }
264
+ }
265
+ return {
266
+ code: raw.code,
267
+ classes: raw.classes,
268
+ changed: raw.changed,
269
+ rsc,
270
+ metadata
271
+ };
272
+ }
273
+ var runtimeDir, requireFromRuntime, cachedBridge, log;
274
+ var init_nativeBridge = __esm({
275
+ "packages/compiler/src/nativeBridge.ts"() {
276
+ init_src();
277
+ runtimeDir = typeof __dirname === "string" && __dirname.length > 0 ? __dirname : process.cwd();
278
+ requireFromRuntime = typeof module !== "undefined" && typeof module.require === "function" ? module.require.bind(module) : createRequire(path5.join(runtimeDir, "noop.cjs"));
279
+ log = createLogger("compiler:native");
280
+ }
281
+ });
282
+
283
+ // packages/scanner/src/native-bridge.ts
284
+ var native_bridge_exports = {};
285
+ __export(native_bridge_exports, {
286
+ cachePriorityNative: () => cachePriorityNative,
287
+ cacheReadNative: () => cacheReadNative,
288
+ cacheWriteNative: () => cacheWriteNative,
289
+ extractClassesNative: () => extractClassesNative,
290
+ hasNativeScannerBinding: () => hasNativeScannerBinding,
291
+ hashContentNative: () => hashContentNative,
292
+ isRustCacheAvailable: () => isRustCacheAvailable,
293
+ scanWorkspaceNative: () => scanWorkspaceNative
294
+ });
295
+ function getBinding() {
296
+ if (_binding !== void 0) {
297
+ if (_binding === null) {
298
+ throwNativeBindingError();
299
+ }
300
+ return _binding;
301
+ }
302
+ if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_NO_RUST === "1") {
303
+ _loadError = "Native loading is disabled by TWS_NO_NATIVE or TWS_NO_RUST environment variable.";
304
+ _binding = null;
305
+ _candidatePaths = [];
306
+ throwNativeBindingError();
307
+ }
308
+ const runtimeDir2 = typeof __dirname === "string" ? __dirname : process.cwd();
309
+ _candidatePaths = [
310
+ path5.resolve(process.cwd(), "native", "tailwind_styled_parser.node"),
311
+ path5.resolve(runtimeDir2, "..", "..", "..", "native", "tailwind_styled_parser.node")
312
+ ];
313
+ const req = typeof __require === "function" ? __require : createRequire(path5.join(runtimeDir2, "noop.cjs"));
314
+ for (const c of _candidatePaths) {
315
+ try {
316
+ const mod = req(c);
317
+ if (mod?.scanWorkspace || mod?.extractClassesFromSource || mod?.hashFileContent || mod?.cacheRead || mod?.cacheWrite) {
318
+ _binding = mod;
319
+ return _binding;
320
+ }
321
+ } catch (error) {
322
+ _loadError = error instanceof Error ? error.message : String(error);
323
+ }
324
+ }
325
+ _binding = null;
326
+ throwNativeBindingError();
327
+ }
328
+ function throwNativeBindingError() {
329
+ const lines = [
330
+ "FATAL: Native scanner binding not found.",
331
+ "",
332
+ "This package requires the Rust native binding 'tailwind_styled_parser.node'.",
333
+ "The binding was not found in any of these paths:",
334
+ ..._candidatePaths.map((p) => ` - ${p}`),
335
+ ""
336
+ ];
337
+ if (_loadError) {
338
+ lines.push("Load error:", ` ${_loadError}`, "");
339
+ }
340
+ lines.push(
341
+ "To fix this, run:",
342
+ " npm run build:rust",
343
+ "",
344
+ "This will build the native Rust module from the 'native/' directory.",
345
+ "If you're using this package in a CI/CD environment, ensure Rust toolchain is installed",
346
+ "and 'npm run build:rust' is executed before running tests or building."
347
+ );
348
+ throw new Error(lines.join("\n"));
349
+ }
350
+ function scanWorkspaceNative(root, extensions) {
351
+ return getBinding().scanWorkspace(root, extensions ?? null);
352
+ }
353
+ function extractClassesNative(source) {
354
+ const result = getBinding().extractClassesFromSource?.(source);
355
+ if (result === null || result === void 0) {
356
+ throw new Error("Native extractClassesFromSource returned null/undefined");
357
+ }
358
+ return result;
359
+ }
360
+ function hashContentNative(content) {
361
+ const result = getBinding().hashFileContent?.(content);
362
+ if (result === null || result === void 0) {
363
+ throw new Error("Native hashFileContent returned null/undefined");
364
+ }
365
+ return result;
366
+ }
367
+ function isRustCacheAvailable() {
368
+ return true;
369
+ }
370
+ function hasNativeScannerBinding() {
371
+ try {
372
+ getBinding();
373
+ return true;
374
+ } catch {
375
+ return false;
376
+ }
377
+ }
378
+ function cacheReadNative(cachePath) {
379
+ const result = getBinding().cacheRead?.(cachePath);
380
+ if (result === null || result === void 0) {
381
+ throw new Error("Native cacheRead returned null/undefined");
382
+ }
383
+ return result;
384
+ }
385
+ function cacheWriteNative(cachePath, entries) {
386
+ const result = getBinding().cacheWrite?.(cachePath, entries);
387
+ if (result === null || result === void 0) {
388
+ throw new Error("Native cacheWrite returned null/undefined");
389
+ }
390
+ return result;
391
+ }
392
+ function cachePriorityNative(mtimeMs, size, cachedMtimeMs, cachedSize, cachedHitCount, cachedLastSeenMs, nowMs = Date.now()) {
393
+ const result = getBinding().cachePriority?.(
394
+ mtimeMs,
395
+ size,
396
+ cachedMtimeMs,
397
+ cachedSize,
398
+ cachedHitCount,
399
+ cachedLastSeenMs,
400
+ nowMs
401
+ );
402
+ if (result === null || result === void 0) {
403
+ throw new Error("Native cachePriority returned null/undefined");
404
+ }
405
+ return result;
406
+ }
407
+ var _binding, _loadError, _candidatePaths;
408
+ var init_native_bridge = __esm({
409
+ "packages/scanner/src/native-bridge.ts"() {
410
+ _binding = void 0;
411
+ _loadError = null;
412
+ _candidatePaths = [];
413
+ }
414
+ });
415
+ function extractAllClasses(source) {
416
+ const { getNativeBridge: getNativeBridge2 } = (init_nativeBridge(), __toCommonJS(nativeBridge_exports));
417
+ const native = getNativeBridge2();
418
+ if (!native?.extractClassesFromSourceNative) {
419
+ throw new Error(
420
+ `[tailwind-styled/compiler v5] extractClassesFromSourceNative is required but not available.
421
+ Please ensure the native module is properly built.`
422
+ );
423
+ }
424
+ const result = native.extractClassesFromSourceNative(source);
425
+ if (!result || result.length < 0) {
426
+ throw new Error(
427
+ `[tailwind-styled/compiler v5] extractClassesFromSourceNative returned invalid result.`
428
+ );
429
+ }
430
+ return result.sort();
431
+ }
432
+
433
+ // packages/scanner/src/index.ts
434
+ init_src();
435
+
436
+ // packages/scanner/src/cache-native.ts
437
+ init_native_bridge();
438
+ function defaultCachePath(rootDir, cacheDir) {
439
+ const dir = cacheDir ? path5.resolve(rootDir, cacheDir) : path5.join(process.cwd(), ".cache", "tailwind-styled");
440
+ return path5.join(dir, "scanner-cache.json");
441
+ }
442
+ function readCache(rootDir, cacheDir) {
443
+ const cachePath = defaultCachePath(rootDir, cacheDir);
444
+ const result = cacheReadNative(cachePath);
445
+ return result.entries.map((e) => ({
446
+ file: e.file,
447
+ classes: e.classes,
448
+ hash: e.hash,
449
+ mtimeMs: e.mtimeMs,
450
+ size: e.size,
451
+ hitCount: e.hitCount
452
+ }));
453
+ }
454
+ function writeCache(rootDir, entries, cacheDir) {
455
+ const cachePath = defaultCachePath(rootDir, cacheDir);
456
+ const success = cacheWriteNative(cachePath, entries);
457
+ if (!success) {
458
+ throw new Error(
459
+ "Native cacheWrite failed. Run 'npm run build:rust' to rebuild native bindings."
460
+ );
461
+ }
462
+ }
463
+ function filePriority(mtimeMs, size, cached, nowMs = Date.now()) {
464
+ return cachePriorityNative(
465
+ mtimeMs,
466
+ size,
467
+ cached?.mtimeMs ?? 0,
468
+ cached?.size ?? 0,
469
+ cached?.hitCount ?? 0,
470
+ cached?.lastSeenMs ?? 0,
471
+ nowMs
472
+ );
473
+ }
474
+
475
+ // packages/scanner/src/index.ts
476
+ init_native_bridge();
477
+ var log2 = createLogger("scanner");
478
+ var SCAN_WORKER_TIMEOUT_MS = 12e4;
479
+ var SCAN_WORKER_BOOTSTRAP = `
480
+ const { parentPort, workerData } = require("node:worker_threads")
481
+ try {
482
+ const scanner = require(workerData.modulePath)
483
+ const result = scanner.scanWorkspace(workerData.rootDir, workerData.options ?? {})
484
+ parentPort.postMessage({ ok: true, result })
485
+ } catch (error) {
486
+ parentPort.postMessage({
487
+ ok: false,
488
+ error: error instanceof Error ? error.message : String(error),
489
+ })
490
+ }
491
+ `;
492
+ var nativeParserBinding;
493
+ var nativeParserInitError = null;
494
+ function canUseCjsRequire() {
495
+ return typeof __require === "function";
496
+ }
497
+ function debugNative(message) {
498
+ log2.debug(`[native] ${message}`);
499
+ }
500
+ function loadNativeParserBinding() {
501
+ if (nativeParserBinding !== void 0) return nativeParserBinding;
502
+ if (!canUseCjsRequire()) {
503
+ nativeParserBinding = null;
504
+ nativeParserInitError = "require is unavailable in current module format";
505
+ debugNative(`fallback to JS: ${nativeParserInitError}`);
506
+ return nativeParserBinding;
507
+ }
508
+ const candidates = [
509
+ path5.resolve(process.cwd(), "native/tailwind_styled_parser.node"),
510
+ path5.resolve(process.cwd(), "native/build/Release/tailwind_styled_parser.node")
511
+ ];
512
+ for (const fullPath of candidates) {
513
+ if (!fs2.existsSync(fullPath)) continue;
514
+ try {
515
+ const required = __require(fullPath);
516
+ if (required && typeof required.parse_classes === "function") {
517
+ nativeParserBinding = required;
518
+ debugNative(`using native parser from ${fullPath}`);
519
+ return nativeParserBinding;
520
+ }
521
+ } catch (error) {
522
+ nativeParserInitError = error instanceof Error ? error.message : String(error);
523
+ }
524
+ }
525
+ nativeParserBinding = null;
526
+ if (!nativeParserInitError) {
527
+ nativeParserInitError = "native .node binding not found";
528
+ }
529
+ debugNative(`fallback to JS: ${nativeParserInitError}`);
530
+ return nativeParserBinding;
531
+ }
532
+ function normalizeWithNativeParser(tokens) {
533
+ const binding = loadNativeParserBinding();
534
+ if (!binding || typeof binding.parse_classes !== "function") {
535
+ throw new Error(
536
+ "Native parser binding is required but not available. Run 'npm run build:rust' to build it."
537
+ );
538
+ }
539
+ try {
540
+ const parsed = binding.parse_classes(tokens.join(" "));
541
+ const normalized = parsed.map((item) => item.raw?.trim() ?? "").filter(Boolean);
542
+ return Array.from(new Set(normalized));
543
+ } catch (error) {
544
+ const errorMessage = error instanceof Error ? error.message : String(error);
545
+ throw new Error(`Native parser failed: ${errorMessage}. Run 'npm run build:rust' to rebuild.`);
546
+ }
547
+ }
548
+ var DEFAULT_EXTENSIONS = [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs"];
549
+ var DEFAULT_IGNORES = ["node_modules", ".git", ".next", "dist", "out", ".turbo", ".cache"];
550
+ function resolveScannerWorkerModulePath() {
551
+ const runtimeDir2 = typeof __dirname === "string" && __dirname.length > 0 ? __dirname : path5.dirname(fileURLToPath(import.meta.url));
552
+ const candidates = [
553
+ path5.resolve(runtimeDir2, "index.cjs"),
554
+ path5.resolve(runtimeDir2, "index.js"),
555
+ path5.resolve(runtimeDir2, "index.ts")
556
+ ];
557
+ for (const candidate of candidates) {
558
+ if (fs2.existsSync(candidate)) return candidate;
559
+ }
560
+ return null;
561
+ }
562
+ function scanWorkspaceInWorker(rootDir, options) {
563
+ const modulePath = resolveScannerWorkerModulePath();
564
+ if (!modulePath) {
565
+ return Promise.reject(new Error("scanner worker module path could not be resolved"));
566
+ }
567
+ return new Promise((resolve, reject) => {
568
+ let settled = false;
569
+ const worker = new Worker(SCAN_WORKER_BOOTSTRAP, {
570
+ eval: true,
571
+ workerData: { modulePath, rootDir, options }
572
+ });
573
+ const timeout = setTimeout(() => {
574
+ if (settled) return;
575
+ settled = true;
576
+ void worker.terminate();
577
+ reject(new Error(`scanner worker timed out after ${SCAN_WORKER_TIMEOUT_MS}ms`));
578
+ }, SCAN_WORKER_TIMEOUT_MS);
579
+ const finish = (callback) => {
580
+ if (settled) return;
581
+ settled = true;
582
+ clearTimeout(timeout);
583
+ callback();
584
+ };
585
+ worker.once("message", (payload) => {
586
+ const message = payload;
587
+ finish(() => {
588
+ if (message?.ok) {
589
+ resolve(message.result);
590
+ return;
591
+ }
592
+ reject(new Error(message?.error ?? "scanner worker failed without an error message"));
593
+ });
594
+ });
595
+ worker.once("error", (error) => {
596
+ finish(() => reject(error));
597
+ });
598
+ worker.once("exit", (code) => {
599
+ if (code !== 0) {
600
+ finish(() => reject(new Error(`scanner worker exited with code ${code}`)));
601
+ }
602
+ });
603
+ });
604
+ }
605
+ function buildExtensionSet(includeExtensions) {
606
+ return new Set(includeExtensions);
607
+ }
608
+ function collectCandidates(rootDir, ignoreDirectories, extensionSet) {
609
+ const candidates = [];
610
+ const directories = [rootDir];
611
+ while (directories.length > 0) {
612
+ const currentDir = directories.pop();
613
+ if (!currentDir) continue;
614
+ let entries = [];
615
+ try {
616
+ entries = fs2.readdirSync(currentDir, { withFileTypes: true });
617
+ } catch {
618
+ continue;
619
+ }
620
+ for (const entry of entries) {
621
+ const fullPath = path5.join(currentDir, entry.name);
622
+ if (entry.isDirectory()) {
623
+ if (!ignoreDirectories.has(entry.name)) directories.push(fullPath);
624
+ continue;
625
+ }
626
+ if (!entry.isFile()) continue;
627
+ if (!extensionSet.has(path5.extname(entry.name))) continue;
628
+ candidates.push(fullPath);
629
+ }
630
+ }
631
+ return candidates;
632
+ }
633
+ function toCacheSize(size) {
634
+ if (!Number.isFinite(size)) return 0;
635
+ const normalized = Math.max(0, Math.trunc(size));
636
+ return Math.min(normalized, 4294967295);
637
+ }
638
+ function extractClassesJs(source) {
639
+ return extractAllClasses(source);
640
+ }
641
+ function scanSource(source) {
642
+ const nativeBinding = loadNativeParserBinding();
643
+ if (nativeBinding && typeof nativeBinding.parse_classes === "function") {
644
+ try {
645
+ const baseClasses = extractClassesJs(source);
646
+ const nativeNormalized = normalizeWithNativeParser(baseClasses);
647
+ return nativeNormalized;
648
+ } catch (error) {
649
+ throw error;
650
+ }
651
+ }
652
+ throw new Error(
653
+ "Native parser binding is required but not available. Run 'npm run build:rust' to build it."
654
+ );
655
+ }
656
+ function scanFile(filePath) {
657
+ const source = fs2.readFileSync(filePath, "utf8");
658
+ const hash = hashContentNative(source) ?? void 0;
659
+ return {
660
+ file: filePath,
661
+ classes: scanSource(source),
662
+ ...hash ? { hash } : {}
663
+ };
664
+ }
665
+ function scanWorkspace(rootDir, options = {}) {
666
+ const includeExtensions = options.includeExtensions ?? DEFAULT_EXTENSIONS;
667
+ const extensionSet = buildExtensionSet(includeExtensions);
668
+ const ignoreDirectories = new Set(options.ignoreDirectories ?? DEFAULT_IGNORES);
669
+ const useCache = options.useCache ?? true;
670
+ options.smartInvalidation ?? true;
671
+ const files = [];
672
+ const unique = /* @__PURE__ */ new Set();
673
+ const candidates = collectCandidates(rootDir, ignoreDirectories, extensionSet);
674
+ const processResult = (result) => {
675
+ files.push(result);
676
+ for (const cls of result.classes) unique.add(cls);
677
+ };
678
+ const { scanWorkspaceNative: scanWorkspaceNative2 } = (init_native_bridge(), __toCommonJS(native_bridge_exports));
679
+ if (!options.cacheDir && !useCache) {
680
+ const nativeResult = scanWorkspaceNative2(rootDir, includeExtensions);
681
+ if (nativeResult) {
682
+ return {
683
+ files: nativeResult.files.map((f) => ({
684
+ file: f.file,
685
+ classes: f.classes
686
+ })),
687
+ totalFiles: nativeResult.totalFiles,
688
+ uniqueClasses: nativeResult.uniqueClasses
689
+ };
690
+ }
691
+ }
692
+ if (useCache && isRustCacheAvailable()) {
693
+ let cacheEntries = [];
694
+ try {
695
+ cacheEntries = readCache(rootDir, options.cacheDir);
696
+ } catch (error) {
697
+ cacheEntries = [];
698
+ log2.debug(
699
+ `cache read failed, continuing without persisted cache: ${error instanceof Error ? error.message : String(error)}`
700
+ );
701
+ }
702
+ const cacheMap = new Map(cacheEntries.map((entry) => [entry.file, entry]));
703
+ const nowMs = Date.now();
704
+ const ranked = [];
705
+ for (const filePath of candidates) {
706
+ let stat;
707
+ try {
708
+ stat = fs2.statSync(filePath);
709
+ } catch {
710
+ continue;
711
+ }
712
+ const size = toCacheSize(stat.size);
713
+ const cached = cacheMap.get(filePath);
714
+ const priority = filePriority(
715
+ stat.mtimeMs,
716
+ size,
717
+ cached ? {
718
+ mtimeMs: cached.mtimeMs,
719
+ size: cached.size,
720
+ hitCount: cached.hitCount,
721
+ lastSeenMs: 0
722
+ } : void 0,
723
+ nowMs
724
+ );
725
+ ranked.push({ filePath, stat, size, cached, priority });
726
+ }
727
+ ranked.sort((a, b) => b.priority - a.priority);
728
+ const updatedEntries = [];
729
+ for (const { filePath, stat, size, cached } of ranked) {
730
+ let content;
731
+ try {
732
+ content = fs2.readFileSync(filePath, "utf8");
733
+ } catch {
734
+ continue;
735
+ }
736
+ const hash = hashContentNative(content);
737
+ if (cached && cached.hash === hash && cached.mtimeMs === stat.mtimeMs && cached.size === size) {
738
+ log2.debug(`cache HIT ${filePath}`);
739
+ processResult({ file: filePath, classes: cached.classes });
740
+ updatedEntries.push({
741
+ file: filePath,
742
+ classes: cached.classes,
743
+ hash: cached.hash,
744
+ mtimeMs: stat.mtimeMs,
745
+ size,
746
+ hitCount: (cached.hitCount ?? 0) + 1
747
+ });
748
+ continue;
749
+ }
750
+ log2.debug(`cache MISS ${filePath}`);
751
+ const classes = scanSource(content);
752
+ processResult({ file: filePath, classes });
753
+ updatedEntries.push({
754
+ file: filePath,
755
+ classes,
756
+ hash,
757
+ mtimeMs: stat.mtimeMs,
758
+ size,
759
+ hitCount: 1
760
+ });
761
+ }
762
+ try {
763
+ writeCache(rootDir, updatedEntries, options.cacheDir);
764
+ } catch (error) {
765
+ log2.debug(`cache write failed: ${error instanceof Error ? error.message : String(error)}`);
766
+ }
767
+ return {
768
+ files,
769
+ totalFiles: files.length,
770
+ uniqueClasses: Array.from(unique).sort()
771
+ };
772
+ }
773
+ for (const filePath of candidates) {
774
+ processResult(scanFile(filePath));
775
+ }
776
+ return {
777
+ files,
778
+ totalFiles: files.length,
779
+ uniqueClasses: Array.from(unique).sort()
780
+ };
781
+ }
782
+ async function scanWorkspaceAsync(rootDir, options = {}) {
783
+ if (process.env.TWS_DISABLE_SCANNER_WORKER === "1") {
784
+ return scanWorkspace(rootDir, options);
785
+ }
786
+ try {
787
+ return await scanWorkspaceInWorker(rootDir, options);
788
+ } catch (error) {
789
+ log2.debug(
790
+ `worker scan failed, falling back to sync scanner: ${error instanceof Error ? error.message : String(error)}`
791
+ );
792
+ return scanWorkspace(rootDir, options);
793
+ }
794
+ }
795
+
796
+ // packages/analyzer/src/binding.ts
797
+ init_src();
798
+
799
+ // packages/analyzer/src/utils.ts
800
+ init_src();
801
+ var DEFAULT_TOP_LIMIT = 10;
802
+ var DEFAULT_FREQUENT_THRESHOLD = 2;
803
+ var DEBUG_NAMESPACE = "tailwind-styled:analyzer";
804
+ function formatErrorMessage2(error) {
805
+ return error instanceof Error ? error.message : String(error);
806
+ }
807
+ function isRecord(value) {
808
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
809
+ const proto = Object.getPrototypeOf(value);
810
+ return proto === Object.prototype || proto === null;
811
+ }
812
+ async function pathExists(filePath) {
813
+ try {
814
+ await fs2.promises.access(filePath, fs2.constants.F_OK);
815
+ return true;
816
+ } catch {
817
+ return false;
818
+ }
819
+ }
820
+ var debugLog = createDebugLogger(DEBUG_NAMESPACE, "tailwind-styled/analyzer");
821
+ function sanitizeTopLimit(value) {
822
+ if (!Number.isFinite(value)) return DEFAULT_TOP_LIMIT;
823
+ return Math.max(1, Math.trunc(value));
824
+ }
825
+ function sanitizeFrequentThreshold(value) {
826
+ if (!Number.isFinite(value)) return DEFAULT_FREQUENT_THRESHOLD;
827
+ return Math.max(1, Math.trunc(value));
828
+ }
829
+
830
+ // packages/analyzer/src/binding.ts
831
+ var bindingCache;
832
+ var bindingCandidateCache = [];
833
+ var bindingLoadErrorsCache = [];
834
+ var loadedBindingPathCache = null;
835
+ function isAnalyzerModule(module2) {
836
+ const candidate = module2;
837
+ return typeof candidate?.analyzeClasses === "function";
838
+ }
839
+ function getNativeBinding() {
840
+ if (bindingCache !== void 0) return bindingCache;
841
+ if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_NO_RUST === "1") {
842
+ bindingCandidateCache = [];
843
+ bindingLoadErrorsCache = [];
844
+ loadedBindingPathCache = null;
845
+ debugLog("native binding disabled by TWS_NO_NATIVE/TWS_NO_RUST");
846
+ bindingCache = null;
847
+ return bindingCache;
848
+ }
849
+ const runtimeDir2 = resolveRuntimeDir(
850
+ typeof __dirname === "string" ? __dirname : void 0,
851
+ import.meta.url
852
+ );
853
+ const candidates = resolveNativeBindingCandidates({
854
+ runtimeDir: runtimeDir2,
855
+ envVarNames: ["TWS_NATIVE_PATH"]
856
+ });
857
+ const { binding, loadErrors, loadedPath } = loadNativeBinding({
858
+ runtimeDir: runtimeDir2,
859
+ candidates,
860
+ isValid: isAnalyzerModule,
861
+ invalidExportMessage: "Module loaded but missing `analyzeClasses` export."
862
+ });
863
+ bindingCandidateCache = candidates;
864
+ bindingLoadErrorsCache = loadErrors;
865
+ loadedBindingPathCache = loadedPath;
866
+ if (binding) {
867
+ debugLog(`native binding loaded from: ${loadedPath}`);
868
+ bindingCache = binding;
869
+ return bindingCache;
870
+ }
871
+ if (bindingLoadErrorsCache.length > 0) {
872
+ debugLog(
873
+ `native binding load failed for ${bindingLoadErrorsCache.length} candidate(s): ${bindingLoadErrorsCache.map((entry) => `${entry.path} (${entry.message})`).join("; ")}`
874
+ );
875
+ } else {
876
+ debugLog("native binding not found in any candidate path");
877
+ }
878
+ bindingCache = null;
879
+ return bindingCache;
880
+ }
881
+ function requireNativeBinding() {
882
+ const binding = getNativeBinding();
883
+ if (binding?.analyzeClasses) return binding;
884
+ const lines = [
885
+ "Native analyzer binding not found. Ensure `tailwind_styled_parser.node` is built."
886
+ ];
887
+ if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_NO_RUST === "1") {
888
+ lines.push("Native loading is disabled by TWS_NO_NATIVE/TWS_NO_RUST.");
889
+ } else {
890
+ lines.push("Checked paths:");
891
+ for (const candidate of bindingCandidateCache) lines.push(`- ${candidate}`);
892
+ if (bindingLoadErrorsCache.length > 0) {
893
+ lines.push("Load errors:");
894
+ for (const failure of bindingLoadErrorsCache) {
895
+ lines.push(`- ${failure.path}: ${failure.message}`);
896
+ }
897
+ }
898
+ }
899
+ throw new Error(lines.join("\n"));
900
+ }
901
+ function requireNativeCssCompiler() {
902
+ const binding = requireNativeBinding();
903
+ if (typeof binding.compileCss === "function") return binding;
904
+ const loadedPathText = loadedBindingPathCache ? ` (${loadedBindingPathCache})` : "";
905
+ throw new Error(`Native analyzer compileCss binding is missing in v5${loadedPathText}.`);
906
+ }
907
+ var SUPPORTED_TAILWIND_CONFIG_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".js", ".cjs", ".mjs"]);
908
+ var KNOWN_UTILITY_PREFIXES = /* @__PURE__ */ new Set([
909
+ "absolute",
910
+ "align",
911
+ "animate",
912
+ "arbitrary",
913
+ "aspect",
914
+ "backdrop",
915
+ "basis",
916
+ "bg",
917
+ "block",
918
+ "border",
919
+ "bottom",
920
+ "col",
921
+ "container",
922
+ "contents",
923
+ "cursor",
924
+ "dark",
925
+ "display",
926
+ "divide",
927
+ "fill",
928
+ "fixed",
929
+ "flex",
930
+ "float",
931
+ "font",
932
+ "from",
933
+ "gap",
934
+ "grid",
935
+ "grow",
936
+ "h",
937
+ "hidden",
938
+ "inset",
939
+ "inline",
940
+ "isolate",
941
+ "items",
942
+ "justify",
943
+ "left",
944
+ "leading",
945
+ "line",
946
+ "list",
947
+ "m",
948
+ "max-h",
949
+ "max-w",
950
+ "mb",
951
+ "min-h",
952
+ "min-w",
953
+ "ml",
954
+ "mr",
955
+ "mt",
956
+ "mx",
957
+ "my",
958
+ "object",
959
+ "opacity",
960
+ "order",
961
+ "origin",
962
+ "outline",
963
+ "overflow",
964
+ "overscroll",
965
+ "p",
966
+ "pb",
967
+ "pe",
968
+ "perspective",
969
+ "place",
970
+ "pl",
971
+ "pointer",
972
+ "position",
973
+ "pr",
974
+ "ps",
975
+ "pt",
976
+ "px",
977
+ "py",
978
+ "relative",
979
+ "right",
980
+ "ring",
981
+ "rotate",
982
+ "rounded",
983
+ "row",
984
+ "scale",
985
+ "shadow",
986
+ "shrink",
987
+ "size",
988
+ "skew",
989
+ "snap",
990
+ "space-x",
991
+ "space-y",
992
+ "sr",
993
+ "start",
994
+ "static",
995
+ "sticky",
996
+ "stroke",
997
+ "table",
998
+ "text",
999
+ "to",
1000
+ "top",
1001
+ "touch",
1002
+ "tracking",
1003
+ "transform",
1004
+ "transition",
1005
+ "translate",
1006
+ "truncate",
1007
+ "underline",
1008
+ "via",
1009
+ "visible",
1010
+ "w",
1011
+ "whitespace",
1012
+ "z"
1013
+ ]);
1014
+ var tailwindConfigCache = /* @__PURE__ */ new Map();
1015
+ function splitVariantAndBase(className) {
1016
+ const parts = className.split(":");
1017
+ if (parts.length <= 1) return { variantKey: "", base: className };
1018
+ const base = parts.pop() ?? className;
1019
+ return { variantKey: parts.join(":"), base };
1020
+ }
1021
+ function isArbitraryUtility(baseClass) {
1022
+ return baseClass.includes("[") && baseClass.includes("]");
1023
+ }
1024
+ function resolveConflictGroup(base) {
1025
+ if (isArbitraryUtility(base)) return null;
1026
+ if (["block", "inline", "inline-block", "inline-flex", "flex", "grid", "hidden"].includes(base))
1027
+ return "display";
1028
+ if (base.startsWith("bg-")) return "bg";
1029
+ if (base.startsWith("text-")) return "text";
1030
+ if (base.startsWith("font-")) return "font";
1031
+ if (base.startsWith("rounded")) return "rounded";
1032
+ if (base.startsWith("shadow")) return "shadow";
1033
+ if (base.startsWith("border-")) return "border";
1034
+ if (base.startsWith("opacity-")) return "opacity";
1035
+ if (base.startsWith("w-") || base.startsWith("min-w-") || base.startsWith("max-w-"))
1036
+ return "width";
1037
+ if (base.startsWith("h-") || base.startsWith("min-h-") || base.startsWith("max-h-"))
1038
+ return "height";
1039
+ if (base.startsWith("p-") || base.startsWith("px-") || base.startsWith("py-")) return "padding";
1040
+ if (base.startsWith("m-") || base.startsWith("mx-") || base.startsWith("my-")) return "margin";
1041
+ return null;
1042
+ }
1043
+ function detectConflicts(usages) {
1044
+ const buckets = /* @__PURE__ */ new Map();
1045
+ for (const usage of usages) {
1046
+ const { variantKey, base } = splitVariantAndBase(usage.name);
1047
+ const group = resolveConflictGroup(base);
1048
+ if (!group) continue;
1049
+ const key = `${variantKey}::${group}`;
1050
+ const bucket = buckets.get(key) ?? {
1051
+ variantKey,
1052
+ group,
1053
+ classes: /* @__PURE__ */ new Set()
1054
+ };
1055
+ bucket.classes.add(usage.name);
1056
+ buckets.set(key, bucket);
1057
+ }
1058
+ const conflicts = [];
1059
+ const conflictedClassNames = /* @__PURE__ */ new Set();
1060
+ for (const bucket of buckets.values()) {
1061
+ if (bucket.classes.size <= 1) continue;
1062
+ const classes = Array.from(bucket.classes).sort();
1063
+ for (const className of classes) conflictedClassNames.add(className);
1064
+ const variantLabel = bucket.variantKey.length > 0 ? bucket.variantKey : "base";
1065
+ conflicts.push({
1066
+ className: bucket.group,
1067
+ variants: bucket.variantKey.length > 0 ? bucket.variantKey.split(":") : [],
1068
+ classes,
1069
+ message: `Multiple ${bucket.group} utilities detected for "${variantLabel}".`
1070
+ });
1071
+ }
1072
+ conflicts.sort((left, right) => {
1073
+ if (right.classes.length !== left.classes.length)
1074
+ return right.classes.length - left.classes.length;
1075
+ return left.className.localeCompare(right.className);
1076
+ });
1077
+ return { conflicts, conflictedClassNames };
1078
+ }
1079
+ function isSupportedTailwindConfigPath(configPath) {
1080
+ return SUPPORTED_TAILWIND_CONFIG_EXTENSIONS.has(path5.extname(configPath).toLowerCase());
1081
+ }
1082
+ async function resolveTailwindConfigPath(root, explicitPath) {
1083
+ if (explicitPath) {
1084
+ const resolved = path5.resolve(root, explicitPath);
1085
+ if (!await pathExists(resolved)) return null;
1086
+ return resolved;
1087
+ }
1088
+ const candidates = [
1089
+ "tailwind.config.ts",
1090
+ "tailwind.config.js",
1091
+ "tailwind.config.cjs",
1092
+ "tailwind.config.mjs"
1093
+ ];
1094
+ for (const candidate of candidates) {
1095
+ const fullPath = path5.resolve(root, candidate);
1096
+ if (await pathExists(fullPath)) return fullPath;
1097
+ }
1098
+ return null;
1099
+ }
1100
+ function collectSafelistFromConfig(config) {
1101
+ const raw = config.safelist;
1102
+ if (!Array.isArray(raw)) return [];
1103
+ const out = /* @__PURE__ */ new Set();
1104
+ for (const entry of raw) {
1105
+ if (typeof entry === "string" && entry.length > 0) {
1106
+ out.add(entry);
1107
+ continue;
1108
+ }
1109
+ if (!entry || typeof entry !== "object") continue;
1110
+ const pattern = entry.pattern;
1111
+ if (typeof pattern === "string" && pattern.length > 0) {
1112
+ out.add(pattern);
1113
+ }
1114
+ }
1115
+ return Array.from(out);
1116
+ }
1117
+ function collectCustomUtilities(config) {
1118
+ const out = /* @__PURE__ */ new Set();
1119
+ const theme = config.theme;
1120
+ if (!theme || typeof theme !== "object") return out;
1121
+ const extend = theme.extend;
1122
+ if (!extend || typeof extend !== "object") return out;
1123
+ for (const [section, value] of Object.entries(extend)) {
1124
+ if (!value || typeof value !== "object" || Array.isArray(value)) continue;
1125
+ for (const key of Object.keys(value)) {
1126
+ out.add(`${section}-${key}`);
1127
+ if (section === "colors") {
1128
+ out.add(`bg-${key}`);
1129
+ out.add(`text-${key}`);
1130
+ out.add(`border-${key}`);
1131
+ } else if (section === "spacing") {
1132
+ out.add(`p-${key}`);
1133
+ out.add(`m-${key}`);
1134
+ out.add(`gap-${key}`);
1135
+ out.add(`w-${key}`);
1136
+ out.add(`h-${key}`);
1137
+ } else if (section === "fontSize") {
1138
+ out.add(`text-${key}`);
1139
+ } else if (section === "borderRadius") {
1140
+ out.add(`rounded-${key}`);
1141
+ } else if (section === "boxShadow") {
1142
+ out.add(`shadow-${key}`);
1143
+ }
1144
+ }
1145
+ }
1146
+ return out;
1147
+ }
1148
+ async function collectSafelistFromSource(configPath) {
1149
+ const source = await fs2.promises.readFile(configPath, "utf8");
1150
+ const safelistBlock = source.match(/safelist\s*:\s*\[([\s\S]*?)\]/m)?.[1];
1151
+ if (!safelistBlock) return [];
1152
+ const out = /* @__PURE__ */ new Set();
1153
+ const tokenRegex = /["'`]([^"'`]+)["'`]/g;
1154
+ let token = tokenRegex.exec(safelistBlock);
1155
+ while (token) {
1156
+ const value = token[1].trim();
1157
+ if (value.length > 0) out.add(value);
1158
+ token = tokenRegex.exec(safelistBlock);
1159
+ }
1160
+ return Array.from(out);
1161
+ }
1162
+ async function loadTailwindConfig(root, semanticOption) {
1163
+ const startMs = Date.now();
1164
+ const configPath = await resolveTailwindConfigPath(root, semanticOption?.tailwindConfigPath);
1165
+ if (!configPath) return null;
1166
+ if (!isSupportedTailwindConfigPath(configPath)) {
1167
+ return {
1168
+ path: configPath,
1169
+ loaded: false,
1170
+ warning: `Unsupported Tailwind config extension at "${configPath}". Supported extensions: .ts, .js, .cjs, .mjs.`,
1171
+ safelist: /* @__PURE__ */ new Set(),
1172
+ customUtilities: /* @__PURE__ */ new Set()
1173
+ };
1174
+ }
1175
+ const configStat = await fs2.promises.stat(configPath).catch(() => null);
1176
+ if (configStat) {
1177
+ const cached = tailwindConfigCache.get(configPath);
1178
+ if (cached && cached.mtimeMs === configStat.mtimeMs && cached.size === configStat.size) {
1179
+ debugLog(
1180
+ `tailwind config cache hit: ${configPath} (${cached.config.safelist.size} safelist entries)`
1181
+ );
1182
+ return cached.config;
1183
+ }
1184
+ }
1185
+ let config = null;
1186
+ let warning;
1187
+ try {
1188
+ const cacheBustToken = Math.trunc(configStat?.mtimeMs ?? Date.now());
1189
+ const imported = await import(`${pathToFileURL(configPath).href}?tws_mtime=${cacheBustToken}`);
1190
+ const candidate = imported.default ?? imported;
1191
+ if (isRecord(candidate)) {
1192
+ config = candidate;
1193
+ } else if (typeof candidate === "function") {
1194
+ const evaluated = candidate();
1195
+ if (isRecord(evaluated)) {
1196
+ config = evaluated;
1197
+ } else {
1198
+ warning = "Tailwind config export function must return an object.";
1199
+ }
1200
+ } else {
1201
+ warning = "Tailwind config export must be an object or a function returning an object.";
1202
+ }
1203
+ } catch (error) {
1204
+ warning = formatErrorMessage2(error);
1205
+ }
1206
+ const safelist = /* @__PURE__ */ new Set();
1207
+ const customUtilities = /* @__PURE__ */ new Set();
1208
+ if (config) {
1209
+ for (const item of collectSafelistFromConfig(config)) safelist.add(item);
1210
+ for (const item of collectCustomUtilities(config)) customUtilities.add(item);
1211
+ }
1212
+ if (safelist.size === 0) {
1213
+ try {
1214
+ for (const item of await collectSafelistFromSource(configPath)) safelist.add(item);
1215
+ } catch (error) {
1216
+ debugLog(
1217
+ `failed to parse safelist from source at "${configPath}": ${formatErrorMessage2(error)}`
1218
+ );
1219
+ }
1220
+ }
1221
+ const loaded = {
1222
+ path: configPath,
1223
+ loaded: config !== null,
1224
+ warning,
1225
+ safelist,
1226
+ customUtilities
1227
+ };
1228
+ if (configStat) {
1229
+ tailwindConfigCache.set(configPath, {
1230
+ mtimeMs: configStat.mtimeMs,
1231
+ size: configStat.size,
1232
+ config: loaded
1233
+ });
1234
+ }
1235
+ debugLog(
1236
+ `tailwind config loaded from "${configPath}" in ${Date.now() - startMs}ms (loaded=${loaded.loaded}, safelist=${loaded.safelist.size}, custom=${loaded.customUtilities.size})`
1237
+ );
1238
+ return loaded;
1239
+ }
1240
+ function utilityPrefix(baseClass) {
1241
+ const normalized = baseClass.startsWith("-") ? baseClass.slice(1) : baseClass;
1242
+ if (normalized.includes("[") && normalized.includes("]")) return "arbitrary";
1243
+ if (normalized.startsWith("min-w-")) return "min-w";
1244
+ if (normalized.startsWith("max-w-")) return "max-w";
1245
+ if (normalized.startsWith("min-h-")) return "min-h";
1246
+ if (normalized.startsWith("max-h-")) return "max-h";
1247
+ if (normalized.startsWith("space-x-")) return "space-x";
1248
+ if (normalized.startsWith("space-y-")) return "space-y";
1249
+ if (normalized.startsWith("inline-")) return "inline";
1250
+ if (normalized.startsWith("border-")) return "border";
1251
+ if (normalized.startsWith("text-")) return "text";
1252
+ if (normalized.startsWith("bg-")) return "bg";
1253
+ if (normalized.startsWith("rounded")) return "rounded";
1254
+ if (normalized.startsWith("shadow")) return "shadow";
1255
+ const hyphen = normalized.indexOf("-");
1256
+ if (hyphen < 0) return normalized;
1257
+ return normalized.slice(0, hyphen);
1258
+ }
1259
+ function isKnownTailwindClass(className, safelist, customUtilities) {
1260
+ if (safelist.has(className) || customUtilities.has(className)) return true;
1261
+ const { base } = splitVariantAndBase(className);
1262
+ if (customUtilities.has(base)) return true;
1263
+ const prefix = utilityPrefix(base);
1264
+ return KNOWN_UTILITY_PREFIXES.has(prefix);
1265
+ }
1266
+ async function buildSemanticReport(usages, root, semanticOption) {
1267
+ const loadedConfig = await loadTailwindConfig(root, semanticOption);
1268
+ const safelist = loadedConfig?.safelist ?? /* @__PURE__ */ new Set();
1269
+ const customUtilities = loadedConfig?.customUtilities ?? /* @__PURE__ */ new Set();
1270
+ const usageNames = new Set(usages.map((usage) => usage.name));
1271
+ const unusedClasses = Array.from(safelist).filter((className) => !usageNames.has(className)).sort().map((className) => ({ name: className, count: 0, isUnused: true }));
1272
+ const unknownClasses = usages.filter((usage) => !isKnownTailwindClass(usage.name, safelist, customUtilities)).map((usage) => ({ ...usage, isUnused: true }));
1273
+ const { conflicts } = detectConflicts(usages);
1274
+ return {
1275
+ unusedClasses,
1276
+ unknownClasses,
1277
+ conflicts,
1278
+ ...loadedConfig ? {
1279
+ tailwindConfig: {
1280
+ path: loadedConfig.path,
1281
+ loaded: loadedConfig.loaded,
1282
+ safelistCount: loadedConfig.safelist.size,
1283
+ customUtilityCount: loadedConfig.customUtilities.size,
1284
+ ...loadedConfig.warning ? { warning: loadedConfig.warning } : {}
1285
+ }
1286
+ } : {}
1287
+ };
1288
+ }
1289
+
1290
+ // packages/analyzer/src/analyzeWorkspace.ts
1291
+ function normalizeScan(scan, includeClass) {
1292
+ if (!includeClass) return scan;
1293
+ const filteredFiles = scan.files.map((file) => ({
1294
+ file: file.file,
1295
+ classes: file.classes.filter((className) => includeClass(className))
1296
+ }));
1297
+ const unique = /* @__PURE__ */ new Set();
1298
+ for (const file of filteredFiles) {
1299
+ for (const className of file.classes) unique.add(className);
1300
+ }
1301
+ return {
1302
+ files: filteredFiles,
1303
+ totalFiles: scan.totalFiles,
1304
+ uniqueClasses: Array.from(unique).sort()
1305
+ };
1306
+ }
1307
+ function collectClassCounts(scan) {
1308
+ const counts = /* @__PURE__ */ new Map();
1309
+ for (const file of scan.files) {
1310
+ for (const className of file.classes) {
1311
+ counts.set(className, (counts.get(className) ?? 0) + 1);
1312
+ }
1313
+ }
1314
+ return counts;
1315
+ }
1316
+ function buildClassUsage(counts) {
1317
+ return Array.from(counts.entries()).map(([name, count]) => ({ name, count })).sort((left, right) => {
1318
+ if (right.count !== left.count) return right.count - left.count;
1319
+ return left.name.localeCompare(right.name);
1320
+ });
1321
+ }
1322
+ function buildDistribution(usages) {
1323
+ const distribution = {
1324
+ "1": 0,
1325
+ "2-3": 0,
1326
+ "4-7": 0,
1327
+ "8+": 0
1328
+ };
1329
+ for (const usage of usages) {
1330
+ if (usage.count === 1) {
1331
+ distribution["1"] += 1;
1332
+ continue;
1333
+ }
1334
+ if (usage.count <= 3) {
1335
+ distribution["2-3"] += 1;
1336
+ continue;
1337
+ }
1338
+ if (usage.count <= 7) {
1339
+ distribution["4-7"] += 1;
1340
+ continue;
1341
+ }
1342
+ distribution["8+"] += 1;
1343
+ }
1344
+ return distribution;
1345
+ }
1346
+ async function analyzeWorkspace(root, options = {}) {
1347
+ const startedAtMs = Date.now();
1348
+ const resolvedRoot = path5.resolve(root);
1349
+ const scanStartedAtMs = Date.now();
1350
+ let scan;
1351
+ try {
1352
+ scan = await scanWorkspaceAsync(resolvedRoot, options.scanner);
1353
+ } catch (error) {
1354
+ throw new Error(`Failed to scan workspace at "${resolvedRoot}": ${formatErrorMessage2(error)}`, {
1355
+ cause: error
1356
+ });
1357
+ }
1358
+ debugLog(
1359
+ `scanWorkspaceAsync processed ${scan.totalFiles} files in ${Date.now() - scanStartedAtMs}ms`
1360
+ );
1361
+ const normalizedScan = normalizeScan(scan, options.includeClass);
1362
+ const topLimit = sanitizeTopLimit(options.classStats?.top);
1363
+ const frequentThreshold = sanitizeFrequentThreshold(options.classStats?.frequentThreshold);
1364
+ const binding = requireNativeBinding();
1365
+ const filesJson = JSON.stringify(
1366
+ normalizedScan.files.map((file) => ({ file: file.file, classes: file.classes }))
1367
+ );
1368
+ let nativeReport = null;
1369
+ try {
1370
+ nativeReport = binding.analyzeClasses(filesJson, resolvedRoot, topLimit);
1371
+ } catch (error) {
1372
+ throw new Error(`Native analyzer failed for "${resolvedRoot}": ${formatErrorMessage2(error)}`, {
1373
+ cause: error
1374
+ });
1375
+ }
1376
+ if (!nativeReport) {
1377
+ throw new Error(`Native analyzer returned no report for "${resolvedRoot}".`);
1378
+ }
1379
+ const counts = collectClassCounts(normalizedScan);
1380
+ let all = buildClassUsage(counts);
1381
+ let semanticReport;
1382
+ if (options.semantic) {
1383
+ const semanticOption = typeof options.semantic === "object" ? options.semantic : void 0;
1384
+ const semanticStartedAtMs = Date.now();
1385
+ try {
1386
+ semanticReport = await buildSemanticReport(all, resolvedRoot, semanticOption);
1387
+ } catch (error) {
1388
+ throw new Error(
1389
+ `Failed to build semantic report for "${resolvedRoot}": ${formatErrorMessage2(error)}`,
1390
+ { cause: error }
1391
+ );
1392
+ }
1393
+ debugLog(`semantic report built in ${Date.now() - semanticStartedAtMs}ms`);
1394
+ if (semanticReport.conflicts.length > 0) {
1395
+ const conflicted = new Set(semanticReport.conflicts.flatMap((conflict) => conflict.classes));
1396
+ all = all.map(
1397
+ (usage) => conflicted.has(usage.name) ? { ...usage, isConflict: true } : usage
1398
+ );
1399
+ }
1400
+ }
1401
+ const top = all.slice(0, topLimit);
1402
+ const frequent = all.filter((usage) => usage.count >= frequentThreshold).slice(0, topLimit);
1403
+ const unique = all.filter((usage) => usage.count === 1);
1404
+ const totalClassOccurrences = all.reduce((sum, usage) => sum + usage.count, 0);
1405
+ debugLog(
1406
+ `analyzeWorkspace completed in ${Date.now() - startedAtMs}ms (files=${normalizedScan.totalFiles}, uniqueClasses=${all.length})`
1407
+ );
1408
+ return {
1409
+ root: nativeReport.root || resolvedRoot,
1410
+ totalFiles: nativeReport.totalFiles,
1411
+ uniqueClassCount: all.length,
1412
+ totalClassOccurrences,
1413
+ classStats: {
1414
+ all,
1415
+ top,
1416
+ frequent,
1417
+ unique,
1418
+ distribution: buildDistribution(all)
1419
+ },
1420
+ safelist: all.map((usage) => usage.name),
1421
+ ...semanticReport ? { semantic: semanticReport } : {}
1422
+ };
1423
+ }
1424
+
1425
+ // packages/analyzer/src/classToCss.ts
1426
+ function normalizeClassInput(input) {
1427
+ if (typeof input === "string") {
1428
+ return input.split(/\s+/).map((item) => item.trim()).filter((item) => item.length > 0);
1429
+ }
1430
+ if (!Array.isArray(input)) {
1431
+ throw new TypeError("classToCss input must be a string or an array of strings.");
1432
+ }
1433
+ const out = [];
1434
+ for (const item of input) {
1435
+ if (typeof item !== "string") {
1436
+ throw new TypeError("classToCss input array must contain only strings.");
1437
+ }
1438
+ const value = item.trim();
1439
+ if (value.length > 0) out.push(value);
1440
+ }
1441
+ return out;
1442
+ }
1443
+ function normalizeClassToCssOptions(options) {
1444
+ if (!options || typeof options !== "object" || Array.isArray(options)) {
1445
+ throw new TypeError("classToCss options must be an object.");
1446
+ }
1447
+ const strict = options.strict ?? false;
1448
+ if (typeof strict !== "boolean") {
1449
+ throw new TypeError("classToCss options.strict must be a boolean when provided.");
1450
+ }
1451
+ const prefix = options.prefix ?? null;
1452
+ if (prefix !== null && typeof prefix !== "string") {
1453
+ throw new TypeError("classToCss options.prefix must be a string or null when provided.");
1454
+ }
1455
+ return { prefix, strict };
1456
+ }
1457
+ function mergeDeclarationMap(target, css) {
1458
+ const ruleRegex = /\{([^}]*)\}/g;
1459
+ let ruleMatch = ruleRegex.exec(css);
1460
+ while (ruleMatch) {
1461
+ const body = ruleMatch[1];
1462
+ for (const raw of body.split(";")) {
1463
+ const declaration = raw.trim();
1464
+ if (declaration.length === 0) continue;
1465
+ const colonIndex = declaration.indexOf(":");
1466
+ if (colonIndex <= 0) continue;
1467
+ const property = declaration.slice(0, colonIndex).trim();
1468
+ const value = declaration.slice(colonIndex + 1).trim();
1469
+ if (property.length === 0 || value.length === 0) continue;
1470
+ if (target.has(property)) target.delete(property);
1471
+ target.set(property, value);
1472
+ }
1473
+ ruleMatch = ruleRegex.exec(css);
1474
+ }
1475
+ }
1476
+ function declarationMapToString(declarationMap) {
1477
+ return Array.from(declarationMap.entries()).map(([property, value]) => `${property}: ${value}`).join("; ");
1478
+ }
1479
+ async function classToCss(input, options = {}) {
1480
+ const inputClasses = normalizeClassInput(input);
1481
+ const normalizedOptions = normalizeClassToCssOptions(options);
1482
+ if (inputClasses.length === 0) {
1483
+ return {
1484
+ inputClasses: [],
1485
+ css: "",
1486
+ declarations: "",
1487
+ resolvedClasses: [],
1488
+ unknownClasses: [],
1489
+ sizeBytes: 0
1490
+ };
1491
+ }
1492
+ const binding = requireNativeCssCompiler();
1493
+ const prefix = normalizedOptions.prefix;
1494
+ const cssChunks = [];
1495
+ const resolvedClasses = [];
1496
+ const unknownClasses = [];
1497
+ let sizeBytes = 0;
1498
+ const declarationMap = /* @__PURE__ */ new Map();
1499
+ for (const className of inputClasses) {
1500
+ let compiled = null;
1501
+ try {
1502
+ compiled = binding.compileCss([className], prefix);
1503
+ } catch (error) {
1504
+ throw new Error(
1505
+ `Native analyzer failed while compiling class "${className}": ${formatErrorMessage2(error)}`,
1506
+ { cause: error }
1507
+ );
1508
+ }
1509
+ if (!compiled) {
1510
+ throw new Error(`Native analyzer returned no result for class "${className}".`);
1511
+ }
1512
+ cssChunks.push(compiled.css);
1513
+ resolvedClasses.push(...compiled.resolvedClasses);
1514
+ unknownClasses.push(...compiled.unknownClasses);
1515
+ sizeBytes += compiled.sizeBytes;
1516
+ mergeDeclarationMap(declarationMap, compiled.css);
1517
+ }
1518
+ const uniqueUnknown = Array.from(new Set(unknownClasses));
1519
+ if (normalizedOptions.strict && uniqueUnknown.length > 0) {
1520
+ throw new Error(`Unknown Tailwind classes: ${uniqueUnknown.join(", ")}`);
1521
+ }
1522
+ return {
1523
+ inputClasses,
1524
+ css: cssChunks.filter((chunk) => chunk.length > 0).join("\n"),
1525
+ declarations: declarationMapToString(declarationMap),
1526
+ resolvedClasses: Array.from(new Set(resolvedClasses)),
1527
+ unknownClasses: uniqueUnknown,
1528
+ sizeBytes
1529
+ };
1530
+ }
1531
+
1532
+ // packages/analyzer/src/index.ts
1533
+ var __internal = {
1534
+ normalizeClassInput,
1535
+ splitVariantAndBase,
1536
+ resolveConflictGroup,
1537
+ collectClassCounts,
1538
+ buildDistribution,
1539
+ utilityPrefix
1540
+ };
1541
+
1542
+ export { __internal, analyzeWorkspace, classToCss };
1543
+ //# sourceMappingURL=analyzer.mjs.map
1544
+ //# sourceMappingURL=analyzer.mjs.map