@motion-proto/live-tokens 0.50.0 → 0.53.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.
Files changed (91) hide show
  1. package/.claude/skills/live-tokens-adjust-shape-space/SKILL.md +7 -1
  2. package/CHANGELOG.md +108 -0
  3. package/bin/adjust.mjs +16 -39
  4. package/bin/generate-theme.mjs +20 -6
  5. package/dist-plugin/adjust/index.cjs +781 -21
  6. package/dist-plugin/adjust/index.d.cts +2 -1
  7. package/dist-plugin/adjust/index.d.ts +2 -1
  8. package/dist-plugin/adjust/index.js +43 -21
  9. package/dist-plugin/{chunk-6OZFXIQI.js → chunk-232GZGQU.js} +207 -12
  10. package/dist-plugin/chunk-NE6N66EE.js +753 -0
  11. package/dist-plugin/{chunk-76TFDTJO.js → chunk-PB2JTK2H.js} +179 -128
  12. package/dist-plugin/{chunk-44RSTAII.js → chunk-TKZBVIW5.js} +33 -5
  13. package/dist-plugin/chunk-YR6GPXW2.js +129 -0
  14. package/dist-plugin/generateColorsAndType/index.cjs +135 -63
  15. package/dist-plugin/generateColorsAndType/index.d.cts +2 -1
  16. package/dist-plugin/generateColorsAndType/index.d.ts +2 -1
  17. package/dist-plugin/generateColorsAndType/index.js +28 -784
  18. package/dist-plugin/{themeTypes-DSwKq-bj.d.ts → index-DpTIRZ2H.d.cts} +67 -26
  19. package/dist-plugin/{themeTypes-DSwKq-bj.d.cts → index-DpTIRZ2H.d.ts} +67 -26
  20. package/dist-plugin/index.cjs +1254 -140
  21. package/dist-plugin/index.js +106 -82
  22. package/dist-plugin/migrateData/index.cjs +956 -14
  23. package/dist-plugin/migrateData/index.js +10 -3
  24. package/dist-plugin/tokensCssMigrations/index.cjs +71 -5
  25. package/dist-plugin/tokensCssMigrations/index.d.cts +20 -9
  26. package/dist-plugin/tokensCssMigrations/index.d.ts +20 -9
  27. package/dist-plugin/tokensCssMigrations/index.js +4 -1
  28. package/package.json +8 -4
  29. package/src/editor/component-editor/NotificationEditor.svelte +6 -0
  30. package/src/editor/component-editor/scaffolding/ComponentFileManager.svelte +9 -23
  31. package/src/editor/component-editor/scaffolding/LinkedBlock.svelte +8 -8
  32. package/src/editor/core/components/adjustAliases.ts +49 -22
  33. package/src/editor/core/components/aliasKinds.ts +7 -2
  34. package/src/editor/core/components/componentConfigService.ts +1 -1
  35. package/src/editor/core/palettes/oklch.ts +3 -137
  36. package/src/editor/core/palettes/paletteDerivation.ts +79 -37
  37. package/src/editor/core/store/editorStore.ts +7 -197
  38. package/src/editor/core/store/editorTypes.ts +9 -30
  39. package/src/editor/core/themes/generateColorsAndType.ts +18 -8
  40. package/src/editor/core/themes/lookSummary.ts +3 -25
  41. package/src/editor/core/themes/migrateComponentConfig.ts +205 -0
  42. package/src/editor/core/themes/migrations/2026-05-19-sectiondivider-rich-gradient.ts +1 -1
  43. package/src/editor/core/themes/migrations/2026-05-20-sectiondivider-slim-variants.ts +1 -1
  44. package/src/editor/core/themes/migrations/2026-05-22-sectiondivider-intrinsics-to-css.ts +1 -1
  45. package/src/editor/core/themes/parsers/gradient.ts +211 -0
  46. package/src/editor/core/themes/slices/gradients.ts +5 -58
  47. package/src/editor/core/themes/themeService.ts +22 -9
  48. package/src/editor/core/themes/themeTypes.ts +89 -27
  49. package/src/editor/docs/content/editing-tokens.md +6 -2
  50. package/src/editor/docs/content/themes-workflow.md +9 -11
  51. package/src/editor/docs/content/where-themes-live.md +2 -2
  52. package/src/editor/docs/content.generated.ts +3 -3
  53. package/src/editor/index.ts +1 -0
  54. package/src/editor/styles/ui-editor.css +5 -2
  55. package/src/editor/ui/BezierCurveEditor.svelte +90 -67
  56. package/src/editor/ui/PaletteEditor.svelte +180 -59
  57. package/src/editor/ui/ThemePanel.svelte +24 -15
  58. package/src/editor/ui/Toggle.svelte +36 -24
  59. package/src/editor/ui/UIPillButton.svelte +1 -1
  60. package/src/editor/ui/UIReveal.svelte +47 -0
  61. package/src/editor/ui/UISquareButton.svelte +1 -1
  62. package/src/editor/ui/colors/ColorStory.svelte +12 -8
  63. package/src/editor/ui/colors/ColorsTab.svelte +4 -5
  64. package/src/editor/ui/curveEngine.ts +101 -21
  65. package/src/editor/ui/palette/OverridesPanel.svelte +23 -8
  66. package/src/editor/ui/palette/PaletteBase.svelte +17 -78
  67. package/src/editor/ui/palette/PaletteJumpButton.svelte +3 -3
  68. package/src/editor/ui/palette/ScaleCurveEditor.svelte +110 -20
  69. package/src/editor/ui/palette/curveSummary.ts +20 -0
  70. package/src/editor/ui/palette/dockMagnify.ts +5 -13
  71. package/src/editor/ui/palette/paletteMath.ts +7 -4
  72. package/src/live-tokens/data/colors-and-type/autumn.json +528 -528
  73. package/src/live-tokens/data/colors-and-type/default.json +247 -247
  74. package/src/live-tokens/data/colors-and-type/halloween.json +532 -532
  75. package/src/live-tokens/data/colors-and-type/midnight-study.json +538 -538
  76. package/src/live-tokens/data/colors-and-type/ocean.json +521 -521
  77. package/src/live-tokens/data/colors-and-type/royal-velvet.json +532 -532
  78. package/src/live-tokens/data/colors-and-type/spring-meadow.json +504 -504
  79. package/src/live-tokens/data/colors-and-type/sunset.json +531 -531
  80. package/src/live-tokens/data/themes/autumn.json +604 -568
  81. package/src/live-tokens/data/themes/halloween.json +584 -583
  82. package/src/live-tokens/data/themes/midnight-study.json +673 -605
  83. package/src/live-tokens/data/themes/ocean.json +597 -561
  84. package/src/live-tokens/data/themes/royal-velvet.json +574 -573
  85. package/src/live-tokens/data/themes/spring-meadow.json +590 -556
  86. package/src/live-tokens/data/themes/sunset.json +632 -571
  87. package/src/live-tokens/data/tokens.generated.css +282 -282
  88. package/src/system/components/FloatingTokenTags.css +0 -1
  89. package/src/system/internal/backgroundContrast.ts +7 -0
  90. package/src/system/internal/oklch.ts +189 -0
  91. package/src/system/styles/tokens.css +283 -283
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // vite-plugin/generateColorsAndType/index.ts
31
31
  var generateColorsAndType_exports = {};
32
32
  __export(generateColorsAndType_exports, {
33
+ CURRENT_COMPONENT_SCHEMA_VERSION: () => CURRENT_COMPONENT_SCHEMA_VERSION,
33
34
  buildColorsAndTypeFromSeeds: () => buildColorsAndTypeFromSeeds,
34
35
  readLiveTokensConfig: () => readLiveTokensConfig,
35
36
  resolveDataDirs: () => resolveDataDirs,
@@ -37,7 +38,7 @@ __export(generateColorsAndType_exports, {
37
38
  });
38
39
  module.exports = __toCommonJS(generateColorsAndType_exports);
39
40
 
40
- // src/editor/core/palettes/oklch.ts
41
+ // src/system/internal/oklch.ts
41
42
  function srgbToLinear(c) {
42
43
  return c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
43
44
  }
@@ -131,6 +132,31 @@ function gamutClamp(l, c, h) {
131
132
  }
132
133
  return { l, c: lo, h };
133
134
  }
135
+ function trim(value, decimals) {
136
+ return Number(value.toFixed(decimals)).toString();
137
+ }
138
+ function oklchToCss(l, c, h) {
139
+ const cs = trim(c, 4);
140
+ return `oklch(${trim(l, 4)} ${cs} ${cs === "0" ? "0" : trim(h, 2)})`;
141
+ }
142
+ function oklchToCssClamped(l, c, h) {
143
+ const g = gamutClamp(l, c, h);
144
+ return oklchToCss(g.l, g.c, g.h);
145
+ }
146
+ var OKLCH_RE = /^oklch\(\s*([\d.]+)(%?)\s+([\d.]+)(%?)\s+([\d.]+)(?:deg)?\s*\)$/i;
147
+ var HEX6_RE = /^#[0-9a-f]{6}$/i;
148
+ function parseOklchCss(value) {
149
+ const m = OKLCH_RE.exec(value.trim());
150
+ if (!m) return null;
151
+ const l = Number.parseFloat(m[1]) / (m[2] === "%" ? 100 : 1);
152
+ const c = Number.parseFloat(m[3]) * (m[4] === "%" ? 4e-3 : 1);
153
+ return { l, c, h: Number.parseFloat(m[5]) };
154
+ }
155
+ function cssColorToOklch(value) {
156
+ const raw = value.trim();
157
+ if (HEX6_RE.test(raw)) return hexToOklch(raw);
158
+ return parseOklchCss(raw);
159
+ }
134
160
 
135
161
  // src/editor/ui/curveEngine.ts
136
162
  function makeAnchor(x, y, tangentLen = 15) {
@@ -155,6 +181,15 @@ function tangentAnchor(x, y, prev, next) {
155
181
  const outDx = next ? (next.x - x) * HANDLE_SPAN : 0;
156
182
  return { x, y, inDx, inDy: m * inDx, outDx, outDy: m * outDx };
157
183
  }
184
+ function isCornerAnchor(a) {
185
+ return a.inDx === 0 && a.inDy === 0 && a.outDx === 0 && a.outDy === 0;
186
+ }
187
+ function resmoothAutoCurve(anchors) {
188
+ if (anchors.length < 2) return anchors;
189
+ return anchors.map(
190
+ (a, i) => isCornerAnchor(a) ? a : tangentAnchor(a.x, a.y, anchors[i - 1] ?? null, anchors[i + 1] ?? null)
191
+ );
192
+ }
158
193
  function evalBezier(p0x, p0y, c0x, c0y, c1x, c1y, p1x, p1y, t) {
159
194
  const u = 1 - t, u2 = u * u, u3 = u2 * u;
160
195
  const t2 = t * t, t3 = t2 * t;
@@ -250,37 +285,39 @@ var SCALES = [
250
285
  ];
251
286
  var BW_GUARD_MIN_L = 0.17;
252
287
  var BW_GUARD_MAX_L = 0.93;
253
- var DEFAULT_PALETTE_LIGHTNESS = () => [makeAnchor(0, 95, 5), makeAnchor(100, 8, 5)];
254
- var DEFAULT_PALETTE_SATURATION = () => [makeAnchor(0, 100, 30), makeAnchor(100, 100, 30)];
288
+ var autoCurve = (...anchors) => resmoothAutoCurve(anchors);
289
+ var DEFAULT_PALETTE_LIGHTNESS = () => autoCurve(makeAnchor(0, 95), makeAnchor(100, 8));
290
+ var DEFAULT_PALETTE_SATURATION = () => autoCurve(makeAnchor(0, 100), makeAnchor(100, 100));
291
+ var wrapHue = (h) => (h % 360 + 360) % 360;
255
292
  function scaleCurveDefaults(scheme = "dark") {
256
293
  if (scheme === "light") {
257
294
  return {
258
295
  Surfaces: {
259
- lightness: () => [makeAnchor(0, 98, 5), makeAnchor(100, 82, 5)],
260
- saturation: () => [makeAnchor(0, 100, 30), makeAnchor(100, 100, 30)]
296
+ lightness: () => autoCurve(makeAnchor(0, 98), makeAnchor(100, 82)),
297
+ saturation: () => autoCurve(makeAnchor(0, 100), makeAnchor(100, 100))
261
298
  },
262
299
  Borders: {
263
- lightness: () => [makeAnchor(0, 92, 5), makeAnchor(100, 45, 5)],
264
- saturation: () => [makeAnchor(0, 100, 30), makeAnchor(100, 100, 30)]
300
+ lightness: () => autoCurve(makeAnchor(0, 92), makeAnchor(100, 45)),
301
+ saturation: () => autoCurve(makeAnchor(0, 100), makeAnchor(100, 100))
265
302
  },
266
303
  Text: {
267
- lightness: () => [makeAnchor(0, 30, 30), makeAnchor(100, 120, 30)],
268
- saturation: () => [makeAnchor(0, 100, 30), makeAnchor(100, 15, 30)]
304
+ lightness: () => autoCurve(makeAnchor(0, 30), makeAnchor(100, 120)),
305
+ saturation: () => autoCurve(makeAnchor(0, 100), makeAnchor(100, 15))
269
306
  }
270
307
  };
271
308
  }
272
309
  return {
273
310
  Surfaces: {
274
- lightness: () => [makeAnchor(0, 15, 5), makeAnchor(100, 47, 5)],
275
- saturation: () => [makeAnchor(0, 100, 30), makeAnchor(100, 100, 30)]
311
+ lightness: () => autoCurve(makeAnchor(0, 15), makeAnchor(100, 47)),
312
+ saturation: () => autoCurve(makeAnchor(0, 100), makeAnchor(100, 100))
276
313
  },
277
314
  Borders: {
278
- lightness: () => [makeAnchor(0, 25, 5), makeAnchor(100, 80, 5)],
279
- saturation: () => [makeAnchor(0, 100, 30), makeAnchor(100, 100, 30)]
315
+ lightness: () => autoCurve(makeAnchor(0, 25), makeAnchor(100, 80)),
316
+ saturation: () => autoCurve(makeAnchor(0, 100), makeAnchor(100, 100))
280
317
  },
281
318
  Text: {
282
- lightness: () => [makeAnchor(0, 120, 30), makeAnchor(100, 55, 30)],
283
- saturation: () => [makeAnchor(0, 100, 30), makeAnchor(100, 15, 30)]
319
+ lightness: () => autoCurve(makeAnchor(0, 120), makeAnchor(100, 55)),
320
+ saturation: () => autoCurve(makeAnchor(0, 100), makeAnchor(100, 15))
284
321
  }
285
322
  };
286
323
  }
@@ -299,14 +336,16 @@ function scaleStepToX(step, scale) {
299
336
  return scale.steps.length > 1 ? idx / (scale.steps.length - 1) * 100 : 50;
300
337
  }
301
338
  function serializeDerivedValue(value) {
302
- return value.kind === "raw" ? value.css : oklchToHexClamped(value.l, value.c, value.h);
339
+ return value.kind === "raw" ? value.css : oklchToCssClamped(value.l, value.c, value.h);
303
340
  }
304
- function computePaletteOklch(index, base, lightnessCurve, saturationCurve, curveOffset) {
305
- const { c: baseC, h } = base;
341
+ function computePaletteOklch(index, base, lightnessCurve, saturationCurve, curveOffset, hueCurve) {
342
+ const { c: baseC } = base;
306
343
  const xPos = stepIndexToX(index);
307
344
  const targetL = Math.max(0, Math.min(100, sampleCurve(lightnessCurve, xPos) + (curveOffset.lightness ?? 0))) / 100;
308
345
  const satMul = Math.max(0, Math.min(2, (sampleCurve(saturationCurve, xPos) + (curveOffset.saturation ?? 0)) / 100));
309
346
  const targetC = baseC * satMul;
347
+ const hueDelta = (hueCurve ? sampleCurve(hueCurve, xPos) : 0) + (curveOffset.hue ?? 0);
348
+ const h = hueDelta === 0 ? base.h : wrapHue(base.h + hueDelta);
310
349
  return gamutClamp(targetL, targetC, h);
311
350
  }
312
351
  function nearestPaletteStep(lightnessCurve, baseL) {
@@ -402,10 +441,12 @@ function syncBaseAnchor(cfg) {
402
441
  const fresh = prev === void 0;
403
442
  let lCurve = cfg.lightnessCurve;
404
443
  let sCurve = cfg.saturationCurve;
444
+ let hCurve = cfg.hueCurve;
405
445
  if (prev) {
406
446
  const prevX = stepIndexToX(prev.step);
407
447
  lCurve = liftCurveAnchor(lCurve, prevX, prev.displacedL);
408
448
  sCurve = liftCurveAnchor(sCurve, prevX, prev.displacedS);
449
+ if (hCurve) hCurve = liftCurveAnchor(hCurve, prevX, prev.displacedH);
409
450
  }
410
451
  const step = nearestPaletteStep(lCurve, cfg.baseColor.l);
411
452
  const x = stepIndexToX(step);
@@ -413,12 +454,19 @@ function syncBaseAnchor(cfg) {
413
454
  const s = setCurveAnchor(sCurve, x, 100, fresh);
414
455
  cfg.lightnessCurve = l.curve;
415
456
  cfg.saturationCurve = s.curve;
457
+ const h = hCurve ? setCurveAnchor(hCurve, x, 0, fresh) : void 0;
458
+ if (h) cfg.hueCurve = h.curve;
416
459
  cfg.anchorPlacement = {
417
460
  step,
418
461
  displacedL: l.displacedY,
419
462
  displacedS: s.displacedY,
463
+ displacedH: h?.displacedY,
420
464
  priorLightnessEndpoints: prev?.priorLightnessEndpoints ?? l.priorEndpoints,
421
- priorSaturationEndpoints: prev?.priorSaturationEndpoints ?? s.priorEndpoints
465
+ priorSaturationEndpoints: prev?.priorSaturationEndpoints ?? s.priorEndpoints,
466
+ // No else-branch reading `prev?.priorHueEndpoints`: that could only fire
467
+ // if a placed hue curve later went absent, which RJC 7 (reset never
468
+ // deletes) never lets happen.
469
+ priorHueEndpoints: h ? prev?.priorHueEndpoints ?? h.priorEndpoints : void 0
422
470
  };
423
471
  }
424
472
  function computeDerivedOklch(step, base, scaleTitle, scaleCurves, curveOffset) {
@@ -427,8 +475,10 @@ function computeDerivedOklch(step, base, scaleTitle, scaleCurves, curveOffset) {
427
475
  const defs = defaultScaleCurves[scaleTitle];
428
476
  const lCurve = scaleCurves[scaleTitle]?.lightness ?? defs.lightness();
429
477
  const sCurve = scaleCurves[scaleTitle]?.saturation ?? defs.saturation();
478
+ const hCurve = scaleCurves[scaleTitle]?.hue;
430
479
  const lOff = curveOffset[`${scaleTitle}-lightness`] ?? 0;
431
480
  const sOff = curveOffset[`${scaleTitle}-saturation`] ?? 0;
481
+ const hOff = curveOffset[`${scaleTitle}-hue`] ?? 0;
432
482
  const { l: baseL, c: baseC, h: baseH } = base;
433
483
  let targetL;
434
484
  if (scale.isText) {
@@ -439,7 +489,9 @@ function computeDerivedOklch(step, base, scaleTitle, scaleCurves, curveOffset) {
439
489
  }
440
490
  const satMul = Math.max(0, Math.min(2, (sampleCurve(sCurve, xPos) + sOff) / 100));
441
491
  const targetC = baseC * satMul;
442
- return gamutClamp(targetL, targetC, baseH);
492
+ const hueDelta = (hCurve ? sampleCurve(hCurve, xPos) : 0) + hOff;
493
+ const targetH = hueDelta === 0 ? baseH : wrapHue(baseH + hueDelta);
494
+ return gamutClamp(targetL, targetC, targetH);
443
495
  }
444
496
  function scaleToCssVar(scaleTitle, stepName, cssNamespace) {
445
497
  if (cssNamespace === null) return null;
@@ -468,7 +520,7 @@ function derivePaletteValues(spec, config) {
468
520
  const saturationCurve = config.saturationCurve ?? DEFAULT_PALETTE_SATURATION();
469
521
  PALETTE_STEPS.forEach((ps, index) => {
470
522
  const k = paletteStepKey(ps.label);
471
- const value = k in overrides ? { kind: "color", ...overrides[k] } : { kind: "color", ...computePaletteOklch(index, baseColor, lightnessCurve, saturationCurve, curveOffset) };
523
+ const value = k in overrides ? { kind: "color", ...overrides[k] } : { kind: "color", ...computePaletteOklch(index, baseColor, lightnessCurve, saturationCurve, curveOffset, config.hueCurve) };
472
524
  out[`--color-${spec.cssNamespace}-${ps.label}`] = value;
473
525
  });
474
526
  for (const scale of SCALES) {
@@ -503,8 +555,8 @@ function derivePaletteValues(spec, config) {
503
555
  );
504
556
  const stopsCss = sortedStops.map((s) => {
505
557
  const stopValue = out[`--color-${spec.cssNamespace}-${s.paletteLabel}`];
506
- const hex = stopValue ? serializeDerivedValue(stopValue) : "#000000";
507
- return `${hex} ${s.position}%`;
558
+ const css = stopValue ? serializeDerivedValue(stopValue) : "oklch(0 0 0)";
559
+ return `${css} ${s.position}%`;
508
560
  }).join(", ");
509
561
  let gradient;
510
562
  switch (gradientStyle) {
@@ -551,6 +603,52 @@ var canUndo = (0, import_store.derived)(historyTick, () => past.length > 0);
551
603
  var canRedo = (0, import_store.derived)(historyTick, () => future.length > 0);
552
604
  var dirty = (0, import_store.derived)(historyTick, () => past.length !== savedAtIndex);
553
605
 
606
+ // src/editor/core/themes/parsers/colorOpacity.ts
607
+ function formatColorOpacity(name, opacity) {
608
+ return `color-mix(in srgb, var(${name}) ${opacity}%, transparent)`;
609
+ }
610
+
611
+ // src/editor/core/themes/parsers/gradient.ts
612
+ var RADIAL_BASE_PX = 100;
613
+ function formatStopColor(s) {
614
+ const opacity = s.opacity ?? 100;
615
+ if (s.color.startsWith("--")) {
616
+ return opacity >= 100 ? `var(${s.color})` : formatColorOpacity(s.color, opacity);
617
+ }
618
+ return opacity >= 100 ? s.color : `color-mix(in srgb, ${s.color} ${opacity}%, transparent)`;
619
+ }
620
+ function formatGradientStops(stops) {
621
+ return stops.map((s) => `${formatStopColor(s)} ${s.position}%`).join(", ");
622
+ }
623
+ function formatRadialShape(v) {
624
+ const ax = v.aspectX ?? 1;
625
+ const ay = v.aspectY ?? 1;
626
+ if (ax === 1 && ay === 1) {
627
+ return v.radius && v.radius > 0 ? `circle ${v.radius}px` : "circle";
628
+ }
629
+ const base = v.radius && v.radius > 0 ? v.radius : RADIAL_BASE_PX;
630
+ return `ellipse ${(base * ax).toFixed(2)}px ${(base * ay).toFixed(2)}px`;
631
+ }
632
+ function formatGradientValue(v) {
633
+ if (v.type === "none") return "transparent";
634
+ if (v.type === "solid") {
635
+ const first = v.stops[0];
636
+ return first ? formatStopColor(first) : "transparent";
637
+ }
638
+ const stops = formatGradientStops(v.stops);
639
+ if (v.type === "linear") return `linear-gradient(${v.angle}deg, ${stops})`;
640
+ return `radial-gradient(${formatRadialShape(v)} at ${v.centerX ?? 50}% 50%, ${stops})`;
641
+ }
642
+ var NUM = String.raw`-?\d+(?:\.\d+)?`;
643
+ var LINEAR_RE = new RegExp(String.raw`^linear-gradient\(\s*(${NUM})deg\s*,\s*(.+)\)$`, "i");
644
+ var RADIAL_RE = new RegExp(
645
+ String.raw`^radial-gradient\(\s*(circle|circle\s+${NUM}px|ellipse\s+${NUM}px\s+${NUM}px)\s+at\s+(${NUM})%\s+50%\s*,\s*(.+)\)$`,
646
+ "i"
647
+ );
648
+ var STOP_RE = new RegExp(String.raw`^(.*?)\s+(${NUM})%$`);
649
+ var CIRCLE_RADIUS_RE = new RegExp(String.raw`^circle\s+(${NUM})px$`, "i");
650
+ var ELLIPSE_RE = new RegExp(String.raw`^ellipse\s+(${NUM})px\s+(${NUM})px$`, "i");
651
+
554
652
  // src/editor/core/themes/slices/gradients.ts
555
653
  function makeDefaultGradients() {
556
654
  return [
@@ -592,38 +690,6 @@ function makeDefaultGradients() {
592
690
  }
593
691
  ];
594
692
  }
595
- function formatGradientStop(s) {
596
- return `${formatGradientStopColor(s)} ${s.position}%`;
597
- }
598
- function formatGradientValue(v) {
599
- if (v.type === "none") return "transparent";
600
- if (v.type === "solid") {
601
- const first = v.stops[0];
602
- if (!first) return "transparent";
603
- return formatGradientStopColor(first);
604
- }
605
- const stops = v.stops.map(formatGradientStop).join(", ");
606
- if (v.type === "linear") return `linear-gradient(${v.angle}deg, ${stops})`;
607
- const cx = v.centerX ?? 50;
608
- return `radial-gradient(${formatRadialShape(v)} at ${cx}% 50%, ${stops})`;
609
- }
610
- var DEFAULT_RADIAL_BASE_PX = 100;
611
- function formatRadialShape(v) {
612
- const ax = v.aspectX ?? 1;
613
- const ay = v.aspectY ?? 1;
614
- if (ax === 1 && ay === 1) {
615
- return v.radius && v.radius > 0 ? `circle ${v.radius}px` : "circle";
616
- }
617
- const base = v.radius && v.radius > 0 ? v.radius : DEFAULT_RADIAL_BASE_PX;
618
- const rx = base * ax;
619
- const ry = base * ay;
620
- return `ellipse ${rx.toFixed(2)}px ${ry.toFixed(2)}px`;
621
- }
622
- function formatGradientStopColor(s) {
623
- const base = s.color.startsWith("--") ? `var(${s.color})` : s.color;
624
- const opacity = s.opacity ?? 100;
625
- return opacity >= 100 ? base : `color-mix(in srgb, ${base} ${opacity}%, transparent)`;
626
- }
627
693
 
628
694
  // src/editor/core/palettes/contrast.ts
629
695
  var AA_BODY = 4.5;
@@ -705,7 +771,7 @@ function findLForContrast(opts) {
705
771
  }
706
772
 
707
773
  // src/editor/ui/palette/paletteMath.ts
708
- var DEFAULT_NEUTRAL_LIGHTNESS = () => [makeAnchor(0, 92, 5), makeAnchor(100, 3, 5)];
774
+ var DEFAULT_NEUTRAL_LIGHTNESS = () => resmoothAutoCurve([makeAnchor(0, 92), makeAnchor(100, 3)]);
709
775
  function defaultPaletteConfig(opts) {
710
776
  const cfg = {
711
777
  baseColor: opts.baseColor,
@@ -1577,12 +1643,16 @@ function surfaceVars() {
1577
1643
  "--page-bg"
1578
1644
  ];
1579
1645
  }
1646
+ function varToHex(value) {
1647
+ const parsed = value ? cssColorToOklch(value) : null;
1648
+ return parsed ? oklchToHexClamped(parsed.l, parsed.c, parsed.h) : null;
1649
+ }
1580
1650
  function worstSurface(textHex, vars) {
1581
1651
  let against = "";
1582
1652
  let ratio = Infinity;
1583
1653
  for (const surfVar of surfaceVars()) {
1584
- const surfHex = vars[surfVar];
1585
- if (!surfHex || !HEX_RE.test(surfHex)) continue;
1654
+ const surfHex = varToHex(vars[surfVar]);
1655
+ if (!surfHex) continue;
1586
1656
  const r = contrastRatio(textHex, surfHex);
1587
1657
  if (r < ratio) {
1588
1658
  ratio = r;
@@ -1610,17 +1680,18 @@ function runContrastGate(configs, scheme) {
1610
1680
  const vars = palettesToVars(configs);
1611
1681
  let anyFixed = false;
1612
1682
  for (const def of defs) {
1613
- const textHex = vars[def.textVar];
1614
- if (!textHex) continue;
1683
+ const text = cssColorToOklch(vars[def.textVar] ?? "");
1684
+ if (!text) continue;
1685
+ const textHex = oklchToHexClamped(text.l, text.c, text.h);
1615
1686
  const worst = worstSurface(textHex, vars);
1616
1687
  if (worst.ratio >= def.floor) continue;
1617
1688
  const cfg = configs[def.paletteLabel];
1618
1689
  const seed = cfg.baseColor;
1619
1690
  const solved = findLForContrast({
1620
- against: vars[worst.against],
1691
+ against: varToHex(vars[worst.against]) ?? "#000000",
1621
1692
  ratio: def.target,
1622
1693
  direction,
1623
- c: hexToOklch(textHex).c,
1694
+ c: text.c,
1624
1695
  h: seed.h,
1625
1696
  lMax: Math.min(1, 2 * seed.l)
1626
1697
  });
@@ -1632,7 +1703,7 @@ function runContrastGate(configs, scheme) {
1632
1703
  }
1633
1704
  const finalVars = palettesToVars(configs);
1634
1705
  const checks = defs.map((def) => {
1635
- const worst = worstSurface(finalVars[def.textVar] ?? "#000000", finalVars);
1706
+ const worst = worstSurface(varToHex(finalVars[def.textVar]) ?? "#000000", finalVars);
1636
1707
  return {
1637
1708
  textVar: def.textVar,
1638
1709
  floor: def.floor,
@@ -1785,6 +1856,7 @@ function resolveDataDirs(opts = {}) {
1785
1856
  }
1786
1857
  // Annotate the CommonJS export names for ESM import in node:
1787
1858
  0 && (module.exports = {
1859
+ CURRENT_COMPONENT_SCHEMA_VERSION,
1788
1860
  buildColorsAndTypeFromSeeds,
1789
1861
  readLiveTokensConfig,
1790
1862
  resolveDataDirs,
@@ -1,4 +1,5 @@
1
- import { F as FontSource, b as FontStack, G as GradientDiskToken, O as Oklch, H as HarmonyMode, C as ColorsAndType } from '../themeTypes-DSwKq-bj.cjs';
1
+ import { F as FontSource, c as FontStack, G as GradientDiskToken, O as Oklch, H as HarmonyMode, a as ColorsAndType } from '../index-DpTIRZ2H.cjs';
2
+ export { C as CURRENT_COMPONENT_SCHEMA_VERSION } from '../index-DpTIRZ2H.cjs';
2
3
  export { r as readLiveTokensConfig, a as resolveDataDirs } from '../dataPaths-DBN0RPuT.cjs';
3
4
 
4
5
  /**
@@ -1,4 +1,5 @@
1
- import { F as FontSource, b as FontStack, G as GradientDiskToken, O as Oklch, H as HarmonyMode, C as ColorsAndType } from '../themeTypes-DSwKq-bj.js';
1
+ import { F as FontSource, c as FontStack, G as GradientDiskToken, O as Oklch, H as HarmonyMode, a as ColorsAndType } from '../index-DpTIRZ2H.js';
2
+ export { C as CURRENT_COMPONENT_SCHEMA_VERSION } from '../index-DpTIRZ2H.js';
2
3
  export { r as readLiveTokensConfig, a as resolveDataDirs } from '../dataPaths-DBN0RPuT.js';
3
4
 
4
5
  /**