tailwind-styled-v4 5.0.12 → 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 (60) hide show
  1. package/README.md +100 -4
  2. package/dist/animate.d.mts +4 -0
  3. package/dist/animate.d.ts +4 -0
  4. package/dist/animate.js +22 -0
  5. package/dist/animate.js.map +1 -1
  6. package/dist/animate.mjs +22 -0
  7. package/dist/animate.mjs.map +1 -1
  8. package/dist/atomic.js +42 -0
  9. package/dist/atomic.js.map +1 -1
  10. package/dist/atomic.mjs +42 -0
  11. package/dist/atomic.mjs.map +1 -1
  12. package/dist/cli.js +142 -0
  13. package/dist/cli.js.map +1 -1
  14. package/dist/cli.mjs +142 -0
  15. package/dist/cli.mjs.map +1 -1
  16. package/dist/compiler.d.mts +1045 -991
  17. package/dist/compiler.d.ts +1045 -991
  18. package/dist/compiler.js +888 -922
  19. package/dist/compiler.js.map +1 -1
  20. package/dist/compiler.mjs +873 -908
  21. package/dist/compiler.mjs.map +1 -1
  22. package/dist/engine.js +1637 -340
  23. package/dist/engine.js.map +1 -1
  24. package/dist/engine.mjs +1636 -339
  25. package/dist/engine.mjs.map +1 -1
  26. package/dist/index.js +1636 -339
  27. package/dist/index.js.map +1 -1
  28. package/dist/index.mjs +1636 -339
  29. package/dist/index.mjs.map +1 -1
  30. package/dist/next.js +1060 -970
  31. package/dist/next.js.map +1 -1
  32. package/dist/next.mjs +1060 -970
  33. package/dist/next.mjs.map +1 -1
  34. package/dist/shared.js +1607 -310
  35. package/dist/shared.js.map +1 -1
  36. package/dist/shared.mjs +1607 -310
  37. package/dist/shared.mjs.map +1 -1
  38. package/dist/svelte.js.map +1 -1
  39. package/dist/svelte.mjs.map +1 -1
  40. package/dist/turbopackLoader.js +1610 -313
  41. package/dist/turbopackLoader.js.map +1 -1
  42. package/dist/turbopackLoader.mjs +1610 -313
  43. package/dist/turbopackLoader.mjs.map +1 -1
  44. package/dist/tw.js +142 -0
  45. package/dist/tw.js.map +1 -1
  46. package/dist/tw.mjs +142 -0
  47. package/dist/tw.mjs.map +1 -1
  48. package/dist/vite.js +1622 -325
  49. package/dist/vite.js.map +1 -1
  50. package/dist/vite.mjs +1622 -325
  51. package/dist/vite.mjs.map +1 -1
  52. package/dist/vue.js.map +1 -1
  53. package/dist/vue.mjs.map +1 -1
  54. package/dist/webpackLoader.js +66 -15
  55. package/dist/webpackLoader.js.map +1 -1
  56. package/dist/webpackLoader.mjs +66 -15
  57. package/dist/webpackLoader.mjs.map +1 -1
  58. package/native/tailwind-styled-native.node +0 -0
  59. package/native/tailwind-styled-native.win32-x64-msvc.node +0 -0
  60. package/package.json +1 -1
package/dist/next.js CHANGED
@@ -322,271 +322,20 @@ Tried paths: ${result.tried.join("\n")}`);
322
322
  }
323
323
  });
324
324
 
325
- // packages/domain/compiler/src/tailwindEngine.ts
326
- var tailwindEngine_exports = {};
327
- __export(tailwindEngine_exports, {
328
- clearCache: () => clearCache,
329
- generateRawCss: () => generateRawCss,
330
- getCacheStats: () => getCacheStats,
331
- processTailwindCssWithTargets: () => processTailwindCssWithTargets,
332
- runCssPipeline: () => runCssPipeline,
333
- runCssPipelineSync: () => runCssPipelineSync
334
- });
335
- function _getCacheKey(classes, minify, cssEntry, root) {
336
- const sorted = [...classes].sort().join(",");
337
- const flags = `${minify ? "1" : "0"}${cssEntry ? "1" : "0"}${root ? "1" : "0"}`;
338
- return `${sorted}|${flags}`;
339
- }
340
- function _evictOldestIfNeeded() {
341
- if (_cssCache.size >= MAX_CACHE_SIZE) {
342
- const firstKey = _cssCache.keys().next().value;
343
- if (firstKey !== void 0) {
344
- _cssCache.delete(firstKey);
345
- }
346
- }
347
- }
348
- function getCacheStats() {
349
- const total = _cacheHits + _cacheMisses;
350
- return {
351
- hits: _cacheHits,
352
- misses: _cacheMisses,
353
- hitRate: total > 0 ? _cacheHits / total : 0,
354
- size: _cssCache.size,
355
- maxSize: MAX_CACHE_SIZE
356
- };
357
- }
358
- function clearCache() {
359
- _cssCache.clear();
360
- _cacheHits = 0;
361
- _cacheMisses = 0;
362
- }
363
- function loadTailwindEngine() {
364
- if (_twEngine) return _twEngine;
365
- if (_twEngineError) throw _twEngineError;
366
- try {
367
- const tw = require2("tailwindcss");
368
- if (typeof tw.compile !== "function") {
369
- throw new Error("tailwindcss v4 not found \u2014 compile() API missing. Check tailwindcss version >= 4.");
370
- }
371
- _twEngine = tw;
372
- return _twEngine;
373
- } catch (e) {
374
- _twEngineError = e instanceof Error ? e : new Error(String(e));
375
- throw _twEngineError;
376
- }
377
- }
378
- async function generateRawCss(classes, cssEntryContent, root) {
379
- if (classes.length === 0) return "";
380
- const tw = loadTailwindEngine();
381
- const input = cssEntryContent ?? "@import 'tailwindcss';";
382
- const { readFileSync, existsSync: existsSync3 } = await import('fs');
383
- const { dirname, resolve: resolve2 } = await import('path');
384
- const projectRoot = root ?? process.cwd();
385
- const req = module$1.createRequire(resolve2(projectRoot, "package.json"));
386
- const loadStylesheet = async (id, base) => {
387
- try {
388
- 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;
389
- const pkgPath = req.resolve(cssId);
390
- return { content: readFileSync(pkgPath, "utf-8"), base: dirname(pkgPath) };
391
- } catch {
392
- try {
393
- const absPath = resolve2(base, id);
394
- if (existsSync3(absPath)) {
395
- return { content: readFileSync(absPath, "utf-8"), base: dirname(absPath) };
396
- }
397
- } catch {
398
- }
399
- return { content: "", base };
400
- }
401
- };
402
- const compiler = await Promise.resolve(tw.compile(input, { loadStylesheet }));
403
- return compiler.build(classes);
404
- }
405
- function getThemeConfig() {
406
- return {
407
- colors: {
408
- slate: {
409
- "50": "#f8fafc",
410
- "100": "#f1f5f9",
411
- "200": "#e2e8f0",
412
- "300": "#cbd5e1",
413
- "400": "#94a3b8",
414
- "500": "#64748b",
415
- "600": "#475569",
416
- "700": "#334155",
417
- "800": "#1e293b",
418
- "900": "#0f172a"
419
- },
420
- gray: {
421
- "50": "#f9fafb",
422
- "100": "#f3f4f6",
423
- "200": "#e5e7eb",
424
- "300": "#d1d5db",
425
- "400": "#9ca3af",
426
- "500": "#6b7280",
427
- "600": "#4b5563",
428
- "700": "#374151",
429
- "800": "#1f2937",
430
- "900": "#111827"
431
- },
432
- white: "#ffffff",
433
- black: "#000000",
434
- red: {
435
- "500": "#ef4444",
436
- "600": "#dc2626"
437
- },
438
- blue: {
439
- "500": "#3b82f6",
440
- "600": "#1e40af"
441
- }
442
- },
443
- spacing: {
444
- "0": "0px",
445
- "1": "0.25rem",
446
- "2": "0.5rem",
447
- "3": "0.75rem",
448
- "4": "1rem",
449
- "5": "1.25rem",
450
- "6": "1.5rem",
451
- "8": "2rem",
452
- "10": "2.5rem",
453
- "12": "3rem",
454
- "16": "4rem",
455
- "20": "5rem",
456
- "24": "6rem"
457
- },
458
- breakpoints: {
459
- "sm": "640px",
460
- "md": "768px",
461
- "lg": "1024px",
462
- "xl": "1280px",
463
- "2xl": "1536px"
464
- }
465
- };
466
- }
467
- function postProcessWithLightning(rawCss) {
468
- if (!rawCss) return "";
325
+ // packages/domain/compiler/src/compiler/cssGeneratorNative.ts
326
+ async function generateCssNative(classes, options) {
327
+ const { theme } = options;
469
328
  const native = getNativeBridge();
470
- if (!native?.processTailwindCssLightning) {
471
- throw new Error("FATAL: Native binding 'processTailwindCssLightning' is required but not available.");
472
- }
473
- const result = native.processTailwindCssLightning(rawCss);
474
- if (!result?.css) {
475
- throw new Error("FATAL: processTailwindCssLightning returned null");
476
- }
477
- return result.css;
478
- }
479
- async function runCssPipeline(classes, cssEntryContent, root, minify = true) {
480
- const filtered = classes.filter(Boolean);
481
- const uniqueMap = /* @__PURE__ */ new Map();
482
- filtered.forEach((cls) => uniqueMap.set(cls, cls));
483
- const unique = Array.from(uniqueMap.values());
484
- if (unique.length === 0) {
485
- return { css: "", classes: [], sizeBytes: 0, optimized: false };
486
- }
487
- const cacheKey = _getCacheKey(unique, minify, cssEntryContent, root);
488
- const cached = _cssCache.get(cacheKey);
489
- if (cached) {
490
- _cacheHits++;
491
- if (process.env.DEBUG?.includes("compiler")) {
492
- console.log(
493
- `[Compiler] Cache HIT: ${unique.length} classes (hit rate: ${(getCacheStats().hitRate * 100).toFixed(1)}%)`
494
- );
495
- }
496
- return cached;
497
- }
498
- _cacheMisses++;
499
- let rawCss;
500
- let usedRustCompiler = false;
501
- try {
502
- const theme = getThemeConfig();
503
- rawCss = await generateCssNative(unique, {
504
- theme,
505
- fallbackToJs: true,
506
- logFallback: process.env.DEBUG?.includes("compiler") === true
507
- });
508
- usedRustCompiler = true;
509
- } catch (error) {
510
- if (process.env.DEBUG?.includes("compiler")) {
511
- console.warn("[Compiler] Rust compiler failed, using JavaScript Tailwind:", error);
512
- }
513
- rawCss = await generateRawCss(unique, cssEntryContent, root);
514
- }
515
- const finalCss = minify ? postProcessWithLightning(rawCss) : rawCss;
516
- if (process.env.DEBUG?.includes("compiler")) {
517
- console.log(
518
- `[Compiler] Generated CSS from ${unique.length} classes (${usedRustCompiler ? "Rust" : "JavaScript"})`,
519
- `Size: ${finalCss.length} bytes`
329
+ if (!native?.generateCssNative) {
330
+ throw new Error(
331
+ "FATAL: Rust CSS generator (generateCssNative) is required but not available. Ensure native binding is properly loaded. Check that native/.node binary exists."
520
332
  );
521
333
  }
522
- const result = {
523
- css: finalCss,
524
- classes: unique,
525
- sizeBytes: finalCss.length,
526
- optimized: minify
527
- };
528
- _evictOldestIfNeeded();
529
- _cssCache.set(cacheKey, result);
530
- return result;
531
- }
532
- function runCssPipelineSync(_classes) {
533
- return { css: "", classes: [], sizeBytes: 0, optimized: false };
534
- }
535
- function processTailwindCssWithTargets(css, targets) {
536
- const native = getNativeBridge();
537
- if (!native?.processTailwindCssWithTargets) {
538
- throw new Error("FATAL: Native binding 'processTailwindCssWithTargets' is required but not available.");
539
- }
540
- const result = native.processTailwindCssWithTargets(css, targets ?? null);
541
- if (!result?.css) {
542
- throw new Error("FATAL: processTailwindCssWithTargets returned null");
543
- }
544
- return result.css;
545
- }
546
- var require2, _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE, _twEngine, _twEngineError;
547
- var init_tailwindEngine = __esm({
548
- "packages/domain/compiler/src/tailwindEngine.ts"() {
549
- init_nativeBridge();
550
- init_cssGeneratorNative();
551
- require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href)));
552
- _cssCache = /* @__PURE__ */ new Map();
553
- _cacheHits = 0;
554
- _cacheMisses = 0;
555
- MAX_CACHE_SIZE = 100;
556
- _twEngine = null;
557
- _twEngineError = null;
558
- }
559
- });
560
-
561
- // packages/domain/compiler/src/cssGeneratorNative.ts
562
- async function generateCssNative(classes, options) {
563
- const {
564
- theme,
565
- fallbackToJs = true,
566
- logFallback = false
567
- } = options;
568
- try {
569
- const native = getNativeBridge();
570
- if (!native?.generateCssNative) {
571
- throw new Error("generateCssNative not available in native binding");
572
- }
573
- const themeJson = JSON.stringify(theme);
574
- const css = native.generateCssNative(classes, themeJson);
575
- return css;
576
- } catch (error) {
577
- if (!fallbackToJs) {
578
- throw error;
579
- }
580
- if (logFallback) {
581
- console.warn(
582
- "[CSS Compiler] Rust CSS generator unavailable, falling back to JavaScript Tailwind",
583
- error instanceof Error ? error.message : String(error)
584
- );
585
- }
586
- return generateRawCss(classes);
587
- }
334
+ const themeJson = JSON.stringify(theme);
335
+ const css = native.generateCssNative(classes, themeJson);
336
+ return css;
588
337
  }
589
- function getCacheStats2() {
338
+ function getCacheStats() {
590
339
  try {
591
340
  const native = getNativeBridge();
592
341
  if (!native?.getCacheStats) {
@@ -609,169 +358,53 @@ function clearThemeCache() {
609
358
  }
610
359
  }
611
360
  var init_cssGeneratorNative = __esm({
612
- "packages/domain/compiler/src/cssGeneratorNative.ts"() {
361
+ "packages/domain/compiler/src/compiler/cssGeneratorNative.ts"() {
613
362
  init_nativeBridge();
614
- init_tailwindEngine();
615
363
  }
616
364
  });
617
365
 
618
- // packages/domain/compiler/src/scannerNative.ts
619
- function scanWorkspace(root, extensions) {
366
+ // packages/domain/compiler/src/compiler/compilationNative.ts
367
+ function compileCssNative2(classes, prefix) {
620
368
  const native = getNativeBridge();
621
- if (!native?.scan_workspace) throw new Error("scan_workspace not available");
622
- return native.scan_workspace(root, extensions);
369
+ if (!native?.compileCss) throw new Error("compileCss not available");
370
+ return native.compileCss(classes, prefix);
623
371
  }
624
- function extractClassesFromSourceNative(source) {
372
+ function compileCssLightning(classes) {
625
373
  const native = getNativeBridge();
626
- if (!native?.extract_classes_from_source) throw new Error("extract_classes_from_source not available");
627
- return native.extract_classes_from_source(source);
374
+ if (!native?.compileCssLightning) throw new Error("compileCssLightning not available");
375
+ return native.compileCssLightning(classes);
628
376
  }
629
- function batchExtractClassesNative(filePaths) {
377
+ function extractTwStateConfigsNative(source, filename) {
630
378
  const native = getNativeBridge();
631
- if (!native?.batch_extract_classes) throw new Error("batch_extract_classes not available");
632
- return native.batch_extract_classes(filePaths);
379
+ if (!native?.extractTwStateConfigs) throw new Error("extractTwStateConfigs not available");
380
+ return native.extractTwStateConfigs(source, filename);
633
381
  }
634
- function checkAgainstSafelistNative(classes, safelist) {
382
+ function generateStaticStateCssNative(inputs, resolvedCss) {
635
383
  const native = getNativeBridge();
636
- if (!native?.check_against_safelist) throw new Error("check_against_safelist not available");
637
- return native.check_against_safelist(classes, safelist);
384
+ if (!native?.generateStaticStateCss) throw new Error("generateStaticStateCss not available");
385
+ return native.generateStaticStateCss(inputs, resolvedCss ?? null);
638
386
  }
639
- function scanFile(filePath) {
387
+ function extractAndGenerateStateCssNative(source, filename) {
640
388
  const native = getNativeBridge();
641
- if (!native?.scan_file) throw new Error("scan_file not available");
642
- return native.scan_file(filePath);
389
+ if (!native?.extractAndGenerateStateCss) throw new Error("extractAndGenerateStateCss not available");
390
+ return native.extractAndGenerateStateCss(source, filename);
643
391
  }
644
- function collectFiles(root, extensions) {
392
+ function layoutClassesToCss(classes) {
645
393
  const native = getNativeBridge();
646
- if (!native?.collect_files) throw new Error("collect_files not available");
647
- return native.collect_files(root, extensions);
394
+ if (!native?.layoutClassesToCss) throw new Error("layoutClassesToCss not available");
395
+ return native.layoutClassesToCss(classes);
648
396
  }
649
- function walkAndPrefilterSourceFiles(root, extensions, _parallel) {
397
+ function hashContent(input, algorithm = "sha256", length = 8) {
650
398
  const native = getNativeBridge();
651
- if (!native?.walk_and_prefilter_source_files) throw new Error("walk_and_prefilter_source_files not available");
652
- return native.walk_and_prefilter_source_files(root, extensions);
399
+ if (!native?.hashContent) throw new Error("hashContent not available");
400
+ return native.hashContent(input, algorithm, length);
653
401
  }
654
- function generateSubComponentTypes(root, outputPath) {
402
+ function extractTwContainerConfigs(source) {
655
403
  const native = getNativeBridge();
656
- if (!native?.generate_sub_component_types) throw new Error("generate_sub_component_types not available");
657
- return native.generate_sub_component_types(root, outputPath);
404
+ if (!native?.extractTwContainerConfigs) throw new Error("extractTwContainerConfigs not available");
405
+ return native.extractTwContainerConfigs(source);
658
406
  }
659
- var init_scannerNative = __esm({
660
- "packages/domain/compiler/src/scannerNative.ts"() {
661
- init_nativeBridge();
662
- }
663
- });
664
-
665
- // packages/domain/compiler/src/analyzerNative.ts
666
- function detectDeadCode(scanResultJson, css) {
667
- const native = getNativeBridge();
668
- if (!native?.detectDeadCode) throw new Error("detectDeadCode not available");
669
- return native.detectDeadCode(scanResultJson, css);
670
- }
671
- function analyzeClassUsageNative(classes, scanResultJson, css) {
672
- const native = getNativeBridge();
673
- if (!native?.analyzeClassUsage) throw new Error("analyzeClassUsage not available");
674
- return native.analyzeClassUsage(classes, scanResultJson, css);
675
- }
676
- function analyzeClassesNative(filesJson, cwd, flags) {
677
- const native = getNativeBridge();
678
- if (!native?.analyzeClasses) throw new Error("analyzeClasses not available");
679
- return native.analyzeClasses(filesJson, cwd, flags ?? 0);
680
- }
681
- function analyzeRscNative(source, filename) {
682
- const native = getNativeBridge();
683
- if (!native?.analyzeRsc) throw new Error("analyzeRsc not available");
684
- return native.analyzeRsc(source, filename);
685
- }
686
- function optimizeCssNative(css) {
687
- const native = getNativeBridge();
688
- if (!native?.processTailwindCssLightning) throw new Error("processTailwindCssLightning not available");
689
- const result = native.processTailwindCssLightning(css);
690
- return {
691
- css: result.css,
692
- originalSize: css.length,
693
- optimizedSize: result.size_bytes,
694
- reductionPercentage: (css.length - result.size_bytes) / css.length * 100
695
- };
696
- }
697
- function processTailwindCssLightning(css) {
698
- const native = getNativeBridge();
699
- if (!native?.processTailwindCssLightning) throw new Error("processTailwindCssLightning not available");
700
- return native.processTailwindCssLightning(css);
701
- }
702
- function eliminateDeadCssNative(css, deadClasses) {
703
- const native = getNativeBridge();
704
- if (!native?.eliminateDeadCss) throw new Error("eliminateDeadCss not available");
705
- return native.eliminateDeadCss(css, deadClasses);
706
- }
707
- function hoistComponentsNative(source) {
708
- const native = getNativeBridge();
709
- if (!native?.hoistComponents) throw new Error("hoistComponents not available");
710
- return native.hoistComponents(source);
711
- }
712
- function compileVariantTableNative(configJson) {
713
- const native = getNativeBridge();
714
- if (!native?.compileVariantTable) throw new Error("compileVariantTable not available");
715
- return native.compileVariantTable(configJson);
716
- }
717
- function classifyAndSortClassesNative(classes) {
718
- const native = getNativeBridge();
719
- if (!native?.classifyAndSortClasses) throw new Error("classifyAndSortClasses not available");
720
- return native.classifyAndSortClasses(classes);
721
- }
722
- function mergeCssDeclarationsNative(cssChunks) {
723
- const native = getNativeBridge();
724
- if (!native?.mergeCssDeclarations) throw new Error("mergeCssDeclarations not available");
725
- return native.mergeCssDeclarations(cssChunks);
726
- }
727
- var init_analyzerNative = __esm({
728
- "packages/domain/compiler/src/analyzerNative.ts"() {
729
- init_nativeBridge();
730
- }
731
- });
732
-
733
- // packages/domain/compiler/src/compilationNative.ts
734
- function compileCssNative2(classes, prefix) {
735
- const native = getNativeBridge();
736
- if (!native?.compileCss) throw new Error("compileCss not available");
737
- return native.compileCss(classes, prefix);
738
- }
739
- function compileCssLightning(classes) {
740
- const native = getNativeBridge();
741
- if (!native?.compileCssLightning) throw new Error("compileCssLightning not available");
742
- return native.compileCssLightning(classes);
743
- }
744
- function extractTwStateConfigsNative(source, filename) {
745
- const native = getNativeBridge();
746
- if (!native?.extractTwStateConfigs) throw new Error("extractTwStateConfigs not available");
747
- return native.extractTwStateConfigs(source, filename);
748
- }
749
- function generateStaticStateCssNative(inputs, resolvedCss) {
750
- const native = getNativeBridge();
751
- if (!native?.generateStaticStateCss) throw new Error("generateStaticStateCss not available");
752
- return native.generateStaticStateCss(inputs, resolvedCss ?? null);
753
- }
754
- function extractAndGenerateStateCssNative(source, filename) {
755
- const native = getNativeBridge();
756
- if (!native?.extractAndGenerateStateCss) throw new Error("extractAndGenerateStateCss not available");
757
- return native.extractAndGenerateStateCss(source, filename);
758
- }
759
- function layoutClassesToCss(classes) {
760
- const native = getNativeBridge();
761
- if (!native?.layoutClassesToCss) throw new Error("layoutClassesToCss not available");
762
- return native.layoutClassesToCss(classes);
763
- }
764
- function hashContent(input, algorithm = "sha256", length = 8) {
765
- const native = getNativeBridge();
766
- if (!native?.hashContent) throw new Error("hashContent not available");
767
- return native.hashContent(input, algorithm, length);
768
- }
769
- function extractTwContainerConfigs(source) {
770
- const native = getNativeBridge();
771
- if (!native?.extractTwContainerConfigs) throw new Error("extractTwContainerConfigs not available");
772
- return native.extractTwContainerConfigs(source);
773
- }
774
- function parseAtomicClass(twClass) {
407
+ function parseAtomicClass(twClass) {
775
408
  const native = getNativeBridge();
776
409
  if (!native?.parseAtomicClass) throw new Error("parseAtomicClass not available");
777
410
  return native.parseAtomicClass(twClass);
@@ -797,245 +430,244 @@ function atomicRegistrySize() {
797
430
  return native.atomicRegistrySize();
798
431
  }
799
432
  var init_compilationNative = __esm({
800
- "packages/domain/compiler/src/compilationNative.ts"() {
433
+ "packages/domain/compiler/src/compiler/compilationNative.ts"() {
801
434
  init_nativeBridge();
802
435
  }
803
436
  });
804
437
 
805
- // packages/domain/compiler/src/cacheNative.ts
806
- function getCacheStatistics() {
438
+ // packages/domain/compiler/src/compiler/cssCompilationNative.ts
439
+ function compileClass(input) {
807
440
  const native = getNativeBridge();
808
- if (!native?.get_cache_statistics) throw new Error("get_cache_statistics not available");
809
- const statsJson = native.get_cache_statistics();
441
+ if (!native?.compile_class) throw new Error("compile_class not available");
442
+ const resultJson = native.compile_class(input);
810
443
  try {
811
- return JSON.parse(statsJson);
444
+ return JSON.parse(resultJson);
812
445
  } catch {
813
446
  return {
814
- parse_cache: { hits: 0, misses: 0, size: 0 },
815
- resolve_cache: { hits: 0, misses: 0, size: 0 },
816
- compile_cache: { hits: 0, misses: 0, size: 0 },
817
- css_gen_cache: { hits: 0, misses: 0, size: 0 },
818
- overall_hit_rate: 0,
819
- total_memory_bytes: 0
447
+ selector: "",
448
+ declarations: "",
449
+ properties: [],
450
+ specificity: 0
820
451
  };
821
452
  }
822
453
  }
823
- function clearAllCaches() {
454
+ function compileClasses(inputs) {
824
455
  const native = getNativeBridge();
825
- if (!native?.clear_all_caches) return;
456
+ if (!native?.compile_classes) throw new Error("compile_classes not available");
457
+ const resultJson = native.compile_classes(inputs);
826
458
  try {
827
- native.clear_all_caches();
459
+ return JSON.parse(resultJson);
828
460
  } catch {
461
+ return {
462
+ css: "",
463
+ resolved_classes: [],
464
+ unknown_classes: [],
465
+ size_bytes: 0,
466
+ duration_ms: 0
467
+ };
829
468
  }
830
469
  }
831
- function clearParseCache() {
470
+ function compileToCss(input, minify) {
832
471
  const native = getNativeBridge();
833
- if (!native?.clear_parse_cache) return;
834
- try {
835
- native.clear_parse_cache();
836
- } catch {
837
- }
472
+ if (!native?.compile_to_css) throw new Error("compile_to_css not available");
473
+ return native.compile_to_css(input, minify ?? false);
838
474
  }
839
- function clearResolveCache() {
475
+ function compileToCssBatch(inputs, minify) {
840
476
  const native = getNativeBridge();
841
- if (!native?.clear_resolve_cache) return;
842
- try {
843
- native.clear_resolve_cache();
844
- } catch {
845
- }
477
+ if (!native?.compile_to_css_batch) throw new Error("compile_to_css_batch not available");
478
+ return native.compile_to_css_batch(inputs, minify ?? false);
846
479
  }
847
- function clearCompileCache() {
480
+ function minifyCss(css) {
848
481
  const native = getNativeBridge();
849
- if (!native?.clear_compile_cache) return;
850
- try {
851
- native.clear_compile_cache();
852
- } catch {
853
- }
482
+ if (!native?.minify_css) throw new Error("minify_css not available");
483
+ return native.minify_css(css);
854
484
  }
855
- function clearCssGenCache() {
485
+ function compileAnimation(animationName, from, to) {
856
486
  const native = getNativeBridge();
857
- if (!native?.clear_css_gen_cache) return;
487
+ if (!native?.compile_animation) throw new Error("compile_animation not available");
488
+ const resultJson = native.compile_animation(animationName, from, to);
858
489
  try {
859
- native.clear_css_gen_cache();
490
+ return JSON.parse(resultJson);
860
491
  } catch {
492
+ return {
493
+ animation_id: "",
494
+ keyframes_css: "",
495
+ animation_rule: "",
496
+ duration_ms: 0
497
+ };
861
498
  }
862
499
  }
863
- function getCacheOptimizationHints(hitRatePercent, memoryUsedMb) {
500
+ function compileKeyframes(name, stopsJson) {
864
501
  const native = getNativeBridge();
865
- if (!native?.get_cache_optimization_hints)
866
- throw new Error("get_cache_optimization_hints not available");
867
- const hintsJson = native.get_cache_optimization_hints(
868
- Math.min(100, Math.max(0, hitRatePercent)),
869
- Math.max(1, memoryUsedMb)
870
- );
502
+ if (!native?.compile_keyframes) throw new Error("compile_keyframes not available");
503
+ const resultJson = native.compile_keyframes(name, stopsJson);
871
504
  try {
872
- return JSON.parse(hintsJson);
505
+ return JSON.parse(resultJson);
873
506
  } catch {
874
507
  return {
875
- current_strategy: "unknown",
876
- recommended_strategy: "increase_size",
877
- estimated_improvement_percent: 0,
878
- suggested_memory_mb: 256,
879
- notes: ["Unable to analyze cache statistics"]
508
+ animation_id: "",
509
+ keyframes_css: "",
510
+ animation_rule: "",
511
+ duration_ms: 0
880
512
  };
881
513
  }
882
514
  }
883
- function estimateOptimalCacheConfig(totalBudgetMb, workloadType) {
515
+ function compileTheme(tokensJson, themeName, prefix) {
884
516
  const native = getNativeBridge();
885
- if (!native?.estimate_optimal_cache_config_native)
886
- throw new Error("estimate_optimal_cache_config_native not available");
887
- const configJson = native.estimate_optimal_cache_config_native(
888
- Math.max(64, totalBudgetMb),
889
- workloadType
890
- );
517
+ if (!native?.compile_theme) throw new Error("compile_theme not available");
518
+ const resultJson = native.compile_theme(tokensJson, themeName, prefix);
891
519
  try {
892
- return JSON.parse(configJson);
520
+ return JSON.parse(resultJson);
893
521
  } catch {
894
522
  return {
895
- parse_cache_size: 128,
896
- resolve_cache_size: 64,
897
- compile_cache_size: 256,
898
- css_gen_cache_size: 128,
899
- recommended_eviction_policy: "lru",
900
- ttl_seconds: 3600,
901
- expected_hit_rate_percent: 75
523
+ selector: ":root",
524
+ variables: [],
525
+ variables_css: "",
526
+ theme_name: themeName
902
527
  };
903
528
  }
904
529
  }
905
- function cacheRead(cachePath) {
530
+ function twMerge(classString) {
906
531
  const native = getNativeBridge();
907
- if (!native?.cache_read) throw new Error("cache_read not available");
908
- const result = native.cache_read(cachePath);
909
- try {
910
- return JSON.parse(result.entries_json || "[]");
911
- } catch {
912
- return [];
913
- }
532
+ if (!native?.tw_merge) throw new Error("tw_merge not available");
533
+ return native.tw_merge(classString);
914
534
  }
915
- function cacheWrite(cachePath, entries) {
535
+ function twMergeMany(classStrings) {
916
536
  const native = getNativeBridge();
917
- if (!native?.cache_write) throw new Error("cache_write not available");
918
- try {
919
- const result = native.cache_write(
920
- cachePath,
921
- entries.map((e) => ({
922
- file: e.file,
923
- content_hash: e.contentHash,
924
- classes: e.classes,
925
- mtime_ms: e.mtimeMs,
926
- size_bytes: e.sizeBytes
927
- }))
928
- );
929
- return typeof result === "boolean" ? result : result === true;
930
- } catch {
931
- return false;
932
- }
537
+ if (!native?.tw_merge_many) throw new Error("tw_merge_many not available");
538
+ return native.tw_merge_many(classStrings);
933
539
  }
934
- function cachePriority(mtimeMs, sizeBytes, hitCount) {
540
+ function twMergeWithSeparator(classString, options) {
935
541
  const native = getNativeBridge();
936
- if (!native?.cache_priority) throw new Error("cache_priority not available");
937
- return native.cache_priority(mtimeMs, sizeBytes, hitCount);
542
+ if (!native?.tw_merge_with_separator)
543
+ throw new Error("tw_merge_with_separator not available");
544
+ const opts = {
545
+ separator: options.separator,
546
+ debug: options.debug
547
+ };
548
+ return native.tw_merge_with_separator(classString, opts);
938
549
  }
939
- var init_cacheNative = __esm({
940
- "packages/domain/compiler/src/cacheNative.ts"() {
550
+ function twMergeManyWithSeparator(classStrings, options) {
551
+ const native = getNativeBridge();
552
+ if (!native?.tw_merge_many_with_separator)
553
+ throw new Error("tw_merge_many_with_separator not available");
554
+ const opts = {
555
+ separator: options.separator,
556
+ debug: options.debug
557
+ };
558
+ return native.tw_merge_many_with_separator(classStrings, opts);
559
+ }
560
+ function twMergeRaw(classLists) {
561
+ const native = getNativeBridge();
562
+ if (!native?.tw_merge_raw) throw new Error("tw_merge_raw not available");
563
+ return native.tw_merge_raw(classLists);
564
+ }
565
+ var init_cssCompilationNative = __esm({
566
+ "packages/domain/compiler/src/compiler/cssCompilationNative.ts"() {
941
567
  init_nativeBridge();
942
568
  }
943
569
  });
944
570
 
945
- // packages/domain/compiler/src/themeResolutionNative.ts
946
- function resolveVariants(configJson) {
571
+ // packages/domain/compiler/src/compiler/idRegistryNative.ts
572
+ function idRegistryCreate() {
947
573
  const native = getNativeBridge();
948
- if (!native?.resolve_variants) throw new Error("resolve_variants not available");
949
- const resultJson = native.resolve_variants(configJson);
950
- try {
951
- return JSON.parse(resultJson);
952
- } catch {
953
- return {
954
- variants: [],
955
- supported: [],
956
- deprecated: [],
957
- conflicting: []
958
- };
959
- }
574
+ if (!native?.id_registry_create) throw new Error("id_registry_create not available");
575
+ return native.id_registry_create();
960
576
  }
961
- function validateThemeConfig(configJson) {
577
+ function idRegistryGenerate(handle, name) {
962
578
  const native = getNativeBridge();
963
- if (!native?.validate_variant_config) throw new Error("validate_variant_config not available");
964
- const resultJson = native.validate_variant_config(configJson);
965
- try {
966
- return JSON.parse(resultJson);
967
- } catch {
968
- return {
969
- is_valid: false,
970
- errors: ["Unable to parse configuration"],
971
- warnings: [],
972
- suggestions: []
973
- };
974
- }
579
+ if (!native?.id_registry_generate) throw new Error("id_registry_generate not available");
580
+ return native.id_registry_generate(handle, name);
975
581
  }
976
- function resolveCascade(baseThemeJson, overridesJson) {
582
+ function idRegistryLookup(handle, name) {
977
583
  const native = getNativeBridge();
978
- if (!native?.resolve_cascade) throw new Error("resolve_cascade not available");
979
- const resultJson = native.resolve_cascade(baseThemeJson, overridesJson);
980
- try {
981
- return JSON.parse(resultJson);
982
- } catch {
983
- return {
984
- base_theme: {},
985
- user_overrides: {},
986
- merged_theme: {},
987
- conflict_resolutions: []
988
- };
989
- }
584
+ if (!native?.id_registry_lookup) throw new Error("id_registry_lookup not available");
585
+ return native.id_registry_lookup(handle, name);
990
586
  }
991
- function resolveClassNames(classNames, themeJson) {
587
+ function idRegistryNext(handle) {
992
588
  const native = getNativeBridge();
993
- if (!native?.resolve_class_names) throw new Error("resolve_class_names not available");
994
- const resultJson = native.resolve_class_names(classNames, themeJson);
995
- try {
996
- return JSON.parse(resultJson);
997
- } catch {
998
- return [];
999
- }
589
+ if (!native?.id_registry_next) throw new Error("id_registry_next not available");
590
+ return native.id_registry_next(handle);
1000
591
  }
1001
- function resolveConflictGroup(groupName, themeJson) {
592
+ function idRegistryDestroy(handle) {
1002
593
  const native = getNativeBridge();
1003
- if (!native?.resolve_conflict_group)
1004
- throw new Error("resolve_conflict_group not available");
1005
- const resultJson = native.resolve_conflict_group(groupName, themeJson);
594
+ if (!native?.id_registry_destroy) return;
595
+ native.id_registry_destroy(handle);
596
+ }
597
+ function idRegistryReset(handle) {
598
+ const native = getNativeBridge();
599
+ if (!native?.id_registry_reset) return;
600
+ native.id_registry_reset(handle);
601
+ }
602
+ function idRegistrySnapshot(handle) {
603
+ const native = getNativeBridge();
604
+ if (!native?.id_registry_snapshot) throw new Error("id_registry_snapshot not available");
605
+ const snapshotJson = native.id_registry_snapshot(handle);
1006
606
  try {
1007
- return JSON.parse(resultJson);
607
+ return JSON.parse(snapshotJson);
1008
608
  } catch {
1009
609
  return {
1010
- group_name: groupName,
1011
- conflicting_classes: [],
1012
- description: "",
1013
- resolution_strategy: "last-wins"
610
+ handle,
611
+ next_id: 0,
612
+ entries: [],
613
+ total_entries: 0
1014
614
  };
1015
615
  }
1016
616
  }
1017
- function resolveThemeValue(keyPath, themeJson) {
617
+ function idRegistryActiveCount() {
1018
618
  const native = getNativeBridge();
1019
- if (!native?.resolve_theme_value) throw new Error("resolve_theme_value not available");
1020
- return native.resolve_theme_value(keyPath, themeJson);
619
+ if (!native?.id_registry_active_count) throw new Error("id_registry_active_count not available");
620
+ return native.id_registry_active_count();
1021
621
  }
1022
- function resolveSimpleVariants(configJson) {
622
+ function registerPropertyName(propertyName) {
1023
623
  const native = getNativeBridge();
1024
- if (!native?.resolve_simple_variants) throw new Error("resolve_simple_variants not available");
1025
- const resultJson = native.resolve_simple_variants(configJson);
1026
- try {
1027
- return JSON.parse(resultJson);
1028
- } catch {
1029
- return [];
1030
- }
624
+ if (!native?.register_property_name)
625
+ throw new Error("register_property_name not available");
626
+ return native.register_property_name(propertyName);
1031
627
  }
1032
- var init_themeResolutionNative = __esm({
1033
- "packages/domain/compiler/src/themeResolutionNative.ts"() {
628
+ function registerValueName(valueName) {
629
+ const native = getNativeBridge();
630
+ if (!native?.register_value_name) throw new Error("register_value_name not available");
631
+ return native.register_value_name(valueName);
632
+ }
633
+ function propertyIdToString(propertyId) {
634
+ const native = getNativeBridge();
635
+ if (!native?.property_id_to_string) throw new Error("property_id_to_string not available");
636
+ return native.property_id_to_string(propertyId);
637
+ }
638
+ function valueIdToString(valueId) {
639
+ const native = getNativeBridge();
640
+ if (!native?.value_id_to_string) throw new Error("value_id_to_string not available");
641
+ return native.value_id_to_string(valueId);
642
+ }
643
+ function reverseLookupProperty(propertyId) {
644
+ const native = getNativeBridge();
645
+ if (!native?.reverse_lookup_property)
646
+ throw new Error("reverse_lookup_property not available");
647
+ return native.reverse_lookup_property(propertyId);
648
+ }
649
+ function reverseLookupValue(valueId) {
650
+ const native = getNativeBridge();
651
+ if (!native?.reverse_lookup_value) throw new Error("reverse_lookup_value not available");
652
+ return native.reverse_lookup_value(valueId);
653
+ }
654
+ function idRegistryExport(handle) {
655
+ const native = getNativeBridge();
656
+ if (!native?.id_registry_export) throw new Error("id_registry_export not available");
657
+ return native.id_registry_export(handle);
658
+ }
659
+ function idRegistryImport(importedData) {
660
+ const native = getNativeBridge();
661
+ if (!native?.id_registry_import) throw new Error("id_registry_import not available");
662
+ return native.id_registry_import(importedData);
663
+ }
664
+ var init_idRegistryNative = __esm({
665
+ "packages/domain/compiler/src/compiler/idRegistryNative.ts"() {
1034
666
  init_nativeBridge();
1035
667
  }
1036
668
  });
1037
669
 
1038
- // packages/domain/compiler/src/streamingNative.ts
670
+ // packages/domain/compiler/src/compiler/streamingNative.ts
1039
671
  function processFileChange(fileChangeJson) {
1040
672
  const native = getNativeBridge();
1041
673
  if (!native?.process_file_change) throw new Error("process_file_change not available");
@@ -1171,244 +803,663 @@ function scanFilesBatchNative(filesJson) {
1171
803
  }
1172
804
  }
1173
805
  var init_streamingNative = __esm({
1174
- "packages/domain/compiler/src/streamingNative.ts"() {
806
+ "packages/domain/compiler/src/compiler/streamingNative.ts"() {
1175
807
  init_nativeBridge();
1176
808
  }
1177
809
  });
1178
810
 
1179
- // packages/domain/compiler/src/cssCompilationNative.ts
1180
- function compileClass(input) {
811
+ // packages/domain/compiler/src/compiler/tailwindEngine.ts
812
+ var tailwindEngine_exports = {};
813
+ __export(tailwindEngine_exports, {
814
+ clearCache: () => clearCache,
815
+ getCacheStats: () => getCacheStats2,
816
+ processTailwindCssWithTargets: () => processTailwindCssWithTargets,
817
+ runCssPipeline: () => runCssPipeline,
818
+ runCssPipelineSync: () => runCssPipelineSync
819
+ });
820
+ function _getCacheKey(classes, minify, cssEntry, root) {
821
+ const sorted = [...classes].sort().join(",");
822
+ const flags = `${minify ? "1" : "0"}${cssEntry ? "1" : "0"}${root ? "1" : "0"}`;
823
+ return `${sorted}|${flags}`;
824
+ }
825
+ function _evictOldestIfNeeded() {
826
+ if (_cssCache.size >= MAX_CACHE_SIZE) {
827
+ const firstKey = _cssCache.keys().next().value;
828
+ if (firstKey !== void 0) {
829
+ _cssCache.delete(firstKey);
830
+ }
831
+ }
832
+ }
833
+ function getCacheStats2() {
834
+ const total = _cacheHits + _cacheMisses;
835
+ return {
836
+ hits: _cacheHits,
837
+ misses: _cacheMisses,
838
+ hitRate: total > 0 ? _cacheHits / total : 0,
839
+ size: _cssCache.size,
840
+ maxSize: MAX_CACHE_SIZE
841
+ };
842
+ }
843
+ function clearCache() {
844
+ _cssCache.clear();
845
+ _cacheHits = 0;
846
+ _cacheMisses = 0;
847
+ }
848
+ function getThemeConfig() {
849
+ return {
850
+ colors: {
851
+ slate: {
852
+ "50": "#f8fafc",
853
+ "100": "#f1f5f9",
854
+ "200": "#e2e8f0",
855
+ "300": "#cbd5e1",
856
+ "400": "#94a3b8",
857
+ "500": "#64748b",
858
+ "600": "#475569",
859
+ "700": "#334155",
860
+ "800": "#1e293b",
861
+ "900": "#0f172a"
862
+ },
863
+ gray: {
864
+ "50": "#f9fafb",
865
+ "100": "#f3f4f6",
866
+ "200": "#e5e7eb",
867
+ "300": "#d1d5db",
868
+ "400": "#9ca3af",
869
+ "500": "#6b7280",
870
+ "600": "#4b5563",
871
+ "700": "#374151",
872
+ "800": "#1f2937",
873
+ "900": "#111827"
874
+ },
875
+ white: "#ffffff",
876
+ black: "#000000",
877
+ red: {
878
+ "500": "#ef4444",
879
+ "600": "#dc2626"
880
+ },
881
+ blue: {
882
+ "500": "#3b82f6",
883
+ "600": "#1e40af"
884
+ }
885
+ },
886
+ spacing: {
887
+ "0": "0px",
888
+ "1": "0.25rem",
889
+ "2": "0.5rem",
890
+ "3": "0.75rem",
891
+ "4": "1rem",
892
+ "5": "1.25rem",
893
+ "6": "1.5rem",
894
+ "8": "2rem",
895
+ "10": "2.5rem",
896
+ "12": "3rem",
897
+ "16": "4rem",
898
+ "20": "5rem",
899
+ "24": "6rem"
900
+ },
901
+ breakpoints: {
902
+ "sm": "640px",
903
+ "md": "768px",
904
+ "lg": "1024px",
905
+ "xl": "1280px",
906
+ "2xl": "1536px"
907
+ }
908
+ };
909
+ }
910
+ function postProcessWithLightning(rawCss) {
911
+ if (!rawCss) return "";
1181
912
  const native = getNativeBridge();
1182
- if (!native?.compile_class) throw new Error("compile_class not available");
1183
- const resultJson = native.compile_class(input);
1184
- try {
1185
- return JSON.parse(resultJson);
1186
- } catch {
1187
- return {
1188
- selector: "",
1189
- declarations: "",
1190
- properties: [],
1191
- specificity: 0
1192
- };
913
+ if (!native?.processTailwindCssLightning) {
914
+ throw new Error("FATAL: Native binding 'processTailwindCssLightning' is required but not available.");
1193
915
  }
916
+ const result = native.processTailwindCssLightning(rawCss);
917
+ if (!result?.css) {
918
+ throw new Error("FATAL: processTailwindCssLightning returned null");
919
+ }
920
+ return result.css;
1194
921
  }
1195
- function compileClasses(inputs) {
922
+ async function runCssPipeline(classes, cssEntryContent, root, minify = true) {
923
+ const filtered = classes.filter(Boolean);
924
+ const uniqueMap = /* @__PURE__ */ new Map();
925
+ filtered.forEach((cls) => uniqueMap.set(cls, cls));
926
+ const unique = Array.from(uniqueMap.values());
927
+ if (unique.length === 0) {
928
+ return { css: "", classes: [], sizeBytes: 0, optimized: false };
929
+ }
930
+ const cacheKey = _getCacheKey(unique, minify, cssEntryContent, root);
931
+ const cached = _cssCache.get(cacheKey);
932
+ if (cached) {
933
+ _cacheHits++;
934
+ if (process.env.DEBUG?.includes("compiler")) {
935
+ console.log(
936
+ `[Compiler] Cache HIT: ${unique.length} classes (hit rate: ${(getCacheStats2().hitRate * 100).toFixed(1)}%)`
937
+ );
938
+ }
939
+ return cached;
940
+ }
941
+ _cacheMisses++;
942
+ let rawCss;
943
+ let usedRustCompiler = false;
944
+ const theme = getThemeConfig();
945
+ rawCss = await generateCssNative(unique, { theme });
946
+ usedRustCompiler = true;
947
+ const finalCss = minify ? postProcessWithLightning(rawCss) : rawCss;
948
+ if (process.env.DEBUG?.includes("compiler")) {
949
+ console.log(
950
+ `[Compiler] Generated CSS from ${unique.length} classes (${usedRustCompiler ? "Rust" : "JavaScript"})`,
951
+ `Size: ${finalCss.length} bytes`
952
+ );
953
+ }
954
+ const result = {
955
+ css: finalCss,
956
+ classes: unique,
957
+ sizeBytes: finalCss.length,
958
+ optimized: minify
959
+ };
960
+ _evictOldestIfNeeded();
961
+ _cssCache.set(cacheKey, result);
962
+ return result;
963
+ }
964
+ function runCssPipelineSync(_classes) {
965
+ return { css: "", classes: [], sizeBytes: 0, optimized: false };
966
+ }
967
+ function processTailwindCssWithTargets(css, targets) {
1196
968
  const native = getNativeBridge();
1197
- if (!native?.compile_classes) throw new Error("compile_classes not available");
1198
- const resultJson = native.compile_classes(inputs);
1199
- try {
1200
- return JSON.parse(resultJson);
1201
- } catch {
1202
- return {
1203
- css: "",
1204
- resolved_classes: [],
1205
- unknown_classes: [],
1206
- size_bytes: 0,
1207
- duration_ms: 0
969
+ if (!native?.processTailwindCssWithTargets) {
970
+ throw new Error("FATAL: Native binding 'processTailwindCssWithTargets' is required but not available.");
971
+ }
972
+ const result = native.processTailwindCssWithTargets(css, targets ?? null);
973
+ if (!result?.css) {
974
+ throw new Error("FATAL: processTailwindCssWithTargets returned null");
975
+ }
976
+ return result.css;
977
+ }
978
+ var _cssCache, _cacheHits, _cacheMisses, MAX_CACHE_SIZE;
979
+ var init_tailwindEngine = __esm({
980
+ "packages/domain/compiler/src/compiler/tailwindEngine.ts"() {
981
+ init_nativeBridge();
982
+ init_cssGeneratorNative();
983
+ module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('next.js', document.baseURI).href)));
984
+ _cssCache = /* @__PURE__ */ new Map();
985
+ _cacheHits = 0;
986
+ _cacheMisses = 0;
987
+ MAX_CACHE_SIZE = 100;
988
+ }
989
+ });
990
+
991
+ // packages/domain/compiler/src/compiler/index.ts
992
+ var init_compiler = __esm({
993
+ "packages/domain/compiler/src/compiler/index.ts"() {
994
+ init_cssGeneratorNative();
995
+ init_compilationNative();
996
+ init_cssCompilationNative();
997
+ init_idRegistryNative();
998
+ init_streamingNative();
999
+ init_tailwindEngine();
1000
+ }
1001
+ });
1002
+
1003
+ // packages/domain/compiler/src/parser/index.ts
1004
+ var parser_exports = {};
1005
+ __export(parser_exports, {
1006
+ astExtractClasses: () => astExtractClasses,
1007
+ batchExtractClasses: () => batchExtractClasses,
1008
+ checkAgainstSafelist: () => checkAgainstSafelist,
1009
+ diffClassLists: () => diffClassLists,
1010
+ extractAllClasses: () => extractAllClasses,
1011
+ extractClassesFromSource: () => extractClassesFromSource,
1012
+ extractComponentUsage: () => extractComponentUsage,
1013
+ mergeClassesStatic: () => mergeClassesStatic,
1014
+ normalizeAndDedupClasses: () => normalizeAndDedupClasses,
1015
+ normalizeClasses: () => normalizeClasses,
1016
+ parseClasses: () => parseClasses
1017
+ });
1018
+ var parseClasses, extractAllClasses, extractClassesFromSource, astExtractClasses, normalizeClasses, mergeClassesStatic, normalizeAndDedupClasses, extractComponentUsage, batchExtractClasses, checkAgainstSafelist, diffClassLists;
1019
+ var init_parser = __esm({
1020
+ "packages/domain/compiler/src/parser/index.ts"() {
1021
+ init_nativeBridge();
1022
+ parseClasses = (raw) => {
1023
+ const native = getNativeBridge();
1024
+ if (!native?.parseClasses) {
1025
+ throw new Error("FATAL: Native binding 'parseClasses' is required but not available.");
1026
+ }
1027
+ return native.parseClasses(raw) || [];
1028
+ };
1029
+ extractAllClasses = (source) => {
1030
+ const native = getNativeBridge();
1031
+ if (!native?.extractAllClasses) {
1032
+ throw new Error("FATAL: Native binding 'extractAllClasses' is required but not available.");
1033
+ }
1034
+ return native.extractAllClasses(source) || [];
1035
+ };
1036
+ extractClassesFromSource = (source) => {
1037
+ const native = getNativeBridge();
1038
+ if (!native?.extractClassesFromSource) {
1039
+ throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
1040
+ }
1041
+ const result = native.extractClassesFromSource(source);
1042
+ return Array.isArray(result) ? result.join(" ") : String(result || "");
1043
+ };
1044
+ astExtractClasses = (source, _filename) => {
1045
+ const native = getNativeBridge();
1046
+ if (!native?.extractClassesFromSource) {
1047
+ throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
1048
+ }
1049
+ return native.extractClassesFromSource(source) || [];
1050
+ };
1051
+ normalizeClasses = (raw) => {
1052
+ const result = normalizeAndDedupClasses(raw);
1053
+ return result?.normalized || "";
1054
+ };
1055
+ mergeClassesStatic = (classes) => {
1056
+ const result = normalizeAndDedupClasses(classes);
1057
+ return result?.normalized || "";
1058
+ };
1059
+ normalizeAndDedupClasses = (raw) => {
1060
+ const native = getNativeBridge();
1061
+ if (!native?.normalizeAndDedupClasses) {
1062
+ throw new Error("FATAL: Native binding 'normalizeAndDedupClasses' is required but not available.");
1063
+ }
1064
+ const result = native.normalizeAndDedupClasses(raw);
1065
+ return result || { normalized: "", duplicatesRemoved: 0, uniqueCount: 0 };
1066
+ };
1067
+ extractComponentUsage = (source) => {
1068
+ const native = getNativeBridge();
1069
+ if (!native?.extractComponentUsage) {
1070
+ throw new Error("FATAL: Native binding 'extractComponentUsage' is required but not available.");
1071
+ }
1072
+ return native.extractComponentUsage(source) || [];
1073
+ };
1074
+ batchExtractClasses = (filePaths) => {
1075
+ const native = getNativeBridge();
1076
+ if (!native?.batchExtractClasses) {
1077
+ throw new Error("FATAL: Native binding 'batchExtractClasses' is required but not available.");
1078
+ }
1079
+ return native.batchExtractClasses(filePaths) || [];
1080
+ };
1081
+ checkAgainstSafelist = (classes, safelist) => {
1082
+ const native = getNativeBridge();
1083
+ if (!native?.checkAgainstSafelist) {
1084
+ throw new Error("FATAL: Native binding 'checkAgainstSafelist' is required but not available.");
1085
+ }
1086
+ return native.checkAgainstSafelist(classes, safelist) || { matched: [], unmatched: [], safelistSize: 0 };
1087
+ };
1088
+ diffClassLists = (previous, current) => {
1089
+ const native = getNativeBridge();
1090
+ if (!native?.diffClassLists) {
1091
+ throw new Error("FATAL: Native binding 'diffClassLists' is required but not available.");
1092
+ }
1093
+ return native.diffClassLists(previous, current) || { added: [], removed: [], unchanged: [], hasChanges: false };
1208
1094
  };
1209
1095
  }
1096
+ });
1097
+
1098
+ // packages/domain/compiler/src/analyzer/analyzerNative.ts
1099
+ function detectDeadCode(scanResultJson, css) {
1100
+ const native = getNativeBridge();
1101
+ if (!native?.detectDeadCode) throw new Error("detectDeadCode not available");
1102
+ return native.detectDeadCode(scanResultJson, css);
1210
1103
  }
1211
- function compileToCss(input, minify) {
1104
+ function analyzeClassUsageNative(classes, scanResultJson, css) {
1212
1105
  const native = getNativeBridge();
1213
- if (!native?.compile_to_css) throw new Error("compile_to_css not available");
1214
- return native.compile_to_css(input, minify ?? false);
1106
+ if (!native?.analyzeClassUsage) throw new Error("analyzeClassUsage not available");
1107
+ return native.analyzeClassUsage(classes, scanResultJson, css);
1108
+ }
1109
+ function analyzeClassesNative(filesJson, cwd, flags) {
1110
+ const native = getNativeBridge();
1111
+ if (!native?.analyzeClasses) throw new Error("analyzeClasses not available");
1112
+ return native.analyzeClasses(filesJson, cwd, flags ?? 0);
1113
+ }
1114
+ function analyzeRscNative(source, filename) {
1115
+ const native = getNativeBridge();
1116
+ if (!native?.analyzeRsc) throw new Error("analyzeRsc not available");
1117
+ return native.analyzeRsc(source, filename);
1118
+ }
1119
+ function optimizeCssNative(css) {
1120
+ const native = getNativeBridge();
1121
+ if (!native?.processTailwindCssLightning) throw new Error("processTailwindCssLightning not available");
1122
+ const result = native.processTailwindCssLightning(css);
1123
+ return {
1124
+ css: result.css,
1125
+ originalSize: css.length,
1126
+ optimizedSize: result.size_bytes,
1127
+ reductionPercentage: (css.length - result.size_bytes) / css.length * 100
1128
+ };
1129
+ }
1130
+ function processTailwindCssLightning(css) {
1131
+ const native = getNativeBridge();
1132
+ if (!native?.processTailwindCssLightning) throw new Error("processTailwindCssLightning not available");
1133
+ return native.processTailwindCssLightning(css);
1134
+ }
1135
+ function eliminateDeadCssNative(css, deadClasses) {
1136
+ const native = getNativeBridge();
1137
+ if (!native?.eliminateDeadCss) throw new Error("eliminateDeadCss not available");
1138
+ return native.eliminateDeadCss(css, deadClasses);
1139
+ }
1140
+ function hoistComponentsNative(source) {
1141
+ const native = getNativeBridge();
1142
+ if (!native?.hoistComponents) throw new Error("hoistComponents not available");
1143
+ return native.hoistComponents(source);
1144
+ }
1145
+ function compileVariantTableNative(configJson) {
1146
+ const native = getNativeBridge();
1147
+ if (!native?.compileVariantTable) throw new Error("compileVariantTable not available");
1148
+ return native.compileVariantTable(configJson);
1215
1149
  }
1216
- function compileToCssBatch(inputs, minify) {
1150
+ function classifyAndSortClassesNative(classes) {
1217
1151
  const native = getNativeBridge();
1218
- if (!native?.compile_to_css_batch) throw new Error("compile_to_css_batch not available");
1219
- return native.compile_to_css_batch(inputs, minify ?? false);
1152
+ if (!native?.classifyAndSortClasses) throw new Error("classifyAndSortClasses not available");
1153
+ return native.classifyAndSortClasses(classes);
1220
1154
  }
1221
- function minifyCss(css) {
1155
+ function mergeCssDeclarationsNative(cssChunks) {
1222
1156
  const native = getNativeBridge();
1223
- if (!native?.minify_css) throw new Error("minify_css not available");
1224
- return native.minify_css(css);
1157
+ if (!native?.mergeCssDeclarations) throw new Error("mergeCssDeclarations not available");
1158
+ return native.mergeCssDeclarations(cssChunks);
1225
1159
  }
1226
- function compileAnimation(animationName, from, to) {
1160
+ var init_analyzerNative = __esm({
1161
+ "packages/domain/compiler/src/analyzer/analyzerNative.ts"() {
1162
+ init_nativeBridge();
1163
+ }
1164
+ });
1165
+
1166
+ // packages/domain/compiler/src/analyzer/themeResolutionNative.ts
1167
+ function resolveVariants(configJson) {
1227
1168
  const native = getNativeBridge();
1228
- if (!native?.compile_animation) throw new Error("compile_animation not available");
1229
- const resultJson = native.compile_animation(animationName, from, to);
1169
+ if (!native?.resolve_variants) throw new Error("resolve_variants not available");
1170
+ const resultJson = native.resolve_variants(configJson);
1230
1171
  try {
1231
1172
  return JSON.parse(resultJson);
1232
1173
  } catch {
1233
1174
  return {
1234
- animation_id: "",
1235
- keyframes_css: "",
1236
- animation_rule: "",
1237
- duration_ms: 0
1175
+ variants: [],
1176
+ supported: [],
1177
+ deprecated: [],
1178
+ conflicting: []
1238
1179
  };
1239
1180
  }
1240
1181
  }
1241
- function compileKeyframes(name, stopsJson) {
1182
+ function validateThemeConfig(configJson) {
1242
1183
  const native = getNativeBridge();
1243
- if (!native?.compile_keyframes) throw new Error("compile_keyframes not available");
1244
- const resultJson = native.compile_keyframes(name, stopsJson);
1184
+ if (!native?.validate_variant_config) throw new Error("validate_variant_config not available");
1185
+ const resultJson = native.validate_variant_config(configJson);
1245
1186
  try {
1246
1187
  return JSON.parse(resultJson);
1247
1188
  } catch {
1248
1189
  return {
1249
- animation_id: "",
1250
- keyframes_css: "",
1251
- animation_rule: "",
1252
- duration_ms: 0
1190
+ is_valid: false,
1191
+ errors: ["Unable to parse configuration"],
1192
+ warnings: [],
1193
+ suggestions: []
1253
1194
  };
1254
1195
  }
1255
1196
  }
1256
- function compileTheme(tokensJson, themeName, prefix) {
1197
+ function resolveCascade(baseThemeJson, overridesJson) {
1257
1198
  const native = getNativeBridge();
1258
- if (!native?.compile_theme) throw new Error("compile_theme not available");
1259
- const resultJson = native.compile_theme(tokensJson, themeName, prefix);
1199
+ if (!native?.resolve_cascade) throw new Error("resolve_cascade not available");
1200
+ const resultJson = native.resolve_cascade(baseThemeJson, overridesJson);
1260
1201
  try {
1261
1202
  return JSON.parse(resultJson);
1262
1203
  } catch {
1263
1204
  return {
1264
- selector: ":root",
1265
- variables: [],
1266
- variables_css: "",
1267
- theme_name: themeName
1205
+ base_theme: {},
1206
+ user_overrides: {},
1207
+ merged_theme: {},
1208
+ conflict_resolutions: []
1268
1209
  };
1269
1210
  }
1270
1211
  }
1271
- function twMerge(classString) {
1272
- const native = getNativeBridge();
1273
- if (!native?.tw_merge) throw new Error("tw_merge not available");
1274
- return native.tw_merge(classString);
1275
- }
1276
- function twMergeMany(classStrings) {
1212
+ function resolveClassNames(classNames, themeJson) {
1277
1213
  const native = getNativeBridge();
1278
- if (!native?.tw_merge_many) throw new Error("tw_merge_many not available");
1279
- return native.tw_merge_many(classStrings);
1214
+ if (!native?.resolve_class_names) throw new Error("resolve_class_names not available");
1215
+ const resultJson = native.resolve_class_names(classNames, themeJson);
1216
+ try {
1217
+ return JSON.parse(resultJson);
1218
+ } catch {
1219
+ return [];
1220
+ }
1280
1221
  }
1281
- function twMergeWithSeparator(classString, options) {
1222
+ function resolveConflictGroup(groupName, themeJson) {
1282
1223
  const native = getNativeBridge();
1283
- if (!native?.tw_merge_with_separator)
1284
- throw new Error("tw_merge_with_separator not available");
1285
- const opts = {
1286
- separator: options.separator,
1287
- debug: options.debug
1288
- };
1289
- return native.tw_merge_with_separator(classString, opts);
1224
+ if (!native?.resolve_conflict_group)
1225
+ throw new Error("resolve_conflict_group not available");
1226
+ const resultJson = native.resolve_conflict_group(groupName, themeJson);
1227
+ try {
1228
+ return JSON.parse(resultJson);
1229
+ } catch {
1230
+ return {
1231
+ group_name: groupName,
1232
+ conflicting_classes: [],
1233
+ description: "",
1234
+ resolution_strategy: "last-wins"
1235
+ };
1236
+ }
1290
1237
  }
1291
- function twMergeManyWithSeparator(classStrings, options) {
1238
+ function resolveThemeValue(keyPath, themeJson) {
1292
1239
  const native = getNativeBridge();
1293
- if (!native?.tw_merge_many_with_separator)
1294
- throw new Error("tw_merge_many_with_separator not available");
1295
- const opts = {
1296
- separator: options.separator,
1297
- debug: options.debug
1298
- };
1299
- return native.tw_merge_many_with_separator(classStrings, opts);
1240
+ if (!native?.resolve_theme_value) throw new Error("resolve_theme_value not available");
1241
+ return native.resolve_theme_value(keyPath, themeJson);
1300
1242
  }
1301
- function twMergeRaw(classLists) {
1243
+ function resolveSimpleVariants(configJson) {
1302
1244
  const native = getNativeBridge();
1303
- if (!native?.tw_merge_raw) throw new Error("tw_merge_raw not available");
1304
- return native.tw_merge_raw(classLists);
1245
+ if (!native?.resolve_simple_variants) throw new Error("resolve_simple_variants not available");
1246
+ const resultJson = native.resolve_simple_variants(configJson);
1247
+ try {
1248
+ return JSON.parse(resultJson);
1249
+ } catch {
1250
+ return [];
1251
+ }
1305
1252
  }
1306
- var init_cssCompilationNative = __esm({
1307
- "packages/domain/compiler/src/cssCompilationNative.ts"() {
1253
+ var init_themeResolutionNative = __esm({
1254
+ "packages/domain/compiler/src/analyzer/themeResolutionNative.ts"() {
1308
1255
  init_nativeBridge();
1309
1256
  }
1310
1257
  });
1311
1258
 
1312
- // packages/domain/compiler/src/idRegistryNative.ts
1313
- function idRegistryCreate() {
1259
+ // packages/domain/compiler/src/analyzer/scannerNative.ts
1260
+ function scanWorkspace(root, extensions) {
1314
1261
  const native = getNativeBridge();
1315
- if (!native?.id_registry_create) throw new Error("id_registry_create not available");
1316
- return native.id_registry_create();
1262
+ if (!native?.scan_workspace) throw new Error("scan_workspace not available");
1263
+ return native.scan_workspace(root, extensions);
1317
1264
  }
1318
- function idRegistryGenerate(handle, name) {
1265
+ function extractClassesFromSourceNative(source) {
1319
1266
  const native = getNativeBridge();
1320
- if (!native?.id_registry_generate) throw new Error("id_registry_generate not available");
1321
- return native.id_registry_generate(handle, name);
1267
+ if (!native?.extract_classes_from_source) throw new Error("extract_classes_from_source not available");
1268
+ return native.extract_classes_from_source(source);
1322
1269
  }
1323
- function idRegistryLookup(handle, name) {
1270
+ function batchExtractClassesNative(filePaths) {
1324
1271
  const native = getNativeBridge();
1325
- if (!native?.id_registry_lookup) throw new Error("id_registry_lookup not available");
1326
- return native.id_registry_lookup(handle, name);
1272
+ if (!native?.batch_extract_classes) throw new Error("batch_extract_classes not available");
1273
+ return native.batch_extract_classes(filePaths);
1327
1274
  }
1328
- function idRegistryNext(handle) {
1275
+ function checkAgainstSafelistNative(classes, safelist) {
1329
1276
  const native = getNativeBridge();
1330
- if (!native?.id_registry_next) throw new Error("id_registry_next not available");
1331
- return native.id_registry_next(handle);
1277
+ if (!native?.check_against_safelist) throw new Error("check_against_safelist not available");
1278
+ return native.check_against_safelist(classes, safelist);
1332
1279
  }
1333
- function idRegistryDestroy(handle) {
1280
+ function scanFile(filePath) {
1334
1281
  const native = getNativeBridge();
1335
- if (!native?.id_registry_destroy) return;
1336
- native.id_registry_destroy(handle);
1282
+ if (!native?.scan_file) throw new Error("scan_file not available");
1283
+ return native.scan_file(filePath);
1337
1284
  }
1338
- function idRegistryReset(handle) {
1285
+ function collectFiles(root, extensions) {
1339
1286
  const native = getNativeBridge();
1340
- if (!native?.id_registry_reset) return;
1341
- native.id_registry_reset(handle);
1287
+ if (!native?.collect_files) throw new Error("collect_files not available");
1288
+ return native.collect_files(root, extensions);
1342
1289
  }
1343
- function idRegistrySnapshot(handle) {
1290
+ function walkAndPrefilterSourceFiles(root, extensions, _parallel) {
1344
1291
  const native = getNativeBridge();
1345
- if (!native?.id_registry_snapshot) throw new Error("id_registry_snapshot not available");
1346
- const snapshotJson = native.id_registry_snapshot(handle);
1292
+ if (!native?.walk_and_prefilter_source_files) throw new Error("walk_and_prefilter_source_files not available");
1293
+ return native.walk_and_prefilter_source_files(root, extensions);
1294
+ }
1295
+ function generateSubComponentTypes(root, outputPath) {
1296
+ const native = getNativeBridge();
1297
+ if (!native?.generate_sub_component_types) throw new Error("generate_sub_component_types not available");
1298
+ return native.generate_sub_component_types(root, outputPath);
1299
+ }
1300
+ var init_scannerNative = __esm({
1301
+ "packages/domain/compiler/src/analyzer/scannerNative.ts"() {
1302
+ init_nativeBridge();
1303
+ }
1304
+ });
1305
+
1306
+ // packages/domain/compiler/src/analyzer/index.ts
1307
+ var init_analyzer = __esm({
1308
+ "packages/domain/compiler/src/analyzer/index.ts"() {
1309
+ init_analyzerNative();
1310
+ init_themeResolutionNative();
1311
+ init_scannerNative();
1312
+ }
1313
+ });
1314
+
1315
+ // packages/domain/compiler/src/cache/cacheNative.ts
1316
+ function getCacheStatistics() {
1317
+ const native = getNativeBridge();
1318
+ if (!native?.get_cache_statistics) throw new Error("get_cache_statistics not available");
1319
+ const statsJson = native.get_cache_statistics();
1347
1320
  try {
1348
- return JSON.parse(snapshotJson);
1321
+ return JSON.parse(statsJson);
1349
1322
  } catch {
1350
1323
  return {
1351
- handle,
1352
- next_id: 0,
1353
- entries: [],
1354
- total_entries: 0
1324
+ parse_cache: { hits: 0, misses: 0, size: 0 },
1325
+ resolve_cache: { hits: 0, misses: 0, size: 0 },
1326
+ compile_cache: { hits: 0, misses: 0, size: 0 },
1327
+ css_gen_cache: { hits: 0, misses: 0, size: 0 },
1328
+ overall_hit_rate: 0,
1329
+ total_memory_bytes: 0
1355
1330
  };
1356
1331
  }
1357
1332
  }
1358
- function idRegistryActiveCount() {
1333
+ function clearAllCaches() {
1359
1334
  const native = getNativeBridge();
1360
- if (!native?.id_registry_active_count) throw new Error("id_registry_active_count not available");
1361
- return native.id_registry_active_count();
1335
+ if (!native?.clear_all_caches) return;
1336
+ try {
1337
+ native.clear_all_caches();
1338
+ } catch {
1339
+ }
1362
1340
  }
1363
- function registerPropertyName(propertyName) {
1341
+ function clearParseCache() {
1364
1342
  const native = getNativeBridge();
1365
- if (!native?.register_property_name)
1366
- throw new Error("register_property_name not available");
1367
- return native.register_property_name(propertyName);
1343
+ if (!native?.clear_parse_cache) return;
1344
+ try {
1345
+ native.clear_parse_cache();
1346
+ } catch {
1347
+ }
1368
1348
  }
1369
- function registerValueName(valueName) {
1349
+ function clearResolveCache() {
1370
1350
  const native = getNativeBridge();
1371
- if (!native?.register_value_name) throw new Error("register_value_name not available");
1372
- return native.register_value_name(valueName);
1351
+ if (!native?.clear_resolve_cache) return;
1352
+ try {
1353
+ native.clear_resolve_cache();
1354
+ } catch {
1355
+ }
1373
1356
  }
1374
- function propertyIdToString(propertyId) {
1357
+ function clearCompileCache() {
1375
1358
  const native = getNativeBridge();
1376
- if (!native?.property_id_to_string) throw new Error("property_id_to_string not available");
1377
- return native.property_id_to_string(propertyId);
1359
+ if (!native?.clear_compile_cache) return;
1360
+ try {
1361
+ native.clear_compile_cache();
1362
+ } catch {
1363
+ }
1378
1364
  }
1379
- function valueIdToString(valueId) {
1365
+ function clearCssGenCache() {
1380
1366
  const native = getNativeBridge();
1381
- if (!native?.value_id_to_string) throw new Error("value_id_to_string not available");
1382
- return native.value_id_to_string(valueId);
1367
+ if (!native?.clear_css_gen_cache) return;
1368
+ try {
1369
+ native.clear_css_gen_cache();
1370
+ } catch {
1371
+ }
1372
+ }
1373
+ function getCacheOptimizationHints(hitRatePercent, memoryUsedMb) {
1374
+ const native = getNativeBridge();
1375
+ if (!native?.get_cache_optimization_hints)
1376
+ throw new Error("get_cache_optimization_hints not available");
1377
+ const hintsJson = native.get_cache_optimization_hints(
1378
+ Math.min(100, Math.max(0, hitRatePercent)),
1379
+ Math.max(1, memoryUsedMb)
1380
+ );
1381
+ try {
1382
+ return JSON.parse(hintsJson);
1383
+ } catch {
1384
+ return {
1385
+ current_strategy: "unknown",
1386
+ recommended_strategy: "increase_size",
1387
+ estimated_improvement_percent: 0,
1388
+ suggested_memory_mb: 256,
1389
+ notes: ["Unable to analyze cache statistics"]
1390
+ };
1391
+ }
1383
1392
  }
1384
- function reverseLookupProperty(propertyId) {
1393
+ function estimateOptimalCacheConfig(totalBudgetMb, workloadType) {
1385
1394
  const native = getNativeBridge();
1386
- if (!native?.reverse_lookup_property)
1387
- throw new Error("reverse_lookup_property not available");
1388
- return native.reverse_lookup_property(propertyId);
1395
+ if (!native?.estimate_optimal_cache_config_native)
1396
+ throw new Error("estimate_optimal_cache_config_native not available");
1397
+ const configJson = native.estimate_optimal_cache_config_native(
1398
+ Math.max(64, totalBudgetMb),
1399
+ workloadType
1400
+ );
1401
+ try {
1402
+ return JSON.parse(configJson);
1403
+ } catch {
1404
+ return {
1405
+ parse_cache_size: 128,
1406
+ resolve_cache_size: 64,
1407
+ compile_cache_size: 256,
1408
+ css_gen_cache_size: 128,
1409
+ recommended_eviction_policy: "lru",
1410
+ ttl_seconds: 3600,
1411
+ expected_hit_rate_percent: 75
1412
+ };
1413
+ }
1389
1414
  }
1390
- function reverseLookupValue(valueId) {
1415
+ function cacheRead(cachePath) {
1391
1416
  const native = getNativeBridge();
1392
- if (!native?.reverse_lookup_value) throw new Error("reverse_lookup_value not available");
1393
- return native.reverse_lookup_value(valueId);
1417
+ if (!native?.cache_read) throw new Error("cache_read not available");
1418
+ const result = native.cache_read(cachePath);
1419
+ try {
1420
+ return JSON.parse(result.entries_json || "[]");
1421
+ } catch {
1422
+ return [];
1423
+ }
1394
1424
  }
1395
- function idRegistryExport(handle) {
1425
+ function cacheWrite(cachePath, entries) {
1396
1426
  const native = getNativeBridge();
1397
- if (!native?.id_registry_export) throw new Error("id_registry_export not available");
1398
- return native.id_registry_export(handle);
1427
+ if (!native?.cache_write) throw new Error("cache_write not available");
1428
+ try {
1429
+ const result = native.cache_write(
1430
+ cachePath,
1431
+ entries.map((e) => ({
1432
+ file: e.file,
1433
+ content_hash: e.contentHash,
1434
+ classes: e.classes,
1435
+ mtime_ms: e.mtimeMs,
1436
+ size_bytes: e.sizeBytes
1437
+ }))
1438
+ );
1439
+ return typeof result === "boolean" ? result : result === true;
1440
+ } catch {
1441
+ return false;
1442
+ }
1399
1443
  }
1400
- function idRegistryImport(importedData) {
1444
+ function cachePriority(mtimeMs, sizeBytes, hitCount) {
1401
1445
  const native = getNativeBridge();
1402
- if (!native?.id_registry_import) throw new Error("id_registry_import not available");
1403
- return native.id_registry_import(importedData);
1446
+ if (!native?.cache_priority) throw new Error("cache_priority not available");
1447
+ return native.cache_priority(mtimeMs, sizeBytes, hitCount);
1404
1448
  }
1405
- var init_idRegistryNative = __esm({
1406
- "packages/domain/compiler/src/idRegistryNative.ts"() {
1449
+ var init_cacheNative = __esm({
1450
+ "packages/domain/compiler/src/cache/cacheNative.ts"() {
1407
1451
  init_nativeBridge();
1408
1452
  }
1409
1453
  });
1410
1454
 
1411
- // packages/domain/compiler/src/redisNative.ts
1455
+ // packages/domain/compiler/src/cache/index.ts
1456
+ var init_cache = __esm({
1457
+ "packages/domain/compiler/src/cache/index.ts"() {
1458
+ init_cacheNative();
1459
+ }
1460
+ });
1461
+
1462
+ // packages/domain/compiler/src/redis/redisNative.ts
1412
1463
  function redisPing() {
1413
1464
  const native = getNativeBridge();
1414
1465
  if (!native?.redis_ping) throw new Error("redis_ping not available");
@@ -1651,12 +1702,19 @@ function redisDiagnose() {
1651
1702
  return native.redis_diagnose();
1652
1703
  }
1653
1704
  var init_redisNative = __esm({
1654
- "packages/domain/compiler/src/redisNative.ts"() {
1705
+ "packages/domain/compiler/src/redis/redisNative.ts"() {
1655
1706
  init_nativeBridge();
1656
1707
  }
1657
1708
  });
1658
1709
 
1659
- // packages/domain/compiler/src/watchSystemNative.ts
1710
+ // packages/domain/compiler/src/redis/index.ts
1711
+ var init_redis = __esm({
1712
+ "packages/domain/compiler/src/redis/index.ts"() {
1713
+ init_redisNative();
1714
+ }
1715
+ });
1716
+
1717
+ // packages/domain/compiler/src/watch/watchSystemNative.ts
1660
1718
  function startWatch(root_path, patterns) {
1661
1719
  const native = getNativeBridge();
1662
1720
  if (!native?.start_watch) throw new Error("start_watch not available");
@@ -1789,23 +1847,28 @@ function getCompilerDiagnostics() {
1789
1847
  return native.get_compiler_diagnostics();
1790
1848
  }
1791
1849
  var init_watchSystemNative = __esm({
1792
- "packages/domain/compiler/src/watchSystemNative.ts"() {
1850
+ "packages/domain/compiler/src/watch/watchSystemNative.ts"() {
1793
1851
  init_nativeBridge();
1794
1852
  }
1795
1853
  });
1796
1854
 
1855
+ // packages/domain/compiler/src/watch/index.ts
1856
+ var init_watch = __esm({
1857
+ "packages/domain/compiler/src/watch/index.ts"() {
1858
+ init_watchSystemNative();
1859
+ }
1860
+ });
1861
+
1797
1862
  // packages/domain/compiler/src/index.ts
1798
1863
  var src_exports = {};
1799
1864
  __export(src_exports, {
1800
1865
  BucketEngine: () => BucketEngine,
1801
1866
  IncrementalEngine: () => IncrementalEngine,
1802
1867
  adaptNativeResult: () => adaptNativeResult,
1803
- analyzeClassUsage: () => analyzeClassUsage,
1804
1868
  analyzeClassUsageNative: () => analyzeClassUsageNative,
1805
1869
  analyzeClasses: () => analyzeClasses,
1806
1870
  analyzeClassesNative: () => analyzeClassesNative,
1807
1871
  analyzeFile: () => analyzeFile,
1808
- analyzeRsc: () => analyzeRsc,
1809
1872
  analyzeRscNative: () => analyzeRscNative,
1810
1873
  analyzeVariantUsage: () => analyzeVariantUsage,
1811
1874
  astExtractClasses: () => astExtractClasses,
@@ -1819,7 +1882,6 @@ __export(src_exports, {
1819
1882
  cacheWrite: () => cacheWrite,
1820
1883
  checkAgainstSafelist: () => checkAgainstSafelist,
1821
1884
  checkAgainstSafelistNative: () => checkAgainstSafelistNative,
1822
- classifyAndSortClasses: () => classifyAndSortClasses,
1823
1885
  classifyAndSortClassesNative: () => classifyAndSortClassesNative,
1824
1886
  classifyNode: () => classifyNode,
1825
1887
  clearAllCaches: () => clearAllCaches,
@@ -1835,15 +1897,12 @@ __export(src_exports, {
1835
1897
  compileClasses: () => compileClasses,
1836
1898
  compileCssFromClasses: () => compileCssFromClasses,
1837
1899
  compileCssLightning: () => compileCssLightning,
1838
- compileCssNative: () => compileCssNative,
1839
1900
  compileCssNative2: () => compileCssNative2,
1840
1901
  compileKeyframes: () => compileKeyframes,
1841
1902
  compileTheme: () => compileTheme,
1842
1903
  compileToCss: () => compileToCss,
1843
1904
  compileToCssBatch: () => compileToCssBatch,
1844
- compileVariantTable: () => compileVariantTable,
1845
1905
  compileVariantTableNative: () => compileVariantTableNative,
1846
- compileVariants: () => compileVariants,
1847
1906
  computeIncrementalDiff: () => computeIncrementalDiff,
1848
1907
  createFingerprint: () => createFingerprint,
1849
1908
  detectConflicts: () => detectConflicts,
@@ -1876,7 +1935,7 @@ __export(src_exports, {
1876
1935
  getBucketEngine: () => getBucketEngine,
1877
1936
  getCacheOptimizationHints: () => getCacheOptimizationHints,
1878
1937
  getCacheStatistics: () => getCacheStatistics,
1879
- getCacheStats: () => getCacheStats2,
1938
+ getCacheStats: () => getCacheStats,
1880
1939
  getCompilationMetrics: () => getCompilationMetrics,
1881
1940
  getCompilerDiagnostics: () => getCompilerDiagnostics,
1882
1941
  getContentPaths: () => getContentPaths,
@@ -1887,7 +1946,6 @@ __export(src_exports, {
1887
1946
  getWatchStats: () => getWatchStats,
1888
1947
  hasTwUsage: () => hasTwUsage,
1889
1948
  hashContent: () => hashContent,
1890
- hoistComponents: () => hoistComponents,
1891
1949
  hoistComponentsNative: () => hoistComponentsNative,
1892
1950
  idRegistryActiveCount: () => idRegistryActiveCount,
1893
1951
  idRegistryCreate: () => idRegistryCreate,
@@ -1908,12 +1966,10 @@ __export(src_exports, {
1908
1966
  loadSafelist: () => loadSafelist,
1909
1967
  loadTailwindConfig: () => loadTailwindConfig,
1910
1968
  mergeClassesStatic: () => mergeClassesStatic,
1911
- mergeCssDeclarations: () => mergeCssDeclarations,
1912
1969
  mergeCssDeclarationsNative: () => mergeCssDeclarationsNative,
1913
1970
  minifyCss: () => minifyCss,
1914
1971
  normalizeAndDedupClasses: () => normalizeAndDedupClasses,
1915
1972
  normalizeClasses: () => normalizeClasses,
1916
- optimizeCss: () => optimizeCss,
1917
1973
  optimizeCssNative: () => optimizeCssNative,
1918
1974
  parseAtomicClass: () => parseAtomicClass,
1919
1975
  parseClasses: () => parseClasses,
@@ -1978,6 +2034,7 @@ __export(src_exports, {
1978
2034
  resolveVariants: () => resolveVariants,
1979
2035
  reverseLookupProperty: () => reverseLookupProperty,
1980
2036
  reverseLookupValue: () => reverseLookupValue,
2037
+ runCssPipeline: () => runCssPipeline,
1981
2038
  runElimination: () => runElimination,
1982
2039
  runLoaderTransform: () => runLoaderTransform,
1983
2040
  scanCacheOptimizations: () => scanCacheOptimizations,
@@ -2044,21 +2101,16 @@ function extractContainerCssFromSource(source) {
2044
2101
  }
2045
2102
  return rules.join("\n");
2046
2103
  }
2047
- var transformSource, hasTwUsage, isAlreadyTransformed, shouldProcess, compileCssFromClasses, buildStyleTag, compileCssNative, generateCssForClasses, extractAllClasses, extractClassesFromSource, astExtractClasses, parseClasses, normalizeClasses, mergeClassesStatic, normalizeAndDedupClasses, eliminateDeadCss, findDeadVariants, runElimination, optimizeCss, scanProjectUsage, extractComponentUsage, diffClassLists, batchExtractClasses, checkAgainstSafelist, hoistComponents, compileVariantTable, compileVariants, classifyAndSortClasses, mergeCssDeclarations, analyzeClassUsage, analyzeRsc, analyzeFile, analyzeVariantUsage, injectClientDirective, injectServerOnlyComment, analyzeClasses, generateSafelist, loadSafelist, loadTailwindConfig, getContentPaths, _CONTAINER_BREAKPOINTS, runLoaderTransform, shouldSkipFile, fileToRoute, getAllRoutes, getRouteClasses, registerFileClasses, registerGlobalClasses, _incrementalEngineInstance, getIncrementalEngine, resetIncrementalEngine, IncrementalEngine, getBucketEngine, resetBucketEngine, BucketEngine, classifyNode, detectConflicts, bucketSort, extractTwStateConfigs, generateStaticStateCss, extractAndGenerateStateCss;
2104
+ 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;
2048
2105
  var init_src = __esm({
2049
2106
  "packages/domain/compiler/src/index.ts"() {
2050
2107
  init_nativeBridge();
2051
- init_cssGeneratorNative();
2052
- init_scannerNative();
2053
- init_analyzerNative();
2054
- init_compilationNative();
2055
- init_cacheNative();
2056
- init_themeResolutionNative();
2057
- init_streamingNative();
2058
- init_cssCompilationNative();
2059
- init_idRegistryNative();
2060
- init_redisNative();
2061
- init_watchSystemNative();
2108
+ init_compiler();
2109
+ init_parser();
2110
+ init_analyzer();
2111
+ init_cache();
2112
+ init_redis();
2113
+ init_watch();
2062
2114
  transformSource = (source, opts) => {
2063
2115
  const native = getNativeBridge();
2064
2116
  if (!native?.transformSource) {
@@ -2098,217 +2150,69 @@ var init_src = __esm({
2098
2150
  }
2099
2151
  return result;
2100
2152
  };
2101
- buildStyleTag = (classes) => {
2102
- const result = compileCssFromClasses(classes);
2103
- return result?.code ? `<style data-tailwind-styled>${result.code}</style>` : "";
2104
- };
2105
- compileCssNative = (classes, prefix = null) => {
2106
- return compileCssFromClasses(classes, prefix);
2107
- };
2108
- generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
2109
- const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
2110
- const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
2111
- return result.css;
2112
- };
2113
- extractAllClasses = (source) => {
2114
- const native = getNativeBridge();
2115
- if (!native?.extractAllClasses) {
2116
- throw new Error("FATAL: Native binding 'extractAllClasses' is required but not available.");
2117
- }
2118
- return native.extractAllClasses(source) || [];
2119
- };
2120
- extractClassesFromSource = (source) => {
2121
- const native = getNativeBridge();
2122
- if (!native?.extractClassesFromSource) {
2123
- throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
2124
- }
2125
- const result = native.extractClassesFromSource(source);
2126
- return Array.isArray(result) ? result.join(" ") : String(result || "");
2127
- };
2128
- astExtractClasses = (source, _filename) => {
2129
- const native = getNativeBridge();
2130
- if (!native?.extractClassesFromSource) {
2131
- throw new Error("FATAL: Native binding 'extractClassesFromSource' is required but not available.");
2132
- }
2133
- return native.extractClassesFromSource(source) || [];
2134
- };
2135
- parseClasses = (raw) => {
2136
- const native = getNativeBridge();
2137
- if (!native?.parseClasses) {
2138
- throw new Error("FATAL: Native binding 'parseClasses' is required but not available.");
2139
- }
2140
- return native.parseClasses(raw) || [];
2141
- };
2142
- normalizeClasses = (raw) => {
2143
- const result = normalizeAndDedupClasses(raw);
2144
- return result?.normalized || "";
2145
- };
2146
- mergeClassesStatic = (classes) => {
2147
- const result = normalizeAndDedupClasses(classes);
2148
- return result?.normalized || "";
2149
- };
2150
- normalizeAndDedupClasses = (raw) => {
2151
- const native = getNativeBridge();
2152
- if (!native?.normalizeAndDedupClasses) {
2153
- throw new Error("FATAL: Native binding 'normalizeAndDedupClasses' is required but not available.");
2154
- }
2155
- const result = native.normalizeAndDedupClasses(raw);
2156
- return result || { normalized: "", duplicatesRemoved: 0, uniqueCount: 0 };
2157
- };
2158
- eliminateDeadCss = (css, deadClasses) => {
2159
- const native = getNativeBridge();
2160
- if (!native?.eliminateDeadCss) {
2161
- throw new Error("FATAL: Native binding 'eliminateDeadCss' is required but not available.");
2162
- }
2163
- return native.eliminateDeadCss(css, Array.from(deadClasses));
2164
- };
2165
- findDeadVariants = (variantConfig, usage) => {
2166
- const unused = [];
2167
- const configs = Array.isArray(variantConfig) ? variantConfig : [{ name: "__root__", variants: variantConfig }];
2168
- for (const component of configs) {
2169
- const componentUsage = usage[component.name] ?? /* @__PURE__ */ new Set();
2170
- const variants = component.variants;
2171
- for (const [key, values] of Object.entries(variants)) {
2172
- for (const [value] of Object.entries(values)) {
2173
- if (!componentUsage.has(`${key}:${value}`)) {
2174
- unused.push(`${component.name !== "__root__" ? `${component.name}/` : ""}${key}:${value}`);
2175
- }
2176
- }
2177
- }
2178
- }
2179
- return { unusedCount: unused.length, unused };
2180
- };
2181
- runElimination = (css, scanResult) => {
2182
- const native = getNativeBridge();
2183
- if (!native?.detectDeadCode) {
2184
- throw new Error("FATAL: Native binding 'detectDeadCode' is required but not available.");
2185
- }
2186
- const dead = native.detectDeadCode(JSON.stringify(scanResult), css);
2187
- return eliminateDeadCss(css, new Set(dead.deadInCss ?? []));
2188
- };
2189
- optimizeCss = (css) => {
2190
- const native = getNativeBridge();
2191
- if (!native?.optimizeCss) {
2192
- throw new Error("FATAL: Native binding 'optimizeCss' is required but not available.");
2193
- }
2194
- return native.optimizeCss(css);
2195
- };
2196
- scanProjectUsage = (dirs, cwd) => {
2197
- const files = dirs.map((dir) => path10__namespace.default.resolve(cwd, dir));
2198
- const results = batchExtractClasses(files) || [];
2199
- const combined = {};
2200
- for (const result of results) {
2201
- if (result.ok && result.classes) {
2202
- for (const cls of result.classes) {
2203
- if (!combined[cls]) combined[cls] = {};
2204
- combined[cls][result.file] = /* @__PURE__ */ new Set([cls]);
2205
- }
2206
- }
2207
- }
2208
- return combined;
2209
- };
2210
- extractComponentUsage = (source) => {
2211
- const native = getNativeBridge();
2212
- if (!native?.extractComponentUsage) {
2213
- throw new Error("FATAL: Native binding 'extractComponentUsage' is required but not available.");
2214
- }
2215
- return native.extractComponentUsage(source) || [];
2216
- };
2217
- diffClassLists = (previous, current) => {
2218
- const native = getNativeBridge();
2219
- if (!native?.diffClassLists) {
2220
- throw new Error("FATAL: Native binding 'diffClassLists' is required but not available.");
2221
- }
2222
- return native.diffClassLists(previous, current) || { added: [], removed: [], unchanged: [], hasChanges: false };
2223
- };
2224
- batchExtractClasses = (filePaths) => {
2225
- const native = getNativeBridge();
2226
- if (!native?.batchExtractClasses) {
2227
- throw new Error("FATAL: Native binding 'batchExtractClasses' is required but not available.");
2228
- }
2229
- return native.batchExtractClasses(filePaths) || [];
2230
- };
2231
- checkAgainstSafelist = (classes, safelist) => {
2232
- const native = getNativeBridge();
2233
- if (!native?.checkAgainstSafelist) {
2234
- throw new Error("FATAL: Native binding 'checkAgainstSafelist' is required but not available.");
2235
- }
2236
- return native.checkAgainstSafelist(classes, safelist) || { matched: [], unmatched: [], safelistSize: 0 };
2237
- };
2238
- hoistComponents = (source) => {
2239
- const native = getNativeBridge();
2240
- if (!native?.hoistComponents) {
2241
- throw new Error("FATAL: Native binding 'hoistComponents' is required but not available.");
2242
- }
2243
- return native.hoistComponents(source) || { code: source, hoisted: [], warnings: [] };
2244
- };
2245
- compileVariantTable = (configJson) => {
2246
- const native = getNativeBridge();
2247
- if (!native?.compileVariantTable) {
2248
- throw new Error("FATAL: Native binding 'compileVariantTable' is required but not available.");
2249
- }
2250
- return native.compileVariantTable(configJson) || { id: "", tableJson: "{}", keys: [], defaultKey: "", combinations: 0 };
2251
- };
2252
- compileVariants = (componentId, config) => {
2253
- return compileVariantTable(JSON.stringify({ componentId, ...config }));
2254
- };
2255
- classifyAndSortClasses = (classes) => {
2256
- const native = getNativeBridge();
2257
- if (!native?.classifyAndSortClasses) {
2258
- throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
2259
- }
2260
- return native.classifyAndSortClasses(classes) || [];
2261
- };
2262
- mergeCssDeclarations = (cssChunks) => {
2263
- const native = getNativeBridge();
2264
- if (!native?.mergeCssDeclarations) {
2265
- throw new Error("FATAL: Native binding 'mergeCssDeclarations' is required but not available.");
2266
- }
2267
- return native.mergeCssDeclarations(cssChunks) || { declarationsJson: "{}", declarationString: "", count: 0 };
2268
- };
2269
- analyzeClassUsage = (classes, scanResultJson, css) => {
2270
- const native = getNativeBridge();
2271
- if (!native?.analyzeClassUsage) {
2272
- throw new Error("FATAL: Native binding 'analyzeClassUsage' is required but not available.");
2273
- }
2274
- return native.analyzeClassUsage(classes, scanResultJson, css) || [];
2275
- };
2276
- analyzeRsc = (source, filename) => {
2277
- const native = getNativeBridge();
2278
- if (!native?.analyzeRsc) {
2279
- throw new Error("FATAL: Native binding 'analyzeRsc' is required but not available.");
2280
- }
2281
- return native.analyzeRsc(source, filename) || { isServer: true, needsClientDirective: false, clientReasons: [] };
2282
- };
2283
- analyzeFile = (source, filename) => {
2284
- const rsc = analyzeRsc(source, filename);
2285
- return {
2286
- isServer: rsc?.isServer ?? true,
2287
- needsClientDirective: rsc?.needsClientDirective ?? false,
2288
- clientReasons: rsc?.clientReasons ?? [],
2289
- interactiveClasses: [],
2290
- canStaticResolveVariants: true
2291
- };
2153
+ buildStyleTag = (classes) => {
2154
+ const result = compileCssFromClasses(classes);
2155
+ return result?.code ? `<style data-tailwind-styled>${result.code}</style>` : "";
2292
2156
  };
2293
- analyzeVariantUsage = (_source, _componentName, _variantKeys) => {
2294
- return { resolved: {}, dynamic: [] };
2157
+ generateCssForClasses = async (classes, _tailwindConfig, root, cssEntryContent, minify = false) => {
2158
+ try {
2159
+ const { runCssPipeline: runCssPipeline2 } = await Promise.resolve().then(() => (init_tailwindEngine(), tailwindEngine_exports));
2160
+ const result = await runCssPipeline2(classes, cssEntryContent, root, minify);
2161
+ return result.css;
2162
+ } catch {
2163
+ const native = getNativeBridge();
2164
+ if (!native?.transformSource) {
2165
+ throw new Error("FATAL: Native binding 'transformSource' is required but not available.");
2166
+ }
2167
+ const result = native.transformSource(classes.join(" "), {});
2168
+ return result?.code || "";
2169
+ }
2295
2170
  };
2296
- injectClientDirective = (source) => {
2297
- if (!source.includes('"use client"') && !source.includes("'use client'")) {
2298
- return '"use client";\n' + source;
2171
+ eliminateDeadCss = (css, deadClasses) => {
2172
+ const native = getNativeBridge();
2173
+ if (!native?.eliminateDeadCss) {
2174
+ throw new Error("FATAL: Native binding 'eliminateDeadCss' is required but not available.");
2299
2175
  }
2300
- return source;
2176
+ return native.eliminateDeadCss(css, Array.from(deadClasses));
2301
2177
  };
2302
- injectServerOnlyComment = (source) => {
2303
- return `/* @server-only */
2304
- ${source}`;
2178
+ findDeadVariants = (variantConfig, usage) => {
2179
+ const unused = [];
2180
+ const configs = Array.isArray(variantConfig) ? variantConfig : [{ name: "__root__", variants: variantConfig }];
2181
+ for (const component of configs) {
2182
+ const componentUsage = usage[component.name] ?? /* @__PURE__ */ new Set();
2183
+ const variants = component.variants;
2184
+ for (const [key, values] of Object.entries(variants)) {
2185
+ for (const [value] of Object.entries(values)) {
2186
+ if (!componentUsage.has(`${key}:${value}`)) {
2187
+ unused.push(`${component.name !== "__root__" ? `${component.name}/` : ""}${key}:${value}`);
2188
+ }
2189
+ }
2190
+ }
2191
+ }
2192
+ return { unusedCount: unused.length, unused };
2305
2193
  };
2306
- analyzeClasses = (filesJson, cwd, flags) => {
2194
+ runElimination = (css, scanResult) => {
2307
2195
  const native = getNativeBridge();
2308
- if (!native?.analyzeClasses) {
2309
- throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
2196
+ if (!native?.detectDeadCode) {
2197
+ throw new Error("FATAL: Native binding 'detectDeadCode' is required but not available.");
2310
2198
  }
2311
- return native.analyzeClasses(filesJson, cwd, flags);
2199
+ const dead = native.detectDeadCode(JSON.stringify(scanResult), css);
2200
+ return eliminateDeadCss(css, new Set(dead.deadInCss ?? []));
2201
+ };
2202
+ scanProjectUsage = (dirs, cwd) => {
2203
+ const { batchExtractClasses: batchExtractClasses2 } = (init_parser(), __toCommonJS(parser_exports));
2204
+ const files = dirs.map((dir) => path10__namespace.default.resolve(cwd, dir));
2205
+ const results = batchExtractClasses2(files) || [];
2206
+ const combined = {};
2207
+ for (const result of results) {
2208
+ if (result.ok && result.classes) {
2209
+ for (const cls of result.classes) {
2210
+ if (!combined[cls]) combined[cls] = {};
2211
+ combined[cls][result.file] = /* @__PURE__ */ new Set([cls]);
2212
+ }
2213
+ }
2214
+ }
2215
+ return combined;
2312
2216
  };
2313
2217
  generateSafelist = (scanDirs, outputPath, cwd) => {
2314
2218
  const classes = scanProjectUsage(scanDirs, cwd || process.cwd());
@@ -2373,7 +2277,8 @@ ${source}`;
2373
2277
  if (containerCss) cssChunks.push(containerCss);
2374
2278
  const combined = cssChunks.join("\n").trim();
2375
2279
  if (combined) staticCss = combined;
2376
- } catch {
2280
+ } catch (err) {
2281
+ console.debug("Static CSS extraction warning:", err);
2377
2282
  }
2378
2283
  return {
2379
2284
  code: result?.code || "",
@@ -2463,7 +2368,46 @@ ${source}`;
2463
2368
  return [];
2464
2369
  };
2465
2370
  bucketSort = (classes) => {
2466
- return classifyAndSortClasses(classes).map((c) => c.raw ?? c);
2371
+ const native = getNativeBridge();
2372
+ if (!native?.classifyAndSortClasses) {
2373
+ throw new Error("FATAL: Native binding 'classifyAndSortClasses' is required but not available.");
2374
+ }
2375
+ const sorted = native.classifyAndSortClasses(classes);
2376
+ return sorted.map((c) => c.raw ?? c);
2377
+ };
2378
+ analyzeFile = (source, filename) => {
2379
+ const native = getNativeBridge();
2380
+ if (!native?.analyzeRsc) {
2381
+ throw new Error("FATAL: Native binding 'analyzeRsc' is required but not available.");
2382
+ }
2383
+ const rsc = native.analyzeRsc(source, filename);
2384
+ return {
2385
+ isServer: rsc?.isServer ?? true,
2386
+ needsClientDirective: rsc?.needsClientDirective ?? false,
2387
+ clientReasons: rsc?.clientReasons ?? [],
2388
+ interactiveClasses: [],
2389
+ canStaticResolveVariants: true
2390
+ };
2391
+ };
2392
+ analyzeVariantUsage = (_source, _componentName, _variantKeys) => {
2393
+ return { resolved: {}, dynamic: [] };
2394
+ };
2395
+ injectClientDirective = (source) => {
2396
+ if (!source.includes('"use client"') && !source.includes("'use client'")) {
2397
+ return '"use client";\n' + source;
2398
+ }
2399
+ return source;
2400
+ };
2401
+ injectServerOnlyComment = (source) => {
2402
+ return `/* @server-only */
2403
+ ${source}`;
2404
+ };
2405
+ analyzeClasses = (filesJson, cwd, flags) => {
2406
+ const native = getNativeBridge();
2407
+ if (!native?.analyzeClasses) {
2408
+ throw new Error("FATAL: Native binding 'analyzeClasses' is required but not available.");
2409
+ }
2410
+ return native.analyzeClasses(filesJson, cwd, flags);
2467
2411
  };
2468
2412
  extractTwStateConfigs = (source, filename) => {
2469
2413
  const native = getNativeBridge();
@@ -2472,23 +2416,25 @@ ${source}`;
2472
2416
  }
2473
2417
  return native.extractTwStateConfigs(source, filename);
2474
2418
  };
2475
- generateStaticStateCss = (inputs, resolvedCss = null) => {
2476
- const native = getNativeBridge();
2477
- if (!native?.generateStaticStateCss) {
2478
- throw new Error("FATAL: Native binding 'generateStaticStateCss' is required but not available.");
2419
+ generateStaticStateCss = (entries, _themeConfig) => {
2420
+ const rules = [];
2421
+ for (const entry of entries) {
2422
+ const stateConfig = JSON.parse(entry.statesJson);
2423
+ for (const [stateName, classes] of Object.entries(stateConfig)) {
2424
+ rules.push({
2425
+ selector: `.${entry.componentName}[data-state="${stateName}"]`,
2426
+ declarations: classes,
2427
+ cssRule: `.${entry.componentName}[data-state="${stateName}"]{${classes}}`,
2428
+ componentName: entry.componentName,
2429
+ stateName
2430
+ });
2431
+ }
2479
2432
  }
2480
- return native.generateStaticStateCss(inputs, resolvedCss);
2433
+ return rules;
2481
2434
  };
2482
2435
  extractAndGenerateStateCss = (source, filename) => {
2483
- const native = getNativeBridge();
2484
- if (!native?.extractAndGenerateStateCss) {
2485
- const configs = extractTwStateConfigs(source, filename);
2486
- if (configs.length === 0) return [];
2487
- return generateStaticStateCss(
2488
- configs.map((c) => ({ tag: c.tag, componentName: c.componentName, statesJson: c.statesJson }))
2489
- );
2490
- }
2491
- return native.extractAndGenerateStateCss(source, filename);
2436
+ const entries = extractTwStateConfigs(source, filename);
2437
+ return generateStaticStateCss(entries);
2492
2438
  };
2493
2439
  }
2494
2440
  });
@@ -2497,75 +2443,219 @@ ${source}`;
2497
2443
  var internal_exports = {};
2498
2444
  __export(internal_exports, {
2499
2445
  adaptNativeResult: () => adaptNativeResult,
2500
- analyzeClassUsage: () => analyzeClassUsage,
2446
+ analyzeClassUsageNative: () => analyzeClassUsageNative,
2501
2447
  analyzeClasses: () => analyzeClasses,
2448
+ analyzeClassesNative: () => analyzeClassesNative,
2502
2449
  analyzeFile: () => analyzeFile,
2503
- analyzeRsc: () => analyzeRsc,
2450
+ analyzeRscNative: () => analyzeRscNative,
2504
2451
  analyzeVariantUsage: () => analyzeVariantUsage,
2505
2452
  astExtractClasses: () => astExtractClasses,
2453
+ atomicRegistrySize: () => atomicRegistrySize,
2506
2454
  batchExtractClasses: () => batchExtractClasses,
2455
+ batchExtractClassesNative: () => batchExtractClassesNative,
2507
2456
  bucketSort: () => bucketSort,
2508
2457
  buildStyleTag: () => buildStyleTag,
2458
+ cachePriority: () => cachePriority,
2459
+ cacheRead: () => cacheRead,
2460
+ cacheWrite: () => cacheWrite,
2509
2461
  checkAgainstSafelist: () => checkAgainstSafelist,
2510
- classifyAndSortClasses: () => classifyAndSortClasses,
2462
+ checkAgainstSafelistNative: () => checkAgainstSafelistNative,
2463
+ classifyAndSortClassesNative: () => classifyAndSortClassesNative,
2511
2464
  classifyNode: () => classifyNode,
2465
+ clearAllCaches: () => clearAllCaches,
2466
+ clearAtomicRegistry: () => clearAtomicRegistry,
2512
2467
  clearCache: () => clearCache,
2468
+ clearCompileCache: () => clearCompileCache,
2469
+ clearCssGenCache: () => clearCssGenCache,
2470
+ clearParseCache: () => clearParseCache,
2471
+ clearResolveCache: () => clearResolveCache,
2472
+ clearThemeCache: () => clearThemeCache,
2473
+ collectFiles: () => collectFiles,
2474
+ compileAnimation: () => compileAnimation,
2475
+ compileClass: () => compileClass,
2476
+ compileClasses: () => compileClasses,
2513
2477
  compileCssFromClasses: () => compileCssFromClasses,
2514
- compileCssNative: () => compileCssNative,
2515
- compileVariantTable: () => compileVariantTable,
2516
- compileVariants: () => compileVariants,
2478
+ compileCssLightning: () => compileCssLightning,
2479
+ compileCssNative2: () => compileCssNative2,
2480
+ compileKeyframes: () => compileKeyframes,
2481
+ compileTheme: () => compileTheme,
2482
+ compileToCss: () => compileToCss,
2483
+ compileToCssBatch: () => compileToCssBatch,
2484
+ compileVariantTableNative: () => compileVariantTableNative,
2485
+ computeIncrementalDiff: () => computeIncrementalDiff,
2486
+ createFingerprint: () => createFingerprint,
2517
2487
  detectConflicts: () => detectConflicts,
2488
+ detectDeadCode: () => detectDeadCode,
2518
2489
  diffClassLists: () => diffClassLists,
2519
2490
  eliminateDeadCss: () => eliminateDeadCss,
2491
+ eliminateDeadCssNative: () => eliminateDeadCssNative,
2492
+ emitPluginHook: () => emitPluginHook,
2493
+ estimateOptimalCacheConfig: () => estimateOptimalCacheConfig,
2520
2494
  extractAllClasses: () => extractAllClasses,
2521
2495
  extractAndGenerateStateCss: () => extractAndGenerateStateCss,
2496
+ extractAndGenerateStateCssNative: () => extractAndGenerateStateCssNative,
2522
2497
  extractClassesFromSource: () => extractClassesFromSource,
2498
+ extractClassesFromSourceNative: () => extractClassesFromSourceNative,
2523
2499
  extractComponentUsage: () => extractComponentUsage,
2524
2500
  extractContainerCssFromSource: () => extractContainerCssFromSource,
2501
+ extractTwContainerConfigs: () => extractTwContainerConfigs,
2525
2502
  extractTwStateConfigs: () => extractTwStateConfigs,
2503
+ extractTwStateConfigsNative: () => extractTwStateConfigsNative,
2526
2504
  fileToRoute: () => fileToRoute,
2527
2505
  findDeadVariants: () => findDeadVariants,
2506
+ generateAtomicCss: () => generateAtomicCss,
2528
2507
  generateCssForClasses: () => generateCssForClasses,
2529
- generateRawCss: () => generateRawCss,
2508
+ generateCssNative: () => generateCssNative,
2530
2509
  generateSafelist: () => generateSafelist,
2531
2510
  generateStaticStateCss: () => generateStaticStateCss,
2511
+ generateStaticStateCssNative: () => generateStaticStateCssNative,
2512
+ generateSubComponentTypes: () => generateSubComponentTypes,
2532
2513
  getAllRoutes: () => getAllRoutes,
2533
2514
  getBucketEngine: () => getBucketEngine,
2534
- getCacheStats: () => getCacheStats,
2515
+ getCacheOptimizationHints: () => getCacheOptimizationHints,
2516
+ getCacheStatistics: () => getCacheStatistics,
2517
+ getCacheStats: () => getCacheStats2,
2518
+ getCompilationMetrics: () => getCompilationMetrics,
2519
+ getCompilerDiagnostics: () => getCompilerDiagnostics,
2535
2520
  getContentPaths: () => getContentPaths,
2536
2521
  getIncrementalEngine: () => getIncrementalEngine,
2537
2522
  getNativeBridge: () => getNativeBridge,
2523
+ getPluginHooks: () => getPluginHooks,
2538
2524
  getRouteClasses: () => getRouteClasses,
2525
+ getWatchStats: () => getWatchStats,
2539
2526
  hasTwUsage: () => hasTwUsage,
2540
- hoistComponents: () => hoistComponents,
2527
+ hashContent: () => hashContent,
2528
+ hoistComponentsNative: () => hoistComponentsNative,
2529
+ idRegistryActiveCount: () => idRegistryActiveCount,
2530
+ idRegistryCreate: () => idRegistryCreate,
2531
+ idRegistryDestroy: () => idRegistryDestroy,
2532
+ idRegistryExport: () => idRegistryExport,
2533
+ idRegistryGenerate: () => idRegistryGenerate,
2534
+ idRegistryImport: () => idRegistryImport,
2535
+ idRegistryLookup: () => idRegistryLookup,
2536
+ idRegistryNext: () => idRegistryNext,
2537
+ idRegistryReset: () => idRegistryReset,
2538
+ idRegistrySnapshot: () => idRegistrySnapshot,
2541
2539
  injectClientDirective: () => injectClientDirective,
2542
2540
  injectServerOnlyComment: () => injectServerOnlyComment,
2541
+ injectStateHash: () => injectStateHash,
2543
2542
  isAlreadyTransformed: () => isAlreadyTransformed,
2543
+ isWatchRunning: () => isWatchRunning,
2544
+ layoutClassesToCss: () => layoutClassesToCss,
2544
2545
  loadSafelist: () => loadSafelist,
2545
2546
  loadTailwindConfig: () => loadTailwindConfig,
2546
2547
  mergeClassesStatic: () => mergeClassesStatic,
2547
- mergeCssDeclarations: () => mergeCssDeclarations,
2548
+ mergeCssDeclarationsNative: () => mergeCssDeclarationsNative,
2549
+ minifyCss: () => minifyCss,
2548
2550
  normalizeAndDedupClasses: () => normalizeAndDedupClasses,
2549
2551
  normalizeClasses: () => normalizeClasses,
2550
- optimizeCss: () => optimizeCss,
2552
+ optimizeCssNative: () => optimizeCssNative,
2553
+ parseAtomicClass: () => parseAtomicClass,
2551
2554
  parseClasses: () => parseClasses,
2555
+ pollWatchEvents: () => pollWatchEvents,
2556
+ processFileChange: () => processFileChange,
2557
+ processTailwindCssLightning: () => processTailwindCssLightning,
2558
+ propertyIdToString: () => propertyIdToString,
2559
+ pruneStaleCacheEntries: () => pruneStaleCacheEntries,
2560
+ rebuildWorkspaceResult: () => rebuildWorkspaceResult,
2561
+ redisCacheClear: () => redisCacheClear,
2562
+ redisCacheHitRate: () => redisCacheHitRate,
2563
+ redisCacheKeyCount: () => redisCacheKeyCount,
2564
+ redisCacheSize: () => redisCacheSize,
2565
+ redisCacheSync: () => redisCacheSync,
2566
+ redisClusterStatus: () => redisClusterStatus,
2567
+ redisDelete: () => redisDelete,
2568
+ redisDiagnose: () => redisDiagnose,
2569
+ redisDisableCacheWarming: () => redisDisableCacheWarming,
2570
+ redisDisableCluster: () => redisDisableCluster,
2571
+ redisDisablePersistence: () => redisDisablePersistence,
2572
+ redisEnableCacheWarming: () => redisEnableCacheWarming,
2573
+ redisEnableCluster: () => redisEnableCluster,
2574
+ redisEnablePersistence: () => redisEnablePersistence,
2575
+ redisExists: () => redisExists,
2576
+ redisExpirationGet: () => redisExpirationGet,
2577
+ redisExpirationSet: () => redisExpirationSet,
2578
+ redisFlushAll: () => redisFlushAll,
2579
+ redisFlushDb: () => redisFlushDb,
2580
+ redisGet: () => redisGet,
2581
+ redisGetEvictionPolicy: () => redisGetEvictionPolicy,
2582
+ redisInfo: () => redisInfo,
2583
+ redisMemoryStats: () => redisMemoryStats,
2584
+ redisMget: () => redisMget,
2585
+ redisMonitor: () => redisMonitor,
2586
+ redisMset: () => redisMset,
2587
+ redisOptimizeMemory: () => redisOptimizeMemory,
2588
+ redisPing: () => redisPing,
2589
+ redisPoolConnect: () => redisPoolConnect,
2590
+ redisPoolReconnect: () => redisPoolReconnect,
2591
+ redisPoolStats: () => redisPoolStats,
2592
+ redisPublish: () => redisPublish,
2593
+ redisReplicate: () => redisReplicate,
2594
+ redisReplicationStatus: () => redisReplicationStatus,
2595
+ redisSet: () => redisSet,
2596
+ redisSetEvictionPolicy: () => redisSetEvictionPolicy,
2597
+ redisSnapshot: () => redisSnapshot,
2598
+ redisSubscribe: () => redisSubscribe,
2552
2599
  registerFileClasses: () => registerFileClasses,
2553
2600
  registerGlobalClasses: () => registerGlobalClasses,
2601
+ registerPluginHook: () => registerPluginHook,
2602
+ registerPropertyName: () => registerPropertyName,
2603
+ registerValueName: () => registerValueName,
2554
2604
  resetBucketEngine: () => resetBucketEngine,
2605
+ resetCompilationMetrics: () => resetCompilationMetrics,
2555
2606
  resetIncrementalEngine: () => resetIncrementalEngine,
2607
+ resolveCascade: () => resolveCascade,
2608
+ resolveClassNames: () => resolveClassNames,
2609
+ resolveConflictGroup: () => resolveConflictGroup,
2610
+ resolveSimpleVariants: () => resolveSimpleVariants,
2611
+ resolveThemeValue: () => resolveThemeValue,
2612
+ resolveVariants: () => resolveVariants,
2613
+ reverseLookupProperty: () => reverseLookupProperty,
2614
+ reverseLookupValue: () => reverseLookupValue,
2556
2615
  runCssPipeline: () => runCssPipeline,
2557
2616
  runCssPipelineSync: () => runCssPipelineSync,
2558
2617
  runElimination: () => runElimination,
2559
2618
  runLoaderTransform: () => runLoaderTransform,
2619
+ scanCacheOptimizations: () => scanCacheOptimizations,
2620
+ scanFile: () => scanFile,
2621
+ scanFileNative: () => scanFileNative,
2622
+ scanFilesBatchNative: () => scanFilesBatchNative,
2560
2623
  scanProjectUsage: () => scanProjectUsage,
2624
+ scanWorkspace: () => scanWorkspace,
2561
2625
  shouldProcess: () => shouldProcess,
2562
2626
  shouldSkipFile: () => shouldSkipFile,
2563
- transformSource: () => transformSource
2627
+ startWatch: () => startWatch,
2628
+ stopWatch: () => stopWatch,
2629
+ toAtomicClasses: () => toAtomicClasses,
2630
+ transformSource: () => transformSource,
2631
+ twMerge: () => twMerge,
2632
+ twMergeMany: () => twMergeMany,
2633
+ twMergeManyWithSeparator: () => twMergeManyWithSeparator,
2634
+ twMergeRaw: () => twMergeRaw,
2635
+ twMergeWithSeparator: () => twMergeWithSeparator,
2636
+ unregisterPluginHook: () => unregisterPluginHook,
2637
+ validateCssOutput: () => validateCssOutput,
2638
+ validateThemeConfig: () => validateThemeConfig,
2639
+ valueIdToString: () => valueIdToString,
2640
+ walkAndPrefilterSourceFiles: () => walkAndPrefilterSourceFiles,
2641
+ watchAddPattern: () => watchAddPattern,
2642
+ watchClearAll: () => watchClearAll,
2643
+ watchEventTypeToString: () => watchEventTypeToString,
2644
+ watchGetActiveHandles: () => watchGetActiveHandles,
2645
+ watchPause: () => watchPause,
2646
+ watchRemovePattern: () => watchRemovePattern,
2647
+ watchResume: () => watchResume
2564
2648
  });
2565
2649
  var init_internal = __esm({
2566
2650
  "packages/domain/compiler/src/internal.ts"() {
2567
2651
  init_src();
2568
2652
  init_tailwindEngine();
2653
+ init_compiler();
2654
+ init_parser();
2655
+ init_analyzer();
2656
+ init_cache();
2657
+ init_redis();
2658
+ init_watch();
2569
2659
  }
2570
2660
  });
2571
2661
  function getNative() {