@csszyx/unplugin 0.3.0 → 0.4.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/dist/{chunk-3J4XUYF5.js → chunk-CW4XYEQR.js} +607 -71
- package/dist/index.cjs +611 -71
- package/dist/index.d.cts +51 -1
- package/dist/index.d.ts +51 -1
- package/dist/index.js +9 -1
- package/dist/{unplugin-B9noIooS.d.cts → unplugin-DUbr5w-N.d.cts} +17 -1
- package/dist/{unplugin-B9noIooS.d.ts → unplugin-DUbr5w-N.d.ts} +17 -1
- package/dist/vite.cjs +597 -69
- package/dist/vite.d.cts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +1 -1
- package/dist/webpack.cjs +597 -69
- package/dist/webpack.d.cts +1 -1
- package/dist/webpack.d.ts +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +6 -6
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,58 @@
|
|
|
1
1
|
export { CSSManglerOptions, CSSManglerResult, MangleMap, createPostCSSPlugin, escapeCSSClassName, mangleCSS, mangleCSSSync, unescapeTailwindClass } from './css-mangler.cjs';
|
|
2
|
-
export { u as default, e as esbuildPlugin, r as rollupPlugin, u as unplugin, v as vitePlugin, w as webpackPlugin } from './unplugin-
|
|
2
|
+
export { u as default, e as esbuildPlugin, m as mangleCodeClassesSync, r as rollupPlugin, u as unplugin, v as vitePlugin, w as webpackPlugin } from './unplugin-DUbr5w-N.cjs';
|
|
3
3
|
import 'postcss';
|
|
4
4
|
import '@csszyx/types';
|
|
5
5
|
import 'esbuild';
|
|
6
6
|
import 'rollup';
|
|
7
7
|
import 'unplugin';
|
|
8
8
|
import 'vite';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Theme Scanner — parses Tailwind v4 @theme blocks from CSS files.
|
|
12
|
+
*
|
|
13
|
+
* Extracts custom design tokens and categorizes them by type so the
|
|
14
|
+
* type writer can generate accurate TypeScript augmentation.
|
|
15
|
+
*
|
|
16
|
+
* Supports:
|
|
17
|
+
* - Multiple @theme blocks per file
|
|
18
|
+
* - @theme inline { } syntax (inline keyword ignored)
|
|
19
|
+
* - @theme inside @layer (two-pass strip)
|
|
20
|
+
* - --color-brand-50 shade suffixes (deduped to 'brand')
|
|
21
|
+
* - Multi-file merge via mergeThemes()
|
|
22
|
+
*/
|
|
23
|
+
/** Extracted and categorized custom tokens from @theme blocks. */
|
|
24
|
+
interface ParsedTheme {
|
|
25
|
+
/** Custom color names (from --color-*): e.g. ['brand', 'brand-dark'] */
|
|
26
|
+
colors: string[];
|
|
27
|
+
/** Custom spacing tokens (from --spacing-*): e.g. ['xl', '2xs'] */
|
|
28
|
+
spacings: string[];
|
|
29
|
+
/** Custom font families (from --font-*): e.g. ['display', 'body'] */
|
|
30
|
+
fonts: string[];
|
|
31
|
+
/** Custom border radii (from --radius-*): e.g. ['button'] */
|
|
32
|
+
radii: string[];
|
|
33
|
+
/** Custom shadows (from --shadow-*): e.g. ['card'] */
|
|
34
|
+
shadows: string[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Parse all @theme blocks in a CSS file and extract design tokens.
|
|
38
|
+
*
|
|
39
|
+
* @param cssContent - Raw CSS file content
|
|
40
|
+
* @returns Categorized design tokens
|
|
41
|
+
*/
|
|
42
|
+
declare function parseThemeBlocks(cssContent: string): ParsedTheme;
|
|
43
|
+
/**
|
|
44
|
+
* Merge multiple ParsedTheme objects into one, deduplicating tokens.
|
|
45
|
+
*
|
|
46
|
+
* @param themes - Array of parsed themes to merge
|
|
47
|
+
* @returns Merged theme with unique tokens per category
|
|
48
|
+
*/
|
|
49
|
+
declare function mergeThemes(themes: ParsedTheme[]): ParsedTheme;
|
|
50
|
+
/**
|
|
51
|
+
* Check if a ParsedTheme has any tokens.
|
|
52
|
+
*
|
|
53
|
+
* @param theme - Parsed theme to check
|
|
54
|
+
* @returns True if at least one category has tokens
|
|
55
|
+
*/
|
|
56
|
+
declare function hasTokens(theme: ParsedTheme): boolean;
|
|
57
|
+
|
|
58
|
+
export { type ParsedTheme, hasTokens, mergeThemes, parseThemeBlocks };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,58 @@
|
|
|
1
1
|
export { CSSManglerOptions, CSSManglerResult, MangleMap, createPostCSSPlugin, escapeCSSClassName, mangleCSS, mangleCSSSync, unescapeTailwindClass } from './css-mangler.js';
|
|
2
|
-
export { u as default, e as esbuildPlugin, r as rollupPlugin, u as unplugin, v as vitePlugin, w as webpackPlugin } from './unplugin-
|
|
2
|
+
export { u as default, e as esbuildPlugin, m as mangleCodeClassesSync, r as rollupPlugin, u as unplugin, v as vitePlugin, w as webpackPlugin } from './unplugin-DUbr5w-N.js';
|
|
3
3
|
import 'postcss';
|
|
4
4
|
import '@csszyx/types';
|
|
5
5
|
import 'esbuild';
|
|
6
6
|
import 'rollup';
|
|
7
7
|
import 'unplugin';
|
|
8
8
|
import 'vite';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Theme Scanner — parses Tailwind v4 @theme blocks from CSS files.
|
|
12
|
+
*
|
|
13
|
+
* Extracts custom design tokens and categorizes them by type so the
|
|
14
|
+
* type writer can generate accurate TypeScript augmentation.
|
|
15
|
+
*
|
|
16
|
+
* Supports:
|
|
17
|
+
* - Multiple @theme blocks per file
|
|
18
|
+
* - @theme inline { } syntax (inline keyword ignored)
|
|
19
|
+
* - @theme inside @layer (two-pass strip)
|
|
20
|
+
* - --color-brand-50 shade suffixes (deduped to 'brand')
|
|
21
|
+
* - Multi-file merge via mergeThemes()
|
|
22
|
+
*/
|
|
23
|
+
/** Extracted and categorized custom tokens from @theme blocks. */
|
|
24
|
+
interface ParsedTheme {
|
|
25
|
+
/** Custom color names (from --color-*): e.g. ['brand', 'brand-dark'] */
|
|
26
|
+
colors: string[];
|
|
27
|
+
/** Custom spacing tokens (from --spacing-*): e.g. ['xl', '2xs'] */
|
|
28
|
+
spacings: string[];
|
|
29
|
+
/** Custom font families (from --font-*): e.g. ['display', 'body'] */
|
|
30
|
+
fonts: string[];
|
|
31
|
+
/** Custom border radii (from --radius-*): e.g. ['button'] */
|
|
32
|
+
radii: string[];
|
|
33
|
+
/** Custom shadows (from --shadow-*): e.g. ['card'] */
|
|
34
|
+
shadows: string[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Parse all @theme blocks in a CSS file and extract design tokens.
|
|
38
|
+
*
|
|
39
|
+
* @param cssContent - Raw CSS file content
|
|
40
|
+
* @returns Categorized design tokens
|
|
41
|
+
*/
|
|
42
|
+
declare function parseThemeBlocks(cssContent: string): ParsedTheme;
|
|
43
|
+
/**
|
|
44
|
+
* Merge multiple ParsedTheme objects into one, deduplicating tokens.
|
|
45
|
+
*
|
|
46
|
+
* @param themes - Array of parsed themes to merge
|
|
47
|
+
* @returns Merged theme with unique tokens per category
|
|
48
|
+
*/
|
|
49
|
+
declare function mergeThemes(themes: ParsedTheme[]): ParsedTheme;
|
|
50
|
+
/**
|
|
51
|
+
* Check if a ParsedTheme has any tokens.
|
|
52
|
+
*
|
|
53
|
+
* @param theme - Parsed theme to check
|
|
54
|
+
* @returns True if at least one category has tokens
|
|
55
|
+
*/
|
|
56
|
+
declare function hasTokens(theme: ParsedTheme): boolean;
|
|
57
|
+
|
|
58
|
+
export { type ParsedTheme, hasTokens, mergeThemes, parseThemeBlocks };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
esbuildPlugin,
|
|
3
|
+
hasTokens,
|
|
4
|
+
mangleCodeClassesSync,
|
|
5
|
+
mergeThemes,
|
|
6
|
+
parseThemeBlocks,
|
|
3
7
|
rollupPlugin,
|
|
4
8
|
unplugin,
|
|
5
9
|
vitePlugin,
|
|
6
10
|
webpackPlugin
|
|
7
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-CW4XYEQR.js";
|
|
8
12
|
import {
|
|
9
13
|
createPostCSSPlugin,
|
|
10
14
|
escapeCSSClassName,
|
|
@@ -17,8 +21,12 @@ export {
|
|
|
17
21
|
unplugin as default,
|
|
18
22
|
esbuildPlugin,
|
|
19
23
|
escapeCSSClassName,
|
|
24
|
+
hasTokens,
|
|
20
25
|
mangleCSS,
|
|
21
26
|
mangleCSSSync,
|
|
27
|
+
mangleCodeClassesSync,
|
|
28
|
+
mergeThemes,
|
|
29
|
+
parseThemeBlocks,
|
|
22
30
|
rollupPlugin,
|
|
23
31
|
unescapeTailwindClass,
|
|
24
32
|
unplugin,
|
|
@@ -4,6 +4,22 @@ import { InputPluginOption } from 'rollup';
|
|
|
4
4
|
import { UnpluginInstance, WebpackPluginInstance } from 'unplugin';
|
|
5
5
|
import { PluginOption } from 'vite';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Mangles class strings in bundled code (JS/HTML assets) using the given mangle map.
|
|
9
|
+
*
|
|
10
|
+
* Exported for unit testing; the plugin calls this via the thin private wrapper that
|
|
11
|
+
* supplies state.mangleMap.
|
|
12
|
+
*
|
|
13
|
+
* Pass 1: Direct `className="..."` / `class="..."` static strings
|
|
14
|
+
* Pass 1.5: Template literal quasi (static) segments in `className:\`...\``
|
|
15
|
+
* Pass 2: `className:EXPR` patterns with ternary operators containing quoted strings
|
|
16
|
+
* Pass 3: Quoted string arguments to csszyx runtime helpers (_szMerge, _szIf, etc.)
|
|
17
|
+
*
|
|
18
|
+
* @param code bundled source code
|
|
19
|
+
* @param mangleMap class-name → mangled-token mapping
|
|
20
|
+
* @returns code with mangled class names
|
|
21
|
+
*/
|
|
22
|
+
declare function mangleCodeClassesSync(code: string, mangleMap: Record<string, string>): string;
|
|
7
23
|
declare const unplugin: UnpluginInstance<PartialCsszyxConfig, boolean>;
|
|
8
24
|
/**
|
|
9
25
|
* Creates a Vite plugin array with both pre-transform and post-mangle plugins.
|
|
@@ -30,4 +46,4 @@ declare const rollupPlugin: (options?: PartialCsszyxConfig) => InputPluginOption
|
|
|
30
46
|
*/
|
|
31
47
|
declare const esbuildPlugin: (options?: PartialCsszyxConfig) => Plugin;
|
|
32
48
|
|
|
33
|
-
export { esbuildPlugin as e, rollupPlugin as r, unplugin as u, vitePlugin as v, webpackPlugin as w };
|
|
49
|
+
export { esbuildPlugin as e, mangleCodeClassesSync as m, rollupPlugin as r, unplugin as u, vitePlugin as v, webpackPlugin as w };
|
|
@@ -4,6 +4,22 @@ import { InputPluginOption } from 'rollup';
|
|
|
4
4
|
import { UnpluginInstance, WebpackPluginInstance } from 'unplugin';
|
|
5
5
|
import { PluginOption } from 'vite';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Mangles class strings in bundled code (JS/HTML assets) using the given mangle map.
|
|
9
|
+
*
|
|
10
|
+
* Exported for unit testing; the plugin calls this via the thin private wrapper that
|
|
11
|
+
* supplies state.mangleMap.
|
|
12
|
+
*
|
|
13
|
+
* Pass 1: Direct `className="..."` / `class="..."` static strings
|
|
14
|
+
* Pass 1.5: Template literal quasi (static) segments in `className:\`...\``
|
|
15
|
+
* Pass 2: `className:EXPR` patterns with ternary operators containing quoted strings
|
|
16
|
+
* Pass 3: Quoted string arguments to csszyx runtime helpers (_szMerge, _szIf, etc.)
|
|
17
|
+
*
|
|
18
|
+
* @param code bundled source code
|
|
19
|
+
* @param mangleMap class-name → mangled-token mapping
|
|
20
|
+
* @returns code with mangled class names
|
|
21
|
+
*/
|
|
22
|
+
declare function mangleCodeClassesSync(code: string, mangleMap: Record<string, string>): string;
|
|
7
23
|
declare const unplugin: UnpluginInstance<PartialCsszyxConfig, boolean>;
|
|
8
24
|
/**
|
|
9
25
|
* Creates a Vite plugin array with both pre-transform and post-mangle plugins.
|
|
@@ -30,4 +46,4 @@ declare const rollupPlugin: (options?: PartialCsszyxConfig) => InputPluginOption
|
|
|
30
46
|
*/
|
|
31
47
|
declare const esbuildPlugin: (options?: PartialCsszyxConfig) => Plugin;
|
|
32
48
|
|
|
33
|
-
export { esbuildPlugin as e, rollupPlugin as r, unplugin as u, vitePlugin as v, webpackPlugin as w };
|
|
49
|
+
export { esbuildPlugin as e, mangleCodeClassesSync as m, rollupPlugin as r, unplugin as u, vitePlugin as v, webpackPlugin as w };
|