tailwind-styled-v4 5.0.11 → 5.0.13

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 (110) hide show
  1. package/README.md +100 -4
  2. package/dist/{analyzeWorkspace-DDOQdzzI.d.ts → analyzeWorkspace-CopJNGmi.d.ts} +2 -0
  3. package/dist/{analyzeWorkspace-BS5O4rhC.d.mts → analyzeWorkspace-DpVPccjz.d.mts} +2 -0
  4. package/dist/analyzer.d.mts +4 -4
  5. package/dist/analyzer.d.ts +4 -4
  6. package/dist/analyzer.js +34 -69
  7. package/dist/analyzer.js.map +1 -1
  8. package/dist/analyzer.mjs +33 -68
  9. package/dist/analyzer.mjs.map +1 -1
  10. package/dist/animate.d.mts +4 -0
  11. package/dist/animate.d.ts +4 -0
  12. package/dist/animate.js +33 -11
  13. package/dist/animate.js.map +1 -1
  14. package/dist/animate.mjs +33 -11
  15. package/dist/animate.mjs.map +1 -1
  16. package/dist/atomic.js +57 -6
  17. package/dist/atomic.js.map +1 -1
  18. package/dist/atomic.mjs +57 -6
  19. package/dist/atomic.mjs.map +1 -1
  20. package/dist/cli.js +404 -190
  21. package/dist/cli.js.map +1 -1
  22. package/dist/cli.mjs +401 -187
  23. package/dist/cli.mjs.map +1 -1
  24. package/dist/compiler.d.mts +2700 -212
  25. package/dist/compiler.d.ts +2700 -212
  26. package/dist/compiler.js +1996 -503
  27. package/dist/compiler.js.map +1 -1
  28. package/dist/compiler.mjs +1847 -448
  29. package/dist/compiler.mjs.map +1 -1
  30. package/dist/devtools.js +17 -4
  31. package/dist/devtools.js.map +1 -1
  32. package/dist/devtools.mjs +17 -4
  33. package/dist/devtools.mjs.map +1 -1
  34. package/dist/engine.d.mts +11 -470
  35. package/dist/engine.d.ts +11 -470
  36. package/dist/engine.js +2777 -455
  37. package/dist/engine.js.map +1 -1
  38. package/dist/engine.mjs +2776 -454
  39. package/dist/engine.mjs.map +1 -1
  40. package/dist/index-BDQw13kn.d.ts +464 -0
  41. package/dist/index-DJv28Uzq.d.mts +464 -0
  42. package/dist/index.browser.mjs +143 -255
  43. package/dist/index.browser.mjs.map +1 -1
  44. package/dist/index.d.mts +23 -39
  45. package/dist/index.d.ts +23 -39
  46. package/dist/index.js +7234 -1400
  47. package/dist/index.js.map +1 -1
  48. package/dist/index.mjs +7234 -1400
  49. package/dist/index.mjs.map +1 -1
  50. package/dist/next.d.mts +44 -1
  51. package/dist/next.d.ts +44 -1
  52. package/dist/next.js +3224 -1065
  53. package/dist/next.js.map +1 -1
  54. package/dist/next.mjs +3223 -1066
  55. package/dist/next.mjs.map +1 -1
  56. package/dist/rspack.d.mts +9 -0
  57. package/dist/rspack.d.ts +9 -0
  58. package/dist/rspack.js +99 -61
  59. package/dist/rspack.js.map +1 -1
  60. package/dist/rspack.mjs +99 -61
  61. package/dist/rspack.mjs.map +1 -1
  62. package/dist/runtime-css.d.mts +8 -0
  63. package/dist/runtime-css.d.ts +8 -0
  64. package/dist/runtime-css.js +23 -7
  65. package/dist/runtime-css.js.map +1 -1
  66. package/dist/runtime-css.mjs +23 -7
  67. package/dist/runtime-css.mjs.map +1 -1
  68. package/dist/scanner.js +16 -37
  69. package/dist/scanner.js.map +1 -1
  70. package/dist/scanner.mjs +15 -36
  71. package/dist/scanner.mjs.map +1 -1
  72. package/dist/shared.d.mts +107 -1
  73. package/dist/shared.d.ts +107 -1
  74. package/dist/shared.js +3014 -466
  75. package/dist/shared.js.map +1 -1
  76. package/dist/shared.mjs +3008 -445
  77. package/dist/shared.mjs.map +1 -1
  78. package/dist/svelte.js +39 -35
  79. package/dist/svelte.js.map +1 -1
  80. package/dist/svelte.mjs +38 -34
  81. package/dist/svelte.mjs.map +1 -1
  82. package/dist/theme.js +85 -76
  83. package/dist/theme.js.map +1 -1
  84. package/dist/theme.mjs +83 -74
  85. package/dist/theme.mjs.map +1 -1
  86. package/dist/turbopackLoader.js +2351 -187
  87. package/dist/turbopackLoader.js.map +1 -1
  88. package/dist/turbopackLoader.mjs +2351 -187
  89. package/dist/turbopackLoader.mjs.map +1 -1
  90. package/dist/tw.js +404 -190
  91. package/dist/tw.js.map +1 -1
  92. package/dist/tw.mjs +401 -187
  93. package/dist/tw.mjs.map +1 -1
  94. package/dist/vite.js +2657 -320
  95. package/dist/vite.js.map +1 -1
  96. package/dist/vite.mjs +2657 -320
  97. package/dist/vite.mjs.map +1 -1
  98. package/dist/vue.js +39 -35
  99. package/dist/vue.js.map +1 -1
  100. package/dist/vue.mjs +38 -34
  101. package/dist/vue.mjs.map +1 -1
  102. package/dist/webpackLoader.js +190 -33
  103. package/dist/webpackLoader.js.map +1 -1
  104. package/dist/webpackLoader.mjs +190 -33
  105. package/dist/webpackLoader.mjs.map +1 -1
  106. package/native/index.node +0 -0
  107. package/native/tailwind-styled-native.node +0 -0
  108. package/native/tailwind-styled-native.win32-x64-msvc.node +0 -0
  109. package/package.json +9 -4
  110. package/CHANGELOG.md +0 -285
package/dist/compiler.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { createRequire } from 'module';
2
2
  import * as fs from 'fs';
3
+ import fs__default from 'fs';
3
4
  import * as path from 'path';
4
5
  import path__default from 'path';
5
6
  import 'crypto';
@@ -7,7 +8,9 @@ import { fileURLToPath } from 'url';
7
8
 
8
9
  /* tailwind-styled-v4 v5.0.4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
9
10
  var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10
12
  var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
14
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
12
15
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
13
16
  }) : x)(function(x) {
@@ -21,6 +24,15 @@ var __export = (target, all) => {
21
24
  for (var name in all)
22
25
  __defProp(target, name, { get: all[name], enumerable: true });
23
26
  };
27
+ var __copyProps = (to, from, except, desc) => {
28
+ if (from && typeof from === "object" || typeof from === "function") {
29
+ for (let key of __getOwnPropNames(from))
30
+ if (!__hasOwnProp.call(to, key) && key !== except)
31
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
32
+ }
33
+ return to;
34
+ };
35
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
36
  function platformKey() {
25
37
  if (isBrowser) return "browser";
26
38
  return `${process.platform}-${process.arch}`;
@@ -31,7 +43,7 @@ function resolveNativeBinary(runtimeDir) {
31
43
  if (isBrowser) {
32
44
  return { path: null, source: "not-found", platform, tried: ["not available in browser"] };
33
45
  }
34
- if (process.env.TWS_DISABLE_NATIVE === "1") {
46
+ if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_DISABLE_NATIVE === "1") {
35
47
  return { path: null, source: "not-found", platform, tried: [] };
36
48
  }
37
49
  const envPath = process.env.TW_NATIVE_PATH?.trim();
@@ -136,7 +148,7 @@ var _loadNative, log, NATIVE_UNAVAILABLE_MESSAGE, nativeBridge, bridgeLoadAttemp
136
148
  var init_nativeBridge = __esm({
137
149
  "packages/domain/compiler/src/nativeBridge.ts"() {
138
150
  init_src();
139
- _loadNative = (path3) => __require(path3);
151
+ _loadNative = (path4) => __require(path4);
140
152
  log = (...args) => {
141
153
  if (process.env.DEBUG?.includes("compiler:native")) {
142
154
  console.log("[compiler:native]", ...args);
@@ -209,530 +221,1917 @@ Tried paths: ${result.tried.join("\n")}`);
209
221
  }
210
222
  });
211
223
 
212
- // packages/domain/compiler/src/tailwindEngine.ts
213
- var tailwindEngine_exports = {};
214
- __export(tailwindEngine_exports, {
215
- generateRawCss: () => generateRawCss,
216
- processTailwindCssWithTargets: () => processTailwindCssWithTargets,
217
- runCssPipeline: () => runCssPipeline,
218
- runCssPipelineSync: () => runCssPipelineSync
219
- });
220
- function loadTailwindEngine() {
221
- if (_twEngine) return _twEngine;
222
- if (_twEngineError) throw _twEngineError;
224
+ // packages/domain/compiler/src/compiler/cssGeneratorNative.ts
225
+ async function generateCssNative(classes, options) {
226
+ const { theme } = options;
227
+ const native = getNativeBridge();
228
+ if (!native?.generateCssNative) {
229
+ throw new Error(
230
+ "FATAL: Rust CSS generator (generateCssNative) is required but not available. Ensure native binding is properly loaded. Check that native/.node binary exists."
231
+ );
232
+ }
233
+ const themeJson = JSON.stringify(theme);
234
+ const css = native.generateCssNative(classes, themeJson);
235
+ return css;
236
+ }
237
+ function getCacheStats() {
223
238
  try {
224
- const tw = require2("tailwindcss");
225
- if (typeof tw.compile !== "function") {
226
- throw new Error("tailwindcss v4 not found \u2014 compile() API missing. Check tailwindcss version >= 4.");
227
- }
228
- _twEngine = tw;
229
- return _twEngine;
230
- } catch (e) {
231
- _twEngineError = e instanceof Error ? e : new Error(String(e));
232
- throw _twEngineError;
233
- }
234
- }
235
- async function generateRawCss(classes, cssEntryContent, root) {
236
- if (classes.length === 0) return "";
237
- const tw = loadTailwindEngine();
238
- const input = cssEntryContent ?? "@import 'tailwindcss';";
239
- const { readFileSync, existsSync: existsSync2 } = await import('fs');
240
- const { dirname, resolve: resolve2 } = await import('path');
241
- const projectRoot = root ?? process.cwd();
242
- const req = createRequire(resolve2(projectRoot, "package.json"));
243
- const loadStylesheet = async (id, base) => {
244
- try {
245
- const cssId = id === "tailwindcss" ? "tailwindcss/index.css" : id === "tailwindcss/preflight" ? "tailwindcss/preflight.css" : id === "tailwindcss/utilities" ? "tailwindcss/utilities.css" : id === "tailwindcss/theme" ? "tailwindcss/theme.css" : id;
246
- const pkgPath = req.resolve(cssId);
247
- return {
248
- content: readFileSync(pkgPath, "utf-8"),
249
- base: dirname(pkgPath)
250
- };
251
- } catch {
252
- try {
253
- const absPath = resolve2(base, id);
254
- if (existsSync2(absPath)) {
255
- return { content: readFileSync(absPath, "utf-8"), base: dirname(absPath) };
256
- }
257
- } catch {
258
- }
259
- return { content: "", base };
239
+ const native = getNativeBridge();
240
+ if (!native?.getCacheStats) {
241
+ return null;
260
242
  }
261
- };
262
- const compiler = await Promise.resolve(tw.compile(input, { loadStylesheet }));
263
- return compiler.build(classes);
243
+ const [hits, misses] = native.getCacheStats();
244
+ return { hits, misses };
245
+ } catch {
246
+ return null;
247
+ }
264
248
  }
265
- function postProcessWithLightning(rawCss) {
266
- if (!rawCss) return "";
267
- const native = getNativeBridge();
268
- if (typeof native.processTailwindCssLightning !== "function") {
269
- throw new Error("FATAL: Native binding 'processTailwindCssLightning' is required but not available.");
249
+ function clearThemeCache() {
250
+ try {
251
+ const native = getNativeBridge();
252
+ if (!native?.clearThemeCache) {
253
+ return;
254
+ }
255
+ native.clearThemeCache();
256
+ } catch {
270
257
  }
271
- const result = native.processTailwindCssLightning(rawCss);
272
- return result?.css ?? rawCss;
273
258
  }
274
- async function runCssPipeline(classes, cssEntryContent, root, minify = true) {
275
- const unique = [...new Set(classes.filter(Boolean))];
276
- if (unique.length === 0) {
277
- return { css: "", classes: [], sizeBytes: 0, optimized: false };
259
+ var init_cssGeneratorNative = __esm({
260
+ "packages/domain/compiler/src/compiler/cssGeneratorNative.ts"() {
261
+ init_nativeBridge();
278
262
  }
279
- const rawCss = await generateRawCss(unique, cssEntryContent, root);
263
+ });
264
+
265
+ // packages/domain/compiler/src/compiler/compilationNative.ts
266
+ function compileCssNative2(classes, prefix) {
280
267
  const native = getNativeBridge();
281
- const hasLightning = minify && typeof native.processTailwindCssLightning === "function";
282
- const finalCss = hasLightning ? postProcessWithLightning(rawCss) : rawCss;
283
- return {
284
- css: finalCss,
285
- classes: unique,
286
- sizeBytes: finalCss.length,
287
- optimized: hasLightning
288
- };
268
+ if (!native?.compileCss) throw new Error("compileCss not available");
269
+ return native.compileCss(classes, prefix);
289
270
  }
290
- function runCssPipelineSync(_classes) {
291
- return { css: "", classes: [], sizeBytes: 0, optimized: false };
271
+ function compileCssLightning(classes) {
272
+ const native = getNativeBridge();
273
+ if (!native?.compileCssLightning) throw new Error("compileCssLightning not available");
274
+ return native.compileCssLightning(classes);
292
275
  }
293
- function processTailwindCssWithTargets(css, targets) {
276
+ function extractTwStateConfigsNative(source, filename) {
294
277
  const native = getNativeBridge();
295
- if (!native?.processTailwindCssWithTargets) {
296
- throw new Error("FATAL: Native binding 'processTailwindCssWithTargets' is required but not available.");
297
- }
298
- const result = native.processTailwindCssWithTargets(css, targets ?? null);
299
- return (result?.css ?? css).trim();
278
+ if (!native?.extractTwStateConfigs) throw new Error("extractTwStateConfigs not available");
279
+ return native.extractTwStateConfigs(source, filename);
300
280
  }
301
- var require2, _twEngine, _twEngineError;
302
- var init_tailwindEngine = __esm({
303
- "packages/domain/compiler/src/tailwindEngine.ts"() {
281
+ function generateStaticStateCssNative(inputs, resolvedCss) {
282
+ const native = getNativeBridge();
283
+ if (!native?.generateStaticStateCss) throw new Error("generateStaticStateCss not available");
284
+ return native.generateStaticStateCss(inputs, resolvedCss ?? null);
285
+ }
286
+ function extractAndGenerateStateCssNative(source, filename) {
287
+ const native = getNativeBridge();
288
+ if (!native?.extractAndGenerateStateCss) throw new Error("extractAndGenerateStateCss not available");
289
+ return native.extractAndGenerateStateCss(source, filename);
290
+ }
291
+ function layoutClassesToCss(classes) {
292
+ const native = getNativeBridge();
293
+ if (!native?.layoutClassesToCss) throw new Error("layoutClassesToCss not available");
294
+ return native.layoutClassesToCss(classes);
295
+ }
296
+ function hashContent(input, algorithm = "sha256", length = 8) {
297
+ const native = getNativeBridge();
298
+ if (!native?.hashContent) throw new Error("hashContent not available");
299
+ return native.hashContent(input, algorithm, length);
300
+ }
301
+ function extractTwContainerConfigs(source) {
302
+ const native = getNativeBridge();
303
+ if (!native?.extractTwContainerConfigs) throw new Error("extractTwContainerConfigs not available");
304
+ return native.extractTwContainerConfigs(source);
305
+ }
306
+ function parseAtomicClass(twClass) {
307
+ const native = getNativeBridge();
308
+ if (!native?.parseAtomicClass) throw new Error("parseAtomicClass not available");
309
+ return native.parseAtomicClass(twClass);
310
+ }
311
+ function generateAtomicCss(rulesJson) {
312
+ const native = getNativeBridge();
313
+ if (!native?.generateAtomicCss) throw new Error("generateAtomicCss not available");
314
+ return native.generateAtomicCss(rulesJson);
315
+ }
316
+ function toAtomicClasses(twClasses) {
317
+ const native = getNativeBridge();
318
+ if (!native?.toAtomicClasses) throw new Error("toAtomicClasses not available");
319
+ return native.toAtomicClasses(twClasses);
320
+ }
321
+ function clearAtomicRegistry() {
322
+ const native = getNativeBridge();
323
+ if (!native?.clearAtomicRegistry) return;
324
+ native.clearAtomicRegistry();
325
+ }
326
+ function atomicRegistrySize() {
327
+ const native = getNativeBridge();
328
+ if (!native?.atomicRegistrySize) return 0;
329
+ return native.atomicRegistrySize();
330
+ }
331
+ var init_compilationNative = __esm({
332
+ "packages/domain/compiler/src/compiler/compilationNative.ts"() {
304
333
  init_nativeBridge();
305
- require2 = createRequire(import.meta.url);
306
- _twEngine = null;
307
- _twEngineError = null;
308
334
  }
309
335
  });
310
336
 
311
- // packages/domain/compiler/src/index.ts
312
- init_nativeBridge();
313
- var transformSource = (source, opts) => {
337
+ // packages/domain/compiler/src/compiler/cssCompilationNative.ts
338
+ function compileClass(input) {
314
339
  const native = getNativeBridge();
315
- if (!native?.transformSource) {
316
- throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
317
- }
318
- const result = native.transformSource(source, opts);
319
- if (!result) {
320
- throw new Error("FATAL: transformSource returned null");
340
+ if (!native?.compile_class) throw new Error("compile_class not available");
341
+ const resultJson = native.compile_class(input);
342
+ try {
343
+ return JSON.parse(resultJson);
344
+ } catch {
345
+ return {
346
+ selector: "",
347
+ declarations: "",
348
+ properties: [],
349
+ specificity: 0
350
+ };
321
351
  }
322
- return result;
323
- };
324
- var hasTwUsage = (source) => {
352
+ }
353
+ function compileClasses(inputs) {
325
354
  const native = getNativeBridge();
326
- if (!native?.hasTwUsage) {
327
- throw new Error("FATAL: Native binding 'hasTwUsage' is required but not available.");
355
+ if (!native?.compile_classes) throw new Error("compile_classes not available");
356
+ const resultJson = native.compile_classes(inputs);
357
+ try {
358
+ return JSON.parse(resultJson);
359
+ } catch {
360
+ return {
361
+ css: "",
362
+ resolved_classes: [],
363
+ unknown_classes: [],
364
+ size_bytes: 0,
365
+ duration_ms: 0
366
+ };
328
367
  }
329
- return native.hasTwUsage(source);
330
- };
331
- var isAlreadyTransformed = (source) => {
368
+ }
369
+ function compileToCss(input, minify) {
332
370
  const native = getNativeBridge();
333
- if (!native?.isAlreadyTransformed) {
334
- throw new Error("FATAL: Native binding 'isAlreadyTransformed' is required but not available.");
335
- }
336
- return native.isAlreadyTransformed(source);
337
- };
338
- var shouldProcess = (source) => {
339
- return hasTwUsage(source) && !isAlreadyTransformed(source);
340
- };
341
- var compileCssFromClasses = (classes, prefix) => {
371
+ if (!native?.compile_to_css) throw new Error("compile_to_css not available");
372
+ return native.compile_to_css(input, minify ?? false);
373
+ }
374
+ function compileToCssBatch(inputs, minify) {
342
375
  const native = getNativeBridge();
343
- if (!native?.transformSource) {
344
- throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
345
- }
346
- const result = native.transformSource(classes.join(" "), { prefix: prefix ?? "" });
347
- if (!result) {
348
- throw new Error("FATAL: transformSource returned null");
349
- }
350
- return result;
351
- };
352
- var buildStyleTag = (classes) => {
353
- const result = compileCssFromClasses(classes);
354
- return result?.code ? `<style data-tailwind-styled>${result.code}</style>` : "";
355
- };
356
- var compileCssNative = (classes, prefix = null) => {
357
- return compileCssFromClasses(classes, prefix);
358
- };
359
- var generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
360
- const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
361
- const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
362
- return result.css;
363
- };
364
- var extractAllClasses = (source) => {
376
+ if (!native?.compile_to_css_batch) throw new Error("compile_to_css_batch not available");
377
+ return native.compile_to_css_batch(inputs, minify ?? false);
378
+ }
379
+ function minifyCss(css) {
365
380
  const native = getNativeBridge();
366
- if (!native?.extractAllClasses) {
367
- throw new Error("FATAL: Native binding 'extractAllClasses' is required but not available.");
368
- }
369
- return native.extractAllClasses(source) || [];
370
- };
371
- var extractClassesFromSource = (source) => {
381
+ if (!native?.minify_css) throw new Error("minify_css not available");
382
+ return native.minify_css(css);
383
+ }
384
+ function compileAnimation(animationName, from, to) {
372
385
  const native = getNativeBridge();
373
- if (!native?.extractClassesFromSource) {
374
- throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
386
+ if (!native?.compile_animation) throw new Error("compile_animation not available");
387
+ const resultJson = native.compile_animation(animationName, from, to);
388
+ try {
389
+ return JSON.parse(resultJson);
390
+ } catch {
391
+ return {
392
+ animation_id: "",
393
+ keyframes_css: "",
394
+ animation_rule: "",
395
+ duration_ms: 0
396
+ };
375
397
  }
376
- const result = native.extractClassesFromSource(source);
377
- return Array.isArray(result) ? result.join(" ") : String(result || "");
378
- };
379
- var astExtractClasses = (source, filename) => {
398
+ }
399
+ function compileKeyframes(name, stopsJson) {
380
400
  const native = getNativeBridge();
381
- if (!native?.extractClassesFromSource) {
382
- throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
401
+ if (!native?.compile_keyframes) throw new Error("compile_keyframes not available");
402
+ const resultJson = native.compile_keyframes(name, stopsJson);
403
+ try {
404
+ return JSON.parse(resultJson);
405
+ } catch {
406
+ return {
407
+ animation_id: "",
408
+ keyframes_css: "",
409
+ animation_rule: "",
410
+ duration_ms: 0
411
+ };
383
412
  }
384
- return native.extractClassesFromSource(source) || [];
385
- };
386
- var parseClasses = (raw) => {
413
+ }
414
+ function compileTheme(tokensJson, themeName, prefix) {
387
415
  const native = getNativeBridge();
388
- if (!native?.parseClasses) {
389
- throw new Error("FATAL: Native binding 'parseClasses' is required but not available.");
416
+ if (!native?.compile_theme) throw new Error("compile_theme not available");
417
+ const resultJson = native.compile_theme(tokensJson, themeName, prefix);
418
+ try {
419
+ return JSON.parse(resultJson);
420
+ } catch {
421
+ return {
422
+ selector: ":root",
423
+ variables: [],
424
+ variables_css: "",
425
+ theme_name: themeName
426
+ };
390
427
  }
391
- return native.parseClasses(raw) || [];
392
- };
393
- var normalizeClasses = (raw) => {
394
- const result = normalizeAndDedupClasses(raw);
395
- return result?.normalized || "";
396
- };
397
- var mergeClassesStatic = (classes) => {
398
- const result = normalizeAndDedupClasses(classes);
399
- return result?.normalized || "";
400
- };
401
- var normalizeAndDedupClasses = (raw) => {
428
+ }
429
+ function twMerge(classString) {
402
430
  const native = getNativeBridge();
403
- if (!native?.normalizeAndDedupClasses) {
404
- throw new Error("FATAL: Native binding 'normalizeAndDedupClasses' is required but not available.");
405
- }
406
- const result = native.normalizeAndDedupClasses(raw);
407
- return result || { normalized: "", duplicatesRemoved: 0, uniqueCount: 0 };
408
- };
409
- var eliminateDeadCss = (css, deadClasses) => {
431
+ if (!native?.tw_merge) throw new Error("tw_merge not available");
432
+ return native.tw_merge(classString);
433
+ }
434
+ function twMergeMany(classStrings) {
410
435
  const native = getNativeBridge();
411
- if (!native?.processTailwindCssLightning) {
412
- throw new Error("FATAL: Native binding 'processTailwindCssLightning' is required but not available.");
413
- }
414
- const deadSet = deadClasses;
415
- const pruned = css.split(/(?<=\})\s*/).filter((rule) => {
416
- const m = rule.match(/\.([a-zA-Z0-9_-]+)/);
417
- return !m || !deadSet.has(m[1]);
418
- }).join("\n");
419
- const compiled = native.processTailwindCssLightning(pruned);
420
- return (compiled?.css ?? pruned).trim();
421
- };
422
- var findDeadVariants = (variantConfig, usage) => {
423
- const unused = [];
424
- const configs = Array.isArray(variantConfig) ? variantConfig : [{ name: "__root__", variants: variantConfig }];
425
- for (const component of configs) {
426
- const componentUsage = usage[component.name] ?? /* @__PURE__ */ new Set();
427
- const variants = component.variants;
428
- for (const [key, values] of Object.entries(variants)) {
429
- for (const [value] of Object.entries(values)) {
430
- if (!componentUsage.has(`${key}:${value}`)) {
431
- unused.push(`${component.name !== "__root__" ? `${component.name}/` : ""}${key}:${value}`);
432
- }
433
- }
434
- }
435
- }
436
- return {
437
- unusedCount: unused.length,
438
- unused
436
+ if (!native?.tw_merge_many) throw new Error("tw_merge_many not available");
437
+ return native.tw_merge_many(classStrings);
438
+ }
439
+ function twMergeWithSeparator(classString, options) {
440
+ const native = getNativeBridge();
441
+ if (!native?.tw_merge_with_separator)
442
+ throw new Error("tw_merge_with_separator not available");
443
+ const opts = {
444
+ separator: options.separator,
445
+ debug: options.debug
439
446
  };
440
- };
441
- var runElimination = (css, scanResult) => {
447
+ return native.tw_merge_with_separator(classString, opts);
448
+ }
449
+ function twMergeManyWithSeparator(classStrings, options) {
442
450
  const native = getNativeBridge();
443
- if (!native?.detectDeadCode) {
444
- throw new Error("FATAL: Native binding 'detectDeadCode' is required but not available.");
445
- }
446
- const dead = native.detectDeadCode(
447
- JSON.stringify(scanResult),
448
- css
449
- );
450
- return eliminateDeadCss(css, new Set(dead.deadInCss ?? []));
451
- };
452
- var optimizeCss = (css) => {
451
+ if (!native?.tw_merge_many_with_separator)
452
+ throw new Error("tw_merge_many_with_separator not available");
453
+ const opts = {
454
+ separator: options.separator,
455
+ debug: options.debug
456
+ };
457
+ return native.tw_merge_many_with_separator(classStrings, opts);
458
+ }
459
+ function twMergeRaw(classLists) {
453
460
  const native = getNativeBridge();
454
- if (!native?.detectDeadCode) {
455
- throw new Error("FATAL: Native binding 'detectDeadCode' is required but not available.");
456
- }
457
- const deadResult = native.detectDeadCode(
458
- JSON.stringify({ uniqueClasses: [] }),
459
- css
460
- );
461
- if (!native?.processTailwindCssLightning) {
462
- throw new Error("FATAL: Native binding 'processTailwindCssLightning' is required but not available.");
463
- }
464
- const deadSet = new Set(deadResult.deadInCss ?? []);
465
- const pruned = css.split(/(?<=\})\s*/).filter((rule) => {
466
- const selectorMatch = rule.match(/\.([a-zA-Z0-9_-]+)/);
467
- if (!selectorMatch) return true;
468
- return !deadSet.has(selectorMatch[1]);
469
- }).join("\n");
470
- const compiled = native.processTailwindCssLightning(pruned);
471
- return (compiled?.css ?? pruned).trim();
472
- };
473
- var scanProjectUsage = (dirs, cwd) => {
474
- const path3 = __require("path");
475
- const files = dirs.map((dir) => path3.resolve(cwd, dir));
476
- const results = batchExtractClasses(files) || [];
477
- const combined = {};
478
- for (const result of results) {
479
- if (result.ok && result.classes) {
480
- for (const cls of result.classes) {
481
- if (!combined[cls]) combined[cls] = {};
482
- combined[cls][result.file] = /* @__PURE__ */ new Set([cls]);
483
- }
484
- }
461
+ if (!native?.tw_merge_raw) throw new Error("tw_merge_raw not available");
462
+ return native.tw_merge_raw(classLists);
463
+ }
464
+ var init_cssCompilationNative = __esm({
465
+ "packages/domain/compiler/src/compiler/cssCompilationNative.ts"() {
466
+ init_nativeBridge();
485
467
  }
486
- return combined;
487
- };
488
- var extractComponentUsage = (source) => {
468
+ });
469
+
470
+ // packages/domain/compiler/src/compiler/idRegistryNative.ts
471
+ function idRegistryCreate() {
489
472
  const native = getNativeBridge();
490
- if (!native?.extractComponentUsage) {
491
- throw new Error("FATAL: Native binding 'extractComponentUsage' is required but not available.");
492
- }
493
- return native.extractComponentUsage(source) || [];
494
- };
495
- var diffClassLists = (previous, current) => {
473
+ if (!native?.id_registry_create) throw new Error("id_registry_create not available");
474
+ return native.id_registry_create();
475
+ }
476
+ function idRegistryGenerate(handle, name) {
496
477
  const native = getNativeBridge();
497
- if (!native?.diffClassLists) {
498
- throw new Error("FATAL: Native binding 'diffClassLists' is required but not available.");
499
- }
500
- return native.diffClassLists(previous, current) || { added: [], removed: [], unchanged: [], hasChanges: false };
501
- };
502
- var batchExtractClasses = (filePaths) => {
478
+ if (!native?.id_registry_generate) throw new Error("id_registry_generate not available");
479
+ return native.id_registry_generate(handle, name);
480
+ }
481
+ function idRegistryLookup(handle, name) {
503
482
  const native = getNativeBridge();
504
- if (!native?.batchExtractClasses) {
505
- throw new Error("FATAL: Native binding 'batchExtractClasses' is required but not available.");
506
- }
507
- return native.batchExtractClasses(filePaths) || [];
508
- };
509
- var checkAgainstSafelist = (classes, safelist) => {
483
+ if (!native?.id_registry_lookup) throw new Error("id_registry_lookup not available");
484
+ return native.id_registry_lookup(handle, name);
485
+ }
486
+ function idRegistryNext(handle) {
487
+ const native = getNativeBridge();
488
+ if (!native?.id_registry_next) throw new Error("id_registry_next not available");
489
+ return native.id_registry_next(handle);
490
+ }
491
+ function idRegistryDestroy(handle) {
492
+ const native = getNativeBridge();
493
+ if (!native?.id_registry_destroy) return;
494
+ native.id_registry_destroy(handle);
495
+ }
496
+ function idRegistryReset(handle) {
497
+ const native = getNativeBridge();
498
+ if (!native?.id_registry_reset) return;
499
+ native.id_registry_reset(handle);
500
+ }
501
+ function idRegistrySnapshot(handle) {
510
502
  const native = getNativeBridge();
511
- if (!native?.checkAgainstSafelist) {
512
- throw new Error("FATAL: Native binding 'checkAgainstSafelist' is required but not available.");
503
+ if (!native?.id_registry_snapshot) throw new Error("id_registry_snapshot not available");
504
+ const snapshotJson = native.id_registry_snapshot(handle);
505
+ try {
506
+ return JSON.parse(snapshotJson);
507
+ } catch {
508
+ return {
509
+ handle,
510
+ next_id: 0,
511
+ entries: [],
512
+ total_entries: 0
513
+ };
513
514
  }
514
- return native.checkAgainstSafelist(classes, safelist) || { matched: [], unmatched: [], safelistSize: 0 };
515
- };
516
- var hoistComponents = (source) => {
515
+ }
516
+ function idRegistryActiveCount() {
517
+ const native = getNativeBridge();
518
+ if (!native?.id_registry_active_count) throw new Error("id_registry_active_count not available");
519
+ return native.id_registry_active_count();
520
+ }
521
+ function registerPropertyName(propertyName) {
522
+ const native = getNativeBridge();
523
+ if (!native?.register_property_name)
524
+ throw new Error("register_property_name not available");
525
+ return native.register_property_name(propertyName);
526
+ }
527
+ function registerValueName(valueName) {
528
+ const native = getNativeBridge();
529
+ if (!native?.register_value_name) throw new Error("register_value_name not available");
530
+ return native.register_value_name(valueName);
531
+ }
532
+ function propertyIdToString(propertyId) {
517
533
  const native = getNativeBridge();
518
- if (!native?.hoistComponents) {
519
- throw new Error("FATAL: Native binding 'hoistComponents' is required but not available.");
534
+ if (!native?.property_id_to_string) throw new Error("property_id_to_string not available");
535
+ return native.property_id_to_string(propertyId);
536
+ }
537
+ function valueIdToString(valueId) {
538
+ const native = getNativeBridge();
539
+ if (!native?.value_id_to_string) throw new Error("value_id_to_string not available");
540
+ return native.value_id_to_string(valueId);
541
+ }
542
+ function reverseLookupProperty(propertyId) {
543
+ const native = getNativeBridge();
544
+ if (!native?.reverse_lookup_property)
545
+ throw new Error("reverse_lookup_property not available");
546
+ return native.reverse_lookup_property(propertyId);
547
+ }
548
+ function reverseLookupValue(valueId) {
549
+ const native = getNativeBridge();
550
+ if (!native?.reverse_lookup_value) throw new Error("reverse_lookup_value not available");
551
+ return native.reverse_lookup_value(valueId);
552
+ }
553
+ function idRegistryExport(handle) {
554
+ const native = getNativeBridge();
555
+ if (!native?.id_registry_export) throw new Error("id_registry_export not available");
556
+ return native.id_registry_export(handle);
557
+ }
558
+ function idRegistryImport(importedData) {
559
+ const native = getNativeBridge();
560
+ if (!native?.id_registry_import) throw new Error("id_registry_import not available");
561
+ return native.id_registry_import(importedData);
562
+ }
563
+ var init_idRegistryNative = __esm({
564
+ "packages/domain/compiler/src/compiler/idRegistryNative.ts"() {
565
+ init_nativeBridge();
520
566
  }
521
- return native.hoistComponents(source) || { code: source, hoisted: [], warnings: [] };
522
- };
523
- var compileVariantTable = (configJson) => {
567
+ });
568
+
569
+ // packages/domain/compiler/src/compiler/streamingNative.ts
570
+ function processFileChange(fileChangeJson) {
524
571
  const native = getNativeBridge();
525
- if (!native?.compileVariantTable) {
526
- throw new Error("FATAL: Native binding 'compileVariantTable' is required but not available.");
572
+ if (!native?.process_file_change) throw new Error("process_file_change not available");
573
+ const resultJson = native.process_file_change(fileChangeJson);
574
+ try {
575
+ return JSON.parse(resultJson);
576
+ } catch {
577
+ return {
578
+ file_path: "",
579
+ status: "error",
580
+ old_classes: [],
581
+ new_classes: [],
582
+ added_classes: [],
583
+ removed_classes: [],
584
+ changed: false,
585
+ fingerprint: "",
586
+ error: "Failed to parse result"
587
+ };
527
588
  }
528
- return native.compileVariantTable(configJson) || { id: "", tableJson: "{}", keys: [], defaultKey: "", combinations: 0 };
529
- };
530
- var compileVariants = (componentId, config) => {
531
- return compileVariantTable(JSON.stringify({ componentId, ...config }));
532
- };
533
- var classifyAndSortClasses = (classes) => {
589
+ }
590
+ function computeIncrementalDiff(oldScanJson, newScanJson) {
534
591
  const native = getNativeBridge();
535
- if (!native?.classifyAndSortClasses) {
536
- throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
592
+ if (!native?.compute_incremental_diff)
593
+ throw new Error("compute_incremental_diff not available");
594
+ const resultJson = native.compute_incremental_diff(oldScanJson, newScanJson);
595
+ try {
596
+ return JSON.parse(resultJson);
597
+ } catch {
598
+ return {
599
+ is_changed: false,
600
+ changes_count: 0,
601
+ diff: {
602
+ added_files: [],
603
+ removed_files: [],
604
+ modified_files: [],
605
+ added_classes: [],
606
+ removed_classes: [],
607
+ total_changes: 0
608
+ },
609
+ processing_time_ms: 0
610
+ };
537
611
  }
538
- return native.classifyAndSortClasses(classes) || [];
539
- };
540
- var mergeCssDeclarations = (cssChunks) => {
612
+ }
613
+ function createFingerprint(filePath, fileContent) {
541
614
  const native = getNativeBridge();
542
- if (!native?.mergeCssDeclarations) {
543
- throw new Error("FATAL: Native binding 'mergeCssDeclarations' is required but not available.");
615
+ if (!native?.create_fingerprint) throw new Error("create_fingerprint not available");
616
+ const fingerprintJson = native.create_fingerprint(filePath, fileContent);
617
+ try {
618
+ return JSON.parse(fingerprintJson);
619
+ } catch {
620
+ return {
621
+ file_path: filePath,
622
+ content_hash: "",
623
+ size_bytes: fileContent.length,
624
+ mtime_ms: Date.now(),
625
+ class_hash: "",
626
+ signature: ""
627
+ };
544
628
  }
545
- return native.mergeCssDeclarations(cssChunks) || { declarationsJson: "{}", declarationString: "", count: 0 };
546
- };
547
- var analyzeClassUsage = (classes, scanResultJson, css) => {
629
+ }
630
+ function injectStateHash(css, stateHash) {
548
631
  const native = getNativeBridge();
549
- if (!native?.analyzeClassUsage) {
550
- throw new Error("FATAL: Native binding 'analyzeClassUsage' is required but not available.");
632
+ if (!native?.inject_state_hash) throw new Error("inject_state_hash not available");
633
+ const resultJson = native.inject_state_hash(css, stateHash);
634
+ try {
635
+ return JSON.parse(resultJson);
636
+ } catch {
637
+ return {
638
+ injected: false,
639
+ state_hash: stateHash,
640
+ affected_files: 0,
641
+ total_injected_bytes: 0
642
+ };
551
643
  }
552
- return native.analyzeClassUsage(classes, scanResultJson, css) || [];
553
- };
554
- var analyzeRsc = (source, filename) => {
644
+ }
645
+ function pruneStaleCacheEntries(maxAgeSeconds, maxEntries) {
555
646
  const native = getNativeBridge();
556
- if (!native?.analyzeRsc) {
557
- throw new Error("FATAL: Native binding 'analyzeRsc' is required but not available.");
647
+ if (!native?.prune_stale_entries) throw new Error("prune_stale_entries not available");
648
+ const resultJson = native.prune_stale_entries(maxAgeSeconds, maxEntries);
649
+ try {
650
+ return JSON.parse(resultJson);
651
+ } catch {
652
+ return {
653
+ entries_before: 0,
654
+ entries_after: 0,
655
+ entries_removed: 0,
656
+ freed_bytes: 0
657
+ };
558
658
  }
559
- return native.analyzeRsc(source, filename) || { isServer: true, needsClientDirective: false, clientReasons: [] };
560
- };
561
- var analyzeFile = (source, filename) => {
562
- const rsc = analyzeRsc(source, filename);
563
- return {
564
- isServer: rsc?.isServer ?? true,
565
- needsClientDirective: rsc?.needsClientDirective ?? false,
566
- clientReasons: rsc?.clientReasons ?? [],
567
- interactiveClasses: [],
568
- canStaticResolveVariants: true
569
- };
570
- };
571
- var analyzeVariantUsage = (source, componentName, variantKeys) => {
572
- analyzeRsc(source, componentName);
573
- return {
574
- resolved: {},
575
- dynamic: []
576
- };
577
- };
578
- var injectClientDirective = (source) => {
579
- if (!source.includes('"use client"') && !source.includes("'use client'")) {
580
- return '"use client";\n' + source;
659
+ }
660
+ function rebuildWorkspaceResult(rootDir, extensions) {
661
+ const native = getNativeBridge();
662
+ if (!native?.rebuild_workspace_result)
663
+ throw new Error("rebuild_workspace_result not available");
664
+ const resultJson = native.rebuild_workspace_result(rootDir, extensions || []);
665
+ try {
666
+ return JSON.parse(resultJson);
667
+ } catch {
668
+ return {
669
+ total_files_scanned: 0,
670
+ total_classes_found: 0,
671
+ unique_classes: 0,
672
+ build_time_ms: 0,
673
+ files_with_changes: 0
674
+ };
581
675
  }
582
- return source;
583
- };
584
- var injectServerOnlyComment = (source) => {
585
- return `/* @server-only */
586
- ${source}`;
587
- };
588
- var analyzeClasses = (filesJson, cwd, flags) => {
676
+ }
677
+ function scanFileNative(filePath, fileContent) {
589
678
  const native = getNativeBridge();
590
- if (!native?.analyzeClasses) {
591
- throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
679
+ if (!native?.scan_file_native) throw new Error("scan_file_native not available");
680
+ const resultJson = native.scan_file_native(filePath, fileContent);
681
+ try {
682
+ return JSON.parse(resultJson);
683
+ } catch {
684
+ return {
685
+ file: filePath,
686
+ classes: [],
687
+ added_classes: [],
688
+ removed_classes: [],
689
+ changed: false
690
+ };
592
691
  }
593
- return native.analyzeClasses(filesJson, cwd, flags);
594
- };
595
- var generateSafelist = (scanDirs, outputPath, cwd) => {
596
- const classes = scanProjectUsage(scanDirs, cwd || process.cwd());
597
- const allClasses = Object.keys(classes).sort();
598
- if (outputPath) {
599
- const fs3 = __require("fs");
600
- fs3.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
601
- }
602
- return allClasses;
603
- };
604
- var loadSafelist = (safelistPath) => {
605
- const fs3 = __require("fs");
692
+ }
693
+ function scanFilesBatchNative(filesJson) {
694
+ const native = getNativeBridge();
695
+ if (!native?.scan_files_batch_native)
696
+ throw new Error("scan_files_batch_native not available");
697
+ const resultJson = native.scan_files_batch_native(filesJson);
606
698
  try {
607
- const content = fs3.readFileSync(safelistPath, "utf-8");
608
- return JSON.parse(content);
699
+ return JSON.parse(resultJson);
609
700
  } catch {
610
701
  return [];
611
702
  }
612
- };
613
- var loadTailwindConfig = (cwd = process.cwd()) => {
614
- const fs3 = __require("fs");
615
- const path3 = __require("path");
616
- const configFiles = [
617
- "tailwind.config.ts",
618
- "tailwind.config.js",
619
- "tailwind.config.mjs",
620
- "tailwind.config.cjs"
621
- ];
622
- for (const file of configFiles) {
623
- const fullPath = path3.join(cwd, file);
624
- if (fs3.existsSync(fullPath)) {
625
- const mod = __require(fullPath);
626
- return mod.default || mod;
703
+ }
704
+ var init_streamingNative = __esm({
705
+ "packages/domain/compiler/src/compiler/streamingNative.ts"() {
706
+ init_nativeBridge();
707
+ }
708
+ });
709
+
710
+ // packages/domain/compiler/src/compiler/tailwindEngine.ts
711
+ var tailwindEngine_exports = {};
712
+ __export(tailwindEngine_exports, {
713
+ clearCache: () => clearCache,
714
+ getCacheStats: () => getCacheStats2,
715
+ processTailwindCssWithTargets: () => processTailwindCssWithTargets,
716
+ runCssPipeline: () => runCssPipeline,
717
+ runCssPipelineSync: () => runCssPipelineSync
718
+ });
719
+ function _getCacheKey(classes, minify, cssEntry, root) {
720
+ const sorted = [...classes].sort().join(",");
721
+ const flags = `${minify ? "1" : "0"}${cssEntry ? "1" : "0"}${root ? "1" : "0"}`;
722
+ return `${sorted}|${flags}`;
723
+ }
724
+ function _evictOldestIfNeeded() {
725
+ if (_cssCache.size >= MAX_CACHE_SIZE) {
726
+ const firstKey = _cssCache.keys().next().value;
727
+ if (firstKey !== void 0) {
728
+ _cssCache.delete(firstKey);
627
729
  }
628
730
  }
629
- return {};
630
- };
631
- var getContentPaths = (cwd = process.cwd()) => {
632
- const path3 = __require("path");
731
+ }
732
+ function getCacheStats2() {
733
+ const total = _cacheHits + _cacheMisses;
633
734
  return {
634
- content: [
635
- path3.join(cwd, "src/**/*.{js,ts,jsx,tsx}"),
636
- path3.join(cwd, "app/**/*.{js,ts,jsx,tsx}"),
637
- path3.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
638
- ]
735
+ hits: _cacheHits,
736
+ misses: _cacheMisses,
737
+ hitRate: total > 0 ? _cacheHits / total : 0,
738
+ size: _cssCache.size,
739
+ maxSize: MAX_CACHE_SIZE
639
740
  };
640
- };
641
- var runLoaderTransform = (ctx) => {
642
- const { filepath, source, options } = ctx;
643
- const result = transformSource(source, { filename: filepath, ...options });
741
+ }
742
+ function clearCache() {
743
+ _cssCache.clear();
744
+ _cacheHits = 0;
745
+ _cacheMisses = 0;
746
+ }
747
+ function getThemeConfig() {
644
748
  return {
645
- code: result?.code || "",
646
- changed: result?.changed || false,
647
- classes: result?.classes || []
749
+ colors: {
750
+ slate: {
751
+ "50": "#f8fafc",
752
+ "100": "#f1f5f9",
753
+ "200": "#e2e8f0",
754
+ "300": "#cbd5e1",
755
+ "400": "#94a3b8",
756
+ "500": "#64748b",
757
+ "600": "#475569",
758
+ "700": "#334155",
759
+ "800": "#1e293b",
760
+ "900": "#0f172a"
761
+ },
762
+ gray: {
763
+ "50": "#f9fafb",
764
+ "100": "#f3f4f6",
765
+ "200": "#e5e7eb",
766
+ "300": "#d1d5db",
767
+ "400": "#9ca3af",
768
+ "500": "#6b7280",
769
+ "600": "#4b5563",
770
+ "700": "#374151",
771
+ "800": "#1f2937",
772
+ "900": "#111827"
773
+ },
774
+ white: "#ffffff",
775
+ black: "#000000",
776
+ red: {
777
+ "500": "#ef4444",
778
+ "600": "#dc2626"
779
+ },
780
+ blue: {
781
+ "500": "#3b82f6",
782
+ "600": "#1e40af"
783
+ }
784
+ },
785
+ spacing: {
786
+ "0": "0px",
787
+ "1": "0.25rem",
788
+ "2": "0.5rem",
789
+ "3": "0.75rem",
790
+ "4": "1rem",
791
+ "5": "1.25rem",
792
+ "6": "1.5rem",
793
+ "8": "2rem",
794
+ "10": "2.5rem",
795
+ "12": "3rem",
796
+ "16": "4rem",
797
+ "20": "5rem",
798
+ "24": "6rem"
799
+ },
800
+ breakpoints: {
801
+ "sm": "640px",
802
+ "md": "768px",
803
+ "lg": "1024px",
804
+ "xl": "1280px",
805
+ "2xl": "1536px"
806
+ }
648
807
  };
649
- };
650
- var shouldSkipFile = (filepath) => {
651
- const SKIP_PATHS = ["node_modules", ".next", ".rspack-dist", ".turbo", "dist/", "out/"];
652
- const skipExtensions = [".css", ".json", ".md", ".txt", ".yaml", ".yml"];
653
- for (const p of SKIP_PATHS) {
654
- if (filepath.includes(p)) return true;
808
+ }
809
+ function postProcessWithLightning(rawCss) {
810
+ if (!rawCss) return "";
811
+ const native = getNativeBridge();
812
+ if (!native?.processTailwindCssLightning) {
813
+ throw new Error("FATAL: Native binding 'processTailwindCssLightning' is required but not available.");
655
814
  }
656
- for (const ext of skipExtensions) {
657
- if (filepath.endsWith(ext)) return true;
815
+ const result = native.processTailwindCssLightning(rawCss);
816
+ if (!result?.css) {
817
+ throw new Error("FATAL: processTailwindCssLightning returned null");
658
818
  }
659
- return false;
660
- };
661
- var fileToRoute = (filepath) => {
662
- const normalized = filepath.replace(/\\/g, "/");
663
- if (normalized.includes("/layout.") || normalized.includes("/loading.") || normalized.includes("/error.")) {
664
- return "__global";
665
- }
666
- const pageMatch = normalized.match(/\/app\/(.+?)\/page\.[tj]sx?$/);
667
- if (pageMatch) return `/${pageMatch[1]}`;
668
- const rootPage = normalized.match(/\/app\/page\.[tj]sx?$/);
669
- if (rootPage) return "/";
670
- return null;
671
- };
672
- var getAllRoutes = () => {
673
- const native = getNativeBridge();
674
- if (!native?.analyzeClasses) {
675
- throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
819
+ return result.css;
820
+ }
821
+ async function runCssPipeline(classes, cssEntryContent, root, minify = true) {
822
+ const filtered = classes.filter(Boolean);
823
+ const uniqueMap = /* @__PURE__ */ new Map();
824
+ filtered.forEach((cls) => uniqueMap.set(cls, cls));
825
+ const unique = Array.from(uniqueMap.values());
826
+ if (unique.length === 0) {
827
+ return { css: "", classes: [], sizeBytes: 0, optimized: false };
676
828
  }
677
- return ["/", "__global"];
678
- };
679
- var getRouteClasses = (_route) => {
680
- return /* @__PURE__ */ new Set();
681
- };
682
- var registerFileClasses = (_filepath, _classes) => {
683
- };
684
- var registerGlobalClasses = (_classes) => {
685
- };
686
- var _incrementalEngineInstance = null;
687
- var getIncrementalEngine = () => {
688
- if (!_incrementalEngineInstance) {
689
- _incrementalEngineInstance = new IncrementalEngine();
829
+ const cacheKey = _getCacheKey(unique, minify, cssEntryContent, root);
830
+ const cached = _cssCache.get(cacheKey);
831
+ if (cached) {
832
+ _cacheHits++;
833
+ if (process.env.DEBUG?.includes("compiler")) {
834
+ console.log(
835
+ `[Compiler] Cache HIT: ${unique.length} classes (hit rate: ${(getCacheStats2().hitRate * 100).toFixed(1)}%)`
836
+ );
837
+ }
838
+ return cached;
690
839
  }
691
- return _incrementalEngineInstance;
692
- };
693
- var resetIncrementalEngine = () => {
694
- _incrementalEngineInstance = null;
695
- };
696
- var IncrementalEngine = class {
697
- compile(source) {
698
- return transformSource(source);
840
+ _cacheMisses++;
841
+ let rawCss;
842
+ let usedRustCompiler = false;
843
+ const theme = getThemeConfig();
844
+ rawCss = await generateCssNative(unique, { theme });
845
+ usedRustCompiler = true;
846
+ const finalCss = minify ? postProcessWithLightning(rawCss) : rawCss;
847
+ if (process.env.DEBUG?.includes("compiler")) {
848
+ console.log(
849
+ `[Compiler] Generated CSS from ${unique.length} classes (${usedRustCompiler ? "Rust" : "JavaScript"})`,
850
+ `Size: ${finalCss.length} bytes`
851
+ );
699
852
  }
700
- };
701
- var getBucketEngine = () => {
853
+ const result = {
854
+ css: finalCss,
855
+ classes: unique,
856
+ sizeBytes: finalCss.length,
857
+ optimized: minify
858
+ };
859
+ _evictOldestIfNeeded();
860
+ _cssCache.set(cacheKey, result);
861
+ return result;
862
+ }
863
+ function runCssPipelineSync(_classes) {
864
+ return { css: "", classes: [], sizeBytes: 0, optimized: false };
865
+ }
866
+ function processTailwindCssWithTargets(css, targets) {
702
867
  const native = getNativeBridge();
703
- if (!native?.classifyAndSortClasses) {
704
- throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
868
+ if (!native?.processTailwindCssWithTargets) {
869
+ throw new Error("FATAL: Native binding 'processTailwindCssWithTargets' is required but not available.");
870
+ }
871
+ const result = native.processTailwindCssWithTargets(css, targets ?? null);
872
+ if (!result?.css) {
873
+ throw new Error("FATAL: processTailwindCssWithTargets returned null");
874
+ }
875
+ return result.css;
876
+ }
877
+ var _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE;
878
+ var init_tailwindEngine = __esm({
879
+ "packages/domain/compiler/src/compiler/tailwindEngine.ts"() {
880
+ init_nativeBridge();
881
+ init_cssGeneratorNative();
882
+ createRequire(import.meta.url);
883
+ _cssCache = /* @__PURE__ */ new Map();
884
+ _cacheHits = 0;
885
+ _cacheMisses = 0;
886
+ MAX_CACHE_SIZE = 100;
887
+ }
888
+ });
889
+
890
+ // packages/domain/compiler/src/compiler/index.ts
891
+ var init_compiler = __esm({
892
+ "packages/domain/compiler/src/compiler/index.ts"() {
893
+ init_cssGeneratorNative();
894
+ init_compilationNative();
895
+ init_cssCompilationNative();
896
+ init_idRegistryNative();
897
+ init_streamingNative();
898
+ init_tailwindEngine();
705
899
  }
900
+ });
901
+
902
+ // packages/domain/compiler/src/parser/index.ts
903
+ var parser_exports = {};
904
+ __export(parser_exports, {
905
+ astExtractClasses: () => astExtractClasses,
906
+ batchExtractClasses: () => batchExtractClasses,
907
+ checkAgainstSafelist: () => checkAgainstSafelist,
908
+ diffClassLists: () => diffClassLists,
909
+ extractAllClasses: () => extractAllClasses,
910
+ extractClassesFromSource: () => extractClassesFromSource,
911
+ extractComponentUsage: () => extractComponentUsage,
912
+ mergeClassesStatic: () => mergeClassesStatic,
913
+ normalizeAndDedupClasses: () => normalizeAndDedupClasses,
914
+ normalizeClasses: () => normalizeClasses,
915
+ parseClasses: () => parseClasses
916
+ });
917
+ var parseClasses, extractAllClasses, extractClassesFromSource, astExtractClasses, normalizeClasses, mergeClassesStatic, normalizeAndDedupClasses, extractComponentUsage, batchExtractClasses, checkAgainstSafelist, diffClassLists;
918
+ var init_parser = __esm({
919
+ "packages/domain/compiler/src/parser/index.ts"() {
920
+ init_nativeBridge();
921
+ parseClasses = (raw) => {
922
+ const native = getNativeBridge();
923
+ if (!native?.parseClasses) {
924
+ throw new Error("FATAL: Native binding 'parseClasses' is required but not available.");
925
+ }
926
+ return native.parseClasses(raw) || [];
927
+ };
928
+ extractAllClasses = (source) => {
929
+ const native = getNativeBridge();
930
+ if (!native?.extractAllClasses) {
931
+ throw new Error("FATAL: Native binding 'extractAllClasses' is required but not available.");
932
+ }
933
+ return native.extractAllClasses(source) || [];
934
+ };
935
+ extractClassesFromSource = (source) => {
936
+ const native = getNativeBridge();
937
+ if (!native?.extractClassesFromSource) {
938
+ throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
939
+ }
940
+ const result = native.extractClassesFromSource(source);
941
+ return Array.isArray(result) ? result.join(" ") : String(result || "");
942
+ };
943
+ astExtractClasses = (source, _filename) => {
944
+ const native = getNativeBridge();
945
+ if (!native?.extractClassesFromSource) {
946
+ throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
947
+ }
948
+ return native.extractClassesFromSource(source) || [];
949
+ };
950
+ normalizeClasses = (raw) => {
951
+ const result = normalizeAndDedupClasses(raw);
952
+ return result?.normalized || "";
953
+ };
954
+ mergeClassesStatic = (classes) => {
955
+ const result = normalizeAndDedupClasses(classes);
956
+ return result?.normalized || "";
957
+ };
958
+ normalizeAndDedupClasses = (raw) => {
959
+ const native = getNativeBridge();
960
+ if (!native?.normalizeAndDedupClasses) {
961
+ throw new Error("FATAL: Native binding 'normalizeAndDedupClasses' is required but not available.");
962
+ }
963
+ const result = native.normalizeAndDedupClasses(raw);
964
+ return result || { normalized: "", duplicatesRemoved: 0, uniqueCount: 0 };
965
+ };
966
+ extractComponentUsage = (source) => {
967
+ const native = getNativeBridge();
968
+ if (!native?.extractComponentUsage) {
969
+ throw new Error("FATAL: Native binding 'extractComponentUsage' is required but not available.");
970
+ }
971
+ return native.extractComponentUsage(source) || [];
972
+ };
973
+ batchExtractClasses = (filePaths) => {
974
+ const native = getNativeBridge();
975
+ if (!native?.batchExtractClasses) {
976
+ throw new Error("FATAL: Native binding 'batchExtractClasses' is required but not available.");
977
+ }
978
+ return native.batchExtractClasses(filePaths) || [];
979
+ };
980
+ checkAgainstSafelist = (classes, safelist) => {
981
+ const native = getNativeBridge();
982
+ if (!native?.checkAgainstSafelist) {
983
+ throw new Error("FATAL: Native binding 'checkAgainstSafelist' is required but not available.");
984
+ }
985
+ return native.checkAgainstSafelist(classes, safelist) || { matched: [], unmatched: [], safelistSize: 0 };
986
+ };
987
+ diffClassLists = (previous, current) => {
988
+ const native = getNativeBridge();
989
+ if (!native?.diffClassLists) {
990
+ throw new Error("FATAL: Native binding 'diffClassLists' is required but not available.");
991
+ }
992
+ return native.diffClassLists(previous, current) || { added: [], removed: [], unchanged: [], hasChanges: false };
993
+ };
994
+ }
995
+ });
996
+
997
+ // packages/domain/compiler/src/analyzer/analyzerNative.ts
998
+ function detectDeadCode(scanResultJson, css) {
999
+ const native = getNativeBridge();
1000
+ if (!native?.detectDeadCode) throw new Error("detectDeadCode not available");
1001
+ return native.detectDeadCode(scanResultJson, css);
1002
+ }
1003
+ function analyzeClassUsageNative(classes, scanResultJson, css) {
1004
+ const native = getNativeBridge();
1005
+ if (!native?.analyzeClassUsage) throw new Error("analyzeClassUsage not available");
1006
+ return native.analyzeClassUsage(classes, scanResultJson, css);
1007
+ }
1008
+ function analyzeClassesNative(filesJson, cwd, flags) {
1009
+ const native = getNativeBridge();
1010
+ if (!native?.analyzeClasses) throw new Error("analyzeClasses not available");
1011
+ return native.analyzeClasses(filesJson, cwd, flags ?? 0);
1012
+ }
1013
+ function analyzeRscNative(source, filename) {
1014
+ const native = getNativeBridge();
1015
+ if (!native?.analyzeRsc) throw new Error("analyzeRsc not available");
1016
+ return native.analyzeRsc(source, filename);
1017
+ }
1018
+ function optimizeCssNative(css) {
1019
+ const native = getNativeBridge();
1020
+ if (!native?.processTailwindCssLightning) throw new Error("processTailwindCssLightning not available");
1021
+ const result = native.processTailwindCssLightning(css);
706
1022
  return {
707
- add: (className) => className,
708
- get: (_bucket) => []
1023
+ css: result.css,
1024
+ originalSize: css.length,
1025
+ optimizedSize: result.size_bytes,
1026
+ reductionPercentage: (css.length - result.size_bytes) / css.length * 100
709
1027
  };
710
- };
711
- var resetBucketEngine = () => {
712
- };
713
- var BucketEngine = class {
714
- add(className) {
715
- return className;
1028
+ }
1029
+ function processTailwindCssLightning(css) {
1030
+ const native = getNativeBridge();
1031
+ if (!native?.processTailwindCssLightning) throw new Error("processTailwindCssLightning not available");
1032
+ return native.processTailwindCssLightning(css);
1033
+ }
1034
+ function eliminateDeadCssNative(css, deadClasses) {
1035
+ const native = getNativeBridge();
1036
+ if (!native?.eliminateDeadCss) throw new Error("eliminateDeadCss not available");
1037
+ return native.eliminateDeadCss(css, deadClasses);
1038
+ }
1039
+ function hoistComponentsNative(source) {
1040
+ const native = getNativeBridge();
1041
+ if (!native?.hoistComponents) throw new Error("hoistComponents not available");
1042
+ return native.hoistComponents(source);
1043
+ }
1044
+ function compileVariantTableNative(configJson) {
1045
+ const native = getNativeBridge();
1046
+ if (!native?.compileVariantTable) throw new Error("compileVariantTable not available");
1047
+ return native.compileVariantTable(configJson);
1048
+ }
1049
+ function classifyAndSortClassesNative(classes) {
1050
+ const native = getNativeBridge();
1051
+ if (!native?.classifyAndSortClasses) throw new Error("classifyAndSortClasses not available");
1052
+ return native.classifyAndSortClasses(classes);
1053
+ }
1054
+ function mergeCssDeclarationsNative(cssChunks) {
1055
+ const native = getNativeBridge();
1056
+ if (!native?.mergeCssDeclarations) throw new Error("mergeCssDeclarations not available");
1057
+ return native.mergeCssDeclarations(cssChunks);
1058
+ }
1059
+ var init_analyzerNative = __esm({
1060
+ "packages/domain/compiler/src/analyzer/analyzerNative.ts"() {
1061
+ init_nativeBridge();
716
1062
  }
717
- };
718
- var classifyNode = (_node) => {
1063
+ });
1064
+
1065
+ // packages/domain/compiler/src/analyzer/themeResolutionNative.ts
1066
+ function resolveVariants(configJson) {
719
1067
  const native = getNativeBridge();
720
- if (!native?.classifyAndSortClasses) {
721
- throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
1068
+ if (!native?.resolve_variants) throw new Error("resolve_variants not available");
1069
+ const resultJson = native.resolve_variants(configJson);
1070
+ try {
1071
+ return JSON.parse(resultJson);
1072
+ } catch {
1073
+ return {
1074
+ variants: [],
1075
+ supported: [],
1076
+ deprecated: [],
1077
+ conflicting: []
1078
+ };
722
1079
  }
723
- return "unknown";
724
- };
725
- var detectConflicts = (classes) => {
1080
+ }
1081
+ function validateThemeConfig(configJson) {
726
1082
  const native = getNativeBridge();
727
- if (!native?.analyzeClassUsage) {
728
- throw new Error("FATAL: Native binding 'analyzeClassUsage' is required but not available.");
1083
+ if (!native?.validate_variant_config) throw new Error("validate_variant_config not available");
1084
+ const resultJson = native.validate_variant_config(configJson);
1085
+ try {
1086
+ return JSON.parse(resultJson);
1087
+ } catch {
1088
+ return {
1089
+ is_valid: false,
1090
+ errors: ["Unable to parse configuration"],
1091
+ warnings: [],
1092
+ suggestions: []
1093
+ };
729
1094
  }
730
- return [];
731
- };
732
- var bucketSort = (classes) => {
733
- return classifyAndSortClasses(classes).map((c) => c.raw ?? c);
734
- };
1095
+ }
1096
+ function resolveCascade(baseThemeJson, overridesJson) {
1097
+ const native = getNativeBridge();
1098
+ if (!native?.resolve_cascade) throw new Error("resolve_cascade not available");
1099
+ const resultJson = native.resolve_cascade(baseThemeJson, overridesJson);
1100
+ try {
1101
+ return JSON.parse(resultJson);
1102
+ } catch {
1103
+ return {
1104
+ base_theme: {},
1105
+ user_overrides: {},
1106
+ merged_theme: {},
1107
+ conflict_resolutions: []
1108
+ };
1109
+ }
1110
+ }
1111
+ function resolveClassNames(classNames, themeJson) {
1112
+ const native = getNativeBridge();
1113
+ if (!native?.resolve_class_names) throw new Error("resolve_class_names not available");
1114
+ const resultJson = native.resolve_class_names(classNames, themeJson);
1115
+ try {
1116
+ return JSON.parse(resultJson);
1117
+ } catch {
1118
+ return [];
1119
+ }
1120
+ }
1121
+ function resolveConflictGroup(groupName, themeJson) {
1122
+ const native = getNativeBridge();
1123
+ if (!native?.resolve_conflict_group)
1124
+ throw new Error("resolve_conflict_group not available");
1125
+ const resultJson = native.resolve_conflict_group(groupName, themeJson);
1126
+ try {
1127
+ return JSON.parse(resultJson);
1128
+ } catch {
1129
+ return {
1130
+ group_name: groupName,
1131
+ conflicting_classes: [],
1132
+ description: "",
1133
+ resolution_strategy: "last-wins"
1134
+ };
1135
+ }
1136
+ }
1137
+ function resolveThemeValue(keyPath, themeJson) {
1138
+ const native = getNativeBridge();
1139
+ if (!native?.resolve_theme_value) throw new Error("resolve_theme_value not available");
1140
+ return native.resolve_theme_value(keyPath, themeJson);
1141
+ }
1142
+ function resolveSimpleVariants(configJson) {
1143
+ const native = getNativeBridge();
1144
+ if (!native?.resolve_simple_variants) throw new Error("resolve_simple_variants not available");
1145
+ const resultJson = native.resolve_simple_variants(configJson);
1146
+ try {
1147
+ return JSON.parse(resultJson);
1148
+ } catch {
1149
+ return [];
1150
+ }
1151
+ }
1152
+ var init_themeResolutionNative = __esm({
1153
+ "packages/domain/compiler/src/analyzer/themeResolutionNative.ts"() {
1154
+ init_nativeBridge();
1155
+ }
1156
+ });
1157
+
1158
+ // packages/domain/compiler/src/analyzer/scannerNative.ts
1159
+ function scanWorkspace(root, extensions) {
1160
+ const native = getNativeBridge();
1161
+ if (!native?.scan_workspace) throw new Error("scan_workspace not available");
1162
+ return native.scan_workspace(root, extensions);
1163
+ }
1164
+ function extractClassesFromSourceNative(source) {
1165
+ const native = getNativeBridge();
1166
+ if (!native?.extract_classes_from_source) throw new Error("extract_classes_from_source not available");
1167
+ return native.extract_classes_from_source(source);
1168
+ }
1169
+ function batchExtractClassesNative(filePaths) {
1170
+ const native = getNativeBridge();
1171
+ if (!native?.batch_extract_classes) throw new Error("batch_extract_classes not available");
1172
+ return native.batch_extract_classes(filePaths);
1173
+ }
1174
+ function checkAgainstSafelistNative(classes, safelist) {
1175
+ const native = getNativeBridge();
1176
+ if (!native?.check_against_safelist) throw new Error("check_against_safelist not available");
1177
+ return native.check_against_safelist(classes, safelist);
1178
+ }
1179
+ function scanFile(filePath) {
1180
+ const native = getNativeBridge();
1181
+ if (!native?.scan_file) throw new Error("scan_file not available");
1182
+ return native.scan_file(filePath);
1183
+ }
1184
+ function collectFiles(root, extensions) {
1185
+ const native = getNativeBridge();
1186
+ if (!native?.collect_files) throw new Error("collect_files not available");
1187
+ return native.collect_files(root, extensions);
1188
+ }
1189
+ function walkAndPrefilterSourceFiles(root, extensions, _parallel) {
1190
+ const native = getNativeBridge();
1191
+ if (!native?.walk_and_prefilter_source_files) throw new Error("walk_and_prefilter_source_files not available");
1192
+ return native.walk_and_prefilter_source_files(root, extensions);
1193
+ }
1194
+ function generateSubComponentTypes(root, outputPath) {
1195
+ const native = getNativeBridge();
1196
+ if (!native?.generate_sub_component_types) throw new Error("generate_sub_component_types not available");
1197
+ return native.generate_sub_component_types(root, outputPath);
1198
+ }
1199
+ var init_scannerNative = __esm({
1200
+ "packages/domain/compiler/src/analyzer/scannerNative.ts"() {
1201
+ init_nativeBridge();
1202
+ }
1203
+ });
1204
+
1205
+ // packages/domain/compiler/src/analyzer/index.ts
1206
+ var init_analyzer = __esm({
1207
+ "packages/domain/compiler/src/analyzer/index.ts"() {
1208
+ init_analyzerNative();
1209
+ init_themeResolutionNative();
1210
+ init_scannerNative();
1211
+ }
1212
+ });
1213
+
1214
+ // packages/domain/compiler/src/cache/cacheNative.ts
1215
+ function getCacheStatistics() {
1216
+ const native = getNativeBridge();
1217
+ if (!native?.get_cache_statistics) throw new Error("get_cache_statistics not available");
1218
+ const statsJson = native.get_cache_statistics();
1219
+ try {
1220
+ return JSON.parse(statsJson);
1221
+ } catch {
1222
+ return {
1223
+ parse_cache: { hits: 0, misses: 0, size: 0 },
1224
+ resolve_cache: { hits: 0, misses: 0, size: 0 },
1225
+ compile_cache: { hits: 0, misses: 0, size: 0 },
1226
+ css_gen_cache: { hits: 0, misses: 0, size: 0 },
1227
+ overall_hit_rate: 0,
1228
+ total_memory_bytes: 0
1229
+ };
1230
+ }
1231
+ }
1232
+ function clearAllCaches() {
1233
+ const native = getNativeBridge();
1234
+ if (!native?.clear_all_caches) return;
1235
+ try {
1236
+ native.clear_all_caches();
1237
+ } catch {
1238
+ }
1239
+ }
1240
+ function clearParseCache() {
1241
+ const native = getNativeBridge();
1242
+ if (!native?.clear_parse_cache) return;
1243
+ try {
1244
+ native.clear_parse_cache();
1245
+ } catch {
1246
+ }
1247
+ }
1248
+ function clearResolveCache() {
1249
+ const native = getNativeBridge();
1250
+ if (!native?.clear_resolve_cache) return;
1251
+ try {
1252
+ native.clear_resolve_cache();
1253
+ } catch {
1254
+ }
1255
+ }
1256
+ function clearCompileCache() {
1257
+ const native = getNativeBridge();
1258
+ if (!native?.clear_compile_cache) return;
1259
+ try {
1260
+ native.clear_compile_cache();
1261
+ } catch {
1262
+ }
1263
+ }
1264
+ function clearCssGenCache() {
1265
+ const native = getNativeBridge();
1266
+ if (!native?.clear_css_gen_cache) return;
1267
+ try {
1268
+ native.clear_css_gen_cache();
1269
+ } catch {
1270
+ }
1271
+ }
1272
+ function getCacheOptimizationHints(hitRatePercent, memoryUsedMb) {
1273
+ const native = getNativeBridge();
1274
+ if (!native?.get_cache_optimization_hints)
1275
+ throw new Error("get_cache_optimization_hints not available");
1276
+ const hintsJson = native.get_cache_optimization_hints(
1277
+ Math.min(100, Math.max(0, hitRatePercent)),
1278
+ Math.max(1, memoryUsedMb)
1279
+ );
1280
+ try {
1281
+ return JSON.parse(hintsJson);
1282
+ } catch {
1283
+ return {
1284
+ current_strategy: "unknown",
1285
+ recommended_strategy: "increase_size",
1286
+ estimated_improvement_percent: 0,
1287
+ suggested_memory_mb: 256,
1288
+ notes: ["Unable to analyze cache statistics"]
1289
+ };
1290
+ }
1291
+ }
1292
+ function estimateOptimalCacheConfig(totalBudgetMb, workloadType) {
1293
+ const native = getNativeBridge();
1294
+ if (!native?.estimate_optimal_cache_config_native)
1295
+ throw new Error("estimate_optimal_cache_config_native not available");
1296
+ const configJson = native.estimate_optimal_cache_config_native(
1297
+ Math.max(64, totalBudgetMb),
1298
+ workloadType
1299
+ );
1300
+ try {
1301
+ return JSON.parse(configJson);
1302
+ } catch {
1303
+ return {
1304
+ parse_cache_size: 128,
1305
+ resolve_cache_size: 64,
1306
+ compile_cache_size: 256,
1307
+ css_gen_cache_size: 128,
1308
+ recommended_eviction_policy: "lru",
1309
+ ttl_seconds: 3600,
1310
+ expected_hit_rate_percent: 75
1311
+ };
1312
+ }
1313
+ }
1314
+ function cacheRead(cachePath) {
1315
+ const native = getNativeBridge();
1316
+ if (!native?.cache_read) throw new Error("cache_read not available");
1317
+ const result = native.cache_read(cachePath);
1318
+ try {
1319
+ return JSON.parse(result.entries_json || "[]");
1320
+ } catch {
1321
+ return [];
1322
+ }
1323
+ }
1324
+ function cacheWrite(cachePath, entries) {
1325
+ const native = getNativeBridge();
1326
+ if (!native?.cache_write) throw new Error("cache_write not available");
1327
+ try {
1328
+ const result = native.cache_write(
1329
+ cachePath,
1330
+ entries.map((e) => ({
1331
+ file: e.file,
1332
+ content_hash: e.contentHash,
1333
+ classes: e.classes,
1334
+ mtime_ms: e.mtimeMs,
1335
+ size_bytes: e.sizeBytes
1336
+ }))
1337
+ );
1338
+ return typeof result === "boolean" ? result : result === true;
1339
+ } catch {
1340
+ return false;
1341
+ }
1342
+ }
1343
+ function cachePriority(mtimeMs, sizeBytes, hitCount) {
1344
+ const native = getNativeBridge();
1345
+ if (!native?.cache_priority) throw new Error("cache_priority not available");
1346
+ return native.cache_priority(mtimeMs, sizeBytes, hitCount);
1347
+ }
1348
+ var init_cacheNative = __esm({
1349
+ "packages/domain/compiler/src/cache/cacheNative.ts"() {
1350
+ init_nativeBridge();
1351
+ }
1352
+ });
1353
+
1354
+ // packages/domain/compiler/src/cache/index.ts
1355
+ var init_cache = __esm({
1356
+ "packages/domain/compiler/src/cache/index.ts"() {
1357
+ init_cacheNative();
1358
+ }
1359
+ });
1360
+
1361
+ // packages/domain/compiler/src/redis/redisNative.ts
1362
+ function redisPing() {
1363
+ const native = getNativeBridge();
1364
+ if (!native?.redis_ping) throw new Error("redis_ping not available");
1365
+ return native.redis_ping();
1366
+ }
1367
+ function redisGet(key) {
1368
+ const native = getNativeBridge();
1369
+ if (!native?.redis_get) throw new Error("redis_get not available");
1370
+ const result = native.redis_get(key);
1371
+ return result === "nil" ? null : result;
1372
+ }
1373
+ function redisSet(key, value, ttl_seconds) {
1374
+ const native = getNativeBridge();
1375
+ if (!native?.redis_set) throw new Error("redis_set not available");
1376
+ return native.redis_set(key, value, ttl_seconds);
1377
+ }
1378
+ function redisDelete(key) {
1379
+ const native = getNativeBridge();
1380
+ if (!native?.redis_delete) throw new Error("redis_delete not available");
1381
+ return native.redis_delete(key);
1382
+ }
1383
+ function redisExists(key) {
1384
+ const native = getNativeBridge();
1385
+ if (!native?.redis_exists) throw new Error("redis_exists not available");
1386
+ return native.redis_exists(key);
1387
+ }
1388
+ function redisMget(keys) {
1389
+ const native = getNativeBridge();
1390
+ if (!native?.redis_mget) throw new Error("redis_mget not available");
1391
+ const result = native.redis_mget(keys);
1392
+ try {
1393
+ return JSON.parse(result);
1394
+ } catch {
1395
+ return keys.map(() => null);
1396
+ }
1397
+ }
1398
+ function redisMset(pairs) {
1399
+ const native = getNativeBridge();
1400
+ if (!native?.redis_mset) throw new Error("redis_mset not available");
1401
+ return native.redis_mset(pairs);
1402
+ }
1403
+ function redisFlushDb() {
1404
+ const native = getNativeBridge();
1405
+ if (!native?.redis_flush_db) throw new Error("redis_flush_db not available");
1406
+ return native.redis_flush_db();
1407
+ }
1408
+ function redisFlushAll() {
1409
+ const native = getNativeBridge();
1410
+ if (!native?.redis_flush_all) throw new Error("redis_flush_all not available");
1411
+ return native.redis_flush_all();
1412
+ }
1413
+ function redisPoolConnect(host, port, pool_size) {
1414
+ const native = getNativeBridge();
1415
+ if (!native?.redis_pool_connect) throw new Error("redis_pool_connect not available");
1416
+ return native.redis_pool_connect(host, port, pool_size);
1417
+ }
1418
+ function redisPoolStats() {
1419
+ const native = getNativeBridge();
1420
+ if (!native?.redis_pool_stats) throw new Error("redis_pool_stats not available");
1421
+ const result = native.redis_pool_stats();
1422
+ try {
1423
+ return JSON.parse(result);
1424
+ } catch {
1425
+ return {
1426
+ connected_count: 0,
1427
+ idle_count: 0,
1428
+ waiting_count: 0,
1429
+ total_requests: 0,
1430
+ total_errors: 0
1431
+ };
1432
+ }
1433
+ }
1434
+ function redisPoolReconnect() {
1435
+ const native = getNativeBridge();
1436
+ if (!native?.redis_pool_reconnect) throw new Error("redis_pool_reconnect not available");
1437
+ return native.redis_pool_reconnect();
1438
+ }
1439
+ function redisEnableCluster(initial_nodes) {
1440
+ const native = getNativeBridge();
1441
+ if (!native?.redis_enable_cluster) throw new Error("redis_enable_cluster not available");
1442
+ const result = native.redis_enable_cluster(initial_nodes);
1443
+ try {
1444
+ return JSON.parse(result);
1445
+ } catch {
1446
+ return {
1447
+ enabled: false,
1448
+ cluster_state: "error",
1449
+ nodes: [],
1450
+ slots_assigned: 0,
1451
+ slots_ok: 0,
1452
+ slots_fail: 0
1453
+ };
1454
+ }
1455
+ }
1456
+ function redisDisableCluster() {
1457
+ const native = getNativeBridge();
1458
+ if (!native?.redis_disable_cluster) throw new Error("redis_disable_cluster not available");
1459
+ return native.redis_disable_cluster();
1460
+ }
1461
+ function redisClusterStatus() {
1462
+ const native = getNativeBridge();
1463
+ if (!native?.redis_cluster_status) throw new Error("redis_cluster_status not available");
1464
+ const result = native.redis_cluster_status();
1465
+ try {
1466
+ return JSON.parse(result);
1467
+ } catch {
1468
+ return {
1469
+ enabled: false,
1470
+ cluster_state: "unknown",
1471
+ nodes: [],
1472
+ slots_assigned: 0,
1473
+ slots_ok: 0,
1474
+ slots_fail: 0
1475
+ };
1476
+ }
1477
+ }
1478
+ function redisSubscribe(channel) {
1479
+ const native = getNativeBridge();
1480
+ if (!native?.redis_subscribe) throw new Error("redis_subscribe not available");
1481
+ return native.redis_subscribe(channel);
1482
+ }
1483
+ function redisPublish(channel, message) {
1484
+ const native = getNativeBridge();
1485
+ if (!native?.redis_publish) throw new Error("redis_publish not available");
1486
+ return native.redis_publish(channel, message);
1487
+ }
1488
+ function redisExpirationSet(key, ttl_seconds) {
1489
+ const native = getNativeBridge();
1490
+ if (!native?.redis_expiration_set) throw new Error("redis_expiration_set not available");
1491
+ return native.redis_expiration_set(key, ttl_seconds);
1492
+ }
1493
+ function redisExpirationGet(key) {
1494
+ const native = getNativeBridge();
1495
+ if (!native?.redis_expiration_get) throw new Error("redis_expiration_get not available");
1496
+ const result = native.redis_expiration_get(key);
1497
+ try {
1498
+ return JSON.parse(result);
1499
+ } catch {
1500
+ return {
1501
+ key,
1502
+ ttl_seconds: -1,
1503
+ expiration_timestamp: 0,
1504
+ is_persistent: true
1505
+ };
1506
+ }
1507
+ }
1508
+ function redisInfo() {
1509
+ const native = getNativeBridge();
1510
+ if (!native?.redis_info) throw new Error("redis_info not available");
1511
+ return native.redis_info();
1512
+ }
1513
+ function redisMonitor() {
1514
+ const native = getNativeBridge();
1515
+ if (!native?.redis_monitor) throw new Error("redis_monitor not available");
1516
+ return native.redis_monitor();
1517
+ }
1518
+ function redisCacheSize() {
1519
+ const native = getNativeBridge();
1520
+ if (!native?.redis_cache_size) throw new Error("redis_cache_size not available");
1521
+ return native.redis_cache_size();
1522
+ }
1523
+ function redisCacheKeyCount() {
1524
+ const native = getNativeBridge();
1525
+ if (!native?.redis_cache_key_count) throw new Error("redis_cache_key_count not available");
1526
+ return native.redis_cache_key_count();
1527
+ }
1528
+ function redisCacheClear() {
1529
+ const native = getNativeBridge();
1530
+ if (!native?.redis_cache_clear) throw new Error("redis_cache_clear not available");
1531
+ return native.redis_cache_clear();
1532
+ }
1533
+ function redisCacheHitRate() {
1534
+ const native = getNativeBridge();
1535
+ if (!native?.redis_cache_hit_rate) throw new Error("redis_cache_hit_rate not available");
1536
+ return native.redis_cache_hit_rate();
1537
+ }
1538
+ function redisEnablePersistence(mode) {
1539
+ const native = getNativeBridge();
1540
+ if (!native?.redis_enable_persistence) throw new Error("redis_enable_persistence not available");
1541
+ return native.redis_enable_persistence(mode);
1542
+ }
1543
+ function redisDisablePersistence() {
1544
+ const native = getNativeBridge();
1545
+ if (!native?.redis_disable_persistence) throw new Error("redis_disable_persistence not available");
1546
+ return native.redis_disable_persistence();
1547
+ }
1548
+ function redisSnapshot() {
1549
+ const native = getNativeBridge();
1550
+ if (!native?.redis_snapshot) throw new Error("redis_snapshot not available");
1551
+ return native.redis_snapshot();
1552
+ }
1553
+ function redisMemoryStats() {
1554
+ const native = getNativeBridge();
1555
+ if (!native?.redis_memory_stats) throw new Error("redis_memory_stats not available");
1556
+ return native.redis_memory_stats();
1557
+ }
1558
+ function redisOptimizeMemory() {
1559
+ const native = getNativeBridge();
1560
+ if (!native?.redis_optimize_memory) throw new Error("redis_optimize_memory not available");
1561
+ return native.redis_optimize_memory();
1562
+ }
1563
+ function redisSetEvictionPolicy(policy) {
1564
+ const native = getNativeBridge();
1565
+ if (!native?.redis_set_eviction_policy) throw new Error("redis_set_eviction_policy not available");
1566
+ return native.redis_set_eviction_policy(policy);
1567
+ }
1568
+ function redisGetEvictionPolicy() {
1569
+ const native = getNativeBridge();
1570
+ if (!native?.redis_get_eviction_policy) throw new Error("redis_get_eviction_policy not available");
1571
+ return native.redis_get_eviction_policy();
1572
+ }
1573
+ function redisReplicate(target_host, target_port) {
1574
+ const native = getNativeBridge();
1575
+ if (!native?.redis_replicate) throw new Error("redis_replicate not available");
1576
+ return native.redis_replicate(target_host, target_port);
1577
+ }
1578
+ function redisReplicationStatus() {
1579
+ const native = getNativeBridge();
1580
+ if (!native?.redis_replication_status) throw new Error("redis_replication_status not available");
1581
+ return native.redis_replication_status();
1582
+ }
1583
+ function redisCacheSync(peers) {
1584
+ const native = getNativeBridge();
1585
+ if (!native?.redis_cache_sync) throw new Error("redis_cache_sync not available");
1586
+ return native.redis_cache_sync(peers);
1587
+ }
1588
+ function redisEnableCacheWarming(key_pattern) {
1589
+ const native = getNativeBridge();
1590
+ if (!native?.redis_enable_cache_warming) throw new Error("redis_enable_cache_warming not available");
1591
+ return native.redis_enable_cache_warming(key_pattern);
1592
+ }
1593
+ function redisDisableCacheWarming() {
1594
+ const native = getNativeBridge();
1595
+ if (!native?.redis_disable_cache_warming) throw new Error("redis_disable_cache_warming not available");
1596
+ return native.redis_disable_cache_warming();
1597
+ }
1598
+ function redisDiagnose() {
1599
+ const native = getNativeBridge();
1600
+ if (!native?.redis_diagnose) throw new Error("redis_diagnose not available");
1601
+ return native.redis_diagnose();
1602
+ }
1603
+ var init_redisNative = __esm({
1604
+ "packages/domain/compiler/src/redis/redisNative.ts"() {
1605
+ init_nativeBridge();
1606
+ }
1607
+ });
1608
+
1609
+ // packages/domain/compiler/src/redis/index.ts
1610
+ var init_redis = __esm({
1611
+ "packages/domain/compiler/src/redis/index.ts"() {
1612
+ init_redisNative();
1613
+ }
1614
+ });
1615
+
1616
+ // packages/domain/compiler/src/watch/watchSystemNative.ts
1617
+ function startWatch(root_path, patterns) {
1618
+ const native = getNativeBridge();
1619
+ if (!native?.start_watch) throw new Error("start_watch not available");
1620
+ return native.start_watch(root_path, patterns);
1621
+ }
1622
+ function pollWatchEvents(handle, timeout_ms) {
1623
+ const native = getNativeBridge();
1624
+ if (!native?.poll_watch_events) throw new Error("poll_watch_events not available");
1625
+ const result = native.poll_watch_events(handle, timeout_ms);
1626
+ try {
1627
+ return JSON.parse(result);
1628
+ } catch {
1629
+ return [];
1630
+ }
1631
+ }
1632
+ function stopWatch(handle) {
1633
+ const native = getNativeBridge();
1634
+ if (!native?.stop_watch) throw new Error("stop_watch not available");
1635
+ return native.stop_watch(handle);
1636
+ }
1637
+ function watchAddPattern(handle, pattern) {
1638
+ const native = getNativeBridge();
1639
+ if (!native?.watch_add_pattern) throw new Error("watch_add_pattern not available");
1640
+ return native.watch_add_pattern(handle, pattern);
1641
+ }
1642
+ function watchRemovePattern(handle, pattern) {
1643
+ const native = getNativeBridge();
1644
+ if (!native?.watch_remove_pattern) throw new Error("watch_remove_pattern not available");
1645
+ return native.watch_remove_pattern(handle, pattern);
1646
+ }
1647
+ function watchGetActiveHandles() {
1648
+ const native = getNativeBridge();
1649
+ if (!native?.watch_get_active_handles) throw new Error("watch_get_active_handles not available");
1650
+ const result = native.watch_get_active_handles();
1651
+ try {
1652
+ return JSON.parse(result);
1653
+ } catch {
1654
+ return [];
1655
+ }
1656
+ }
1657
+ function watchClearAll() {
1658
+ const native = getNativeBridge();
1659
+ if (!native?.watch_clear_all) throw new Error("watch_clear_all not available");
1660
+ return native.watch_clear_all();
1661
+ }
1662
+ function watchEventTypeToString(event_type_code) {
1663
+ const native = getNativeBridge();
1664
+ if (!native?.watch_event_type_to_string) throw new Error("watch_event_type_to_string not available");
1665
+ return native.watch_event_type_to_string(event_type_code);
1666
+ }
1667
+ function isWatchRunning(handle) {
1668
+ const native = getNativeBridge();
1669
+ if (!native?.is_watch_running) throw new Error("is_watch_running not available");
1670
+ return native.is_watch_running(handle);
1671
+ }
1672
+ function getWatchStats() {
1673
+ const native = getNativeBridge();
1674
+ if (!native?.get_watch_stats) throw new Error("get_watch_stats not available");
1675
+ const result = native.get_watch_stats();
1676
+ try {
1677
+ return JSON.parse(result);
1678
+ } catch {
1679
+ return {
1680
+ active_watchers: 0,
1681
+ total_events: 0,
1682
+ events_this_second: 0,
1683
+ average_latency_ms: 0,
1684
+ largest_batch_size: 0
1685
+ };
1686
+ }
1687
+ }
1688
+ function watchPause(handle) {
1689
+ const native = getNativeBridge();
1690
+ if (!native?.watch_pause) throw new Error("watch_pause not available");
1691
+ return native.watch_pause(handle);
1692
+ }
1693
+ function watchResume(handle) {
1694
+ const native = getNativeBridge();
1695
+ if (!native?.watch_resume) throw new Error("watch_resume not available");
1696
+ return native.watch_resume(handle);
1697
+ }
1698
+ function scanCacheOptimizations() {
1699
+ const native = getNativeBridge();
1700
+ if (!native?.scan_cache_optimizations) throw new Error("scan_cache_optimizations not available");
1701
+ return native.scan_cache_optimizations();
1702
+ }
1703
+ function getPluginHooks() {
1704
+ const native = getNativeBridge();
1705
+ if (!native?.get_plugin_hooks) throw new Error("get_plugin_hooks not available");
1706
+ const result = native.get_plugin_hooks();
1707
+ try {
1708
+ return JSON.parse(result);
1709
+ } catch {
1710
+ return [];
1711
+ }
1712
+ }
1713
+ function registerPluginHook(hook_name, handler_id) {
1714
+ const native = getNativeBridge();
1715
+ if (!native?.register_plugin_hook) throw new Error("register_plugin_hook not available");
1716
+ return native.register_plugin_hook(hook_name, handler_id);
1717
+ }
1718
+ function unregisterPluginHook(hook_name, handler_id) {
1719
+ const native = getNativeBridge();
1720
+ if (!native?.unregister_plugin_hook) throw new Error("unregister_plugin_hook not available");
1721
+ return native.unregister_plugin_hook(hook_name, handler_id);
1722
+ }
1723
+ function emitPluginHook(hook_name, data_json) {
1724
+ const native = getNativeBridge();
1725
+ if (!native?.emit_plugin_hook) throw new Error("emit_plugin_hook not available");
1726
+ return native.emit_plugin_hook(hook_name, data_json);
1727
+ }
1728
+ function getCompilationMetrics() {
1729
+ const native = getNativeBridge();
1730
+ if (!native?.get_compilation_metrics) throw new Error("get_compilation_metrics not available");
1731
+ return native.get_compilation_metrics();
1732
+ }
1733
+ function resetCompilationMetrics() {
1734
+ const native = getNativeBridge();
1735
+ if (!native?.reset_compilation_metrics) throw new Error("reset_compilation_metrics not available");
1736
+ return native.reset_compilation_metrics();
1737
+ }
1738
+ function validateCssOutput(css) {
1739
+ const native = getNativeBridge();
1740
+ if (!native?.validate_css_output) throw new Error("validate_css_output not available");
1741
+ return native.validate_css_output(css);
1742
+ }
1743
+ function getCompilerDiagnostics() {
1744
+ const native = getNativeBridge();
1745
+ if (!native?.get_compiler_diagnostics) throw new Error("get_compiler_diagnostics not available");
1746
+ return native.get_compiler_diagnostics();
1747
+ }
1748
+ var init_watchSystemNative = __esm({
1749
+ "packages/domain/compiler/src/watch/watchSystemNative.ts"() {
1750
+ init_nativeBridge();
1751
+ }
1752
+ });
1753
+
1754
+ // packages/domain/compiler/src/watch/index.ts
1755
+ var init_watch = __esm({
1756
+ "packages/domain/compiler/src/watch/index.ts"() {
1757
+ init_watchSystemNative();
1758
+ }
1759
+ });
1760
+ function _layoutClassesToCss(classes) {
1761
+ const native = getNativeBridge();
1762
+ if (!native?.layoutClassesToCss) {
1763
+ throw new Error("FATAL: Native binding 'layoutClassesToCss' is required but not available.");
1764
+ }
1765
+ return native.layoutClassesToCss(classes);
1766
+ }
1767
+ function _hashContainer(tag, containerJson, name) {
1768
+ const sortedKey = tag + (name ?? "") + containerJson;
1769
+ const native = getNativeBridge();
1770
+ if (!native?.hashContent) {
1771
+ throw new Error("FATAL: Native binding 'hashContent' is required but not available.");
1772
+ }
1773
+ return `tw-cq-${native.hashContent(sortedKey, "fnv", 6)}`;
1774
+ }
1775
+ function extractContainerCssFromSource(source) {
1776
+ const native = getNativeBridge();
1777
+ if (!native?.extractTwContainerConfigs) {
1778
+ throw new Error("FATAL: Native binding 'extractTwContainerConfigs' is required but not available.");
1779
+ }
1780
+ const configs = native.extractTwContainerConfigs(source);
1781
+ const rules = [];
1782
+ for (const cfg of configs) {
1783
+ const id = _hashContainer(cfg.tag, cfg.containerJson, cfg.containerName);
1784
+ for (const { key, classes } of cfg.breakpoints) {
1785
+ const minWidth = _CONTAINER_BREAKPOINTS[key] ?? key;
1786
+ const css = _layoutClassesToCss(classes);
1787
+ if (!css) continue;
1788
+ const query = cfg.containerName ? `@container ${cfg.containerName} (min-width: ${minWidth})` : `@container (min-width: ${minWidth})`;
1789
+ rules.push(`${query}{.${id}{${css}}}`);
1790
+ }
1791
+ }
1792
+ return rules.join("\n");
1793
+ }
1794
+ var transformSource, hasTwUsage, isAlreadyTransformed, shouldProcess, compileCssFromClasses, buildStyleTag, generateCssForClasses, eliminateDeadCss, findDeadVariants, runElimination, scanProjectUsage, generateSafelist, loadSafelist, loadTailwindConfig, getContentPaths, _CONTAINER_BREAKPOINTS, runLoaderTransform, shouldSkipFile, fileToRoute, getAllRoutes, getRouteClasses, registerFileClasses, registerGlobalClasses, _incrementalEngineInstance, getIncrementalEngine, resetIncrementalEngine, IncrementalEngine, getBucketEngine, resetBucketEngine, BucketEngine, classifyNode, detectConflicts, bucketSort, analyzeFile, analyzeVariantUsage, injectClientDirective, injectServerOnlyComment, analyzeClasses, extractTwStateConfigs, generateStaticStateCss, extractAndGenerateStateCss;
1795
+ var init_src2 = __esm({
1796
+ "packages/domain/compiler/src/index.ts"() {
1797
+ init_nativeBridge();
1798
+ init_compiler();
1799
+ init_parser();
1800
+ init_analyzer();
1801
+ init_cache();
1802
+ init_redis();
1803
+ init_watch();
1804
+ transformSource = (source, opts) => {
1805
+ const native = getNativeBridge();
1806
+ if (!native?.transformSource) {
1807
+ throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
1808
+ }
1809
+ const result = native.transformSource(source, opts);
1810
+ if (!result) {
1811
+ throw new Error("FATAL: transformSource returned null");
1812
+ }
1813
+ return result;
1814
+ };
1815
+ hasTwUsage = (source) => {
1816
+ const native = getNativeBridge();
1817
+ if (!native?.hasTwUsage) {
1818
+ throw new Error("FATAL: Native binding 'hasTwUsage' is required but not available.");
1819
+ }
1820
+ return native.hasTwUsage(source);
1821
+ };
1822
+ isAlreadyTransformed = (source) => {
1823
+ const native = getNativeBridge();
1824
+ if (!native?.isAlreadyTransformed) {
1825
+ throw new Error("FATAL: Native binding 'isAlreadyTransformed' is required but not available.");
1826
+ }
1827
+ return native.isAlreadyTransformed(source);
1828
+ };
1829
+ shouldProcess = (source) => {
1830
+ return hasTwUsage(source) && !isAlreadyTransformed(source);
1831
+ };
1832
+ compileCssFromClasses = (classes, prefix) => {
1833
+ const native = getNativeBridge();
1834
+ if (!native?.transformSource) {
1835
+ throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
1836
+ }
1837
+ const result = native.transformSource(classes.join(" "), { prefix: prefix ?? "" });
1838
+ if (!result) {
1839
+ throw new Error("FATAL: transformSource returned null");
1840
+ }
1841
+ return result;
1842
+ };
1843
+ buildStyleTag = (classes) => {
1844
+ const result = compileCssFromClasses(classes);
1845
+ return result?.code ? `<style data-tailwind-styled>${result.code}</style>` : "";
1846
+ };
1847
+ generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
1848
+ try {
1849
+ const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
1850
+ const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
1851
+ return result.css;
1852
+ } catch {
1853
+ const native = getNativeBridge();
1854
+ if (!native?.transformSource) {
1855
+ throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
1856
+ }
1857
+ const result = native.transformSource(classes.join(" "), {});
1858
+ return result?.code || "";
1859
+ }
1860
+ };
1861
+ eliminateDeadCss = (css, deadClasses) => {
1862
+ const native = getNativeBridge();
1863
+ if (!native?.eliminateDeadCss) {
1864
+ throw new Error("FATAL: Native binding 'eliminateDeadCss' is required but not available.");
1865
+ }
1866
+ return native.eliminateDeadCss(css, Array.from(deadClasses));
1867
+ };
1868
+ findDeadVariants = (variantConfig, usage) => {
1869
+ const unused = [];
1870
+ const configs = Array.isArray(variantConfig) ? variantConfig : [{ name: "__root__", variants: variantConfig }];
1871
+ for (const component of configs) {
1872
+ const componentUsage = usage[component.name] ?? /* @__PURE__ */ new Set();
1873
+ const variants = component.variants;
1874
+ for (const [key, values] of Object.entries(variants)) {
1875
+ for (const [value] of Object.entries(values)) {
1876
+ if (!componentUsage.has(`${key}:${value}`)) {
1877
+ unused.push(`${component.name !== "__root__" ? `${component.name}/` : ""}${key}:${value}`);
1878
+ }
1879
+ }
1880
+ }
1881
+ }
1882
+ return { unusedCount: unused.length, unused };
1883
+ };
1884
+ runElimination = (css, scanResult) => {
1885
+ const native = getNativeBridge();
1886
+ if (!native?.detectDeadCode) {
1887
+ throw new Error("FATAL: Native binding 'detectDeadCode' is required but not available.");
1888
+ }
1889
+ const dead = native.detectDeadCode(JSON.stringify(scanResult), css);
1890
+ return eliminateDeadCss(css, new Set(dead.deadInCss ?? []));
1891
+ };
1892
+ scanProjectUsage = (dirs, cwd) => {
1893
+ const { batchExtractClasses: batchExtractClasses2 } = (init_parser(), __toCommonJS(parser_exports));
1894
+ const files = dirs.map((dir) => path__default.resolve(cwd, dir));
1895
+ const results = batchExtractClasses2(files) || [];
1896
+ const combined = {};
1897
+ for (const result of results) {
1898
+ if (result.ok && result.classes) {
1899
+ for (const cls of result.classes) {
1900
+ if (!combined[cls]) combined[cls] = {};
1901
+ combined[cls][result.file] = /* @__PURE__ */ new Set([cls]);
1902
+ }
1903
+ }
1904
+ }
1905
+ return combined;
1906
+ };
1907
+ generateSafelist = (scanDirs, outputPath, cwd) => {
1908
+ const classes = scanProjectUsage(scanDirs, cwd || process.cwd());
1909
+ const allClasses = Object.keys(classes).sort();
1910
+ if (outputPath) {
1911
+ fs__default.writeFileSync(outputPath, JSON.stringify(allClasses, null, 2));
1912
+ }
1913
+ return allClasses;
1914
+ };
1915
+ loadSafelist = (safelistPath) => {
1916
+ try {
1917
+ const content = fs__default.readFileSync(safelistPath, "utf-8");
1918
+ return JSON.parse(content);
1919
+ } catch {
1920
+ return [];
1921
+ }
1922
+ };
1923
+ loadTailwindConfig = (cwd = process.cwd()) => {
1924
+ const configFiles = [
1925
+ "tailwind.config.ts",
1926
+ "tailwind.config.js",
1927
+ "tailwind.config.mjs",
1928
+ "tailwind.config.cjs"
1929
+ ];
1930
+ for (const file of configFiles) {
1931
+ const fullPath = path__default.join(cwd, file);
1932
+ if (fs__default.existsSync(fullPath)) {
1933
+ const mod = __require(fullPath);
1934
+ return mod.default || mod;
1935
+ }
1936
+ }
1937
+ return {};
1938
+ };
1939
+ getContentPaths = (cwd = process.cwd()) => {
1940
+ return {
1941
+ content: [
1942
+ path__default.join(cwd, "src/**/*.{js,ts,jsx,tsx}"),
1943
+ path__default.join(cwd, "app/**/*.{js,ts,jsx,tsx}"),
1944
+ path__default.join(cwd, "pages/**/*.{js,ts,jsx,tsx}")
1945
+ ]
1946
+ };
1947
+ };
1948
+ _CONTAINER_BREAKPOINTS = {
1949
+ xs: "240px",
1950
+ sm: "320px",
1951
+ md: "640px",
1952
+ lg: "1024px",
1953
+ xl: "1280px",
1954
+ "2xl": "1536px"
1955
+ };
1956
+ runLoaderTransform = (ctx) => {
1957
+ const { filepath, source, options } = ctx;
1958
+ const result = transformSource(source, { filename: filepath, ...options });
1959
+ let staticCss;
1960
+ try {
1961
+ const cssChunks = [];
1962
+ const stateRules = extractAndGenerateStateCss(source, filepath);
1963
+ if (stateRules.length > 0) {
1964
+ cssChunks.push(stateRules.map((r) => r.cssRule).join("\n"));
1965
+ }
1966
+ const containerCss = extractContainerCssFromSource(source);
1967
+ if (containerCss) cssChunks.push(containerCss);
1968
+ const combined = cssChunks.join("\n").trim();
1969
+ if (combined) staticCss = combined;
1970
+ } catch (err) {
1971
+ console.debug("Static CSS extraction warning:", err);
1972
+ }
1973
+ return {
1974
+ code: result?.code || "",
1975
+ changed: result?.changed || false,
1976
+ classes: result?.classes || [],
1977
+ staticCss
1978
+ };
1979
+ };
1980
+ shouldSkipFile = (filepath) => {
1981
+ const SKIP_PATHS = ["node_modules", ".next", ".rspack-dist", ".turbo", "dist/", "out/"];
1982
+ const skipExtensions = [".css", ".json", ".md", ".txt", ".yaml", ".yml"];
1983
+ for (const p of SKIP_PATHS) {
1984
+ if (filepath.includes(p)) return true;
1985
+ }
1986
+ for (const ext of skipExtensions) {
1987
+ if (filepath.endsWith(ext)) return true;
1988
+ }
1989
+ return false;
1990
+ };
1991
+ fileToRoute = (filepath) => {
1992
+ const normalized = filepath.replace(/\\/g, "/");
1993
+ if (normalized.includes("/layout.") || normalized.includes("/loading.") || normalized.includes("/error.")) {
1994
+ return "__global";
1995
+ }
1996
+ const pageMatch = normalized.match(/\/app\/(.+?)\/page\.[tj]sx?$/);
1997
+ if (pageMatch) return `/${pageMatch[1]}`;
1998
+ const rootPage = normalized.match(/\/app\/page\.[tj]sx?$/);
1999
+ if (rootPage) return "/";
2000
+ return null;
2001
+ };
2002
+ getAllRoutes = () => {
2003
+ const native = getNativeBridge();
2004
+ if (!native?.analyzeClasses) {
2005
+ throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
2006
+ }
2007
+ return ["/", "__global"];
2008
+ };
2009
+ getRouteClasses = (_route) => /* @__PURE__ */ new Set();
2010
+ registerFileClasses = (_filepath, _classes) => {
2011
+ };
2012
+ registerGlobalClasses = (_classes) => {
2013
+ };
2014
+ _incrementalEngineInstance = null;
2015
+ getIncrementalEngine = () => {
2016
+ if (!_incrementalEngineInstance) {
2017
+ _incrementalEngineInstance = new IncrementalEngine();
2018
+ }
2019
+ return _incrementalEngineInstance;
2020
+ };
2021
+ resetIncrementalEngine = () => {
2022
+ _incrementalEngineInstance = null;
2023
+ };
2024
+ IncrementalEngine = class {
2025
+ compile(source) {
2026
+ return transformSource(source);
2027
+ }
2028
+ };
2029
+ getBucketEngine = () => {
2030
+ const native = getNativeBridge();
2031
+ if (!native?.classifyAndSortClasses) {
2032
+ throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
2033
+ }
2034
+ return {
2035
+ add: (className) => className,
2036
+ get: (_bucket) => []
2037
+ };
2038
+ };
2039
+ resetBucketEngine = () => {
2040
+ };
2041
+ BucketEngine = class {
2042
+ add(className) {
2043
+ return className;
2044
+ }
2045
+ };
2046
+ classifyNode = (_node) => {
2047
+ const native = getNativeBridge();
2048
+ if (!native?.classifyAndSortClasses) {
2049
+ throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
2050
+ }
2051
+ return "unknown";
2052
+ };
2053
+ detectConflicts = (_classes) => {
2054
+ const native = getNativeBridge();
2055
+ if (!native?.analyzeClassUsage) {
2056
+ throw new Error("FATAL: Native binding 'analyzeClassUsage' is required but not available.");
2057
+ }
2058
+ return [];
2059
+ };
2060
+ bucketSort = (classes) => {
2061
+ const native = getNativeBridge();
2062
+ if (!native?.classifyAndSortClasses) {
2063
+ throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
2064
+ }
2065
+ const sorted = native.classifyAndSortClasses(classes);
2066
+ return sorted.map((c) => c.raw ?? c);
2067
+ };
2068
+ analyzeFile = (source, filename) => {
2069
+ const native = getNativeBridge();
2070
+ if (!native?.analyzeRsc) {
2071
+ throw new Error("FATAL: Native binding 'analyzeRsc' is required but not available.");
2072
+ }
2073
+ const rsc = native.analyzeRsc(source, filename);
2074
+ return {
2075
+ isServer: rsc?.isServer ?? true,
2076
+ needsClientDirective: rsc?.needsClientDirective ?? false,
2077
+ clientReasons: rsc?.clientReasons ?? [],
2078
+ interactiveClasses: [],
2079
+ canStaticResolveVariants: true
2080
+ };
2081
+ };
2082
+ analyzeVariantUsage = (_source, _componentName, _variantKeys) => {
2083
+ return { resolved: {}, dynamic: [] };
2084
+ };
2085
+ injectClientDirective = (source) => {
2086
+ if (!source.includes('"use client"') && !source.includes("'use client'")) {
2087
+ return '"use client";\n' + source;
2088
+ }
2089
+ return source;
2090
+ };
2091
+ injectServerOnlyComment = (source) => {
2092
+ return `/* @server-only */
2093
+ ${source}`;
2094
+ };
2095
+ analyzeClasses = (filesJson, cwd, flags) => {
2096
+ const native = getNativeBridge();
2097
+ if (!native?.analyzeClasses) {
2098
+ throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
2099
+ }
2100
+ return native.analyzeClasses(filesJson, cwd, flags);
2101
+ };
2102
+ extractTwStateConfigs = (source, filename) => {
2103
+ const native = getNativeBridge();
2104
+ if (!native?.extractTwStateConfigs) {
2105
+ throw new Error("FATAL: Native binding 'extractTwStateConfigs' is required but not available.");
2106
+ }
2107
+ return native.extractTwStateConfigs(source, filename);
2108
+ };
2109
+ generateStaticStateCss = (entries, _themeConfig) => {
2110
+ const rules = [];
2111
+ for (const entry of entries) {
2112
+ const stateConfig = JSON.parse(entry.statesJson);
2113
+ for (const [stateName, classes] of Object.entries(stateConfig)) {
2114
+ rules.push({
2115
+ selector: `.${entry.componentName}[data-state="${stateName}"]`,
2116
+ declarations: classes,
2117
+ cssRule: `.${entry.componentName}[data-state="${stateName}"]{${classes}}`,
2118
+ componentName: entry.componentName,
2119
+ stateName
2120
+ });
2121
+ }
2122
+ }
2123
+ return rules;
2124
+ };
2125
+ extractAndGenerateStateCss = (source, filename) => {
2126
+ const entries = extractTwStateConfigs(source, filename);
2127
+ return generateStaticStateCss(entries);
2128
+ };
2129
+ }
2130
+ });
2131
+
2132
+ // src/umbrella/compiler.ts
2133
+ init_src2();
735
2134
 
736
- 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 };
2135
+ export { BucketEngine, IncrementalEngine, adaptNativeResult, analyzeClassUsageNative, analyzeClasses, analyzeClassesNative, analyzeFile, analyzeRscNative, analyzeVariantUsage, astExtractClasses, atomicRegistrySize, batchExtractClasses, batchExtractClassesNative, bucketSort, buildStyleTag, cachePriority, cacheRead, cacheWrite, checkAgainstSafelist, checkAgainstSafelistNative, classifyAndSortClassesNative, classifyNode, clearAllCaches, clearAtomicRegistry, clearCompileCache, clearCssGenCache, clearParseCache, clearResolveCache, clearThemeCache, collectFiles, compileAnimation, compileClass, compileClasses, compileCssFromClasses, compileCssLightning, compileCssNative2, compileKeyframes, compileTheme, compileToCss, compileToCssBatch, compileVariantTableNative, computeIncrementalDiff, createFingerprint, detectConflicts, detectDeadCode, diffClassLists, eliminateDeadCss, eliminateDeadCssNative, emitPluginHook, estimateOptimalCacheConfig, extractAllClasses, extractAndGenerateStateCss, extractAndGenerateStateCssNative, extractClassesFromSource, extractClassesFromSourceNative, extractComponentUsage, extractContainerCssFromSource, extractTwContainerConfigs, extractTwStateConfigs, extractTwStateConfigsNative, fileToRoute, findDeadVariants, generateAtomicCss, generateCssForClasses, generateCssNative, generateSafelist, generateStaticStateCss, generateStaticStateCssNative, generateSubComponentTypes, getAllRoutes, getBucketEngine, getCacheOptimizationHints, getCacheStatistics, getCacheStats, getCompilationMetrics, getCompilerDiagnostics, getContentPaths, getIncrementalEngine, getNativeBridge, getPluginHooks, getRouteClasses, getWatchStats, hasTwUsage, hashContent, hoistComponentsNative, idRegistryActiveCount, idRegistryCreate, idRegistryDestroy, idRegistryExport, idRegistryGenerate, idRegistryImport, idRegistryLookup, idRegistryNext, idRegistryReset, idRegistrySnapshot, injectClientDirective, injectServerOnlyComment, injectStateHash, isAlreadyTransformed, isWatchRunning, layoutClassesToCss, loadSafelist, loadTailwindConfig, mergeClassesStatic, mergeCssDeclarationsNative, minifyCss, normalizeAndDedupClasses, normalizeClasses, optimizeCssNative, parseAtomicClass, parseClasses, pollWatchEvents, processFileChange, processTailwindCssLightning, propertyIdToString, pruneStaleCacheEntries, rebuildWorkspaceResult, redisCacheClear, redisCacheHitRate, redisCacheKeyCount, redisCacheSize, redisCacheSync, redisClusterStatus, redisDelete, redisDiagnose, redisDisableCacheWarming, redisDisableCluster, redisDisablePersistence, redisEnableCacheWarming, redisEnableCluster, redisEnablePersistence, redisExists, redisExpirationGet, redisExpirationSet, redisFlushAll, redisFlushDb, redisGet, redisGetEvictionPolicy, redisInfo, redisMemoryStats, redisMget, redisMonitor, redisMset, redisOptimizeMemory, redisPing, redisPoolConnect, redisPoolReconnect, redisPoolStats, redisPublish, redisReplicate, redisReplicationStatus, redisSet, redisSetEvictionPolicy, redisSnapshot, redisSubscribe, registerFileClasses, registerGlobalClasses, registerPluginHook, registerPropertyName, registerValueName, resetBucketEngine, resetCompilationMetrics, resetIncrementalEngine, resetNativeBridgeCache, resolveCascade, resolveClassNames, resolveConflictGroup, resolveSimpleVariants, resolveThemeValue, resolveVariants, reverseLookupProperty, reverseLookupValue, runCssPipeline, runElimination, runLoaderTransform, scanCacheOptimizations, scanFile, scanFileNative, scanFilesBatchNative, scanProjectUsage, scanWorkspace, shouldProcess, shouldSkipFile, startWatch, stopWatch, toAtomicClasses, transformSource, twMerge, twMergeMany, twMergeManyWithSeparator, twMergeRaw, twMergeWithSeparator, unregisterPluginHook, validateCssOutput, validateThemeConfig, valueIdToString, walkAndPrefilterSourceFiles, watchAddPattern, watchClearAll, watchEventTypeToString, watchGetActiveHandles, watchPause, watchRemovePattern, watchResume };
737
2136
  //# sourceMappingURL=compiler.mjs.map
738
2137
  //# sourceMappingURL=compiler.mjs.map