brand-intent 0.3.1 → 0.3.2

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.3.1",
3
+ "version": "0.3.2",
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",
@@ -128,8 +128,6 @@ export interface ParsedDivider {
128
128
 
129
129
  // ── Constants ─────────────────────────────────────────────────────────────────
130
130
 
131
- /** Backward-compat map: band letters A-F → 0-based row indices */
132
- const LEGACY_BAND_MAP: Record<string, number> = { A: 0, B: 1, C: 2, D: 3, E: 4, F: 5 };
133
131
  const GRID_Y_KEYWORDS = new Set<string>(['top', 'center', 'bottom']);
134
132
 
135
133
  const VALID_SLOTS = new Set<string>(['primary', 'secondary', 'detail', 'meta', 'cta', 'label']);
@@ -292,16 +290,6 @@ export function parseCompositionFile(content: string, fileName: string): ParsedC
292
290
  logo = { row: parseInt(rowMatch[1], 10) - 1, col, size: (rowMatch[3] as 's' | 'm' | 'l') ?? undefined };
293
291
  continue;
294
292
  }
295
- // Backward compat: "logo: band A [col] X"
296
- const bandMatch = line.match(/^logo:\s+band\s+([A-F])\s+(?:col\s+)?(left|center|right)(?:\s+(s|m|l))?\s*$/);
297
- if (bandMatch) {
298
- const row = LEGACY_BAND_MAP[bandMatch[1]];
299
- if (row === undefined) throw new Error(`${fileName}:${lineNum}: unknown band "${bandMatch[1]}"`);
300
- console.warn(`${fileName}:${lineNum}: deprecated "band ${bandMatch[1]}" syntax — use "row ${row + 1}" instead`);
301
- const col = resolveColKeyword(bandMatch[2], fileName, lineNum);
302
- logo = { row, col, size: (bandMatch[3] as 's' | 'm' | 'l') ?? undefined };
303
- continue;
304
- }
305
293
  throw new Error(`${fileName}:${lineNum}: invalid logo line "${line}" (expected "logo: row N left|center|right" or "logo: top/center/bottom left|center|right")`);
306
294
  }
307
295
 
@@ -319,15 +307,6 @@ export function parseCompositionFile(content: string, fileName: string): ParsedC
319
307
  icon = { row: parseInt(rowMatch[1], 10) - 1, col, size: (rowMatch[3] as 's' | 'm' | 'l') ?? undefined };
320
308
  continue;
321
309
  }
322
- const bandMatch = line.match(/^icon:\s+band\s+([A-F])\s+(?:col\s+)?(left|center|right)(?:\s+(s|m|l))?\s*$/);
323
- if (bandMatch) {
324
- const row = LEGACY_BAND_MAP[bandMatch[1]];
325
- if (row === undefined) throw new Error(`${fileName}:${lineNum}: unknown band "${bandMatch[1]}"`);
326
- console.warn(`${fileName}:${lineNum}: deprecated "band ${bandMatch[1]}" syntax — use "row ${row + 1}" instead`);
327
- const col = resolveColKeyword(bandMatch[2], fileName, lineNum);
328
- icon = { row, col, size: (bandMatch[3] as 's' | 'm' | 'l') ?? undefined };
329
- continue;
330
- }
331
310
  throw new Error(`${fileName}:${lineNum}: invalid icon line "${line}"`);
332
311
  }
333
312
 
@@ -511,25 +490,6 @@ export function parseCompositionFile(content: string, fileName: string): ParsedC
511
490
  continue;
512
491
  }
513
492
 
514
- // Backward compat: "primary band D cols 1--4 left"
515
- const bandSlotMatch = line.match(/^(\w+)\s+band\s+([A-F])\s+cols\s+(\S+)\s+(left|center|right)$/);
516
- if (bandSlotMatch) {
517
- const [, slotId, bandLetter, colRange, align] = bandSlotMatch;
518
- if (!VALID_SLOTS.has(slotId)) throw new Error(`${fileName}:${lineNum}: unknown slot "${slotId}"`);
519
- const row = LEGACY_BAND_MAP[bandLetter];
520
- if (row === undefined) throw new Error(`${fileName}:${lineNum}: unknown band "${bandLetter}"`);
521
- console.warn(`${fileName}:${lineNum}: deprecated "band ${bandLetter}" syntax — use "row ${row + 1}" instead`);
522
- const cols = parseColRange(colRange, fileName, lineNum, 12);
523
- slots.push({
524
- id: slotId as SlotId,
525
- row,
526
- colStart: cols.start,
527
- colEnd: cols.end,
528
- textAlign: align as 'left' | 'center' | 'right',
529
- });
530
- continue;
531
- }
532
-
533
493
  // Unknown line
534
494
  throw new Error(`${fileName}:${lineNum}: unexpected "${line}"`);
535
495
  }
@@ -29,7 +29,7 @@ export interface ParsedFormat {
29
29
  dpi?: number;
30
30
  bleedMm?: number;
31
31
  // Optional grid override — absent means auto portrait/landscape selection
32
- grid?: { bands: number; cols: number };
32
+ grid?: { rows: number; cols: number };
33
33
  // Zones — always stored in px (mm values converted during parse)
34
34
  danger: ZoneInsets;
35
35
  gridCrop: ZoneInsets | null;
@@ -183,12 +183,12 @@ export function parseFormatFile(content: string, fileName: string): ParsedFormat
183
183
 
184
184
  case 'grid': {
185
185
  const parts = value.split(/\s+/);
186
- if (parts.length !== 2) throw new Error(`${fileName}:${lineNum}: grid requires "bands cols", got "${value}"`);
187
- const bands = parseInt(parts[0], 10);
186
+ if (parts.length !== 2) throw new Error(`${fileName}:${lineNum}: grid requires "rows cols", got "${value}"`);
187
+ const rows = parseInt(parts[0], 10);
188
188
  const cols = parseInt(parts[1], 10);
189
- if (isNaN(bands) || bands < 1 || isNaN(cols) || cols < 1)
190
- throw new Error(`${fileName}:${lineNum}: grid bands and cols must be positive integers`);
191
- grid = { bands, cols };
189
+ if (isNaN(rows) || rows < 1 || isNaN(cols) || cols < 1)
190
+ throw new Error(`${fileName}:${lineNum}: grid rows and cols must be positive integers`);
191
+ grid = { rows, cols };
192
192
  break;
193
193
  }
194
194