@terrazzo/plugin-css 2.0.0-beta.3 → 2.0.0-beta.5

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,3 +1,4 @@
1
+ import { CachedWildcardMatcher } from "@terrazzo/token-tools";
1
2
  import { BuildHookOptions, Logger, Plugin, TokenNormalized, TokenTransformed, TransformHookOptions } from "@terrazzo/parser";
2
3
 
3
4
  //#region src/lib.d.ts
@@ -12,6 +13,8 @@ interface CSSPluginOptions {
12
13
  * @default "index.css"
13
14
  */
14
15
  filename?: string;
16
+ /** Glob patterns to filter tokens in output */
17
+ include?: string[];
15
18
  /** Glob patterns to exclude tokens from output */
16
19
  exclude?: string[];
17
20
  /**
@@ -60,8 +63,10 @@ interface Permutation<T extends Record<string, string> = Record<string, string>>
60
63
  prepare(css: string): string;
61
64
  /** Input for this permutation. */
62
65
  input: T;
63
- /** Provide token(s) to ignore (Note: ignoring tokens that are used as aliases for other tokens could cause visual bugs in generated CSS) */
64
- ignore?: string[];
66
+ /** Provide token(s) to include (Note: not including tokens that are used as aliases for other tokens could cause visual bugs in generated CSS) */
67
+ include?: string[];
68
+ /** Provide token(s) to exclude (Note: excluding tokens that are used as aliases for other tokens could cause visual bugs in generated CSS) */
69
+ exclude?: string[];
65
70
  }
66
71
  interface ModeSelector {
67
72
  /** The name of the mode to match */
@@ -112,23 +117,11 @@ declare function printNode(node: CSSRule | CSSDeclaration, {
112
117
  indentChar: string;
113
118
  indentLv: number;
114
119
  }): string;
115
- /** Infer indentation preferences from a user-defined wrapping method. */
116
- declare function getIndentFromPrepare(prepare: (css: string) => string): {
117
- indentChar: string;
118
- indentLv: number;
119
- };
120
- /** Syntactic sugar over Rule boilerplate */
121
- declare function rule(prelude: CSSRule['prelude'], children?: CSSRule['children']): CSSRule;
122
- /** Syntactic sugar over Declaration boilerplate */
123
- declare function decl(property: CSSDeclaration['property'], value: CSSDeclaration['value'], comment?: CSSDeclaration['comment']): CSSDeclaration;
124
- /** Does a node list contain a root-level declaration with this property? */
125
- declare function hasDecl(list: (CSSRule | CSSDeclaration)[], property: string): boolean;
126
- /** Add a declaration only if it’s unique (note: CSS, by design, allows duplication—it’s how fallbacks happen. Only use this if fallbacks aren’t needed. */
127
- declare function addDeclUnique(list: (CSSRule | CSSDeclaration)[], declaration: CSSDeclaration): void;
128
120
  //#endregion
129
121
  //#region src/build.d.ts
130
122
  interface BuildFormatOptions {
131
123
  logger: Logger;
124
+ include: CSSPluginOptions['include'];
132
125
  exclude: CSSPluginOptions['exclude'];
133
126
  getTransforms: BuildHookOptions['getTransforms'];
134
127
  modeSelectors: CSSPluginOptions['modeSelectors'];
@@ -147,5 +140,5 @@ interface TransformOptions {
147
140
  //#region src/index.d.ts
148
141
  declare function cssPlugin(options?: CSSPluginOptions): Plugin;
149
142
  //#endregion
150
- export { BuildFormatOptions, CSSDeclaration, CSSPluginOptions, CSSRule, FILE_PREFIX, FORMAT_ID, ModeSelector, PLUGIN_NAME, Permutation, TransformOptions, UtilityCSSGroup, UtilityCSSPrefix, addDeclUnique, decl, cssPlugin as default, getIndentFromPrepare, hasDecl, printNode, printRules, rule };
143
+ 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 };
151
144
  //# 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":";;;KAEY,eAAA;AAAA,KAEA,gBAAA;AAAA,cAEC,WAAA;AAAA,cAEA,SAAA;AAAA,cAEA,WAAA;AAAA,UAII,gBAAA;EAZU;AAE3B;;;EAeE,QAAA;EAf0B;EAiB1B,OAAA;EAfsB;;;;AAExB;EAmBE,YAAA;;;;AAjBF;;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EAWP,MAAA;EAXQ;EAaR,SAAA;EAjBqC;EAmBrC,MAAA;AAAA;AAAA,UAIe,cAAA;EACf,IAAA;EACA,QAAA;EACA,KAAA;EACA,OAAA;AAAA;AAAA,UAGe,OAAA;EACf,IAAA;EACA,OAAA;EACA,QAAA,GAAW,OAAA,GAAU,cAAA;AAAA;;;;;;;AAVvB;;;;;;;iBA0BgB,UAAA,CACd,KAAA,GAAQ,OAAA,GAAU,cAAA;EAChB,UAAA;EAAmB;AAAA;EAAkB,UAAA;EAAqB,QAAA;AAAA;;iBAa9C,SAAA,CACd,IAAA,EAAM,OAAA,GAAU,cAAA;EACd,UAAA;EAAY;AAAA;EAAc,UAAA;EAAoB,QAAA;AAAA;;;UCrHjC,kBAAA;EACf,MAAA,EAAQ,MAAA;EACR,OAAA,EAAS,gBAAA;EACT,OAAA,EAAS,gBAAA;EACT,aAAA,EAAe,gBAAA;EACf,aAAA,EAAe,gBAAA;EACf,YAAA,EAAc,gBAAA;EACd,OAAA,EAAS,gBAAA;EACT,YAAA;EACA,UAAA,EAAY,gBAAA;AAAA;;;UCzBG,gBAAA;EACf,SAAA,EAAW,oBAAA;EACX,OAAA,EAAS,gBAAA;AAAA;;;iBCiBa,SAAA,CAAU,OAAA,GAAU,gBAAA,GAAmB,MAAA"}
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { generateShorthand, makeCSSVar, transformCSSValue } from "@terrazzo/token-tools/css";
2
- import wcmatch from "wildcard-match";
3
- import { kebabCase } from "@terrazzo/token-tools";
2
+ import { CachedWildcardMatcher, kebabCase } from "@terrazzo/token-tools";
4
3
 
5
4
  //#region src/lib.ts
6
5
  const PLUGIN_NAME = "@terrazzo/plugin-css";
7
6
  const FORMAT_ID = "css";
7
+ const cachedMatcher = new CachedWildcardMatcher();
8
8
  const FILE_PREFIX = `/* -------------------------------------------
9
9
  * Autogenerated by ⛋ Terrazzo. DO NOT EDIT!
10
10
  * ------------------------------------------- */`;
@@ -136,12 +136,13 @@ function makePrelude(token, prefix, subgroup) {
136
136
  function makeVarValue(token) {
137
137
  return makeCSSVar(token.localID ?? token.token.id, { wrapVar: true });
138
138
  }
139
+ const utilityMatcher = new CachedWildcardMatcher();
139
140
  function generateUtilityCSS(groups, tokens, { logger }) {
140
141
  const root = [];
141
142
  const groupEntries = Object.entries(groups);
142
143
  groupEntries.sort((a, b) => a[0].localeCompare(b[0]));
143
144
  for (const [group, selectors] of groupEntries) {
144
- const selectorMatcher = wcmatch(selectors);
145
+ const selectorMatcher = utilityMatcher.match(selectors);
145
146
  const matchingTokens = tokens.filter((token) => selectorMatcher(token.token.id));
146
147
  if (!matchingTokens.length) {
147
148
  logger.warn({
@@ -277,7 +278,9 @@ function generateUtilityCSS(groups, tokens, { logger }) {
277
278
  //#region src/build.ts
278
279
  const P3_MQ = "@media (color-gamut: p3)";
279
280
  const REC2020_MQ = "@media (color-gamut: rec2020)";
280
- function buildCSS({ logger, getTransforms, exclude, utility, permutations, modeSelectors, baseSelector, baseScheme }) {
281
+ function buildCSS({ logger, getTransforms, include: userInclude, exclude: userExclude, utility, permutations, modeSelectors, baseSelector, baseScheme }) {
282
+ const include = userInclude ? cachedMatcher.tokenIDMatch(userInclude) : () => true;
283
+ const exclude = userExclude ? cachedMatcher.tokenIDMatch(userExclude) : () => false;
281
284
  if (permutations?.length) {
282
285
  let output = "";
283
286
  for (const p of permutations) {
@@ -296,7 +299,13 @@ function buildCSS({ logger, getTransforms, exclude, utility, permutations, modeS
296
299
  p3: [],
297
300
  rec2020: []
298
301
  };
302
+ const pInclude = p.include ? cachedMatcher.tokenIDMatch(p.include) : () => true;
303
+ const pExclude = p.exclude ? cachedMatcher.tokenIDMatch(p.exclude) : () => false;
304
+ const includeToken = (tokenId) => {
305
+ return include(tokenId) && pInclude(tokenId) && !exclude(tokenId) && !pExclude(tokenId);
306
+ };
299
307
  for (const token of tokens) {
308
+ if (!includeToken(token.id)) continue;
300
309
  const localID = makeCSSVar(token.localID ?? token.token.id);
301
310
  const aliasTokens = token.token.aliasedBy?.length ? getTransforms({
302
311
  format: FORMAT_ID,
@@ -326,7 +335,10 @@ function buildCSS({ logger, getTransforms, exclude, utility, permutations, modeS
326
335
  });
327
336
  if (shorthand) addDeclUnique(root, decl(localID, shorthand, token.token.$description));
328
337
  }
329
- for (const alias of aliasTokens) if (alias.localID && typeof alias.value === "string") addDeclUnique(root, decl(alias.localID, alias.value, token.token.$description));
338
+ for (const alias of aliasTokens) if (alias.localID && typeof alias.value === "string") {
339
+ if (!includeToken(alias.id)) continue;
340
+ addDeclUnique(root, decl(alias.localID, alias.value, token.token.$description));
341
+ }
330
342
  }
331
343
  const indentRules = getIndentFromPrepare(p.prepare);
332
344
  if (output) output += "\n";
@@ -339,8 +351,11 @@ function buildCSS({ logger, getTransforms, exclude, utility, permutations, modeS
339
351
  }
340
352
  }
341
353
  if (utility && Object.keys(utility).length) {
342
- if (output) output += "\n\n";
343
- output += generateUtilityCSS(utility, getTransforms({ format: FORMAT_ID }), { logger });
354
+ if (output) output += "\n";
355
+ output += printRules(generateUtilityCSS(utility, getTransforms({
356
+ format: FORMAT_ID,
357
+ input: permutations[0]?.input ?? {}
358
+ }), { logger }));
344
359
  }
345
360
  return output;
346
361
  }
@@ -359,14 +374,12 @@ function buildCSS({ logger, getTransforms, exclude, utility, permutations, modeS
359
374
  const p3Rule = rules[1].children[0];
360
375
  const rec2020Rule = rules[2].children[0];
361
376
  if (baseScheme) rootRule.children.unshift(decl("color-scheme", baseScheme));
362
- const shouldExclude = wcmatch(exclude ?? []);
363
377
  for (const token of rootTokens) {
364
- if (shouldExclude(token.token.id)) continue;
378
+ if (!include(token.token.id) || exclude(token.token.id)) continue;
365
379
  const localID = token.localID ?? token.token.id;
366
380
  const aliasTokens = token.token.aliasedBy?.length ? getTransforms({
367
381
  format: FORMAT_ID,
368
- id: token.token.aliasedBy,
369
- mode: "."
382
+ id: token.token.aliasedBy
370
383
  }) : [];
371
384
  if (token.type === "SINGLE_VALUE") addDeclUnique(rootRule.children, decl(localID, token.value, token.token.$description));
372
385
  else if (token.value.srgb && token.value.p3 && token.value.rec2020) {
@@ -455,7 +468,7 @@ function buildCSS({ logger, getTransforms, exclude, utility, permutations, modeS
455
468
 
456
469
  //#endregion
457
470
  //#region src/transform.ts
458
- function transformCSS({ transform: { context: { logger }, resolver, getTransforms, setTransform, tokens: baseTokens }, options: { permutations, exclude: userExclude, legacyHex, transform: customTransform, variableName } }) {
471
+ function transformCSS({ transform: { context: { logger }, resolver, setTransform, tokens: baseTokens }, options: { permutations, include: userInclude, exclude: userExclude, legacyHex, transform: customTransform, variableName } }) {
459
472
  function transformName(token) {
460
473
  const customName = variableName?.(token);
461
474
  if (customName !== void 0) {
@@ -469,24 +482,26 @@ function transformCSS({ transform: { context: { logger }, resolver, getTransform
469
482
  return makeCSSVar(token.id);
470
483
  }
471
484
  const transformAlias = (token) => `var(${transformName(token)})`;
472
- const exclude = userExclude ? wcmatch(userExclude) : void 0;
485
+ const include = userInclude ? cachedMatcher.tokenIDMatch(userInclude) : () => true;
486
+ const exclude = userExclude ? cachedMatcher.tokenIDMatch(userExclude) : () => false;
473
487
  if (permutations?.length) {
474
488
  for (const p of permutations) {
475
489
  const input = p.input;
476
- const ignore = p.ignore ? wcmatch(p.ignore) : void 0;
490
+ const pInclude = p.include ? cachedMatcher.tokenIDMatch(p.include) : () => true;
491
+ const pExclude = p.exclude ? cachedMatcher.tokenIDMatch(p.exclude) : () => false;
492
+ const includeToken = (tokenId) => {
493
+ return include(tokenId) && pInclude(tokenId) && !exclude(tokenId) && !pExclude(tokenId);
494
+ };
477
495
  try {
478
496
  const tokens = resolver.apply(input);
479
497
  for (const token of Object.values(tokens)) {
480
- if (ignore?.(token.id) || exclude?.(token.id)) continue;
498
+ if (!includeToken(token.id)) continue;
481
499
  const value = customTransform?.(token) ?? transformCSSValue(token, {
482
500
  tokensSet: tokens,
483
501
  transformAlias,
484
502
  color: { legacyHex }
485
503
  });
486
- if (value && isDifferentValue(value, getTransforms({
487
- format: FORMAT_ID,
488
- id: token.id
489
- })[0]?.value)) {
504
+ if (value) {
490
505
  const localID = transformName(token);
491
506
  setTransform(token.id, {
492
507
  format: FORMAT_ID,
@@ -510,7 +525,7 @@ function transformCSS({ transform: { context: { logger }, resolver, getTransform
510
525
  return;
511
526
  }
512
527
  for (const token of Object.values(baseTokens)) {
513
- if (exclude?.(token.id)) continue;
528
+ if (!include(token.id) || exclude(token.id)) continue;
514
529
  for (const mode of Object.keys(token.mode)) {
515
530
  const value = customTransform?.(token, ".") ?? transformCSSValue({
516
531
  ...token,
@@ -533,16 +548,6 @@ function transformCSS({ transform: { context: { logger }, resolver, getTransform
533
548
  }
534
549
  }
535
550
  }
536
- /** Is the transformed value different from the base value? */
537
- function isDifferentValue(value, baseValue) {
538
- if (!value || !baseValue || typeof value !== typeof baseValue) return true;
539
- if (typeof value === "string" && typeof baseValue === "string") return value !== baseValue;
540
- const keysA = Object.keys(value);
541
- const keysB = Object.keys(baseValue);
542
- if (keysA.length !== keysB.length) return true;
543
- if (!keysA.every((k) => keysB.includes(k) && value[k] === baseValue[k])) return true;
544
- return false;
545
- }
546
551
 
547
552
  //#endregion
548
553
  //#region src/index.ts
@@ -573,6 +578,7 @@ function cssPlugin(options) {
573
578
  if (skipBuild === true) return;
574
579
  let contents = `${FILE_PREFIX}\n\n`;
575
580
  contents += buildCSS({
581
+ include: options?.include,
576
582
  exclude: options?.exclude,
577
583
  getTransforms,
578
584
  permutations: options?.permutations,
@@ -588,5 +594,5 @@ function cssPlugin(options) {
588
594
  }
589
595
 
590
596
  //#endregion
591
- export { FILE_PREFIX, FORMAT_ID, PLUGIN_NAME, addDeclUnique, decl, cssPlugin as default, getIndentFromPrepare, hasDecl, printNode, printRules, rule };
597
+ export { FILE_PREFIX, FORMAT_ID, PLUGIN_NAME, cssPlugin as default, printNode, printRules };
592
598
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/lib.ts","../src/utility-css.ts","../src/build.ts","../src/transform.ts","../src/index.ts"],"sourcesContent":["import type { TokenNormalized, TokenTransformed } from '@terrazzo/parser';\n\nexport type UtilityCSSGroup = 'bg' | 'border' | 'font' | 'layout' | 'shadow' | 'text';\n\nexport type UtilityCSSPrefix = 'bg' | 'border' | 'font' | 'gap' | 'm' | 'p' | 'shadow' | 'text';\n\nexport const PLUGIN_NAME = '@terrazzo/plugin-css';\n\nexport const FORMAT_ID = 'css';\n\nexport const FILE_PREFIX = `/* -------------------------------------------\n * Autogenerated by ⛋ Terrazzo. DO NOT EDIT!\n * ------------------------------------------- */`;\n\nexport interface CSSPluginOptions {\n /**\n * Where to output CSS\n * @default \"index.css\"\n */\n filename?: string;\n /** Glob patterns to exclude tokens from output */\n exclude?: string[];\n /**\n * Set the base selector, like \":root\" or \":host\".\n * @deprecated use permutations instead.\n * @default \":root\"\n */\n baseSelector?: string;\n /**\n * Set the color-scheme CSS property for `baseSelector`.\n * @deprecated use permutations instead.\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/color-scheme\n * @example \"light dark\"\n */\n baseScheme?: string;\n /**\n * Build resolver contexts into media queries\n */\n permutations?: Permutation[];\n /**\n * Define mode selectors as media queries or CSS classes\n * @deprecated Migrate to permutations\n */\n modeSelectors?: ModeSelector[];\n /** Control the final CSS variable name */\n variableName?: (token: TokenNormalized) => string;\n /** Override certain token values */\n transform?: (\n token: TokenNormalized,\n /** @deprecated */\n mode?: string,\n ) => TokenTransformed['value'] | undefined | null;\n /** Generate utility CSS from groups */\n utility?: Partial<Record<UtilityCSSGroup, string[]>>;\n /**\n * Output colors as hex-6/hex-8 instead of color() function\n * @default false\n */\n legacyHex?: boolean;\n /**\n * 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).\n * @default false\n */\n skipBuild?: boolean;\n}\n\nexport interface Permutation<T extends Record<string, string> = Record<string, string>> {\n /** Generate the final CSS string, wrapping content in the selector(s) of your choice. */\n prepare(css: string): string;\n /** Input for this permutation. */\n input: T;\n /** Provide token(s) to ignore (Note: ignoring tokens that are used as aliases for other tokens could cause visual bugs in generated CSS) */\n ignore?: string[];\n}\n\nexport interface ModeSelector {\n /** The name of the mode to match */\n mode: string;\n /** Provide token IDs to match. Globs are allowed (e.g: `[\"color.*\", \"shadow.dark\"]`) */\n tokens?: string[];\n /** Provide CSS selectors to generate. (e.g.: `[\"@media (prefers-color-scheme: dark)\", \"[data-color-theme='dark']\"]` ) */\n selectors: string[];\n /** Set the color-scheme CSS property for this mode (e.g.: \"light\", \"dark\", \"light dark\") */\n scheme?: string;\n}\n\n// Simple AST types loosely-inspired by csstree.\nexport interface CSSDeclaration {\n type: 'Declaration';\n property: string;\n value: string;\n comment?: string;\n}\n\nexport interface CSSRule {\n type: 'Rule';\n prelude: string[];\n children: (CSSRule | CSSDeclaration)[];\n}\n\n/**\n * Convert CSSRules into a formatted, indented CSS string.\n * The reason we’re using this homemade version instead of something like css-tree is:\n *\n * 1. css-tree doesn’t support comments :(\n * 2. we are only generating PARTIALS, not full CSS (the user controls the\n * wrapper). So with a proper AST, we’d be hacking it a little anyway because\n * we never really have a true, valid, finalized document.\n * 3. we want @terrazzo/plugin-css to run in the browser AND be lean (i.e. don’t\n * load Prettier or 25MB of wasm).\n * 4. we only have to deal with a small subset of CSS—this doesn’t have to be robust\n * by any means (even future additions won’t push the limits of the spec).\n */\nexport function printRules(\n nodes: (CSSRule | CSSDeclaration)[],\n { indentChar = ' ', indentLv = 0 }: { indentChar?: string; indentLv?: number } = {},\n): string {\n let output = '';\n for (const node of nodes) {\n if (output && node.type === 'Rule') {\n output += '\\n';\n }\n output += printNode(node, { indentChar, indentLv });\n }\n return output.trim();\n}\n\n/** Internal printer for individual nodes */\nexport function printNode(\n node: CSSRule | CSSDeclaration,\n { indentChar, indentLv }: { indentChar: string; indentLv: number },\n): string {\n let output = '';\n\n const indent = indentChar.repeat(indentLv);\n\n if (node.type === 'Declaration') {\n if (node.comment) {\n output += `${indent}/* ${node.comment} */\\n`;\n }\n output += `${indent}${node.property}: ${node.value};\\n`;\n return output;\n }\n\n if (!node.prelude.length || !node.children.length) {\n return output;\n }\n\n // legacy behavior: mediaQueryWithDecls should be removed in 3.0. This\n // was originally introduced in modeSelectors, but it generates unexpected CSS.\n const mediaQueryWithDecls = node.children.some((s) => s.type === 'Declaration')\n ? node.prelude.find((s) => s.startsWith('@'))\n : undefined;\n if (mediaQueryWithDecls) {\n const nonMedia = node.prelude.filter((s) => s !== mediaQueryWithDecls);\n output += `${indent}${mediaQueryWithDecls} {\\n`;\n output += printNode(rule([':root'], node.children), { indentChar, indentLv: indentLv + 1 });\n output += `${indent}}\\n\\n`;\n output += printNode(rule(nonMedia, node.children), { indentChar, indentLv });\n return output;\n }\n\n // Note: nested rules may eventually resolve to no declarations. This prevents that by rendering children first before the wrapper.\n let childOutput = '';\n for (const child of node.children) {\n childOutput += printNode(child, { indentChar, indentLv: indentLv + 1 });\n }\n childOutput = childOutput.trim();\n if (!childOutput) {\n return output;\n }\n output += `${indent}${node.prelude.join(', ')} {\\n`;\n output += `${indentChar.repeat(indentLv + 1)}${childOutput}\\n`;\n output += `${indent}}\\n`;\n return output;\n}\n\n/** Infer indentation preferences from a user-defined wrapping method. */\nexport function getIndentFromPrepare(prepare: (css: string) => string): { indentChar: string; indentLv: number } {\n const str = '//css//'; // this is a string that’s invalid CSS that wouldn’t be in the fn itself\n const output = prepare(str).replace(/\\/\\*.*\\*\\//g, ''); // strip comments because we don’t need them\n let indentChar = ' ';\n let indentLv = 0;\n let lineStartChar = 0;\n for (let i = 0; i < output.length; i++) {\n if (output[i] === '{') {\n lineStartChar = i + 1;\n indentLv++;\n } else if (output[i] === '}') {\n indentLv--;\n } else if (output[i] === '\\n') {\n lineStartChar = i + 1;\n } else if (output[i] === str[0] && output.slice(i).startsWith(str)) {\n indentChar = output.slice(lineStartChar, i);\n indentChar = indentChar.slice(0, Math.floor(indentChar.length / indentLv));\n break;\n }\n }\n return {\n indentChar: indentChar || ' ', // fall back to 2 spaces rather than no indentation\n indentLv,\n };\n}\n\n/** Syntactic sugar over Rule boilerplate */\nexport function rule(prelude: CSSRule['prelude'], children: CSSRule['children'] = []): CSSRule {\n return { type: 'Rule', prelude, children };\n}\n\n/** Syntactic sugar over Declaration boilerplate */\nexport function decl(\n property: CSSDeclaration['property'],\n value: CSSDeclaration['value'],\n comment?: CSSDeclaration['comment'],\n): CSSDeclaration {\n return { type: 'Declaration', property, value, comment };\n}\n\n/** Does a node list contain a root-level declaration with this property? */\nexport function hasDecl(list: (CSSRule | CSSDeclaration)[], property: string): boolean {\n return list.some((d) => d.type === 'Declaration' && d.property === property);\n}\n\n/** Add a declaration only if it’s unique (note: CSS, by design, allows duplication—it’s how fallbacks happen. Only use this if fallbacks aren’t needed. */\nexport function addDeclUnique(list: (CSSRule | CSSDeclaration)[], declaration: CSSDeclaration): void {\n if (!hasDecl(list, declaration.property)) {\n list.push(declaration);\n }\n}\n","import type { Logger, TokenTransformed } from '@terrazzo/parser';\nimport { kebabCase } from '@terrazzo/token-tools';\nimport { makeCSSVar } from '@terrazzo/token-tools/css';\nimport wcmatch from 'wildcard-match';\nimport { type CSSRule, decl, PLUGIN_NAME, rule, type UtilityCSSGroup, type UtilityCSSPrefix } from './lib.js';\n\n// micro-optimization: precompile all RegExs (which can be known) because dynamic compilation is a waste of resources\nconst GROUP_REGEX: Record<UtilityCSSPrefix, RegExp> = {\n bg: /(^bg-|-bg-)/,\n border: /(^border-|-border-)/,\n font: /(^font-|-font-)/,\n gap: /(^gap-|-gap-)/,\n m: /(^margin-|-margin-|)/,\n p: /(^padding-|-padding-|)/,\n shadow: /(^shadow-|-shadow-)/,\n text: /(^text-|-text-)/,\n};\n\n/** Make CSS class name from transformed token */\nfunction makePrelude(token: TokenTransformed, prefix: UtilityCSSPrefix, subgroup?: string): CSSRule['prelude'] {\n return [`.${prefix}${subgroup || ''}-${kebabCase(token.token.id).replace(GROUP_REGEX[prefix], '')}`];\n}\n\nfunction makeVarValue(token: TokenTransformed): string {\n return makeCSSVar(token.localID ?? token.token.id, { wrapVar: true });\n}\n\nexport default function generateUtilityCSS(\n groups: Partial<Record<UtilityCSSGroup, string[]>>,\n tokens: TokenTransformed[],\n { logger }: { logger: Logger },\n): CSSRule[] {\n const root: CSSRule[] = [];\n const groupEntries = Object.entries(groups);\n groupEntries.sort((a, b) => a[0].localeCompare(b[0]));\n\n for (const [group, selectors] of groupEntries) {\n const selectorMatcher = wcmatch(selectors);\n const matchingTokens = tokens.filter((token) => selectorMatcher(token.token.id));\n if (!matchingTokens.length) {\n logger.warn({\n group: 'plugin',\n label: PLUGIN_NAME,\n message: `utility group \"${group}\" matched 0 tokens: ${JSON.stringify(selectors)}`,\n });\n break;\n }\n switch (group) {\n case 'bg': {\n for (const token of matchingTokens) {\n const prelude = makePrelude(token, 'bg');\n switch (token.token.$type) {\n case 'color': {\n root.push(rule(prelude, [decl('background-color', makeVarValue(token))]));\n break;\n }\n case 'gradient': {\n const value = decl(\n 'background-image',\n `linear-gradient(${makeCSSVar(token.localID ?? token.token.id, { wrapVar: true })})`,\n );\n root.push(rule(prelude, [value]));\n }\n }\n }\n break;\n }\n case 'border': {\n // ALL generic properties must come before specific properties\n for (const token of matchingTokens) {\n const property = {\n border: 'border',\n color: 'border-color',\n dimension: 'border-width',\n strokeStyle: 'border-style',\n }[token.token.$type as string];\n if (property) {\n root.push(rule(makePrelude(token, 'border'), [decl(property, makeVarValue(token))]));\n }\n }\n // specific properties\n for (const token of matchingTokens) {\n for (const side of ['top', 'right', 'bottom', 'left']) {\n const property = {\n border: `border-${side}`,\n color: `border-${side}-color`,\n dimension: `border-${side}-width`,\n strokeStyle: `border-${side}-style`,\n }[token.token.$type as string];\n if (property) {\n root.push(rule(makePrelude(token, 'border', `-${side}`), [decl(property, makeVarValue(token))]));\n }\n }\n }\n break;\n }\n case 'font': {\n for (const token of matchingTokens) {\n const prelude = makePrelude(token, 'font');\n if (token.token.$type === 'typography' && token.type === 'MULTI_VALUE') {\n const value = Object.keys(token.value).map((property) =>\n decl(property, makeCSSVar(`${token.localID ?? token.token.id}-${property}`, { wrapVar: true })),\n );\n root.push(rule(prelude, value));\n } else {\n const property = {\n dimension: 'font-size',\n fontFamily: 'font-family',\n fontWeight: 'font-weight',\n }[token.token.$type as string];\n if (property) {\n root.push(rule(prelude, [decl(property, makeVarValue(token))]));\n }\n }\n }\n break;\n }\n case 'layout': {\n const filteredTokens = matchingTokens.filter((t) => t.token.$type === 'dimension'); // only dimension tokens here\n // gap\n // ALL generic properties (gap) must come before specific properties (column-gap)\n for (const token of filteredTokens) {\n root.push(rule(makePrelude(token, 'gap'), [decl('gap', makeVarValue(token))]));\n }\n // specific properties\n for (const token of filteredTokens) {\n root.push(rule(makePrelude(token, 'gap', '-col'), [decl('column-gap', makeVarValue(token))]));\n }\n // specific properties\n for (const token of filteredTokens) {\n root.push(rule(makePrelude(token, 'gap', '-row'), [decl('row-gap', makeVarValue(token))]));\n }\n\n // margin/padding\n for (const prefix of ['m', 'p'] as const) {\n const property = prefix === 'm' ? 'margin' : 'padding';\n // note: ALL generic properties (margin: [value]) MUST come before specific properties (margin-top: [value])\n // this is why we loop through all tokens so many times\n for (const token of filteredTokens) {\n root.push(rule(makePrelude(token, prefix, 'a'), [decl(property, makeVarValue(token))]));\n }\n for (const token of filteredTokens) {\n const value = makeVarValue(token);\n root.push(\n rule(makePrelude(token, prefix, 'x'), [\n decl(`${property}-inline`, value),\n decl(`${property}-left`, value),\n decl(`${property}-right`, value),\n ]),\n rule(makePrelude(token, prefix, 'y'), [\n decl(`${property}-block`, value),\n decl(`${property}-bottom`, value),\n decl(`${property}-top`, value),\n ]),\n );\n }\n for (const side of ['top', 'right', 'bottom', 'left']) {\n for (const token of filteredTokens) {\n root.push(rule(makePrelude(token, prefix, side[0]), [decl(`${property}-${side}`, makeVarValue(token))]));\n }\n }\n for (const token of filteredTokens) {\n const value = makeVarValue(token);\n root.push(\n rule(makePrelude(token, prefix, 'bs'), [decl(`${property}-block-start`, value)]),\n rule(makePrelude(token, prefix, 'be'), [decl(`${property}-block-end`, value)]),\n rule(makePrelude(token, prefix, 'is'), [decl(`${property}-inline-start`, value)]),\n rule(makePrelude(token, prefix, 'ie'), [decl(`${property}-inline-end`, value)]),\n );\n }\n }\n break;\n }\n case 'shadow': {\n for (const token of matchingTokens) {\n if (token.token.$type === 'shadow') {\n root.push(rule(makePrelude(token, 'shadow'), [decl('box-shadow', makeVarValue(token))]));\n }\n }\n break;\n }\n case 'text': {\n for (const token of matchingTokens) {\n const prelude = makePrelude(token, 'text');\n const value = makeVarValue(token);\n switch (token.token.$type) {\n case 'color': {\n root.push(rule(prelude, [decl('color', value)]));\n break;\n }\n case 'gradient': {\n root.push(\n rule(prelude, [\n decl('background', `-webkit-linear-gradient(${value})`),\n decl('-webkit-background-clip', 'text'),\n decl('-webkit-text-fill-color', 'transparent'),\n ]),\n );\n break;\n }\n }\n }\n break;\n }\n default: {\n logger.warn({ group: 'plugin', label: PLUGIN_NAME, message: `unknown utility CSS group \"${group}\", ignoring` });\n break;\n }\n }\n }\n\n return root;\n}\n","import type { BuildHookOptions, Logger } from '@terrazzo/parser';\nimport { generateShorthand, makeCSSVar } from '@terrazzo/token-tools/css';\nimport wcmatch from 'wildcard-match';\nimport {\n addDeclUnique,\n type CSSDeclaration,\n type CSSPluginOptions,\n type CSSRule,\n decl,\n FORMAT_ID,\n getIndentFromPrepare,\n PLUGIN_NAME,\n printRules,\n rule,\n} from './lib.js';\nimport generateUtilityCSS from './utility-css.js';\n\nconst P3_MQ = '@media (color-gamut: p3)';\nconst REC2020_MQ = '@media (color-gamut: rec2020)';\n\nexport interface BuildFormatOptions {\n logger: Logger;\n exclude: CSSPluginOptions['exclude'];\n getTransforms: BuildHookOptions['getTransforms'];\n modeSelectors: CSSPluginOptions['modeSelectors'];\n permutations: CSSPluginOptions['permutations'];\n utility: CSSPluginOptions['utility'];\n baseSelector: string;\n baseScheme: CSSPluginOptions['baseScheme'];\n}\n\nexport default function buildCSS({\n logger,\n getTransforms,\n exclude,\n utility,\n permutations,\n modeSelectors,\n baseSelector,\n baseScheme,\n}: BuildFormatOptions): string {\n if (permutations?.length) {\n let output = '';\n\n for (const p of permutations) {\n if (typeof p.prepare !== 'function') {\n logger.error({ group: 'plugin', label: PLUGIN_NAME, message: 'prepare(css) must be a function!' });\n }\n\n const tokens = getTransforms({ format: FORMAT_ID, input: p.input });\n if (!tokens.length) {\n continue;\n }\n\n const root: (CSSRule | CSSDeclaration)[] = [];\n const hdrColors = {\n p3: [] as CSSDeclaration[],\n rec2020: [] as CSSDeclaration[],\n };\n\n for (const token of tokens) {\n const localID = makeCSSVar(token.localID ?? token.token.id);\n const aliasTokens = token.token.aliasedBy?.length\n ? getTransforms({ format: FORMAT_ID, id: token.token.aliasedBy, input: p.input })\n : [];\n\n // single-value token\n if (token.type === 'SINGLE_VALUE') {\n addDeclUnique(root, decl(localID, token.value, token.token.$description));\n }\n\n // multi-value token (wide gamut color)\n else if (token.value.srgb && token.value.p3 && token.value.rec2020) {\n addDeclUnique(root, decl(localID, token.value.srgb!, token.token.$description));\n\n if (token.value.p3 !== token.value.srgb) {\n addDeclUnique(hdrColors.p3, decl(localID, token.value.p3!, token.token.$description));\n addDeclUnique(hdrColors.rec2020, decl(localID, token.value.rec2020!, token.token.$description));\n\n // handle aliases within color gamut media queries\n for (const alias of aliasTokens) {\n if (alias.localID && typeof alias.value === 'string') {\n const aliasID = makeCSSVar(alias.localID);\n addDeclUnique(hdrColors.p3, decl(aliasID, alias.value, alias.token.$description));\n addDeclUnique(hdrColors.rec2020, decl(aliasID, alias.value, alias.token.$description));\n }\n }\n }\n }\n\n // multi-value token\n else {\n for (const [name, subValue] of Object.entries(token.value)) {\n const subValueID = `${localID}-${name}`;\n addDeclUnique(root, decl(subValueID, subValue, token.token.$description));\n }\n // Note: always generate shorthand AFTER other declarations\n const shorthand = generateShorthand({ token: { ...token.token, $value: token.value as any }, localID });\n if (shorthand) {\n addDeclUnique(root, decl(localID, shorthand, token.token.$description));\n }\n }\n\n // redeclare aliases so they have the correct scope\n for (const alias of aliasTokens) {\n if (alias.localID && typeof alias.value === 'string') {\n addDeclUnique(root, decl(alias.localID, alias.value, token.token.$description));\n }\n }\n }\n\n const indentRules = getIndentFromPrepare(p.prepare);\n if (output) {\n output += '\\n';\n }\n output += `${p.prepare(printRules(root, indentRules))}\\n`;\n\n // declare P3 and Rec2020 gamuts, if needed\n for (const gamut of ['p3', 'rec2020'] as const) {\n if (hdrColors[gamut].length) {\n output += `\\n@media (color-gamut: ${gamut}) {\\n`;\n output += indentRules.indentChar;\n output += p\n .prepare(printRules(hdrColors[gamut], indentRules))\n .replace(/\\n(?!\\n)/g, `\\n${indentRules.indentChar}`); // indent every line an extra level\n output += '\\n}\\n';\n }\n }\n }\n\n // add utility CSS\n if (utility && Object.keys(utility).length) {\n if (output) {\n output += '\\n\\n';\n }\n output += generateUtilityCSS(utility, getTransforms({ format: FORMAT_ID }), { logger });\n }\n\n return output;\n }\n\n // legacy plugin (will be deprecated in 3.0)\n let output = '';\n const rootTokens = getTransforms({ format: FORMAT_ID, mode: '.' });\n if (rootTokens.length) {\n const rules: CSSRule[] = [\n rule([baseSelector], []),\n rule([P3_MQ], [rule([baseSelector])]),\n rule([REC2020_MQ], [rule([baseSelector])]),\n ];\n\n const rootRule = rules[0]!;\n const p3Rule = rules[1]!.children[0] as CSSRule;\n const rec2020Rule = rules[2]!.children[0] as CSSRule;\n\n // add base color-scheme declaration first if configured\n // (must be before other properties to ensure it appears first in output)\n if (baseScheme) {\n rootRule.children.unshift(decl('color-scheme', baseScheme));\n }\n\n const shouldExclude = wcmatch(exclude ?? []);\n for (const token of rootTokens) {\n // handle exclude (if any)\n if (shouldExclude(token.token.id)) {\n continue;\n }\n\n const localID = token.localID ?? token.token.id;\n const aliasTokens = token.token.aliasedBy?.length\n ? getTransforms({ format: FORMAT_ID, id: token.token.aliasedBy, mode: '.' })\n : [];\n\n // single-value token\n if (token.type === 'SINGLE_VALUE') {\n addDeclUnique(rootRule.children, decl(localID, token.value, token.token.$description));\n }\n\n // multi-value token (wide gamut color)\n else if (token.value.srgb && token.value.p3 && token.value.rec2020) {\n addDeclUnique(rootRule.children, decl(localID, token.value.srgb!, token.token.$description));\n\n if (token.value.p3 !== token.value.srgb) {\n addDeclUnique(p3Rule.children, decl(localID, token.value.p3!, token.token.$description));\n addDeclUnique(rec2020Rule.children, decl(localID, token.value.rec2020!, token.token.$description));\n // handle aliases within color gamut media queries\n for (const alias of aliasTokens) {\n if (alias.localID && typeof alias.value === 'string') {\n addDeclUnique(p3Rule.children, decl(alias.localID, alias.value, token.token.$description));\n addDeclUnique(rec2020Rule.children, decl(alias.localID, alias.value, token.token.$description));\n }\n }\n }\n }\n\n // multi-value token\n else if (token.type === 'MULTI_VALUE') {\n for (const [name, value] of Object.entries(token.value)) {\n const property = name === '.' ? localID : [localID, name].join('-');\n addDeclUnique(rootRule.children, decl(property, value, token.token.$description));\n }\n // Note: always place shorthand after other values\n const shorthand = generateShorthand({ token: { ...token.token, $value: token.value as any }, localID });\n if (shorthand) {\n addDeclUnique(rootRule.children, decl(token.localID ?? token.token.id, shorthand, token.token.$description));\n }\n }\n }\n\n output += printRules(rules);\n }\n\n // legacy modeSelectors\n // Delete this behavior in 3.0.\n // This code is intentionally left-alone as a separate code path so it behaves as it did with 0.x.\n for (const selector of modeSelectors ?? []) {\n const selectorTokens = getTransforms({ format: FORMAT_ID, id: selector.tokens, mode: selector.mode });\n if (!selectorTokens.length) {\n continue;\n }\n\n const modeRule: CSSRule = rule(selector.selectors);\n\n // add color-scheme declaration first if configured for this mode\n // (must be before other properties to ensure it appears first in output)\n if (selector.scheme) {\n modeRule.children.unshift(decl('color-scheme', selector.scheme));\n }\n const hdrColors = {\n p3: [] as CSSDeclaration[],\n rec2020: [] as CSSDeclaration[],\n };\n for (const token of selectorTokens) {\n const localID = token.localID ?? token.token.id;\n const aliasTokens = token.token.aliasedBy?.length\n ? getTransforms({ format: FORMAT_ID, id: token.token.aliasedBy })\n : [];\n\n // single-value token\n if (token.type === 'SINGLE_VALUE') {\n addDeclUnique(modeRule.children, decl(localID, token.value, token.token.$description));\n }\n\n // multi-value token (wide gamut color)\n else if (token.value.srgb && token.value.p3 && token.value.rec2020) {\n addDeclUnique(modeRule.children, decl(localID, token.value.srgb!, token.token.$description));\n if (token.value.p3 !== token.value.srgb) {\n addDeclUnique(hdrColors.p3, decl(localID, token.value.p3!, token.token.$description));\n addDeclUnique(hdrColors.rec2020, decl(localID, token.value.rec2020!, token.token.$description));\n\n // handle aliases within color gamut media queries\n for (const alias of aliasTokens) {\n if (alias.localID && typeof alias.value === 'string') {\n for (const gamut of ['p3', 'rec2020'] as const) {\n addDeclUnique(hdrColors[gamut], decl(alias.localID, alias.value, token.token.$description));\n }\n }\n }\n }\n }\n\n // multi-value token\n else {\n for (const [name, subValue] of Object.entries(token.value)) {\n addDeclUnique(modeRule.children, decl(`${localID}-${name}`, subValue, token.token.$description));\n }\n // Note: always generate shorthand after other declarations\n const shorthand = generateShorthand({ token: { ...token.token, $value: token.value as any }, localID });\n if (shorthand) {\n addDeclUnique(modeRule.children, decl(localID, shorthand, token.token.$description));\n }\n }\n\n // redeclare aliases so they have the correct scope\n for (const alias of aliasTokens) {\n if (alias.localID && typeof alias.value === 'string') {\n addDeclUnique(modeRule.children, decl(alias.localID, alias.value, token.token.$description));\n }\n }\n }\n\n if (output) {\n output += '\\n\\n';\n }\n output += printRules([\n modeRule,\n rule([P3_MQ], [rule(selector.selectors, hdrColors.p3)]),\n rule([REC2020_MQ], [rule(selector.selectors, hdrColors.rec2020)]),\n ]);\n }\n\n // add utility CSS\n if (utility && Object.keys(utility).length) {\n if (output) {\n output += '\\n\\n';\n }\n output += printRules(generateUtilityCSS(utility, getTransforms({ format: FORMAT_ID, mode: '.' }), { logger }));\n }\n\n return output;\n}\n","import type { TokenNormalized, TokenTransformed, TransformHookOptions } from '@terrazzo/parser';\nimport { makeCSSVar, transformCSSValue } from '@terrazzo/token-tools/css';\nimport wcmatch from 'wildcard-match';\nimport { type CSSPluginOptions, FORMAT_ID, PLUGIN_NAME } from './lib.js';\n\nexport interface TransformOptions {\n transform: TransformHookOptions;\n options: CSSPluginOptions;\n}\n\nexport default function transformCSS({\n transform: {\n context: { logger },\n resolver,\n getTransforms,\n setTransform,\n tokens: baseTokens,\n },\n options: { permutations, exclude: userExclude, legacyHex, transform: customTransform, variableName },\n}: TransformOptions) {\n function transformName(token: TokenNormalized) {\n const customName = variableName?.(token);\n if (customName !== undefined) {\n if (typeof customName !== 'string') {\n logger.error({\n group: 'plugin',\n label: PLUGIN_NAME,\n message: `variableName() must return a string; received ${customName}`,\n });\n }\n return customName;\n }\n return makeCSSVar(token.id);\n }\n const transformAlias = (token: TokenNormalized) => `var(${transformName(token)})`;\n\n const exclude = userExclude ? wcmatch(userExclude) : undefined;\n\n // permutations\n if (permutations?.length) {\n for (const p of permutations) {\n const input = p.input;\n const ignore = p.ignore ? wcmatch(p.ignore) : undefined;\n // Note: if we throw an error here without specifying the input, a user may\n // find it impossible to debug the issue\n try {\n const tokens = resolver.apply(input);\n for (const token of Object.values(tokens)) {\n if (ignore?.(token.id) || exclude?.(token.id)) {\n continue;\n }\n const value =\n customTransform?.(token) ??\n transformCSSValue(token, { tokensSet: tokens, transformAlias, color: { legacyHex } });\n // Don’t duplicate values when unnecessary\n if (value && isDifferentValue(value, getTransforms({ format: FORMAT_ID, id: token.id })[0]?.value)) {\n const localID = transformName(token);\n setTransform(token.id, {\n format: FORMAT_ID,\n value,\n localID,\n input,\n meta: { 'token-listing': { name: localID } },\n });\n }\n }\n } catch (err) {\n logger.error({\n group: 'plugin',\n label: PLUGIN_NAME,\n message: `There was an error trying to apply input ${resolver.getPermutationID(input)}.`,\n continueOnError: true, // throw below\n });\n throw err; // note: this is most likely a nicely-formatted message from another logger instance; just pass it through\n }\n }\n\n return;\n }\n\n // modes (legacy)\n for (const token of Object.values(baseTokens)) {\n if (exclude?.(token.id)) {\n continue;\n }\n for (const mode of Object.keys(token.mode)) {\n const value =\n customTransform?.(token, '.') ??\n transformCSSValue(\n { ...token, ...(token.mode[mode] as any) },\n { tokensSet: baseTokens, transformAlias, color: { legacyHex } },\n );\n if (value) {\n const localID = transformName(token);\n setTransform(token.id, {\n format: FORMAT_ID,\n localID,\n value,\n mode,\n meta: { 'token-listing': { name: localID } },\n });\n }\n }\n }\n}\n\n/** Is the transformed value different from the base value? */\nfunction isDifferentValue(\n value: TokenTransformed['value'] | undefined,\n baseValue: TokenTransformed['value'] | undefined,\n): boolean {\n if (!value || !baseValue || typeof value !== typeof baseValue) {\n return true;\n }\n if (typeof value === 'string' && typeof baseValue === 'string') {\n return value !== baseValue;\n }\n const keysA = Object.keys(value);\n const keysB = Object.keys(baseValue);\n if (keysA.length !== keysB.length) {\n return true;\n }\n if (\n !keysA.every(\n (k) => keysB.includes(k) && (value as Record<string, string>)[k] === (baseValue as Record<string, string>)[k],\n )\n ) {\n return true;\n }\n return false;\n}\n","import type { Plugin } from '@terrazzo/parser';\nimport buildCSS from './build.js';\nimport { type CSSPluginOptions, FILE_PREFIX, FORMAT_ID, PLUGIN_NAME } from './lib.js';\nimport transformCSS from './transform.js';\n\nexport * from './build.js';\nexport * from './lib.js';\nexport * from './transform.js';\nexport * from './utility-css.js';\n\nexport default function cssPlugin(options?: CSSPluginOptions): Plugin {\n const { utility, skipBuild, baseScheme } = options ?? {};\n\n const filename = options?.filename ?? (options as any)?.fileName ?? 'index.css';\n const baseSelector = options?.baseSelector ?? ':root';\n\n return {\n name: PLUGIN_NAME,\n config(_config, context) {\n if (options?.permutations && (options?.modeSelectors || options?.baseSelector || options?.baseScheme)) {\n context.logger.error({\n group: 'plugin',\n label: PLUGIN_NAME,\n message: 'Permutations option is incompatible with modeSelectors, baseSelector, and baseScheme.',\n });\n }\n },\n async transform(transformOptions) {\n // skip work if another .css plugin has already run\n const cssTokens = transformOptions.getTransforms({ format: FORMAT_ID, id: '*' });\n if (cssTokens.length) {\n return;\n }\n transformCSS({ transform: transformOptions, options: options ?? {} });\n },\n async build({ getTransforms, outputFile, context }) {\n if (skipBuild === true) {\n return;\n }\n\n let contents = `${FILE_PREFIX}\\n\\n`;\n contents += buildCSS({\n exclude: options?.exclude,\n getTransforms,\n permutations: options?.permutations,\n modeSelectors: options?.modeSelectors,\n utility,\n baseSelector,\n baseScheme,\n logger: context.logger,\n });\n outputFile(filename, contents.replace(/\\n*$/, '\\n'));\n },\n };\n}\n"],"mappings":";;;;;AAMA,MAAa,cAAc;AAE3B,MAAa,YAAY;AAEzB,MAAa,cAAc;;;;;;;;;;;;;;;;AAuG3B,SAAgB,WACd,OACA,EAAE,aAAa,MAAM,WAAW,MAAkD,EAAE,EAC5E;CACR,IAAI,SAAS;AACb,MAAK,MAAM,QAAQ,OAAO;AACxB,MAAI,UAAU,KAAK,SAAS,OAC1B,WAAU;AAEZ,YAAU,UAAU,MAAM;GAAE;GAAY;GAAU,CAAC;;AAErD,QAAO,OAAO,MAAM;;;AAItB,SAAgB,UACd,MACA,EAAE,YAAY,YACN;CACR,IAAI,SAAS;CAEb,MAAM,SAAS,WAAW,OAAO,SAAS;AAE1C,KAAI,KAAK,SAAS,eAAe;AAC/B,MAAI,KAAK,QACP,WAAU,GAAG,OAAO,KAAK,KAAK,QAAQ;AAExC,YAAU,GAAG,SAAS,KAAK,SAAS,IAAI,KAAK,MAAM;AACnD,SAAO;;AAGT,KAAI,CAAC,KAAK,QAAQ,UAAU,CAAC,KAAK,SAAS,OACzC,QAAO;CAKT,MAAM,sBAAsB,KAAK,SAAS,MAAM,MAAM,EAAE,SAAS,cAAc,GAC3E,KAAK,QAAQ,MAAM,MAAM,EAAE,WAAW,IAAI,CAAC,GAC3C;AACJ,KAAI,qBAAqB;EACvB,MAAM,WAAW,KAAK,QAAQ,QAAQ,MAAM,MAAM,oBAAoB;AACtE,YAAU,GAAG,SAAS,oBAAoB;AAC1C,YAAU,UAAU,KAAK,CAAC,QAAQ,E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W,EAAE;CAExD,MAAM,WAAW,SAAS,YAAa,SAAiB,YAAY;CACpE,MAAM,eAAe,SAAS,gBAAgB;AAE9C,QAAO;EACL,MAAM;EACN,OAAO,SAAS,SAAS;AACvB,OAAI,SAAS,iBAAiB,SAAS,iBAAiB,SAAS,gBAAgB,SAAS,YACxF,SAAQ,OAAO,MAAM;IACnB,OAAO;IACP,OAAO;IACP,SAAS;IACV,CAAC;;EAGN,MAAM,UAAU,kBAAkB;AAGhC,OADkB,iBAAiB,cAAc;IAAE,QAAQ;IAAW,IAAI;IAAK,CAAC,CAClE,OACZ;AAEF,gBAAa;IAAE,WAAW;IAAkB,SAAS,WAAW,EAAE;IAAE,CAAC;;EAEvE,MAAM,MAAM,EAAE,eAAe,YAAY,WAAW;AAClD,OAAI,cAAc,KAChB;GAGF,IAAI,WAAW,GAAG,YAAY;AAC9B,eAAY,SAAS;IACnB,SAAS,SAAS;IAClB;IACA,cAAc,SAAS;IACvB,eAAe,SAAS;IACxB;IACA;IACA;IACA,QAAQ,QAAQ;IACjB,CAAC;AACF,cAAW,UAAU,SAAS,QAAQ,QAAQ,KAAK,CAAC;;EAEvD"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/lib.ts","../src/utility-css.ts","../src/build.ts","../src/transform.ts","../src/index.ts"],"sourcesContent":["import type { TokenNormalized, TokenTransformed } from '@terrazzo/parser';\nimport { CachedWildcardMatcher } from '@terrazzo/token-tools';\n\nexport type UtilityCSSGroup = 'bg' | 'border' | 'font' | 'layout' | 'shadow' | 'text';\n\nexport type UtilityCSSPrefix = 'bg' | 'border' | 'font' | 'gap' | 'm' | 'p' | 'shadow' | 'text';\n\nexport const PLUGIN_NAME = '@terrazzo/plugin-css';\n\nexport const FORMAT_ID = 'css';\n\nexport const cachedMatcher = new CachedWildcardMatcher();\n\nexport const FILE_PREFIX = `/* -------------------------------------------\n * Autogenerated by ⛋ Terrazzo. DO NOT EDIT!\n * ------------------------------------------- */`;\n\nexport interface CSSPluginOptions {\n /**\n * Where to output CSS\n * @default \"index.css\"\n */\n filename?: string;\n /** Glob patterns to filter tokens in output */\n include?: string[];\n /** Glob patterns to exclude tokens from output */\n exclude?: string[];\n /**\n * Set the base selector, like \":root\" or \":host\".\n * @deprecated use permutations instead.\n * @default \":root\"\n */\n baseSelector?: string;\n /**\n * Set the color-scheme CSS property for `baseSelector`.\n * @deprecated use permutations instead.\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/color-scheme\n * @example \"light dark\"\n */\n baseScheme?: string;\n /**\n * Build resolver contexts into media queries\n */\n permutations?: Permutation[];\n /**\n * Define mode selectors as media queries or CSS classes\n * @deprecated Migrate to permutations\n */\n modeSelectors?: ModeSelector[];\n /** Control the final CSS variable name */\n variableName?: (token: TokenNormalized) => string;\n /** Override certain token values */\n transform?: (\n token: TokenNormalized,\n /** @deprecated */\n mode?: string,\n ) => TokenTransformed['value'] | undefined | null;\n /** Generate utility CSS from groups */\n utility?: Partial<Record<UtilityCSSGroup, string[]>>;\n /**\n * Output colors as hex-6/hex-8 instead of color() function\n * @default false\n */\n legacyHex?: boolean;\n /**\n * 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).\n * @default false\n */\n skipBuild?: boolean;\n}\n\nexport interface Permutation<T extends Record<string, string> = Record<string, string>> {\n /** Generate the final CSS string, wrapping content in the selector(s) of your choice. */\n prepare(css: string): string;\n /** Input for this permutation. */\n input: T;\n /** Provide token(s) to include (Note: not including tokens that are used as aliases for other tokens could cause visual bugs in generated CSS) */\n include?: string[];\n /** Provide token(s) to exclude (Note: excluding tokens that are used as aliases for other tokens could cause visual bugs in generated CSS) */\n exclude?: string[];\n}\n\nexport interface ModeSelector {\n /** The name of the mode to match */\n mode: string;\n /** Provide token IDs to match. Globs are allowed (e.g: `[\"color.*\", \"shadow.dark\"]`) */\n tokens?: string[];\n /** Provide CSS selectors to generate. (e.g.: `[\"@media (prefers-color-scheme: dark)\", \"[data-color-theme='dark']\"]` ) */\n selectors: string[];\n /** Set the color-scheme CSS property for this mode (e.g.: \"light\", \"dark\", \"light dark\") */\n scheme?: string;\n}\n\n// Simple AST types loosely-inspired by csstree.\nexport interface CSSDeclaration {\n type: 'Declaration';\n property: string;\n value: string;\n comment?: string;\n}\n\nexport interface CSSRule {\n type: 'Rule';\n prelude: string[];\n children: (CSSRule | CSSDeclaration)[];\n}\n\n/**\n * Convert CSSRules into a formatted, indented CSS string.\n * The reason we’re using this homemade version instead of something like css-tree is:\n *\n * 1. css-tree doesn’t support comments :(\n * 2. we are only generating PARTIALS, not full CSS (the user controls the\n * wrapper). So with a proper AST, we’d be hacking it a little anyway because\n * we never really have a true, valid, finalized document.\n * 3. we want @terrazzo/plugin-css to run in the browser AND be lean (i.e. don’t\n * load Prettier or 25MB of wasm).\n * 4. we only have to deal with a small subset of CSS—this doesn’t have to be robust\n * by any means (even future additions won’t push the limits of the spec).\n */\nexport function printRules(\n nodes: (CSSRule | CSSDeclaration)[],\n { indentChar = ' ', indentLv = 0 }: { indentChar?: string; indentLv?: number } = {},\n): string {\n let output = '';\n for (const node of nodes) {\n if (output && node.type === 'Rule') {\n output += '\\n';\n }\n output += printNode(node, { indentChar, indentLv });\n }\n return output.trim();\n}\n\n/** Internal printer for individual nodes */\nexport function printNode(\n node: CSSRule | CSSDeclaration,\n { indentChar, indentLv }: { indentChar: string; indentLv: number },\n): string {\n let output = '';\n\n const indent = indentChar.repeat(indentLv);\n\n if (node.type === 'Declaration') {\n if (node.comment) {\n output += `${indent}/* ${node.comment} */\\n`;\n }\n output += `${indent}${node.property}: ${node.value};\\n`;\n return output;\n }\n\n if (!node.prelude.length || !node.children.length) {\n return output;\n }\n\n // legacy behavior: mediaQueryWithDecls should be removed in 3.0. This\n // was originally introduced in modeSelectors, but it generates unexpected CSS.\n const mediaQueryWithDecls = node.children.some((s) => s.type === 'Declaration')\n ? node.prelude.find((s) => s.startsWith('@'))\n : undefined;\n if (mediaQueryWithDecls) {\n const nonMedia = node.prelude.filter((s) => s !== mediaQueryWithDecls);\n output += `${indent}${mediaQueryWithDecls} {\\n`;\n output += printNode(rule([':root'], node.children), { indentChar, indentLv: indentLv + 1 });\n output += `${indent}}\\n\\n`;\n output += printNode(rule(nonMedia, node.children), { indentChar, indentLv });\n return output;\n }\n\n // Note: nested rules may eventually resolve to no declarations. This prevents that by rendering children first before the wrapper.\n let childOutput = '';\n for (const child of node.children) {\n childOutput += printNode(child, { indentChar, indentLv: indentLv + 1 });\n }\n childOutput = childOutput.trim();\n if (!childOutput) {\n return output;\n }\n output += `${indent}${node.prelude.join(', ')} {\\n`;\n output += `${indentChar.repeat(indentLv + 1)}${childOutput}\\n`;\n output += `${indent}}\\n`;\n return output;\n}\n\n/** Infer indentation preferences from a user-defined wrapping method. */\nexport function getIndentFromPrepare(prepare: (css: string) => string): { indentChar: string; indentLv: number } {\n const str = '//css//'; // this is a string that’s invalid CSS that wouldn’t be in the fn itself\n const output = prepare(str).replace(/\\/\\*.*\\*\\//g, ''); // strip comments because we don’t need them\n let indentChar = ' ';\n let indentLv = 0;\n let lineStartChar = 0;\n for (let i = 0; i < output.length; i++) {\n if (output[i] === '{') {\n lineStartChar = i + 1;\n indentLv++;\n } else if (output[i] === '}') {\n indentLv--;\n } else if (output[i] === '\\n') {\n lineStartChar = i + 1;\n } else if (output[i] === str[0] && output.slice(i).startsWith(str)) {\n indentChar = output.slice(lineStartChar, i);\n indentChar = indentChar.slice(0, Math.floor(indentChar.length / indentLv));\n break;\n }\n }\n return {\n indentChar: indentChar || ' ', // fall back to 2 spaces rather than no indentation\n indentLv,\n };\n}\n\n/** Syntactic sugar over Rule boilerplate */\nexport function rule(prelude: CSSRule['prelude'], children: CSSRule['children'] = []): CSSRule {\n return { type: 'Rule', prelude, children };\n}\n\n/** Syntactic sugar over Declaration boilerplate */\nexport function decl(\n property: CSSDeclaration['property'],\n value: CSSDeclaration['value'],\n comment?: CSSDeclaration['comment'],\n): CSSDeclaration {\n return { type: 'Declaration', property, value, comment };\n}\n\n/** Does a node list contain a root-level declaration with this property? */\nexport function hasDecl(list: (CSSRule | CSSDeclaration)[], property: string): boolean {\n return list.some((d) => d.type === 'Declaration' && d.property === property);\n}\n\n/** Add a declaration only if it’s unique (note: CSS, by design, allows duplication—it’s how fallbacks happen. Only use this if fallbacks aren’t needed. */\nexport function addDeclUnique(list: (CSSRule | CSSDeclaration)[], declaration: CSSDeclaration): void {\n if (!hasDecl(list, declaration.property)) {\n list.push(declaration);\n }\n}\n","import type { Logger, TokenTransformed } from '@terrazzo/parser';\nimport { CachedWildcardMatcher, kebabCase } from '@terrazzo/token-tools';\nimport { makeCSSVar } from '@terrazzo/token-tools/css';\nimport { type CSSRule, decl, PLUGIN_NAME, rule, type UtilityCSSGroup, type UtilityCSSPrefix } from './lib.js';\n\n// micro-optimization: precompile all RegExs (which can be known) because dynamic compilation is a waste of resources\nconst GROUP_REGEX: Record<UtilityCSSPrefix, RegExp> = {\n bg: /(^bg-|-bg-)/,\n border: /(^border-|-border-)/,\n font: /(^font-|-font-)/,\n gap: /(^gap-|-gap-)/,\n m: /(^margin-|-margin-|)/,\n p: /(^padding-|-padding-|)/,\n shadow: /(^shadow-|-shadow-)/,\n text: /(^text-|-text-)/,\n};\n\n/** Make CSS class name from transformed token */\nfunction makePrelude(token: TokenTransformed, prefix: UtilityCSSPrefix, subgroup?: string): CSSRule['prelude'] {\n return [`.${prefix}${subgroup || ''}-${kebabCase(token.token.id).replace(GROUP_REGEX[prefix], '')}`];\n}\n\nfunction makeVarValue(token: TokenTransformed): string {\n return makeCSSVar(token.localID ?? token.token.id, { wrapVar: true });\n}\n\nconst utilityMatcher = new CachedWildcardMatcher();\n\nexport default function generateUtilityCSS(\n groups: Partial<Record<UtilityCSSGroup, string[]>>,\n tokens: TokenTransformed[],\n { logger }: { logger: Logger },\n): CSSRule[] {\n const root: CSSRule[] = [];\n const groupEntries = Object.entries(groups);\n groupEntries.sort((a, b) => a[0].localeCompare(b[0]));\n\n for (const [group, selectors] of groupEntries) {\n const selectorMatcher = utilityMatcher.match(selectors);\n const matchingTokens = tokens.filter((token) => selectorMatcher(token.token.id));\n if (!matchingTokens.length) {\n logger.warn({\n group: 'plugin',\n label: PLUGIN_NAME,\n message: `utility group \"${group}\" matched 0 tokens: ${JSON.stringify(selectors)}`,\n });\n break;\n }\n switch (group) {\n case 'bg': {\n for (const token of matchingTokens) {\n const prelude = makePrelude(token, 'bg');\n switch (token.token.$type) {\n case 'color': {\n root.push(rule(prelude, [decl('background-color', makeVarValue(token))]));\n break;\n }\n case 'gradient': {\n const value = decl(\n 'background-image',\n `linear-gradient(${makeCSSVar(token.localID ?? token.token.id, { wrapVar: true })})`,\n );\n root.push(rule(prelude, [value]));\n }\n }\n }\n break;\n }\n case 'border': {\n // ALL generic properties must come before specific properties\n for (const token of matchingTokens) {\n const property = {\n border: 'border',\n color: 'border-color',\n dimension: 'border-width',\n strokeStyle: 'border-style',\n }[token.token.$type as string];\n if (property) {\n root.push(rule(makePrelude(token, 'border'), [decl(property, makeVarValue(token))]));\n }\n }\n // specific properties\n for (const token of matchingTokens) {\n for (const side of ['top', 'right', 'bottom', 'left']) {\n const property = {\n border: `border-${side}`,\n color: `border-${side}-color`,\n dimension: `border-${side}-width`,\n strokeStyle: `border-${side}-style`,\n }[token.token.$type as string];\n if (property) {\n root.push(rule(makePrelude(token, 'border', `-${side}`), [decl(property, makeVarValue(token))]));\n }\n }\n }\n break;\n }\n case 'font': {\n for (const token of matchingTokens) {\n const prelude = makePrelude(token, 'font');\n if (token.token.$type === 'typography' && token.type === 'MULTI_VALUE') {\n const value = Object.keys(token.value).map((property) =>\n decl(property, makeCSSVar(`${token.localID ?? token.token.id}-${property}`, { wrapVar: true })),\n );\n root.push(rule(prelude, value));\n } else {\n const property = {\n dimension: 'font-size',\n fontFamily: 'font-family',\n fontWeight: 'font-weight',\n }[token.token.$type as string];\n if (property) {\n root.push(rule(prelude, [decl(property, makeVarValue(token))]));\n }\n }\n }\n break;\n }\n case 'layout': {\n const filteredTokens = matchingTokens.filter((t) => t.token.$type === 'dimension'); // only dimension tokens here\n // gap\n // ALL generic properties (gap) must come before specific properties (column-gap)\n for (const token of filteredTokens) {\n root.push(rule(makePrelude(token, 'gap'), [decl('gap', makeVarValue(token))]));\n }\n // specific properties\n for (const token of filteredTokens) {\n root.push(rule(makePrelude(token, 'gap', '-col'), [decl('column-gap', makeVarValue(token))]));\n }\n // specific properties\n for (const token of filteredTokens) {\n root.push(rule(makePrelude(token, 'gap', '-row'), [decl('row-gap', makeVarValue(token))]));\n }\n\n // margin/padding\n for (const prefix of ['m', 'p'] as const) {\n const property = prefix === 'm' ? 'margin' : 'padding';\n // note: ALL generic properties (margin: [value]) MUST come before specific properties (margin-top: [value])\n // this is why we loop through all tokens so many times\n for (const token of filteredTokens) {\n root.push(rule(makePrelude(token, prefix, 'a'), [decl(property, makeVarValue(token))]));\n }\n for (const token of filteredTokens) {\n const value = makeVarValue(token);\n root.push(\n rule(makePrelude(token, prefix, 'x'), [\n decl(`${property}-inline`, value),\n decl(`${property}-left`, value),\n decl(`${property}-right`, value),\n ]),\n rule(makePrelude(token, prefix, 'y'), [\n decl(`${property}-block`, value),\n decl(`${property}-bottom`, value),\n decl(`${property}-top`, value),\n ]),\n );\n }\n for (const side of ['top', 'right', 'bottom', 'left']) {\n for (const token of filteredTokens) {\n root.push(rule(makePrelude(token, prefix, side[0]), [decl(`${property}-${side}`, makeVarValue(token))]));\n }\n }\n for (const token of filteredTokens) {\n const value = makeVarValue(token);\n root.push(\n rule(makePrelude(token, prefix, 'bs'), [decl(`${property}-block-start`, value)]),\n rule(makePrelude(token, prefix, 'be'), [decl(`${property}-block-end`, value)]),\n rule(makePrelude(token, prefix, 'is'), [decl(`${property}-inline-start`, value)]),\n rule(makePrelude(token, prefix, 'ie'), [decl(`${property}-inline-end`, value)]),\n );\n }\n }\n break;\n }\n case 'shadow': {\n for (const token of matchingTokens) {\n if (token.token.$type === 'shadow') {\n root.push(rule(makePrelude(token, 'shadow'), [decl('box-shadow', makeVarValue(token))]));\n }\n }\n break;\n }\n case 'text': {\n for (const token of matchingTokens) {\n const prelude = makePrelude(token, 'text');\n const value = makeVarValue(token);\n switch (token.token.$type) {\n case 'color': {\n root.push(rule(prelude, [decl('color', value)]));\n break;\n }\n case 'gradient': {\n root.push(\n rule(prelude, [\n decl('background', `-webkit-linear-gradient(${value})`),\n decl('-webkit-background-clip', 'text'),\n decl('-webkit-text-fill-color', 'transparent'),\n ]),\n );\n break;\n }\n }\n }\n break;\n }\n default: {\n logger.warn({ group: 'plugin', label: PLUGIN_NAME, message: `unknown utility CSS group \"${group}\", ignoring` });\n break;\n }\n }\n }\n\n return root;\n}\n","import type { BuildHookOptions, Logger } from '@terrazzo/parser';\nimport { generateShorthand, makeCSSVar } from '@terrazzo/token-tools/css';\nimport {\n addDeclUnique,\n type CSSDeclaration,\n type CSSPluginOptions,\n type CSSRule,\n cachedMatcher,\n decl,\n FORMAT_ID,\n getIndentFromPrepare,\n PLUGIN_NAME,\n printRules,\n rule,\n} from './lib.js';\nimport generateUtilityCSS from './utility-css.js';\n\nconst P3_MQ = '@media (color-gamut: p3)';\nconst REC2020_MQ = '@media (color-gamut: rec2020)';\n\nexport interface BuildFormatOptions {\n logger: Logger;\n include: CSSPluginOptions['include'];\n exclude: CSSPluginOptions['exclude'];\n getTransforms: BuildHookOptions['getTransforms'];\n modeSelectors: CSSPluginOptions['modeSelectors'];\n permutations: CSSPluginOptions['permutations'];\n utility: CSSPluginOptions['utility'];\n baseSelector: string;\n baseScheme: CSSPluginOptions['baseScheme'];\n}\n\nexport default function buildCSS({\n logger,\n getTransforms,\n include: userInclude,\n exclude: userExclude,\n utility,\n permutations,\n modeSelectors,\n baseSelector,\n baseScheme,\n}: BuildFormatOptions): string {\n const include = userInclude ? cachedMatcher.tokenIDMatch(userInclude) : () => true;\n const exclude = userExclude ? cachedMatcher.tokenIDMatch(userExclude) : () => false;\n if (permutations?.length) {\n let output = '';\n\n for (const p of permutations) {\n if (typeof p.prepare !== 'function') {\n logger.error({ group: 'plugin', label: PLUGIN_NAME, message: 'prepare(css) must be a function!' });\n }\n\n const tokens = getTransforms({ format: FORMAT_ID, input: p.input });\n if (!tokens.length) {\n continue;\n }\n\n const root: (CSSRule | CSSDeclaration)[] = [];\n const hdrColors = {\n p3: [] as CSSDeclaration[],\n rec2020: [] as CSSDeclaration[],\n };\n\n const pInclude = p.include ? cachedMatcher.tokenIDMatch(p.include) : () => true;\n const pExclude = p.exclude ? cachedMatcher.tokenIDMatch(p.exclude) : () => false;\n\n const includeToken = (tokenId: string): boolean => {\n return include(tokenId) && pInclude(tokenId) && !exclude(tokenId) && !pExclude(tokenId);\n };\n\n for (const token of tokens) {\n if (!includeToken(token.id)) {\n continue;\n }\n const localID = makeCSSVar(token.localID ?? token.token.id);\n const aliasTokens = token.token.aliasedBy?.length\n ? getTransforms({ format: FORMAT_ID, id: token.token.aliasedBy, input: p.input })\n : [];\n\n // single-value token\n if (token.type === 'SINGLE_VALUE') {\n addDeclUnique(root, decl(localID, token.value, token.token.$description));\n }\n\n // multi-value token (wide gamut color)\n else if (token.value.srgb && token.value.p3 && token.value.rec2020) {\n addDeclUnique(root, decl(localID, token.value.srgb!, token.token.$description));\n\n if (token.value.p3 !== token.value.srgb) {\n addDeclUnique(hdrColors.p3, decl(localID, token.value.p3!, token.token.$description));\n addDeclUnique(hdrColors.rec2020, decl(localID, token.value.rec2020!, token.token.$description));\n\n // handle aliases within color gamut media queries\n for (const alias of aliasTokens) {\n if (alias.localID && typeof alias.value === 'string') {\n const aliasID = makeCSSVar(alias.localID);\n addDeclUnique(hdrColors.p3, decl(aliasID, alias.value, alias.token.$description));\n addDeclUnique(hdrColors.rec2020, decl(aliasID, alias.value, alias.token.$description));\n }\n }\n }\n }\n\n // multi-value token\n else {\n for (const [name, subValue] of Object.entries(token.value)) {\n const subValueID = `${localID}-${name}`;\n addDeclUnique(root, decl(subValueID, subValue, token.token.$description));\n }\n // Note: always generate shorthand AFTER other declarations\n const shorthand = generateShorthand({ token: { ...token.token, $value: token.value as any }, localID });\n if (shorthand) {\n addDeclUnique(root, decl(localID, shorthand, token.token.$description));\n }\n }\n\n // redeclare aliases so they have the correct scope\n for (const alias of aliasTokens) {\n if (alias.localID && typeof alias.value === 'string') {\n if (!includeToken(alias.id)) {\n continue;\n }\n addDeclUnique(root, decl(alias.localID, alias.value, token.token.$description));\n }\n }\n }\n\n const indentRules = getIndentFromPrepare(p.prepare);\n if (output) {\n output += '\\n';\n }\n output += `${p.prepare(printRules(root, indentRules))}\\n`;\n\n // declare P3 and Rec2020 gamuts, if needed\n for (const gamut of ['p3', 'rec2020'] as const) {\n if (hdrColors[gamut].length) {\n output += `\\n@media (color-gamut: ${gamut}) {\\n`;\n output += indentRules.indentChar;\n output += p\n .prepare(printRules(hdrColors[gamut], indentRules))\n .replace(/\\n(?!\\n)/g, `\\n${indentRules.indentChar}`); // indent every line an extra level\n output += '\\n}\\n';\n }\n }\n }\n\n // add utility CSS\n if (utility && Object.keys(utility).length) {\n if (output) {\n output += '\\n';\n }\n output += printRules(\n generateUtilityCSS(utility, getTransforms({ format: FORMAT_ID, input: permutations[0]?.input ?? {} }), {\n logger,\n }),\n );\n }\n\n return output;\n }\n\n // legacy plugin (will be deprecated in 3.0)\n let output = '';\n const rootTokens = getTransforms({ format: FORMAT_ID, mode: '.' });\n if (rootTokens.length) {\n const rules: CSSRule[] = [\n rule([baseSelector], []),\n rule([P3_MQ], [rule([baseSelector])]),\n rule([REC2020_MQ], [rule([baseSelector])]),\n ];\n\n const rootRule = rules[0]!;\n const p3Rule = rules[1]!.children[0] as CSSRule;\n const rec2020Rule = rules[2]!.children[0] as CSSRule;\n\n // add base color-scheme declaration first if configured\n // (must be before other properties to ensure it appears first in output)\n if (baseScheme) {\n rootRule.children.unshift(decl('color-scheme', baseScheme));\n }\n\n for (const token of rootTokens) {\n // handle exclude (if any)\n if (!include(token.token.id) || exclude(token.token.id)) {\n continue;\n }\n\n const localID = token.localID ?? token.token.id;\n const aliasTokens = token.token.aliasedBy?.length\n ? getTransforms({ format: FORMAT_ID, id: token.token.aliasedBy })\n : [];\n\n // single-value token\n if (token.type === 'SINGLE_VALUE') {\n addDeclUnique(rootRule.children, decl(localID, token.value, token.token.$description));\n }\n\n // multi-value token (wide gamut color)\n else if (token.value.srgb && token.value.p3 && token.value.rec2020) {\n addDeclUnique(rootRule.children, decl(localID, token.value.srgb!, token.token.$description));\n\n if (token.value.p3 !== token.value.srgb) {\n addDeclUnique(p3Rule.children, decl(localID, token.value.p3!, token.token.$description));\n addDeclUnique(rec2020Rule.children, decl(localID, token.value.rec2020!, token.token.$description));\n // handle aliases within color gamut media queries\n for (const alias of aliasTokens) {\n if (alias.localID && typeof alias.value === 'string') {\n addDeclUnique(p3Rule.children, decl(alias.localID, alias.value, token.token.$description));\n addDeclUnique(rec2020Rule.children, decl(alias.localID, alias.value, token.token.$description));\n }\n }\n }\n }\n\n // multi-value token\n else if (token.type === 'MULTI_VALUE') {\n for (const [name, value] of Object.entries(token.value)) {\n const property = name === '.' ? localID : [localID, name].join('-');\n addDeclUnique(rootRule.children, decl(property, value, token.token.$description));\n }\n // Note: always place shorthand after other values\n const shorthand = generateShorthand({ token: { ...token.token, $value: token.value as any }, localID });\n if (shorthand) {\n addDeclUnique(rootRule.children, decl(token.localID ?? token.token.id, shorthand, token.token.$description));\n }\n }\n }\n\n output += printRules(rules);\n }\n\n // legacy modeSelectors\n // Delete this behavior in 3.0.\n // This code is intentionally left-alone as a separate code path so it behaves as it did with 0.x.\n for (const selector of modeSelectors ?? []) {\n const selectorTokens = getTransforms({ format: FORMAT_ID, id: selector.tokens, mode: selector.mode });\n if (!selectorTokens.length) {\n continue;\n }\n\n const modeRule: CSSRule = rule(selector.selectors);\n\n // add color-scheme declaration first if configured for this mode\n // (must be before other properties to ensure it appears first in output)\n if (selector.scheme) {\n modeRule.children.unshift(decl('color-scheme', selector.scheme));\n }\n const hdrColors = {\n p3: [] as CSSDeclaration[],\n rec2020: [] as CSSDeclaration[],\n };\n for (const token of selectorTokens) {\n const localID = token.localID ?? token.token.id;\n const aliasTokens = token.token.aliasedBy?.length\n ? getTransforms({ format: FORMAT_ID, id: token.token.aliasedBy })\n : [];\n\n // single-value token\n if (token.type === 'SINGLE_VALUE') {\n addDeclUnique(modeRule.children, decl(localID, token.value, token.token.$description));\n }\n\n // multi-value token (wide gamut color)\n else if (token.value.srgb && token.value.p3 && token.value.rec2020) {\n addDeclUnique(modeRule.children, decl(localID, token.value.srgb!, token.token.$description));\n if (token.value.p3 !== token.value.srgb) {\n addDeclUnique(hdrColors.p3, decl(localID, token.value.p3!, token.token.$description));\n addDeclUnique(hdrColors.rec2020, decl(localID, token.value.rec2020!, token.token.$description));\n\n // handle aliases within color gamut media queries\n for (const alias of aliasTokens) {\n if (alias.localID && typeof alias.value === 'string') {\n for (const gamut of ['p3', 'rec2020'] as const) {\n addDeclUnique(hdrColors[gamut], decl(alias.localID, alias.value, token.token.$description));\n }\n }\n }\n }\n }\n\n // multi-value token\n else {\n for (const [name, subValue] of Object.entries(token.value)) {\n addDeclUnique(modeRule.children, decl(`${localID}-${name}`, subValue, token.token.$description));\n }\n // Note: always generate shorthand after other declarations\n const shorthand = generateShorthand({ token: { ...token.token, $value: token.value as any }, localID });\n if (shorthand) {\n addDeclUnique(modeRule.children, decl(localID, shorthand, token.token.$description));\n }\n }\n\n // redeclare aliases so they have the correct scope\n for (const alias of aliasTokens) {\n if (alias.localID && typeof alias.value === 'string') {\n addDeclUnique(modeRule.children, decl(alias.localID, alias.value, token.token.$description));\n }\n }\n }\n\n if (output) {\n output += '\\n\\n';\n }\n output += printRules([\n modeRule,\n rule([P3_MQ], [rule(selector.selectors, hdrColors.p3)]),\n rule([REC2020_MQ], [rule(selector.selectors, hdrColors.rec2020)]),\n ]);\n }\n\n // add utility CSS\n if (utility && Object.keys(utility).length) {\n if (output) {\n output += '\\n\\n';\n }\n output += printRules(generateUtilityCSS(utility, getTransforms({ format: FORMAT_ID, mode: '.' }), { logger }));\n }\n\n return output;\n}\n","import type { TokenNormalized, TransformHookOptions } from '@terrazzo/parser';\nimport { makeCSSVar, transformCSSValue } from '@terrazzo/token-tools/css';\nimport { type CSSPluginOptions, cachedMatcher, FORMAT_ID, PLUGIN_NAME } from './lib.js';\n\nexport interface TransformOptions {\n transform: TransformHookOptions;\n options: CSSPluginOptions;\n}\n\nexport default function transformCSS({\n transform: {\n context: { logger },\n resolver,\n setTransform,\n tokens: baseTokens,\n },\n options: {\n permutations,\n include: userInclude,\n exclude: userExclude,\n legacyHex,\n transform: customTransform,\n variableName,\n },\n}: TransformOptions) {\n function transformName(token: TokenNormalized) {\n const customName = variableName?.(token);\n if (customName !== undefined) {\n if (typeof customName !== 'string') {\n logger.error({\n group: 'plugin',\n label: PLUGIN_NAME,\n message: `variableName() must return a string; received ${customName}`,\n });\n }\n return customName;\n }\n return makeCSSVar(token.id);\n }\n const transformAlias = (token: TokenNormalized) => `var(${transformName(token)})`;\n\n const include = userInclude ? cachedMatcher.tokenIDMatch(userInclude) : () => true;\n const exclude = userExclude ? cachedMatcher.tokenIDMatch(userExclude) : () => false;\n\n // permutations\n if (permutations?.length) {\n for (const p of permutations) {\n const input = p.input;\n const pInclude = p.include ? cachedMatcher.tokenIDMatch(p.include) : () => true;\n const pExclude = p.exclude ? cachedMatcher.tokenIDMatch(p.exclude) : () => false;\n\n const includeToken = (tokenId: string): boolean => {\n return include(tokenId) && pInclude(tokenId) && !exclude(tokenId) && !pExclude(tokenId);\n };\n // Note: if we throw an error here without specifying the input, a user may\n // find it impossible to debug the issue\n try {\n const tokens = resolver.apply(input);\n for (const token of Object.values(tokens)) {\n if (!includeToken(token.id)) {\n continue;\n }\n const value =\n customTransform?.(token) ??\n transformCSSValue(token, { tokensSet: tokens, transformAlias, color: { legacyHex } });\n if (value) {\n const localID = transformName(token);\n setTransform(token.id, {\n format: FORMAT_ID,\n value,\n localID,\n input,\n // TODO: plugin-css shouldn’t set metadata for plugin-token-listing; move this there\n meta: { 'token-listing': { name: localID } },\n });\n }\n }\n } catch (err) {\n logger.error({\n group: 'plugin',\n label: PLUGIN_NAME,\n message: `There was an error trying to apply input ${resolver.getPermutationID(input)}.`,\n continueOnError: true, // throw below\n });\n throw err; // note: this is most likely a nicely-formatted message from another logger instance; just pass it through\n }\n }\n\n return;\n }\n\n // modes (legacy)\n for (const token of Object.values(baseTokens)) {\n if (!include(token.id) || exclude(token.id)) {\n continue;\n }\n for (const mode of Object.keys(token.mode)) {\n const value =\n customTransform?.(token, '.') ??\n transformCSSValue(\n { ...token, ...(token.mode[mode] as any) },\n { tokensSet: baseTokens, transformAlias, color: { legacyHex } },\n );\n if (value) {\n const localID = transformName(token);\n setTransform(token.id, {\n format: FORMAT_ID,\n localID,\n value,\n mode,\n // TODO: plugin-css shouldn’t set metadata for plugin-token-listing; move this there\n meta: { 'token-listing': { name: localID } },\n });\n }\n }\n }\n}\n","import type { Plugin } from '@terrazzo/parser';\nimport buildCSS from './build.js';\nimport { type CSSPluginOptions, FILE_PREFIX, FORMAT_ID, PLUGIN_NAME } from './lib.js';\nimport transformCSS from './transform.js';\n\nexport * from './build.js';\nexport {\n type CSSDeclaration,\n type CSSPluginOptions,\n type CSSRule,\n FILE_PREFIX,\n FORMAT_ID,\n type ModeSelector,\n type Permutation,\n PLUGIN_NAME,\n printNode,\n printRules,\n type UtilityCSSGroup,\n type UtilityCSSPrefix,\n} from './lib.js';\nexport * from './transform.js';\nexport * from './utility-css.js';\n\nexport default function cssPlugin(options?: CSSPluginOptions): Plugin {\n const { utility, skipBuild, baseScheme } = options ?? {};\n\n const filename = options?.filename ?? (options as any)?.fileName ?? 'index.css';\n const baseSelector = options?.baseSelector ?? ':root';\n\n return {\n name: PLUGIN_NAME,\n config(_config, context) {\n if (options?.permutations && (options?.modeSelectors || options?.baseSelector || options?.baseScheme)) {\n context.logger.error({\n group: 'plugin',\n label: PLUGIN_NAME,\n message: 'Permutations option is incompatible with modeSelectors, baseSelector, and baseScheme.',\n });\n }\n },\n async transform(transformOptions) {\n // skip work if another .css plugin has already run\n const cssTokens = transformOptions.getTransforms({ format: FORMAT_ID, id: '*' });\n if (cssTokens.length) {\n return;\n }\n transformCSS({ transform: transformOptions, options: options ?? {} });\n },\n async build({ getTransforms, outputFile, context }) {\n if (skipBuild === true) {\n return;\n }\n\n let contents = `${FILE_PREFIX}\\n\\n`;\n contents += buildCSS({\n include: options?.include,\n exclude: options?.exclude,\n getTransforms,\n permutations: options?.permutations,\n modeSelectors: options?.modeSelectors,\n utility,\n baseSelector,\n baseScheme,\n logger: context.logger,\n });\n outputFile(filename, contents.replace(/\\n*$/, '\\n'));\n },\n };\n}\n"],"mappings":";;;;AAOA,MAAa,cAAc;AAE3B,MAAa,YAAY;AAEzB,MAAa,gBAAgB,IAAI,uBAAuB;AAExD,MAAa,cAAc;;;;;;;;;;;;;;;;AA2G3B,SAAgB,WACd,OACA,EAAE,aAAa,MAAM,WAAW,MAAkD,EAAE,EAC5E;CACR,IAAI,SAAS;AACb,MAAK,MAAM,QAAQ,OAAO;AACxB,MAAI,UAAU,KAAK,SAAS,OAC1B,WAAU;AAEZ,YAAU,UAAU,MAAM;GAAE;GAAY;GAAU,CAAC;;AAErD,QAAO,OAAO,MAAM;;;AAItB,SAAgB,UACd,MACA,EAAE,YAAY,YACN;CACR,IAAI,SAAS;CAEb,MAAM,SAAS,WAAW,OAAO,SAAS;AAE1C,KAAI,KAAK,SAAS,eAAe;AAC/B,MAAI,KAAK,QACP,WAAU,GAAG,OAAO,KAAK,KAAK,QAAQ;AAExC,YAAU,GAAG,SAAS,KAAK,SAAS,IAAI,KAAK,MAAM;AACnD,SAAO;;AAGT,KAAI,CAAC,KAAK,QAAQ,UAAU,CAAC,KAAK,SAAS,OACzC,QAAO;CAKT,MAAM,sBAAsB,KAAK,SAAS,MAAM,MAAM,EAAE,SAAS,cAAc,GAC3E,KAAK,QAAQ,MAAM,MAAM,EAAE,WAAW,IAAI,CAAC,GAC3C;AACJ,KAAI,qBAAqB;EACvB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zo/plugin-css",
3
- "version": "2.0.0-beta.3",
3
+ "version": "2.0.0-beta.5",
4
4
  "description": "Convert DTCG design tokens JSON into CSS variables for use in any web application or native app with webview.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -27,17 +27,17 @@
27
27
  "directory": "./packages/plugin-css/"
28
28
  },
29
29
  "peerDependencies": {
30
- "@terrazzo/cli": "^2.0.0-beta.3",
31
- "@terrazzo/parser": "^2.0.0-beta.3"
30
+ "@terrazzo/cli": "^2.0.0-beta.5",
31
+ "@terrazzo/parser": "^2.0.0-beta.5"
32
32
  },
33
33
  "dependencies": {
34
34
  "wildcard-match": "^5.1.4",
35
- "@terrazzo/token-tools": "^2.0.0-beta.3"
35
+ "@terrazzo/token-tools": "^2.0.0-beta.5"
36
36
  },
37
37
  "devDependencies": {
38
- "dtcg-examples": "^1.0.2",
39
- "@terrazzo/cli": "^2.0.0-beta.3",
40
- "@terrazzo/parser": "^2.0.0-beta.3"
38
+ "dtcg-examples": "^1.0.3",
39
+ "@terrazzo/cli": "^2.0.0-beta.5",
40
+ "@terrazzo/parser": "^2.0.0-beta.5"
41
41
  },
42
42
  "scripts": {
43
43
  "build": "rolldown -c && attw --profile esm-only --pack .",