@designtools/tokens 0.11.1 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -6,13 +6,16 @@ import {
6
6
  SHADE_PRESETS,
7
7
  TOKEN_SECTIONS,
8
8
  VALID_SHADES,
9
+ applyScaleOverrides,
9
10
  bridgeShade,
10
11
  checkRampChroma,
11
12
  checkSemanticContrast,
12
13
  checkSemanticContrastAPCA,
13
14
  checkSurfaceContrast,
14
15
  computeAccessibilityScore,
16
+ defaultScale,
15
17
  diffSlice,
18
+ exportScale,
16
19
  exportTokens,
17
20
  extendedBridgeShades,
18
21
  externalReferences,
@@ -33,16 +36,127 @@ import {
33
36
  serialiseUsage,
34
37
  snapShade,
35
38
  stepContract,
39
+ suggestStep,
36
40
  tokenFamilies,
37
41
  usageReport,
38
42
  withJsonProvenance
39
- } from "./chunk-2UR5FIHQ.js";
43
+ } from "./chunk-HK7ME2YV.js";
40
44
 
41
45
  // src/cli.ts
42
- import { parseArgs } from "util";
43
- import { mkdirSync, writeFileSync, readFileSync, statSync } from "fs";
44
- import { join, dirname } from "path";
46
+ import { parseArgs as parseArgs2 } from "util";
47
+ import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2, readFileSync as readFileSync2, statSync } from "fs";
48
+ import { join as join2, dirname } from "path";
45
49
  import { fileURLToPath } from "url";
50
+
51
+ // src/scale-cli.ts
52
+ import { mkdirSync, readFileSync, writeFileSync } from "fs";
53
+ import { join } from "path";
54
+ import { parseArgs } from "util";
55
+ var FORMATS = ["css", "tailwind-v4", "tailwind-v3", "dtcg", "json"];
56
+ var FILE_NAMES = {
57
+ css: "scale.css",
58
+ "tailwind-v4": "scale.css",
59
+ "tailwind-v3": "tailwind.scale.js",
60
+ dtcg: "scale.dtcg.json",
61
+ json: "scale.json"
62
+ };
63
+ var SCALE_HELP = `generate-tokens scale: the non-colour scale, from defaults and your overrides
64
+
65
+ generate-tokens scale --format tailwind-v4 --out app/styles/scale.css
66
+ generate-tokens scale --format css --overrides scale.overrides.json --out src/scale.css
67
+ generate-tokens scale --format all --out ./tokens
68
+
69
+ Space (--spacing), size (--size-*), type sizes with their line height and tracking (--text-*,
70
+ --leading-*, --tracking-*, --font-weight-*), corners (--radius-*), elevation (--shadow-*),
71
+ motion (--duration-*, --ease-*), screen sizes (--breakpoint-*) and widths (--container-*).
72
+ The names are the contract; retune the values with --overrides, never by editing the file.
73
+
74
+ --format <fmt> css | tailwind-v4 | tailwind-v3 | dtcg | json | all. Default: css.
75
+ css writes screen sizes as @custom-media too, since a variable can't go in @media.
76
+ --overrides <file> JSON, by token name: { "--radius-md": "0.5rem", "--text-5xl": { "value":
77
+ "3rem", "description": "48px: page titles" }, "--leading-relaxed": null }.
78
+ A new name joins the tier its prefix belongs to; null removes a token.
79
+ --out <path> File to write, or a directory with --format all. Default: stdout.
80
+ --check Compare against the file at --out instead of writing it. Exit 1 if it differs.
81
+ --no-provenance Leave out the "Generated by" header.
82
+ `;
83
+ function runScale(argv, version) {
84
+ const fail2 = (message) => {
85
+ process.stderr.write(`generate-tokens scale: ${message}
86
+ `);
87
+ return 1;
88
+ };
89
+ let values2;
90
+ try {
91
+ ({ values: values2 } = parseArgs({
92
+ args: argv,
93
+ options: {
94
+ format: { type: "string" },
95
+ overrides: { type: "string" },
96
+ out: { type: "string" },
97
+ check: { type: "boolean" },
98
+ "no-provenance": { type: "boolean" },
99
+ help: { type: "boolean", short: "h" }
100
+ }
101
+ }));
102
+ } catch (err) {
103
+ return fail2(err instanceof Error ? err.message : String(err));
104
+ }
105
+ if (values2.help) {
106
+ process.stdout.write(SCALE_HELP);
107
+ return 0;
108
+ }
109
+ const format2 = values2.format ?? "css";
110
+ if (format2 !== "all" && !FORMATS.includes(format2)) return fail2(`--format must be one of ${[...FORMATS, "all"].join(", ")}`);
111
+ if (values2.check && !values2.out) return fail2("--check needs --out to compare against");
112
+ let overrides2 = {};
113
+ if (values2.overrides) {
114
+ try {
115
+ overrides2 = JSON.parse(readFileSync(values2.overrides, "utf8"));
116
+ } catch (err) {
117
+ return fail2(`can't read --overrides ${values2.overrides}: ${err instanceof Error ? err.message : String(err)}`);
118
+ }
119
+ }
120
+ let tiers;
121
+ try {
122
+ tiers = applyScaleOverrides(defaultScale(), overrides2);
123
+ } catch (err) {
124
+ return fail2(err instanceof Error ? err.message : String(err));
125
+ }
126
+ const header = values2["no-provenance"] ? void 0 : `/* Generated by @designtools/tokens v${version} (scale${values2.overrides ? `, overrides ${values2.overrides}` : ""}) - retune with --overrides, do not edit by hand */`;
127
+ const formats2 = format2 === "all" ? FORMATS.filter((f) => f !== "tailwind-v4") : [format2];
128
+ const target = (f) => format2 === "all" ? join(values2.out ?? ".", FILE_NAMES[f]) : values2.out;
129
+ if (values2.check) {
130
+ let ok = true;
131
+ for (const f of formats2) {
132
+ const want = exportScale(tiers, f, header);
133
+ let have = "";
134
+ try {
135
+ have = readFileSync(target(f), "utf8");
136
+ } catch {
137
+ }
138
+ const same = have === want;
139
+ process.stderr.write(same ? `check: ${target(f)} up to date
140
+ ` : `check: ${target(f)} differs from the scale and its overrides; regenerate it
141
+ `);
142
+ ok &&= same;
143
+ }
144
+ return ok ? 0 : 1;
145
+ }
146
+ if (!values2.out) {
147
+ process.stdout.write(exportScale(tiers, formats2[0], header));
148
+ return 0;
149
+ }
150
+ if (format2 === "all") mkdirSync(values2.out, { recursive: true });
151
+ for (const f of formats2) {
152
+ writeFileSync(target(f), exportScale(tiers, f, header));
153
+ process.stderr.write(`wrote ${target(f)}
154
+ `);
155
+ }
156
+ return 0;
157
+ }
158
+
159
+ // src/cli.ts
46
160
  var HELP = `generate-tokens \u2014 brand colour in, design tokens out
47
161
 
48
162
  Usage:
@@ -68,22 +182,42 @@ Seeds:
68
182
  The page, card and overlay backgrounds as exact colours
69
183
  (light, then dark after a slash), in place of the
70
184
  neutral steps they default to. Text on each is measured.
71
- --background <name>=<colour>[/<dark>]
72
- A colour a whole section is painted with (a band on a
73
- marketing page), not a ramp: --surface-<name> with
74
- measured text, and a ground. Inside data-surface="<name>"
75
- every token (buttons, muted text, borders, inputs, the
76
- ring, status text) is searched again against it, so
77
- components need no change. Repeatable. A name a token or
78
- ground already uses (canvas, primary, warning-subdued\u2026)
79
- is refused.
80
- --grounds <full|text|none>
81
- What data-surface gives each ground. full (default):
82
- every token, tinted to the ground and contrast-checked
83
- on it. text: the background and its text only; buttons,
84
- borders and the rest keep the page's. none: no grounds.
185
+ --page-surface <name>=<ramp>@<step>[/<ramp>@<step>]
186
+ Another page surface beside canvas, surface and overlay:
187
+ a sunken well, a raised panel, an alternate section. A
188
+ step for light, then dark (default: the light step's
189
+ mirror, 100 to 800). Follows the mode. Emitted as
190
+ --<name> with measured --<name>-foreground, and every
191
+ page token is searched to work on it. Repeatable.
192
+ --ground <name>=<ramp>@<step>
193
+ A section painted one step of a ramp (a --color, often
194
+ --decorative, or primary for a brand band), the same in
195
+ light and dark mode. Inside data-surface="<name>",
196
+ content reads tokens that work on it: the page's of the
197
+ ground's polarity, and what --ground-tint and
198
+ --ground-text change. Repeatable.
199
+ --ground-tint <fill> or <name>=<fill>
200
+ Where a ground's lines, panels, card, input edge, ring
201
+ and buttons come from. own (default): steps on its
202
+ ramp, each searched to its floor. page: the page's.
203
+ Or one colour for every line, edge and ring: white,
204
+ black, or a step (sage-100). A bare value sets every
205
+ ground; name=value one, and wins. Repeatable.
206
+ --ground-text <fill> or <name>=<fill>
207
+ Where a ground's body and secondary text come from. page
208
+ (default): the page's, where it reads; white or black
209
+ where it doesn't. own: steps on its ramp. Or one
210
+ colour for both. Repeatable, as --ground-tint.
211
+ --ground-action <action> or <name>=<action>
212
+ Where a ground's main button (--primary, its label and
213
+ states) comes from. Unset, it follows the tint. page:
214
+ the page's button as it is, wherever it lands (a pale
215
+ brand colour its label carries). own: the ground's own
216
+ colour, turned over on its ramp. Or a colour, with its
217
+ label measured on it or after a slash:
218
+ neutral-950/primary-400. Repeatable, as --ground-tint.
85
219
  --usage <file.json> Also write where each colour can go: every fill, status
86
- text tone and muted text on every background, per mode,
220
+ text tone and secondary text on every background, per mode,
87
221
  as text, shape or neither. @designtools/manifest reads it
88
222
  (manifest.usage) and writes the failures as usage rules.
89
223
  --check compares it too.
@@ -163,8 +297,8 @@ Selection:
163
297
  --only <sections> Emit only these slices, comma-separated or repeated:
164
298
  ramp the twelve-step colour ramps alone
165
299
  primitives the ramps plus black and white
166
- semantic intent tokens (primary, destructive, muted, \u2026)
167
- surface canvas / surface / overlay
300
+ semantic intent tokens (primary, destructive, \u2026)
301
+ surface canvas / surface / overlay, each with its text and secondary text
168
302
  utility border / input / ring / shadow
169
303
  grounds --on-<ground>-* and the data-surface scopes
170
304
  Keeps generated colour separable from hand-tuned files,
@@ -210,9 +344,9 @@ Verification:
210
344
  With --ramps or --merge, only the declarations this run
211
345
  generates are compared, so hand-edited regions elsewhere
212
346
  in the file are not reported as drift.
213
- --no-aliases Emit each status ramp once, as success, destructive and
214
- warning, without green, red and yellow beside them as
215
- the same ramps.
347
+ --aliases Also emit green, red and yellow beside success,
348
+ destructive and warning, as the same ramps, so
349
+ bg-red-500 matches. Off by default from 0.12.
216
350
  --contract Print the step contract: each step that carries text on
217
351
  white (or black) in some colours and not others, so
218
352
  "the 700" means the same everywhere. Measured, not
@@ -228,7 +362,7 @@ Input:
228
362
 
229
363
  --help Show this help.
230
364
  `;
231
- var FILE_NAMES = {
365
+ var FILE_NAMES2 = {
232
366
  css: "tokens.css",
233
367
  "tailwind-v4": "tailwind.css",
234
368
  "tailwind-v3": "tailwind.config.js",
@@ -238,11 +372,12 @@ var FILE_NAMES = {
238
372
  var VERSION = (() => {
239
373
  try {
240
374
  const here = dirname(fileURLToPath(import.meta.url));
241
- return JSON.parse(readFileSync(join(here, "../package.json"), "utf8")).version;
375
+ return JSON.parse(readFileSync2(join2(here, "../package.json"), "utf8")).version;
242
376
  } catch {
243
377
  return "0.0.0";
244
378
  }
245
379
  })();
380
+ if (process.argv[2] === "scale") process.exit(runScale(process.argv.slice(3), VERSION));
246
381
  function fail(message) {
247
382
  process.stderr.write(`generate-tokens: ${message}
248
383
  `);
@@ -250,7 +385,7 @@ function fail(message) {
250
385
  }
251
386
  var values;
252
387
  try {
253
- ({ values } = parseArgs({
388
+ ({ values } = parseArgs2({
254
389
  options: {
255
390
  primary: { type: "string" },
256
391
  neutral: { type: "string" },
@@ -267,6 +402,11 @@ try {
267
402
  foreground: { type: "string" },
268
403
  "no-wcag-floor": { type: "boolean" },
269
404
  grounds: { type: "string" },
405
+ ground: { type: "string", multiple: true },
406
+ "page-surface": { type: "string", multiple: true },
407
+ "ground-tint": { type: "string", multiple: true },
408
+ "ground-text": { type: "string", multiple: true },
409
+ "ground-action": { type: "string", multiple: true },
270
410
  gamut: { type: "string" },
271
411
  "seed-shade": { type: "string" },
272
412
  "neutral-seed-shade": { type: "string" },
@@ -279,6 +419,7 @@ try {
279
419
  "hue-drift": { type: "string" },
280
420
  pin: { type: "string", multiple: true },
281
421
  "no-aliases": { type: "boolean" },
422
+ aliases: { type: "boolean" },
282
423
  shades: { type: "string" },
283
424
  overrides: { type: "string" },
284
425
  only: { type: "string", multiple: true },
@@ -309,14 +450,14 @@ if (values.help) {
309
450
  var seed = {};
310
451
  if (values.stdin) {
311
452
  try {
312
- seed = JSON.parse(readFileSync(0, "utf8"));
453
+ seed = JSON.parse(readFileSync2(0, "utf8"));
313
454
  } catch (err) {
314
455
  fail(`could not read seed from stdin: ${err instanceof Error ? err.message : String(err)}`);
315
456
  }
316
457
  }
317
458
  if (values.seed) {
318
459
  try {
319
- seed = JSON.parse(readFileSync(values.seed, "utf8"));
460
+ seed = JSON.parse(readFileSync2(values.seed, "utf8"));
320
461
  } catch (err) {
321
462
  fail(`could not read --seed file: ${err instanceof Error ? err.message : String(err)}`);
322
463
  }
@@ -382,7 +523,9 @@ var contrastTarget = validateChoice("target", values.target ?? seed.contrastTarg
382
523
  var lightnessStrategy = validateChoice("lightness", values.lightness ?? seed.lightnessStrategy, ["fixed", "perceptual"], "fixed");
383
524
  var foreground = validateChoice("foreground", values.foreground ?? seed.foreground, ["balanced", "max"], "balanced");
384
525
  var wcagFloor = values["no-wcag-floor"] === true ? false : seed.wcagFloor ?? true;
385
- var grounds = validateChoice("grounds", values.grounds ?? seed.grounds, ["full", "text", "none"], "full");
526
+ if (values.grounds !== void 0 || typeof seed.grounds === "string") {
527
+ fail(`--grounds is gone from 0.12: grounds are declared with --ground <name>=<ramp>@<step>, and a project without one has none. --grounds text is --ground-tint page.`);
528
+ }
386
529
  function lightDark(flag, raw) {
387
530
  const [light, dark] = raw.split("/").map((s) => s.trim());
388
531
  return { light: validateColor(flag, light), ...dark ? { dark: validateColor(flag, dark) } : {} };
@@ -397,13 +540,88 @@ for (const key of ["canvas", "surface", "overlay"]) {
397
540
  surfaceColors.light[key] = light;
398
541
  if (dark) surfaceColors.dark[key] = dark;
399
542
  }
400
- var backgrounds = { ...seed.backgrounds ?? {} };
401
- for (const entry of values.background ?? []) {
543
+ var oldBackgrounds = [
544
+ ...(values.background ?? []).map((entry) => {
545
+ const [light, dark] = entry.slice(entry.indexOf("=") + 1).split("/").map((x) => x.trim());
546
+ return [entry.slice(0, entry.indexOf("=")).trim(), light, dark];
547
+ }),
548
+ ...Object.entries(seed.backgrounds ?? {}).map(
549
+ ([name, bg]) => [name, bg.light, bg.dark]
550
+ )
551
+ ];
552
+ if (oldBackgrounds.length) {
553
+ const lines = oldBackgrounds.map(([name, light, dark]) => {
554
+ if (dark && dark !== light) return ` --page-surface "${name}=${light}/${dark}"`;
555
+ const step = suggestStep(validateColor(`--background ${name}`, light));
556
+ return ` --color "${name}=${light}@${step}" --decorative ${name} --ground "${name}=${name}@${step}"`;
557
+ });
558
+ fail(`--background is gone from 0.12. A section that changes with the mode is a page surface; one painted the same in both is a ground on a ramp. In its place:
559
+ ${lines.join("\n")}`);
560
+ }
561
+ function validateFill(flag, raw) {
562
+ const v = raw.trim();
563
+ if (v === "page" || v === "own" || v === "white" || v === "black" || /^[a-z][a-z0-9-]*-\d+$/.test(v)) return v;
564
+ fail(`--${flag} must be page, own, white, black or a step such as sage-100 (got "${raw}")`);
565
+ }
566
+ function validateAction(flag, raw) {
567
+ const v = raw.trim();
568
+ const colour = (c) => c === "white" || c === "black" || /^[a-z][a-z0-9-]*-\d+$/.test(c);
569
+ const [fill, label, extra] = v.split("/");
570
+ if (v === "page" || v === "own" || colour(fill) && (label === void 0 || colour(label)) && extra === void 0) return v;
571
+ fail(`--${flag} must be page, own, or a colour such as neutral-950, with its label after a slash if you name it (neutral-950/primary-400) (got "${raw}")`);
572
+ }
573
+ function rampStep(flag, raw) {
574
+ const m = /^([a-z][a-z0-9-]*)@(\d+)$/.exec(raw.trim());
575
+ if (!m || !VALID_SHADES.includes(Number(m[2]))) fail(`${flag} expects <ramp>@<step>, with a step of ${VALID_SHADES.join(", ")} (got "${raw}")`);
576
+ return { ramp: m[1], step: Number(m[2]) };
577
+ }
578
+ var pageSurfaces = { ...seed.pageSurfaces ?? {} };
579
+ for (const entry of values["page-surface"] ?? []) {
402
580
  const eq = entry.indexOf("=");
403
- if (eq === -1) fail(`--background expects name=colour (got "${entry}")`);
581
+ if (eq === -1) fail(`--page-surface expects name=<ramp>@<step>[/<ramp>@<step>] (got "${entry}")`);
404
582
  const name = entry.slice(0, eq).trim();
405
- if (!/^[a-z][a-z0-9-]*$/.test(name) || name === "foreground") fail(`--background name must be lower-case kebab-case, and not "foreground" (got "${name}")`);
406
- backgrounds[name] = lightDark(`--background ${name}`, entry.slice(eq + 1));
583
+ if (!/^[a-z][a-z0-9-]*$/.test(name)) fail(`--page-surface name must be lower-case kebab-case (got "${name}")`);
584
+ const [light, dark] = entry.slice(eq + 1).split("/").map((x) => x.trim());
585
+ const check2 = (v) => v.includes("@") ? rampStep(`--page-surface ${name}`, v) : validateColor(`--page-surface ${name}`, v);
586
+ check2(light);
587
+ if (dark) check2(dark);
588
+ pageSurfaces[name] = { light, ...dark ? { dark } : {} };
589
+ }
590
+ var grounds = { ...seed.grounds ?? {} };
591
+ for (const entry of values.ground ?? []) {
592
+ const eq = entry.indexOf("=");
593
+ if (eq === -1) fail(`--ground expects name=<ramp>@<step> (got "${entry}")`);
594
+ const name = entry.slice(0, eq).trim();
595
+ if (!/^[a-z][a-z0-9-]*$/.test(name) || name === "canvas") fail(`--ground name must be lower-case kebab-case, and not "canvas" (got "${name}")`);
596
+ const { tint, text, action } = grounds[name] ?? {};
597
+ grounds[name] = { ...rampStep(`--ground ${name}`, entry.slice(eq + 1)), ...tint ? { tint } : {}, ...text ? { text } : {}, ...action ? { action } : {} };
598
+ }
599
+ function fills(flag, key, seeded, fallback) {
600
+ let all = seeded ?? fallback;
601
+ for (const entry of values[flag] ?? []) {
602
+ const eq = entry.indexOf("=");
603
+ if (eq === -1) {
604
+ all = validateFill(flag, entry);
605
+ continue;
606
+ }
607
+ const name = entry.slice(0, eq).trim();
608
+ if (!grounds[name]) fail(`--${flag} names no ground: ${name} (grounds: ${Object.keys(grounds).join(", ") || "none"})`);
609
+ grounds[name] = { ...grounds[name], [key]: validateFill(`${flag} ${name}`, entry.slice(eq + 1)) };
610
+ }
611
+ return all;
612
+ }
613
+ var groundTint = fills("ground-tint", "tint", seed.groundTint, "own");
614
+ var groundText = fills("ground-text", "text", seed.groundText, "page");
615
+ var groundAction = seed.groundAction;
616
+ for (const entry of values["ground-action"] ?? []) {
617
+ const eq = entry.indexOf("=");
618
+ if (eq === -1) {
619
+ groundAction = validateAction("ground-action", entry);
620
+ continue;
621
+ }
622
+ const name = entry.slice(0, eq).trim();
623
+ if (!grounds[name]) fail(`--ground-action names no ground: ${name} (grounds: ${Object.keys(grounds).join(", ") || "none"})`);
624
+ grounds[name] = { ...grounds[name], action: validateAction(`ground-action ${name}`, entry.slice(eq + 1)) };
407
625
  }
408
626
  var hasSurfaceColors = Object.keys(surfaceColors.light).length + Object.keys(surfaceColors.dark).length > 0;
409
627
  var gamut = validateChoice("gamut", values.gamut ?? seed.gamut, ["srgb", "p3"], "srgb");
@@ -478,7 +696,7 @@ for (const raw of values.pin ?? []) {
478
696
  }
479
697
  }
480
698
  var hasPins = Object.keys(pins).length > 0;
481
- var aliases = values["no-aliases"] === true ? false : seed.aliases ?? true;
699
+ var aliases = values.aliases === true ? true : values["no-aliases"] === true ? false : seed.aliases ?? false;
482
700
  var seedShades = {};
483
701
  if (neutralSeedShade !== void 0) seedShades.neutral = neutralSeedShade;
484
702
  for (const [name, { flag, raw }] of Object.entries(additionalAnchors)) {
@@ -526,7 +744,7 @@ var overrides = {
526
744
  };
527
745
  if (values.overrides) {
528
746
  try {
529
- overrides = JSON.parse(readFileSync(values.overrides, "utf8"));
747
+ overrides = JSON.parse(readFileSync2(values.overrides, "utf8"));
530
748
  } catch (err) {
531
749
  fail(`could not read --overrides file: ${err instanceof Error ? err.message : String(err)}`);
532
750
  }
@@ -543,8 +761,11 @@ var options = {
543
761
  ...foreground !== "balanced" ? { foreground } : {},
544
762
  ...!wcagFloor ? { wcagFloor } : {},
545
763
  ...hasSurfaceColors ? { surfaceColors } : {},
546
- ...Object.keys(backgrounds).length ? { backgrounds } : {},
547
- ...grounds !== "full" ? { grounds } : {},
764
+ ...Object.keys(pageSurfaces).length ? { pageSurfaces } : {},
765
+ ...Object.keys(grounds).length ? { grounds } : {},
766
+ ...groundTint !== "own" ? { groundTint } : {},
767
+ ...groundText !== "page" ? { groundText } : {},
768
+ ...groundAction ? { groundAction } : {},
548
769
  seedShade,
549
770
  ...Object.keys(seedShades).length > 0 ? { seedShades } : {},
550
771
  ...lightnessRange ? { lightnessRange: { ...lightnessRange.light !== void 0 ? { light: lightnessRange.light / 100 } : {}, ...lightnessRange.dark !== void 0 ? { dark: lightnessRange.dark / 100 } : {} } } : {},
@@ -553,7 +774,7 @@ var options = {
553
774
  ...hueDrift !== void 0 ? { hueDrift } : {},
554
775
  ...familyShapes ? { families: familiesOf({ families: familyShapes }) } : {},
555
776
  ...hasPins ? { pins } : {},
556
- ...aliases ? {} : { aliases: false },
777
+ ...aliases ? { aliases: true } : {},
557
778
  ...decorative.size > 0 ? { decorative: [...decorative].sort() } : {},
558
779
  shades,
559
780
  shadeOverrides: overrides.shadeOverrides ?? {},
@@ -613,10 +834,10 @@ if (families.length > 0) {
613
834
  }
614
835
  if (shades) {
615
836
  const named = [
616
- ["muted (light)", 100],
617
- ["muted-foreground (light)", 500],
618
- ["muted (dark)", 800],
619
- ["muted-foreground (dark)", 200],
837
+ ["neutral subdued (light)", 100],
838
+ ["secondary text (light)", 500],
839
+ ["neutral subdued (dark)", 800],
840
+ ["secondary text (dark)", 200],
620
841
  ["canvas (light)", 25],
621
842
  ["canvas (dark)", 950],
622
843
  ["semantic DEFAULT (light)", 500],
@@ -654,9 +875,12 @@ var resolvedSeed = {
654
875
  ...foreground !== "balanced" ? { foreground } : {},
655
876
  ...!wcagFloor ? { wcagFloor } : {},
656
877
  ...hasSurfaceColors ? { surfaceColors } : {},
657
- ...Object.keys(backgrounds).length ? { backgrounds } : {},
658
- // left out at the default, so a seed from before grounds keeps its fingerprint
659
- ...grounds !== "full" ? { grounds } : {},
878
+ // left out when unset, so a seed without them keeps its fingerprint
879
+ ...Object.keys(pageSurfaces).length ? { pageSurfaces } : {},
880
+ ...Object.keys(grounds).length ? { grounds } : {},
881
+ ...groundTint !== "own" ? { groundTint } : {},
882
+ ...groundText !== "page" ? { groundText } : {},
883
+ ...groundAction ? { groundAction } : {},
660
884
  seedShade,
661
885
  neutralSeedShade,
662
886
  // left out when unset, so a seed without them keeps the fingerprint it always had
@@ -667,7 +891,7 @@ var resolvedSeed = {
667
891
  ...familyShapes ? { families: familyShapes } : {},
668
892
  ...hasPins ? { pins } : {},
669
893
  // left out when on, the default, so existing seeds keep their fingerprint
670
- ...aliases ? {} : { aliases: false },
894
+ ...aliases ? { aliases: true } : {},
671
895
  shades,
672
896
  shadeOverrides: options.shadeOverrides ?? {},
673
897
  surfaceShadeOverrides: options.surfaceShadeOverrides,
@@ -704,7 +928,7 @@ ${body}`;
704
928
  }
705
929
  function targetPath(fmt, out) {
706
930
  try {
707
- if (statSync(out).isDirectory()) return join(out, FILE_NAMES[fmt]);
931
+ if (statSync(out).isDirectory()) return join2(out, FILE_NAMES2[fmt]);
708
932
  } catch {
709
933
  }
710
934
  return out;
@@ -712,7 +936,7 @@ function targetPath(fmt, out) {
712
936
  function check(fmt, target) {
713
937
  let existing;
714
938
  try {
715
- existing = readFileSync(target, "utf8");
939
+ existing = readFileSync2(target, "utf8");
716
940
  } catch {
717
941
  process.stderr.write(`check: ${target} does not exist
718
942
  `);
@@ -778,16 +1002,20 @@ fills moved from the offset table
778
1002
  ${moved.join("\n")}
779
1003
  `);
780
1004
  process.stderr.write(`
781
- searched to their contrast floor (ring and input 3:1 on canvas and surface; muted text on muted)
1005
+ searched to their contrast floor (ring and input 3:1 on canvas and surface; secondary text on its surface)
782
1006
  `);
783
1007
  for (const mode of ["light", "dark"]) {
784
1008
  const steps = tokens.utility[mode]._steps;
785
- const muted = tokens.semantic[mode].muted._shades;
786
- if (!steps || !muted) continue;
1009
+ const refs = tokens.surface[mode]._refs;
1010
+ if (!steps || !refs) continue;
787
1011
  const start = ringBridgeShade(mode, options.seedShade, active);
788
1012
  const moved2 = (from, to) => from === to ? `${to}` : `${to} (from ${from})`;
1013
+ const quiet = (key) => {
1014
+ const ref = refs[`${key}-foreground-secondary`];
1015
+ return ref.type === "shade" ? `${key} neutral-${moved2(snapShade(mode === "light" ? 500 : 200, active), ref.shade)}` : `${key} ${ref.type}`;
1016
+ };
789
1017
  process.stderr.write(
790
- ` ${mode.padEnd(6)} ring primary-${moved2(start, steps.ring)} input neutral-${moved2(snapShade(mode === "light" ? 200 : 800, active), steps.input)} muted-foreground neutral-${moved2(snapShade(mode === "light" ? 500 : 200, active), muted.foreground)}
1018
+ ` ${mode.padEnd(6)} ring primary-${moved2(start, steps.ring)} input neutral-${moved2(snapShade(mode === "light" ? 200 : 800, active), steps.input)} secondary text: ${quiet("canvas")}, ${quiet("surface")}, ${quiet("overlay")}
791
1019
  `
792
1020
  );
793
1021
  }
@@ -898,30 +1126,42 @@ ${mode} mode${label} (${contrastAlgorithm}, target ${contrastTarget})
898
1126
  reportGrounds();
899
1127
  }
900
1128
  function reportGrounds() {
901
- const grounds2 = tokens.grounds;
902
- if (!grounds2) return;
903
1129
  const step = (ref) => ref.type === "shade" ? `${ref.colorName}-${ref.shade}` : ref.type === "value" ? "computed" : ref.type;
904
- process.stderr.write(`
905
- grounds: what data-surface="<ground>" changes from the page (ratio against the ground; a label's against its fill)
1130
+ const under = (token) => token.startsWith("surface-foreground") ? "surface" : token.startsWith("canvas-foreground") ? "canvas" : token.endsWith("-foreground") ? token.slice(0, -"-foreground".length) : "canvas";
1131
+ const grounds2 = Object.entries(tokens.grounds ?? {});
1132
+ if (grounds2.length) {
1133
+ process.stderr.write(`
1134
+ grounds: what data-surface="<ground>" writes (ratio against the ground; a label's against its fill)
906
1135
  `);
907
- const under = (token) => token.endsWith("-foreground") && token !== "canvas-foreground" && token !== "muted-foreground" ? token.slice(0, -"-foreground".length) : "canvas";
908
- for (const mode of ["light", "dark"]) {
909
- for (const [name, g] of Object.entries(grounds2[mode])) {
910
- if (g.kind === "base") continue;
911
- const shown = g.changed.filter((t) => !t.endsWith("-hover") && !t.endsWith("-active"));
912
- const head = ` ${mode.padEnd(6)}${name.padEnd(22)}`;
913
- if (!shown.length) {
914
- process.stderr.write(`${head}the page's tokens already work here
1136
+ for (const [name, g] of grounds2) {
1137
+ process.stderr.write(` ${name.padEnd(14)}${g.ramp}@${g.step}, ${g.polarity}, text ${g.text}, tint ${g.tint}${g.action ? `, action ${g.action}` : ""}
915
1138
  `);
916
- } else {
917
- const items = shown.map((t) => `${t} ${step(g._refs[t])} ${getContrastRatio(g.tokens[t], g.tokens[under(t)]).toFixed(1)}`);
918
- process.stderr.write(`${head}${items.join(", ")}
1139
+ const shown = g.own.filter((t) => t !== "canvas" && !t.endsWith("-hover") && !t.endsWith("-active"));
1140
+ const items = shown.map((t) => `${t} ${step(g._refs[t])} ${getContrastRatio(g.tokens[t], g.tokens[under(t)]).toFixed(1)}`);
1141
+ process.stderr.write(` ${"".padEnd(14)}${items.length ? items.join(", ") : "the page's tokens work here as they are"}
919
1142
  `);
920
- }
921
- for (const note of g.notes) process.stderr.write(` ${"".padEnd(28)}! ${note}
1143
+ for (const note of g.notes) process.stderr.write(` ${"".padEnd(14)}! ${note}
922
1144
  `);
923
1145
  }
924
1146
  }
1147
+ const advice = [];
1148
+ for (const mode of ["light", "dark"]) {
1149
+ const semantic = tokens.semantic[mode];
1150
+ for (const status of ["success", "warning", "destructive"]) {
1151
+ const tint = semantic[status].subdued;
1152
+ for (const fill of ["primary", "neutral"]) {
1153
+ const ratio = getContrastRatio(semantic[fill].DEFAULT, tint);
1154
+ if (ratio < 3) advice.push(`${mode} ${fill} on ${status}-subdued ${ratio.toFixed(1)}:1`);
1155
+ }
1156
+ }
1157
+ }
1158
+ if (advice.length) {
1159
+ process.stderr.write(`
1160
+ banners (the -subdued tints): a filled button that blends in; use the outline button there
1161
+ `);
1162
+ process.stderr.write(` ${advice.join(", ")}
1163
+ `);
1164
+ }
925
1165
  }
926
1166
  if (values.report) report();
927
1167
  if (values.contract) {
@@ -935,7 +1175,7 @@ step contract (does a step mean the same in every colour?)
935
1175
  `);
936
1176
  }
937
1177
  }
938
- var formats = format === "all" ? Object.keys(FILE_NAMES) : [format];
1178
+ var formats = format === "all" ? Object.keys(FILE_NAMES2) : [format];
939
1179
  var isSlice = families.length > 0 || sections.length > 0;
940
1180
  function reportExternalReferences(css, merged) {
941
1181
  const external = externalReferences(css, merged?.css);
@@ -952,7 +1192,7 @@ function reportExternalReferences(css, merged) {
952
1192
  function checkSlice(target, slice) {
953
1193
  let existing;
954
1194
  try {
955
- existing = readFileSync(target, "utf8");
1195
+ existing = readFileSync2(target, "utf8");
956
1196
  } catch {
957
1197
  process.stderr.write(`check: ${target} does not exist
958
1198
  `);
@@ -986,7 +1226,7 @@ function checkUsage() {
986
1226
  if (!values.usage) return true;
987
1227
  let existing = "";
988
1228
  try {
989
- existing = readFileSync(values.usage, "utf8");
1229
+ existing = readFileSync2(values.usage, "utf8");
990
1230
  } catch {
991
1231
  process.stderr.write(`check: ${values.usage} is missing
992
1232
  `);
@@ -1006,13 +1246,13 @@ if (values.check) {
1006
1246
  if (isSlice) {
1007
1247
  process.exit(checkSlice(targetPath(format, out), serialise(format)) && checkUsage() ? 0 : 1);
1008
1248
  }
1009
- const ok = formats.map((fmt) => check(fmt, format === "all" ? join(out, FILE_NAMES[fmt]) : targetPath(fmt, out)));
1249
+ const ok = formats.map((fmt) => check(fmt, format === "all" ? join2(out, FILE_NAMES2[fmt]) : targetPath(fmt, out)));
1010
1250
  process.exit(ok.every(Boolean) && checkUsage() ? 0 : 1);
1011
1251
  } else if (values.merge) {
1012
1252
  const target = targetPath(format, values.out);
1013
1253
  let existing;
1014
1254
  try {
1015
- existing = readFileSync(target, "utf8");
1255
+ existing = readFileSync2(target, "utf8");
1016
1256
  } catch (err) {
1017
1257
  fail(`--merge needs an existing file at ${target}: ${err instanceof Error ? err.message : String(err)}`);
1018
1258
  }
@@ -1023,7 +1263,7 @@ if (values.check) {
1023
1263
  `--merge cannot place ${result.missingBlocks.length} block(s) absent from ${target}: ` + result.missingBlocks.join(", ")
1024
1264
  );
1025
1265
  }
1026
- writeFileSync(target, result.css);
1266
+ writeFileSync2(target, result.css);
1027
1267
  process.stderr.write(
1028
1268
  `merged into ${target}: ${result.updated.length} updated, ${result.added.length} added, ${result.unchanged.length} already current
1029
1269
  `
@@ -1031,10 +1271,10 @@ if (values.check) {
1031
1271
  reportExternalReferences(slice, { target, css: result.css });
1032
1272
  } else if (format === "all") {
1033
1273
  const dir = values.out ?? ".";
1034
- mkdirSync(dir, { recursive: true });
1274
+ mkdirSync2(dir, { recursive: true });
1035
1275
  for (const fmt of formats) {
1036
- const target = join(dir, FILE_NAMES[fmt]);
1037
- writeFileSync(target, serialise(fmt) + "\n");
1276
+ const target = join2(dir, FILE_NAMES2[fmt]);
1277
+ writeFileSync2(target, serialise(fmt) + "\n");
1038
1278
  process.stderr.write(`wrote ${target}
1039
1279
  `);
1040
1280
  }
@@ -1042,7 +1282,7 @@ if (values.check) {
1042
1282
  const output = serialise(format) + "\n";
1043
1283
  if (values.out) {
1044
1284
  const target = targetPath(format, values.out);
1045
- writeFileSync(target, output);
1285
+ writeFileSync2(target, output);
1046
1286
  process.stderr.write(`wrote ${target}
1047
1287
  `);
1048
1288
  } else {
@@ -1051,7 +1291,7 @@ if (values.check) {
1051
1291
  if (isSlice && SECTIONED_FORMATS.includes(format)) reportExternalReferences(output);
1052
1292
  }
1053
1293
  if (values.usage && !values.check) {
1054
- writeFileSync(values.usage, usageText);
1294
+ writeFileSync2(values.usage, usageText);
1055
1295
  process.stderr.write(`wrote ${values.usage}
1056
1296
  `);
1057
1297
  }