brand-intent 0.18.0 → 0.19.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brand-intent",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "description": "An open file format specification for making brand intent machine-readable.",
5
5
  "author": "Christophe Stoll <christophe@stoll.studio>",
6
6
  "license": "MIT",
@@ -1202,13 +1202,16 @@ export function parseBrandFile(content: string, fileName: string): ParsedBrand {
1202
1202
  if (!Number.isInteger(distance) || distance < 1) throw new Error(`${fileName}: color-families distance must be a whole number ≥ 1, got "${familiesProps.distance}"`);
1203
1203
  if (familiesRaw.length === 0) throw new Error(`${fileName}: color-families declares no family`);
1204
1204
 
1205
- const shared: Array<{ name: string; hex: string }> = [];
1206
- for (const ref of (familiesProps.shared ?? '').split(',').map(r => r.trim()).filter(Boolean)) {
1207
- if (!ref.startsWith('$')) throw new Error(`${fileName}: color-families shared entries must be $refs to brand-colors, got "${ref}"`);
1208
- const hex = brandColors[ref.slice(1)] ? normalizeHex(brandColors[ref.slice(1)]) : null;
1209
- if (!hex || !isHex6(hex)) throw new Error(`${fileName}: color-families shared "${ref}" is not a known 6-digit brand color`);
1210
- shared.push({ name: ref.slice(1), hex });
1211
- }
1205
+ /** Comma-separated `$refs` to brand-colors (`shared:`, `photo-fallback:`). */
1206
+ const colorRefs = (key: string): Array<{ name: string; hex: string }> =>
1207
+ (familiesProps[key] ?? '').split(',').map(r => r.trim()).filter(Boolean).map(ref => {
1208
+ if (!ref.startsWith('$')) throw new Error(`${fileName}: color-families ${key} entries must be $refs to brand-colors, got "${ref}"`);
1209
+ const hex = brandColors[ref.slice(1)] ? normalizeHex(brandColors[ref.slice(1)]) : null;
1210
+ if (!hex || !isHex6(hex)) throw new Error(`${fileName}: color-families ${key} "${ref}" is not a known 6-digit brand color`);
1211
+ return { name: ref.slice(1), hex };
1212
+ });
1213
+ const shared = colorRefs('shared');
1214
+ const photoFallback = colorRefs('photo-fallback');
1212
1215
 
1213
1216
  const families: ColorFamily[] = [];
1214
1217
  for (const raw of familiesRaw) {
@@ -1245,7 +1248,7 @@ export function parseBrandFile(content: string, fileName: string): ParsedBrand {
1245
1248
  const twin = dated.find(o => o !== f && o.from === f.from);
1246
1249
  if (twin) throw new Error(`${fileName}:${f.line}: families "${twin.name}" and "${f.name}" share from: ${f.from}`);
1247
1250
  }
1248
- colorFamilies = { order, borrow, distance, shared, families };
1251
+ colorFamilies = { order, borrow, distance, shared, ...(photoFallback.length > 0 ? { photoFallback } : {}), families };
1249
1252
  if (borrow !== 'none' && reachCoversAll(families.length, { order, borrow, distance })) {
1250
1253
  colorWarnings.push(`color-families: borrow "${borrow}" with distance ${distance} reaches every family — the borrow rule has no effect`);
1251
1254
  }
package/parser/types.ts CHANGED
@@ -168,6 +168,9 @@ export interface ColorFamilies {
168
168
  distance: number;
169
169
  /** Colors allowed in every family (resolved from `shared:` refs). */
170
170
  shared: Array<{ name: string; hex: string }>;
171
+ /** Text and figure colors for photos no pair reads on, in order of preference (`photo-fallback:` refs).
172
+ * Used only over photos, never in pairs or guided generation. Absent when not declared. */
173
+ photoFallback?: Array<{ name: string; hex: string }>;
171
174
  families: ColorFamily[];
172
175
  }
173
176
 
@@ -120,8 +120,8 @@
120
120
  }
121
121
  },
122
122
  "color-families-property": {
123
- "comment": "Block keys under color-families: order/borrow/distance/shared",
124
- "match": "^( {2})(order|borrow|distance|shared)(:\\s*)(.+)$",
123
+ "comment": "Block keys under color-families: order/borrow/distance/shared/photo-fallback",
124
+ "match": "^( {2})(order|borrow|distance|shared|photo-fallback)(:\\s*)(.+)$",
125
125
  "captures": {
126
126
  "2": { "name": "support.type.property-name.brand-intent-brand" },
127
127
  "3": { "name": "punctuation.separator.key-value.brand-intent-brand" },