chaincss 2.0.7 → 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.
- 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 +724 -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
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
// src/core/types.ts
|
|
2
|
+
/**
|
|
3
|
+
* Core ChainCSS Types - Build-Time Only
|
|
4
|
+
* These types are for the compiler and never ship to browser
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export interface StyleDefinition {
|
|
8
|
+
selectors: string[];
|
|
9
|
+
hover?: Record<string, string | number>;
|
|
10
|
+
atRules?: AtRule[];
|
|
11
|
+
nestedRules?: NestedRule[];
|
|
12
|
+
themes?: ThemeBlock[];
|
|
13
|
+
_componentName?: string;
|
|
14
|
+
_generateComponent?: boolean;
|
|
15
|
+
_framework?: 'react' | 'vue' | 'svelte' | 'solid' | 'auto';
|
|
16
|
+
_propsDefinition?: Record<string, any>;
|
|
17
|
+
/** Explicit bucket for custom CSS properties to avoid index signature issues */
|
|
18
|
+
customProperties?: Record<string, string | number>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface AtRule {
|
|
22
|
+
type: 'media' | 'keyframes' | 'font-face' | 'supports' | 'container' | 'layer' | 'counter-style' | 'property';
|
|
23
|
+
query?: string;
|
|
24
|
+
condition?: string;
|
|
25
|
+
name?: string;
|
|
26
|
+
styles?: any;
|
|
27
|
+
steps?: Record<string, Record<string, string>>;
|
|
28
|
+
properties?: Record<string, string>;
|
|
29
|
+
descriptors?: Record<string, string>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface NestedRule {
|
|
33
|
+
selector: string;
|
|
34
|
+
styles: Record<string, string | number>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface ThemeBlock {
|
|
38
|
+
name: string;
|
|
39
|
+
styles: StyleDefinition;
|
|
40
|
+
tokens: any;
|
|
41
|
+
fallback: any;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface AtomicClass {
|
|
45
|
+
className: string;
|
|
46
|
+
prop: string;
|
|
47
|
+
value: string;
|
|
48
|
+
usageCount: number;
|
|
49
|
+
sourceFile?: string;
|
|
50
|
+
hash?: string;
|
|
51
|
+
rules?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface CompileResult {
|
|
55
|
+
css: string;
|
|
56
|
+
classMap: Record<string, string>;
|
|
57
|
+
atomicClasses: AtomicClass[];
|
|
58
|
+
stats: CompileStats;
|
|
59
|
+
warnings?: string[];
|
|
60
|
+
errors?: string[];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface CompileStats {
|
|
64
|
+
totalStyles: number;
|
|
65
|
+
atomicStyles: number;
|
|
66
|
+
uniqueProperties: number;
|
|
67
|
+
savings: string;
|
|
68
|
+
cacheHitRate?: number;
|
|
69
|
+
compileTime?: number;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface AtomicOptimizerOptions {
|
|
73
|
+
enabled: boolean;
|
|
74
|
+
threshold: number;
|
|
75
|
+
naming: 'hash' | 'readable';
|
|
76
|
+
cache: boolean;
|
|
77
|
+
cachePath: string;
|
|
78
|
+
minify: boolean;
|
|
79
|
+
mode: 'standard' | 'atomic' | 'hybrid';
|
|
80
|
+
outputStrategy: 'component-first' | 'utility-first';
|
|
81
|
+
alwaysAtomic: string[];
|
|
82
|
+
neverAtomic: string[];
|
|
83
|
+
verbose: boolean;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface TokenContext {
|
|
87
|
+
tokens: Record<string, any>;
|
|
88
|
+
prefix: string;
|
|
89
|
+
transform?: (value: any) => any;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface ChainCSSConfig {
|
|
93
|
+
inputs?: string[];
|
|
94
|
+
output?: {
|
|
95
|
+
cssFile?: string;
|
|
96
|
+
classMapFile?: string;
|
|
97
|
+
typesFile?: string;
|
|
98
|
+
minify?: boolean;
|
|
99
|
+
generateGlobalCSS?: boolean;
|
|
100
|
+
outputDir?: string;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
tokens?: {
|
|
104
|
+
enabled?: boolean;
|
|
105
|
+
prefix?: string;
|
|
106
|
+
transform?: (value: any) => any;
|
|
107
|
+
tokens?: Record<string, any>;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
atomic?: {
|
|
111
|
+
enabled?: boolean;
|
|
112
|
+
threshold?: number;
|
|
113
|
+
naming?: 'hash' | 'readable';
|
|
114
|
+
cache?: boolean;
|
|
115
|
+
cachePath?: string;
|
|
116
|
+
minify?: boolean;
|
|
117
|
+
mode?: 'standard' | 'atomic' | 'hybrid';
|
|
118
|
+
outputStrategy?: 'component-first' | 'utility-first';
|
|
119
|
+
alwaysAtomic?: string[];
|
|
120
|
+
neverAtomic?: string[];
|
|
121
|
+
verbose?: boolean;
|
|
122
|
+
maxAtomicClasses?: number;
|
|
123
|
+
reuseThreshold?: number;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
prefixer?: {
|
|
127
|
+
enabled?: boolean;
|
|
128
|
+
mode?: 'auto' | 'full' | 'lightweight';
|
|
129
|
+
browsers?: string[];
|
|
130
|
+
sourceMap?: boolean;
|
|
131
|
+
sourceMapInline?: boolean;
|
|
132
|
+
remove?: boolean;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
cachePath?: string;
|
|
136
|
+
cacheEnabled?: boolean;
|
|
137
|
+
persistentCachePath?: string;
|
|
138
|
+
cacheMaxAgeDays?: number;
|
|
139
|
+
cacheMaxSizeMB?: number;
|
|
140
|
+
|
|
141
|
+
timeline?: boolean;
|
|
142
|
+
sourceComments?: boolean;
|
|
143
|
+
debug?: boolean;
|
|
144
|
+
sourceMap?: boolean;
|
|
145
|
+
watch?: boolean;
|
|
146
|
+
hmr?: boolean;
|
|
147
|
+
|
|
148
|
+
breakpoints?: Record<string, string>;
|
|
149
|
+
|
|
150
|
+
framework?: 'react' | 'vue' | 'svelte' | 'solid' | 'angular' | 'auto';
|
|
151
|
+
esmOnly?: boolean;
|
|
152
|
+
|
|
153
|
+
namespace?: string;
|
|
154
|
+
verbose?: boolean;
|
|
155
|
+
silent?: boolean;
|
|
156
|
+
profiling?: boolean;
|
|
157
|
+
|
|
158
|
+
classNameGenerator?: (name: string, options?: any) => string;
|
|
159
|
+
|
|
160
|
+
plugins?: ChainCSSPlugin[];
|
|
161
|
+
|
|
162
|
+
minifySelectors?: boolean;
|
|
163
|
+
extractCritical?: boolean;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export interface ChainCSSPlugin {
|
|
167
|
+
name: string;
|
|
168
|
+
setup?: (compiler: any) => void;
|
|
169
|
+
transform?: (code: string, id: string) => string | null;
|
|
170
|
+
transformCSS?: (css: string, filePath: string) => string;
|
|
171
|
+
transformAST?: (ast: any) => any;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export interface CompileOptions {
|
|
175
|
+
writeFiles?: boolean;
|
|
176
|
+
minify?: boolean;
|
|
177
|
+
sourceMap?: boolean;
|
|
178
|
+
verbose?: boolean;
|
|
179
|
+
watch?: boolean;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export interface ScanResult {
|
|
183
|
+
files: string[];
|
|
184
|
+
styles: StyleDefinition[];
|
|
185
|
+
errors: Error[];
|
|
186
|
+
warnings: string[];
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export interface CacheEntry {
|
|
190
|
+
hash: string;
|
|
191
|
+
timestamp: number;
|
|
192
|
+
result: CompileResult;
|
|
193
|
+
dependencies: string[];
|
|
194
|
+
accessCount: number;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export interface TokenValue {
|
|
198
|
+
value: any;
|
|
199
|
+
description?: string;
|
|
200
|
+
deprecated?: boolean;
|
|
201
|
+
aliases?: string[];
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export interface DesignTokens {
|
|
205
|
+
colors: Record<string, TokenValue | string>;
|
|
206
|
+
spacing: Record<string, TokenValue | string>;
|
|
207
|
+
typography: Record<string, TokenValue | string>;
|
|
208
|
+
breakpoints: Record<string, TokenValue | string>;
|
|
209
|
+
animations: Record<string, TokenValue | any>;
|
|
210
|
+
[key: string]: any;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export interface BreakpointConfig {
|
|
214
|
+
name: string;
|
|
215
|
+
minWidth?: number;
|
|
216
|
+
maxWidth?: number;
|
|
217
|
+
query: string;
|
|
218
|
+
priority?: number;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// ============================================================================
|
|
222
|
+
// Utility Types
|
|
223
|
+
// ============================================================================
|
|
224
|
+
|
|
225
|
+
export type DeepPartial<T> = {
|
|
226
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
export type RequiredKeys<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
230
|
+
|
|
231
|
+
export type OptionalKeys<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
232
|
+
|
|
233
|
+
// ============================================================================
|
|
234
|
+
// Type Guards
|
|
235
|
+
// ============================================================================
|
|
236
|
+
|
|
237
|
+
export function isStyleDefinition(value: any): value is StyleDefinition {
|
|
238
|
+
return value && typeof value === 'object' && Array.isArray(value.selectors);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export function isAtRule(value: any): value is AtRule {
|
|
242
|
+
return value && typeof value === 'object' && value.type &&
|
|
243
|
+
['media', 'keyframes', 'font-face', 'supports', 'container', 'layer'].includes(value.type);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export function isAtomicClass(value: any): value is AtomicClass {
|
|
247
|
+
return value && typeof value === 'object' &&
|
|
248
|
+
typeof value.className === 'string' &&
|
|
249
|
+
typeof value.prop === 'string';
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export function isCompileResult(value: any): value is CompileResult {
|
|
253
|
+
return value && typeof value === 'object' &&
|
|
254
|
+
typeof value.css === 'string' &&
|
|
255
|
+
typeof value.classMap === 'object' &&
|
|
256
|
+
typeof value.stats === 'object';
|
|
257
|
+
}
|