@terrazzo/plugin-css 2.0.3 → 2.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @terrazzo/plugin-css
2
2
 
3
+ ## 2.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#738](https://github.com/terrazzoapp/terrazzo/pull/738) [`5f2700e`](https://github.com/terrazzoapp/terrazzo/commit/5f2700e0bbe76cb19674feef8a3868653f273b11) Thanks [@james-nash](https://github.com/james-nash)! - Added `subValueVariableName` option.
8
+
9
+ - [#738](https://github.com/terrazzoapp/terrazzo/pull/738) [`5f2700e`](https://github.com/terrazzoapp/terrazzo/commit/5f2700e0bbe76cb19674feef8a3868653f273b11) Thanks [@james-nash](https://github.com/james-nash)! - Added `omitTypographyShorthand` option.
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [[`108aad0`](https://github.com/terrazzoapp/terrazzo/commit/108aad068486ced7c6791683d30ce393cc4426ae), [`5f2700e`](https://github.com/terrazzoapp/terrazzo/commit/5f2700e0bbe76cb19674feef8a3868653f273b11)]:
14
+ - @terrazzo/token-tools@2.2.0
15
+
16
+ ## 2.1.0
17
+
18
+ ### Minor Changes
19
+
20
+ - [#732](https://github.com/terrazzoapp/terrazzo/pull/732) [`07be482`](https://github.com/terrazzoapp/terrazzo/commit/07be4826763bcaeac2ecae156c00f547b5564122) Thanks [@avasis-ai](https://github.com/avasis-ai)! - feat: add opt-in `propertyDefinitions` option to CSS plugin to generate CSS @property definitions
21
+
3
22
  ## 2.0.3
4
23
 
5
24
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -56,6 +56,26 @@ interface CSSPluginOptions {
56
56
  * @default false
57
57
  */
58
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;
59
79
  }
60
80
  interface Permutation<T extends Record<string, string> = Record<string, string>> {
61
81
  /** Generate the final CSS string, wrapping content in the selector(s) of your choice. */
@@ -132,6 +152,9 @@ interface BuildFormatOptions {
132
152
  utility: CSSPluginOptions['utility'];
133
153
  baseSelector: string;
134
154
  baseScheme: CSSPluginOptions['baseScheme'];
155
+ propertyDefinitions: boolean;
156
+ omitTypographyShorthand: CSSPluginOptions['omitTypographyShorthand'];
157
+ subValueVariableName: CSSPluginOptions['subValueVariableName'];
135
158
  }
136
159
  //#endregion
137
160
  //#region src/transform.d.ts
@@ -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;;;;;AAIb;EAsBE,UAAA;;;;EAIA,YAAA,GAAe,WAAA;EAUN;;;;EALT,aAAA,GAAgB,YAAA;EASN;EAPV,YAAA,IAAgB,KAAA,EAAO,eAAA;EAON;EALjB,SAAA,IACE,KAAA,EAAO,eAAA,EACP,OAAA,EAAS,wBAAA,KACN,gBAAA;EA/BL;EAiCA,OA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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;;;UCzIjC,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;EACZ,mBAAA;EACA,uBAAA,EAAyB,gBAAA;EACzB,oBAAA,EAAsB,gBAAA;AAAA;;;UCpCP,gBAAA;EACf,SAAA,EAAW,oBAAA;EACX,OAAA,EAAS,gBAAgB;AAAA;;;iBCiBH,SAAA,CAAU,OAAA,GAAU,gBAAA,GAAmB,MAAM"}
package/dist/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { generateShorthand, makeCSSVar, transformCSSValue } from "@terrazzo/token-tools/css";
2
2
  import { CachedWildcardMatcher, kebabCase } from "@terrazzo/token-tools";
3
-
4
3
  //#region src/lib.ts
5
4
  const PLUGIN_NAME = "@terrazzo/plugin-css";
6
5
  const FORMAT_ID = "css";
@@ -42,7 +41,7 @@ function printNode(node, { indentChar, indentLv }) {
42
41
  return output;
43
42
  }
44
43
  if (!node.prelude.length || !node.children.length) return output;
45
- const mediaQueryWithDecls = node.children.some((s) => s.type === "Declaration") ? node.prelude.find((s) => s.startsWith("@")) : void 0;
44
+ const mediaQueryWithDecls = node.children.some((s) => s.type === "Declaration") ? node.prelude.find((s) => s.startsWith("@media")) : void 0;
46
45
  if (mediaQueryWithDecls) {
47
46
  const nonMedia = node.prelude.filter((s) => s !== mediaQueryWithDecls);
48
47
  output += `${indent}${mediaQueryWithDecls} {\n`;
@@ -116,7 +115,6 @@ function hasDecl(list, property) {
116
115
  function addDeclUnique(list, declaration) {
117
116
  if (!hasDecl(list, declaration.property)) list.push(declaration);
118
117
  }
119
-
120
118
  //#endregion
121
119
  //#region src/utility-css.ts
122
120
  const GROUP_REGEX = {
@@ -273,7 +271,6 @@ function generateUtilityCSS(groups, tokens, { logger }) {
273
271
  }
274
272
  return root;
275
273
  }
276
-
277
274
  //#endregion
278
275
  //#region src/build.ts
279
276
  const P3_MQ = "@media (color-gamut: p3)";
@@ -285,9 +282,115 @@ const REC2020_MQ = "@media (color-gamut: rec2020)";
285
282
  function getDescription(token) {
286
283
  return token.meta?.["plugin-css"]?.description ?? token.token.$description;
287
284
  }
288
- function buildCSS({ logger, getTransforms, include: userInclude, exclude: userExclude, utility, permutations, modeSelectors, baseSelector, baseScheme }) {
285
+ const TOKEN_TYPE_SYNTAX = {
286
+ color: "<color>",
287
+ dimension: "<length>",
288
+ duration: "<time>",
289
+ fontWeight: "<integer>",
290
+ number: "<number>",
291
+ boolean: "<integer>",
292
+ fontFamily: "*",
293
+ string: "*",
294
+ cubicBezier: "*",
295
+ border: "*",
296
+ shadow: "*",
297
+ gradient: "*",
298
+ typography: "*",
299
+ transition: "*",
300
+ strokeStyle: "*",
301
+ link: "<url>"
302
+ };
303
+ const SUB_PROPERTY_SYNTAX = {
304
+ border: {
305
+ color: "<color>",
306
+ width: "<length>",
307
+ style: "*"
308
+ },
309
+ shadow: {
310
+ color: "<color>",
311
+ "offset-x": "<length>",
312
+ "offset-y": "<length>",
313
+ blur: "<length>",
314
+ spread: "<length>"
315
+ },
316
+ transition: {
317
+ duration: "<time>",
318
+ delay: "<time>",
319
+ "timing-function": "*"
320
+ },
321
+ typography: {
322
+ "font-family": "*",
323
+ "font-size": "<length>",
324
+ "font-weight": "<integer>",
325
+ "line-height": "*",
326
+ "letter-spacing": "<length>",
327
+ "font-style": "*",
328
+ "font-variant": "*",
329
+ "font-variation-settings": "*",
330
+ "text-decoration": "*",
331
+ "text-transform": "*"
332
+ },
333
+ strokeStyle: {
334
+ "dash-array": "*",
335
+ "line-cap": "*"
336
+ }
337
+ };
338
+ function generatePropertyDefinition(localID, syntax, initialValue) {
339
+ const children = [decl("syntax", `'${syntax}'`), decl("inherits", "true")];
340
+ if (initialValue) children.push(decl("initial-value", initialValue));
341
+ return rule([`@property ${localID}`], children);
342
+ }
343
+ function generatePropertyDefinitions(getTransforms, options) {
344
+ const tokens = getTransforms({ format: "css" });
345
+ const properties = [];
346
+ const seen = /* @__PURE__ */ new Set();
347
+ for (const token of tokens) {
348
+ const localID = token.localID;
349
+ if (!localID) continue;
350
+ if (!options.include(token.token.id) || options.exclude(token.token.id)) continue;
351
+ const cssSyntax = TOKEN_TYPE_SYNTAX[token.token.$type] ?? "*";
352
+ if (token.type === "SINGLE_VALUE") {
353
+ if (seen.has(localID)) continue;
354
+ seen.add(localID);
355
+ if (!token.token.aliasOf && cssSyntax !== "*") properties.push(generatePropertyDefinition(localID, cssSyntax, token.value));
356
+ else properties.push(generatePropertyDefinition(localID, "*"));
357
+ } else if (token.type === "MULTI_VALUE") {
358
+ for (const [name, subValue] of Object.entries(token.value)) {
359
+ const subID = name === "." ? localID : `${localID}-${name}`;
360
+ if (seen.has(subID)) continue;
361
+ seen.add(subID);
362
+ const subSyntax = SUB_PROPERTY_SYNTAX[token.token.$type]?.[name] ?? "*";
363
+ if (!token.token.aliasOf && subSyntax !== "*") properties.push(generatePropertyDefinition(subID, subSyntax, subValue));
364
+ else properties.push(generatePropertyDefinition(subID, "*"));
365
+ }
366
+ if (!seen.has(localID)) {
367
+ seen.add(localID);
368
+ properties.push(generatePropertyDefinition(localID, "*"));
369
+ }
370
+ }
371
+ }
372
+ return properties;
373
+ }
374
+ function buildCSS({ logger, getTransforms, include: userInclude, exclude: userExclude, utility, permutations, modeSelectors, baseSelector, baseScheme, propertyDefinitions = false, omitTypographyShorthand, subValueVariableName }) {
375
+ function makeSubValueId(variableName, subValueName, token) {
376
+ const customName = subValueVariableName?.(variableName, subValueName, token);
377
+ if (customName !== void 0) {
378
+ if (typeof customName !== "string") logger.error({
379
+ group: "plugin",
380
+ label: PLUGIN_NAME,
381
+ message: `subValueVariableName() must return a string; received ${customName}`
382
+ });
383
+ return customName;
384
+ }
385
+ return `${variableName}-${subValueName}`;
386
+ }
289
387
  const include = userInclude ? cachedMatcher.tokenIDMatch(userInclude) : () => true;
290
388
  const exclude = userExclude ? cachedMatcher.tokenIDMatch(userExclude) : () => false;
389
+ let propertyDefsNodes = [];
390
+ if (propertyDefinitions) propertyDefsNodes = generatePropertyDefinitions(getTransforms, {
391
+ include,
392
+ exclude
393
+ });
291
394
  if (permutations?.length) {
292
395
  let output = "";
293
396
  for (const p of permutations) {
@@ -297,7 +400,7 @@ function buildCSS({ logger, getTransforms, include: userInclude, exclude: userEx
297
400
  message: "prepare(css) must be a function!"
298
401
  });
299
402
  const tokens = getTransforms({
300
- format: FORMAT_ID,
403
+ format: "css",
301
404
  input: p.input
302
405
  });
303
406
  if (!tokens.length) continue;
@@ -315,7 +418,7 @@ function buildCSS({ logger, getTransforms, include: userInclude, exclude: userEx
315
418
  if (!includeToken(token.id)) continue;
316
419
  const localID = makeCSSVar(token.localID ?? token.token.id);
317
420
  const aliasTokens = token.token.aliasedBy?.length ? getTransforms({
318
- format: FORMAT_ID,
421
+ format: "css",
319
422
  id: token.token.aliasedBy,
320
423
  input: p.input
321
424
  }) : [];
@@ -332,13 +435,14 @@ function buildCSS({ logger, getTransforms, include: userInclude, exclude: userEx
332
435
  }
333
436
  }
334
437
  } else {
335
- for (const [name, subValue] of Object.entries(token.value)) addDeclUnique(root, decl(`${localID}-${name}`, subValue, getDescription(token)));
438
+ for (const [name, subValue] of Object.entries(token.value)) addDeclUnique(root, decl(makeSubValueId(localID, name, token), subValue, getDescription(token)));
336
439
  const shorthand = generateShorthand({
337
440
  token: {
338
441
  ...token.token,
339
442
  $value: token.value
340
443
  },
341
- localID
444
+ localID,
445
+ omitTypographyShorthand
342
446
  });
343
447
  if (shorthand) addDeclUnique(root, decl(localID, shorthand, getDescription(token)));
344
448
  }
@@ -360,15 +464,16 @@ function buildCSS({ logger, getTransforms, include: userInclude, exclude: userEx
360
464
  if (utility && Object.keys(utility).length) {
361
465
  if (output) output += "\n";
362
466
  output += printRules(generateUtilityCSS(utility, getTransforms({
363
- format: FORMAT_ID,
467
+ format: "css",
364
468
  input: permutations[0]?.input ?? {}
365
469
  }), { logger }));
366
470
  }
471
+ if (propertyDefsNodes.length && output) output = `${printRules(propertyDefsNodes)}\n\n${output}`;
367
472
  return output;
368
473
  }
369
474
  let output = "";
370
475
  const rootTokens = getTransforms({
371
- format: FORMAT_ID,
476
+ format: "css",
372
477
  mode: "."
373
478
  });
374
479
  if (rootTokens.length) {
@@ -385,7 +490,7 @@ function buildCSS({ logger, getTransforms, include: userInclude, exclude: userEx
385
490
  if (!include(token.token.id) || exclude(token.token.id)) continue;
386
491
  const localID = token.localID ?? token.token.id;
387
492
  const aliasTokens = token.token.aliasedBy?.length ? getTransforms({
388
- format: FORMAT_ID,
493
+ format: "css",
389
494
  id: token.token.aliasedBy
390
495
  }) : [];
391
496
  if (token.type === "SINGLE_VALUE") addDeclUnique(rootRule.children, decl(localID, token.value, getDescription(token)));
@@ -401,7 +506,7 @@ function buildCSS({ logger, getTransforms, include: userInclude, exclude: userEx
401
506
  }
402
507
  } else if (token.type === "MULTI_VALUE") {
403
508
  for (const [name, value] of Object.entries(token.value)) {
404
- const property = name === "." ? localID : [localID, name].join("-");
509
+ const property = name === "." ? localID : makeSubValueId(localID, name, token);
405
510
  addDeclUnique(rootRule.children, decl(property, value, getDescription(token)));
406
511
  }
407
512
  const shorthand = generateShorthand({
@@ -409,7 +514,8 @@ function buildCSS({ logger, getTransforms, include: userInclude, exclude: userEx
409
514
  ...token.token,
410
515
  $value: token.value
411
516
  },
412
- localID
517
+ localID,
518
+ omitTypographyShorthand
413
519
  });
414
520
  if (shorthand) addDeclUnique(rootRule.children, decl(token.localID ?? token.token.id, shorthand, getDescription(token)));
415
521
  }
@@ -418,7 +524,7 @@ function buildCSS({ logger, getTransforms, include: userInclude, exclude: userEx
418
524
  }
419
525
  for (const selector of modeSelectors ?? []) {
420
526
  const selectorTokens = getTransforms({
421
- format: FORMAT_ID,
527
+ format: "css",
422
528
  id: selector.tokens,
423
529
  mode: selector.mode
424
530
  });
@@ -433,7 +539,7 @@ function buildCSS({ logger, getTransforms, include: userInclude, exclude: userEx
433
539
  const localID = token.localID ?? token.token.id;
434
540
  const aliasedBy = token.token.mode[selector.mode]?.aliasedBy?.length ? token.token.mode[selector.mode].aliasedBy : token.token.aliasedBy;
435
541
  let aliasTokens = aliasedBy?.length ? getTransforms({
436
- format: FORMAT_ID,
542
+ format: "css",
437
543
  id: aliasedBy,
438
544
  mode: selector.mode
439
545
  }) : [];
@@ -447,13 +553,17 @@ function buildCSS({ logger, getTransforms, include: userInclude, exclude: userEx
447
553
  for (const alias of aliasTokens) if (alias.localID && typeof alias.value === "string") for (const gamut of ["p3", "rec2020"]) addDeclUnique(hdrColors[gamut], decl(alias.localID, alias.value, getDescription(alias)));
448
554
  }
449
555
  } else {
450
- for (const [name, subValue] of Object.entries(token.value)) addDeclUnique(modeRule.children, decl(`${localID}-${name}`, subValue, getDescription(token)));
556
+ for (const [name, subValue] of Object.entries(token.value)) {
557
+ const subValueID = makeSubValueId(localID, name, token);
558
+ addDeclUnique(modeRule.children, decl(subValueID, subValue, getDescription(token)));
559
+ }
451
560
  const shorthand = generateShorthand({
452
561
  token: {
453
562
  ...token.token,
454
563
  $value: token.value
455
564
  },
456
- localID
565
+ localID,
566
+ omitTypographyShorthand
457
567
  });
458
568
  if (shorthand) addDeclUnique(modeRule.children, decl(localID, shorthand, getDescription(token)));
459
569
  }
@@ -469,13 +579,13 @@ function buildCSS({ logger, getTransforms, include: userInclude, exclude: userEx
469
579
  if (utility && Object.keys(utility).length) {
470
580
  if (output) output += "\n\n";
471
581
  output += printRules(generateUtilityCSS(utility, getTransforms({
472
- format: FORMAT_ID,
582
+ format: "css",
473
583
  mode: "."
474
584
  }), { logger }));
475
585
  }
586
+ if (propertyDefsNodes.length && output) output = `${printRules(propertyDefsNodes)}\n\n${output}`;
476
587
  return output;
477
588
  }
478
-
479
589
  //#endregion
480
590
  //#region src/transform.ts
481
591
  function transformCSS({ transform: { context: { logger }, resolver, setTransform, tokens: baseTokens }, options: { permutations, include: userInclude, exclude: userExclude, legacyHex, transform: customTransform, variableName } }) {
@@ -520,7 +630,7 @@ function transformCSS({ transform: { context: { logger }, resolver, setTransform
520
630
  if (value) {
521
631
  const localID = transformName(token);
522
632
  setTransform(token.id, {
523
- format: FORMAT_ID,
633
+ format: "css",
524
634
  value,
525
635
  localID,
526
636
  input,
@@ -530,7 +640,7 @@ function transformCSS({ transform: { context: { logger }, resolver, setTransform
530
640
  }
531
641
  });
532
642
  if (defaultPermutationI === i) setTransform(token.id, {
533
- format: FORMAT_ID,
643
+ format: "css",
534
644
  value,
535
645
  localID,
536
646
  mode: ".",
@@ -570,7 +680,7 @@ function transformCSS({ transform: { context: { logger }, resolver, setTransform
570
680
  if (value) {
571
681
  const localID = transformName(token);
572
682
  setTransform(token.id, {
573
- format: FORMAT_ID,
683
+ format: "css",
574
684
  localID,
575
685
  value,
576
686
  mode,
@@ -583,11 +693,10 @@ function transformCSS({ transform: { context: { logger }, resolver, setTransform
583
693
  }
584
694
  }
585
695
  }
586
-
587
696
  //#endregion
588
697
  //#region src/index.ts
589
698
  function cssPlugin(options) {
590
- const { utility, skipBuild, baseScheme } = options ?? {};
699
+ const { utility, skipBuild, baseScheme, propertyDefinitions } = options ?? {};
591
700
  const filename = options?.filename ?? options?.fileName ?? "index.css";
592
701
  const baseSelector = options?.baseSelector ?? ":root";
593
702
  return {
@@ -617,13 +726,16 @@ function cssPlugin(options) {
617
726
  utility,
618
727
  baseSelector,
619
728
  baseScheme,
620
- logger: context.logger
729
+ propertyDefinitions: propertyDefinitions ?? false,
730
+ logger: context.logger,
731
+ omitTypographyShorthand: options?.omitTypographyShorthand,
732
+ subValueVariableName: options?.subValueVariableName
621
733
  });
622
734
  outputFile(filename, contents.replace(/\n*$/, "\n"));
623
735
  }
624
736
  };
625
737
  }
626
-
627
738
  //#endregion
628
739
  export { FILE_PREFIX, FORMAT_ID, PLUGIN_NAME, cssPlugin as default, printNode, printRules };
740
+
629
741
  //# 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';\nimport { CachedWildcardMatcher } from '@terrazzo/token-tools';\n\nimport type { TransformCSSValueOptions } from '@terrazzo/token-tools/css';\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 options: TransformCSSValueOptions,\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(contents: 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 * Custom transform for this permutation\n */\n transform?: (\n token: TokenNormalized,\n options: TransformCSSValueOptions,\n ) => TokenTransformed['value'] | undefined | null;\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: Permutation['prepare']): { 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\n/**\n * Get description from metadata with fallback to token.$description\n * Preserves the descriptions and alias descriptions.\n */\nfunction getDescription(token: any): string | undefined {\n return token.meta?.['plugin-css']?.description ?? token.token.$description;\n}\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, getDescription(token)));\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!, getDescription(token)));\n\n if (token.value.p3 !== token.value.srgb) {\n addDeclUnique(hdrColors.p3, decl(localID, token.value.p3!, getDescription(token)));\n addDeclUnique(hdrColors.rec2020, decl(localID, token.value.rec2020!, getDescription(token)));\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, getDescription(alias)));\n addDeclUnique(hdrColors.rec2020, decl(aliasID, alias.value, getDescription(alias)));\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, getDescription(token)));\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, getDescription(token)));\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, getDescription(token)));\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, getDescription(token)));\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!, getDescription(token)));\n\n if (token.value.p3 !== token.value.srgb) {\n addDeclUnique(p3Rule.children, decl(localID, token.value.p3!, getDescription(token)));\n addDeclUnique(rec2020Rule.children, decl(localID, token.value.rec2020!, getDescription(token)));\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, getDescription(alias)));\n addDeclUnique(rec2020Rule.children, decl(alias.localID, alias.value, getDescription(alias)));\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, getDescription(token)));\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, getDescription(token)));\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 aliasedBy = token.token.mode[selector.mode]?.aliasedBy?.length\n ? token.token.mode[selector.mode]!.aliasedBy\n : token.token.aliasedBy;\n let aliasTokens = aliasedBy?.length\n ? getTransforms({ format: FORMAT_ID, id: aliasedBy, mode: selector.mode })\n : [];\n // Note: this will grab aliases from alternate and default modes. If we have duplicates, discard the default modes\n const uniqueAliasIDs = new Set(aliasTokens.map((t) => t.id));\n if (uniqueAliasIDs.size !== aliasTokens.length && selector.mode !== '.') {\n aliasTokens = aliasTokens.filter(\n (t, i) => !aliasTokens.some((t2, i2) => t.id === t2.id && i !== i2 && t.mode === '.'),\n );\n }\n\n // single-value token\n if (token.type === 'SINGLE_VALUE') {\n addDeclUnique(modeRule.children, decl(localID, token.value, getDescription(token)));\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!, getDescription(token)));\n if (token.value.p3 !== token.value.srgb) {\n addDeclUnique(hdrColors.p3, decl(localID, token.value.p3!, getDescription(token)));\n addDeclUnique(hdrColors.rec2020, decl(localID, token.value.rec2020!, getDescription(token)));\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, getDescription(alias)));\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, getDescription(token)));\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, getDescription(token)));\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, getDescription(token)));\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, type TransformCSSValueOptions, 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 (Array.isArray(permutations)) {\n // For backwards-compat, if this resolver allows a “default” input,\n // also duplicate the token in the global space. This plays nicer with\n // plugins that haven’t upgraded to resolvers yet.\n // If there is no “default” permutation, then take the first one\n let defaultPermutationI = permutations.findIndex((p) => !Object.keys(p.input ?? {}).length);\n if (defaultPermutationI === -1) {\n defaultPermutationI = 0;\n }\n\n for (let i = 0; i < permutations.length; i++) {\n const p = permutations[i]!;\n const inputRaw = p.input;\n const input = !Object.keys(inputRaw ?? {}).length\n ? (JSON.parse(resolver.getPermutationID(inputRaw ?? {})) as Record<string, string>)\n : inputRaw;\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 // 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 options: TransformCSSValueOptions = {\n tokensSet: tokens,\n transformAlias,\n color: { legacyHex },\n permutation: input,\n };\n const value =\n p.transform?.(token, options) ?? customTransform?.(token, options) ?? transformCSSValue(token, options);\n if (value) {\n const localID = transformName(token);\n setTransform(token.id, {\n format: FORMAT_ID,\n value,\n localID,\n input,\n // Store description in metadata for plugin-css to access later\n meta: {\n 'plugin-css': {\n description: token.$description,\n },\n 'token-listing': { name: localID },\n },\n });\n\n // If this is the default permutation, also duplicate to the default mode.\n // Be sure to only do this for ONE permutation! Otherwise output would break.\n if (defaultPermutationI === i) {\n setTransform(token.id, {\n format: FORMAT_ID,\n value,\n localID,\n mode: '.',\n // Store description in metadata for plugin-css to access later\n meta: {\n 'plugin-css': {\n description: token.$description,\n },\n 'token-listing': { name: localID },\n },\n });\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 tokenArgs: TokenNormalized = { ...token, ...(token.mode[mode] as any) };\n const options: TransformCSSValueOptions = {\n tokensSet: baseTokens,\n transformAlias,\n color: { legacyHex },\n permutation: { tzMode: '*' },\n };\n const value = customTransform?.(tokenArgs, options) ?? transformCSSValue(tokenArgs, options);\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: {\n 'plugin-css': {\n description: token.$description,\n },\n 'token-listing': { name: localID },\n },\n });\n }\n }\n }\n}\n","import type { Plugin } from '@terrazzo/parser';\nimport buildCSS from './build.js';\nimport { type CSSPluginOptions, FILE_PREFIX, 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 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":";;;;AASA,MAAa,cAAc;AAE3B,MAAa,YAAY;AA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,SAAS,iBAAiB,SAAS,iBAAiB,SAAS,gBAAgB,SAAS,YACxF,SAAQ,OAAO,MAAM;IACnB,OAAO;IACP,OAAO;IACP,SAAS;IACV,CAAC;;EAGN,MAAM,UAAU,kBAAkB;AAChC,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,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\nimport type { TransformCSSValueOptions } from '@terrazzo/token-tools/css';\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 options: TransformCSSValueOptions,\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 * Generate CSS @property definitions for type-safe CSS Custom Properties.\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@property\n * @default false\n */\n propertyDefinitions?: boolean;\n /**\n * Do not generate CSS shorthand declarations for typography tokens.\n *\n * Note that individual, per-subvalue declarations will still be generated for these tokens.\n * @default false\n */\n omitTypographyShorthand?: boolean;\n /**\n * Control how sub value names are appended to the CSS variable name.\n *\n * By default, sub value names are appended as is with a hyphen. E.g. given CSS variable name `--my-token` and\n * sub value name `font-size`, the resulting variable name would be `--my-token-font-size`.\n */\n subValueVariableName?: (variableName: string, subValueName: string, token: TokenTransformed) => string;\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(contents: 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 * Custom transform for this permutation\n */\n transform?: (\n token: TokenNormalized,\n options: TransformCSSValueOptions,\n ) => TokenTransformed['value'] | undefined | null;\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('@media'))\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: Permutation['prepare']): { 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, TokenTransformed } 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\n/**\n * Get description from metadata with fallback to token.$description\n * Preserves the descriptions and alias descriptions.\n */\nfunction getDescription(token: any): string | undefined {\n return token.meta?.['plugin-css']?.description ?? token.token.$description;\n}\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 propertyDefinitions: boolean;\n omitTypographyShorthand: CSSPluginOptions['omitTypographyShorthand'];\n subValueVariableName: CSSPluginOptions['subValueVariableName'];\n}\n\nconst TOKEN_TYPE_SYNTAX: Record<string, string> = {\n color: '<color>',\n dimension: '<length>',\n duration: '<time>',\n fontWeight: '<integer>',\n number: '<number>',\n boolean: '<integer>',\n fontFamily: '*',\n string: '*',\n cubicBezier: '*',\n border: '*',\n shadow: '*',\n gradient: '*',\n typography: '*',\n transition: '*',\n strokeStyle: '*',\n link: '<url>',\n};\n\nconst SUB_PROPERTY_SYNTAX: Record<string, Record<string, string>> = {\n border: { color: '<color>', width: '<length>', style: '*' },\n shadow: { color: '<color>', 'offset-x': '<length>', 'offset-y': '<length>', blur: '<length>', spread: '<length>' },\n transition: { duration: '<time>', delay: '<time>', 'timing-function': '*' },\n typography: {\n 'font-family': '*',\n 'font-size': '<length>',\n 'font-weight': '<integer>',\n 'line-height': '*',\n 'letter-spacing': '<length>',\n 'font-style': '*',\n 'font-variant': '*',\n 'font-variation-settings': '*',\n 'text-decoration': '*',\n 'text-transform': '*',\n },\n strokeStyle: { 'dash-array': '*', 'line-cap': '*' },\n};\n\nfunction generatePropertyDefinition(localID: string, syntax: string, initialValue?: string): CSSRule {\n const children: CSSDeclaration[] = [decl('syntax', `'${syntax}'`), decl('inherits', 'true')];\n if (initialValue) {\n children.push(decl('initial-value', initialValue));\n }\n return rule([`@property ${localID}`], children);\n}\n\nfunction generatePropertyDefinitions(\n getTransforms: BuildHookOptions['getTransforms'],\n options: { include: (id: string) => boolean; exclude: (id: string) => boolean },\n): CSSRule[] {\n const tokens = getTransforms({ format: FORMAT_ID });\n const properties: CSSRule[] = [];\n const seen = new Set<string>();\n\n for (const token of tokens) {\n const localID = token.localID;\n if (!localID) {\n continue;\n }\n if (!options.include(token.token.id) || options.exclude(token.token.id)) {\n continue;\n }\n\n const cssSyntax = TOKEN_TYPE_SYNTAX[token.token.$type] ?? '*';\n\n if (token.type === 'SINGLE_VALUE') {\n if (seen.has(localID)) {\n continue;\n }\n seen.add(localID);\n if (!token.token.aliasOf && cssSyntax !== '*') {\n properties.push(generatePropertyDefinition(localID, cssSyntax, token.value));\n } else {\n properties.push(generatePropertyDefinition(localID, '*'));\n }\n } else if (token.type === 'MULTI_VALUE') {\n for (const [name, subValue] of Object.entries(token.value)) {\n const subID = name === '.' ? localID : `${localID}-${name}`;\n if (seen.has(subID)) {\n continue;\n }\n seen.add(subID);\n const subSyntax = SUB_PROPERTY_SYNTAX[token.token.$type]?.[name] ?? '*';\n if (!token.token.aliasOf && subSyntax !== '*') {\n properties.push(generatePropertyDefinition(subID, subSyntax, subValue));\n } else {\n properties.push(generatePropertyDefinition(subID, '*'));\n }\n }\n if (!seen.has(localID)) {\n seen.add(localID);\n properties.push(generatePropertyDefinition(localID, '*'));\n }\n }\n }\n\n return properties;\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 propertyDefinitions = false,\n omitTypographyShorthand,\n subValueVariableName,\n}: BuildFormatOptions): string {\n function makeSubValueId(variableName: string, subValueName: string, token: TokenTransformed) {\n const customName = subValueVariableName?.(variableName, subValueName, token);\n if (customName !== undefined) {\n if (typeof customName !== 'string') {\n logger.error({\n group: 'plugin',\n label: PLUGIN_NAME,\n message: `subValueVariableName() must return a string; received ${customName}`,\n });\n }\n return customName;\n }\n return `${variableName}-${subValueName}`;\n }\n\n const include = userInclude ? cachedMatcher.tokenIDMatch(userInclude) : () => true;\n const exclude = userExclude ? cachedMatcher.tokenIDMatch(userExclude) : () => false;\n let propertyDefsNodes: CSSRule[] = [];\n if (propertyDefinitions) {\n propertyDefsNodes = generatePropertyDefinitions(getTransforms, { include, exclude });\n }\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, getDescription(token)));\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!, getDescription(token)));\n\n if (token.value.p3 !== token.value.srgb) {\n addDeclUnique(hdrColors.p3, decl(localID, token.value.p3!, getDescription(token)));\n addDeclUnique(hdrColors.rec2020, decl(localID, token.value.rec2020!, getDescription(token)));\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, getDescription(alias)));\n addDeclUnique(hdrColors.rec2020, decl(aliasID, alias.value, getDescription(alias)));\n }\n }\n }\n }\n\n // multi-value token\n else {\n for (const [name, subValue] of Object.entries(token.value)) {\n const subValueID = makeSubValueId(localID, name, token);\n addDeclUnique(root, decl(subValueID, subValue, getDescription(token)));\n }\n // Note: always generate shorthand AFTER other declarations\n const shorthand = generateShorthand({\n token: { ...token.token, $value: token.value as any },\n localID,\n omitTypographyShorthand,\n });\n if (shorthand) {\n addDeclUnique(root, decl(localID, shorthand, getDescription(token)));\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, getDescription(token)));\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 if (propertyDefsNodes.length && output) {\n output = `${printRules(propertyDefsNodes)}\\n\\n${output}`;\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, getDescription(token)));\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!, getDescription(token)));\n\n if (token.value.p3 !== token.value.srgb) {\n addDeclUnique(p3Rule.children, decl(localID, token.value.p3!, getDescription(token)));\n addDeclUnique(rec2020Rule.children, decl(localID, token.value.rec2020!, getDescription(token)));\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, getDescription(alias)));\n addDeclUnique(rec2020Rule.children, decl(alias.localID, alias.value, getDescription(alias)));\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 : makeSubValueId(localID, name, token);\n addDeclUnique(rootRule.children, decl(property, value, getDescription(token)));\n }\n // Note: always place shorthand after other values\n const shorthand = generateShorthand({\n token: { ...token.token, $value: token.value as any },\n localID,\n omitTypographyShorthand,\n });\n if (shorthand) {\n addDeclUnique(rootRule.children, decl(token.localID ?? token.token.id, shorthand, getDescription(token)));\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 aliasedBy = token.token.mode[selector.mode]?.aliasedBy?.length\n ? token.token.mode[selector.mode]!.aliasedBy\n : token.token.aliasedBy;\n let aliasTokens = aliasedBy?.length\n ? getTransforms({ format: FORMAT_ID, id: aliasedBy, mode: selector.mode })\n : [];\n // Note: this will grab aliases from alternate and default modes. If we have duplicates, discard the default modes\n const uniqueAliasIDs = new Set(aliasTokens.map((t) => t.id));\n if (uniqueAliasIDs.size !== aliasTokens.length && selector.mode !== '.') {\n aliasTokens = aliasTokens.filter(\n (t, i) => !aliasTokens.some((t2, i2) => t.id === t2.id && i !== i2 && t.mode === '.'),\n );\n }\n\n // single-value token\n if (token.type === 'SINGLE_VALUE') {\n addDeclUnique(modeRule.children, decl(localID, token.value, getDescription(token)));\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!, getDescription(token)));\n if (token.value.p3 !== token.value.srgb) {\n addDeclUnique(hdrColors.p3, decl(localID, token.value.p3!, getDescription(token)));\n addDeclUnique(hdrColors.rec2020, decl(localID, token.value.rec2020!, getDescription(token)));\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, getDescription(alias)));\n }\n }\n }\n }\n }\n\n // multi-value token\n else {\n for (const [name, subValue] of Object.entries(token.value)) {\n const subValueID = makeSubValueId(localID, name, token);\n addDeclUnique(modeRule.children, decl(subValueID, subValue, getDescription(token)));\n }\n // Note: always generate shorthand after other declarations\n const shorthand = generateShorthand({\n token: { ...token.token, $value: token.value as any },\n localID,\n omitTypographyShorthand,\n });\n if (shorthand) {\n addDeclUnique(modeRule.children, decl(localID, shorthand, getDescription(token)));\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, getDescription(token)));\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 if (propertyDefsNodes.length && output) {\n output = `${printRules(propertyDefsNodes)}\\n\\n${output}`;\n }\n\n return output;\n}\n","import type { TokenNormalized, TransformHookOptions } from '@terrazzo/parser';\nimport { makeCSSVar, type TransformCSSValueOptions, 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 (Array.isArray(permutations)) {\n // For backwards-compat, if this resolver allows a “default” input,\n // also duplicate the token in the global space. This plays nicer with\n // plugins that haven’t upgraded to resolvers yet.\n // If there is no “default” permutation, then take the first one\n let defaultPermutationI = permutations.findIndex((p) => !Object.keys(p.input ?? {}).length);\n if (defaultPermutationI === -1) {\n defaultPermutationI = 0;\n }\n\n for (let i = 0; i < permutations.length; i++) {\n const p = permutations[i]!;\n const inputRaw = p.input;\n const input = !Object.keys(inputRaw ?? {}).length\n ? (JSON.parse(resolver.getPermutationID(inputRaw ?? {})) as Record<string, string>)\n : inputRaw;\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 // 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 options: TransformCSSValueOptions = {\n tokensSet: tokens,\n transformAlias,\n color: { legacyHex },\n permutation: input,\n };\n const value =\n p.transform?.(token, options) ?? customTransform?.(token, options) ?? transformCSSValue(token, options);\n if (value) {\n const localID = transformName(token);\n setTransform(token.id, {\n format: FORMAT_ID,\n value,\n localID,\n input,\n // Store description in metadata for plugin-css to access later\n meta: {\n 'plugin-css': {\n description: token.$description,\n },\n 'token-listing': { name: localID },\n },\n });\n\n // If this is the default permutation, also duplicate to the default mode.\n // Be sure to only do this for ONE permutation! Otherwise output would break.\n if (defaultPermutationI === i) {\n setTransform(token.id, {\n format: FORMAT_ID,\n value,\n localID,\n mode: '.',\n // Store description in metadata for plugin-css to access later\n meta: {\n 'plugin-css': {\n description: token.$description,\n },\n 'token-listing': { name: localID },\n },\n });\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 tokenArgs: TokenNormalized = { ...token, ...(token.mode[mode] as any) };\n const options: TransformCSSValueOptions = {\n tokensSet: baseTokens,\n transformAlias,\n color: { legacyHex },\n permutation: { tzMode: '*' },\n };\n const value = customTransform?.(tokenArgs, options) ?? transformCSSValue(tokenArgs, options);\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: {\n 'plugin-css': {\n description: token.$description,\n },\n 'token-listing': { name: localID },\n },\n });\n }\n }\n }\n}\n","import type { Plugin } from '@terrazzo/parser';\nimport buildCSS from './build.js';\nimport { type CSSPluginOptions, FILE_PREFIX, 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, propertyDefinitions } = 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 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 propertyDefinitions: propertyDefinitions ?? false,\n logger: context.logger,\n omitTypographyShorthand: options?.omitTypographyShorthand,\n subValueVariableName: options?.subValueVariableName,\n });\n outputFile(filename, contents.replace(/\\n*$/, '\\n'));\n },\n };\n}\n"],"mappings":";;;AASA,MAAa,cAAc;AAE3B,MAAa,YAAY;AAEzB,MAAa,gBAAgB,IAAI,sBAAsB;AAEvD,MAAa,cAAc;;;;;;;;;;;;;;;;AAqI3B,SAAgB,WACd,OACA,EAAE,aAAa,MAAM,WAAW,MAAkD,CAAC,GAC3E;CACR,IAAI,SAAS;CACb,KAAK,MAAM,QAAQ,OAAO;EACxB,IAAI,UAAU,KAAK,SAAS,QAC1B,UAAU;EAEZ,UAAU,UAAU,MAAM;GAAE;GAAY;EAAS,CAAC;CACpD;CACA,OAAO,OAAO,KAAK;AACrB;;AAGA,SAAgB,UACd,MACA,EAAE,YAAY,YACN;CACR,IAAI,SAAS;CAEb,MAAM,SAAS,WAAW,OAAO,QAAQ;CAEzC,IAAI,KAAK,SAAS,eAAe;EAC/B,IAAI,KAAK,SACP,UAAU,GAAG,OAAO,KAAK,KAAK,QAAQ;EAExC,UAAU,GAAG,SAAS,KAAK,SAAS,IAAI,KAAK,MAAM;EACnD,OAAO;CACT;CAEA,I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AU,kBAAkB;GAChC,aAAa;IAAE,WAAW;IAAkB,SAAS,WAAW,CAAC;GAAE,CAAC;EACtE;EACA,MAAM,MAAM,EAAE,eAAe,YAAY,WAAW;GAClD,IAAI,cAAc,MAChB;GAGF,IAAI,WAAW,GAAG,YAAY;GAC9B,YAAY,SAAS;IACnB,SAAS,SAAS;IAClB,SAAS,SAAS;IAClB;IACA,cAAc,SAAS;IACvB,eAAe,SAAS;IACxB;IACA;IACA;IACA,qBAAqB,uBAAuB;IAC5C,QAAQ,QAAQ;IAChB,yBAAyB,SAAS;IAClC,sBAAsB,SAAS;GACjC,CAAC;GACD,WAAW,UAAU,SAAS,QAAQ,QAAQ,IAAI,CAAC;EACrD;CACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@terrazzo/plugin-css",
3
- "version": "2.0.3",
3
+ "version": "2.2.0",
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,16 +27,16 @@
27
27
  "directory": "./packages/plugin-css/"
28
28
  },
29
29
  "peerDependencies": {
30
- "@terrazzo/cli": "^2.0.3",
31
- "@terrazzo/parser": "^2.0.3"
30
+ "@terrazzo/cli": "^2.2.0",
31
+ "@terrazzo/parser": "^2.2.0"
32
32
  },
33
33
  "dependencies": {
34
- "@terrazzo/token-tools": "^2.0.3"
34
+ "@terrazzo/token-tools": "^2.2.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "dtcg-examples": "^1.0.3",
38
- "@terrazzo/cli": "^2.0.3",
39
- "@terrazzo/parser": "^2.0.3"
38
+ "@terrazzo/cli": "^2.2.0",
39
+ "@terrazzo/parser": "^2.2.0"
40
40
  },
41
41
  "scripts": {
42
42
  "build": "rolldown -c && attw --profile esm-only --pack .",