chaincss 2.0.6 → 2.1.0

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 (159) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/CODE_OF_CONDUCT.md +21 -0
  3. package/CONTRIBUTING.md +28 -0
  4. package/README.md +454 -231
  5. package/demo/demo/node_modules/caniuse-db/fulldata-json/data-2.0.json +1 -0
  6. package/demo/index.html +16 -0
  7. package/demo/package.json +20 -0
  8. package/demo/src/App.tsx +117 -0
  9. package/demo/src/chaincss-barrel.ts +9 -0
  10. package/demo/src/main.tsx +8 -0
  11. package/demo/src/styles.chain.ts +300 -0
  12. package/demo/vite.config.ts +46 -0
  13. package/dist/cli/commands/build.d.ts +0 -1
  14. package/dist/cli/commands/cache.d.ts +1 -0
  15. package/dist/cli/commands/init.d.ts +6 -3
  16. package/dist/cli/commands/timeline.d.ts +0 -1
  17. package/dist/cli/commands/watch.d.ts +0 -1
  18. package/dist/cli/index.d.ts +0 -1
  19. package/dist/cli/index.js +3213 -5296
  20. package/dist/cli/types.d.ts +51 -20
  21. package/dist/cli/utils/config-loader.d.ts +0 -1
  22. package/dist/cli/utils/file-utils.d.ts +27 -3
  23. package/dist/cli/utils/logger.d.ts +0 -1
  24. package/dist/compiler/Chain.d.ts +215 -0
  25. package/dist/compiler/animations.d.ts +76 -0
  26. package/dist/compiler/atomic-optimizer.d.ts +47 -12
  27. package/dist/compiler/breakpoints.d.ts +46 -0
  28. package/dist/compiler/btt.d.ts +36 -60
  29. package/dist/compiler/cache-manager.d.ts +58 -4
  30. package/dist/compiler/commonProps.d.ts +0 -1
  31. package/dist/compiler/content-addressable-cache.d.ts +78 -0
  32. package/dist/compiler/helpers.d.ts +54 -0
  33. package/dist/compiler/index.d.ts +16 -9
  34. package/dist/compiler/index.js +4450 -4316
  35. package/dist/compiler/prefixer.d.ts +17 -1
  36. package/dist/compiler/shorthands.d.ts +28 -0
  37. package/dist/compiler/suggestions.d.ts +43 -0
  38. package/dist/compiler/theme-contract.d.ts +16 -27
  39. package/dist/compiler/token-resolver.d.ts +69 -0
  40. package/dist/compiler/tokens.d.ts +33 -8
  41. package/dist/core/auto-detector.d.ts +34 -0
  42. package/dist/core/common-utils.d.ts +97 -0
  43. package/dist/core/compiler.d.ts +63 -23
  44. package/dist/core/constants.d.ts +137 -36
  45. package/dist/core/smart-chain.d.ts +3 -0
  46. package/dist/core/types.d.ts +122 -15
  47. package/dist/core/utils.d.ts +134 -17
  48. package/dist/index.d.ts +52 -8
  49. package/dist/index.js +7090 -5578
  50. package/dist/plugins/vite.d.ts +7 -5
  51. package/dist/plugins/vite.js +2964 -25641
  52. package/dist/plugins/webpack.d.ts +24 -1
  53. package/dist/plugins/webpack.js +209 -72
  54. package/dist/runtime/Chain.d.ts +32 -0
  55. package/dist/runtime/auto-hooks.d.ts +11 -0
  56. package/dist/runtime/hmr.d.ts +22 -2
  57. package/dist/runtime/index.d.ts +3 -2
  58. package/dist/runtime/index.js +3649 -301
  59. package/dist/runtime/injector.d.ts +39 -71
  60. package/dist/runtime/react.d.ts +17 -12
  61. package/dist/runtime/svelte.d.ts +15 -0
  62. package/dist/runtime/types.d.ts +126 -4
  63. package/dist/runtime/utils.d.ts +0 -1
  64. package/dist/runtime/vue.d.ts +34 -14
  65. package/package.json +59 -66
  66. package/src/cli/commands/build.ts +133 -0
  67. package/src/cli/commands/cache.ts +371 -0
  68. package/src/cli/commands/init.ts +230 -0
  69. package/src/cli/commands/timeline.ts +435 -0
  70. package/src/cli/commands/watch.ts +211 -0
  71. package/src/cli/index.ts +226 -0
  72. package/src/cli/types.ts +100 -0
  73. package/src/cli/utils/config-loader.ts +174 -0
  74. package/src/cli/utils/file-utils.ts +139 -0
  75. package/src/cli/utils/logger.ts +74 -0
  76. package/src/compiler/Chain.ts +831 -0
  77. package/src/compiler/animations.ts +517 -0
  78. package/src/compiler/atomic-optimizer.ts +786 -0
  79. package/src/compiler/breakpoints.ts +347 -0
  80. package/src/compiler/btt.ts +1147 -0
  81. package/src/compiler/cache-manager.ts +446 -0
  82. package/src/compiler/commonProps.ts +18 -0
  83. package/src/compiler/content-addressable-cache.ts +478 -0
  84. package/src/compiler/helpers.ts +407 -0
  85. package/src/compiler/index.ts +72 -0
  86. package/src/compiler/prefixer.ts +724 -0
  87. package/src/compiler/shorthands.ts +558 -0
  88. package/src/compiler/suggestions.ts +436 -0
  89. package/src/compiler/theme-contract.ts +197 -0
  90. package/src/compiler/token-resolver.ts +241 -0
  91. package/src/compiler/tokens.ts +612 -0
  92. package/src/core/auto-detector.ts +187 -0
  93. package/src/core/common-utils.ts +423 -0
  94. package/src/core/compiler.ts +835 -0
  95. package/src/core/constants.ts +424 -0
  96. package/src/core/index.ts +107 -0
  97. package/src/core/smart-chain.ts +163 -0
  98. package/src/core/types.ts +257 -0
  99. package/src/core/utils.ts +598 -0
  100. package/src/index.ts +208 -0
  101. package/src/plugins/vite.d.ts +316 -0
  102. package/src/plugins/vite.ts +424 -0
  103. package/src/plugins/webpack.d.ts +289 -0
  104. package/src/plugins/webpack.ts +416 -0
  105. package/src/runtime/Chain.ts +242 -0
  106. package/src/runtime/auto-hooks.tsx +127 -0
  107. package/src/runtime/auto-vue.ts +72 -0
  108. package/src/runtime/hmr.ts +212 -0
  109. package/src/runtime/index.ts +82 -0
  110. package/src/runtime/injector.ts +273 -0
  111. package/src/runtime/react.tsx +269 -0
  112. package/src/runtime/svelte.ts +15 -0
  113. package/src/runtime/types.ts +256 -0
  114. package/src/runtime/utils.ts +128 -0
  115. package/src/runtime/vite-env.d.ts +120 -0
  116. package/src/runtime/vue.ts +231 -0
  117. package/tsconfig.build.json +41 -0
  118. package/tsconfig.json +25 -0
  119. package/tsconfig.runtimes.json +18 -0
  120. package/dist/cli/cli.cjs +0 -7
  121. package/dist/cli/commands/build.d.ts.map +0 -1
  122. package/dist/cli/commands/compile.d.ts +0 -3
  123. package/dist/cli/commands/compile.d.ts.map +0 -1
  124. package/dist/cli/commands/init.d.ts.map +0 -1
  125. package/dist/cli/commands/timeline.d.ts.map +0 -1
  126. package/dist/cli/commands/watch.d.ts.map +0 -1
  127. package/dist/cli/index.d.ts.map +0 -1
  128. package/dist/cli/types.d.ts.map +0 -1
  129. package/dist/cli/utils/config-loader.d.ts.map +0 -1
  130. package/dist/cli/utils/file-utils.d.ts.map +0 -1
  131. package/dist/cli/utils/logger.d.ts.map +0 -1
  132. package/dist/compiler/atomic-optimizer.d.ts.map +0 -1
  133. package/dist/compiler/btt.d.ts.map +0 -1
  134. package/dist/compiler/cache-manager.d.ts.map +0 -1
  135. package/dist/compiler/commonProps.d.ts.map +0 -1
  136. package/dist/compiler/index.d.ts.map +0 -1
  137. package/dist/compiler/prefixer.d.ts.map +0 -1
  138. package/dist/compiler/theme-contract.d.ts.map +0 -1
  139. package/dist/compiler/tokens.d.ts.map +0 -1
  140. package/dist/compiler/types.d.ts +0 -57
  141. package/dist/compiler/types.d.ts.map +0 -1
  142. package/dist/core/compiler.d.ts.map +0 -1
  143. package/dist/core/constants.d.ts.map +0 -1
  144. package/dist/core/index.d.ts +0 -4
  145. package/dist/core/index.d.ts.map +0 -1
  146. package/dist/core/types.d.ts.map +0 -1
  147. package/dist/core/utils.d.ts.map +0 -1
  148. package/dist/index.d.ts.map +0 -1
  149. package/dist/plugins/vite.d.ts.map +0 -1
  150. package/dist/plugins/webpack.d.ts.map +0 -1
  151. package/dist/runtime/hmr.d.ts.map +0 -1
  152. package/dist/runtime/index.d.ts.map +0 -1
  153. package/dist/runtime/injector.d.ts.map +0 -1
  154. package/dist/runtime/react.d.ts.map +0 -1
  155. package/dist/runtime/react.js +0 -270
  156. package/dist/runtime/types.d.ts.map +0 -1
  157. package/dist/runtime/utils.d.ts.map +0 -1
  158. package/dist/runtime/vue.d.ts.map +0 -1
  159. package/dist/runtime/vue.js +0 -232
@@ -2,6 +2,7 @@
2
2
  * ChainCSS Constants
3
3
  * Shared constants used across the codebase
4
4
  */
5
+ import type { ChainCSSConfig } from './types.js';
5
6
  export declare const VERSION = "2.0.0";
6
7
  export declare const NEVER_ATOMIC_PROPERTIES: string[];
7
8
  export declare const ALWAYS_ATOMIC_PROPERTIES: string[];
@@ -12,7 +13,7 @@ export declare const DEFAULT_CLASS_MAP_FILENAME = "class-map.json";
12
13
  export declare const DEFAULT_TYPES_FILENAME = "classes.d.ts";
13
14
  export declare const DEFAULT_CACHE_PATH = "./.chaincss-cache";
14
15
  export declare const CACHE_VERSION = "2.0.0";
15
- export declare const DEFAULT_ATOMIC_THRESHOLD = 3;
16
+ export declare const DEFAULT_ATOMIC_THRESHOLD = 2;
16
17
  export declare const MIN_ATOMIC_THRESHOLD = 2;
17
18
  export declare const MAX_ATOMIC_THRESHOLD = 10;
18
19
  export declare const NAMING_SCHEMES: readonly ["hash", "readable"];
@@ -46,6 +47,17 @@ export declare const PATTERNS: {
46
47
  TOKEN_REFERENCE: RegExp;
47
48
  HOVER_STATE: RegExp;
48
49
  PSEUDO_CLASS: RegExp;
50
+ CSS_VARIABLE: RegExp;
51
+ SHORTHAND_PROPERTY: RegExp;
52
+ URL_REFERENCE: RegExp;
53
+ IMPORT_STATEMENT: RegExp;
54
+ FONT_FACE: RegExp;
55
+ STYLE_OBJECT: RegExp;
56
+ CHAIN_METHOD: RegExp;
57
+ HEX_COLOR: RegExp;
58
+ RGB_COLOR: RegExp;
59
+ RGBA_COLOR: RegExp;
60
+ HSL_COLOR: RegExp;
49
61
  };
50
62
  export declare const ERROR_MESSAGES: {
51
63
  FILE_NOT_FOUND: (file: string) => string;
@@ -71,45 +83,130 @@ export declare const DEFAULT_BREAKPOINTS: {
71
83
  tablet: string;
72
84
  desktop: string;
73
85
  };
74
- export declare const DEFAULT_CONFIG: {
75
- tokens: {
76
- enabled: boolean;
77
- prefix: string;
86
+ export declare const PERFORMANCE: {
87
+ readonly MAX_CONCURRENT_COMPILATIONS: 10;
88
+ readonly BATCH_SIZE: 20;
89
+ readonly CACHE_PRUNE_INTERVAL_MS: 3600000;
90
+ readonly CACHE_MAX_ENTRIES: 1000;
91
+ readonly MAX_MEMORY_USAGE_MB: 512;
92
+ readonly GC_THRESHOLD_MB: 400;
93
+ readonly COMPILE_TIMEOUT: 30000;
94
+ readonly FILE_WATCH_TIMEOUT: 5000;
95
+ readonly DEBOUNCE_WRITE_MS: 100;
96
+ readonly THROTTLE_COMPILE_MS: 50;
97
+ };
98
+ export declare const FRAMEWORK_CONFIGS: {
99
+ readonly react: {
100
+ readonly extension: ".jsx";
101
+ readonly componentTemplate: "React.FC";
102
+ readonly importReact: true;
103
+ readonly cssInJs: false;
104
+ };
105
+ readonly vue: {
106
+ readonly extension: ".vue";
107
+ readonly componentTemplate: "defineComponent";
108
+ readonly importReact: false;
109
+ readonly cssInJs: true;
110
+ };
111
+ readonly svelte: {
112
+ readonly extension: ".svelte";
113
+ readonly componentTemplate: "script";
114
+ readonly importReact: false;
115
+ readonly cssInJs: true;
78
116
  };
79
- atomic: {
80
- enabled: boolean;
81
- threshold: number;
82
- naming: string;
83
- cache: boolean;
84
- cachePath: string;
85
- minify: boolean;
86
- mode: string;
87
- outputStrategy: string;
88
- alwaysAtomic: string[];
89
- neverAtomic: string[];
90
- verbose: boolean;
117
+ readonly solid: {
118
+ readonly extension: ".jsx";
119
+ readonly componentTemplate: "Component";
120
+ readonly importReact: false;
121
+ readonly cssInJs: false;
122
+ };
123
+ readonly angular: {
124
+ readonly extension: ".ts";
125
+ readonly componentTemplate: "Component";
126
+ readonly importReact: false;
127
+ readonly cssInJs: true;
128
+ };
129
+ };
130
+ export type Framework = keyof typeof FRAMEWORK_CONFIGS;
131
+ export declare const ENVIRONMENT_PRESETS: {
132
+ readonly development: {
133
+ readonly atomic: {
134
+ readonly naming: NamingScheme;
135
+ readonly minify: false;
136
+ readonly verbose: true;
137
+ readonly cache: true;
138
+ };
139
+ readonly output: {
140
+ readonly minify: false;
141
+ readonly sourceComments: true;
142
+ };
143
+ readonly debug: true;
144
+ readonly timeline: true;
145
+ readonly sourceComments: true;
146
+ readonly verbose: true;
91
147
  };
92
- prefixer: {
93
- enabled: boolean;
94
- mode: PrefixerMode;
95
- browsers: string[];
96
- sourceMap: boolean;
97
- sourceMapInline: boolean;
148
+ readonly production: {
149
+ readonly atomic: {
150
+ readonly naming: NamingScheme;
151
+ readonly minify: true;
152
+ readonly verbose: false;
153
+ readonly cache: true;
154
+ };
155
+ readonly output: {
156
+ readonly minify: true;
157
+ readonly sourceComments: false;
158
+ };
159
+ readonly debug: false;
160
+ readonly timeline: false;
161
+ readonly sourceComments: false;
162
+ readonly verbose: false;
98
163
  };
99
- output: {
100
- cssFile: string;
101
- classMapFile: string;
102
- typesFile: string;
103
- minify: boolean;
104
- generateGlobalCSS: boolean;
164
+ readonly test: {
165
+ readonly atomic: {
166
+ readonly naming: NamingScheme;
167
+ readonly minify: false;
168
+ readonly verbose: false;
169
+ readonly cache: false;
170
+ };
171
+ readonly output: {
172
+ readonly minify: false;
173
+ readonly sourceComments: true;
174
+ };
175
+ readonly debug: true;
176
+ readonly timeline: true;
177
+ readonly sourceComments: true;
178
+ readonly verbose: false;
105
179
  };
106
- debug: boolean;
107
- sourceComments: boolean;
108
- timeline: boolean;
109
- framework: "auto";
110
- namespace: string;
111
- verbose: boolean;
112
180
  };
181
+ export declare const VALIDATION: {
182
+ readonly MAX_SELECTOR_LENGTH: 100;
183
+ readonly MAX_STYLE_RULES: 10000;
184
+ readonly MAX_NESTING_DEPTH: 10;
185
+ readonly CLASS_NAME: {
186
+ readonly MIN_LENGTH: 1;
187
+ readonly MAX_LENGTH: 50;
188
+ readonly PATTERN: RegExp;
189
+ readonly RESERVED: readonly ["chain", "css", "style", "global", "atomic"];
190
+ };
191
+ readonly PROPERTY_VALUE: {
192
+ readonly MAX_LENGTH: 5000;
193
+ readonly ALLOWED_UNITS: readonly ["px", "rem", "em", "%", "vw", "vh", "deg", "rad", "ms", "s"];
194
+ };
195
+ readonly BREAKPOINT: {
196
+ readonly MIN_VALUE: 0;
197
+ readonly MAX_VALUE: 10000;
198
+ readonly ALLOWED_UNITS: readonly ["px", "rem", "em", "vw"];
199
+ };
200
+ };
201
+ export declare const MEMORY: {
202
+ readonly CACHE_PRUNE_SIZE: number;
203
+ readonly MAX_STRING_BUFFER: number;
204
+ readonly BATCH_SIZE: 100;
205
+ readonly CLEANUP_INTERVAL_MS: 300000;
206
+ readonly CACHE_CHECK_INTERVAL_MS: 60000;
207
+ readonly MEMORY_CHECK_INTERVAL_MS: 30000;
208
+ };
209
+ export declare const DEFAULT_CONFIG: ChainCSSConfig;
113
210
  export declare const RUNTIME: {
114
211
  STYLE_ID_PREFIX: string;
115
212
  CLASS_NAME_PREFIX: string;
@@ -126,4 +223,8 @@ export declare const PROD: {
126
223
  COMPRESSION_LEVEL: number;
127
224
  SOURCE_MAP_COMMENT: string;
128
225
  };
129
- //# sourceMappingURL=constants.d.ts.map
226
+ export declare function isNamingScheme(value: unknown): value is NamingScheme;
227
+ export declare function isAtomicMode(value: unknown): value is AtomicMode;
228
+ export declare function isOutputStrategy(value: unknown): value is OutputStrategy;
229
+ export declare function isPrefixerMode(value: unknown): value is PrefixerMode;
230
+ export declare function isFramework(value: unknown): value is Framework;
@@ -0,0 +1,3 @@
1
+ export declare function smartChain(useTokens?: boolean): any;
2
+ export declare const buildChain: (useTokens?: boolean) => import("../index.js").Chain;
3
+ export declare const runtimeChain: (useTokens?: boolean) => any;
@@ -12,7 +12,8 @@ export interface StyleDefinition {
12
12
  _generateComponent?: boolean;
13
13
  _framework?: 'react' | 'vue' | 'svelte' | 'solid' | 'auto';
14
14
  _propsDefinition?: Record<string, any>;
15
- [cssProperty: string]: any;
15
+ /** Explicit bucket for custom CSS properties to avoid index signature issues */
16
+ customProperties?: Record<string, string | number>;
16
17
  }
17
18
  export interface AtRule {
18
19
  type: 'media' | 'keyframes' | 'font-face' | 'supports' | 'container' | 'layer' | 'counter-style' | 'property';
@@ -39,22 +40,59 @@ export interface AtomicClass {
39
40
  prop: string;
40
41
  value: string;
41
42
  usageCount: number;
43
+ sourceFile?: string;
44
+ hash?: string;
45
+ rules?: string;
42
46
  }
43
47
  export interface CompileResult {
44
48
  css: string;
45
49
  classMap: Record<string, string>;
46
50
  atomicClasses: AtomicClass[];
47
- stats: {
48
- totalStyles: number;
49
- atomicStyles: number;
50
- uniqueProperties: number;
51
- savings: string;
52
- };
51
+ stats: CompileStats;
52
+ warnings?: string[];
53
+ errors?: string[];
54
+ }
55
+ export interface CompileStats {
56
+ totalStyles: number;
57
+ atomicStyles: number;
58
+ uniqueProperties: number;
59
+ savings: string;
60
+ cacheHitRate?: number;
61
+ compileTime?: number;
62
+ }
63
+ export interface AtomicOptimizerOptions {
64
+ enabled: boolean;
65
+ threshold: number;
66
+ naming: 'hash' | 'readable';
67
+ cache: boolean;
68
+ cachePath: string;
69
+ minify: boolean;
70
+ mode: 'standard' | 'atomic' | 'hybrid';
71
+ outputStrategy: 'component-first' | 'utility-first';
72
+ alwaysAtomic: string[];
73
+ neverAtomic: string[];
74
+ verbose: boolean;
75
+ }
76
+ export interface TokenContext {
77
+ tokens: Record<string, any>;
78
+ prefix: string;
79
+ transform?: (value: any) => any;
53
80
  }
54
81
  export interface ChainCSSConfig {
82
+ inputs?: string[];
83
+ output?: {
84
+ cssFile?: string;
85
+ classMapFile?: string;
86
+ typesFile?: string;
87
+ minify?: boolean;
88
+ generateGlobalCSS?: boolean;
89
+ outputDir?: string;
90
+ };
55
91
  tokens?: {
56
92
  enabled?: boolean;
57
93
  prefix?: string;
94
+ transform?: (value: any) => any;
95
+ tokens?: Record<string, any>;
58
96
  };
59
97
  atomic?: {
60
98
  enabled?: boolean;
@@ -68,25 +106,94 @@ export interface ChainCSSConfig {
68
106
  alwaysAtomic?: string[];
69
107
  neverAtomic?: string[];
70
108
  verbose?: boolean;
109
+ maxAtomicClasses?: number;
110
+ reuseThreshold?: number;
71
111
  };
72
112
  prefixer?: {
73
113
  enabled?: boolean;
74
114
  mode?: 'auto' | 'full' | 'lightweight';
75
115
  browsers?: string[];
76
116
  sourceMap?: boolean;
117
+ sourceMapInline?: boolean;
118
+ remove?: boolean;
77
119
  };
78
- output?: {
79
- cssFile?: string;
80
- classMapFile?: string;
81
- typesFile?: string;
82
- minify?: boolean;
83
- generateGlobalCSS?: boolean;
84
- };
120
+ cachePath?: string;
121
+ cacheEnabled?: boolean;
122
+ persistentCachePath?: string;
123
+ cacheMaxAgeDays?: number;
124
+ cacheMaxSizeMB?: number;
85
125
  timeline?: boolean;
86
126
  sourceComments?: boolean;
87
127
  debug?: boolean;
128
+ sourceMap?: boolean;
129
+ watch?: boolean;
130
+ hmr?: boolean;
88
131
  breakpoints?: Record<string, string>;
132
+ framework?: 'react' | 'vue' | 'svelte' | 'solid' | 'angular' | 'auto';
133
+ esmOnly?: boolean;
89
134
  namespace?: string;
90
135
  verbose?: boolean;
136
+ silent?: boolean;
137
+ profiling?: boolean;
138
+ classNameGenerator?: (name: string, options?: any) => string;
139
+ plugins?: ChainCSSPlugin[];
140
+ minifySelectors?: boolean;
141
+ extractCritical?: boolean;
142
+ }
143
+ export interface ChainCSSPlugin {
144
+ name: string;
145
+ setup?: (compiler: any) => void;
146
+ transform?: (code: string, id: string) => string | null;
147
+ transformCSS?: (css: string, filePath: string) => string;
148
+ transformAST?: (ast: any) => any;
149
+ }
150
+ export interface CompileOptions {
151
+ writeFiles?: boolean;
152
+ minify?: boolean;
153
+ sourceMap?: boolean;
154
+ verbose?: boolean;
155
+ watch?: boolean;
156
+ }
157
+ export interface ScanResult {
158
+ files: string[];
159
+ styles: StyleDefinition[];
160
+ errors: Error[];
161
+ warnings: string[];
162
+ }
163
+ export interface CacheEntry {
164
+ hash: string;
165
+ timestamp: number;
166
+ result: CompileResult;
167
+ dependencies: string[];
168
+ accessCount: number;
169
+ }
170
+ export interface TokenValue {
171
+ value: any;
172
+ description?: string;
173
+ deprecated?: boolean;
174
+ aliases?: string[];
175
+ }
176
+ export interface DesignTokens {
177
+ colors: Record<string, TokenValue | string>;
178
+ spacing: Record<string, TokenValue | string>;
179
+ typography: Record<string, TokenValue | string>;
180
+ breakpoints: Record<string, TokenValue | string>;
181
+ animations: Record<string, TokenValue | any>;
182
+ [key: string]: any;
183
+ }
184
+ export interface BreakpointConfig {
185
+ name: string;
186
+ minWidth?: number;
187
+ maxWidth?: number;
188
+ query: string;
189
+ priority?: number;
91
190
  }
92
- //# sourceMappingURL=types.d.ts.map
191
+ export type DeepPartial<T> = {
192
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
193
+ };
194
+ export type RequiredKeys<T, K extends keyof T> = T & Required<Pick<T, K>>;
195
+ export type OptionalKeys<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
196
+ export declare function isStyleDefinition(value: any): value is StyleDefinition;
197
+ export declare function isAtRule(value: any): value is AtRule;
198
+ export declare function isAtomicClass(value: any): value is AtomicClass;
199
+ export declare function isCompileResult(value: any): value is CompileResult;
@@ -1,37 +1,154 @@
1
1
  /**
2
- * Generate a hash for a string
2
+ * 1. RE-EXPORTS
3
+ * Re-exporting everything from common-utils ensures the Compiler
4
+ * can still find processStyleObject, resolveToken, and kebabCase
5
+ * without changing its import statements.
6
+ */
7
+ export * from './common-utils.js';
8
+ /**
9
+ * 2. HASHING & NAMING (Node/Compiler Only)
3
10
  */
4
11
  export declare function hashString(str: string, length?: number): string;
12
+ export declare function generateClassName(styleId: string, naming?: 'hash' | 'readable'): string;
13
+ export declare function generateAtomicClassName(prop: string, value: string, type?: 'atomic' | 'utility'): string;
14
+ export declare function generateComponentClassName(componentName: string, hash?: string): string;
15
+ /**
16
+ * 3. OBJECT MANIPULATION
17
+ */
18
+ export declare function deepMerge<T extends Record<string, any>>(target: T, source: Partial<T>): T;
19
+ export declare function deepClone<T>(obj: T): T;
20
+ export declare function deepEqual(obj1: any, obj2: any): boolean;
21
+ export declare function pick<T extends Record<string, any>, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
22
+ export declare function omit<T extends Record<string, any>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
23
+ /**
24
+ * 4. FILE SYSTEM UTILS (Node Only)
25
+ */
26
+ export declare function ensureDir(dir: string): void;
27
+ export declare function writeFile(filePath: string, content: string): void;
28
+ export declare function readFile(filePath: string): string;
29
+ export declare function fileExists(filePath: string): boolean;
30
+ export declare function getFileExtension(filePath: string): string;
31
+ export declare function getBaseName(filePath: string): string;
32
+ export declare function getDirName(filePath: string): string;
33
+ export declare function resolvePath(filePath: string): string;
34
+ export declare function isDirectory(filePath: string): boolean;
35
+ export declare function getAllFiles(dir: string, pattern?: RegExp): string[];
5
36
  /**
6
- * Convert camelCase to kebab-case
37
+ * 5. FORMATTING
7
38
  */
39
+ export declare function formatCSS(css: string, minify?: boolean): string;
40
+ export declare function formatJS(code: string, minify?: boolean): string;
8
41
  export declare function kebabCase(str: string): string;
42
+ export declare function camelCase(str: string): string;
43
+ export declare function pascalCase(str: string): string;
44
+ export declare function snakeCase(str: string): string;
9
45
  /**
10
- * Generate a unique class name
46
+ * 6. STRING UTILITIES
11
47
  */
12
- export declare function generateClassName(styleId: string, naming?: 'hash' | 'readable'): string;
48
+ export declare function truncate(str: string, length: number, suffix?: string): string;
49
+ export declare function indent(str: string, level?: number, char?: string): string;
50
+ export declare function stripIndent(str: string): string;
13
51
  /**
14
- * Deep merge objects
52
+ * 7. ARRAY UTILITIES
15
53
  */
16
- export declare function deepMerge<T extends Record<string, any>>(target: T, source: Partial<T>): T;
54
+ export declare function unique<T>(arr: T[], key?: keyof T): T[];
55
+ export declare function chunk<T>(arr: T[], size: number): T[][];
56
+ export declare function groupBy<T>(arr: T[], key: keyof T): Record<string, T[]>;
17
57
  /**
18
- * Ensure directory exists
58
+ * 8. PERFORMANCE UTILITIES
19
59
  */
20
- export declare function ensureDir(dir: string): void;
60
+ export declare function debounce<T extends (...args: any[]) => any>(fn: T, delay: number): (...args: Parameters<T>) => void;
61
+ export declare function throttle<T extends (...args: any[]) => any>(fn: T, limit: number): (...args: Parameters<T>) => void;
21
62
  /**
22
- * Write file with parent directory creation
63
+ * 9. ERROR HANDLING
23
64
  */
24
- export declare function writeFile(filePath: string, content: string): void;
65
+ export declare class ChainCSSError extends Error {
66
+ code: string;
67
+ details?: any;
68
+ constructor(message: string, code?: string, details?: any);
69
+ }
70
+ export declare function tryOrWarn<T>(fn: () => T, defaultValue: T, message?: string): T;
71
+ export declare function tryOrThrow<T>(fn: () => T, errorMessage?: string): T;
25
72
  /**
26
- * Format CSS (minify or beautify)
73
+ * 10. LOGGING UTILITIES (Node Only)
27
74
  */
28
- export declare function formatCSS(css: string, minify?: boolean): string;
75
+ declare const LOG_LEVELS: {
76
+ debug: number;
77
+ info: number;
78
+ warn: number;
79
+ error: number;
80
+ silent: number;
81
+ };
82
+ export declare function setLogLevel(level: keyof typeof LOG_LEVELS): void;
83
+ export declare function logDebug(message: string, ...args: any[]): void;
84
+ export declare function logInfo(message: string, ...args: any[]): void;
85
+ export declare function logWarn(message: string, ...args: any[]): void;
86
+ export declare function logError(message: string, ...args: any[]): void;
29
87
  /**
30
- * Get file extension
88
+ * 11. MEMORY MANAGEMENT
31
89
  */
32
- export declare function getFileExtension(filePath: string): string;
90
+ export declare function getMemoryUsage(): {
91
+ rss: number;
92
+ heapTotal: number;
93
+ heapUsed: number;
94
+ external: number;
95
+ };
96
+ export declare function formatBytes(bytes: number): string;
33
97
  /**
34
- * Get base name without extension
98
+ * 12. VALIDATION UTILITIES
35
99
  */
36
- export declare function getBaseName(filePath: string): string;
37
- //# sourceMappingURL=utils.d.ts.map
100
+ export declare function isValidSelector(selector: string): boolean;
101
+ export declare function isValidClassName(className: string): boolean;
102
+ export declare function isValidCSSProperty(prop: string): boolean;
103
+ /**
104
+ * 13. EXPORTS
105
+ */
106
+ declare const _default: {
107
+ hashString: typeof hashString;
108
+ generateClassName: typeof generateClassName;
109
+ generateAtomicClassName: typeof generateAtomicClassName;
110
+ generateComponentClassName: typeof generateComponentClassName;
111
+ deepMerge: typeof deepMerge;
112
+ deepClone: typeof deepClone;
113
+ deepEqual: typeof deepEqual;
114
+ pick: typeof pick;
115
+ omit: typeof omit;
116
+ ensureDir: typeof ensureDir;
117
+ writeFile: typeof writeFile;
118
+ readFile: typeof readFile;
119
+ fileExists: typeof fileExists;
120
+ getFileExtension: typeof getFileExtension;
121
+ getBaseName: typeof getBaseName;
122
+ getDirName: typeof getDirName;
123
+ resolvePath: typeof resolvePath;
124
+ isDirectory: typeof isDirectory;
125
+ getAllFiles: typeof getAllFiles;
126
+ formatCSS: typeof formatCSS;
127
+ formatJS: typeof formatJS;
128
+ kebabCase: typeof kebabCase;
129
+ camelCase: typeof camelCase;
130
+ pascalCase: typeof pascalCase;
131
+ snakeCase: typeof snakeCase;
132
+ truncate: typeof truncate;
133
+ indent: typeof indent;
134
+ stripIndent: typeof stripIndent;
135
+ unique: typeof unique;
136
+ chunk: typeof chunk;
137
+ groupBy: typeof groupBy;
138
+ debounce: typeof debounce;
139
+ throttle: typeof throttle;
140
+ ChainCSSError: typeof ChainCSSError;
141
+ tryOrWarn: typeof tryOrWarn;
142
+ tryOrThrow: typeof tryOrThrow;
143
+ setLogLevel: typeof setLogLevel;
144
+ logDebug: typeof logDebug;
145
+ logInfo: typeof logInfo;
146
+ logWarn: typeof logWarn;
147
+ logError: typeof logError;
148
+ getMemoryUsage: typeof getMemoryUsage;
149
+ formatBytes: typeof formatBytes;
150
+ isValidSelector: typeof isValidSelector;
151
+ isValidClassName: typeof isValidClassName;
152
+ isValidCSSProperty: typeof isValidCSSProperty;
153
+ };
154
+ export default _default;
package/dist/index.d.ts CHANGED
@@ -1,13 +1,57 @@
1
+ /**
2
+ * ChainCSS - Zero-runtime CSS-in-JS with Atomic CSS optimization
3
+ * @packageDocumentation
4
+ */
5
+ export { smartChain, smartChain as chainV3, buildChain, runtimeChain } from './core/smart-chain.js';
6
+ export { autoDetector, AutoDetector, type ValueType, type Mode } from './core/auto-detector.js';
7
+ export { useSmartStyles, createSmartComponent, withSmartStyles } from './runtime/auto-hooks.js';
1
8
  export { ChainCSSCompiler, compileChainCSS } from './core/compiler.js';
2
- export { $, recipe, createTokens, configureAtomic, tokens } from './compiler/btt.js';
9
+ export { chain, chain as $, // Alias for convenience
10
+ recipe, // Variant system
11
+ createTokens, // Design token creation
12
+ configureAtomic, // Atomic CSS configuration
13
+ tokens, // Default token instance
14
+ enableDebug, // Debug mode
15
+ setBreakpoints, // Responsive breakpoints
16
+ enableTimeline, // Style timeline tracking
17
+ getStyleHistory, // Timeline history
18
+ getStyleChanges, // Timeline changes
19
+ getStyleDiff, // Timeline diff
20
+ exportTimeline, // Export timeline
21
+ clearTimeline } from './compiler/btt.js';
3
22
  export { AtomicOptimizer } from './compiler/atomic-optimizer.js';
4
23
  export { ChainCSSPrefixer } from './compiler/prefixer.js';
5
- export { DesignTokens, createTokens as createTokensUtil, responsive } from './compiler/tokens.js';
24
+ export { DesignTokens, createTokens as createDesignTokens } from './compiler/tokens.js';
6
25
  export { createThemeContract, validateTheme, createTheme, Theme } from './compiler/theme-contract.js';
7
26
  export { CacheManager } from './compiler/cache-manager.js';
8
- export type { StyleDefinition, AtRule, NestedRule, ThemeBlock } from './compiler/btt.js';
9
- export type { AtomicClass, AtomicOptimizerOptions, AtomicOptimizerStats } from './compiler/atomic-optimizer.js';
10
- export type { PrefixerConfig } from './compiler/prefixer.js';
11
- export type { ThemeContract, ThemeTokens, TokensStructure } from './compiler/theme-contract.js';
12
- export type { ChainCSSConfig, CompileResult } from './core/types.js';
13
- //# sourceMappingURL=index.d.ts.map
27
+ export { PersistentCache } from './compiler/content-addressable-cache.js';
28
+ export { shorthandMap, macros, handleShorthand, isShorthand, expandShorthand, getAvailableShorthands } from './compiler/shorthands.js';
29
+ export { helpers } from './compiler/helpers.js';
30
+ export { animationPresets, createAnimation, getAnimationPreset, hasAnimationPreset, getAnimationPresetNames } from './compiler/animations.js';
31
+ export { getSuggestion, getSuggestions, getPropertySuggestion, getShorthandSuggestion } from './compiler/suggestions.js';
32
+ export type { StyleDefinition, AtRule, NestedRule, ThemeBlock, Recipe, RecipeOptions, ChainObject } from './compiler/btt.js';
33
+ export type { AtomicClass, AtomicOptimizerOptions, AtomicOptimizerStats, ComponentClassMapEntry, OptimizeResult } from './compiler/atomic-optimizer.js';
34
+ export type { PrefixerConfig, PrefixerResult } from './compiler/prefixer.js';
35
+ export type { ThemeContract, ThemeTokens } from './compiler/theme-contract.js';
36
+ export type { TokensStructure } from './compiler/tokens.js';
37
+ export type { ChainCSSConfig, CompileResult, ChainCSSPlugin } from './core/types.js';
38
+ export type { Chain } from './compiler/Chain.js';
39
+ export type { AnimationConfig, KeyframeDefinition } from './compiler/animations.js';
40
+ export type { BreakpointsMap, ResponsiveStyle } from './compiler/breakpoints.js';
41
+ export * from './runtime/index.js';
42
+ export declare const VERSION = "3.0.0";
43
+ import { chain } from './compiler/Chain.js';
44
+ export default chain;
45
+ export type { Properties as CSSProperties } from 'csstype';
46
+ export type TokenValue<T = string> = T | `$${string}`;
47
+ export type ResponsiveValue<T> = T | {
48
+ base?: T;
49
+ sm?: T;
50
+ md?: T;
51
+ lg?: T;
52
+ xl?: T;
53
+ '2xl'?: T;
54
+ [key: string]: T | undefined;
55
+ };
56
+ export type StyleWithTokens<T = any> = T | ((tokens: DesignTokens) => T);
57
+ import { DesignTokens } from './compiler/tokens.js';