css-typed-vars 0.6.0 → 0.8.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/README.md +189 -9
- package/dist/{chunk-TD7SYMDA.js → chunk-32V3V6WT.js} +46 -29
- package/dist/chunk-5HPTHW7S.js +820 -0
- package/dist/{chunk-VZ2BHHXD.js → chunk-YDXCJQPL.js} +42 -29
- package/dist/cli.cjs +542 -151
- package/dist/cli.js +142 -73
- package/dist/esbuild.cjs +358 -87
- package/dist/esbuild.d.cts +1 -1
- package/dist/esbuild.d.ts +1 -1
- package/dist/esbuild.js +2 -2
- package/dist/generator-DJ9uOYBP.d.cts +69 -0
- package/dist/generator-DJ9uOYBP.d.ts +69 -0
- package/dist/index.cjs +423 -77
- package/dist/index.d.cts +29 -6
- package/dist/index.d.ts +29 -6
- package/dist/index.js +14 -2
- package/dist/rollup.cjs +358 -87
- package/dist/rollup.d.cts +1 -1
- package/dist/rollup.d.ts +1 -1
- package/dist/rollup.js +2 -2
- package/dist/unplugin.cjs +358 -87
- package/dist/unplugin.d.cts +12 -2
- package/dist/unplugin.d.ts +12 -2
- package/dist/unplugin.js +2 -2
- package/dist/vite.cjs +358 -87
- package/dist/vite.d.cts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +2 -2
- package/dist/webpack.cjs +358 -87
- package/dist/webpack.d.cts +1 -1
- package/dist/webpack.d.ts +1 -1
- package/dist/webpack.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-LH53WYFF.js +0 -487
- package/dist/generator-C2AppeJL.d.cts +0 -15
- package/dist/generator-C2AppeJL.d.ts +0 -15
package/dist/index.d.cts
CHANGED
|
@@ -1,31 +1,54 @@
|
|
|
1
|
-
import { P as PropertyRule, N as NamingConvention } from './generator-
|
|
2
|
-
export { g as generateCode,
|
|
1
|
+
import { V as VarReference, P as PropertyRule, a as VarDoc, N as NamingConvention } from './generator-DJ9uOYBP.cjs';
|
|
2
|
+
export { G as GeneratorOptions, T as ThemedDeclarations, g as generateCode, b as generateDeclaration, c as generateJs, d as generateTokens, p as parseDeclaredNames, e as parsePropertyRules, f as parseThemedDeclarations, h as parseVarDeclarations, i as parseVarNames, j as parseVarReferences } from './generator-DJ9uOYBP.cjs';
|
|
3
3
|
|
|
4
4
|
interface ScannedCss {
|
|
5
5
|
declarations: Map<string, string>;
|
|
6
6
|
properties: Map<string, PropertyRule>;
|
|
7
|
+
/** Per theme name (from the `themes` option), the values declared for it. Empty without `themes`. */
|
|
8
|
+
themes: Map<string, Map<string, string>>;
|
|
9
|
+
/** `/** ... *\/` doc comments placed directly before a declaration. */
|
|
10
|
+
docs: Map<string, VarDoc>;
|
|
7
11
|
}
|
|
8
|
-
declare function scanCss(patterns: string | string[], exclude?: string | string[], selectors?: string[]): Promise<ScannedCss>;
|
|
12
|
+
declare function scanCss(patterns: string | string[], exclude?: string | string[], selectors?: string[], themes?: Record<string, string>): Promise<ScannedCss>;
|
|
9
13
|
declare function scanVarDeclarations(patterns: string | string[], exclude?: string | string[], selectors?: string[]): Promise<Map<string, string>>;
|
|
10
14
|
declare function scanVarNames(patterns: string | string[], exclude?: string | string[], selectors?: string[]): Promise<string[]>;
|
|
15
|
+
interface FileReference extends VarReference {
|
|
16
|
+
file: string;
|
|
17
|
+
}
|
|
18
|
+
declare function scanReferences(patterns: string | string[], exclude?: string | string[]): Promise<{
|
|
19
|
+
references: FileReference[];
|
|
20
|
+
declared: Set<string>;
|
|
21
|
+
}>;
|
|
11
22
|
declare function scanUsedKeys(patterns: string | string[], exclude?: string | string[]): Promise<Set<string>>;
|
|
12
23
|
|
|
13
24
|
interface GenerateOptions {
|
|
14
25
|
input: string | string[];
|
|
26
|
+
/** `.ts`, `.js`/`.mjs`/`.cjs` (plus a `.d.ts`), or `.json` for a W3C design tokens (DTCG) file. */
|
|
15
27
|
output: string;
|
|
16
28
|
exclude?: string | string[];
|
|
17
29
|
prefix?: string;
|
|
18
30
|
naming?: NamingConvention;
|
|
19
31
|
selectors?: string[];
|
|
32
|
+
/**
|
|
33
|
+
* Theme name -> selector (`'[data-theme="dark"]'`) or `@media` prelude
|
|
34
|
+
* (`'@media (prefers-color-scheme: dark)'`). Each theme's values are emitted as
|
|
35
|
+
* `@theme <name> <value>` JSDoc tags, and kept out of the default value.
|
|
36
|
+
*/
|
|
37
|
+
themes?: Record<string, string>;
|
|
20
38
|
group?: boolean;
|
|
21
|
-
/** Prune generated vars with no detected `cssVars.<key>` usage. Requires `usage
|
|
39
|
+
/** Prune generated vars with no detected `cssVars.<key>` (or `cssVars.<group>.<key>`) usage. Requires `usage`. */
|
|
22
40
|
prune?: boolean;
|
|
23
41
|
/** Glob(s) of source files to scan for `cssVars` usage. Required when `prune` is true, or when calling `findUnusedVars`. */
|
|
24
42
|
usage?: string | string[];
|
|
25
43
|
usageExclude?: string | string[];
|
|
44
|
+
/** Also emit the `CssVarRef` type and `getCssVar`/`setCssVar` runtime helpers. */
|
|
45
|
+
helpers?: boolean;
|
|
46
|
+
/** Names (or `--prefix-*` patterns) that `findUndefinedRefs` shouldn't report, e.g. vars set from JS. */
|
|
47
|
+
refsIgnore?: string[];
|
|
26
48
|
}
|
|
27
|
-
declare function findUnusedVars(options: Pick<GenerateOptions, 'input' | 'exclude' | 'selectors' | 'prefix' | 'naming' | 'usage' | 'usageExclude'>): Promise<string[]>;
|
|
49
|
+
declare function findUnusedVars(options: Pick<GenerateOptions, 'input' | 'exclude' | 'selectors' | 'themes' | 'prefix' | 'naming' | 'group' | 'usage' | 'usageExclude'>): Promise<string[]>;
|
|
50
|
+
declare function findUndefinedRefs(options: Pick<GenerateOptions, 'input' | 'exclude' | 'refsIgnore'>): Promise<FileReference[]>;
|
|
28
51
|
declare function generate(options: GenerateOptions): Promise<void>;
|
|
29
52
|
declare function checkGenerated(options: GenerateOptions): Promise<boolean>;
|
|
30
53
|
|
|
31
|
-
export { type GenerateOptions, NamingConvention, PropertyRule, checkGenerated, findUnusedVars, generate, scanCss, scanUsedKeys, scanVarDeclarations, scanVarNames };
|
|
54
|
+
export { type FileReference, type GenerateOptions, NamingConvention, PropertyRule, VarDoc, VarReference, checkGenerated, findUndefinedRefs, findUnusedVars, generate, scanCss, scanReferences, scanUsedKeys, scanVarDeclarations, scanVarNames };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,31 +1,54 @@
|
|
|
1
|
-
import { P as PropertyRule, N as NamingConvention } from './generator-
|
|
2
|
-
export { g as generateCode,
|
|
1
|
+
import { V as VarReference, P as PropertyRule, a as VarDoc, N as NamingConvention } from './generator-DJ9uOYBP.js';
|
|
2
|
+
export { G as GeneratorOptions, T as ThemedDeclarations, g as generateCode, b as generateDeclaration, c as generateJs, d as generateTokens, p as parseDeclaredNames, e as parsePropertyRules, f as parseThemedDeclarations, h as parseVarDeclarations, i as parseVarNames, j as parseVarReferences } from './generator-DJ9uOYBP.js';
|
|
3
3
|
|
|
4
4
|
interface ScannedCss {
|
|
5
5
|
declarations: Map<string, string>;
|
|
6
6
|
properties: Map<string, PropertyRule>;
|
|
7
|
+
/** Per theme name (from the `themes` option), the values declared for it. Empty without `themes`. */
|
|
8
|
+
themes: Map<string, Map<string, string>>;
|
|
9
|
+
/** `/** ... *\/` doc comments placed directly before a declaration. */
|
|
10
|
+
docs: Map<string, VarDoc>;
|
|
7
11
|
}
|
|
8
|
-
declare function scanCss(patterns: string | string[], exclude?: string | string[], selectors?: string[]): Promise<ScannedCss>;
|
|
12
|
+
declare function scanCss(patterns: string | string[], exclude?: string | string[], selectors?: string[], themes?: Record<string, string>): Promise<ScannedCss>;
|
|
9
13
|
declare function scanVarDeclarations(patterns: string | string[], exclude?: string | string[], selectors?: string[]): Promise<Map<string, string>>;
|
|
10
14
|
declare function scanVarNames(patterns: string | string[], exclude?: string | string[], selectors?: string[]): Promise<string[]>;
|
|
15
|
+
interface FileReference extends VarReference {
|
|
16
|
+
file: string;
|
|
17
|
+
}
|
|
18
|
+
declare function scanReferences(patterns: string | string[], exclude?: string | string[]): Promise<{
|
|
19
|
+
references: FileReference[];
|
|
20
|
+
declared: Set<string>;
|
|
21
|
+
}>;
|
|
11
22
|
declare function scanUsedKeys(patterns: string | string[], exclude?: string | string[]): Promise<Set<string>>;
|
|
12
23
|
|
|
13
24
|
interface GenerateOptions {
|
|
14
25
|
input: string | string[];
|
|
26
|
+
/** `.ts`, `.js`/`.mjs`/`.cjs` (plus a `.d.ts`), or `.json` for a W3C design tokens (DTCG) file. */
|
|
15
27
|
output: string;
|
|
16
28
|
exclude?: string | string[];
|
|
17
29
|
prefix?: string;
|
|
18
30
|
naming?: NamingConvention;
|
|
19
31
|
selectors?: string[];
|
|
32
|
+
/**
|
|
33
|
+
* Theme name -> selector (`'[data-theme="dark"]'`) or `@media` prelude
|
|
34
|
+
* (`'@media (prefers-color-scheme: dark)'`). Each theme's values are emitted as
|
|
35
|
+
* `@theme <name> <value>` JSDoc tags, and kept out of the default value.
|
|
36
|
+
*/
|
|
37
|
+
themes?: Record<string, string>;
|
|
20
38
|
group?: boolean;
|
|
21
|
-
/** Prune generated vars with no detected `cssVars.<key>` usage. Requires `usage
|
|
39
|
+
/** Prune generated vars with no detected `cssVars.<key>` (or `cssVars.<group>.<key>`) usage. Requires `usage`. */
|
|
22
40
|
prune?: boolean;
|
|
23
41
|
/** Glob(s) of source files to scan for `cssVars` usage. Required when `prune` is true, or when calling `findUnusedVars`. */
|
|
24
42
|
usage?: string | string[];
|
|
25
43
|
usageExclude?: string | string[];
|
|
44
|
+
/** Also emit the `CssVarRef` type and `getCssVar`/`setCssVar` runtime helpers. */
|
|
45
|
+
helpers?: boolean;
|
|
46
|
+
/** Names (or `--prefix-*` patterns) that `findUndefinedRefs` shouldn't report, e.g. vars set from JS. */
|
|
47
|
+
refsIgnore?: string[];
|
|
26
48
|
}
|
|
27
|
-
declare function findUnusedVars(options: Pick<GenerateOptions, 'input' | 'exclude' | 'selectors' | 'prefix' | 'naming' | 'usage' | 'usageExclude'>): Promise<string[]>;
|
|
49
|
+
declare function findUnusedVars(options: Pick<GenerateOptions, 'input' | 'exclude' | 'selectors' | 'themes' | 'prefix' | 'naming' | 'group' | 'usage' | 'usageExclude'>): Promise<string[]>;
|
|
50
|
+
declare function findUndefinedRefs(options: Pick<GenerateOptions, 'input' | 'exclude' | 'refsIgnore'>): Promise<FileReference[]>;
|
|
28
51
|
declare function generate(options: GenerateOptions): Promise<void>;
|
|
29
52
|
declare function checkGenerated(options: GenerateOptions): Promise<boolean>;
|
|
30
53
|
|
|
31
|
-
export { type GenerateOptions, NamingConvention, PropertyRule, checkGenerated, findUnusedVars, generate, scanCss, scanUsedKeys, scanVarDeclarations, scanVarNames };
|
|
54
|
+
export { type FileReference, type GenerateOptions, NamingConvention, PropertyRule, VarDoc, VarReference, checkGenerated, findUndefinedRefs, findUnusedVars, generate, scanCss, scanReferences, scanUsedKeys, scanVarDeclarations, scanVarNames };
|
package/dist/index.js
CHANGED
|
@@ -1,31 +1,43 @@
|
|
|
1
1
|
import {
|
|
2
2
|
checkGenerated,
|
|
3
|
+
findUndefinedRefs,
|
|
3
4
|
findUnusedVars,
|
|
4
5
|
generate
|
|
5
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YDXCJQPL.js";
|
|
6
7
|
import {
|
|
7
8
|
generateCode,
|
|
8
9
|
generateDeclaration,
|
|
9
10
|
generateJs,
|
|
11
|
+
generateTokens,
|
|
12
|
+
parseDeclaredNames,
|
|
10
13
|
parsePropertyRules,
|
|
14
|
+
parseThemedDeclarations,
|
|
11
15
|
parseVarDeclarations,
|
|
12
16
|
parseVarNames,
|
|
17
|
+
parseVarReferences,
|
|
13
18
|
scanCss,
|
|
19
|
+
scanReferences,
|
|
14
20
|
scanUsedKeys,
|
|
15
21
|
scanVarDeclarations,
|
|
16
22
|
scanVarNames
|
|
17
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-5HPTHW7S.js";
|
|
18
24
|
export {
|
|
19
25
|
checkGenerated,
|
|
26
|
+
findUndefinedRefs,
|
|
20
27
|
findUnusedVars,
|
|
21
28
|
generate,
|
|
22
29
|
generateCode,
|
|
23
30
|
generateDeclaration,
|
|
24
31
|
generateJs,
|
|
32
|
+
generateTokens,
|
|
33
|
+
parseDeclaredNames,
|
|
25
34
|
parsePropertyRules,
|
|
35
|
+
parseThemedDeclarations,
|
|
26
36
|
parseVarDeclarations,
|
|
27
37
|
parseVarNames,
|
|
38
|
+
parseVarReferences,
|
|
28
39
|
scanCss,
|
|
40
|
+
scanReferences,
|
|
29
41
|
scanUsedKeys,
|
|
30
42
|
scanVarDeclarations,
|
|
31
43
|
scanVarNames
|