rafters 0.0.46 → 0.0.47

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 (2) hide show
  1. package/dist/index.js +711 -166
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -13718,6 +13718,245 @@ import { createRequire } from "module";
13718
13718
  import { join as join9, relative } from "path";
13719
13719
  import { checkbox, confirm, select } from "@inquirer/prompts";
13720
13720
 
13721
+ // ../design-tokens/src/scale-positions.ts
13722
+ var INDEX_TO_POSITION = [
13723
+ "50",
13724
+ "100",
13725
+ "200",
13726
+ "300",
13727
+ "400",
13728
+ "500",
13729
+ "600",
13730
+ "700",
13731
+ "800",
13732
+ "900",
13733
+ "950"
13734
+ ];
13735
+ var POSITION_TO_INDEX = {
13736
+ "50": 0,
13737
+ "100": 1,
13738
+ "200": 2,
13739
+ "300": 3,
13740
+ "400": 4,
13741
+ "500": 5,
13742
+ "600": 6,
13743
+ "700": 7,
13744
+ "800": 8,
13745
+ "900": 9,
13746
+ "950": 10
13747
+ };
13748
+ var SCALE_POSITION_MAP = {
13749
+ 50: 0,
13750
+ 100: 1,
13751
+ 200: 2,
13752
+ 300: 3,
13753
+ 400: 4,
13754
+ 500: 5,
13755
+ 600: 6,
13756
+ 700: 7,
13757
+ 800: 8,
13758
+ 900: 9,
13759
+ 950: 10
13760
+ };
13761
+ var SCALE_POSITION_MAP_REVERSE = {};
13762
+ for (const [pos, idx] of Object.entries(SCALE_POSITION_MAP)) {
13763
+ if (SCALE_POSITION_MAP_REVERSE[idx] !== void 0) {
13764
+ throw new Error(
13765
+ `Duplicate index ${idx} in SCALE_POSITION_MAP: "${SCALE_POSITION_MAP_REVERSE[idx]}" and "${pos}"`
13766
+ );
13767
+ }
13768
+ SCALE_POSITION_MAP_REVERSE[idx] = pos;
13769
+ }
13770
+ var VALID_SCALE_POSITIONS = Object.keys(SCALE_POSITION_MAP).map(Number);
13771
+ var MIN_WCAG_PAIR_DISTANCE = 3;
13772
+ function findBestWcagPair(sourceIndex, pairs, wantHigher) {
13773
+ let best;
13774
+ let bestDistance = -1;
13775
+ for (const pair of pairs) {
13776
+ if (!pair || pair.length < 2) continue;
13777
+ const [a2, b2] = pair;
13778
+ if (a2 === void 0 || b2 === void 0) continue;
13779
+ let partner;
13780
+ if (a2 === sourceIndex) partner = b2;
13781
+ else if (b2 === sourceIndex) partner = a2;
13782
+ else continue;
13783
+ if (wantHigher && partner <= sourceIndex) continue;
13784
+ if (!wantHigher && partner >= sourceIndex) continue;
13785
+ const distance2 = Math.abs(partner - sourceIndex);
13786
+ if (distance2 > bestDistance) {
13787
+ bestDistance = distance2;
13788
+ best = partner;
13789
+ }
13790
+ }
13791
+ return best;
13792
+ }
13793
+ function findDarkCounterpartIndex(lightIndex, colorValue) {
13794
+ const aaaPairs = colorValue.accessibility?.wcagAAA?.normal ?? [];
13795
+ const aaPairs = colorValue.accessibility?.wcagAA?.normal ?? [];
13796
+ if (aaaPairs.length === 0 && aaPairs.length === 0) {
13797
+ throw new Error(
13798
+ `No WCAG accessibility data available for dark mode counterpart of index ${lightIndex}. ColorValue must include accessibility.wcagAAA or wcagAA pair matrices.`
13799
+ );
13800
+ }
13801
+ const wantHigher = lightIndex <= 5;
13802
+ for (const pairs of [aaaPairs, aaPairs]) {
13803
+ const match2 = findBestWcagPair(lightIndex, pairs, wantHigher);
13804
+ if (match2 !== void 0 && Math.abs(match2 - lightIndex) >= MIN_WCAG_PAIR_DISTANCE) {
13805
+ return match2;
13806
+ }
13807
+ }
13808
+ console.warn(
13809
+ `[design-tokens] No WCAG pair with sufficient distance (>=${MIN_WCAG_PAIR_DISTANCE}) found for index ${lightIndex}. Falling back to mathematical inversion.`
13810
+ );
13811
+ return Math.max(0, Math.min(10, 10 - lightIndex));
13812
+ }
13813
+
13814
+ // ../design-tokens/src/plugins/contrast.ts
13815
+ function contrast(registry2, tokenName, dependencies) {
13816
+ if (dependencies.length === 0) {
13817
+ throw new Error(`No dependencies found for contrast rule on token: ${tokenName}`);
13818
+ }
13819
+ const familyTokenName = dependencies[0];
13820
+ if (!familyTokenName) {
13821
+ throw new Error(`No dependency token name for contrast rule on token: ${tokenName}`);
13822
+ }
13823
+ const familyToken = registry2.get(familyTokenName);
13824
+ if (!familyToken || typeof familyToken.value !== "object") {
13825
+ throw new Error(`ColorValue family token ${familyTokenName} not found for contrast rule`);
13826
+ }
13827
+ const colorValue = familyToken.value;
13828
+ if (colorValue.foregroundReferences?.auto) {
13829
+ const reference = colorValue.foregroundReferences.auto;
13830
+ return {
13831
+ family: reference.family,
13832
+ position: reference.position
13833
+ };
13834
+ }
13835
+ const baseTokenMatch = tokenName.match(/^(.+)-(?:foreground|text|contrast)$/);
13836
+ let basePosition = 5;
13837
+ if (baseTokenMatch?.[1]) {
13838
+ const baseTokenName = baseTokenMatch[1];
13839
+ const baseToken = registry2.get(baseTokenName);
13840
+ if (baseToken && typeof baseToken.value === "object") {
13841
+ const baseRef = baseToken.value;
13842
+ if (baseRef.position) {
13843
+ basePosition = typeof baseRef.position === "string" ? Math.floor(parseInt(baseRef.position, 10) / 100) : Math.floor(baseRef.position / 100);
13844
+ }
13845
+ }
13846
+ }
13847
+ if (colorValue.accessibility) {
13848
+ const accessibility = colorValue.accessibility;
13849
+ const wcagAAA = accessibility.wcagAAA?.normal || [];
13850
+ const wcagAA = accessibility.wcagAA?.normal || [];
13851
+ let contrastPosition;
13852
+ for (const [pos1, pos2] of wcagAAA) {
13853
+ if (pos1 === basePosition) {
13854
+ contrastPosition = pos2;
13855
+ break;
13856
+ }
13857
+ if (pos2 === basePosition) {
13858
+ contrastPosition = pos1;
13859
+ break;
13860
+ }
13861
+ }
13862
+ if (contrastPosition === void 0) {
13863
+ for (const [pos1, pos2] of wcagAA) {
13864
+ if (pos1 === basePosition) {
13865
+ contrastPosition = pos2;
13866
+ break;
13867
+ }
13868
+ if (pos2 === basePosition) {
13869
+ contrastPosition = pos1;
13870
+ break;
13871
+ }
13872
+ }
13873
+ }
13874
+ if (contrastPosition !== void 0) {
13875
+ return {
13876
+ family: familyTokenName,
13877
+ position: INDEX_TO_POSITION[contrastPosition] ?? "500"
13878
+ };
13879
+ }
13880
+ }
13881
+ const neutralFamilies = ["neutral-grayscale", "neutral", "gray", "grey"];
13882
+ for (const neutralFamily of neutralFamilies) {
13883
+ const neutralToken = registry2.get(neutralFamily);
13884
+ if (neutralToken && typeof neutralToken.value === "object") {
13885
+ const neutralValue = neutralToken.value;
13886
+ if (neutralValue.accessibility) {
13887
+ const neutralAccessibility = neutralValue.accessibility;
13888
+ if (neutralAccessibility.onWhite?.aaa && neutralAccessibility.onWhite.aaa.length > 0) {
13889
+ const bestPosition = neutralAccessibility.onWhite.aaa[0];
13890
+ if (bestPosition !== void 0) {
13891
+ return {
13892
+ family: neutralFamily,
13893
+ position: INDEX_TO_POSITION[bestPosition] ?? "500"
13894
+ };
13895
+ }
13896
+ }
13897
+ if (neutralAccessibility.onWhite?.aa && neutralAccessibility.onWhite.aa.length > 0) {
13898
+ const bestPosition = neutralAccessibility.onWhite.aa[0];
13899
+ if (bestPosition !== void 0) {
13900
+ return {
13901
+ family: neutralFamily,
13902
+ position: INDEX_TO_POSITION[bestPosition] ?? "500"
13903
+ };
13904
+ }
13905
+ }
13906
+ }
13907
+ return {
13908
+ family: neutralFamily,
13909
+ position: basePosition <= 5 ? "900" : "100"
13910
+ // Dark text for light backgrounds, light text for dark
13911
+ };
13912
+ }
13913
+ }
13914
+ return {
13915
+ family: familyTokenName ?? "neutral",
13916
+ position: basePosition <= 5 ? "900" : "100"
13917
+ };
13918
+ }
13919
+
13920
+ // ../design-tokens/src/plugins/invert.ts
13921
+ function invert(registry2, tokenName, dependencies) {
13922
+ if (dependencies.length === 0) {
13923
+ throw new Error(`No dependencies found for invert rule on token: ${tokenName}`);
13924
+ }
13925
+ const familyTokenName = dependencies[0];
13926
+ if (!familyTokenName) {
13927
+ throw new Error(`No dependency token name for invert rule on token: ${tokenName}`);
13928
+ }
13929
+ const familyToken = registry2.get(familyTokenName);
13930
+ if (!familyToken || typeof familyToken.value !== "object") {
13931
+ throw new Error(`ColorValue family token ${familyTokenName} not found for invert rule`);
13932
+ }
13933
+ const colorValue = familyToken.value;
13934
+ const lightIndex = extractLightIndex(tokenName, dependencies);
13935
+ const darkIndex = findDarkCounterpartIndex(lightIndex, colorValue);
13936
+ const darkPosition = INDEX_TO_POSITION[darkIndex];
13937
+ if (!darkPosition) {
13938
+ throw new Error(`Invalid dark index ${darkIndex} for token: ${tokenName}`);
13939
+ }
13940
+ return { family: familyTokenName, position: darkPosition };
13941
+ }
13942
+ function extractLightIndex(tokenName, dependencies) {
13943
+ if (dependencies.length > 1 && dependencies[1]) {
13944
+ const posMatch = dependencies[1].match(/-(\d+)$/);
13945
+ if (posMatch?.[1]) {
13946
+ const idx = POSITION_TO_INDEX[posMatch[1]];
13947
+ if (idx !== void 0) return idx;
13948
+ }
13949
+ }
13950
+ const nameMatch = tokenName.match(/-(\d+)$/);
13951
+ if (nameMatch?.[1]) {
13952
+ const idx = POSITION_TO_INDEX[nameMatch[1]];
13953
+ if (idx !== void 0) return idx;
13954
+ }
13955
+ throw new Error(
13956
+ `Cannot determine light mode scale position for invert rule on token: ${tokenName}. Neither dependency[1] (${dependencies[1] ?? "none"}) nor token name suffix contain a valid position.`
13957
+ );
13958
+ }
13959
+
13721
13960
  // ../design-tokens/src/plugins/scale.ts
13722
13961
  function scale(registry2, tokenName, dependencies) {
13723
13962
  const match2 = tokenName.match(/(\d+)$/);
@@ -13742,21 +13981,58 @@ function scale(registry2, tokenName, dependencies) {
13742
13981
  };
13743
13982
  }
13744
13983
 
13745
- // ../design-tokens/src/generation-rules.ts
13746
- var SCALE_POSITION_MAP = {
13747
- 50: 0,
13748
- 100: 1,
13749
- 200: 2,
13750
- 300: 3,
13751
- 400: 4,
13752
- 500: 5,
13753
- 600: 6,
13754
- 700: 7,
13755
- 800: 8,
13756
- 900: 9,
13757
- 950: 10
13984
+ // ../design-tokens/src/plugins/state.ts
13985
+ var STATE_OFFSETS = {
13986
+ hover: 1,
13987
+ active: 2,
13988
+ focus: 1,
13989
+ disabled: -2
13758
13990
  };
13759
- var VALID_SCALE_POSITIONS = Object.keys(SCALE_POSITION_MAP).map(Number);
13991
+ function state(registry2, tokenName, dependencies) {
13992
+ const stateMatch = tokenName.match(/(hover|active|focus|disabled)$/);
13993
+ if (!stateMatch) {
13994
+ throw new Error(`Cannot extract state from token name: ${tokenName}`);
13995
+ }
13996
+ const stateName = stateMatch[1];
13997
+ if (dependencies.length === 0) {
13998
+ throw new Error(`No dependencies found for state rule on token: ${tokenName}`);
13999
+ }
14000
+ const familyTokenName = dependencies[0];
14001
+ if (!familyTokenName) {
14002
+ throw new Error(`No dependency token name for state rule on token: ${tokenName}`);
14003
+ }
14004
+ const familyToken = registry2.get(familyTokenName);
14005
+ if (!familyToken || typeof familyToken.value !== "object") {
14006
+ throw new Error(`ColorValue family token ${familyTokenName} not found for state rule`);
14007
+ }
14008
+ const colorValue = familyToken.value;
14009
+ if (colorValue.stateReferences?.[stateName]) {
14010
+ const reference = colorValue.stateReferences[stateName];
14011
+ return { family: reference.family, position: String(reference.position) };
14012
+ }
14013
+ const baseTokenName = tokenName.replace(/-(hover|active|focus|disabled)$/, "");
14014
+ const baseToken = registry2.get(baseTokenName);
14015
+ let baseIndex = 5;
14016
+ if (baseToken && typeof baseToken.value === "object" && "position" in baseToken.value) {
14017
+ const baseRef = baseToken.value;
14018
+ if (baseRef.position) {
14019
+ const idx = POSITION_TO_INDEX[baseRef.position];
14020
+ if (idx !== void 0) baseIndex = idx;
14021
+ }
14022
+ }
14023
+ const offset = STATE_OFFSETS[stateName] ?? 0;
14024
+ const adjustedIndex = Math.max(0, Math.min(10, baseIndex + offset));
14025
+ const position = INDEX_TO_POSITION[adjustedIndex] ?? "500";
14026
+ return { family: familyTokenName, position };
14027
+ }
14028
+
14029
+ // ../design-tokens/src/generation-rules.ts
14030
+ function cssResult(value2) {
14031
+ return { kind: "css", value: value2 };
14032
+ }
14033
+ function refResult(family, position) {
14034
+ return { kind: "ref", ref: { family, position } };
14035
+ }
13760
14036
  var GenerationRuleParser = class {
13761
14037
  /**
13762
14038
  * Parse a generation rule string into a structured rule object
@@ -13920,7 +14196,9 @@ var GenerationRuleExecutor = class {
13920
14196
  this.registry = registry2;
13921
14197
  }
13922
14198
  /**
13923
- * Execute a parsed rule and return the computed value
14199
+ * Execute a parsed rule and return the computed value.
14200
+ * Returns a string for CSS-value rules (calc, scale, scale-position)
14201
+ * or a ColorReference for semantic rules (state, contrast, invert).
13924
14202
  */
13925
14203
  execute(rule, tokenName) {
13926
14204
  switch (rule.type) {
@@ -13931,11 +14209,11 @@ var GenerationRuleExecutor = class {
13931
14209
  case "scale-position":
13932
14210
  return this.executeScalePositionRule(rule, tokenName);
13933
14211
  case "state":
13934
- return this.executeStateRule(rule);
14212
+ return this.executeStateRule(rule, tokenName);
13935
14213
  case "contrast":
13936
- return this.executeContrastRule(rule);
14214
+ return this.executeContrastRule(rule, tokenName);
13937
14215
  case "invert":
13938
- return this.executeInvertRule(rule);
14216
+ return this.executeInvertRule(rule, tokenName);
13939
14217
  default:
13940
14218
  throw new Error(`Unknown rule type: ${rule.type}`);
13941
14219
  }
@@ -13955,7 +14233,7 @@ var GenerationRuleExecutor = class {
13955
14233
  expression = expression.replace(new RegExp(`\\{${tokenName}\\}`, "g"), tokenValue);
13956
14234
  }
13957
14235
  }
13958
- return `calc(${expression})`;
14236
+ return cssResult(`calc(${expression})`);
13959
14237
  }
13960
14238
  executeScaleRule(rule) {
13961
14239
  if (!rule.baseToken) {
@@ -13971,18 +14249,37 @@ var GenerationRuleExecutor = class {
13971
14249
  if (numericMatch?.[1]) {
13972
14250
  const value2 = parseFloat(numericMatch[1]);
13973
14251
  const unit = numericMatch[2] || "";
13974
- return `${value2 * ratio}${unit}`;
14252
+ return cssResult(`${value2 * ratio}${unit}`);
13975
14253
  }
13976
- return `calc(${baseValue} * ${ratio})`;
14254
+ return cssResult(`calc(${baseValue} * ${ratio})`);
13977
14255
  }
13978
14256
  /**
13979
- * Execute a scale-position rule to extract a value from a ColorValue's scale array.
13980
- * Delegates to the scale plugin for lazy reference, then resolves to CSS.
14257
+ * Execute a scale-position rule.
14258
+ *
14259
+ * For position tokens (e.g., primary-600): extracts from ColorValue scale, returns CSS string.
14260
+ * For semantic tokens (e.g., background): returns a ColorReference to family + position.
14261
+ *
14262
+ * Detection: if the token's current value is a ColorReference, return a ColorReference.
14263
+ * Otherwise, resolve to CSS string via the scale plugin.
13981
14264
  */
13982
- executeScalePositionRule(_rule, tokenName) {
14265
+ executeScalePositionRule(rule, tokenName) {
14266
+ const existingToken = this.registry.get(tokenName);
14267
+ const existingValue = existingToken?.value;
14268
+ if (existingValue && typeof existingValue === "object" && "family" in existingValue) {
14269
+ const dependencies2 = this.registry.getDependencies(tokenName);
14270
+ const familyName = dependencies2[0];
14271
+ if (!familyName) {
14272
+ throw new Error(`No family dependency for semantic scale rule on token: ${tokenName}`);
14273
+ }
14274
+ const position = rule.scalePosition !== void 0 ? SCALE_POSITION_MAP_REVERSE[rule.scalePosition] : existingValue.position;
14275
+ if (!position) {
14276
+ throw new Error(`Cannot resolve scale position for token: ${tokenName}`);
14277
+ }
14278
+ return refResult(familyName, String(position));
14279
+ }
13983
14280
  const dependencies = this.registry.getDependencies(tokenName);
13984
14281
  const reference = scale(this.registry, tokenName, dependencies);
13985
- return this.resolveColorReference(reference);
14282
+ return cssResult(this.resolveColorReference(reference));
13986
14283
  }
13987
14284
  /**
13988
14285
  * Resolve a color reference {family, position} to a CSS value.
@@ -14026,49 +14323,20 @@ var GenerationRuleExecutor = class {
14026
14323
  }
14027
14324
  return `oklch(${l} ${c4} ${h})`;
14028
14325
  }
14029
- executeStateRule(rule) {
14030
- if (!rule.baseToken) {
14031
- throw new Error("State rule missing base token");
14032
- }
14033
- const baseToken = this.registry.get(rule.baseToken);
14034
- if (!baseToken) {
14035
- throw new Error(`Base token not found: ${rule.baseToken}`);
14036
- }
14037
- const baseValue = String(baseToken.value);
14038
- const stateType = rule.stateType || "hover";
14039
- switch (stateType) {
14040
- case "hover":
14041
- return `${baseValue}:hover`;
14042
- case "focus":
14043
- return `${baseValue}:focus`;
14044
- case "active":
14045
- return `${baseValue}:active`;
14046
- default:
14047
- return `${baseValue}:${stateType}`;
14048
- }
14326
+ executeStateRule(_rule, tokenName) {
14327
+ const dependencies = this.registry.getDependencies(tokenName);
14328
+ const ref = state(this.registry, tokenName, dependencies);
14329
+ return refResult(ref.family, ref.position);
14049
14330
  }
14050
- executeContrastRule(rule) {
14051
- if (!rule.baseToken) {
14052
- throw new Error("Contrast rule missing base token");
14053
- }
14054
- const baseToken = this.registry.get(rule.baseToken);
14055
- if (!baseToken) {
14056
- throw new Error(`Base token not found: ${rule.baseToken}`);
14057
- }
14058
- const baseValue = String(baseToken.value);
14059
- const contrast2 = rule.contrast || "high";
14060
- return `contrast(${baseValue}, ${contrast2})`;
14331
+ executeContrastRule(_rule, tokenName) {
14332
+ const dependencies = this.registry.getDependencies(tokenName);
14333
+ const ref = contrast(this.registry, tokenName, dependencies);
14334
+ return refResult(ref.family, ref.position);
14061
14335
  }
14062
- executeInvertRule(rule) {
14063
- if (!rule.baseToken) {
14064
- throw new Error("Invert rule missing base token");
14065
- }
14066
- const baseToken = this.registry.get(rule.baseToken);
14067
- if (!baseToken) {
14068
- throw new Error(`Base token not found: ${rule.baseToken}`);
14069
- }
14070
- const baseValue = String(baseToken.value);
14071
- return `invert(${baseValue})`;
14336
+ executeInvertRule(_rule, tokenName) {
14337
+ const dependencies = this.registry.getDependencies(tokenName);
14338
+ const ref = invert(this.registry, tokenName, dependencies);
14339
+ return refResult(ref.family, ref.position);
14072
14340
  }
14073
14341
  };
14074
14342
 
@@ -22707,10 +22975,10 @@ var require_events = __commonJS({
22707
22975
  }
22708
22976
  }
22709
22977
  function _onceWrap(target, type2, listener) {
22710
- var state = { fired: false, wrapFn: void 0, target, type: type2, listener };
22711
- var wrapped = onceWrapper.bind(state);
22978
+ var state2 = { fired: false, wrapFn: void 0, target, type: type2, listener };
22979
+ var wrapped = onceWrapper.bind(state2);
22712
22980
  wrapped.listener = listener;
22713
- state.wrapFn = wrapped;
22981
+ state2.wrapFn = wrapped;
22714
22982
  return wrapped;
22715
22983
  }
22716
22984
  EventEmitter2.prototype.once = function once2(type2, listener) {
@@ -24359,20 +24627,20 @@ function __importStar(mod) {
24359
24627
  function __importDefault(mod) {
24360
24628
  return mod && mod.__esModule ? mod : { default: mod };
24361
24629
  }
24362
- function __classPrivateFieldGet(receiver, state, kind, f) {
24630
+ function __classPrivateFieldGet(receiver, state2, kind, f) {
24363
24631
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
24364
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
24365
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
24632
+ if (typeof state2 === "function" ? receiver !== state2 || !f : !state2.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
24633
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state2.get(receiver);
24366
24634
  }
24367
- function __classPrivateFieldSet(receiver, state, value2, kind, f) {
24635
+ function __classPrivateFieldSet(receiver, state2, value2, kind, f) {
24368
24636
  if (kind === "m") throw new TypeError("Private method is not writable");
24369
24637
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
24370
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
24371
- return kind === "a" ? f.call(receiver, value2) : f ? f.value = value2 : state.set(receiver, value2), value2;
24638
+ if (typeof state2 === "function" ? receiver !== state2 || !f : !state2.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
24639
+ return kind === "a" ? f.call(receiver, value2) : f ? f.value = value2 : state2.set(receiver, value2), value2;
24372
24640
  }
24373
- function __classPrivateFieldIn(state, receiver) {
24641
+ function __classPrivateFieldIn(state2, receiver) {
24374
24642
  if (receiver === null || typeof receiver !== "object" && typeof receiver !== "function") throw new TypeError("Cannot use 'in' operator on non-object");
24375
- return typeof state === "function" ? receiver === state : state.has(receiver);
24643
+ return typeof state2 === "function" ? receiver === state2 : state2.has(receiver);
24376
24644
  }
24377
24645
  function __addDisposableResource(env, value2, async) {
24378
24646
  if (value2 !== null && value2 !== void 0) {
@@ -44806,6 +45074,58 @@ var DEFAULT_SHADOW_DEFINITIONS = {
44806
45074
  contexts: ["critical-modals", "overlays", "drawer-panels"]
44807
45075
  }
44808
45076
  };
45077
+ var DEFAULT_FILL_DEFINITIONS = {
45078
+ surface: {
45079
+ color: "neutral-900",
45080
+ foreground: "neutral-100",
45081
+ meaning: "Primary content surface",
45082
+ contexts: ["surface"]
45083
+ },
45084
+ panel: {
45085
+ color: "neutral-800",
45086
+ opacity: 0.95,
45087
+ foreground: "neutral-100",
45088
+ meaning: "Elevated panel",
45089
+ contexts: ["surface"]
45090
+ },
45091
+ overlay: {
45092
+ color: "neutral-950",
45093
+ opacity: 0.8,
45094
+ backdropBlur: "sm",
45095
+ foreground: "neutral-50",
45096
+ meaning: "Modal backdrop",
45097
+ contexts: ["surface"]
45098
+ },
45099
+ glass: {
45100
+ color: "neutral-900",
45101
+ opacity: 0.6,
45102
+ backdropBlur: "md",
45103
+ foreground: "neutral-100",
45104
+ meaning: "Glass morphism",
45105
+ contexts: ["surface"]
45106
+ },
45107
+ primary: {
45108
+ color: "primary",
45109
+ foreground: "primary-foreground",
45110
+ meaning: "Primary brand surface",
45111
+ contexts: ["surface", "text"]
45112
+ },
45113
+ muted: {
45114
+ color: "muted",
45115
+ foreground: "muted-foreground",
45116
+ meaning: "Subdued surface for secondary content",
45117
+ contexts: ["surface"]
45118
+ },
45119
+ hero: {
45120
+ gradient: {
45121
+ direction: "to-b",
45122
+ stops: [{ color: "primary" }, { color: "primary", opacity: 0 }]
45123
+ },
45124
+ foreground: "primary-foreground",
45125
+ meaning: "Hero fade gradient",
45126
+ contexts: ["surface", "text"]
45127
+ }
45128
+ };
44809
45129
  var DEFAULT_ELEVATION_DEFINITIONS = {
44810
45130
  surface: {
44811
45131
  depth: "depth-base",
@@ -47062,6 +47382,7 @@ function groupTokens(tokens) {
47062
47382
  elevation: [],
47063
47383
  focus: [],
47064
47384
  "typography-composite": [],
47385
+ fill: [],
47065
47386
  other: []
47066
47387
  };
47067
47388
  for (const token of tokens) {
@@ -47102,6 +47423,9 @@ function groupTokens(tokens) {
47102
47423
  case "typography-composite":
47103
47424
  groups["typography-composite"].push(token);
47104
47425
  break;
47426
+ case "fill":
47427
+ groups.fill.push(token);
47428
+ break;
47105
47429
  default:
47106
47430
  groups.other.push(token);
47107
47431
  }
@@ -47270,6 +47594,13 @@ function generateThemeBlock(groups) {
47270
47594
  }
47271
47595
  lines.push("");
47272
47596
  }
47597
+ if (groups.fill.length > 0) {
47598
+ for (const token of groups.fill) {
47599
+ const value2 = typeof token.value === "string" ? token.value : JSON.stringify(token.value);
47600
+ lines.push(` --${token.name}: ${value2};`);
47601
+ }
47602
+ lines.push("");
47603
+ }
47273
47604
  if (groups.other.length > 0) {
47274
47605
  for (const token of groups.other) {
47275
47606
  const value2 = tokenValueToCSS(token);
@@ -47620,6 +47951,13 @@ function generateVarsRootBlock(groups) {
47620
47951
  }
47621
47952
  lines.push("");
47622
47953
  }
47954
+ if (groups.fill.length > 0) {
47955
+ for (const token of groups.fill) {
47956
+ const value2 = typeof token.value === "string" ? token.value : JSON.stringify(token.value);
47957
+ lines.push(` --rafters-${token.name}: ${value2};`);
47958
+ }
47959
+ lines.push("");
47960
+ }
47623
47961
  if (groups.other.length > 0) {
47624
47962
  for (const token of groups.other) {
47625
47963
  const value2 = tokenValueToCSS(token);
@@ -49318,24 +49656,60 @@ var TokenRegistry = class {
49318
49656
  }
49319
49657
  try {
49320
49658
  const parsedRule = this.ruleParser.parse(rule);
49321
- const newComputedValue = this.ruleExecutor.execute(parsedRule, tokenName);
49659
+ const ruleResult = this.ruleExecutor.execute(parsedRule, tokenName);
49322
49660
  this.markDirty(existingToken.namespace);
49661
+ let updatedDependsOn = existingToken.dependsOn;
49662
+ let newValue;
49663
+ switch (ruleResult.kind) {
49664
+ case "ref": {
49665
+ newValue = ruleResult.ref;
49666
+ const darkTokenName = this.findDarkCounterpart(ruleResult.ref, existingToken.dependsOn);
49667
+ updatedDependsOn = [ruleResult.ref.family, darkTokenName];
49668
+ break;
49669
+ }
49670
+ case "css":
49671
+ newValue = ruleResult.value;
49672
+ break;
49673
+ }
49323
49674
  if (existingToken.userOverride) {
49324
49675
  this.tokens.set(tokenName, {
49325
49676
  ...existingToken,
49326
- computedValue: newComputedValue
49327
- // value stays as-is (the human's choice)
49677
+ computedValue: newValue,
49678
+ dependsOn: updatedDependsOn
49328
49679
  });
49329
49680
  } else {
49330
49681
  this.tokens.set(tokenName, {
49331
49682
  ...existingToken,
49332
- value: newComputedValue,
49333
- computedValue: newComputedValue
49683
+ value: newValue,
49684
+ computedValue: newValue,
49685
+ dependsOn: updatedDependsOn
49334
49686
  });
49335
49687
  }
49336
49688
  } catch (error48) {
49337
- throw new Error(`Failed to regenerate token ${tokenName}: ${error48}`);
49689
+ throw new Error(`Failed to regenerate token ${tokenName}: ${error48}`, { cause: error48 });
49690
+ }
49691
+ }
49692
+ /**
49693
+ * Find the dark mode counterpart for a light mode ColorReference.
49694
+ * Uses the WCAG accessibility matrix from the color family's ColorValue.
49695
+ * Falls back to mathematical inversion if no WCAG data available.
49696
+ */
49697
+ findDarkCounterpart(lightRef, _existingDependsOn) {
49698
+ const lightIdx = POSITION_TO_INDEX[lightRef.position];
49699
+ if (lightIdx === void 0) {
49700
+ throw new Error(
49701
+ `Invalid position "${lightRef.position}" in ColorReference for family "${lightRef.family}". Expected one of: ${Object.keys(POSITION_TO_INDEX).join(", ")}`
49702
+ );
49338
49703
  }
49704
+ const familyToken = this.tokens.get(lightRef.family);
49705
+ if (!familyToken || typeof familyToken.value !== "object" || !("scale" in familyToken.value)) {
49706
+ const fallbackIdx = Math.max(0, Math.min(10, 10 - lightIdx));
49707
+ return `${lightRef.family}-${INDEX_TO_POSITION[fallbackIdx] ?? "500"}`;
49708
+ }
49709
+ const colorValue = familyToken.value;
49710
+ const darkIdx = findDarkCounterpartIndex(lightIdx, colorValue);
49711
+ const darkPos = INDEX_TO_POSITION[darkIdx] ?? "500";
49712
+ return `${lightRef.family}-${darkPos}`;
49339
49713
  }
49340
49714
  /**
49341
49715
  * Add multiple dependencies efficiently using bulk operations
@@ -52546,8 +52920,8 @@ function contrastDeltaPhi(color1, color2) {
52546
52920
  let Lstr1 = get(color1, [lab_d65, "l"]);
52547
52921
  let Lstr2 = get(color2, [lab_d65, "l"]);
52548
52922
  let deltaPhiStar = Math.abs(Math.pow(Lstr1, phi) - Math.pow(Lstr2, phi));
52549
- let contrast2 = Math.pow(deltaPhiStar, 1 / phi) * Math.SQRT2 - 40;
52550
- return contrast2 < 7.5 ? 0 : contrast2;
52923
+ let contrast3 = Math.pow(deltaPhiStar, 1 / phi) * Math.SQRT2 - 40;
52924
+ return contrast3 < 7.5 ? 0 : contrast3;
52551
52925
  }
52552
52926
  var contrastMethods = /* @__PURE__ */ Object.freeze({
52553
52927
  __proto__: null,
@@ -52558,7 +52932,7 @@ var contrastMethods = /* @__PURE__ */ Object.freeze({
52558
52932
  contrastWCAG21,
52559
52933
  contrastWeber
52560
52934
  });
52561
- function contrast(background, foreground, o = {}) {
52935
+ function contrast2(background, foreground, o = {}) {
52562
52936
  if (isString(o)) {
52563
52937
  o = { algorithm: o };
52564
52938
  }
@@ -53870,7 +54244,7 @@ Color.extend(deltaEMethods);
53870
54244
  Color.extend({ deltaE });
53871
54245
  Object.assign(Color, { deltaEMethods });
53872
54246
  Color.extend(variations);
53873
- Color.extend({ contrast });
54247
+ Color.extend({ contrast: contrast2 });
53874
54248
  Color.extend(chromaticity);
53875
54249
  Color.extend(luminance);
53876
54250
  Color.extend(interpolation);
@@ -53944,12 +54318,12 @@ function calculateAPCAContrast(foreground, background) {
53944
54318
  return typeof result === "number" ? result : 0;
53945
54319
  }
53946
54320
  function meetsWCAGStandard(foreground, background, level, textSize) {
53947
- const contrast2 = calculateWCAGContrast(foreground, background);
54321
+ const contrast3 = calculateWCAGContrast(foreground, background);
53948
54322
  const thresholds = {
53949
54323
  AA: { normal: 4.5, large: 3 },
53950
54324
  AAA: { normal: 7, large: 4.5 }
53951
54325
  };
53952
- return contrast2 >= thresholds[level][textSize];
54326
+ return contrast3 >= thresholds[level][textSize];
53953
54327
  }
53954
54328
  function generateAccessibilityMetadata(scale3) {
53955
54329
  if (!scale3 || scale3.length === 0) {
@@ -57342,6 +57716,102 @@ function generateElevationTokens(_config, elevationDefs) {
57342
57716
  };
57343
57717
  }
57344
57718
 
57719
+ // ../design-tokens/src/generators/fill.ts
57720
+ function validateFillDef(name2, def) {
57721
+ if (!def.color && !def.gradient) {
57722
+ return `Fill "${name2}" must have either a color or gradient field`;
57723
+ }
57724
+ if (def.gradient) {
57725
+ if (!def.gradient.stops || def.gradient.stops.length < 2) {
57726
+ return `Fill "${name2}" gradient must have at least 2 stops`;
57727
+ }
57728
+ }
57729
+ if (def.opacity !== void 0 && (def.opacity < 0 || def.opacity > 1)) {
57730
+ return `Fill "${name2}" opacity must be between 0 and 1`;
57731
+ }
57732
+ const validBlurSizes = ["sm", "md", "lg", "xl", "2xl", "3xl"];
57733
+ if (def.backdropBlur && !validBlurSizes.includes(def.backdropBlur)) {
57734
+ return `Fill "${name2}" backdropBlur must be one of: ${validBlurSizes.join(", ")}`;
57735
+ }
57736
+ return null;
57737
+ }
57738
+ function serializeFillValue(def) {
57739
+ const parts = {};
57740
+ if (def.color) parts.color = def.color;
57741
+ if (def.opacity !== void 0) parts.opacity = def.opacity;
57742
+ if (def.foreground) parts.foreground = def.foreground;
57743
+ if (def.backdropBlur) parts.backdropBlur = def.backdropBlur;
57744
+ if (def.gradient) parts.gradient = def.gradient;
57745
+ return JSON.stringify(parts);
57746
+ }
57747
+ function generateFillTokens(_config, fillDefinitions) {
57748
+ const tokens = [];
57749
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
57750
+ const fillNames = Object.keys(fillDefinitions);
57751
+ for (const [name2, def] of Object.entries(fillDefinitions)) {
57752
+ const error48 = validateFillDef(name2, def);
57753
+ if (error48) {
57754
+ throw new Error(error48);
57755
+ }
57756
+ const dependsOn = [];
57757
+ if (def.color) {
57758
+ dependsOn.push(def.color);
57759
+ }
57760
+ if (def.foreground) {
57761
+ dependsOn.push(def.foreground);
57762
+ }
57763
+ if (def.gradient) {
57764
+ for (const stop of def.gradient.stops) {
57765
+ dependsOn.push(stop.color);
57766
+ }
57767
+ }
57768
+ tokens.push({
57769
+ name: `fill-${name2}`,
57770
+ value: serializeFillValue(def),
57771
+ category: "fill",
57772
+ namespace: "fill",
57773
+ semanticMeaning: def.meaning,
57774
+ usageContext: def.contexts,
57775
+ dependsOn: dependsOn.length > 0 ? dependsOn : void 0,
57776
+ description: buildDescription(name2, def),
57777
+ generatedAt: timestamp,
57778
+ containerQueryAware: true,
57779
+ scalePosition: fillNames.indexOf(name2),
57780
+ usagePatterns: {
57781
+ do: [
57782
+ `Use fill="${name2}" on surface components (Container, Card) for ${def.meaning.toLowerCase()}`,
57783
+ ...def.gradient ? [`Use color="${name2}" on Typography for gradient text effect`] : []
57784
+ ],
57785
+ never: [
57786
+ "Do not use raw bg-* classes when a fill token exists for the purpose",
57787
+ "Do not hardcode opacity values -- use the fill token instead"
57788
+ ]
57789
+ }
57790
+ });
57791
+ }
57792
+ return {
57793
+ namespace: "fill",
57794
+ tokens
57795
+ };
57796
+ }
57797
+ function buildDescription(name2, def) {
57798
+ const parts = [`Fill token "${name2}"`];
57799
+ if (def.color && def.opacity !== void 0 && def.opacity < 1) {
57800
+ parts.push(`-- ${def.color} at ${Math.round(def.opacity * 100)}% opacity`);
57801
+ } else if (def.color) {
57802
+ parts.push(`-- solid ${def.color}`);
57803
+ }
57804
+ if (def.backdropBlur) {
57805
+ parts.push(`with backdrop-blur-${def.backdropBlur}`);
57806
+ }
57807
+ if (def.gradient) {
57808
+ const stops = def.gradient.stops.map((s) => s.color).join(" to ");
57809
+ parts.push(`-- gradient ${def.gradient.direction}: ${stops}`);
57810
+ }
57811
+ parts.push(`(${def.meaning})`);
57812
+ return parts.join(" ");
57813
+ }
57814
+
57345
57815
  // ../design-tokens/src/generators/focus.ts
57346
57816
  function pxToRem(px) {
57347
57817
  const rem = Math.round(px / 16 * 1e3) / 1e3;
@@ -58307,20 +58777,41 @@ function toColorRef(mapping) {
58307
58777
  function toDarkColorRef(mapping) {
58308
58778
  return { family: mapping.dark.family, position: mapping.dark.position };
58309
58779
  }
58780
+ function deriveGenerationRule(name2, lightRef) {
58781
+ if (name2.endsWith("-foreground") || name2.endsWith("-text") || name2.endsWith("-contrast")) {
58782
+ return "contrast:auto";
58783
+ }
58784
+ if (name2.endsWith("-hover") && !name2.endsWith("-hover-foreground")) {
58785
+ return "state:hover";
58786
+ }
58787
+ if (name2.endsWith("-active") && !name2.endsWith("-active-foreground")) {
58788
+ return "state:active";
58789
+ }
58790
+ if (name2.endsWith("-focus") && !name2.endsWith("-focus-foreground")) {
58791
+ return "state:focus";
58792
+ }
58793
+ if (name2.endsWith("-disabled") && !name2.endsWith("-disabled-foreground")) {
58794
+ return "state:disabled";
58795
+ }
58796
+ return `scale:${lightRef.position}`;
58797
+ }
58310
58798
  function generateSemanticTokens(_config) {
58311
58799
  const tokens = [];
58312
58800
  const timestamp = (/* @__PURE__ */ new Date()).toISOString();
58313
58801
  for (const [name2, mapping] of Object.entries(DEFAULT_SEMANTIC_COLOR_MAPPINGS)) {
58314
58802
  const lightRef = toColorRef(mapping);
58315
58803
  const darkRef = toDarkColorRef(mapping);
58316
- const dependsOn = [`${lightRef.family}-${lightRef.position}`];
58317
- if (darkRef.family !== lightRef.family || darkRef.position !== lightRef.position) {
58318
- dependsOn.push(`${darkRef.family}-${darkRef.position}`);
58804
+ const familyDep = lightRef.family;
58805
+ const darkTokenName = `${darkRef.family}-${darkRef.position}`;
58806
+ const dependsOn = [familyDep];
58807
+ if (darkTokenName !== familyDep) {
58808
+ dependsOn.push(darkTokenName);
58319
58809
  }
58810
+ const generationRule = deriveGenerationRule(name2, lightRef);
58320
58811
  tokens.push({
58321
58812
  name: name2,
58322
58813
  value: lightRef,
58323
- // Light mode is default value; dark mode lookup via DEFAULT_SEMANTIC_COLOR_MAPPINGS
58814
+ // Light mode is default value; dark mode lookup via dependsOn[1]
58324
58815
  category: "color",
58325
58816
  namespace: "semantic",
58326
58817
  semanticMeaning: mapping.meaning,
@@ -58328,6 +58819,7 @@ function generateSemanticTokens(_config) {
58328
58819
  trustLevel: mapping.trustLevel,
58329
58820
  consequence: mapping.consequence,
58330
58821
  dependsOn,
58822
+ generationRule,
58331
58823
  description: `${mapping.meaning}. Light: ${lightRef.family}-${lightRef.position}, Dark: ${darkRef.family}-${darkRef.position}.`,
58332
58824
  generatedAt: timestamp,
58333
58825
  containerQueryAware: true,
@@ -58676,6 +59168,21 @@ function generateTypographyTokens(config3, typographyScale, fontWeights) {
58676
59168
  never: ["Use for body text", "Use for UI elements"]
58677
59169
  }
58678
59170
  });
59171
+ tokens.push({
59172
+ name: "font-serif",
59173
+ value: 'Georgia, "Times New Roman", Times, serif',
59174
+ category: "typography",
59175
+ namespace: "typography",
59176
+ semanticMeaning: "Serif font family for editorial and long-form content",
59177
+ usageContext: ["editorial", "long-form", "articles", "blockquotes"],
59178
+ description: "Serif font family. System serif stack by default. Override in global.css @theme with your imported serif font.",
59179
+ generatedAt: timestamp,
59180
+ containerQueryAware: false,
59181
+ usagePatterns: {
59182
+ do: ["Override in global.css @theme to match imported serif font"],
59183
+ never: ["Use without importing an actual serif font for production"]
59184
+ }
59185
+ });
58679
59186
  tokens.push({
58680
59187
  name: "font-heading",
58681
59188
  value: `var(--font-sans)`,
@@ -58962,6 +59469,11 @@ function createGeneratorDefs(colorPaletteBases) {
58962
59469
  DEFAULT_DELAY_DEFINITIONS
58963
59470
  )
58964
59471
  },
59472
+ // Fill tokens (depend on color/semantic)
59473
+ {
59474
+ name: "fill",
59475
+ generate: (_config) => generateFillTokens(_config, DEFAULT_FILL_DEFINITIONS)
59476
+ },
58965
59477
  // Composite tokens (depend on multiple)
58966
59478
  {
58967
59479
  name: "elevation",
@@ -62622,100 +63134,133 @@ var RaftersToolHandler = class _RaftersToolHandler {
62622
63134
  });
62623
63135
  continue;
62624
63136
  }
62625
- let tokenValue = value2;
63137
+ let colorValue = null;
62626
63138
  let enriched = false;
62627
63139
  if (_RaftersToolHandler.isColorValue(value2)) {
62628
63140
  const oklch2 = _RaftersToolHandler.parseToOKLCH(value2);
62629
63141
  if (oklch2) {
62630
- tokenValue = await _RaftersToolHandler.buildEnrichedColor(oklch2, target);
63142
+ colorValue = await _RaftersToolHandler.buildEnrichedColor(oklch2, target);
62631
63143
  enriched = true;
62632
63144
  }
62633
63145
  }
62634
- const SCALE_POSITIONS2 = [
62635
- "50",
62636
- "100",
62637
- "200",
62638
- "300",
62639
- "400",
62640
- "500",
62641
- "600",
62642
- "700",
62643
- "800",
62644
- "900",
62645
- "950"
62646
- ];
62647
- if (enriched && tokenValue && typeof tokenValue === "object" && "scale" in tokenValue) {
62648
- const cv = tokenValue;
62649
- for (let i = 0; i < cv.scale.length && i < SCALE_POSITIONS2.length; i++) {
63146
+ if (enriched && colorValue) {
63147
+ const isSemantic = _RaftersToolHandler.SEMANTIC_FAMILY_SET.has(target);
63148
+ const familyName = isSemantic ? colorValue.name : target;
63149
+ if (registry2.has(familyName)) {
63150
+ const existingFamily = registry2.get(familyName);
63151
+ if (existingFamily && existingFamily.namespace === "semantic") {
63152
+ registry2.add({
63153
+ name: familyName,
63154
+ value: colorValue,
63155
+ category: "color",
63156
+ namespace: "color",
63157
+ semanticMeaning: `Color family for ${target}`,
63158
+ description: `Enriched color family "${familyName}" mapped to semantic role "${target}"`,
63159
+ containerQueryAware: true
63160
+ });
63161
+ } else {
63162
+ await registry2.set(familyName, colorValue);
63163
+ }
63164
+ } else {
63165
+ registry2.add({
63166
+ name: familyName,
63167
+ value: colorValue,
63168
+ category: "color",
63169
+ namespace: "color",
63170
+ semanticMeaning: `Color family for ${target}`,
63171
+ description: `Enriched color family "${familyName}" mapped to semantic role "${target}"`,
63172
+ containerQueryAware: true,
63173
+ userOverride: isSemantic ? void 0 : {
63174
+ previousValue: "",
63175
+ reason: `Onboarded from ${source}: ${reason}`
63176
+ }
63177
+ });
63178
+ }
63179
+ const SCALE_POSITIONS2 = [
63180
+ "50",
63181
+ "100",
63182
+ "200",
63183
+ "300",
63184
+ "400",
63185
+ "500",
63186
+ "600",
63187
+ "700",
63188
+ "800",
63189
+ "900",
63190
+ "950"
63191
+ ];
63192
+ for (let i = 0; i < colorValue.scale.length && i < SCALE_POSITIONS2.length; i++) {
62650
63193
  const pos = SCALE_POSITIONS2[i];
62651
- const oklchValue = cv.scale[i];
63194
+ const oklchValue = colorValue.scale[i];
62652
63195
  if (!oklchValue) continue;
62653
- const posName = `${target}-${pos}`;
63196
+ const posName = `${familyName}-${pos}`;
62654
63197
  const cssValue = oklchToCSS(oklchValue);
62655
- const posToken = {
62656
- name: posName,
62657
- value: cssValue,
62658
- category: "color",
62659
- namespace: "color",
62660
- scalePosition: i,
62661
- description: `${target} color at ${pos} position`,
62662
- containerQueryAware: true
62663
- };
62664
63198
  if (registry2.has(posName)) {
62665
63199
  await registry2.set(posName, cssValue);
62666
63200
  } else {
62667
- registry2.add(posToken);
63201
+ registry2.add({
63202
+ name: posName,
63203
+ value: cssValue,
63204
+ category: "color",
63205
+ namespace: "color",
63206
+ scalePosition: i,
63207
+ description: `${familyName} color at ${pos} position`,
63208
+ containerQueryAware: true
63209
+ });
62668
63210
  }
62669
63211
  }
62670
- }
62671
- const exists = registry2.has(target);
62672
- if (exists) {
62673
- const existing = registry2.get(target);
62674
- if (existing) {
62675
- const previousValue = existing.value;
62676
- existing.userOverride = {
62677
- previousValue: typeof previousValue === "string" ? previousValue : JSON.stringify(previousValue),
62678
- reason: `Onboarded from ${source}: ${reason}`
62679
- };
62680
- await registry2.set(target, tokenValue);
63212
+ if (isSemantic) {
63213
+ const existing = registry2.get(target);
63214
+ if (existing) {
63215
+ const previousValue = existing.value;
63216
+ existing.userOverride = {
63217
+ previousValue: typeof previousValue === "string" ? previousValue : JSON.stringify(previousValue),
63218
+ reason: `Onboarded from ${source}: ${reason}`
63219
+ };
63220
+ const defaultMapping = DEFAULT_SEMANTIC_COLOR_MAPPINGS[target];
63221
+ const lightPos = defaultMapping?.light.position ?? "900";
63222
+ await registry2.setToken({
63223
+ ...existing,
63224
+ value: { family: familyName, position: lightPos },
63225
+ dependsOn: [familyName, `${familyName}-${defaultMapping?.dark.position ?? "50"}`]
63226
+ });
63227
+ }
62681
63228
  results.push({ source, target, action: "set", ok: true, enriched });
63229
+ allCascadeTokens.push(
63230
+ ...this.cascadeSemanticFamily(registry2, target, familyName, results)
63231
+ );
62682
63232
  } else {
62683
- results.push({
62684
- source,
62685
- target,
62686
- action: "skipped",
62687
- ok: false,
62688
- error: `Token "${target}" exists in registry index but could not be retrieved.`
62689
- });
63233
+ results.push({ source, target, action: "create", ok: true, enriched });
62690
63234
  }
62691
63235
  } else {
62692
- const ns = namespace ?? (enriched ? "color" : "custom");
62693
- const cat = category ?? ns;
62694
- const newToken = {
62695
- name: target,
62696
- namespace: ns,
62697
- category: cat,
62698
- value: tokenValue,
62699
- containerQueryAware: true,
62700
- userOverride: {
62701
- previousValue: "",
62702
- reason: `Onboarded from ${source}: ${reason}`
63236
+ const tokenValue = value2;
63237
+ const exists = registry2.has(target);
63238
+ if (exists) {
63239
+ const existing = registry2.get(target);
63240
+ if (existing) {
63241
+ const previousValue = existing.value;
63242
+ existing.userOverride = {
63243
+ previousValue: typeof previousValue === "string" ? previousValue : JSON.stringify(previousValue),
63244
+ reason: `Onboarded from ${source}: ${reason}`
63245
+ };
63246
+ await registry2.set(target, tokenValue);
63247
+ results.push({ source, target, action: "set", ok: true, enriched });
62703
63248
  }
62704
- };
62705
- registry2.add(newToken);
62706
- results.push({ source, target, action: "create", ok: true, enriched });
62707
- }
62708
- if (_RaftersToolHandler.SEMANTIC_FAMILY_SET.has(target)) {
62709
- if (!enriched) {
62710
- results.push({
62711
- source,
62712
- target,
62713
- action: "skipped",
62714
- ok: false,
62715
- error: `Cascade skipped for "${target}": value was not enriched. Provide a CSS color value so the color family can be created with accessibility data.`
62716
- });
62717
63249
  } else {
62718
- allCascadeTokens.push(...this.cascadeSemanticFamily(registry2, target, target, results));
63250
+ const ns = namespace ?? "custom";
63251
+ const cat = category ?? ns;
63252
+ registry2.add({
63253
+ name: target,
63254
+ namespace: ns,
63255
+ category: cat,
63256
+ value: tokenValue,
63257
+ containerQueryAware: true,
63258
+ userOverride: {
63259
+ previousValue: "",
63260
+ reason: `Onboarded from ${source}: ${reason}`
63261
+ }
63262
+ });
63263
+ results.push({ source, target, action: "create", ok: true, enriched });
62719
63264
  }
62720
63265
  }
62721
63266
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rafters",
3
- "version": "0.0.46",
3
+ "version": "0.0.47",
4
4
  "description": "CLI for Rafters design system - scaffold tokens and add components",
5
5
  "license": "MIT",
6
6
  "type": "module",