@rojaostudio/ds-core 1.1.0-next.2 → 1.1.0-next.3

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.
@@ -1092,7 +1092,7 @@ ${lines.join("\n")}
1092
1092
  const scopes = scope.split(",").map((s) => s.trim());
1093
1093
  const darkSel = scopes.map((s) => s === ":root" ? `:root${dark}, ${dark}` : `${s}${dark}, ${dark} ${s}`).join(", ");
1094
1094
  return [
1095
- block2(scope, theme.light),
1095
+ block2(scope, __spreadValues(__spreadValues({}, theme.light), theme.vars)),
1096
1096
  block2(darkSel, theme.dark, theme.light),
1097
1097
  block2(plate, theme.brand, theme.light)
1098
1098
  ].join("\n\n") + "\n";
@@ -1123,6 +1123,19 @@ function rdsThemeFromTable(table) {
1123
1123
  } else out[mode][roleVar(role)] = ref2;
1124
1124
  }
1125
1125
  }
1126
+ const valueOf = (where, ref2) => {
1127
+ if (!isColourRef(ref2)) return ref2;
1128
+ const value = table.primitives[ref2];
1129
+ if (value === void 0) problems.push(`${where} points to unknown primitive "${ref2}"`);
1130
+ return value == null ? void 0 : value.toLowerCase();
1131
+ };
1132
+ if (table.vars) {
1133
+ out.vars = {};
1134
+ for (const [name, ref2] of Object.entries(table.vars)) {
1135
+ const value = valueOf(`var "${name}"`, ref2);
1136
+ if (value !== void 0) out.vars[roleVar(name)] = value;
1137
+ }
1138
+ }
1126
1139
  if (problems.length) throw new Error(`rdsThemeFromTable(${table.name}):
1127
1140
  ${problems.join("\n ")}`);
1128
1141
  return out;
@@ -3,7 +3,10 @@ import { a as BrandDef } from './recipe.schema-Cq7e82nx.js';
3
3
  export { A as Archetype, B as BrandColors, C as ColorRef, D as DarkStrategy, F as FontDef, P as PaletteRef, S as ScaleToken, T as TextStyle, b as TextStyleName, c as TypeScale } from './recipe.schema-Cq7e82nx.js';
4
4
 
5
5
  type RdsMode = "light" | "dark" | "brand";
6
- type RdsTheme = Record<RdsMode, Record<string, string>>;
6
+ type RdsTheme = Record<RdsMode, Record<string, string>> & {
7
+ /** The brand's own variables (Figma `brand` collection, `<brand>/<name>`), one value for every mode. */
8
+ vars?: Record<string, string>;
9
+ };
7
10
  /**
8
11
  * Roles of the [RDS] theme collection, in Figma order: [name, dark source, brand source].
9
12
  * The light mode always reads the plain base token. In dark and brand, Figma points either to the
@@ -38,6 +41,8 @@ type RdsBrandTable = {
38
41
  name: string;
39
42
  primitives: Record<string, string>;
40
43
  modes: Record<RdsMode, Record<string, string>>;
44
+ /** The brand's own variables of the `brand` collection, by Figma path ("acassius/cyan") → primitive or value. */
45
+ vars?: Record<string, string>;
41
46
  };
42
47
  /** The theme of a brand table. Fails on a missing role or an unknown primitive, listing them all. */
43
48
  declare function rdsThemeFromTable(table: RdsBrandTable): RdsTheme;
package/dist/generate.js CHANGED
@@ -1,3 +1,3 @@
1
- export { ROLES as RDS_ROLES, SCALE_STEPS, brandTones, buildScale, contrastRatio, emitClaudeMd, emitCss, emitRdsCss, generateRdsTheme, generateTheme, hexToHsl, hslToHex, isHex, isNeutralBrand, onColor, rdsContrast, rdsThemeFromTable, refToHex, relativeLuminance, resolveTheme, roleVar } from './chunk-DZAJKHNW.js';
1
+ export { ROLES as RDS_ROLES, SCALE_STEPS, brandTones, buildScale, contrastRatio, emitClaudeMd, emitCss, emitRdsCss, generateRdsTheme, generateTheme, hexToHsl, hslToHex, isHex, isNeutralBrand, onColor, rdsContrast, rdsThemeFromTable, refToHex, relativeLuminance, resolveTheme, roleVar } from './chunk-XEVAQPW7.js';
2
2
  import './chunk-FRWRLCYM.js';
3
3
  import './chunk-ORMEWXMH.js';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export { recipes } from './chunk-3QTDO2HW.js';
2
- export { ROLES as RDS_ROLES, SCALE_STEPS, brandTones, buildScale, contrastRatio, emitClaudeMd, emitCss, emitRdsCss, generateRdsTheme, generateTheme, hexToHsl, hslToHex, isHex, isNeutralBrand, onColor, rdsContrast, rdsThemeFromTable, refToHex, relativeLuminance, resolveTheme, roleVar } from './chunk-DZAJKHNW.js';
2
+ export { ROLES as RDS_ROLES, SCALE_STEPS, brandTones, buildScale, contrastRatio, emitClaudeMd, emitCss, emitRdsCss, generateRdsTheme, generateTheme, hexToHsl, hslToHex, isHex, isNeutralBrand, onColor, rdsContrast, rdsThemeFromTable, refToHex, relativeLuminance, resolveTheme, roleVar } from './chunk-XEVAQPW7.js';
3
3
  export { primitives, tokens } from './chunk-FRWRLCYM.js';
4
4
  import './chunk-ORMEWXMH.js';
package/dist/themes.js CHANGED
@@ -1,4 +1,4 @@
1
- import { generateTheme } from './chunk-DZAJKHNW.js';
1
+ import { generateTheme } from './chunk-XEVAQPW7.js';
2
2
  import './chunk-FRWRLCYM.js';
3
3
  import { __spreadValues, __objRest } from './chunk-ORMEWXMH.js';
4
4
 
@@ -5,6 +5,7 @@
5
5
  //
6
6
  // Each theme role is followed through the aliases of the `base` collection (in the brand's mode) down to a
7
7
  // primitive of the [RDS] Primitives library, kept by name ("accyan/400") with the colour Figma resolves.
8
+ // The brand's own variables in the `brand` collection (`<brand>/<name>`, as acassius/cyan) come along in `vars`.
8
9
  const BRAND = "rojao";
9
10
 
10
11
  const cols = await figma.variables.getLocalVariableCollectionsAsync();
@@ -47,5 +48,11 @@ for (const m of theme.modes) {
47
48
  }
48
49
  modes[m.name] = roles;
49
50
  }
51
+ const vars = {};
52
+ const brandCol = cols.find((c) => c.name === "brand");
53
+ for (const id of brandCol?.variableIds ?? []) {
54
+ const v = await figma.variables.getVariableByIdAsync(id);
55
+ if (v.name.startsWith(`${BRAND}/`)) vars[v.name] = await resolve(v, theme.modes[0].modeId);
56
+ }
50
57
  const sorted = Object.fromEntries(Object.entries(primitives).sort(([a], [b]) => a.localeCompare(b)));
51
- return { $schema: "rds-brand-table/1", name: BRAND, primitives: sorted, modes };
58
+ return { $schema: "rds-brand-table/1", name: BRAND, primitives: sorted, modes, vars };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rojaostudio/ds-core",
3
- "version": "1.1.0-next.2",
3
+ "version": "1.1.0-next.3",
4
4
  "description": "O motor do Rojão DS — tokens, derivação de tema e emissores. Sem React, sem Tailwind, sem CSS.",
5
5
  "license": "MIT",
6
6
  "author": "Rojão Studio (https://rojao.studio)",