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
|
@@ -4,17 +4,28 @@ export interface PrefixerConfig {
|
|
|
4
4
|
mode?: 'auto' | 'full' | 'lightweight';
|
|
5
5
|
sourceMap?: boolean;
|
|
6
6
|
sourceMapInline?: boolean;
|
|
7
|
+
remove?: boolean;
|
|
8
|
+
add?: boolean;
|
|
9
|
+
verbose?: boolean;
|
|
10
|
+
flexbox?: boolean | 'no-2009';
|
|
11
|
+
grid?: boolean | 'autoplace' | 'no-autoplace';
|
|
7
12
|
}
|
|
8
13
|
export interface PrefixerResult {
|
|
9
14
|
css: string;
|
|
10
15
|
map: string | null;
|
|
16
|
+
warnings?: string[];
|
|
11
17
|
}
|
|
12
18
|
export interface ProcessOptionsWithPaths {
|
|
13
19
|
from?: string;
|
|
14
20
|
to?: string;
|
|
21
|
+
map?: boolean | object;
|
|
15
22
|
}
|
|
16
23
|
export interface CaniuseFeature {
|
|
24
|
+
title: string;
|
|
25
|
+
description: string;
|
|
17
26
|
stats: Record<string, Record<string, string>>;
|
|
27
|
+
spec?: string;
|
|
28
|
+
status?: string;
|
|
18
29
|
}
|
|
19
30
|
export declare class ChainCSSPrefixer {
|
|
20
31
|
config: Required<PrefixerConfig>;
|
|
@@ -26,17 +37,22 @@ export declare class ChainCSSPrefixer {
|
|
|
26
37
|
specialValues: Record<string, string[]>;
|
|
27
38
|
browserPrefixMap: Record<string, string>;
|
|
28
39
|
targetBrowsers: string[] | null;
|
|
40
|
+
private warnings;
|
|
29
41
|
constructor(config?: PrefixerConfig);
|
|
30
42
|
determineMode(): Promise<'auto' | 'full' | 'lightweight'>;
|
|
31
43
|
process(cssString: string, options?: ProcessOptionsWithPaths): Promise<PrefixerResult>;
|
|
32
44
|
private processWithAutoprefixer;
|
|
33
45
|
private processWithBuiltIn;
|
|
46
|
+
private lightweightPrefix;
|
|
34
47
|
private createBuiltInPlugin;
|
|
35
48
|
private processBuiltInDeclaration;
|
|
49
|
+
private shouldKeepPrefix;
|
|
36
50
|
private addPrefixesFromCaniuse;
|
|
37
51
|
private addSpecialValuePrefixes;
|
|
38
52
|
private findFeature;
|
|
39
53
|
private getCommonProperties;
|
|
54
|
+
needsPrefix(property: string, browser: string, version: number): boolean;
|
|
55
|
+
getAvailablePrefixes(property: string): string[];
|
|
56
|
+
reset(): void;
|
|
40
57
|
}
|
|
41
58
|
export { ChainCSSPrefixer as default };
|
|
42
|
-
//# sourceMappingURL=prefixer.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 1. THE DICTIONARY (Simple 1-to-1 Swaps)
|
|
3
|
+
* Handled by the ChainClass for performance.
|
|
4
|
+
*/
|
|
5
|
+
export declare const shorthandMap: Record<string, string>;
|
|
6
|
+
type MacroHandler = (value: any, catcher: Record<string, any>, useTokens: boolean) => void;
|
|
7
|
+
/**
|
|
8
|
+
* 2. THE MACRO REGISTRY (Complex Logic)
|
|
9
|
+
*/
|
|
10
|
+
export declare const macros: Record<string, MacroHandler>;
|
|
11
|
+
/**
|
|
12
|
+
* Main handler for shorthand processing
|
|
13
|
+
* Returns true if the shorthand was handled, false otherwise
|
|
14
|
+
*/
|
|
15
|
+
export declare function handleShorthand(prop: string, value: any, catcher: Record<string, any>, useTokens?: boolean): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Utility to check if a property is a registered shorthand
|
|
18
|
+
*/
|
|
19
|
+
export declare function isShorthand(prop: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Get the expanded property name for a shorthand
|
|
22
|
+
*/
|
|
23
|
+
export declare function expandShorthand(prop: string): string | null;
|
|
24
|
+
/**
|
|
25
|
+
* Get all available shorthands
|
|
26
|
+
*/
|
|
27
|
+
export declare function getAvailableShorthands(): string[];
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export interface SuggestionMatch {
|
|
2
|
+
name: string;
|
|
3
|
+
distance: number;
|
|
4
|
+
type: 'shorthand' | 'css-property' | 'macro' | 'animation' | 'breakpoint';
|
|
5
|
+
}
|
|
6
|
+
export declare const KNOWN_SHORTHANDS: string[];
|
|
7
|
+
export declare const COMMON_CSS_PROPERTIES: string[];
|
|
8
|
+
export declare const ANIMATION_PRESETS: string[];
|
|
9
|
+
export declare const BREAKPOINTS: string[];
|
|
10
|
+
export declare function getSuggestion(prop: string, validProperties?: string[], type?: 'shorthand' | 'css-property' | 'all'): string | SuggestionMatch | null;
|
|
11
|
+
export declare function getSuggestions(prop: string, validProperties?: string[], maxResults?: number): SuggestionMatch[];
|
|
12
|
+
export declare function getPropertySuggestion(prop: string, context?: 'spacing' | 'color' | 'typography' | 'layout' | 'animation'): string | null;
|
|
13
|
+
export declare function getShorthandSuggestion(shorthand: string): {
|
|
14
|
+
suggestion: string;
|
|
15
|
+
explanation: string;
|
|
16
|
+
} | null;
|
|
17
|
+
export declare function getValueSuggestion(property: string, value: string): {
|
|
18
|
+
suggested: string;
|
|
19
|
+
confidence: number;
|
|
20
|
+
} | null;
|
|
21
|
+
export declare function getAutocompleteSuggestions(prefix?: string, limit?: number): SuggestionMatch[];
|
|
22
|
+
export declare function formatSuggestion(suggestion: SuggestionMatch): string;
|
|
23
|
+
export declare function getDetailedSuggestion(prop: string, validProperties?: string[]): {
|
|
24
|
+
suggestion: string | null;
|
|
25
|
+
alternatives: SuggestionMatch[];
|
|
26
|
+
type: string;
|
|
27
|
+
confidence: number;
|
|
28
|
+
} | null;
|
|
29
|
+
declare const _default: {
|
|
30
|
+
getSuggestion: typeof getSuggestion;
|
|
31
|
+
getSuggestions: typeof getSuggestions;
|
|
32
|
+
getPropertySuggestion: typeof getPropertySuggestion;
|
|
33
|
+
getShorthandSuggestion: typeof getShorthandSuggestion;
|
|
34
|
+
getValueSuggestion: typeof getValueSuggestion;
|
|
35
|
+
getAutocompleteSuggestions: typeof getAutocompleteSuggestions;
|
|
36
|
+
formatSuggestion: typeof formatSuggestion;
|
|
37
|
+
getDetailedSuggestion: typeof getDetailedSuggestion;
|
|
38
|
+
KNOWN_SHORTHANDS: string[];
|
|
39
|
+
COMMON_CSS_PROPERTIES: string[];
|
|
40
|
+
ANIMATION_PRESETS: string[];
|
|
41
|
+
BREAKPOINTS: string[];
|
|
42
|
+
};
|
|
43
|
+
export default _default;
|
|
@@ -8,20 +8,6 @@ export interface ThemeContract {
|
|
|
8
8
|
export interface ThemeTokens {
|
|
9
9
|
[key: string]: string | ThemeTokens;
|
|
10
10
|
}
|
|
11
|
-
export interface TokensStructure {
|
|
12
|
-
colors: Record<string, string | Record<string, string>>;
|
|
13
|
-
spacing: Record<string, string>;
|
|
14
|
-
typography: {
|
|
15
|
-
fontFamily: Record<string, string>;
|
|
16
|
-
fontSize: Record<string, string>;
|
|
17
|
-
fontWeight: Record<string, string>;
|
|
18
|
-
lineHeight: Record<string, string>;
|
|
19
|
-
};
|
|
20
|
-
breakpoints: Record<string, string>;
|
|
21
|
-
zIndex: Record<string, string>;
|
|
22
|
-
shadows: Record<string, string>;
|
|
23
|
-
borderRadius: Record<string, string>;
|
|
24
|
-
}
|
|
25
11
|
/**
|
|
26
12
|
* Theme class with getter method
|
|
27
13
|
*/
|
|
@@ -29,33 +15,36 @@ export declare class Theme {
|
|
|
29
15
|
private tokens;
|
|
30
16
|
constructor(tokens: ThemeTokens);
|
|
31
17
|
get(path: string): string | undefined;
|
|
18
|
+
set(path: string, value: string): void;
|
|
32
19
|
toObject(): ThemeTokens;
|
|
20
|
+
toCSSVariables(prefix?: string): string;
|
|
33
21
|
}
|
|
34
22
|
/**
|
|
35
23
|
* Create a theme contract that defines the expected shape of themes
|
|
36
|
-
* @param contractShape - The contract object defining required token paths
|
|
37
|
-
* @returns Proxy contract with validation methods
|
|
38
24
|
*/
|
|
39
|
-
export declare function createThemeContract(contractShape:
|
|
40
|
-
__isContract:
|
|
25
|
+
export declare function createThemeContract<T extends ThemeContract>(contractShape: T): T & {
|
|
26
|
+
__isContract: true;
|
|
41
27
|
__validate: (theme: ThemeTokens) => boolean;
|
|
42
28
|
};
|
|
43
29
|
/**
|
|
44
30
|
* Validate that a theme matches the contract
|
|
45
|
-
* @param contract - The contract to validate against
|
|
46
|
-
* @param theme - The theme to validate
|
|
47
|
-
* @param path - Current path for error messages
|
|
48
31
|
* @returns true if valid, throws error otherwise
|
|
49
32
|
*/
|
|
50
33
|
export declare function validateTheme(contract: ThemeContract, theme?: ThemeTokens, path?: string): boolean;
|
|
51
34
|
/**
|
|
52
35
|
* Create an actual theme from a contract and values
|
|
53
|
-
* @param contract - The contract defining the shape
|
|
54
|
-
* @param themeValues - The actual theme values
|
|
55
|
-
* @returns Theme object with getter method
|
|
56
36
|
*/
|
|
57
|
-
export declare function createTheme(contract:
|
|
37
|
+
export declare function createTheme<T extends ThemeContract>(contract: T | (T & {
|
|
58
38
|
__isContract: boolean;
|
|
59
|
-
__validate: (theme: ThemeTokens) => boolean;
|
|
60
39
|
}), themeValues: ThemeTokens): Theme;
|
|
61
|
-
|
|
40
|
+
export declare function isThemeContract(obj: any): obj is ThemeContract & {
|
|
41
|
+
__isContract: true;
|
|
42
|
+
};
|
|
43
|
+
declare const _default: {
|
|
44
|
+
Theme: typeof Theme;
|
|
45
|
+
createThemeContract: typeof createThemeContract;
|
|
46
|
+
validateTheme: typeof validateTheme;
|
|
47
|
+
createTheme: typeof createTheme;
|
|
48
|
+
isThemeContract: typeof isThemeContract;
|
|
49
|
+
};
|
|
50
|
+
export default _default;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { DesignTokens } from './tokens.js';
|
|
2
|
+
/**
|
|
3
|
+
* Set the current token context for resolution
|
|
4
|
+
*/
|
|
5
|
+
export declare function setTokenContext(context: DesignTokens | null): void;
|
|
6
|
+
/**
|
|
7
|
+
* Get the current token context
|
|
8
|
+
*/
|
|
9
|
+
export declare function getTokenContext(): DesignTokens | null;
|
|
10
|
+
/**
|
|
11
|
+
* Clear the current token context
|
|
12
|
+
*/
|
|
13
|
+
export declare function clearTokenContext(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Resolve token references in a value
|
|
16
|
+
* Supports formats:
|
|
17
|
+
* - $token.path (e.g., $colors.primary)
|
|
18
|
+
* - token('path') function style
|
|
19
|
+
* - Nested references within strings
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolveToken(value: any, useTokens?: boolean, tokenContext?: DesignTokens | null): any;
|
|
22
|
+
/**
|
|
23
|
+
* Resolve multiple token references in an object
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolveTokens(obj: Record<string, any>, useTokens?: boolean, tokenContext?: DesignTokens | null): Record<string, any>;
|
|
26
|
+
/**
|
|
27
|
+
* Check if a value contains token references
|
|
28
|
+
*/
|
|
29
|
+
export declare function hasTokenReferences(value: any): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Extract all token paths from a string
|
|
32
|
+
*/
|
|
33
|
+
export declare function extractTokenPaths(value: string): string[];
|
|
34
|
+
/**
|
|
35
|
+
* Create a token resolver function for a specific context
|
|
36
|
+
*/
|
|
37
|
+
export declare function createTokenResolver(tokenContext?: DesignTokens | null): (value: any) => any;
|
|
38
|
+
/**
|
|
39
|
+
* Batch resolve multiple values
|
|
40
|
+
*/
|
|
41
|
+
export declare function resolveBatch(values: string[], useTokens?: boolean, tokenContext?: DesignTokens | null): string[];
|
|
42
|
+
/**
|
|
43
|
+
* Token resolver class for caching and batch operations
|
|
44
|
+
*/
|
|
45
|
+
export declare class TokenResolver {
|
|
46
|
+
private cache;
|
|
47
|
+
private context;
|
|
48
|
+
constructor(context?: DesignTokens | null);
|
|
49
|
+
resolve(value: any): any;
|
|
50
|
+
resolveObject(obj: Record<string, any>): Record<string, any>;
|
|
51
|
+
clearCache(): void;
|
|
52
|
+
updateContext(context: DesignTokens | null): void;
|
|
53
|
+
getStats(): {
|
|
54
|
+
cacheSize: number;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
declare const _default: {
|
|
58
|
+
resolveToken: typeof resolveToken;
|
|
59
|
+
setTokenContext: typeof setTokenContext;
|
|
60
|
+
getTokenContext: typeof getTokenContext;
|
|
61
|
+
clearTokenContext: typeof clearTokenContext;
|
|
62
|
+
resolveTokens: typeof resolveTokens;
|
|
63
|
+
hasTokenReferences: typeof hasTokenReferences;
|
|
64
|
+
extractTokenPaths: typeof extractTokenPaths;
|
|
65
|
+
createTokenResolver: typeof createTokenResolver;
|
|
66
|
+
resolveBatch: typeof resolveBatch;
|
|
67
|
+
TokenResolver: typeof TokenResolver;
|
|
68
|
+
};
|
|
69
|
+
export default _default;
|
|
@@ -9,6 +9,7 @@ export interface TokenTypography {
|
|
|
9
9
|
fontSize: Record<string, string>;
|
|
10
10
|
fontWeight: Record<string, string>;
|
|
11
11
|
lineHeight: Record<string, string>;
|
|
12
|
+
letterSpacing?: Record<string, string>;
|
|
12
13
|
}
|
|
13
14
|
export interface TokenBreakpoints {
|
|
14
15
|
[key: string]: string;
|
|
@@ -32,21 +33,45 @@ export interface TokensStructure {
|
|
|
32
33
|
borderRadius: TokenBorderRadius;
|
|
33
34
|
[key: string]: any;
|
|
34
35
|
}
|
|
36
|
+
export interface TokenValue {
|
|
37
|
+
value: any;
|
|
38
|
+
description?: string;
|
|
39
|
+
deprecated?: boolean;
|
|
40
|
+
aliases?: string[];
|
|
41
|
+
}
|
|
35
42
|
export type FlattenedTokens = Record<string, string>;
|
|
43
|
+
export declare const defaultTokens: TokensStructure;
|
|
36
44
|
export declare class DesignTokens {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
private customTokens;
|
|
46
|
+
private customFlattened;
|
|
47
|
+
private defaultFlattened;
|
|
48
|
+
private tokenCache;
|
|
49
|
+
constructor(customTokens?: Partial<TokensStructure>);
|
|
50
|
+
private deepClone;
|
|
51
|
+
private deepFreeze;
|
|
41
52
|
flattenTokens(obj: Record<string, any>, prefix?: string): FlattenedTokens;
|
|
42
53
|
get(path: string, defaultValue?: string): string;
|
|
54
|
+
getColor(path: string, defaultValue?: string): string;
|
|
55
|
+
getSpacing(path: string, defaultValue?: string): string;
|
|
56
|
+
getFontSize(path: string, defaultValue?: string): string;
|
|
57
|
+
getFontWeight(path: string, defaultValue?: string): string;
|
|
58
|
+
getLineHeight(path: string, defaultValue?: string): string;
|
|
59
|
+
getBreakpoint(path: string, defaultValue?: string): string;
|
|
60
|
+
getZIndex(path: string, defaultValue?: string): string;
|
|
61
|
+
getShadow(path: string, defaultValue?: string): string;
|
|
62
|
+
getBorderRadius(path: string, defaultValue?: string): string;
|
|
63
|
+
getCustomTokens(): FlattenedTokens;
|
|
64
|
+
getDefaultTokens(): FlattenedTokens;
|
|
65
|
+
has(path: string): boolean;
|
|
43
66
|
toCSSVariables(prefix?: string): string;
|
|
67
|
+
toMediaQueries(): Record<string, string>;
|
|
44
68
|
createTheme(name: string, overrides: Record<string, string>): DesignTokens;
|
|
45
|
-
|
|
69
|
+
merge(tokens: Partial<TokensStructure>): DesignTokens;
|
|
70
|
+
clearCache(): void;
|
|
71
|
+
getSuggestions(partialPath: string): string[];
|
|
46
72
|
}
|
|
47
|
-
export declare const defaultTokens: TokensStructure;
|
|
48
73
|
export declare const tokens: DesignTokens;
|
|
49
74
|
export declare function createTokens(customTokens: Partial<TokensStructure>): DesignTokens;
|
|
50
|
-
export declare function
|
|
75
|
+
export declare function resolveTokenReferences(value: string, tokens: DesignTokens, prefix?: string): string;
|
|
76
|
+
export declare function isTokenReference(value: any, prefix?: string): boolean;
|
|
51
77
|
export { DesignTokens as default };
|
|
52
|
-
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type ValueType = 'static' | 'dynamic' | 'runtime-only';
|
|
2
|
+
export type Mode = 'build' | 'runtime' | 'hybrid' | 'auto';
|
|
3
|
+
export interface DetectedPart {
|
|
4
|
+
type: ValueType;
|
|
5
|
+
prop: string;
|
|
6
|
+
value: any;
|
|
7
|
+
originalValue: any;
|
|
8
|
+
index: number;
|
|
9
|
+
}
|
|
10
|
+
export interface AnalysisResult {
|
|
11
|
+
staticParts: DetectedPart[];
|
|
12
|
+
dynamicParts: DetectedPart[];
|
|
13
|
+
runtimeOnlyParts: DetectedPart[];
|
|
14
|
+
isHybrid: boolean;
|
|
15
|
+
mode: Mode;
|
|
16
|
+
}
|
|
17
|
+
export declare class AutoDetector {
|
|
18
|
+
private static instance;
|
|
19
|
+
private dynamicPatterns;
|
|
20
|
+
private staticPatterns;
|
|
21
|
+
private debug;
|
|
22
|
+
static getInstance(): AutoDetector;
|
|
23
|
+
enableDebug(enabled: boolean): void;
|
|
24
|
+
detectValueType(value: any, prop?: string): ValueType;
|
|
25
|
+
analyzeChain(calls: Array<{
|
|
26
|
+
prop: string;
|
|
27
|
+
value: any;
|
|
28
|
+
index: number;
|
|
29
|
+
}>): AnalysisResult;
|
|
30
|
+
addDynamicPattern(pattern: RegExp): void;
|
|
31
|
+
addStaticPattern(pattern: RegExp): void;
|
|
32
|
+
reset(): void;
|
|
33
|
+
}
|
|
34
|
+
export declare const autoDetector: AutoDetector;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { DesignTokens } from '../compiler/tokens.js';
|
|
2
|
+
/**
|
|
3
|
+
* Convert camelCase to kebab-case
|
|
4
|
+
*/
|
|
5
|
+
export declare function kebabCase(str: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Convert kebab-case to camelCase
|
|
8
|
+
*/
|
|
9
|
+
export declare function camelCase(str: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Resolve token references in a value
|
|
12
|
+
* Supports $token.path format
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveToken(value: any, tokenStore?: Record<string, any> | DesignTokens, debug?: boolean): any;
|
|
15
|
+
/**
|
|
16
|
+
* Process a style object, expanding shorthands and resolving tokens
|
|
17
|
+
*/
|
|
18
|
+
export declare function processStyleObject(obj: Record<string, any>, tokenStore?: Record<string, any> | DesignTokens, options?: {
|
|
19
|
+
useTokens?: boolean;
|
|
20
|
+
debug?: boolean;
|
|
21
|
+
}): string;
|
|
22
|
+
/**
|
|
23
|
+
* Extract CSS string from style definition
|
|
24
|
+
*/
|
|
25
|
+
export declare function extractCSS(styleDef: Record<string, any>): string;
|
|
26
|
+
/**
|
|
27
|
+
* Extract hover CSS from style definition
|
|
28
|
+
*/
|
|
29
|
+
export declare function extractHoverCSS(styleDef: Record<string, any>): string;
|
|
30
|
+
/**
|
|
31
|
+
* Merge multiple style objects
|
|
32
|
+
*/
|
|
33
|
+
export declare function mergeStyles(...styles: Record<string, any>[]): Record<string, any>;
|
|
34
|
+
/**
|
|
35
|
+
* Check if a value is a valid CSS length
|
|
36
|
+
*/
|
|
37
|
+
export declare function isValidCSSLength(value: any): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Check if a value is a valid CSS color
|
|
40
|
+
*/
|
|
41
|
+
export declare function isValidCSSColor(value: any): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Escape CSS selector
|
|
44
|
+
*/
|
|
45
|
+
export declare function escapeSelector(selector: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Clean class name for CSS
|
|
48
|
+
*/
|
|
49
|
+
export declare function cleanClassName(className: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* Extract numeric value from CSS value
|
|
52
|
+
*/
|
|
53
|
+
export declare function extractNumericValue(value: string): number;
|
|
54
|
+
/**
|
|
55
|
+
* Extract unit from CSS value
|
|
56
|
+
*/
|
|
57
|
+
export declare function extractUnit(value: string): string;
|
|
58
|
+
/**
|
|
59
|
+
* Add unit to numeric value if missing
|
|
60
|
+
*/
|
|
61
|
+
export declare function addUnit(value: number | string, unit?: string): string;
|
|
62
|
+
/**
|
|
63
|
+
* Sort class names for consistent output
|
|
64
|
+
*/
|
|
65
|
+
export declare function sortClassNames(classNames: string[]): string[];
|
|
66
|
+
/**
|
|
67
|
+
* Join class names safely
|
|
68
|
+
*/
|
|
69
|
+
export declare function cn(...classes: (string | undefined | null | false)[]): string;
|
|
70
|
+
export declare function enableDebug(enable?: boolean): void;
|
|
71
|
+
export declare function isDebugEnabled(): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Debug log function
|
|
74
|
+
*/
|
|
75
|
+
export declare function debugLog(message: string, ...args: any[]): void;
|
|
76
|
+
declare const _default: {
|
|
77
|
+
kebabCase: typeof kebabCase;
|
|
78
|
+
camelCase: typeof camelCase;
|
|
79
|
+
resolveToken: typeof resolveToken;
|
|
80
|
+
processStyleObject: typeof processStyleObject;
|
|
81
|
+
extractCSS: typeof extractCSS;
|
|
82
|
+
extractHoverCSS: typeof extractHoverCSS;
|
|
83
|
+
mergeStyles: typeof mergeStyles;
|
|
84
|
+
isValidCSSLength: typeof isValidCSSLength;
|
|
85
|
+
isValidCSSColor: typeof isValidCSSColor;
|
|
86
|
+
escapeSelector: typeof escapeSelector;
|
|
87
|
+
cleanClassName: typeof cleanClassName;
|
|
88
|
+
extractNumericValue: typeof extractNumericValue;
|
|
89
|
+
extractUnit: typeof extractUnit;
|
|
90
|
+
addUnit: typeof addUnit;
|
|
91
|
+
sortClassNames: typeof sortClassNames;
|
|
92
|
+
cn: typeof cn;
|
|
93
|
+
enableDebug: typeof enableDebug;
|
|
94
|
+
isDebugEnabled: typeof isDebugEnabled;
|
|
95
|
+
debugLog: typeof debugLog;
|
|
96
|
+
};
|
|
97
|
+
export default _default;
|
package/dist/core/compiler.d.ts
CHANGED
|
@@ -1,32 +1,72 @@
|
|
|
1
1
|
import type { ChainCSSConfig, CompileResult, StyleDefinition } from './types.js';
|
|
2
|
+
import { AtomicOptimizer } from '../compiler/atomic-optimizer.js';
|
|
2
3
|
export declare class ChainCSSCompiler {
|
|
3
4
|
private config;
|
|
4
|
-
private atomicOptimizer;
|
|
5
5
|
private prefixer;
|
|
6
|
+
atomicOptimizer: AtomicOptimizer | null;
|
|
7
|
+
private sharedStyles;
|
|
6
8
|
private styleCache;
|
|
7
9
|
private classMap;
|
|
8
|
-
|
|
9
|
-
private
|
|
10
|
-
private
|
|
11
|
-
private
|
|
10
|
+
private runtimeCache;
|
|
11
|
+
private persistentCache;
|
|
12
|
+
private readonly MAX_STYLE_CACHE_SIZE;
|
|
13
|
+
private importedModules;
|
|
14
|
+
private dependencyGraph;
|
|
15
|
+
private generatedCSS;
|
|
16
|
+
private accumulatedCSS;
|
|
17
|
+
private compileInProgress;
|
|
18
|
+
private compileQueue;
|
|
19
|
+
private lruList;
|
|
20
|
+
constructor(config: ChainCSSConfig);
|
|
21
|
+
hasStyles(): boolean;
|
|
22
|
+
private processStyleObject;
|
|
23
|
+
private addToCache;
|
|
24
|
+
/**
|
|
25
|
+
* Scans a raw source string (from Vite) for useChainStyles patterns
|
|
26
|
+
* and registers them with the optimizer.
|
|
27
|
+
* Uses brace-counting parser instead of fragile regex.
|
|
28
|
+
*/
|
|
29
|
+
compileSource(source: string, id: string): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Safely parse a style object string without using eval.
|
|
32
|
+
* Supports JSON-like syntax and token references.
|
|
33
|
+
*/
|
|
34
|
+
private safeParseStyleObject;
|
|
35
|
+
/**
|
|
36
|
+
* Parse a limited subset of JavaScript object literal syntax.
|
|
37
|
+
* Handles: strings, numbers, booleans, null, nested objects, arrays.
|
|
38
|
+
* Does NOT execute code.
|
|
39
|
+
*/
|
|
40
|
+
private parseObjectLiteral;
|
|
41
|
+
private restoreTokens;
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated Use safeParseStyleObject instead.
|
|
44
|
+
* Kept for backward compatibility during migration.
|
|
45
|
+
*/
|
|
46
|
+
private looseParse;
|
|
47
|
+
private setupCompilerGlobals;
|
|
48
|
+
private hashStyleDef;
|
|
49
|
+
private importModule;
|
|
12
50
|
compileStyle(styleId: string, styleDef: StyleDefinition): CompileResult;
|
|
13
|
-
compileRecipe(recipeId: string,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
generateJavaScriptModule(results: Record<string, CompileResult>, outputPath: string): void;
|
|
17
|
-
generateCSSFile(results: Record<string, CompileResult>, outputPath: string): void;
|
|
18
|
-
compile(inputFile: string, outputDir: string): Promise<{
|
|
19
|
-
cssFile: string;
|
|
20
|
-
jsFile: string;
|
|
21
|
-
typesFile: string;
|
|
22
|
-
results: Record<string, CompileResult>;
|
|
23
|
-
}>;
|
|
51
|
+
compileRecipe(recipeId: string, recipeValue: any): CompileResult;
|
|
52
|
+
compile(inputFile: string, outputDir: string): Promise<any>;
|
|
53
|
+
compileFile(filePath: string): Promise<Record<string, CompileResult>>;
|
|
24
54
|
compileComponents(components: string[]): Promise<void>;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Drains the compile queue safely, handling items added during draining.
|
|
57
|
+
*/
|
|
58
|
+
private drainCompileQueue;
|
|
59
|
+
getCombinedCSS(): string;
|
|
60
|
+
clearCSS(): void;
|
|
61
|
+
getStats(): {
|
|
62
|
+
totalStyles: number;
|
|
63
|
+
atomicStyles: any;
|
|
64
|
+
uniqueProperties: any;
|
|
65
|
+
savings: string;
|
|
66
|
+
};
|
|
67
|
+
private generateCSSFile;
|
|
68
|
+
getAtomicMap(): Record<string, string>;
|
|
69
|
+
private initOptimizer;
|
|
70
|
+
private initPrefixer;
|
|
30
71
|
}
|
|
31
|
-
export declare function compileChainCSS(inputFile: string, outputDir: string, config?: ChainCSSConfig): Promise<
|
|
32
|
-
//# sourceMappingURL=compiler.d.ts.map
|
|
72
|
+
export declare function compileChainCSS(inputFile: string, outputDir: string, config?: ChainCSSConfig): Promise<any>;
|