tailwind-styled-v4 5.0.35 → 5.0.37

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 (92) hide show
  1. package/README.md +458 -339
  2. package/dist/analyzer.d.mts +152 -5
  3. package/dist/analyzer.d.ts +152 -5
  4. package/dist/animate.d.mts +30 -3
  5. package/dist/animate.d.ts +30 -3
  6. package/dist/cli.js +9 -6
  7. package/dist/cli.js.map +1 -1
  8. package/dist/cli.mjs +9 -6
  9. package/dist/cli.mjs.map +1 -1
  10. package/dist/compiler.d.mts +5 -0
  11. package/dist/compiler.d.ts +5 -0
  12. package/dist/compiler.js.map +1 -1
  13. package/dist/compiler.mjs.map +1 -1
  14. package/dist/devtools.d.mts +88 -2
  15. package/dist/devtools.d.ts +88 -2
  16. package/dist/engine.d.mts +557 -6
  17. package/dist/engine.d.ts +557 -6
  18. package/dist/engine.js.map +1 -1
  19. package/dist/engine.mjs.map +1 -1
  20. package/dist/index.browser.mjs +689 -508
  21. package/dist/index.browser.mjs.map +1 -1
  22. package/dist/index.d.mts +236 -9
  23. package/dist/index.d.ts +236 -9
  24. package/dist/index.js +38 -20
  25. package/dist/index.js.map +1 -1
  26. package/dist/index.mjs +38 -20
  27. package/dist/index.mjs.map +1 -1
  28. package/dist/next.js +240 -170
  29. package/dist/next.js.map +1 -1
  30. package/dist/next.mjs +240 -170
  31. package/dist/next.mjs.map +1 -1
  32. package/dist/plugin-api.d.mts +4 -2
  33. package/dist/plugin-api.d.ts +4 -2
  34. package/dist/plugin-registry.js +39 -25
  35. package/dist/plugin-registry.js.map +1 -1
  36. package/dist/plugin-registry.mjs +39 -25
  37. package/dist/plugin-registry.mjs.map +1 -1
  38. package/dist/plugin.d.mts +165 -5
  39. package/dist/plugin.d.ts +165 -5
  40. package/dist/plugin.js +17 -0
  41. package/dist/plugin.js.map +1 -1
  42. package/dist/plugin.mjs +15 -1
  43. package/dist/plugin.mjs.map +1 -1
  44. package/dist/runtime.d.mts +38 -3
  45. package/dist/runtime.d.ts +38 -3
  46. package/dist/scanner.d.mts +58 -4
  47. package/dist/scanner.d.ts +58 -4
  48. package/dist/shared.d.mts +185 -3
  49. package/dist/shared.d.ts +185 -3
  50. package/dist/shared.js.map +1 -1
  51. package/dist/shared.mjs.map +1 -1
  52. package/dist/storybook-addon.d.mts +2 -2
  53. package/dist/storybook-addon.d.ts +2 -2
  54. package/dist/svelte.d.mts +2 -1
  55. package/dist/svelte.d.ts +2 -1
  56. package/dist/svelte.js +4 -4
  57. package/dist/svelte.js.map +1 -1
  58. package/dist/svelte.mjs +4 -4
  59. package/dist/svelte.mjs.map +1 -1
  60. package/dist/theme.d.mts +38 -3
  61. package/dist/theme.d.ts +38 -3
  62. package/dist/turbopackLoader.js.map +1 -1
  63. package/dist/turbopackLoader.mjs.map +1 -1
  64. package/dist/tw.js +9 -6
  65. package/dist/tw.js.map +1 -1
  66. package/dist/tw.mjs +9 -6
  67. package/dist/tw.mjs.map +1 -1
  68. package/dist/vite.js.map +1 -1
  69. package/dist/vite.mjs.map +1 -1
  70. package/dist/vue.d.mts +4 -1
  71. package/dist/vue.d.ts +4 -1
  72. package/dist/vue.js +4 -4
  73. package/dist/vue.js.map +1 -1
  74. package/dist/vue.mjs +4 -4
  75. package/dist/vue.mjs.map +1 -1
  76. package/native/tailwind-styled-native.linux-x64-gnu.node +0 -0
  77. package/native/tailwind-styled-native.node +0 -0
  78. package/package.json +7 -5
  79. package/dist/analyzeWorkspace-B1_XRfdl.d.ts +0 -134
  80. package/dist/analyzeWorkspace-hYfu4Hg3.d.mts +0 -134
  81. package/dist/index-DQI6O24n.d.mts +0 -464
  82. package/dist/index-NDINUhLN.d.mts +0 -90
  83. package/dist/index-NDINUhLN.d.ts +0 -90
  84. package/dist/index-UkYbyBkR.d.ts +0 -464
  85. package/dist/liveTokenEngine-CN9ian1R.d.ts +0 -38
  86. package/dist/liveTokenEngine-DKoWRtqH.d.mts +0 -38
  87. package/dist/schemas-DR-SLxZZ.d.mts +0 -59
  88. package/dist/schemas-DR-SLxZZ.d.ts +0 -59
  89. package/dist/trace-Dz4vmZdy.d.mts +0 -96
  90. package/dist/trace-Dz4vmZdy.d.ts +0 -96
  91. package/dist/types-DXr2PmGP.d.mts +0 -31
  92. package/dist/types-DXr2PmGP.d.ts +0 -31
package/dist/index.d.mts CHANGED
@@ -1,12 +1,27 @@
1
1
  import React from 'react';
2
- import { a as AnimateOptions } from './types-DXr2PmGP.mjs';
3
- import { H as HtmlTagName } from './index-NDINUhLN.mjs';
4
- export { T as TokenMap } from './index-NDINUhLN.mjs';
5
- export { a as LiveTokenSet, T as TokenSubscriber, b as applyTokenSet, t as containerRef, c as createUseTokens, g as generateTokenCssString, d as getToken, e as getTokens, l as liveToken, s as setToken, h as setTokens, i as subscribeTokens, t as tokenRef, j as tokenVar } from './liveTokenEngine-DKoWRtqH.mjs';
6
- export { K as createEngine } from './index-DQI6O24n.mjs';
7
- import './analyzeWorkspace-hYfu4Hg3.mjs';
8
- import './schemas-DR-SLxZZ.mjs';
9
- import 'zod';
2
+ import { z } from 'zod';
3
+
4
+ type CSSFillMode = "none" | "forwards" | "backwards" | "both";
5
+ type CSSDirection = "normal" | "reverse" | "alternate" | "alternate-reverse";
6
+ type CSSIterationCount = number | "infinite";
7
+ type PresetEasing = "linear" | "ease" | "ease-in" | "ease-out" | "ease-in-out" | "step-start" | "step-end";
8
+ type CubicBezierEasing = `cubic-bezier(${string})`;
9
+ type StepsEasing = `steps(${string})`;
10
+ type CSSEasing = PresetEasing | CubicBezierEasing | StepsEasing;
11
+ interface AnimateOptions {
12
+ from: string;
13
+ to: string;
14
+ duration?: number;
15
+ easing?: CSSEasing;
16
+ delay?: number;
17
+ fill?: CSSFillMode;
18
+ iterations?: CSSIterationCount;
19
+ direction?: CSSDirection;
20
+ name?: string;
21
+ }
22
+
23
+ type TokenMap = Record<string, string>;
24
+ type HtmlTagName = keyof HTMLElementTagNameMap;
10
25
 
11
26
  /**
12
27
  * tailwind-styled-v4 — Core Types
@@ -301,6 +316,40 @@ declare function cx(...inputs: (ClassValue | ClassValue[])[]): string;
301
316
  /** @deprecated Use cx() instead. */
302
317
  declare const cxm: typeof cx;
303
318
 
319
+ type TokenSubscriber = (tokens: TokenMap) => void;
320
+ interface LiveTokenSet {
321
+ vars: Record<string, string>;
322
+ get(name: string): string | undefined;
323
+ set(name: string, value: string): void;
324
+ setAll(tokens: TokenMap): void;
325
+ snapshot(): TokenMap;
326
+ }
327
+ interface LiveTokenEngineBridge {
328
+ getToken(name: string): string | undefined;
329
+ getTokens(): TokenMap;
330
+ setToken(name: string, value: string): void;
331
+ setTokens(tokens: TokenMap): void;
332
+ applyTokenSet(tokens: TokenMap): void;
333
+ subscribeTokens(fn: TokenSubscriber): () => void;
334
+ subscribe?(fn: TokenSubscriber): () => void;
335
+ }
336
+ declare function tokenVar(name: string): string;
337
+ declare function tokenRef(name: string): string;
338
+ declare function liveToken(tokens: TokenMap): LiveTokenSet;
339
+ declare function setToken(name: string, value: string): void;
340
+ declare function setTokens(tokens: TokenMap): void;
341
+ declare function applyTokenSet(tokens: TokenMap): void;
342
+ declare function getToken(name: string): string | undefined;
343
+ declare function getTokens(): TokenMap;
344
+ declare function subscribeTokens(fn: TokenSubscriber): () => void;
345
+ declare function generateTokenCssString(): string;
346
+ declare function createUseTokens(): () => TokenMap;
347
+ declare global {
348
+ interface Window {
349
+ __TW_TOKEN_ENGINE__?: LiveTokenEngineBridge;
350
+ }
351
+ }
352
+
304
353
  interface ThemeConfig$1 {
305
354
  colors: Record<string, string>;
306
355
  spacing: Record<string, string>;
@@ -675,4 +724,182 @@ declare const v4Tokens: {
675
724
  readonly fontMono: string;
676
725
  };
677
726
 
678
- export { type ComponentConfig, type ContainerConfig, type ContainerEntry, type CvFn, HtmlTagName, type InferVariantProps, type MergeOptions, type ParsedClass, type ParsedClassModifier, type ResolvedThemeTokens, type StateComponentEntry, type StateConfig, type StyledComponentProps, type StyledOptions, type StyledProps, type StyledSystemConfig, type StyledSystemInstance, type SubComponentEntry, type SubComponentMap, type SubComponentProps, type SystemComponentConfig, type SystemComponentFactory, type SystemTokenMap, type ThemeConfig, type ThemeTokenMap, type TwComponentFactory, type TwObject, type TwStyledComponent, type TwSubComponent, type TwTagFactory, type TwTagFactoryAny, type VariantLiterals, cn, createComponent, createStyledSystem, createTheme, createTwMerge, cssVar, cv, cx, cxm, generateContainerCss, generateStateCss, getAllSubComponents, getContainerRegistry, getStateRegistry, getSubComponent, mergeWithRules, processContainer, processState, registerSubComponent, resolveStyledClassName, server, styled, t, tw, twMerge, twVar, v4Tokens, withSubComponents };
727
+ declare const ScanWorkspaceOptionsSchema: z.ZodObject<{
728
+ includeExtensions: z.ZodOptional<z.ZodArray<z.ZodString>>;
729
+ ignoreDirectories: z.ZodOptional<z.ZodArray<z.ZodString>>;
730
+ useCache: z.ZodOptional<z.ZodBoolean>;
731
+ cacheDir: z.ZodOptional<z.ZodString>;
732
+ smartInvalidation: z.ZodOptional<z.ZodBoolean>;
733
+ }, z.core.$strip>;
734
+ type ScanWorkspaceOptions = z.infer<typeof ScanWorkspaceOptionsSchema>;
735
+ declare const ScanWorkspaceResultSchema: z.ZodObject<{
736
+ files: z.ZodArray<z.ZodObject<{
737
+ file: z.ZodString;
738
+ classes: z.ZodArray<z.ZodString>;
739
+ hash: z.ZodOptional<z.ZodString>;
740
+ }, z.core.$strip>>;
741
+ totalFiles: z.ZodNumber;
742
+ uniqueClasses: z.ZodArray<z.ZodString>;
743
+ }, z.core.$strip>;
744
+ type ScanWorkspaceResult = z.infer<typeof ScanWorkspaceResultSchema>;
745
+
746
+ /**
747
+ * Public type contracts for @tailwind-styled/analyzer.
748
+ * Keep this file aligned with the runtime report shape exposed by src/index.ts.
749
+ */
750
+
751
+ interface ClassUsage {
752
+ readonly name: string;
753
+ readonly count: number;
754
+ readonly isUnused?: boolean;
755
+ readonly isConflict?: boolean;
756
+ }
757
+ interface ClassConflict {
758
+ readonly className: string;
759
+ readonly variants: readonly string[];
760
+ readonly classes: readonly string[];
761
+ readonly message: string;
762
+ }
763
+ interface AnalyzerClassStats {
764
+ readonly all: readonly ClassUsage[];
765
+ readonly top: readonly ClassUsage[];
766
+ readonly frequent: readonly ClassUsage[];
767
+ readonly unique: readonly ClassUsage[];
768
+ readonly distribution: Readonly<Record<string, number>>;
769
+ }
770
+ interface TailwindConfigSummary {
771
+ readonly path: string;
772
+ readonly loaded: boolean;
773
+ readonly safelistCount: number;
774
+ readonly customUtilityCount: number;
775
+ readonly warning?: string;
776
+ }
777
+ interface AnalyzerSemanticReport {
778
+ readonly unusedClasses: readonly ClassUsage[];
779
+ readonly unknownClasses: readonly ClassUsage[];
780
+ readonly conflicts: readonly ClassConflict[];
781
+ readonly tailwindConfig?: TailwindConfigSummary;
782
+ }
783
+ interface AnalyzerReport {
784
+ readonly root: string;
785
+ readonly totalFiles: number;
786
+ readonly uniqueClassCount: number;
787
+ readonly totalClassOccurrences: number;
788
+ readonly classStats: AnalyzerClassStats;
789
+ /** Alias for classStats.top — backward compat & test contract */
790
+ readonly topClasses: readonly ClassUsage[];
791
+ readonly safelist: readonly string[];
792
+ readonly semantic?: AnalyzerSemanticReport;
793
+ }
794
+ interface AnalyzerOptions {
795
+ readonly scanner?: ScanWorkspaceOptions;
796
+ readonly classStats?: {
797
+ readonly top?: number;
798
+ readonly frequentThreshold?: number;
799
+ };
800
+ readonly includeClass?: (className: string) => boolean;
801
+ readonly semantic?: boolean | {
802
+ readonly tailwindConfigPath?: string;
803
+ };
804
+ }
805
+
806
+ /**
807
+ * Analyze Tailwind class usage in a workspace and return usage statistics.
808
+ * Set `semantic.tailwindConfigPath` to override Tailwind config lookup.
809
+ * @example
810
+ * const report = await analyzeWorkspace("./src", {
811
+ * classStats: { top: 20, frequentThreshold: 2 },
812
+ * semantic: { tailwindConfigPath: "tailwind.config.js" },
813
+ * })
814
+ */
815
+ declare function analyzeWorkspace(root: string, options?: AnalyzerOptions): Promise<AnalyzerReport>;
816
+
817
+ interface EngineMetricsSnapshot {
818
+ eventsReceived: number;
819
+ eventsProcessed: number;
820
+ batchesProcessed: number;
821
+ incrementalUpdates: number;
822
+ fullRescans: number;
823
+ skippedLargeFiles: number;
824
+ queueMaxSize: number;
825
+ lastBuildMs: number;
826
+ avgBuildMs: number;
827
+ }
828
+
829
+ interface EnginePluginContext {
830
+ root: string;
831
+ timestamp: number;
832
+ }
833
+ interface EngineWatchContext {
834
+ root: string;
835
+ timestamp: number;
836
+ }
837
+ interface EnginePlugin {
838
+ name: string;
839
+ beforeScan?(context: EnginePluginContext): void | Promise<void>;
840
+ afterScan?(scan: ScanWorkspaceResult, context: EnginePluginContext): ScanWorkspaceResult | undefined | Promise<ScanWorkspaceResult | undefined>;
841
+ transformClasses?(classes: string[], context: EnginePluginContext): string[] | undefined | Promise<string[] | undefined>;
842
+ beforeBuild?(scan: ScanWorkspaceResult, context: EnginePluginContext): void | Promise<void>;
843
+ afterBuild?(result: BuildResult, context: EnginePluginContext): BuildResult | undefined | Promise<BuildResult | undefined>;
844
+ onError?(error: Error, context: EnginePluginContext): void | Promise<void>;
845
+ beforeWatch?(context: EngineWatchContext): void | Promise<void>;
846
+ afterWatch?(context: EngineWatchContext): void | Promise<void>;
847
+ }
848
+
849
+ interface EngineOptions {
850
+ root?: string;
851
+ scanner?: ScanWorkspaceOptions;
852
+ compileCss?: boolean;
853
+ tailwindConfigPath?: string;
854
+ plugins?: EnginePlugin[];
855
+ /** Enable analyzer integration - provides semantic report (unused classes, conflicts). Default: false */
856
+ analyze?: boolean;
857
+ }
858
+ interface EngineWatchOptions {
859
+ debounceMs?: number;
860
+ maxEventsPerFlush?: number;
861
+ largeFileThreshold?: number;
862
+ }
863
+ interface BuildResult {
864
+ scan: ScanWorkspaceResult;
865
+ mergedClassList: string;
866
+ css: string;
867
+ /** Analyzer semantic report - present when analyze: true in options */
868
+ analysis?: {
869
+ unusedClasses: string[];
870
+ classConflicts: Array<{
871
+ className: string;
872
+ files: string[];
873
+ classes?: string[];
874
+ message?: string;
875
+ }>;
876
+ classUsage: Record<string, number>;
877
+ semantic?: AnalyzerSemanticReport;
878
+ report: AnalyzerReport;
879
+ };
880
+ }
881
+ type EngineBuildWatchEventType = "initial" | "change" | "unlink" | "full-rescan";
882
+ type EngineWatchEvent = {
883
+ type: EngineBuildWatchEventType;
884
+ filePath?: string;
885
+ result: BuildResult;
886
+ metrics?: EngineMetricsSnapshot;
887
+ } | {
888
+ type: "error";
889
+ filePath?: string;
890
+ error: string;
891
+ metrics?: EngineMetricsSnapshot;
892
+ };
893
+ interface TailwindStyledEngine {
894
+ scan(): Promise<ScanWorkspaceResult>;
895
+ scanWorkspace(): Promise<ScanWorkspaceResult>;
896
+ analyzeWorkspace(): Promise<Awaited<ReturnType<typeof analyzeWorkspace>>>;
897
+ generateSafelist(): Promise<string[]>;
898
+ build(): Promise<BuildResult>;
899
+ watch(onEvent: (event: EngineWatchEvent) => void, options?: EngineWatchOptions): Promise<{
900
+ close(): void;
901
+ }>;
902
+ }
903
+ declare function createEngine(rawOptions?: EngineOptions): Promise<TailwindStyledEngine>;
904
+
905
+ export { type ComponentConfig, type ContainerConfig, type ContainerEntry, type CvFn, type HtmlTagName, type InferVariantProps, type LiveTokenSet, type MergeOptions, type ParsedClass, type ParsedClassModifier, type ResolvedThemeTokens, type StateComponentEntry, type StateConfig, type StyledComponentProps, type StyledOptions, type StyledProps, type StyledSystemConfig, type StyledSystemInstance, type SubComponentEntry, type SubComponentMap, type SubComponentProps, type SystemComponentConfig, type SystemComponentFactory, type SystemTokenMap, type ThemeConfig, type ThemeTokenMap, type TokenMap, type TokenSubscriber, type TwComponentFactory, type TwObject, type TwStyledComponent, type TwSubComponent, type TwTagFactory, type TwTagFactoryAny, type VariantLiterals, applyTokenSet, cn, tokenRef as containerRef, createComponent, createEngine, createStyledSystem, createTheme, createTwMerge, createUseTokens, cssVar, cv, cx, cxm, generateContainerCss, generateStateCss, generateTokenCssString, getAllSubComponents, getContainerRegistry, getStateRegistry, getSubComponent, getToken, getTokens, liveToken, mergeWithRules, processContainer, processState, registerSubComponent, resolveStyledClassName, server, setToken, setTokens, styled, subscribeTokens, t, tokenRef, tokenVar, tw, twMerge, twVar, v4Tokens, withSubComponents };
package/dist/index.d.ts CHANGED
@@ -1,12 +1,27 @@
1
1
  import React from 'react';
2
- import { a as AnimateOptions } from './types-DXr2PmGP.js';
3
- import { H as HtmlTagName } from './index-NDINUhLN.js';
4
- export { T as TokenMap } from './index-NDINUhLN.js';
5
- export { a as LiveTokenSet, T as TokenSubscriber, b as applyTokenSet, t as containerRef, c as createUseTokens, g as generateTokenCssString, d as getToken, e as getTokens, l as liveToken, s as setToken, h as setTokens, i as subscribeTokens, t as tokenRef, j as tokenVar } from './liveTokenEngine-CN9ian1R.js';
6
- export { K as createEngine } from './index-UkYbyBkR.js';
7
- import './analyzeWorkspace-B1_XRfdl.js';
8
- import './schemas-DR-SLxZZ.js';
9
- import 'zod';
2
+ import { z } from 'zod';
3
+
4
+ type CSSFillMode = "none" | "forwards" | "backwards" | "both";
5
+ type CSSDirection = "normal" | "reverse" | "alternate" | "alternate-reverse";
6
+ type CSSIterationCount = number | "infinite";
7
+ type PresetEasing = "linear" | "ease" | "ease-in" | "ease-out" | "ease-in-out" | "step-start" | "step-end";
8
+ type CubicBezierEasing = `cubic-bezier(${string})`;
9
+ type StepsEasing = `steps(${string})`;
10
+ type CSSEasing = PresetEasing | CubicBezierEasing | StepsEasing;
11
+ interface AnimateOptions {
12
+ from: string;
13
+ to: string;
14
+ duration?: number;
15
+ easing?: CSSEasing;
16
+ delay?: number;
17
+ fill?: CSSFillMode;
18
+ iterations?: CSSIterationCount;
19
+ direction?: CSSDirection;
20
+ name?: string;
21
+ }
22
+
23
+ type TokenMap = Record<string, string>;
24
+ type HtmlTagName = keyof HTMLElementTagNameMap;
10
25
 
11
26
  /**
12
27
  * tailwind-styled-v4 — Core Types
@@ -301,6 +316,40 @@ declare function cx(...inputs: (ClassValue | ClassValue[])[]): string;
301
316
  /** @deprecated Use cx() instead. */
302
317
  declare const cxm: typeof cx;
303
318
 
319
+ type TokenSubscriber = (tokens: TokenMap) => void;
320
+ interface LiveTokenSet {
321
+ vars: Record<string, string>;
322
+ get(name: string): string | undefined;
323
+ set(name: string, value: string): void;
324
+ setAll(tokens: TokenMap): void;
325
+ snapshot(): TokenMap;
326
+ }
327
+ interface LiveTokenEngineBridge {
328
+ getToken(name: string): string | undefined;
329
+ getTokens(): TokenMap;
330
+ setToken(name: string, value: string): void;
331
+ setTokens(tokens: TokenMap): void;
332
+ applyTokenSet(tokens: TokenMap): void;
333
+ subscribeTokens(fn: TokenSubscriber): () => void;
334
+ subscribe?(fn: TokenSubscriber): () => void;
335
+ }
336
+ declare function tokenVar(name: string): string;
337
+ declare function tokenRef(name: string): string;
338
+ declare function liveToken(tokens: TokenMap): LiveTokenSet;
339
+ declare function setToken(name: string, value: string): void;
340
+ declare function setTokens(tokens: TokenMap): void;
341
+ declare function applyTokenSet(tokens: TokenMap): void;
342
+ declare function getToken(name: string): string | undefined;
343
+ declare function getTokens(): TokenMap;
344
+ declare function subscribeTokens(fn: TokenSubscriber): () => void;
345
+ declare function generateTokenCssString(): string;
346
+ declare function createUseTokens(): () => TokenMap;
347
+ declare global {
348
+ interface Window {
349
+ __TW_TOKEN_ENGINE__?: LiveTokenEngineBridge;
350
+ }
351
+ }
352
+
304
353
  interface ThemeConfig$1 {
305
354
  colors: Record<string, string>;
306
355
  spacing: Record<string, string>;
@@ -675,4 +724,182 @@ declare const v4Tokens: {
675
724
  readonly fontMono: string;
676
725
  };
677
726
 
678
- export { type ComponentConfig, type ContainerConfig, type ContainerEntry, type CvFn, HtmlTagName, type InferVariantProps, type MergeOptions, type ParsedClass, type ParsedClassModifier, type ResolvedThemeTokens, type StateComponentEntry, type StateConfig, type StyledComponentProps, type StyledOptions, type StyledProps, type StyledSystemConfig, type StyledSystemInstance, type SubComponentEntry, type SubComponentMap, type SubComponentProps, type SystemComponentConfig, type SystemComponentFactory, type SystemTokenMap, type ThemeConfig, type ThemeTokenMap, type TwComponentFactory, type TwObject, type TwStyledComponent, type TwSubComponent, type TwTagFactory, type TwTagFactoryAny, type VariantLiterals, cn, createComponent, createStyledSystem, createTheme, createTwMerge, cssVar, cv, cx, cxm, generateContainerCss, generateStateCss, getAllSubComponents, getContainerRegistry, getStateRegistry, getSubComponent, mergeWithRules, processContainer, processState, registerSubComponent, resolveStyledClassName, server, styled, t, tw, twMerge, twVar, v4Tokens, withSubComponents };
727
+ declare const ScanWorkspaceOptionsSchema: z.ZodObject<{
728
+ includeExtensions: z.ZodOptional<z.ZodArray<z.ZodString>>;
729
+ ignoreDirectories: z.ZodOptional<z.ZodArray<z.ZodString>>;
730
+ useCache: z.ZodOptional<z.ZodBoolean>;
731
+ cacheDir: z.ZodOptional<z.ZodString>;
732
+ smartInvalidation: z.ZodOptional<z.ZodBoolean>;
733
+ }, z.core.$strip>;
734
+ type ScanWorkspaceOptions = z.infer<typeof ScanWorkspaceOptionsSchema>;
735
+ declare const ScanWorkspaceResultSchema: z.ZodObject<{
736
+ files: z.ZodArray<z.ZodObject<{
737
+ file: z.ZodString;
738
+ classes: z.ZodArray<z.ZodString>;
739
+ hash: z.ZodOptional<z.ZodString>;
740
+ }, z.core.$strip>>;
741
+ totalFiles: z.ZodNumber;
742
+ uniqueClasses: z.ZodArray<z.ZodString>;
743
+ }, z.core.$strip>;
744
+ type ScanWorkspaceResult = z.infer<typeof ScanWorkspaceResultSchema>;
745
+
746
+ /**
747
+ * Public type contracts for @tailwind-styled/analyzer.
748
+ * Keep this file aligned with the runtime report shape exposed by src/index.ts.
749
+ */
750
+
751
+ interface ClassUsage {
752
+ readonly name: string;
753
+ readonly count: number;
754
+ readonly isUnused?: boolean;
755
+ readonly isConflict?: boolean;
756
+ }
757
+ interface ClassConflict {
758
+ readonly className: string;
759
+ readonly variants: readonly string[];
760
+ readonly classes: readonly string[];
761
+ readonly message: string;
762
+ }
763
+ interface AnalyzerClassStats {
764
+ readonly all: readonly ClassUsage[];
765
+ readonly top: readonly ClassUsage[];
766
+ readonly frequent: readonly ClassUsage[];
767
+ readonly unique: readonly ClassUsage[];
768
+ readonly distribution: Readonly<Record<string, number>>;
769
+ }
770
+ interface TailwindConfigSummary {
771
+ readonly path: string;
772
+ readonly loaded: boolean;
773
+ readonly safelistCount: number;
774
+ readonly customUtilityCount: number;
775
+ readonly warning?: string;
776
+ }
777
+ interface AnalyzerSemanticReport {
778
+ readonly unusedClasses: readonly ClassUsage[];
779
+ readonly unknownClasses: readonly ClassUsage[];
780
+ readonly conflicts: readonly ClassConflict[];
781
+ readonly tailwindConfig?: TailwindConfigSummary;
782
+ }
783
+ interface AnalyzerReport {
784
+ readonly root: string;
785
+ readonly totalFiles: number;
786
+ readonly uniqueClassCount: number;
787
+ readonly totalClassOccurrences: number;
788
+ readonly classStats: AnalyzerClassStats;
789
+ /** Alias for classStats.top — backward compat & test contract */
790
+ readonly topClasses: readonly ClassUsage[];
791
+ readonly safelist: readonly string[];
792
+ readonly semantic?: AnalyzerSemanticReport;
793
+ }
794
+ interface AnalyzerOptions {
795
+ readonly scanner?: ScanWorkspaceOptions;
796
+ readonly classStats?: {
797
+ readonly top?: number;
798
+ readonly frequentThreshold?: number;
799
+ };
800
+ readonly includeClass?: (className: string) => boolean;
801
+ readonly semantic?: boolean | {
802
+ readonly tailwindConfigPath?: string;
803
+ };
804
+ }
805
+
806
+ /**
807
+ * Analyze Tailwind class usage in a workspace and return usage statistics.
808
+ * Set `semantic.tailwindConfigPath` to override Tailwind config lookup.
809
+ * @example
810
+ * const report = await analyzeWorkspace("./src", {
811
+ * classStats: { top: 20, frequentThreshold: 2 },
812
+ * semantic: { tailwindConfigPath: "tailwind.config.js" },
813
+ * })
814
+ */
815
+ declare function analyzeWorkspace(root: string, options?: AnalyzerOptions): Promise<AnalyzerReport>;
816
+
817
+ interface EngineMetricsSnapshot {
818
+ eventsReceived: number;
819
+ eventsProcessed: number;
820
+ batchesProcessed: number;
821
+ incrementalUpdates: number;
822
+ fullRescans: number;
823
+ skippedLargeFiles: number;
824
+ queueMaxSize: number;
825
+ lastBuildMs: number;
826
+ avgBuildMs: number;
827
+ }
828
+
829
+ interface EnginePluginContext {
830
+ root: string;
831
+ timestamp: number;
832
+ }
833
+ interface EngineWatchContext {
834
+ root: string;
835
+ timestamp: number;
836
+ }
837
+ interface EnginePlugin {
838
+ name: string;
839
+ beforeScan?(context: EnginePluginContext): void | Promise<void>;
840
+ afterScan?(scan: ScanWorkspaceResult, context: EnginePluginContext): ScanWorkspaceResult | undefined | Promise<ScanWorkspaceResult | undefined>;
841
+ transformClasses?(classes: string[], context: EnginePluginContext): string[] | undefined | Promise<string[] | undefined>;
842
+ beforeBuild?(scan: ScanWorkspaceResult, context: EnginePluginContext): void | Promise<void>;
843
+ afterBuild?(result: BuildResult, context: EnginePluginContext): BuildResult | undefined | Promise<BuildResult | undefined>;
844
+ onError?(error: Error, context: EnginePluginContext): void | Promise<void>;
845
+ beforeWatch?(context: EngineWatchContext): void | Promise<void>;
846
+ afterWatch?(context: EngineWatchContext): void | Promise<void>;
847
+ }
848
+
849
+ interface EngineOptions {
850
+ root?: string;
851
+ scanner?: ScanWorkspaceOptions;
852
+ compileCss?: boolean;
853
+ tailwindConfigPath?: string;
854
+ plugins?: EnginePlugin[];
855
+ /** Enable analyzer integration - provides semantic report (unused classes, conflicts). Default: false */
856
+ analyze?: boolean;
857
+ }
858
+ interface EngineWatchOptions {
859
+ debounceMs?: number;
860
+ maxEventsPerFlush?: number;
861
+ largeFileThreshold?: number;
862
+ }
863
+ interface BuildResult {
864
+ scan: ScanWorkspaceResult;
865
+ mergedClassList: string;
866
+ css: string;
867
+ /** Analyzer semantic report - present when analyze: true in options */
868
+ analysis?: {
869
+ unusedClasses: string[];
870
+ classConflicts: Array<{
871
+ className: string;
872
+ files: string[];
873
+ classes?: string[];
874
+ message?: string;
875
+ }>;
876
+ classUsage: Record<string, number>;
877
+ semantic?: AnalyzerSemanticReport;
878
+ report: AnalyzerReport;
879
+ };
880
+ }
881
+ type EngineBuildWatchEventType = "initial" | "change" | "unlink" | "full-rescan";
882
+ type EngineWatchEvent = {
883
+ type: EngineBuildWatchEventType;
884
+ filePath?: string;
885
+ result: BuildResult;
886
+ metrics?: EngineMetricsSnapshot;
887
+ } | {
888
+ type: "error";
889
+ filePath?: string;
890
+ error: string;
891
+ metrics?: EngineMetricsSnapshot;
892
+ };
893
+ interface TailwindStyledEngine {
894
+ scan(): Promise<ScanWorkspaceResult>;
895
+ scanWorkspace(): Promise<ScanWorkspaceResult>;
896
+ analyzeWorkspace(): Promise<Awaited<ReturnType<typeof analyzeWorkspace>>>;
897
+ generateSafelist(): Promise<string[]>;
898
+ build(): Promise<BuildResult>;
899
+ watch(onEvent: (event: EngineWatchEvent) => void, options?: EngineWatchOptions): Promise<{
900
+ close(): void;
901
+ }>;
902
+ }
903
+ declare function createEngine(rawOptions?: EngineOptions): Promise<TailwindStyledEngine>;
904
+
905
+ export { type ComponentConfig, type ContainerConfig, type ContainerEntry, type CvFn, type HtmlTagName, type InferVariantProps, type LiveTokenSet, type MergeOptions, type ParsedClass, type ParsedClassModifier, type ResolvedThemeTokens, type StateComponentEntry, type StateConfig, type StyledComponentProps, type StyledOptions, type StyledProps, type StyledSystemConfig, type StyledSystemInstance, type SubComponentEntry, type SubComponentMap, type SubComponentProps, type SystemComponentConfig, type SystemComponentFactory, type SystemTokenMap, type ThemeConfig, type ThemeTokenMap, type TokenMap, type TokenSubscriber, type TwComponentFactory, type TwObject, type TwStyledComponent, type TwSubComponent, type TwTagFactory, type TwTagFactoryAny, type VariantLiterals, applyTokenSet, cn, tokenRef as containerRef, createComponent, createEngine, createStyledSystem, createTheme, createTwMerge, createUseTokens, cssVar, cv, cx, cxm, generateContainerCss, generateStateCss, generateTokenCssString, getAllSubComponents, getContainerRegistry, getStateRegistry, getSubComponent, getToken, getTokens, liveToken, mergeWithRules, processContainer, processState, registerSubComponent, resolveStyledClassName, server, setToken, setTokens, styled, subscribeTokens, t, tokenRef, tokenVar, tw, twMerge, twVar, v4Tokens, withSubComponents };
package/dist/index.js CHANGED
@@ -5228,17 +5228,12 @@ function hashState(tag, state) {
5228
5228
  _hashStateCache.set(sortedKey, id);
5229
5229
  return id;
5230
5230
  }
5231
- var _twClassesToCssCache = /* @__PURE__ */ new Map();
5232
- function twClassesToCss(classes) {
5233
- const cached = _twClassesToCssCache.get(classes);
5234
- if (cached !== void 0) return cached;
5231
+ function generateStateRules(id, state) {
5235
5232
  const native = getNativeBinding();
5236
- if (!native?.twClassesToCss) {
5237
- throw new Error("FATAL: Native binding 'twClassesToCss' is required but not available.");
5233
+ if (!native?.generateRuntimeStateCss) {
5234
+ throw new Error("FATAL: Native binding 'generateRuntimeStateCss' is required but not available.");
5238
5235
  }
5239
- const result = native.twClassesToCss(classes);
5240
- _twClassesToCssCache.set(classes, result);
5241
- return result;
5236
+ return native.generateRuntimeStateCss(id, JSON.stringify(state), null).map((rule) => rule.cssRule);
5242
5237
  }
5243
5238
  var _staticCssDetected = /* @__PURE__ */ new Set();
5244
5239
  var _batchedInjectFn = null;
@@ -5270,10 +5265,7 @@ function injectStateStyles(id, state) {
5270
5265
  }
5271
5266
  }
5272
5267
  }
5273
- const rules = Object.entries(state).map(([stateName, classes]) => {
5274
- const css = twClassesToCss(classes);
5275
- return css ? `.${id}[data-${stateName}="true"]{${css}}` : null;
5276
- }).filter(Boolean);
5268
+ const rules = generateStateRules(id, state);
5277
5269
  if (rules.length === 0) return;
5278
5270
  if (_batchedInjectFn) {
5279
5271
  for (const rule of rules) _batchedInjectFn(rule);
@@ -5303,11 +5295,7 @@ function processState(tag, state, precomputedHash) {
5303
5295
  }
5304
5296
  function generateStateCss(tag, state) {
5305
5297
  const id = hashState(tag, state);
5306
- const rules = Object.entries(state).map(([stateName, classes]) => {
5307
- const css = twClassesToCss(classes);
5308
- return css ? `.${id}[data-${stateName}="true"]{${css}}` : null;
5309
- }).filter(Boolean);
5310
- return rules.join("\n");
5298
+ return generateStateRules(id, state).join("\n");
5311
5299
  }
5312
5300
  function getStateRegistry() {
5313
5301
  return stateRegistry;
@@ -5712,7 +5700,13 @@ function lookupGenerated(componentId, props, defaultVariants, variantKeys) {
5712
5700
  }
5713
5701
  const binding = getNativeBinding();
5714
5702
  if (!binding?.buildVariantLookupKey) {
5715
- throw new Error("FATAL: Native binding 'buildVariantLookupKey' is required but not available.");
5703
+ const parts = [];
5704
+ for (const k of sortedKeys) {
5705
+ const v = props[k] ?? defaultVariants?.[k];
5706
+ if (v != null) parts.push(`${k}:${String(v)}`);
5707
+ }
5708
+ const key2 = parts.join("|");
5709
+ return table[key2];
5716
5710
  }
5717
5711
  const relevantDefaults = {};
5718
5712
  const relevantProps = {};
@@ -5755,7 +5749,31 @@ function resolveVariantsNative(config, props) {
5755
5749
  const { variants = {}, defaultVariants = {} } = config;
5756
5750
  const binding = getNativeBinding();
5757
5751
  if (!binding?.resolveVariants) {
5758
- throw new Error("FATAL: Native binding 'resolveVariants' is required but not available. Build cannot continue.");
5752
+ const variantKeys2 = Object.keys(variants);
5753
+ const classes = [];
5754
+ for (const key of variantKeys2) {
5755
+ const value = props[key] ?? defaultVariants[key];
5756
+ if (value != null) {
5757
+ const variantClass = variants[key]?.[String(value)];
5758
+ if (variantClass) classes.push(variantClass);
5759
+ }
5760
+ }
5761
+ if (config.compoundVariants) {
5762
+ for (const compound of config.compoundVariants) {
5763
+ const { class: compoundClass, ...conditions } = compound;
5764
+ const resolved = {};
5765
+ for (const key of variantKeys2) {
5766
+ resolved[key] = String(
5767
+ props[key] ?? defaultVariants[key] ?? ""
5768
+ );
5769
+ }
5770
+ const matches = Object.entries(conditions).every(
5771
+ ([k, v]) => resolved[k] === v
5772
+ );
5773
+ if (matches) classes.push(compoundClass);
5774
+ }
5775
+ }
5776
+ return classes.join(" ");
5759
5777
  }
5760
5778
  const variantKeys = Object.keys(variants);
5761
5779
  const configJson = _getConfigJson(config);