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
@@ -358,6 +358,54 @@ interface NativeBridge {
358
358
  reset_compilation_metrics?: () => string;
359
359
  validate_css_output?: (css: string) => string;
360
360
  get_compiler_diagnostics?: () => string;
361
+ configureCacheBackend?: (configJson: string) => string;
362
+ getRecommendedCacheConfig?: (workloadType: string) => string;
363
+ clearAllCachesNapi?: () => void;
364
+ clearResolveCacheNapi?: () => void;
365
+ clearCompileCacheNapi?: () => void;
366
+ clearCssGenCacheNapi?: () => void;
367
+ getResolverPoolStats?: () => string;
368
+ clearResolverPool?: () => string;
369
+ getCacheOptimizationHints?: () => string;
370
+ estimateStreamingBatchSize?: (targetMemoryMb: number) => string;
371
+ parseClass?: (input: string) => string;
372
+ compileClassNapi?: (input: string) => string;
373
+ getParseStats?: () => string;
374
+ clearParseCacheNapi?: () => void;
375
+ parseColorsNapi?: (colorsJson: string) => string | Record<string, string>;
376
+ parseSpacingNapi?: (spacingJson: string) => string | Record<string, string>;
377
+ parseTransformNapi?: (transformJson: string) => string | Record<string, string>;
378
+ normalizeColorNapi?: (color: string, opacity: string) => string;
379
+ sanitizeColorNapi?: (color: string) => string;
380
+ splitRgbaNapi?: (color: string) => string | {
381
+ r: number;
382
+ g: number;
383
+ b: number;
384
+ a: number;
385
+ };
386
+ validateColorsNapi?: (colorsJson: string) => boolean;
387
+ validateBreakpointsNapi?: (breakpointsJson: string) => boolean;
388
+ runHealthCheck?: () => void;
389
+ watchFiles?: (rootDir: string, optionsJson?: string | null) => string;
390
+ stopWatching?: (handleId: number) => string;
391
+ getWatchEvents?: (handleId: number, maxEvents?: number | null) => string;
392
+ getWatchPerformance?: () => string;
393
+ clearWatchStats?: () => string;
394
+ getActiveWatches?: () => number;
395
+ setWatchMetrics?: (metricName: string, value: string) => string;
396
+ setWatchAggregation?: (aggregationType: string) => string;
397
+ getOptimizationRecommendations?: (hitRate: number, memoryMb: number, classCount: number) => string;
398
+ estimateOptimalBatchSize?: (totalClasses: number, memoryAvailableMb: number) => number;
399
+ predictMemoryUsage?: (uniqueClasses: number, avgClassSizeBytes: number) => number;
400
+ recommendCachingStrategy?: (isSsr: boolean, memoryConstraintMb: number) => string;
401
+ benchmarkStreamingVsBuffered?: (classCount: number) => string;
402
+ getWeek6OptimizationStatus?: () => string;
403
+ scanCacheGet?: (filePath: string, contentHash: string) => string[] | null;
404
+ scanCachePut?: (filePath: string, contentHash: string, classes: string[], mtimeMs: number, size: number) => void;
405
+ scanCacheInvalidate?: (filePath: string) => void;
406
+ scanCacheStats?: () => {
407
+ size: number;
408
+ };
361
409
  }
362
410
  interface NativeTransformResult {
363
411
  code: string;
@@ -387,12 +435,10 @@ declare const adaptNativeResult: (raw: NativeTransformResult) => {
387
435
  * cssGeneratorNative.ts
388
436
  *
389
437
  * High-performance CSS generator using Rust compiler via NAPI binding.
390
- * Falls back to JavaScript Tailwind if Rust binding is unavailable.
438
+ * Rust-only implementation - no JavaScript fallback.
391
439
  */
392
440
  interface GenerateCssNativeOptions {
393
441
  theme: Record<string, unknown>;
394
- fallbackToJs?: boolean;
395
- logFallback?: boolean;
396
442
  }
397
443
  /**
398
444
  * Generate CSS from Tailwind classes using the Rust compiler.
@@ -458,77 +504,6 @@ declare function getCacheStats(): {
458
504
  */
459
505
  declare function clearThemeCache(): void;
460
506
 
461
- declare function scanWorkspace(root: string, extensions?: string[]): ScanWorkspaceResult;
462
- declare function extractClassesFromSourceNative(source: string): string[];
463
- declare function batchExtractClassesNative(filePaths: string[]): BatchExtractResult[];
464
- declare function checkAgainstSafelistNative(classes: string[], safelist: string[]): SafelistCheckResult;
465
- declare function scanFile(filePath: string): ScanFileResult;
466
- declare function collectFiles(root: string, extensions?: string[]): string[];
467
- declare function walkAndPrefilterSourceFiles(root: string, extensions?: string[], _parallel?: boolean): PrefilterFileResult[];
468
- declare function generateSubComponentTypes(root: string, outputPath?: string): string;
469
-
470
- /**
471
- * Detect dead CSS selectors in generated CSS.
472
- */
473
- declare function detectDeadCode(scanResultJson: string, css: string): DeadCodeResult;
474
- /**
475
- * Analyze class usage across scanned files.
476
- */
477
- declare function analyzeClassUsageNative(classes: string[], scanResultJson: string, css: string): ClassUsageItem[];
478
- /**
479
- * Analyze entire class list and generate CSS.
480
- */
481
- declare function analyzeClassesNative(filesJson: string, cwd: string, flags?: number): {
482
- css?: string;
483
- code: string;
484
- classes: string[];
485
- changed: boolean;
486
- rscJson?: string;
487
- metadataJson?: string;
488
- safelist?: string[];
489
- } | null;
490
- /**
491
- * Analyze React Server Component requirements.
492
- */
493
- declare function analyzeRscNative(source: string, filename: string): {
494
- isServer: boolean;
495
- needsClientDirective: boolean;
496
- clientReasons: string[];
497
- };
498
- /**
499
- * Optimize CSS by removing dead code and minifying.
500
- */
501
- declare function optimizeCssNative(css: string): {
502
- css: string;
503
- originalSize: number;
504
- optimizedSize: number;
505
- reductionPercentage: number;
506
- };
507
- /**
508
- * Process Tailwind CSS with Lightning CSS post-processing.
509
- */
510
- declare function processTailwindCssLightning(css: string): ProcessedCssResult;
511
- /**
512
- * Eliminate dead CSS selectors.
513
- */
514
- declare function eliminateDeadCssNative(css: string, deadClasses: string[]): string;
515
- /**
516
- * Hoist components from source code.
517
- */
518
- declare function hoistComponentsNative(source: string): HoistResult;
519
- /**
520
- * Compile variant configuration table.
521
- */
522
- declare function compileVariantTableNative(configJson: string): VariantTableResult;
523
- /**
524
- * Classify and sort classes by bucket.
525
- */
526
- declare function classifyAndSortClassesNative(classes: string[]): ClassifyResult[];
527
- /**
528
- * Merge CSS declarations from multiple chunks.
529
- */
530
- declare function mergeCssDeclarationsNative(cssChunks: string[]): MergeResult;
531
-
532
507
  /**
533
508
  * Compile Tailwind classes directly to CSS.
534
509
  */
@@ -598,1144 +573,1269 @@ declare function clearAtomicRegistry(): void;
598
573
  declare function atomicRegistrySize(): number;
599
574
 
600
575
  /**
601
- * cacheNative.ts
576
+ * cssCompilationNative.ts
602
577
  *
603
- * Phase 5.1: Cache Management - Advanced caching strategies and optimization
604
- * Exposes 9 cache-related Rust functions for improved performance tuning
578
+ * Phase 5.2: Advanced CSS Compilation - Complex CSS generation and transformations
579
+ * Exposes 12 CSS compilation functions for animations, themes, and merging
605
580
  */
606
581
  /**
607
- * Cache optimization hints and recommendations
582
+ * Compiled CSS rule result
608
583
  */
609
- interface CacheOptimizationHints {
610
- current_strategy: string;
611
- recommended_strategy: string;
612
- estimated_improvement_percent: number;
613
- suggested_memory_mb: number;
614
- notes: string[];
584
+ interface CompiledCssRule {
585
+ selector: string;
586
+ declarations: string;
587
+ properties: Array<{
588
+ key: string;
589
+ value: string;
590
+ }>;
591
+ specificity: number;
615
592
  }
616
593
  /**
617
- * Optimal cache configuration recommendations
594
+ * Compiled animation result
618
595
  */
619
- interface OptimalCacheConfig {
620
- parse_cache_size: number;
621
- resolve_cache_size: number;
622
- compile_cache_size: number;
623
- css_gen_cache_size: number;
624
- recommended_eviction_policy: string;
625
- ttl_seconds: number;
626
- expected_hit_rate_percent: number;
596
+ interface CompiledAnimation {
597
+ animation_id: string;
598
+ keyframes_css: string;
599
+ animation_rule: string;
600
+ duration_ms: number;
627
601
  }
628
602
  /**
629
- * Cache statistics from all layers
603
+ * Compiled theme result
630
604
  */
631
- interface CacheStatistics {
632
- parse_cache: {
633
- hits: number;
634
- misses: number;
635
- size: number;
636
- };
637
- resolve_cache: {
638
- hits: number;
639
- misses: number;
640
- size: number;
641
- };
642
- compile_cache: {
643
- hits: number;
644
- misses: number;
645
- size: number;
646
- };
647
- css_gen_cache: {
648
- hits: number;
649
- misses: number;
650
- size: number;
651
- };
652
- overall_hit_rate: number;
653
- total_memory_bytes: number;
605
+ interface CompiledTheme {
606
+ selector: string;
607
+ variables: Array<{
608
+ name: string;
609
+ value: string;
610
+ }>;
611
+ variables_css: string;
612
+ theme_name: string;
654
613
  }
655
614
  /**
656
- * Get comprehensive cache statistics across all layers
657
- * Useful for monitoring and optimization
658
- *
659
- * @returns Cache stats including hit rates, sizes, and recommendations
660
- * @example
661
- * ```ts
662
- * const stats = getCacheStatistics()
663
- * console.log(`Overall hit rate: ${stats.overall_hit_rate}%`)
664
- * console.log(`Total memory used: ${stats.total_memory_bytes / 1024}KB`)
665
- * ```
615
+ * CSS compile result with metadata
666
616
  */
667
- declare function getCacheStatistics(): CacheStatistics;
617
+ interface CssCompileResult {
618
+ css: string;
619
+ resolved_classes: string[];
620
+ unknown_classes: string[];
621
+ size_bytes: number;
622
+ duration_ms: number;
623
+ }
668
624
  /**
669
- * Clear all caches (parse, resolve, compile, CSS generation)
670
- * Use when switching themes or major configuration changes
625
+ * tw_merge options
626
+ */
627
+ interface TwMergeOptions {
628
+ separator?: string;
629
+ debug?: boolean;
630
+ }
631
+ /**
632
+ * Compile a single Tailwind class to CSS rule
633
+ * Full compilation pipeline: parse → resolve → generate
634
+ *
635
+ * @param input - Single Tailwind class (e.g., "md:hover:bg-blue-600/50")
636
+ * @returns Compiled CSS rule as JSON
671
637
  *
672
638
  * @example
673
639
  * ```ts
674
- * // Clear before switching themes
675
- * clearAllCaches()
676
- * const css = await generateCssNative(classes, { theme: newTheme })
640
+ * const rule = compileClass('md:hover:bg-blue-600')
641
+ * // Returns: {
642
+ * // selector: '.md\\:hover\\:bg-blue-600',
643
+ * // declarations: 'background-color: #2563eb;',
644
+ * // ...
645
+ * // }
677
646
  * ```
678
647
  */
679
- declare function clearAllCaches(): void;
680
- /**
681
- * Clear only the parse cache
682
- * Useful when parser behavior changes or cache gets stale
683
- */
684
- declare function clearParseCache(): void;
685
- /**
686
- * Clear only the resolve cache
687
- * Use when theme configuration changes
688
- */
689
- declare function clearResolveCache(): void;
690
- /**
691
- * Clear only the compile cache
692
- * Use when Tailwind configuration changes
693
- */
694
- declare function clearCompileCache(): void;
695
- /**
696
- * Clear only the CSS generation cache
697
- * Use when theme or layout changes
698
- */
699
- declare function clearCssGenCache(): void;
648
+ declare function compileClass(input: string): CompiledCssRule;
700
649
  /**
701
- * Get optimization hints based on current cache performance
702
- * Analyzes hit rates and suggests improvements
650
+ * Compile multiple Tailwind classes to CSS rules
651
+ * Batch processing with parallel compilation
703
652
  *
704
- * @param hitRatePercent - Current hit rate (0-100)
705
- * @param memoryUsedMb - Memory currently used in MB
706
- * @returns Optimization recommendations
653
+ * @param inputs - Array of Tailwind classes
654
+ * @returns JSON string of compiled rules
707
655
  *
708
656
  * @example
709
657
  * ```ts
710
- * const stats = getCacheStatistics()
711
- * const hints = getCacheOptimizationHints(
712
- * stats.overall_hit_rate,
713
- * stats.total_memory_bytes / (1024 * 1024)
714
- * )
715
- * console.log(`Recommendation: ${hints.recommended_strategy}`)
716
- * console.log(`Potential improvement: ${hints.estimated_improvement_percent}%`)
658
+ * const rules = compileClasses(['px-4', 'bg-blue-600', 'hover:opacity-80'])
717
659
  * ```
718
660
  */
719
- declare function getCacheOptimizationHints(hitRatePercent: number, memoryUsedMb: number): CacheOptimizationHints;
661
+ declare function compileClasses(inputs: string[]): CssCompileResult;
720
662
  /**
721
- * Estimate optimal cache configuration for your workload
722
- * Analyzes typical patterns and recommends sizes
663
+ * One-step: class CSS string
664
+ * Compiles and generates in single call
723
665
  *
724
- * @param totalBudgetMb - Maximum memory budget in MB
725
- * @param workloadType - "small" (< 100 files), "medium" (100-1000), "large" (1000+)
726
- * @returns Recommended cache configuration
666
+ * @param input - Single Tailwind class
667
+ * @param minify - Whether to minify output (default: false)
668
+ * @returns Generated CSS string
727
669
  *
728
670
  * @example
729
671
  * ```ts
730
- * const config = estimateOptimalCacheConfig(512, 'large')
731
- * console.log(`Parse cache: ${config.parse_cache_size}MB`)
732
- * console.log(`Expected hit rate: ${config.expected_hit_rate_percent}%`)
672
+ * const css = compileToCss('bg-blue-600')
673
+ * // Returns: ".bg-blue-600 { background-color: #2563eb; }"
674
+ *
675
+ * const minified = compileToCss('bg-blue-600', true)
676
+ * // Returns: ".bg-blue-600{background-color:#2563eb}"
733
677
  * ```
734
678
  */
735
- declare function estimateOptimalCacheConfig(totalBudgetMb: number, workloadType: "small" | "medium" | "large"): OptimalCacheConfig;
679
+ declare function compileToCss(input: string, minify?: boolean): string;
736
680
  /**
737
- * Read cache from disk (persistence)
738
- * Restores cached data from previous sessions
681
+ * Batch compile to CSS
682
+ * Compiles multiple classes and generates combined CSS
739
683
  *
740
- * @param cachePath - Path to cache file
741
- * @returns Entries loaded from disk
684
+ * @param inputs - Array of Tailwind classes
685
+ * @param minify - Whether to minify output
686
+ * @returns Combined CSS string
742
687
  *
743
688
  * @example
744
689
  * ```ts
745
- * const entries = cacheRead('./.tw-cache/scan.json')
746
- * // Warm up cache with persisted data
690
+ * const css = compileToCssBatch(['px-4', 'bg-blue-600'], true)
747
691
  * ```
748
692
  */
749
- declare function cacheRead(cachePath: string): Array<{
750
- file: string;
751
- contentHash: string;
752
- classes: string[];
753
- mtimeMs: number;
754
- sizeBytes: number;
755
- }>;
693
+ declare function compileToCssBatch(inputs: string[], minify?: boolean): string;
756
694
  /**
757
- * Write cache to disk (persistence)
758
- * Saves cached data for next session
695
+ * Minify CSS string
696
+ * Removes unnecessary whitespace and formatting
759
697
  *
760
- * @param cachePath - Path where cache should be written
761
- * @param entries - Cache entries to persist
762
- * @returns Success status
698
+ * @param css - Raw CSS string
699
+ * @returns Minified CSS (40-60% size reduction)
763
700
  *
764
701
  * @example
765
702
  * ```ts
766
- * const stats = getCacheStatistics()
767
- * const success = cacheWrite(
768
- * './.tw-cache/scan.json',
769
- * // entries array from previous scan
770
- * )
703
+ * const css = ".px-4 { padding-left: 1rem; padding-right: 1rem; }"
704
+ * const minified = minifyCss(css)
705
+ * // Returns: ".px-4{padding-left:1rem;padding-right:1rem}"
771
706
  * ```
772
707
  */
773
- declare function cacheWrite(cachePath: string, entries: Array<{
774
- file: string;
775
- contentHash: string;
776
- classes: string[];
777
- mtimeMs: number;
778
- sizeBytes: number;
779
- }>): boolean;
708
+ declare function minifyCss(css: string): string;
780
709
  /**
781
- * Calculate cache priority score for file ordering
782
- * Useful for prioritizing which files to scan first
710
+ * Compile animation from from/to states
711
+ * Generates @keyframes and animation rule
783
712
  *
784
- * @param mtimeMs - File modification time in milliseconds
785
- * @param sizeBytes - File size in bytes
786
- * @param hitCount - Number of times this file was accessed from cache
787
- * @returns Priority score (higher = process first)
713
+ * @param animationName - Animation name
714
+ * @param from - From state classes (e.g., "opacity-0 scale-95")
715
+ * @param to - To state classes (e.g., "opacity-100 scale-100")
716
+ * @returns Compiled animation with keyframes
788
717
  *
789
718
  * @example
790
719
  * ```ts
791
- * const priority = cachePriority(Date.now(), 2048, 5)
792
- * // Use priority to sort files for scanning
720
+ * const anim = compileAnimation('fade-in', 'opacity-0', 'opacity-100')
721
+ * console.log(anim.keyframes_css) // @keyframes fade-in { ... }
722
+ * console.log(anim.animation_rule) // animation: fade-in 300ms;
793
723
  * ```
794
724
  */
795
- declare function cachePriority(mtimeMs: number, sizeBytes: number, hitCount: number): number;
796
-
797
- /**
798
- * themeResolutionNative.ts
799
- *
800
- * Phase 5.1: Theme Resolution Extended - Advanced theme configuration handling
801
- * Exposes 7 theme resolution functions for complex Tailwind configurations
802
- */
803
- /**
804
- * Validation result for theme config
805
- */
806
- interface ThemeValidationResult {
807
- is_valid: boolean;
808
- errors: string[];
809
- warnings: string[];
810
- suggestions: string[];
811
- }
812
- /**
813
- * Resolved variant configuration
814
- */
815
- interface ResolvedVariantConfig {
816
- variants: string[];
817
- supported: string[];
818
- deprecated: string[];
819
- conflicting: string[];
820
- }
821
- /**
822
- * Theme cascade resolution result
823
- */
824
- interface ThemeCascadeResult {
825
- base_theme: Record<string, unknown>;
826
- user_overrides: Record<string, unknown>;
827
- merged_theme: Record<string, unknown>;
828
- conflict_resolutions: Array<{
829
- key: string;
830
- base_value: unknown;
831
- override_value: unknown;
832
- resolution: "override" | "merge" | "error";
833
- }>;
834
- }
835
- /**
836
- * Class name resolution from theme
837
- */
838
- interface ResolvedClassName {
839
- class_name: string;
840
- property: string;
841
- value: string;
842
- from_theme_path: string;
843
- is_responsive: boolean;
844
- variants: string[];
845
- }
846
- /**
847
- * Conflict group information
848
- */
849
- interface ConflictGroupInfo {
850
- group_name: string;
851
- conflicting_classes: string[];
852
- description: string;
853
- resolution_strategy: string;
854
- }
725
+ declare function compileAnimation(animationName: string, from: string, to: string): CompiledAnimation;
855
726
  /**
856
- * Get all resolved variants from theme configuration
857
- * Parses theme config and returns all variant prefixes
727
+ * Compile keyframes from stop definitions
728
+ * Creates @keyframes from percentage stops
858
729
  *
859
- * @param configJson - JSON string of theme configuration
860
- * @returns Resolved variants with metadata
730
+ * @param name - Keyframes name
731
+ * @param stopsJson - JSON array of stops: `[{"stop":"0%","classes":"opacity-0"}...]`
732
+ * @returns Compiled @keyframes rule
861
733
  *
862
734
  * @example
863
735
  * ```ts
864
- * const config = {
865
- * screens: { md: '768px', lg: '1024px' },
866
- * state: { hover: '&:hover', focus: '&:focus' }
867
- * }
868
- * const variants = resolveVariants(JSON.stringify(config))
869
- * console.log(variants.variants) // ['md', 'lg', 'hover', 'focus', ...]
736
+ * const kf = compileKeyframes('slide-in', JSON.stringify([
737
+ * { stop: '0%', classes: 'translate-x-full' },
738
+ * { stop: '100%', classes: 'translate-x-0' }
739
+ * ]))
870
740
  * ```
871
741
  */
872
- declare function resolveVariants(configJson: string): ResolvedVariantConfig;
742
+ declare function compileKeyframes(name: string, stopsJson: string): CompiledAnimation;
873
743
  /**
874
- * Validate theme configuration for correctness
875
- * Checks for common issues and provides warnings
744
+ * Compile theme to CSS variables
745
+ * Converts token map to CSS custom properties
876
746
  *
877
- * @param configJson - JSON string of theme configuration
878
- * @returns Validation result with errors and suggestions
747
+ * @param tokensJson - Theme tokens as JSON
748
+ * @param themeName - Theme name ("light", "dark", etc.)
749
+ * @param prefix - CSS variable prefix (e.g., "tw" → "--tw-color-primary")
750
+ * @returns Compiled theme with variables CSS
879
751
  *
880
752
  * @example
881
753
  * ```ts
882
- * const result = validateThemeConfig(JSON.stringify(myTheme))
883
- * if (!result.is_valid) {
884
- * console.error('Errors:', result.errors)
885
- * console.warn('Warnings:', result.warnings)
886
- * }
754
+ * const theme = compileTheme(
755
+ * JSON.stringify({ colors: { blue: { 600: '#2563eb' } } }),
756
+ * 'light',
757
+ * 'tw'
758
+ * )
759
+ * // Returns CSS: :root { --tw-color-blue-600: #2563eb; }
887
760
  * ```
888
761
  */
889
- declare function validateThemeConfig(configJson: string): ThemeValidationResult;
762
+ declare function compileTheme(tokensJson: string, themeName: string, prefix: string): CompiledTheme;
890
763
  /**
891
- * Resolve theme cascade (base + overrides)
892
- * Merges base theme with user overrides intelligently
764
+ * Merge conflicting Tailwind classes
765
+ * Resolves conflicts intelligently (last-one-wins by default)
893
766
  *
894
- * @param baseThemeJson - Base theme configuration
895
- * @param overridesJson - User overrides configuration
896
- * @returns Merged theme with conflict information
767
+ * @param classString - Space-separated class string (e.g., "px-4 px-8 bg-red-500 bg-blue-600")
768
+ * @returns Merged classes with conflicts resolved
897
769
  *
898
770
  * @example
899
771
  * ```ts
900
- * const cascade = resolveCascade(
901
- * JSON.stringify(baseTheme),
902
- * JSON.stringify(userOverrides)
903
- * )
904
- * console.log(cascade.merged_theme)
905
- * console.log('Conflicts resolved:', cascade.conflict_resolutions.length)
772
+ * const merged = twMerge('px-4 px-8 bg-red-500 bg-blue-600')
773
+ * // Returns: "px-8 bg-blue-600"
906
774
  * ```
907
775
  */
908
- declare function resolveCascade(baseThemeJson: string, overridesJson: string): ThemeCascadeResult;
776
+ declare function twMerge(classString: string): string;
909
777
  /**
910
- * Resolve class names from theme
911
- * Maps Tailwind class names to theme values
778
+ * Merge multiple class strings
779
+ * Combines and resolves conflicts across multiple strings
912
780
  *
913
- * @param classNames - Array of Tailwind class names (e.g., ["text-lg", "bg-blue-600"])
914
- * @param themeJson - Theme configuration
915
- * @returns Resolved class name information
781
+ * @param classStrings - Array of class strings
782
+ * @returns Merged result
916
783
  *
917
784
  * @example
918
785
  * ```ts
919
- * const resolved = resolveClassNames(
920
- * ['text-lg', 'bg-blue-600', 'md:p-4'],
921
- * JSON.stringify(theme)
922
- * )
923
- * resolved.forEach(item => {
924
- * console.log(`${item.class_name} -> ${item.property}: ${item.value}`)
925
- * })
786
+ * const merged = twMergeMany([
787
+ * 'px-4 hover:bg-blue-600',
788
+ * 'px-8 hover:opacity-80'
789
+ * ])
790
+ * // Returns: "px-8 hover:bg-blue-600 hover:opacity-80"
926
791
  * ```
927
792
  */
928
- declare function resolveClassNames(classNames: string[], themeJson: string): ResolvedClassName[];
793
+ declare function twMergeMany(classStrings: string[]): string;
929
794
  /**
930
- * Get conflict group information
931
- * Identifies classes that conflict with each other
795
+ * Merge with custom separator
796
+ * Useful for non-standard class separators
932
797
  *
933
- * @param groupName - Conflict group name (e.g., "display", "position", "flex-direction")
934
- * @param themeJson - Theme configuration
935
- * @returns Information about the conflict group
798
+ * @param classString - Classes to merge
799
+ * @param options - Merge options (separator, debug)
800
+ * @returns Merged classes
936
801
  *
937
802
  * @example
938
803
  * ```ts
939
- * const info = resolveConflictGroup('display', JSON.stringify(theme))
940
- * console.log('Conflicting classes:', info.conflicting_classes)
941
- * console.log('Strategy:', info.resolution_strategy)
804
+ * const merged = twMergeWithSeparator(
805
+ * 'px-4,px-8,bg-red-500,bg-blue-600',
806
+ * { separator: ',' }
807
+ * )
942
808
  * ```
943
809
  */
944
- declare function resolveConflictGroup(groupName: string, themeJson: string): ConflictGroupInfo;
810
+ declare function twMergeWithSeparator(classString: string, options: TwMergeOptions): string;
945
811
  /**
946
- * Resolve theme value from key path
947
- * Navigates nested theme config to find values
948
- *
949
- * @param keyPath - Dot-separated path (e.g., "colors.blue.600")
950
- * @param themeJson - Theme configuration
951
- * @returns Resolved value or null if not found
812
+ * Merge many with custom separator
813
+ * Batch merge with custom separator
952
814
  *
953
- * @example
954
- * ```ts
955
- * const color = resolveThemeValue('colors.blue.600', JSON.stringify(theme))
956
- * console.log(color) // "#2563eb" or similar
957
- * ```
815
+ * @param classStrings - Array of class strings
816
+ * @param options - Merge options
817
+ * @returns Merged result
958
818
  */
959
- declare function resolveThemeValue(keyPath: string, themeJson: string): string | null;
819
+ declare function twMergeManyWithSeparator(classStrings: string[], options: TwMergeOptions): string;
960
820
  /**
961
- * Get all simple variants from configuration
962
- * Returns variants that don't require complex selector nesting
821
+ * Raw merge from class lists
822
+ * Direct merge without preprocessing
963
823
  *
964
- * @param configJson - Theme/variant configuration
965
- * @returns Array of simple variant names
824
+ * @param classLists - Array of class lists
825
+ * @returns Merged classes
966
826
  *
967
827
  * @example
968
828
  * ```ts
969
- * const simpleVariants = resolveSimpleVariants(JSON.stringify(config))
970
- * console.log(simpleVariants)
971
- * // ["hover", "focus", "active", "group-hover", ...]
829
+ * const merged = twMergeRaw(['px-4 px-8', 'bg-red bg-blue'])
972
830
  * ```
973
831
  */
974
- declare function resolveSimpleVariants(configJson: string): string[];
832
+ declare function twMergeRaw(classLists: string[]): string;
975
833
 
976
834
  /**
977
- * streamingNative.ts
835
+ * idRegistryNative.ts
978
836
  *
979
- * Phase 5.1: Streaming & Incremental Processing - Handle file changes efficiently
980
- * Exposes 8 functions for real-time incremental compilation
981
- */
982
- /**
983
- * File change notification
984
- */
985
- interface FileChangeEvent {
986
- file_path: string;
987
- event_type: "added" | "modified" | "deleted";
988
- old_content?: string;
989
- new_content?: string;
990
- timestamp_ms: number;
991
- }
992
- /**
993
- * Processed file change result
994
- */
995
- interface ProcessedFileChange {
996
- file_path: string;
997
- status: "processed" | "skipped" | "error";
998
- old_classes: string[];
999
- new_classes: string[];
1000
- added_classes: string[];
1001
- removed_classes: string[];
1002
- changed: boolean;
1003
- fingerprint: string;
1004
- error?: string;
1005
- }
1006
- /**
1007
- * Diff between two scan results
1008
- */
1009
- interface FileDiff {
1010
- added_files: string[];
1011
- removed_files: string[];
1012
- modified_files: string[];
1013
- added_classes: string[];
1014
- removed_classes: string[];
1015
- total_changes: number;
1016
- }
1017
- /**
1018
- * File fingerprint for change detection
1019
- */
1020
- interface FileFingerprint {
1021
- file_path: string;
1022
- content_hash: string;
1023
- size_bytes: number;
1024
- mtime_ms: number;
1025
- class_hash: string;
1026
- signature: string;
1027
- }
1028
- /**
1029
- * Incremental diff result
1030
- */
1031
- interface IncrementalDiffResult {
1032
- is_changed: boolean;
1033
- changes_count: number;
1034
- diff: FileDiff;
1035
- processing_time_ms: number;
1036
- }
1037
- /**
1038
- * State injection result
1039
- */
1040
- interface StateInjectionResult {
1041
- injected: boolean;
1042
- state_hash: string;
1043
- affected_files: number;
1044
- total_injected_bytes: number;
1045
- }
1046
- /**
1047
- * Stale entry pruning result
837
+ * Phase 5.2: ID Registry Management - Efficient ID generation and lookup
838
+ * Exposes 16 ID registry functions for deterministic class/component identification
1048
839
  */
1049
- interface PruneResult {
1050
- entries_before: number;
1051
- entries_after: number;
1052
- entries_removed: number;
1053
- freed_bytes: number;
1054
- }
1055
840
  /**
1056
- * Rebuilt workspace result
841
+ * Registry snapshot data
1057
842
  */
1058
- interface RebuildWorkspaceResult {
1059
- total_files_scanned: number;
1060
- total_classes_found: number;
1061
- unique_classes: number;
1062
- build_time_ms: number;
1063
- files_with_changes: number;
843
+ interface RegistrySnapshot {
844
+ handle: number;
845
+ next_id: number;
846
+ entries: Array<{
847
+ name: string;
848
+ id: number;
849
+ }>;
850
+ total_entries: number;
1064
851
  }
1065
852
  /**
1066
- * Process a single file change event
1067
- * Called when a file is added, modified, or deleted
853
+ * Create a new ID generator
854
+ * Returns a handle to be used in subsequent operations
1068
855
  *
1069
- * @param fileChangeJson - JSON string describing the file change
1070
- * @returns Processing result with class changes
856
+ * @returns Generator handle (u32)
1071
857
  *
1072
858
  * @example
1073
859
  * ```ts
1074
- * const change = processFileChange(JSON.stringify({
1075
- * file_path: 'src/Button.tsx',
1076
- * event_type: 'modified',
1077
- * new_content: 'export const Button = ...',
1078
- * timestamp_ms: Date.now()
1079
- * }))
1080
- *
1081
- * console.log('Added classes:', change.added_classes)
1082
- * console.log('Removed classes:', change.removed_classes)
860
+ * const handle = idRegistryCreate()
861
+ * // Use handle for all subsequent operations
862
+ * try {
863
+ * const id = idRegistryGenerate(handle, 'MyComponent')
864
+ * // ... use id ...
865
+ * } finally {
866
+ * idRegistryDestroy(handle) // Clean up
867
+ * }
1083
868
  * ```
1084
869
  */
1085
- declare function processFileChange(fileChangeJson: string): ProcessedFileChange;
870
+ declare function idRegistryCreate(): number;
1086
871
  /**
1087
- * Compute incremental diff between old and new scan results
1088
- * Efficient way to identify only what changed
872
+ * Generate a new ID for a name
873
+ * Same name always returns same ID (deterministic)
1089
874
  *
1090
- * @param oldScanJson - JSON string of previous scan result
1091
- * @param newScanJson - JSON string of new scan result
1092
- * @returns Diff showing what changed
875
+ * @param handle - Generator handle from idRegistryCreate()
876
+ * @param name - Identifier name (e.g., component name, class name)
877
+ * @returns Generated ID
1093
878
  *
1094
879
  * @example
1095
880
  * ```ts
1096
- * const oldResult = scanWorkspace('./src')
1097
- * // ... files changed ...
1098
- * const newResult = scanWorkspace('./src')
1099
- *
1100
- * const diff = computeIncrementalDiff(
1101
- * JSON.stringify(oldResult),
1102
- * JSON.stringify(newResult)
1103
- * )
1104
- *
1105
- * if (diff.is_changed) {
1106
- * console.log(`${diff.changes_count} files changed`)
1107
- * console.log('Added:', diff.diff.added_classes)
1108
- * console.log('Removed:', diff.diff.removed_classes)
1109
- * }
881
+ * const handle = idRegistryCreate()
882
+ * const id1 = idRegistryGenerate(handle, 'Button') // Returns 1
883
+ * const id2 = idRegistryGenerate(handle, 'Button') // Returns 1 (same)
884
+ * const id3 = idRegistryGenerate(handle, 'Card') // Returns 2 (different)
1110
885
  * ```
1111
886
  */
1112
- declare function computeIncrementalDiff(oldScanJson: string, newScanJson: string): IncrementalDiffResult;
887
+ declare function idRegistryGenerate(handle: number, name: string): number;
1113
888
  /**
1114
- * Create a fingerprint of a file for change detection
1115
- * Use fingerprints to quickly check if file needs reprocessing
889
+ * Lookup existing ID for a name
890
+ * Returns -1 if not found
1116
891
  *
1117
- * @param filePath - Path to file
1118
- * @param fileContent - File content
1119
- * @returns File fingerprint
892
+ * @param handle - Generator handle
893
+ * @param name - Name to look up
894
+ * @returns ID if found, -1 if not found
1120
895
  *
1121
896
  * @example
1122
897
  * ```ts
1123
- * const fingerprint = createFingerprint('src/Button.tsx', fileContent)
1124
- * // Store fingerprint, check later if content changed
1125
- * const newFingerprint = createFingerprint('src/Button.tsx', newContent)
1126
- * if (fingerprint.signature !== newFingerprint.signature) {
1127
- * // Content changed, needs reprocessing
898
+ * const id = idRegistryLookup(handle, 'Button')
899
+ * if (id !== -1) {
900
+ * console.log(`Button has ID: ${id}`)
901
+ * } else {
902
+ * console.log('Button not in registry yet')
1128
903
  * }
1129
904
  * ```
1130
905
  */
1131
- declare function createFingerprint(filePath: string, fileContent: string): FileFingerprint;
906
+ declare function idRegistryLookup(handle: number, name: string): number;
1132
907
  /**
1133
- * Inject state hash into compiled CSS
1134
- * Marks CSS with version/state hash for cache busting
908
+ * Get the next ID that would be assigned
909
+ * Useful for knowing how many unique IDs exist
1135
910
  *
1136
- * @param css - Raw CSS string
1137
- * @param stateHash - State hash to inject
1138
- * @returns Modified CSS with injected state
911
+ * @param handle - Generator handle
912
+ * @returns Next available ID
1139
913
  *
1140
914
  * @example
1141
915
  * ```ts
1142
- * const css = compileCssNative2(['px-4', 'bg-blue-600'])
1143
- * const withState = injectStateHash(css, 'v5-hash-123')
1144
- * // CSS now includes version marker for cache control
916
+ * const handle = idRegistryCreate()
917
+ * idRegistryGenerate(handle, 'Button')
918
+ * idRegistryGenerate(handle, 'Card')
919
+ * const nextId = idRegistryNext(handle) // Returns 2 (next available)
1145
920
  * ```
1146
921
  */
1147
- declare function injectStateHash(css: string, stateHash: string): StateInjectionResult;
922
+ declare function idRegistryNext(handle: number): number;
1148
923
  /**
1149
- * Prune stale entries from cache
1150
- * Removes old/unused cache entries to free memory
924
+ * Destroy a registry (clean up resources)
925
+ * Must be called when done with registry
1151
926
  *
1152
- * @param maxAgeSeconds - Remove entries older than this many seconds
1153
- * @param maxEntries - Keep only this many most-recent entries
1154
- * @returns Result of pruning operation
927
+ * @param handle - Generator handle
1155
928
  *
1156
929
  * @example
1157
930
  * ```ts
1158
- * // Remove cache entries older than 1 hour, keep max 10000 entries
1159
- * const result = pruneStaleCacheEntries(3600, 10000)
1160
- * console.log(`Freed ${result.freed_bytes / 1024}KB`)
931
+ * const handle = idRegistryCreate()
932
+ * try {
933
+ * // Use registry
934
+ * } finally {
935
+ * idRegistryDestroy(handle)
936
+ * }
1161
937
  * ```
1162
938
  */
1163
- declare function pruneStaleCacheEntries(maxAgeSeconds: number, maxEntries: number): PruneResult;
939
+ declare function idRegistryDestroy(handle: number): void;
1164
940
  /**
1165
- * Rebuild workspace result from scratch
1166
- * Useful after major configuration changes
941
+ * Reset registry to initial state
942
+ * Clears all entries but reuses handle
1167
943
  *
1168
- * @param rootDir - Root directory to scan
1169
- * @param extensions - File extensions to scan (e.g., [".tsx", ".ts"])
1170
- * @returns Rebuilt workspace result
944
+ * @param handle - Generator handle
1171
945
  *
1172
946
  * @example
1173
947
  * ```ts
1174
- * const result = rebuildWorkspaceResult('./src', ['.tsx', '.ts'])
1175
- * console.log(`Found ${result.unique_classes} unique classes`)
1176
- * console.log(`${result.files_with_changes} files had changes`)
948
+ * const handle = idRegistryCreate()
949
+ * idRegistryGenerate(handle, 'Component1')
950
+ * idRegistryGenerate(handle, 'Component2')
951
+ * idRegistryReset(handle) // Clear all
952
+ * const id = idRegistryNext(handle) // Back to 0
1177
953
  * ```
1178
954
  */
1179
- declare function rebuildWorkspaceResult(rootDir: string, extensions?: string[]): RebuildWorkspaceResult;
955
+ declare function idRegistryReset(handle: number): void;
1180
956
  /**
1181
- * Scan a single file with incremental state
1182
- * Returns only new/changed classes since last scan
957
+ * Get snapshot of current registry state
958
+ * Useful for serialization/debugging
1183
959
  *
1184
- * @param filePath - Path to file
1185
- * @param fileContent - File content
1186
- * @returns Updated classes and change status
960
+ * @param handle - Generator handle
961
+ * @returns Snapshot with all entries
1187
962
  *
1188
963
  * @example
1189
964
  * ```ts
1190
- * // On file change, get only what changed
1191
- * const file = scanFileNative('src/Button.tsx', newContent)
1192
- * if (file.changed) {
1193
- * console.log('Added:', file.added_classes)
1194
- * console.log('Removed:', file.removed_classes)
1195
- * }
965
+ * const handle = idRegistryCreate()
966
+ * idRegistryGenerate(handle, 'Button')
967
+ * idRegistryGenerate(handle, 'Card')
968
+ * const snapshot = idRegistrySnapshot(handle)
969
+ * console.log(JSON.stringify(snapshot, null, 2))
1196
970
  * ```
1197
971
  */
1198
- declare function scanFileNative(filePath: string, fileContent: string): {
1199
- file: string;
1200
- classes: string[];
1201
- added_classes: string[];
1202
- removed_classes: string[];
1203
- changed: boolean;
1204
- };
972
+ declare function idRegistrySnapshot(handle: number): RegistrySnapshot;
1205
973
  /**
1206
- * Scan multiple files in batch with incremental state
1207
- * Efficient batch processing of file changes
974
+ * Get count of active registries
975
+ * Useful for monitoring resource usage
1208
976
  *
1209
- * @param filesJson - JSON array of {file, content} objects
1210
- * @returns Results for each file
977
+ * @returns Number of active generator handles
1211
978
  *
1212
979
  * @example
1213
980
  * ```ts
1214
- * const files = [
1215
- * { file: 'src/Button.tsx', content: newButtonContent },
1216
- * { file: 'src/Card.tsx', content: newCardContent }
1217
- * ]
1218
- * const results = scanFilesBatchNative(JSON.stringify(files))
981
+ * console.log(`Active registries: ${idRegistryActiveCount()}`)
1219
982
  * ```
1220
983
  */
1221
- declare function scanFilesBatchNative(filesJson: string): Array<{
1222
- file: string;
1223
- classes: string[];
1224
- changed: boolean;
1225
- }>;
1226
-
1227
- /**
1228
- * cssCompilationNative.ts
1229
- *
1230
- * Phase 5.2: Advanced CSS Compilation - Complex CSS generation and transformations
1231
- * Exposes 12 CSS compilation functions for animations, themes, and merging
1232
- */
1233
- /**
1234
- * Compiled CSS rule result
1235
- */
1236
- interface CompiledCssRule {
1237
- selector: string;
1238
- declarations: string;
1239
- properties: Array<{
1240
- key: string;
1241
- value: string;
1242
- }>;
1243
- specificity: number;
1244
- }
1245
- /**
1246
- * Compiled animation result
1247
- */
1248
- interface CompiledAnimation {
1249
- animation_id: string;
1250
- keyframes_css: string;
1251
- animation_rule: string;
1252
- duration_ms: number;
1253
- }
1254
- /**
1255
- * Compiled theme result
1256
- */
1257
- interface CompiledTheme {
1258
- selector: string;
1259
- variables: Array<{
1260
- name: string;
1261
- value: string;
1262
- }>;
1263
- variables_css: string;
1264
- theme_name: string;
1265
- }
1266
- /**
1267
- * CSS compile result with metadata
1268
- */
1269
- interface CssCompileResult {
1270
- css: string;
1271
- resolved_classes: string[];
1272
- unknown_classes: string[];
1273
- size_bytes: number;
1274
- duration_ms: number;
1275
- }
1276
- /**
1277
- * tw_merge options
1278
- */
1279
- interface TwMergeOptions {
1280
- separator?: string;
1281
- debug?: boolean;
1282
- }
984
+ declare function idRegistryActiveCount(): number;
1283
985
  /**
1284
- * Compile a single Tailwind class to CSS rule
1285
- * Full compilation pipeline: parse resolve → generate
986
+ * Register a property name with global registry
987
+ * Maps property names to consistent IDs
1286
988
  *
1287
- * @param input - Single Tailwind class (e.g., "md:hover:bg-blue-600/50")
1288
- * @returns Compiled CSS rule as JSON
989
+ * @param propertyName - Property name (e.g., "background-color")
990
+ * @returns Assigned property ID
1289
991
  *
1290
992
  * @example
1291
993
  * ```ts
1292
- * const rule = compileClass('md:hover:bg-blue-600')
1293
- * // Returns: {
1294
- * // selector: '.md\\:hover\\:bg-blue-600',
1295
- * // declarations: 'background-color: #2563eb;',
1296
- * // ...
1297
- * // }
994
+ * const bgColorId = registerPropertyName('background-color')
995
+ * const paddingId = registerPropertyName('padding')
1298
996
  * ```
1299
997
  */
1300
- declare function compileClass(input: string): CompiledCssRule;
998
+ declare function registerPropertyName(propertyName: string): number;
1301
999
  /**
1302
- * Compile multiple Tailwind classes to CSS rules
1303
- * Batch processing with parallel compilation
1000
+ * Register a value name with global registry
1001
+ * Maps values to consistent IDs
1304
1002
  *
1305
- * @param inputs - Array of Tailwind classes
1306
- * @returns JSON string of compiled rules
1003
+ * @param valueName - Value name (e.g., "blue-600")
1004
+ * @returns Assigned value ID
1307
1005
  *
1308
1006
  * @example
1309
1007
  * ```ts
1310
- * const rules = compileClasses(['px-4', 'bg-blue-600', 'hover:opacity-80'])
1008
+ * const blueId = registerValueName('blue-600')
1009
+ * const redId = registerValueName('red-500')
1311
1010
  * ```
1312
1011
  */
1313
- declare function compileClasses(inputs: string[]): CssCompileResult;
1012
+ declare function registerValueName(valueName: string): number;
1314
1013
  /**
1315
- * One-step: class CSS string
1316
- * Compiles and generates in single call
1014
+ * Convert property ID back to name
1015
+ * Reverse lookup for serialized data
1317
1016
  *
1318
- * @param input - Single Tailwind class
1319
- * @param minify - Whether to minify output (default: false)
1320
- * @returns Generated CSS string
1017
+ * @param propertyId - Property ID
1018
+ * @returns Property name or empty string if not found
1321
1019
  *
1322
1020
  * @example
1323
1021
  * ```ts
1324
- * const css = compileToCss('bg-blue-600')
1325
- * // Returns: ".bg-blue-600 { background-color: #2563eb; }"
1326
- *
1327
- * const minified = compileToCss('bg-blue-600', true)
1328
- * // Returns: ".bg-blue-600{background-color:#2563eb}"
1022
+ * const bgColorId = registerPropertyName('background-color')
1023
+ * const name = propertyIdToString(bgColorId)
1024
+ * console.log(name) // "background-color"
1329
1025
  * ```
1330
1026
  */
1331
- declare function compileToCss(input: string, minify?: boolean): string;
1027
+ declare function propertyIdToString(propertyId: number): string;
1332
1028
  /**
1333
- * Batch compile to CSS
1334
- * Compiles multiple classes and generates combined CSS
1029
+ * Convert value ID back to name
1030
+ * Reverse lookup for serialized data
1335
1031
  *
1336
- * @param inputs - Array of Tailwind classes
1337
- * @param minify - Whether to minify output
1338
- * @returns Combined CSS string
1032
+ * @param valueId - Value ID
1033
+ * @returns Value name or empty string if not found
1339
1034
  *
1340
1035
  * @example
1341
1036
  * ```ts
1342
- * const css = compileToCssBatch(['px-4', 'bg-blue-600'], true)
1037
+ * const blueId = registerValueName('blue-600')
1038
+ * const value = valueIdToString(blueId)
1039
+ * console.log(value) // "blue-600"
1343
1040
  * ```
1344
1041
  */
1345
- declare function compileToCssBatch(inputs: string[], minify?: boolean): string;
1042
+ declare function valueIdToString(valueId: number): string;
1346
1043
  /**
1347
- * Minify CSS string
1348
- * Removes unnecessary whitespace and formatting
1349
- *
1350
- * @param css - Raw CSS string
1351
- * @returns Minified CSS (40-60% size reduction)
1044
+ * Reverse lookup: find property by ID
1045
+ * Alternative way to look up property names
1352
1046
  *
1353
- * @example
1354
- * ```ts
1355
- * const css = ".px-4 { padding-left: 1rem; padding-right: 1rem; }"
1356
- * const minified = minifyCss(css)
1357
- * // Returns: ".px-4{padding-left:1rem;padding-right:1rem}"
1358
- * ```
1047
+ * @param propertyId - Property ID to look up
1048
+ * @returns Property name
1359
1049
  */
1360
- declare function minifyCss(css: string): string;
1050
+ declare function reverseLookupProperty(propertyId: number): string;
1361
1051
  /**
1362
- * Compile animation from from/to states
1363
- * Generates @keyframes and animation rule
1364
- *
1365
- * @param animationName - Animation name
1366
- * @param from - From state classes (e.g., "opacity-0 scale-95")
1367
- * @param to - To state classes (e.g., "opacity-100 scale-100")
1368
- * @returns Compiled animation with keyframes
1052
+ * Reverse lookup: find value by ID
1053
+ * Alternative way to look up value names
1369
1054
  *
1370
- * @example
1371
- * ```ts
1372
- * const anim = compileAnimation('fade-in', 'opacity-0', 'opacity-100')
1373
- * console.log(anim.keyframes_css) // @keyframes fade-in { ... }
1374
- * console.log(anim.animation_rule) // animation: fade-in 300ms;
1375
- * ```
1055
+ * @param valueId - Value ID to look up
1056
+ * @returns Value name
1376
1057
  */
1377
- declare function compileAnimation(animationName: string, from: string, to: string): CompiledAnimation;
1058
+ declare function reverseLookupValue(valueId: number): string;
1378
1059
  /**
1379
- * Compile keyframes from stop definitions
1380
- * Creates @keyframes from percentage stops
1060
+ * Export registry state for persistence
1061
+ * Useful for saving/restoring registry data
1381
1062
  *
1382
- * @param name - Keyframes name
1383
- * @param stopsJson - JSON array of stops: `[{"stop":"0%","classes":"opacity-0"}...]`
1384
- * @returns Compiled @keyframes rule
1063
+ * @param handle - Generator handle
1064
+ * @returns Serialized registry state
1385
1065
  *
1386
1066
  * @example
1387
1067
  * ```ts
1388
- * const kf = compileKeyframes('slide-in', JSON.stringify([
1389
- * { stop: '0%', classes: 'translate-x-full' },
1390
- * { stop: '100%', classes: 'translate-x-0' }
1391
- * ]))
1068
+ * const exported = idRegistryExport(handle)
1069
+ * // Save to file/database
1392
1070
  * ```
1393
1071
  */
1394
- declare function compileKeyframes(name: string, stopsJson: string): CompiledAnimation;
1072
+ declare function idRegistryExport(handle: number): string;
1395
1073
  /**
1396
- * Compile theme to CSS variables
1397
- * Converts token map to CSS custom properties
1074
+ * Import registry state
1075
+ * Restore registry from saved state
1398
1076
  *
1399
- * @param tokensJson - Theme tokens as JSON
1400
- * @param themeName - Theme name ("light", "dark", etc.)
1401
- * @param prefix - CSS variable prefix (e.g., "tw" → "--tw-color-primary")
1402
- * @returns Compiled theme with variables CSS
1077
+ * @param importedData - Serialized registry data
1078
+ * @returns New handle with imported data
1403
1079
  *
1404
1080
  * @example
1405
1081
  * ```ts
1406
- * const theme = compileTheme(
1407
- * JSON.stringify({ colors: { blue: { 600: '#2563eb' } } }),
1408
- * 'light',
1409
- * 'tw'
1410
- * )
1411
- * // Returns CSS: :root { --tw-color-blue-600: #2563eb; }
1082
+ * const handle = idRegistryImport(savedData)
1083
+ * // Registry restored with same IDs
1412
1084
  * ```
1413
1085
  */
1414
- declare function compileTheme(tokensJson: string, themeName: string, prefix: string): CompiledTheme;
1086
+ declare function idRegistryImport(importedData: string): number;
1087
+
1415
1088
  /**
1416
- * Merge conflicting Tailwind classes
1417
- * Resolves conflicts intelligently (last-one-wins by default)
1418
- *
1419
- * @param classString - Space-separated class string (e.g., "px-4 px-8 bg-red-500 bg-blue-600")
1420
- * @returns Merged classes with conflicts resolved
1089
+ * streamingNative.ts
1421
1090
  *
1422
- * @example
1423
- * ```ts
1424
- * const merged = twMerge('px-4 px-8 bg-red-500 bg-blue-600')
1425
- * // Returns: "px-8 bg-blue-600"
1426
- * ```
1091
+ * Phase 5.1: Streaming & Incremental Processing - Handle file changes efficiently
1092
+ * Exposes 8 functions for real-time incremental compilation
1427
1093
  */
1428
- declare function twMerge(classString: string): string;
1429
1094
  /**
1430
- * Merge multiple class strings
1431
- * Combines and resolves conflicts across multiple strings
1432
- *
1433
- * @param classStrings - Array of class strings
1434
- * @returns Merged result
1435
- *
1436
- * @example
1437
- * ```ts
1438
- * const merged = twMergeMany([
1439
- * 'px-4 hover:bg-blue-600',
1440
- * 'px-8 hover:opacity-80'
1441
- * ])
1442
- * // Returns: "px-8 hover:bg-blue-600 hover:opacity-80"
1443
- * ```
1095
+ * File change notification
1444
1096
  */
1445
- declare function twMergeMany(classStrings: string[]): string;
1097
+ interface FileChangeEvent {
1098
+ file_path: string;
1099
+ event_type: "added" | "modified" | "deleted";
1100
+ old_content?: string;
1101
+ new_content?: string;
1102
+ timestamp_ms: number;
1103
+ }
1446
1104
  /**
1447
- * Merge with custom separator
1448
- * Useful for non-standard class separators
1449
- *
1450
- * @param classString - Classes to merge
1451
- * @param options - Merge options (separator, debug)
1452
- * @returns Merged classes
1453
- *
1454
- * @example
1455
- * ```ts
1456
- * const merged = twMergeWithSeparator(
1457
- * 'px-4,px-8,bg-red-500,bg-blue-600',
1458
- * { separator: ',' }
1105
+ * Processed file change result
1106
+ */
1107
+ interface ProcessedFileChange {
1108
+ file_path: string;
1109
+ status: "processed" | "skipped" | "error";
1110
+ old_classes: string[];
1111
+ new_classes: string[];
1112
+ added_classes: string[];
1113
+ removed_classes: string[];
1114
+ changed: boolean;
1115
+ fingerprint: string;
1116
+ error?: string;
1117
+ }
1118
+ /**
1119
+ * Diff between two scan results
1120
+ */
1121
+ interface FileDiff {
1122
+ added_files: string[];
1123
+ removed_files: string[];
1124
+ modified_files: string[];
1125
+ added_classes: string[];
1126
+ removed_classes: string[];
1127
+ total_changes: number;
1128
+ }
1129
+ /**
1130
+ * File fingerprint for change detection
1131
+ */
1132
+ interface FileFingerprint {
1133
+ file_path: string;
1134
+ content_hash: string;
1135
+ size_bytes: number;
1136
+ mtime_ms: number;
1137
+ class_hash: string;
1138
+ signature: string;
1139
+ }
1140
+ /**
1141
+ * Incremental diff result
1142
+ */
1143
+ interface IncrementalDiffResult {
1144
+ is_changed: boolean;
1145
+ changes_count: number;
1146
+ diff: FileDiff;
1147
+ processing_time_ms: number;
1148
+ }
1149
+ /**
1150
+ * State injection result
1151
+ */
1152
+ interface StateInjectionResult {
1153
+ injected: boolean;
1154
+ state_hash: string;
1155
+ affected_files: number;
1156
+ total_injected_bytes: number;
1157
+ }
1158
+ /**
1159
+ * Stale entry pruning result
1160
+ */
1161
+ interface PruneResult {
1162
+ entries_before: number;
1163
+ entries_after: number;
1164
+ entries_removed: number;
1165
+ freed_bytes: number;
1166
+ }
1167
+ /**
1168
+ * Rebuilt workspace result
1169
+ */
1170
+ interface RebuildWorkspaceResult {
1171
+ total_files_scanned: number;
1172
+ total_classes_found: number;
1173
+ unique_classes: number;
1174
+ build_time_ms: number;
1175
+ files_with_changes: number;
1176
+ }
1177
+ /**
1178
+ * Process a single file change event
1179
+ * Called when a file is added, modified, or deleted
1180
+ *
1181
+ * @param fileChangeJson - JSON string describing the file change
1182
+ * @returns Processing result with class changes
1183
+ *
1184
+ * @example
1185
+ * ```ts
1186
+ * const change = processFileChange(JSON.stringify({
1187
+ * file_path: 'src/Button.tsx',
1188
+ * event_type: 'modified',
1189
+ * new_content: 'export const Button = ...',
1190
+ * timestamp_ms: Date.now()
1191
+ * }))
1192
+ *
1193
+ * console.log('Added classes:', change.added_classes)
1194
+ * console.log('Removed classes:', change.removed_classes)
1195
+ * ```
1196
+ */
1197
+ declare function processFileChange(fileChangeJson: string): ProcessedFileChange;
1198
+ /**
1199
+ * Compute incremental diff between old and new scan results
1200
+ * Efficient way to identify only what changed
1201
+ *
1202
+ * @param oldScanJson - JSON string of previous scan result
1203
+ * @param newScanJson - JSON string of new scan result
1204
+ * @returns Diff showing what changed
1205
+ *
1206
+ * @example
1207
+ * ```ts
1208
+ * const oldResult = scanWorkspace('./src')
1209
+ * // ... files changed ...
1210
+ * const newResult = scanWorkspace('./src')
1211
+ *
1212
+ * const diff = computeIncrementalDiff(
1213
+ * JSON.stringify(oldResult),
1214
+ * JSON.stringify(newResult)
1459
1215
  * )
1216
+ *
1217
+ * if (diff.is_changed) {
1218
+ * console.log(`${diff.changes_count} files changed`)
1219
+ * console.log('Added:', diff.diff.added_classes)
1220
+ * console.log('Removed:', diff.diff.removed_classes)
1221
+ * }
1460
1222
  * ```
1461
1223
  */
1462
- declare function twMergeWithSeparator(classString: string, options: TwMergeOptions): string;
1224
+ declare function computeIncrementalDiff(oldScanJson: string, newScanJson: string): IncrementalDiffResult;
1463
1225
  /**
1464
- * Merge many with custom separator
1465
- * Batch merge with custom separator
1226
+ * Create a fingerprint of a file for change detection
1227
+ * Use fingerprints to quickly check if file needs reprocessing
1466
1228
  *
1467
- * @param classStrings - Array of class strings
1468
- * @param options - Merge options
1469
- * @returns Merged result
1229
+ * @param filePath - Path to file
1230
+ * @param fileContent - File content
1231
+ * @returns File fingerprint
1232
+ *
1233
+ * @example
1234
+ * ```ts
1235
+ * const fingerprint = createFingerprint('src/Button.tsx', fileContent)
1236
+ * // Store fingerprint, check later if content changed
1237
+ * const newFingerprint = createFingerprint('src/Button.tsx', newContent)
1238
+ * if (fingerprint.signature !== newFingerprint.signature) {
1239
+ * // Content changed, needs reprocessing
1240
+ * }
1241
+ * ```
1470
1242
  */
1471
- declare function twMergeManyWithSeparator(classStrings: string[], options: TwMergeOptions): string;
1243
+ declare function createFingerprint(filePath: string, fileContent: string): FileFingerprint;
1472
1244
  /**
1473
- * Raw merge from class lists
1474
- * Direct merge without preprocessing
1245
+ * Inject state hash into compiled CSS
1246
+ * Marks CSS with version/state hash for cache busting
1247
+ *
1248
+ * @param css - Raw CSS string
1249
+ * @param stateHash - State hash to inject
1250
+ * @returns Modified CSS with injected state
1251
+ *
1252
+ * @example
1253
+ * ```ts
1254
+ * const css = compileCssNative2(['px-4', 'bg-blue-600'])
1255
+ * const withState = injectStateHash(css, 'v5-hash-123')
1256
+ * // CSS now includes version marker for cache control
1257
+ * ```
1258
+ */
1259
+ declare function injectStateHash(css: string, stateHash: string): StateInjectionResult;
1260
+ /**
1261
+ * Prune stale entries from cache
1262
+ * Removes old/unused cache entries to free memory
1263
+ *
1264
+ * @param maxAgeSeconds - Remove entries older than this many seconds
1265
+ * @param maxEntries - Keep only this many most-recent entries
1266
+ * @returns Result of pruning operation
1267
+ *
1268
+ * @example
1269
+ * ```ts
1270
+ * // Remove cache entries older than 1 hour, keep max 10000 entries
1271
+ * const result = pruneStaleCacheEntries(3600, 10000)
1272
+ * console.log(`Freed ${result.freed_bytes / 1024}KB`)
1273
+ * ```
1274
+ */
1275
+ declare function pruneStaleCacheEntries(maxAgeSeconds: number, maxEntries: number): PruneResult;
1276
+ /**
1277
+ * Rebuild workspace result from scratch
1278
+ * Useful after major configuration changes
1279
+ *
1280
+ * @param rootDir - Root directory to scan
1281
+ * @param extensions - File extensions to scan (e.g., [".tsx", ".ts"])
1282
+ * @returns Rebuilt workspace result
1283
+ *
1284
+ * @example
1285
+ * ```ts
1286
+ * const result = rebuildWorkspaceResult('./src', ['.tsx', '.ts'])
1287
+ * console.log(`Found ${result.unique_classes} unique classes`)
1288
+ * console.log(`${result.files_with_changes} files had changes`)
1289
+ * ```
1290
+ */
1291
+ declare function rebuildWorkspaceResult(rootDir: string, extensions?: string[]): RebuildWorkspaceResult;
1292
+ /**
1293
+ * Scan a single file with incremental state
1294
+ * Returns only new/changed classes since last scan
1295
+ *
1296
+ * @param filePath - Path to file
1297
+ * @param fileContent - File content
1298
+ * @returns Updated classes and change status
1299
+ *
1300
+ * @example
1301
+ * ```ts
1302
+ * // On file change, get only what changed
1303
+ * const file = scanFileNative('src/Button.tsx', newContent)
1304
+ * if (file.changed) {
1305
+ * console.log('Added:', file.added_classes)
1306
+ * console.log('Removed:', file.removed_classes)
1307
+ * }
1308
+ * ```
1309
+ */
1310
+ declare function scanFileNative(filePath: string, fileContent: string): {
1311
+ file: string;
1312
+ classes: string[];
1313
+ added_classes: string[];
1314
+ removed_classes: string[];
1315
+ changed: boolean;
1316
+ };
1317
+ /**
1318
+ * Scan multiple files in batch with incremental state
1319
+ * Efficient batch processing of file changes
1320
+ *
1321
+ * @param filesJson - JSON array of {file, content} objects
1322
+ * @returns Results for each file
1323
+ *
1324
+ * @example
1325
+ * ```ts
1326
+ * const files = [
1327
+ * { file: 'src/Button.tsx', content: newButtonContent },
1328
+ * { file: 'src/Card.tsx', content: newCardContent }
1329
+ * ]
1330
+ * const results = scanFilesBatchNative(JSON.stringify(files))
1331
+ * ```
1332
+ */
1333
+ declare function scanFilesBatchNative(filesJson: string): Array<{
1334
+ file: string;
1335
+ classes: string[];
1336
+ changed: boolean;
1337
+ }>;
1338
+
1339
+ interface CssPipelineResult {
1340
+ css: string;
1341
+ classes: string[];
1342
+ sizeBytes: number;
1343
+ optimized: boolean;
1344
+ }
1345
+ declare function runCssPipeline(classes: string[], cssEntryContent?: string, root?: string, minify?: boolean): Promise<CssPipelineResult>;
1346
+
1347
+ /**
1348
+ * Parser Sub-entry Point
1349
+ *
1350
+ * Exports class parsing and extraction functionality.
1351
+ * - Tailwind class parsing
1352
+ * - Class extraction from source
1353
+ * - Class normalization and deduplication
1354
+ * - Component analysis
1355
+ */
1356
+ declare const parseClasses: (raw: string) => Array<{
1357
+ raw: string;
1358
+ type: string;
1359
+ }>;
1360
+ declare const extractAllClasses: (source: string) => string[];
1361
+ declare const extractClassesFromSource: (source: string) => string;
1362
+ declare const astExtractClasses: (source: string, _filename: string) => string[];
1363
+ declare const normalizeClasses: (raw: string) => string;
1364
+ declare const mergeClassesStatic: (classes: string) => string;
1365
+ declare const normalizeAndDedupClasses: (raw: string) => {
1366
+ normalized: string;
1367
+ duplicatesRemoved: number;
1368
+ uniqueCount: number;
1369
+ };
1370
+ declare const extractComponentUsage: (source: string) => Array<{
1371
+ component: string;
1372
+ propsJson: string;
1373
+ }>;
1374
+ declare const batchExtractClasses: (filePaths: string[]) => {
1375
+ file: string;
1376
+ classes: string[];
1377
+ contentHash: string;
1378
+ ok: boolean;
1379
+ error?: string;
1380
+ }[];
1381
+ declare const checkAgainstSafelist: (classes: string[], safelist: string[]) => {
1382
+ matched: string[];
1383
+ unmatched: string[];
1384
+ safelistSize: number;
1385
+ };
1386
+ declare const diffClassLists: (previous: string[], current: string[]) => {
1387
+ added: string[];
1388
+ removed: string[];
1389
+ unchanged: string[];
1390
+ hasChanges: boolean;
1391
+ };
1392
+
1393
+ /**
1394
+ * Detect dead CSS selectors in generated CSS.
1395
+ */
1396
+ declare function detectDeadCode(scanResultJson: string, css: string): DeadCodeResult;
1397
+ /**
1398
+ * Analyze class usage across scanned files.
1399
+ */
1400
+ declare function analyzeClassUsageNative(classes: string[], scanResultJson: string, css: string): ClassUsageItem[];
1401
+ /**
1402
+ * Analyze entire class list and generate CSS.
1403
+ */
1404
+ declare function analyzeClassesNative(filesJson: string, cwd: string, flags?: number): {
1405
+ css?: string;
1406
+ code: string;
1407
+ classes: string[];
1408
+ changed: boolean;
1409
+ rscJson?: string;
1410
+ metadataJson?: string;
1411
+ safelist?: string[];
1412
+ } | null;
1413
+ /**
1414
+ * Analyze React Server Component requirements.
1415
+ */
1416
+ declare function analyzeRscNative(source: string, filename: string): {
1417
+ isServer: boolean;
1418
+ needsClientDirective: boolean;
1419
+ clientReasons: string[];
1420
+ };
1421
+ /**
1422
+ * Optimize CSS by removing dead code and minifying.
1423
+ */
1424
+ declare function optimizeCssNative(css: string): {
1425
+ css: string;
1426
+ originalSize: number;
1427
+ optimizedSize: number;
1428
+ reductionPercentage: number;
1429
+ };
1430
+ /**
1431
+ * Process Tailwind CSS with Lightning CSS post-processing.
1432
+ */
1433
+ declare function processTailwindCssLightning(css: string): ProcessedCssResult;
1434
+ /**
1435
+ * Eliminate dead CSS selectors.
1436
+ */
1437
+ declare function eliminateDeadCssNative(css: string, deadClasses: string[]): string;
1438
+ /**
1439
+ * Hoist components from source code.
1440
+ */
1441
+ declare function hoistComponentsNative(source: string): HoistResult;
1442
+ /**
1443
+ * Compile variant configuration table.
1444
+ */
1445
+ declare function compileVariantTableNative(configJson: string): VariantTableResult;
1446
+ /**
1447
+ * Classify and sort classes by bucket.
1448
+ */
1449
+ declare function classifyAndSortClassesNative(classes: string[]): ClassifyResult[];
1450
+ /**
1451
+ * Merge CSS declarations from multiple chunks.
1452
+ */
1453
+ declare function mergeCssDeclarationsNative(cssChunks: string[]): MergeResult;
1454
+
1455
+ /**
1456
+ * themeResolutionNative.ts
1457
+ *
1458
+ * Phase 5.1: Theme Resolution Extended - Advanced theme configuration handling
1459
+ * Exposes 7 theme resolution functions for complex Tailwind configurations
1460
+ */
1461
+ /**
1462
+ * Validation result for theme config
1463
+ */
1464
+ interface ThemeValidationResult {
1465
+ is_valid: boolean;
1466
+ errors: string[];
1467
+ warnings: string[];
1468
+ suggestions: string[];
1469
+ }
1470
+ /**
1471
+ * Resolved variant configuration
1472
+ */
1473
+ interface ResolvedVariantConfig {
1474
+ variants: string[];
1475
+ supported: string[];
1476
+ deprecated: string[];
1477
+ conflicting: string[];
1478
+ }
1479
+ /**
1480
+ * Theme cascade resolution result
1481
+ */
1482
+ interface ThemeCascadeResult {
1483
+ base_theme: Record<string, unknown>;
1484
+ user_overrides: Record<string, unknown>;
1485
+ merged_theme: Record<string, unknown>;
1486
+ conflict_resolutions: Array<{
1487
+ key: string;
1488
+ base_value: unknown;
1489
+ override_value: unknown;
1490
+ resolution: "override" | "merge" | "error";
1491
+ }>;
1492
+ }
1493
+ /**
1494
+ * Class name resolution from theme
1495
+ */
1496
+ interface ResolvedClassName {
1497
+ class_name: string;
1498
+ property: string;
1499
+ value: string;
1500
+ from_theme_path: string;
1501
+ is_responsive: boolean;
1502
+ variants: string[];
1503
+ }
1504
+ /**
1505
+ * Conflict group information
1506
+ */
1507
+ interface ConflictGroupInfo {
1508
+ group_name: string;
1509
+ conflicting_classes: string[];
1510
+ description: string;
1511
+ resolution_strategy: string;
1512
+ }
1513
+ /**
1514
+ * Get all resolved variants from theme configuration
1515
+ * Parses theme config and returns all variant prefixes
1475
1516
  *
1476
- * @param classLists - Array of class lists
1477
- * @returns Merged classes
1517
+ * @param configJson - JSON string of theme configuration
1518
+ * @returns Resolved variants with metadata
1478
1519
  *
1479
1520
  * @example
1480
1521
  * ```ts
1481
- * const merged = twMergeRaw(['px-4 px-8', 'bg-red bg-blue'])
1522
+ * const config = {
1523
+ * screens: { md: '768px', lg: '1024px' },
1524
+ * state: { hover: '&:hover', focus: '&:focus' }
1525
+ * }
1526
+ * const variants = resolveVariants(JSON.stringify(config))
1527
+ * console.log(variants.variants) // ['md', 'lg', 'hover', 'focus', ...]
1482
1528
  * ```
1483
1529
  */
1484
- declare function twMergeRaw(classLists: string[]): string;
1485
-
1486
- /**
1487
- * idRegistryNative.ts
1488
- *
1489
- * Phase 5.2: ID Registry Management - Efficient ID generation and lookup
1490
- * Exposes 16 ID registry functions for deterministic class/component identification
1491
- */
1492
- /**
1493
- * Registry snapshot data
1494
- */
1495
- interface RegistrySnapshot {
1496
- handle: number;
1497
- next_id: number;
1498
- entries: Array<{
1499
- name: string;
1500
- id: number;
1501
- }>;
1502
- total_entries: number;
1503
- }
1530
+ declare function resolveVariants(configJson: string): ResolvedVariantConfig;
1504
1531
  /**
1505
- * Create a new ID generator
1506
- * Returns a handle to be used in subsequent operations
1532
+ * Validate theme configuration for correctness
1533
+ * Checks for common issues and provides warnings
1507
1534
  *
1508
- * @returns Generator handle (u32)
1535
+ * @param configJson - JSON string of theme configuration
1536
+ * @returns Validation result with errors and suggestions
1509
1537
  *
1510
1538
  * @example
1511
1539
  * ```ts
1512
- * const handle = idRegistryCreate()
1513
- * // Use handle for all subsequent operations
1514
- * try {
1515
- * const id = idRegistryGenerate(handle, 'MyComponent')
1516
- * // ... use id ...
1517
- * } finally {
1518
- * idRegistryDestroy(handle) // Clean up
1540
+ * const result = validateThemeConfig(JSON.stringify(myTheme))
1541
+ * if (!result.is_valid) {
1542
+ * console.error('Errors:', result.errors)
1543
+ * console.warn('Warnings:', result.warnings)
1519
1544
  * }
1520
1545
  * ```
1521
1546
  */
1522
- declare function idRegistryCreate(): number;
1547
+ declare function validateThemeConfig(configJson: string): ThemeValidationResult;
1523
1548
  /**
1524
- * Generate a new ID for a name
1525
- * Same name always returns same ID (deterministic)
1549
+ * Resolve theme cascade (base + overrides)
1550
+ * Merges base theme with user overrides intelligently
1526
1551
  *
1527
- * @param handle - Generator handle from idRegistryCreate()
1528
- * @param name - Identifier name (e.g., component name, class name)
1529
- * @returns Generated ID
1552
+ * @param baseThemeJson - Base theme configuration
1553
+ * @param overridesJson - User overrides configuration
1554
+ * @returns Merged theme with conflict information
1530
1555
  *
1531
1556
  * @example
1532
1557
  * ```ts
1533
- * const handle = idRegistryCreate()
1534
- * const id1 = idRegistryGenerate(handle, 'Button') // Returns 1
1535
- * const id2 = idRegistryGenerate(handle, 'Button') // Returns 1 (same)
1536
- * const id3 = idRegistryGenerate(handle, 'Card') // Returns 2 (different)
1558
+ * const cascade = resolveCascade(
1559
+ * JSON.stringify(baseTheme),
1560
+ * JSON.stringify(userOverrides)
1561
+ * )
1562
+ * console.log(cascade.merged_theme)
1563
+ * console.log('Conflicts resolved:', cascade.conflict_resolutions.length)
1537
1564
  * ```
1538
1565
  */
1539
- declare function idRegistryGenerate(handle: number, name: string): number;
1566
+ declare function resolveCascade(baseThemeJson: string, overridesJson: string): ThemeCascadeResult;
1540
1567
  /**
1541
- * Lookup existing ID for a name
1542
- * Returns -1 if not found
1568
+ * Resolve class names from theme
1569
+ * Maps Tailwind class names to theme values
1543
1570
  *
1544
- * @param handle - Generator handle
1545
- * @param name - Name to look up
1546
- * @returns ID if found, -1 if not found
1571
+ * @param classNames - Array of Tailwind class names (e.g., ["text-lg", "bg-blue-600"])
1572
+ * @param themeJson - Theme configuration
1573
+ * @returns Resolved class name information
1547
1574
  *
1548
1575
  * @example
1549
1576
  * ```ts
1550
- * const id = idRegistryLookup(handle, 'Button')
1551
- * if (id !== -1) {
1552
- * console.log(`Button has ID: ${id}`)
1553
- * } else {
1554
- * console.log('Button not in registry yet')
1555
- * }
1577
+ * const resolved = resolveClassNames(
1578
+ * ['text-lg', 'bg-blue-600', 'md:p-4'],
1579
+ * JSON.stringify(theme)
1580
+ * )
1581
+ * resolved.forEach(item => {
1582
+ * console.log(`${item.class_name} -> ${item.property}: ${item.value}`)
1583
+ * })
1556
1584
  * ```
1557
1585
  */
1558
- declare function idRegistryLookup(handle: number, name: string): number;
1586
+ declare function resolveClassNames(classNames: string[], themeJson: string): ResolvedClassName[];
1559
1587
  /**
1560
- * Get the next ID that would be assigned
1561
- * Useful for knowing how many unique IDs exist
1588
+ * Get conflict group information
1589
+ * Identifies classes that conflict with each other
1562
1590
  *
1563
- * @param handle - Generator handle
1564
- * @returns Next available ID
1591
+ * @param groupName - Conflict group name (e.g., "display", "position", "flex-direction")
1592
+ * @param themeJson - Theme configuration
1593
+ * @returns Information about the conflict group
1565
1594
  *
1566
1595
  * @example
1567
1596
  * ```ts
1568
- * const handle = idRegistryCreate()
1569
- * idRegistryGenerate(handle, 'Button')
1570
- * idRegistryGenerate(handle, 'Card')
1571
- * const nextId = idRegistryNext(handle) // Returns 2 (next available)
1597
+ * const info = resolveConflictGroup('display', JSON.stringify(theme))
1598
+ * console.log('Conflicting classes:', info.conflicting_classes)
1599
+ * console.log('Strategy:', info.resolution_strategy)
1572
1600
  * ```
1573
1601
  */
1574
- declare function idRegistryNext(handle: number): number;
1602
+ declare function resolveConflictGroup(groupName: string, themeJson: string): ConflictGroupInfo;
1575
1603
  /**
1576
- * Destroy a registry (clean up resources)
1577
- * Must be called when done with registry
1604
+ * Resolve theme value from key path
1605
+ * Navigates nested theme config to find values
1578
1606
  *
1579
- * @param handle - Generator handle
1607
+ * @param keyPath - Dot-separated path (e.g., "colors.blue.600")
1608
+ * @param themeJson - Theme configuration
1609
+ * @returns Resolved value or null if not found
1580
1610
  *
1581
1611
  * @example
1582
1612
  * ```ts
1583
- * const handle = idRegistryCreate()
1584
- * try {
1585
- * // Use registry
1586
- * } finally {
1587
- * idRegistryDestroy(handle)
1588
- * }
1613
+ * const color = resolveThemeValue('colors.blue.600', JSON.stringify(theme))
1614
+ * console.log(color) // "#2563eb" or similar
1589
1615
  * ```
1590
1616
  */
1591
- declare function idRegistryDestroy(handle: number): void;
1617
+ declare function resolveThemeValue(keyPath: string, themeJson: string): string | null;
1592
1618
  /**
1593
- * Reset registry to initial state
1594
- * Clears all entries but reuses handle
1619
+ * Get all simple variants from configuration
1620
+ * Returns variants that don't require complex selector nesting
1595
1621
  *
1596
- * @param handle - Generator handle
1622
+ * @param configJson - Theme/variant configuration
1623
+ * @returns Array of simple variant names
1597
1624
  *
1598
1625
  * @example
1599
1626
  * ```ts
1600
- * const handle = idRegistryCreate()
1601
- * idRegistryGenerate(handle, 'Component1')
1602
- * idRegistryGenerate(handle, 'Component2')
1603
- * idRegistryReset(handle) // Clear all
1604
- * const id = idRegistryNext(handle) // Back to 0
1627
+ * const simpleVariants = resolveSimpleVariants(JSON.stringify(config))
1628
+ * console.log(simpleVariants)
1629
+ * // ["hover", "focus", "active", "group-hover", ...]
1605
1630
  * ```
1606
1631
  */
1607
- declare function idRegistryReset(handle: number): void;
1632
+ declare function resolveSimpleVariants(configJson: string): string[];
1633
+
1634
+ declare function scanWorkspace(root: string, extensions?: string[]): ScanWorkspaceResult;
1635
+ declare function extractClassesFromSourceNative(source: string): string[];
1636
+ declare function batchExtractClassesNative(filePaths: string[]): BatchExtractResult[];
1637
+ declare function checkAgainstSafelistNative(classes: string[], safelist: string[]): SafelistCheckResult;
1638
+ declare function scanFile(filePath: string): ScanFileResult;
1639
+ declare function collectFiles(root: string, extensions?: string[]): string[];
1640
+ declare function walkAndPrefilterSourceFiles(root: string, extensions?: string[], _parallel?: boolean): PrefilterFileResult[];
1641
+ declare function generateSubComponentTypes(root: string, outputPath?: string): string;
1642
+
1608
1643
  /**
1609
- * Get snapshot of current registry state
1610
- * Useful for serialization/debugging
1644
+ * cacheNative.ts
1611
1645
  *
1612
- * @param handle - Generator handle
1613
- * @returns Snapshot with all entries
1646
+ * Phase 5.1: Cache Management - Advanced caching strategies and optimization
1647
+ * Exposes 9 cache-related Rust functions for improved performance tuning
1648
+ */
1649
+ /**
1650
+ * Cache optimization hints and recommendations
1651
+ */
1652
+ interface CacheOptimizationHints {
1653
+ current_strategy: string;
1654
+ recommended_strategy: string;
1655
+ estimated_improvement_percent: number;
1656
+ suggested_memory_mb: number;
1657
+ notes: string[];
1658
+ }
1659
+ /**
1660
+ * Optimal cache configuration recommendations
1661
+ */
1662
+ interface OptimalCacheConfig {
1663
+ parse_cache_size: number;
1664
+ resolve_cache_size: number;
1665
+ compile_cache_size: number;
1666
+ css_gen_cache_size: number;
1667
+ recommended_eviction_policy: string;
1668
+ ttl_seconds: number;
1669
+ expected_hit_rate_percent: number;
1670
+ }
1671
+ /**
1672
+ * Cache statistics from all layers
1673
+ */
1674
+ interface CacheStatistics {
1675
+ parse_cache: {
1676
+ hits: number;
1677
+ misses: number;
1678
+ size: number;
1679
+ };
1680
+ resolve_cache: {
1681
+ hits: number;
1682
+ misses: number;
1683
+ size: number;
1684
+ };
1685
+ compile_cache: {
1686
+ hits: number;
1687
+ misses: number;
1688
+ size: number;
1689
+ };
1690
+ css_gen_cache: {
1691
+ hits: number;
1692
+ misses: number;
1693
+ size: number;
1694
+ };
1695
+ overall_hit_rate: number;
1696
+ total_memory_bytes: number;
1697
+ }
1698
+ /**
1699
+ * Get comprehensive cache statistics across all layers
1700
+ * Useful for monitoring and optimization
1614
1701
  *
1702
+ * @returns Cache stats including hit rates, sizes, and recommendations
1615
1703
  * @example
1616
1704
  * ```ts
1617
- * const handle = idRegistryCreate()
1618
- * idRegistryGenerate(handle, 'Button')
1619
- * idRegistryGenerate(handle, 'Card')
1620
- * const snapshot = idRegistrySnapshot(handle)
1621
- * console.log(JSON.stringify(snapshot, null, 2))
1705
+ * const stats = getCacheStatistics()
1706
+ * console.log(`Overall hit rate: ${stats.overall_hit_rate}%`)
1707
+ * console.log(`Total memory used: ${stats.total_memory_bytes / 1024}KB`)
1622
1708
  * ```
1623
1709
  */
1624
- declare function idRegistrySnapshot(handle: number): RegistrySnapshot;
1710
+ declare function getCacheStatistics(): CacheStatistics;
1625
1711
  /**
1626
- * Get count of active registries
1627
- * Useful for monitoring resource usage
1628
- *
1629
- * @returns Number of active generator handles
1712
+ * Clear all caches (parse, resolve, compile, CSS generation)
1713
+ * Use when switching themes or major configuration changes
1630
1714
  *
1631
1715
  * @example
1632
1716
  * ```ts
1633
- * console.log(`Active registries: ${idRegistryActiveCount()}`)
1717
+ * // Clear before switching themes
1718
+ * clearAllCaches()
1719
+ * const css = await generateCssNative(classes, { theme: newTheme })
1634
1720
  * ```
1635
1721
  */
1636
- declare function idRegistryActiveCount(): number;
1722
+ declare function clearAllCaches(): void;
1723
+ /**
1724
+ * Clear only the parse cache
1725
+ * Useful when parser behavior changes or cache gets stale
1726
+ */
1727
+ declare function clearParseCache(): void;
1728
+ /**
1729
+ * Clear only the resolve cache
1730
+ * Use when theme configuration changes
1731
+ */
1732
+ declare function clearResolveCache(): void;
1733
+ /**
1734
+ * Clear only the compile cache
1735
+ * Use when Tailwind configuration changes
1736
+ */
1737
+ declare function clearCompileCache(): void;
1637
1738
  /**
1638
- * Register a property name with global registry
1639
- * Maps property names to consistent IDs
1640
- *
1641
- * @param propertyName - Property name (e.g., "background-color")
1642
- * @returns Assigned property ID
1643
- *
1644
- * @example
1645
- * ```ts
1646
- * const bgColorId = registerPropertyName('background-color')
1647
- * const paddingId = registerPropertyName('padding')
1648
- * ```
1739
+ * Clear only the CSS generation cache
1740
+ * Use when theme or layout changes
1649
1741
  */
1650
- declare function registerPropertyName(propertyName: string): number;
1742
+ declare function clearCssGenCache(): void;
1651
1743
  /**
1652
- * Register a value name with global registry
1653
- * Maps values to consistent IDs
1744
+ * Get optimization hints based on current cache performance
1745
+ * Analyzes hit rates and suggests improvements
1654
1746
  *
1655
- * @param valueName - Value name (e.g., "blue-600")
1656
- * @returns Assigned value ID
1747
+ * @param hitRatePercent - Current hit rate (0-100)
1748
+ * @param memoryUsedMb - Memory currently used in MB
1749
+ * @returns Optimization recommendations
1657
1750
  *
1658
1751
  * @example
1659
1752
  * ```ts
1660
- * const blueId = registerValueName('blue-600')
1661
- * const redId = registerValueName('red-500')
1753
+ * const stats = getCacheStatistics()
1754
+ * const hints = getCacheOptimizationHints(
1755
+ * stats.overall_hit_rate,
1756
+ * stats.total_memory_bytes / (1024 * 1024)
1757
+ * )
1758
+ * console.log(`Recommendation: ${hints.recommended_strategy}`)
1759
+ * console.log(`Potential improvement: ${hints.estimated_improvement_percent}%`)
1662
1760
  * ```
1663
1761
  */
1664
- declare function registerValueName(valueName: string): number;
1762
+ declare function getCacheOptimizationHints(hitRatePercent: number, memoryUsedMb: number): CacheOptimizationHints;
1665
1763
  /**
1666
- * Convert property ID back to name
1667
- * Reverse lookup for serialized data
1764
+ * Estimate optimal cache configuration for your workload
1765
+ * Analyzes typical patterns and recommends sizes
1668
1766
  *
1669
- * @param propertyId - Property ID
1670
- * @returns Property name or empty string if not found
1767
+ * @param totalBudgetMb - Maximum memory budget in MB
1768
+ * @param workloadType - "small" (< 100 files), "medium" (100-1000), "large" (1000+)
1769
+ * @returns Recommended cache configuration
1671
1770
  *
1672
1771
  * @example
1673
1772
  * ```ts
1674
- * const bgColorId = registerPropertyName('background-color')
1675
- * const name = propertyIdToString(bgColorId)
1676
- * console.log(name) // "background-color"
1773
+ * const config = estimateOptimalCacheConfig(512, 'large')
1774
+ * console.log(`Parse cache: ${config.parse_cache_size}MB`)
1775
+ * console.log(`Expected hit rate: ${config.expected_hit_rate_percent}%`)
1677
1776
  * ```
1678
1777
  */
1679
- declare function propertyIdToString(propertyId: number): string;
1778
+ declare function estimateOptimalCacheConfig(totalBudgetMb: number, workloadType: "small" | "medium" | "large"): OptimalCacheConfig;
1680
1779
  /**
1681
- * Convert value ID back to name
1682
- * Reverse lookup for serialized data
1780
+ * Read cache from disk (persistence)
1781
+ * Restores cached data from previous sessions
1683
1782
  *
1684
- * @param valueId - Value ID
1685
- * @returns Value name or empty string if not found
1783
+ * @param cachePath - Path to cache file
1784
+ * @returns Entries loaded from disk
1686
1785
  *
1687
1786
  * @example
1688
1787
  * ```ts
1689
- * const blueId = registerValueName('blue-600')
1690
- * const value = valueIdToString(blueId)
1691
- * console.log(value) // "blue-600"
1788
+ * const entries = cacheRead('./.tw-cache/scan.json')
1789
+ * // Warm up cache with persisted data
1692
1790
  * ```
1693
1791
  */
1694
- declare function valueIdToString(valueId: number): string;
1695
- /**
1696
- * Reverse lookup: find property by ID
1697
- * Alternative way to look up property names
1698
- *
1699
- * @param propertyId - Property ID to look up
1700
- * @returns Property name
1701
- */
1702
- declare function reverseLookupProperty(propertyId: number): string;
1703
- /**
1704
- * Reverse lookup: find value by ID
1705
- * Alternative way to look up value names
1706
- *
1707
- * @param valueId - Value ID to look up
1708
- * @returns Value name
1709
- */
1710
- declare function reverseLookupValue(valueId: number): string;
1792
+ declare function cacheRead(cachePath: string): Array<{
1793
+ file: string;
1794
+ contentHash: string;
1795
+ classes: string[];
1796
+ mtimeMs: number;
1797
+ sizeBytes: number;
1798
+ }>;
1711
1799
  /**
1712
- * Export registry state for persistence
1713
- * Useful for saving/restoring registry data
1800
+ * Write cache to disk (persistence)
1801
+ * Saves cached data for next session
1714
1802
  *
1715
- * @param handle - Generator handle
1716
- * @returns Serialized registry state
1803
+ * @param cachePath - Path where cache should be written
1804
+ * @param entries - Cache entries to persist
1805
+ * @returns Success status
1717
1806
  *
1718
1807
  * @example
1719
1808
  * ```ts
1720
- * const exported = idRegistryExport(handle)
1721
- * // Save to file/database
1809
+ * const stats = getCacheStatistics()
1810
+ * const success = cacheWrite(
1811
+ * './.tw-cache/scan.json',
1812
+ * // entries array from previous scan
1813
+ * )
1722
1814
  * ```
1723
1815
  */
1724
- declare function idRegistryExport(handle: number): string;
1816
+ declare function cacheWrite(cachePath: string, entries: Array<{
1817
+ file: string;
1818
+ contentHash: string;
1819
+ classes: string[];
1820
+ mtimeMs: number;
1821
+ sizeBytes: number;
1822
+ }>): boolean;
1725
1823
  /**
1726
- * Import registry state
1727
- * Restore registry from saved state
1824
+ * Calculate cache priority score for file ordering
1825
+ * Useful for prioritizing which files to scan first
1728
1826
  *
1729
- * @param importedData - Serialized registry data
1730
- * @returns New handle with imported data
1827
+ * @param mtimeMs - File modification time in milliseconds
1828
+ * @param sizeBytes - File size in bytes
1829
+ * @param hitCount - Number of times this file was accessed from cache
1830
+ * @returns Priority score (higher = process first)
1731
1831
  *
1732
1832
  * @example
1733
1833
  * ```ts
1734
- * const handle = idRegistryImport(savedData)
1735
- * // Registry restored with same IDs
1834
+ * const priority = cachePriority(Date.now(), 2048, 5)
1835
+ * // Use priority to sort files for scanning
1736
1836
  * ```
1737
1837
  */
1738
- declare function idRegistryImport(importedData: string): number;
1838
+ declare function cachePriority(mtimeMs: number, sizeBytes: number, hitCount: number): number;
1739
1839
 
1740
1840
  /**
1741
1841
  * redisNative.ts
@@ -2598,40 +2698,26 @@ declare function validateCssOutput(css: string): string;
2598
2698
  */
2599
2699
  declare function getCompilerDiagnostics(): string;
2600
2700
 
2601
- type LoaderOutput = {
2602
- code: string;
2603
- changed: boolean;
2604
- classes: string[];
2605
- staticCss?: string;
2606
- rsc?: {
2607
- isServer?: boolean;
2608
- needsClientDirective?: boolean;
2609
- clientReasons?: string[];
2610
- };
2611
- engine?: string;
2612
- };
2701
+ /**
2702
+ * tailwind-styled-v5 — Compiler Main Entry Point
2703
+ *
2704
+ * Re-exports all sub-entry points for backward compatibility.
2705
+ * For better tree-shaking, import from specific sub-entries:
2706
+ * - '@tailwind-styled/compiler/compiler' - CSS generation and compilation
2707
+ * - '@tailwind-styled/compiler/parser' - Class parsing and extraction
2708
+ * - '@tailwind-styled/compiler/analyzer' - Analysis and optimization
2709
+ * - '@tailwind-styled/compiler/cache' - Cache management
2710
+ * - '@tailwind-styled/compiler/redis' - Redis and distributed cache
2711
+ * - '@tailwind-styled/compiler/watch' - File watching and monitoring
2712
+ */
2713
+
2613
2714
  declare const transformSource: (source: string, opts?: Record<string, unknown>) => NativeTransformResult;
2614
2715
  declare const hasTwUsage: (source: string) => boolean;
2615
2716
  declare const isAlreadyTransformed: (source: string) => boolean;
2616
2717
  declare const shouldProcess: (source: string) => boolean;
2617
2718
  declare const compileCssFromClasses: (classes: string[], prefix?: string | null) => NativeTransformResult;
2618
2719
  declare const buildStyleTag: (classes: string[]) => string;
2619
- declare const compileCssNative: (classes: string[], prefix?: string | null) => NativeTransformResult;
2620
2720
  declare const generateCssForClasses: (classes: string[], _tailwindConfig?: Record<string, unknown>, root?: string, cssEntryContent?: string, minify?: boolean) => Promise<string>;
2621
- declare const extractAllClasses: (source: string) => string[];
2622
- declare const extractClassesFromSource: (source: string) => string;
2623
- declare const astExtractClasses: (source: string, _filename: string) => string[];
2624
- declare const parseClasses: (raw: string) => Array<{
2625
- raw: string;
2626
- type: string;
2627
- }>;
2628
- declare const normalizeClasses: (raw: string) => string;
2629
- declare const mergeClassesStatic: (classes: string) => string;
2630
- declare const normalizeAndDedupClasses: (raw: string) => {
2631
- normalized: string;
2632
- duplicatesRemoved: number;
2633
- uniqueCount: number;
2634
- };
2635
2721
  declare const eliminateDeadCss: (css: string, deadClasses: Set<string>) => string;
2636
2722
  declare const findDeadVariants: (variantConfig: Record<string, unknown> | Array<{
2637
2723
  name: string;
@@ -2642,74 +2728,26 @@ declare const findDeadVariants: (variantConfig: Record<string, unknown> | Array<
2642
2728
  unused: string[];
2643
2729
  };
2644
2730
  declare const runElimination: (css: string, scanResult: unknown) => string;
2645
- declare const optimizeCss: (css: string) => string;
2646
2731
  declare const scanProjectUsage: (dirs: string[], cwd: string) => Record<string, Record<string, Set<string>>>;
2647
- declare const extractComponentUsage: (source: string) => Array<{
2648
- component: string;
2649
- propsJson: string;
2650
- }>;
2651
- declare const diffClassLists: (previous: string[], current: string[]) => {
2652
- added: string[];
2653
- removed: string[];
2654
- unchanged: string[];
2655
- hasChanges: boolean;
2656
- };
2657
- declare const batchExtractClasses: (filePaths: string[]) => {
2658
- file: string;
2659
- classes: string[];
2660
- contentHash: string;
2661
- ok: boolean;
2662
- error?: string;
2663
- }[];
2664
- declare const checkAgainstSafelist: (classes: string[], safelist: string[]) => {
2665
- matched: string[];
2666
- unmatched: string[];
2667
- safelistSize: number;
2668
- };
2669
- declare const hoistComponents: (source: string) => HoistResult;
2670
- declare const compileVariantTable: (configJson: string) => VariantTableResult;
2671
- declare const compileVariants: (componentId: string, config: Record<string, unknown>) => VariantTableResult;
2672
- declare const classifyAndSortClasses: (classes: string[]) => ClassifyResult[];
2673
- declare const mergeCssDeclarations: (cssChunks: string[]) => MergeResult;
2674
- declare const analyzeClassUsage: (classes: string[], scanResultJson: string, css: string) => ClassUsageItem[];
2675
- declare const analyzeRsc: (source: string, filename: string) => {
2676
- isServer: boolean;
2677
- needsClientDirective: boolean;
2678
- clientReasons: string[];
2679
- };
2680
- declare const analyzeFile: (source: string, filename: string) => {
2681
- isServer: boolean;
2682
- needsClientDirective: boolean;
2683
- clientReasons: string[];
2684
- interactiveClasses: never[];
2685
- canStaticResolveVariants: boolean;
2686
- };
2687
- declare const analyzeVariantUsage: (_source: string, _componentName: string, _variantKeys: string[]) => {
2688
- resolved: Record<string, string>;
2689
- dynamic: string[];
2690
- };
2691
- declare const injectClientDirective: (source: string) => string;
2692
- declare const injectServerOnlyComment: (source: string) => string;
2693
- declare const analyzeClasses: (filesJson: string, cwd: string, flags: number) => {
2694
- css?: string;
2695
- code: string;
2696
- classes: string[];
2697
- changed: boolean;
2698
- rscJson?: string;
2699
- metadataJson?: string;
2700
- safelist?: string[];
2701
- } | null;
2702
2732
  declare const generateSafelist: (scanDirs: string[], outputPath?: string, cwd?: string) => string[];
2703
2733
  declare const loadSafelist: (safelistPath: string) => string[];
2704
2734
  declare const loadTailwindConfig: (cwd?: string) => {};
2705
2735
  declare const getContentPaths: (cwd?: string) => {
2706
2736
  content: string[];
2707
2737
  };
2708
- /**
2709
- * Extract container configs dari source dan generate static `@container` CSS.
2710
- * Native-only: delegates ke Rust extractTwContainerConfigs.
2711
- */
2712
2738
  declare function extractContainerCssFromSource(source: string): string;
2739
+ type LoaderOutput = {
2740
+ code: string;
2741
+ changed: boolean;
2742
+ classes: string[];
2743
+ staticCss?: string;
2744
+ rsc?: {
2745
+ isServer?: boolean;
2746
+ needsClientDirective?: boolean;
2747
+ clientReasons?: string[];
2748
+ };
2749
+ engine?: string;
2750
+ };
2713
2751
  declare const runLoaderTransform: (ctx: {
2714
2752
  filepath: string;
2715
2753
  source: string;
@@ -2721,28 +2759,44 @@ declare const getAllRoutes: () => string[];
2721
2759
  declare const getRouteClasses: (_route: string) => Set<string>;
2722
2760
  declare const registerFileClasses: (_filepath: string, _classes: string[]) => void;
2723
2761
  declare const registerGlobalClasses: (_classes: string[]) => void;
2724
- declare const getIncrementalEngine: () => {
2725
- compile(source: string): NativeTransformResult;
2726
- };
2762
+ declare const getIncrementalEngine: () => IncrementalEngine;
2727
2763
  declare const resetIncrementalEngine: () => void;
2728
- declare const IncrementalEngine: {
2729
- new (): {
2730
- compile(source: string): NativeTransformResult;
2731
- };
2732
- };
2764
+ declare class IncrementalEngine {
2765
+ compile(source: string): NativeTransformResult;
2766
+ }
2733
2767
  declare const getBucketEngine: () => {
2734
2768
  add: (className: string) => string;
2735
2769
  get: (_bucket: string) => string[];
2736
2770
  };
2737
2771
  declare const resetBucketEngine: () => void;
2738
- declare const BucketEngine: {
2739
- new (): {
2740
- add(className: string): string;
2741
- };
2742
- };
2772
+ declare class BucketEngine {
2773
+ add(className: string): string;
2774
+ }
2743
2775
  declare const classifyNode: (_node: unknown) => string;
2744
2776
  declare const detectConflicts: (_classes: string[]) => string[];
2745
2777
  declare const bucketSort: (classes: string[]) => string[];
2778
+ declare const analyzeFile: (source: string, filename: string) => {
2779
+ isServer: boolean;
2780
+ needsClientDirective: boolean;
2781
+ clientReasons: string[];
2782
+ interactiveClasses: never[];
2783
+ canStaticResolveVariants: boolean;
2784
+ };
2785
+ declare const analyzeVariantUsage: (_source: string, _componentName: string, _variantKeys: string[]) => {
2786
+ resolved: Record<string, string>;
2787
+ dynamic: string[];
2788
+ };
2789
+ declare const injectClientDirective: (source: string) => string;
2790
+ declare const injectServerOnlyComment: (source: string) => string;
2791
+ declare const analyzeClasses: (filesJson: string, cwd: string, flags: number) => {
2792
+ css?: string;
2793
+ code: string;
2794
+ classes: string[];
2795
+ changed: boolean;
2796
+ rscJson?: string;
2797
+ metadataJson?: string;
2798
+ safelist?: string[];
2799
+ } | null;
2746
2800
  interface TwStateConfigEntry {
2747
2801
  tag: string;
2748
2802
  componentName: string;
@@ -2762,7 +2816,7 @@ interface GeneratedStateRule {
2762
2816
  stateName: string;
2763
2817
  }
2764
2818
  declare const extractTwStateConfigs: (source: string, filename: string) => TwStateConfigEntry[];
2765
- declare const generateStaticStateCss: (inputs: StaticStateCssInput[], resolvedCss?: string | null) => GeneratedStateRule[];
2819
+ declare const generateStaticStateCss: (entries: TwStateConfigEntry[], _themeConfig?: Record<string, unknown>) => GeneratedStateRule[];
2766
2820
  declare const extractAndGenerateStateCss: (source: string, filename: string) => GeneratedStateRule[];
2767
2821
 
2768
- export { type BatchExtractResult, BucketEngine, type CacheOptimizationHints, type CacheStatistics, type ClassExtractResult, type ClassUsageItem, type ClassifyResult, type CompiledAnimation, type CompiledCssRule, type CompiledTheme, type ComponentMetadata, type ConflictGroupInfo, type ContainerConfig, type CssCompileResult, type DeadCodeResult, type FileChangeEvent, type FileDiff, type FileFingerprint, type GeneratedStateCss, type GeneratedStateRule, type HoistResult, type IncrementalDiffResult, IncrementalEngine, type KeyExpiration, type LoaderOutput, type MergeResult, type NativeBridge, type NativeRscResult, type NativeTransformResult, type OptimalCacheConfig, type PoolInfo, type PrefilterFileResult, type ProcessedCssResult, type ProcessedFileChange, type PruneResult, type PubSubMessage, type RebuildWorkspaceResult, type RedisCacheConfig, type RedisClusterNode, type RedisClusterStatus, type RedisPoolStats, type RegistrySnapshot, type ResolvedClassName, type ResolvedVariantConfig, type SafelistCheckResult, type ScanFileResult, type ScanWorkspaceResult, type StateCssConfig, type StateInjectionResult, type StaticStateCssInput, type ThemeCascadeResult, type ThemeValidationResult, type TwMergeOptions, type TwStateConfigEntry, type VariantTableResult, type WatchEvent, type WatchHandle, type WatchStats, adaptNativeResult, analyzeClassUsage, analyzeClassUsageNative, analyzeClasses, analyzeClassesNative, analyzeFile, analyzeRsc, analyzeRscNative, analyzeVariantUsage, astExtractClasses, atomicRegistrySize, batchExtractClasses, batchExtractClassesNative, bucketSort, buildStyleTag, cachePriority, cacheRead, cacheWrite, checkAgainstSafelist, checkAgainstSafelistNative, classifyAndSortClasses, classifyAndSortClassesNative, classifyNode, clearAllCaches, clearAtomicRegistry, clearCompileCache, clearCssGenCache, clearParseCache, clearResolveCache, clearThemeCache, collectFiles, compileAnimation, compileClass, compileClasses, compileCssFromClasses, compileCssLightning, compileCssNative, compileCssNative2, compileKeyframes, compileTheme, compileToCss, compileToCssBatch, compileVariantTable, compileVariantTableNative, compileVariants, computeIncrementalDiff, createFingerprint, detectConflicts, detectDeadCode, diffClassLists, eliminateDeadCss, eliminateDeadCssNative, emitPluginHook, estimateOptimalCacheConfig, extractAllClasses, extractAndGenerateStateCss, extractAndGenerateStateCssNative, extractClassesFromSource, extractClassesFromSourceNative, extractComponentUsage, extractContainerCssFromSource, extractTwContainerConfigs, extractTwStateConfigs, extractTwStateConfigsNative, fileToRoute, findDeadVariants, generateAtomicCss, generateCssForClasses, generateCssNative, generateSafelist, generateStaticStateCss, generateStaticStateCssNative, generateSubComponentTypes, getAllRoutes, getBucketEngine, getCacheOptimizationHints, getCacheStatistics, getCacheStats, getCompilationMetrics, getCompilerDiagnostics, getContentPaths, getIncrementalEngine, getNativeBridge, getPluginHooks, getRouteClasses, getWatchStats, hasTwUsage, hashContent, hoistComponents, hoistComponentsNative, idRegistryActiveCount, idRegistryCreate, idRegistryDestroy, idRegistryExport, idRegistryGenerate, idRegistryImport, idRegistryLookup, idRegistryNext, idRegistryReset, idRegistrySnapshot, injectClientDirective, injectServerOnlyComment, injectStateHash, isAlreadyTransformed, isWatchRunning, layoutClassesToCss, loadSafelist, loadTailwindConfig, mergeClassesStatic, mergeCssDeclarations, mergeCssDeclarationsNative, minifyCss, normalizeAndDedupClasses, normalizeClasses, optimizeCss, optimizeCssNative, parseAtomicClass, parseClasses, pollWatchEvents, processFileChange, processTailwindCssLightning, propertyIdToString, pruneStaleCacheEntries, rebuildWorkspaceResult, redisCacheClear, redisCacheHitRate, redisCacheKeyCount, redisCacheSize, redisCacheSync, redisClusterStatus, redisDelete, redisDiagnose, redisDisableCacheWarming, redisDisableCluster, redisDisablePersistence, redisEnableCacheWarming, redisEnableCluster, redisEnablePersistence, redisExists, redisExpirationGet, redisExpirationSet, redisFlushAll, redisFlushDb, redisGet, redisGetEvictionPolicy, redisInfo, redisMemoryStats, redisMget, redisMonitor, redisMset, redisOptimizeMemory, redisPing, redisPoolConnect, redisPoolReconnect, redisPoolStats, redisPublish, redisReplicate, redisReplicationStatus, redisSet, redisSetEvictionPolicy, redisSnapshot, redisSubscribe, registerFileClasses, registerGlobalClasses, registerPluginHook, registerPropertyName, registerValueName, resetBucketEngine, resetCompilationMetrics, resetIncrementalEngine, resetNativeBridgeCache, resolveCascade, resolveClassNames, resolveConflictGroup, resolveSimpleVariants, resolveThemeValue, resolveVariants, reverseLookupProperty, reverseLookupValue, runElimination, runLoaderTransform, scanCacheOptimizations, scanFile, scanFileNative, scanFilesBatchNative, scanProjectUsage, scanWorkspace, shouldProcess, shouldSkipFile, startWatch, stopWatch, toAtomicClasses, transformSource, twMerge, twMergeMany, twMergeManyWithSeparator, twMergeRaw, twMergeWithSeparator, unregisterPluginHook, validateCssOutput, validateThemeConfig, valueIdToString, walkAndPrefilterSourceFiles, watchAddPattern, watchClearAll, watchEventTypeToString, watchGetActiveHandles, watchPause, watchRemovePattern, watchResume };
2822
+ export { type BatchExtractResult, BucketEngine, type CacheOptimizationHints, type CacheStatistics, type ClassExtractResult, type ClassUsageItem, type ClassifyResult, type CompiledAnimation, type CompiledCssRule, type CompiledTheme, type ComponentMetadata, type ConflictGroupInfo, type ContainerConfig, type CssCompileResult, type DeadCodeResult, type FileChangeEvent, type FileDiff, type FileFingerprint, type GeneratedStateCss, type GeneratedStateRule, type HoistResult, type IncrementalDiffResult, IncrementalEngine, type KeyExpiration, type LoaderOutput, type MergeResult, type NativeBridge, type NativeRscResult, type NativeTransformResult, type OptimalCacheConfig, type PoolInfo, type PrefilterFileResult, type ProcessedCssResult, type ProcessedFileChange, type PruneResult, type PubSubMessage, type RebuildWorkspaceResult, type RedisCacheConfig, type RedisClusterNode, type RedisClusterStatus, type RedisPoolStats, type RegistrySnapshot, type ResolvedClassName, type ResolvedVariantConfig, type SafelistCheckResult, type ScanFileResult, type ScanWorkspaceResult, type StateCssConfig, type StateInjectionResult, type StaticStateCssInput, type ThemeCascadeResult, type ThemeValidationResult, type TwMergeOptions, type TwStateConfigEntry, type VariantTableResult, type WatchEvent, type WatchHandle, type WatchStats, adaptNativeResult, analyzeClassUsageNative, analyzeClasses, analyzeClassesNative, analyzeFile, analyzeRscNative, analyzeVariantUsage, astExtractClasses, atomicRegistrySize, batchExtractClasses, batchExtractClassesNative, bucketSort, buildStyleTag, cachePriority, cacheRead, cacheWrite, checkAgainstSafelist, checkAgainstSafelistNative, classifyAndSortClassesNative, classifyNode, clearAllCaches, clearAtomicRegistry, clearCompileCache, clearCssGenCache, clearParseCache, clearResolveCache, clearThemeCache, collectFiles, compileAnimation, compileClass, compileClasses, compileCssFromClasses, compileCssLightning, compileCssNative2, compileKeyframes, compileTheme, compileToCss, compileToCssBatch, compileVariantTableNative, computeIncrementalDiff, createFingerprint, detectConflicts, detectDeadCode, diffClassLists, eliminateDeadCss, eliminateDeadCssNative, emitPluginHook, estimateOptimalCacheConfig, extractAllClasses, extractAndGenerateStateCss, extractAndGenerateStateCssNative, extractClassesFromSource, extractClassesFromSourceNative, extractComponentUsage, extractContainerCssFromSource, extractTwContainerConfigs, extractTwStateConfigs, extractTwStateConfigsNative, fileToRoute, findDeadVariants, generateAtomicCss, generateCssForClasses, generateCssNative, generateSafelist, generateStaticStateCss, generateStaticStateCssNative, generateSubComponentTypes, getAllRoutes, getBucketEngine, getCacheOptimizationHints, getCacheStatistics, getCacheStats, getCompilationMetrics, getCompilerDiagnostics, getContentPaths, getIncrementalEngine, getNativeBridge, getPluginHooks, getRouteClasses, getWatchStats, hasTwUsage, hashContent, hoistComponentsNative, idRegistryActiveCount, idRegistryCreate, idRegistryDestroy, idRegistryExport, idRegistryGenerate, idRegistryImport, idRegistryLookup, idRegistryNext, idRegistryReset, idRegistrySnapshot, injectClientDirective, injectServerOnlyComment, injectStateHash, isAlreadyTransformed, isWatchRunning, layoutClassesToCss, loadSafelist, loadTailwindConfig, mergeClassesStatic, mergeCssDeclarationsNative, minifyCss, normalizeAndDedupClasses, normalizeClasses, optimizeCssNative, parseAtomicClass, parseClasses, pollWatchEvents, processFileChange, processTailwindCssLightning, propertyIdToString, pruneStaleCacheEntries, rebuildWorkspaceResult, redisCacheClear, redisCacheHitRate, redisCacheKeyCount, redisCacheSize, redisCacheSync, redisClusterStatus, redisDelete, redisDiagnose, redisDisableCacheWarming, redisDisableCluster, redisDisablePersistence, redisEnableCacheWarming, redisEnableCluster, redisEnablePersistence, redisExists, redisExpirationGet, redisExpirationSet, redisFlushAll, redisFlushDb, redisGet, redisGetEvictionPolicy, redisInfo, redisMemoryStats, redisMget, redisMonitor, redisMset, redisOptimizeMemory, redisPing, redisPoolConnect, redisPoolReconnect, redisPoolStats, redisPublish, redisReplicate, redisReplicationStatus, redisSet, redisSetEvictionPolicy, redisSnapshot, redisSubscribe, registerFileClasses, registerGlobalClasses, registerPluginHook, registerPropertyName, registerValueName, resetBucketEngine, resetCompilationMetrics, resetIncrementalEngine, resetNativeBridgeCache, resolveCascade, resolveClassNames, resolveConflictGroup, resolveSimpleVariants, resolveThemeValue, resolveVariants, reverseLookupProperty, reverseLookupValue, runCssPipeline, runElimination, runLoaderTransform, scanCacheOptimizations, scanFile, scanFileNative, scanFilesBatchNative, scanProjectUsage, scanWorkspace, shouldProcess, shouldSkipFile, startWatch, stopWatch, toAtomicClasses, transformSource, twMerge, twMergeMany, twMergeManyWithSeparator, twMergeRaw, twMergeWithSeparator, unregisterPluginHook, validateCssOutput, validateThemeConfig, valueIdToString, walkAndPrefilterSourceFiles, watchAddPattern, watchClearAll, watchEventTypeToString, watchGetActiveHandles, watchPause, watchRemovePattern, watchResume };