chaincss 2.0.7 → 2.1.1
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.
- package/CHANGELOG.md +30 -0
- package/CODE_OF_CONDUCT.md +21 -0
- package/CONTRIBUTING.md +28 -0
- package/README.md +455 -226
- package/demo/demo/node_modules/caniuse-db/fulldata-json/data-2.0.json +1 -0
- package/demo/index.html +16 -0
- package/demo/package.json +20 -0
- package/demo/src/App.tsx +117 -0
- package/demo/src/chaincss-barrel.ts +9 -0
- package/demo/src/main.tsx +8 -0
- package/demo/src/styles.chain.ts +300 -0
- package/demo/vite.config.ts +46 -0
- package/dist/cli/commands/build.d.ts +0 -1
- package/dist/cli/commands/cache.d.ts +1 -0
- package/dist/cli/commands/init.d.ts +6 -3
- package/dist/cli/commands/timeline.d.ts +0 -1
- package/dist/cli/commands/watch.d.ts +0 -1
- package/dist/cli/index.d.ts +0 -1
- package/dist/cli/index.js +3213 -5296
- package/dist/cli/types.d.ts +51 -20
- package/dist/cli/utils/config-loader.d.ts +0 -1
- package/dist/cli/utils/file-utils.d.ts +27 -3
- package/dist/cli/utils/logger.d.ts +0 -1
- package/dist/compiler/Chain.d.ts +215 -0
- package/dist/compiler/animations.d.ts +76 -0
- package/dist/compiler/atomic-optimizer.d.ts +47 -12
- package/dist/compiler/breakpoints.d.ts +46 -0
- package/dist/compiler/btt.d.ts +36 -60
- package/dist/compiler/cache-manager.d.ts +58 -4
- package/dist/compiler/commonProps.d.ts +0 -1
- package/dist/compiler/content-addressable-cache.d.ts +78 -0
- package/dist/compiler/helpers.d.ts +54 -0
- package/dist/compiler/index.d.ts +16 -9
- package/dist/compiler/index.js +4450 -4316
- package/dist/compiler/prefixer.d.ts +17 -1
- package/dist/compiler/shorthands.d.ts +28 -0
- package/dist/compiler/suggestions.d.ts +43 -0
- package/dist/compiler/theme-contract.d.ts +16 -27
- package/dist/compiler/token-resolver.d.ts +69 -0
- package/dist/compiler/tokens.d.ts +33 -8
- package/dist/core/auto-detector.d.ts +34 -0
- package/dist/core/common-utils.d.ts +97 -0
- package/dist/core/compiler.d.ts +63 -23
- package/dist/core/constants.d.ts +137 -36
- package/dist/core/smart-chain.d.ts +3 -0
- package/dist/core/types.d.ts +122 -15
- package/dist/core/utils.d.ts +134 -17
- package/dist/index.d.ts +52 -8
- package/dist/index.js +7090 -5578
- package/dist/plugins/vite.d.ts +7 -5
- package/dist/plugins/vite.js +2964 -25641
- package/dist/plugins/webpack.d.ts +24 -1
- package/dist/plugins/webpack.js +209 -72
- package/dist/runtime/Chain.d.ts +32 -0
- package/dist/runtime/auto-hooks.d.ts +11 -0
- package/dist/runtime/hmr.d.ts +22 -2
- package/dist/runtime/index.d.ts +3 -2
- package/dist/runtime/index.js +3648 -301
- package/dist/runtime/injector.d.ts +39 -72
- package/dist/runtime/react.d.ts +17 -12
- package/dist/runtime/svelte.d.ts +15 -0
- package/dist/runtime/types.d.ts +126 -4
- package/dist/runtime/utils.d.ts +0 -1
- package/dist/runtime/vue.d.ts +34 -14
- package/package.json +59 -66
- package/src/cli/commands/build.ts +133 -0
- package/src/cli/commands/cache.ts +371 -0
- package/src/cli/commands/init.ts +230 -0
- package/src/cli/commands/timeline.ts +435 -0
- package/src/cli/commands/watch.ts +211 -0
- package/src/cli/index.ts +226 -0
- package/src/cli/types.ts +100 -0
- package/src/cli/utils/config-loader.ts +174 -0
- package/src/cli/utils/file-utils.ts +139 -0
- package/src/cli/utils/logger.ts +74 -0
- package/src/compiler/Chain.ts +831 -0
- package/src/compiler/animations.ts +517 -0
- package/src/compiler/atomic-optimizer.ts +786 -0
- package/src/compiler/breakpoints.ts +347 -0
- package/src/compiler/btt.ts +1147 -0
- package/src/compiler/cache-manager.ts +446 -0
- package/src/compiler/commonProps.ts +18 -0
- package/src/compiler/content-addressable-cache.ts +478 -0
- package/src/compiler/helpers.ts +407 -0
- package/src/compiler/index.ts +72 -0
- package/src/compiler/prefixer.ts +720 -0
- package/src/compiler/shorthands.ts +558 -0
- package/src/compiler/suggestions.ts +436 -0
- package/src/compiler/theme-contract.ts +197 -0
- package/src/compiler/token-resolver.ts +241 -0
- package/src/compiler/tokens.ts +612 -0
- package/src/core/auto-detector.ts +187 -0
- package/src/core/common-utils.ts +423 -0
- package/src/core/compiler.ts +835 -0
- package/src/core/constants.ts +424 -0
- package/src/core/index.ts +107 -0
- package/src/core/smart-chain.ts +163 -0
- package/src/core/types.ts +257 -0
- package/src/core/utils.ts +598 -0
- package/src/index.ts +208 -0
- package/src/plugins/vite.d.ts +316 -0
- package/src/plugins/vite.ts +424 -0
- package/src/plugins/webpack.d.ts +289 -0
- package/src/plugins/webpack.ts +416 -0
- package/src/runtime/Chain.ts +242 -0
- package/src/runtime/auto-hooks.tsx +127 -0
- package/src/runtime/auto-vue.ts +72 -0
- package/src/runtime/hmr.ts +212 -0
- package/src/runtime/index.ts +82 -0
- package/src/runtime/injector.ts +273 -0
- package/src/runtime/react.tsx +269 -0
- package/src/runtime/svelte.ts +15 -0
- package/src/runtime/types.ts +256 -0
- package/src/runtime/utils.ts +128 -0
- package/src/runtime/vite-env.d.ts +120 -0
- package/src/runtime/vue.ts +231 -0
- package/tsconfig.build.json +41 -0
- package/tsconfig.json +25 -0
- package/tsconfig.runtimes.json +18 -0
- package/dist/cli/cli.cjs +0 -7
- package/dist/cli/commands/build.d.ts.map +0 -1
- package/dist/cli/commands/compile.d.ts +0 -3
- package/dist/cli/commands/compile.d.ts.map +0 -1
- package/dist/cli/commands/init.d.ts.map +0 -1
- package/dist/cli/commands/timeline.d.ts.map +0 -1
- package/dist/cli/commands/watch.d.ts.map +0 -1
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/types.d.ts.map +0 -1
- package/dist/cli/utils/config-loader.d.ts.map +0 -1
- package/dist/cli/utils/file-utils.d.ts.map +0 -1
- package/dist/cli/utils/logger.d.ts.map +0 -1
- package/dist/compiler/atomic-optimizer.d.ts.map +0 -1
- package/dist/compiler/btt.d.ts.map +0 -1
- package/dist/compiler/cache-manager.d.ts.map +0 -1
- package/dist/compiler/commonProps.d.ts.map +0 -1
- package/dist/compiler/index.d.ts.map +0 -1
- package/dist/compiler/prefixer.d.ts.map +0 -1
- package/dist/compiler/theme-contract.d.ts.map +0 -1
- package/dist/compiler/tokens.d.ts.map +0 -1
- package/dist/compiler/types.d.ts +0 -57
- package/dist/compiler/types.d.ts.map +0 -1
- package/dist/core/compiler.d.ts.map +0 -1
- package/dist/core/constants.d.ts.map +0 -1
- package/dist/core/index.d.ts +0 -4
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/types.d.ts.map +0 -1
- package/dist/core/utils.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/plugins/vite.d.ts.map +0 -1
- package/dist/plugins/webpack.d.ts.map +0 -1
- package/dist/runtime/hmr.d.ts.map +0 -1
- package/dist/runtime/index.d.ts.map +0 -1
- package/dist/runtime/injector.d.ts.map +0 -1
- package/dist/runtime/react.d.ts.map +0 -1
- package/dist/runtime/react.js +0 -324
- package/dist/runtime/types.d.ts.map +0 -1
- package/dist/runtime/utils.d.ts.map +0 -1
- package/dist/runtime/vue.d.ts.map +0 -1
- package/dist/runtime/vue.js +0 -286
package/dist/core/constants.d.ts
CHANGED
|
@@ -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 =
|
|
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
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
-
|
|
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;
|
package/dist/core/types.d.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
|
|
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;
|
package/dist/core/utils.d.ts
CHANGED
|
@@ -1,37 +1,154 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
46
|
+
* 6. STRING UTILITIES
|
|
11
47
|
*/
|
|
12
|
-
export declare function
|
|
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
|
-
*
|
|
52
|
+
* 7. ARRAY UTILITIES
|
|
15
53
|
*/
|
|
16
|
-
export declare function
|
|
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
|
-
*
|
|
58
|
+
* 8. PERFORMANCE UTILITIES
|
|
19
59
|
*/
|
|
20
|
-
export declare function
|
|
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
|
-
*
|
|
63
|
+
* 9. ERROR HANDLING
|
|
23
64
|
*/
|
|
24
|
-
export declare
|
|
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
|
-
*
|
|
73
|
+
* 10. LOGGING UTILITIES (Node Only)
|
|
27
74
|
*/
|
|
28
|
-
|
|
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
|
-
*
|
|
88
|
+
* 11. MEMORY MANAGEMENT
|
|
31
89
|
*/
|
|
32
|
-
export declare function
|
|
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
|
-
*
|
|
98
|
+
* 12. VALIDATION UTILITIES
|
|
35
99
|
*/
|
|
36
|
-
export declare function
|
|
37
|
-
|
|
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 {
|
|
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
|
|
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
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
|
|
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';
|