@terrazzo/plugin-css 2.3.0 → 2.5.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/index.d.ts CHANGED
@@ -1,173 +1,8 @@
1
- import { TransformCSSValueOptions } from "@terrazzo/token-tools/css";
2
- import { CachedWildcardMatcher } from "@terrazzo/token-tools";
3
- import { BuildHookOptions, Config, Logger, Plugin, TokenNormalized, TokenTransformed, TransformHookOptions } from "@terrazzo/parser";
4
-
5
- //#region src/lib.d.ts
6
- type UtilityCSSGroup = 'bg' | 'border' | 'font' | 'layout' | 'shadow' | 'text';
7
- type UtilityCSSPrefix = 'bg' | 'border' | 'font' | 'gap' | 'm' | 'p' | 'shadow' | 'text';
8
- declare const PLUGIN_NAME = "@terrazzo/plugin-css";
9
- declare const FORMAT_ID = "css";
10
- declare const FILE_PREFIX = "/* -------------------------------------------\n * Autogenerated by \u26CB Terrazzo. DO NOT EDIT!\n * ------------------------------------------- */";
11
- interface CSSPluginOptions {
12
- /**
13
- * Where to output CSS
14
- * @default "index.css"
15
- */
16
- filename?: string;
17
- /** Glob patterns to filter tokens in output */
18
- include?: string[];
19
- /** Glob patterns to exclude tokens from output */
20
- exclude?: string[];
21
- /**
22
- * Set the base selector, like ":root" or ":host".
23
- * @deprecated use permutations instead.
24
- * @default ":root"
25
- */
26
- baseSelector?: string;
27
- /**
28
- * Set the color-scheme CSS property for `baseSelector`.
29
- * @deprecated use permutations instead.
30
- * @see https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/color-scheme
31
- * @example "light dark"
32
- */
33
- baseScheme?: string;
34
- /**
35
- * Build resolver contexts into media queries
36
- */
37
- permutations?: Permutation[];
38
- /**
39
- * Define mode selectors as media queries or CSS classes
40
- * @deprecated Migrate to permutations
41
- */
42
- modeSelectors?: ModeSelector[];
43
- /** Control the final CSS variable name */
44
- variableName?: (token: TokenNormalized) => string;
45
- /** Override certain token values */
46
- transform?: (token: TokenNormalized, options: TransformCSSValueOptions) => TokenTransformed['value'] | undefined | null;
47
- /** Generate utility CSS from groups */
48
- utility?: Partial<Record<UtilityCSSGroup, string[]>>;
49
- /**
50
- * Output colors as hex-6/hex-8 instead of color() function
51
- * @default false
52
- */
53
- legacyHex?: boolean;
54
- /**
55
- * Skip generating any `.css` files (useful if you are consuming values in your own plugin and don’t need any `.css` files written to disk).
56
- * @default false
57
- */
58
- skipBuild?: boolean;
59
- /**
60
- * Generate CSS @property definitions for type-safe CSS Custom Properties.
61
- * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@property
62
- * @default false
63
- */
64
- propertyDefinitions?: boolean;
65
- /**
66
- * Do not generate CSS shorthand declarations for typography tokens.
67
- *
68
- * Note that individual, per-subvalue declarations will still be generated for these tokens.
69
- * @default false
70
- */
71
- omitTypographyShorthand?: boolean;
72
- /**
73
- * Control how sub value names are appended to the CSS variable name.
74
- *
75
- * By default, sub value names are appended as is with a hyphen. E.g. given CSS variable name `--my-token` and
76
- * sub value name `font-size`, the resulting variable name would be `--my-token-font-size`.
77
- */
78
- subValueVariableName?: (variableName: string, subValueName: string, token: TokenTransformed) => string;
79
- }
80
- interface Permutation<T extends Record<string, string> = Record<string, string>> {
81
- /** Generate the final CSS string, wrapping content in the selector(s) of your choice. */
82
- prepare(contents: string): string;
83
- /** Input for this permutation. */
84
- input: T;
85
- /** Provide token(s) to include (Note: not including tokens that are used as aliases for other tokens could cause visual bugs in generated CSS) */
86
- include?: string[];
87
- /** Provide token(s) to exclude (Note: excluding tokens that are used as aliases for other tokens could cause visual bugs in generated CSS) */
88
- exclude?: string[];
89
- /**
90
- * Custom transform for this permutation
91
- */
92
- transform?: (token: TokenNormalized, options: TransformCSSValueOptions) => TokenTransformed['value'] | undefined | null;
93
- }
94
- interface ModeSelector {
95
- /** The name of the mode to match */
96
- mode: string;
97
- /** Provide token IDs to match. Globs are allowed (e.g: `["color.*", "shadow.dark"]`) */
98
- tokens?: string[];
99
- /** Provide CSS selectors to generate. (e.g.: `["@media (prefers-color-scheme: dark)", "[data-color-theme='dark']"]` ) */
100
- selectors: string[];
101
- /** Set the color-scheme CSS property for this mode (e.g.: "light", "dark", "light dark") */
102
- scheme?: string;
103
- }
104
- interface CSSDeclaration {
105
- type: 'Declaration';
106
- property: string;
107
- value: string;
108
- comment?: string;
109
- }
110
- interface CSSRule {
111
- type: 'Rule';
112
- prelude: string[];
113
- children: (CSSRule | CSSDeclaration)[];
114
- }
115
- /**
116
- * Convert CSSRules into a formatted, indented CSS string.
117
- * The reason we’re using this homemade version instead of something like css-tree is:
118
- *
119
- * 1. css-tree doesn’t support comments :(
120
- * 2. we are only generating PARTIALS, not full CSS (the user controls the
121
- * wrapper). So with a proper AST, we’d be hacking it a little anyway because
122
- * we never really have a true, valid, finalized document.
123
- * 3. we want @terrazzo/plugin-css to run in the browser AND be lean (i.e. don’t
124
- * load Prettier or 25MB of wasm).
125
- * 4. we only have to deal with a small subset of CSS—this doesn’t have to be robust
126
- * by any means (even future additions won’t push the limits of the spec).
127
- */
128
- declare function printRules(nodes: (CSSRule | CSSDeclaration)[], {
129
- indentChar,
130
- indentLv,
131
- alphabetize
132
- }?: {
133
- indentChar?: string;
134
- indentLv?: number;
135
- alphabetize?: boolean;
136
- }): string;
137
- /** Internal printer for individual nodes */
138
- declare function printNode(node: CSSRule | CSSDeclaration, {
139
- indentChar,
140
- indentLv
141
- }: {
142
- indentChar: string;
143
- indentLv: number;
144
- }): string;
145
- //#endregion
146
- //#region src/build.d.ts
147
- interface BuildFormatOptions {
148
- logger: Logger;
149
- include: CSSPluginOptions['include'];
150
- exclude: CSSPluginOptions['exclude'];
151
- getTransforms: BuildHookOptions['getTransforms'];
152
- modeSelectors: CSSPluginOptions['modeSelectors'];
153
- alphabetize?: Config['alphabetize'];
154
- permutations: CSSPluginOptions['permutations'];
155
- utility: CSSPluginOptions['utility'];
156
- baseSelector: string;
157
- baseScheme: CSSPluginOptions['baseScheme'];
158
- propertyDefinitions: boolean;
159
- omitTypographyShorthand: CSSPluginOptions['omitTypographyShorthand'];
160
- subValueVariableName: CSSPluginOptions['subValueVariableName'];
161
- }
162
- //#endregion
163
- //#region src/transform.d.ts
164
- interface TransformOptions {
165
- transform: TransformHookOptions;
166
- options: CSSPluginOptions;
167
- }
168
- //#endregion
169
- //#region src/index.d.ts
170
- declare function cssPlugin(options?: CSSPluginOptions): Plugin;
171
- //#endregion
172
- export { BuildFormatOptions, type CSSDeclaration, type CSSPluginOptions, type CSSRule, FILE_PREFIX, FORMAT_ID, type ModeSelector, PLUGIN_NAME, type Permutation, TransformOptions, type UtilityCSSGroup, type UtilityCSSPrefix, cssPlugin as default, printNode, printRules };
1
+ import type { Plugin } from '@terrazzo/parser';
2
+ import { type CSSPluginOptions } from './lib.js';
3
+ export * from './build.js';
4
+ export { type CSSDeclaration, type CSSPluginOptions, type CSSRule, FILE_PREFIX, FORMAT_ID, type ModeSelector, type Permutation, PLUGIN_NAME, printNode, printRules, type UtilityCSSGroup, type UtilityCSSPrefix, } from './lib.js';
5
+ export * from './transform.js';
6
+ export * from './utility-css.js';
7
+ export default function cssPlugin(options?: CSSPluginOptions): Plugin;
173
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/lib.ts","../src/build.ts","../src/transform.ts","../src/index.ts"],"mappings":";;;;;KAKY,eAAA;AAAA,KAEA,gBAAA;AAAA,cAEC,WAAA;AAAA,cAEA,SAAA;AAAA,cAIA,WAAA;AAAA,UAII,gBAAA;EAZL;;;;EAiBV,QAAA;EAfW;EAiBX,OAAA;;EAEA,OAAA;EAnBsB;AAExB;;;;EAuBE,YAAA;EAnBW;;;;AAAW;AAIxB;EAsBE,UAAA;;;;EAIA,YAAA,GAAe,WAAA;EAUN;;;;EALT,aAAA,GAAgB,YAAA;EASN;EAPV,YAAA,IAAgB,KAAA,EAAO,eAAA;EAqCoE;EAnC3F,SAAA,IACE,KAAA,EAAO,eAAA,EACP,OAAA,EAAS,w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