@particle-academy/holy-sheet 2.4.3 → 2.5.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/dist/index.d.cts CHANGED
@@ -223,7 +223,7 @@ interface SetMetaOp {
223
223
  }
224
224
 
225
225
  /** This package's own version, pinned to package.json by `version.test.ts`. */
226
- declare const VERSION = "2.4.3";
226
+ declare const VERSION = "2.5.0";
227
227
  type Any$6 = any;
228
228
  /**
229
229
  * Agent — the structured-tool surface for Holy Sheet. Mirrors PHP `Agent`.
@@ -295,7 +295,7 @@ type Any$5 = any;
295
295
  * over `Agent`. Provided for parity / DI ergonomics; most callers use `Agent`.
296
296
  */
297
297
  declare class HolySheet {
298
- static readonly VERSION = "2.4.3";
298
+ static readonly VERSION = "2.5.0";
299
299
  validate(schema: Any$5): ValidationError[];
300
300
  toBytes(schema: Any$5): Uint8Array;
301
301
  write(schema: Any$5, path: string): Promise<WriteResult>;
@@ -460,6 +460,22 @@ declare class Normalizer {
460
460
  private normalizeSheet;
461
461
  private normalizeCellMap;
462
462
  private normalizeMerges;
463
+ /**
464
+ * The two ways a width can be stated, folded into one map.
465
+ *
466
+ * `columns[].width` widens the column at that POSITION; the sheet-level
467
+ * `columnWidths` map keys the same columns by 0-based index. Both have been
468
+ * described in the shared `skills/holy-sheet.schema.json` ("Same as
469
+ * columnWidths but per-column") for as long as the field has existed, and only
470
+ * the map was ever read — so a width written the way the schema documents it
471
+ * emitted no `<cols>` element at all, with no error and no repair note
472
+ * (holy-sheet#8, fixed in PHP 2.4.0; this is the twin).
473
+ *
474
+ * The MAP IS APPLIED LAST and wins, matching PHP. It is the mechanism that
475
+ * already worked, so anyone who reached for it to work around this bug must not
476
+ * now find a leftover `width` quietly overriding it.
477
+ */
478
+ private normalizeWidths;
463
479
  private normalizeColumnWidths;
464
480
  private columnFormat;
465
481
  private buildCell;
package/dist/index.d.ts CHANGED
@@ -223,7 +223,7 @@ interface SetMetaOp {
223
223
  }
224
224
 
225
225
  /** This package's own version, pinned to package.json by `version.test.ts`. */
226
- declare const VERSION = "2.4.3";
226
+ declare const VERSION = "2.5.0";
227
227
  type Any$6 = any;
228
228
  /**
229
229
  * Agent — the structured-tool surface for Holy Sheet. Mirrors PHP `Agent`.
@@ -295,7 +295,7 @@ type Any$5 = any;
295
295
  * over `Agent`. Provided for parity / DI ergonomics; most callers use `Agent`.
296
296
  */
297
297
  declare class HolySheet {
298
- static readonly VERSION = "2.4.3";
298
+ static readonly VERSION = "2.5.0";
299
299
  validate(schema: Any$5): ValidationError[];
300
300
  toBytes(schema: Any$5): Uint8Array;
301
301
  write(schema: Any$5, path: string): Promise<WriteResult>;
@@ -460,6 +460,22 @@ declare class Normalizer {
460
460
  private normalizeSheet;
461
461
  private normalizeCellMap;
462
462
  private normalizeMerges;
463
+ /**
464
+ * The two ways a width can be stated, folded into one map.
465
+ *
466
+ * `columns[].width` widens the column at that POSITION; the sheet-level
467
+ * `columnWidths` map keys the same columns by 0-based index. Both have been
468
+ * described in the shared `skills/holy-sheet.schema.json` ("Same as
469
+ * columnWidths but per-column") for as long as the field has existed, and only
470
+ * the map was ever read — so a width written the way the schema documents it
471
+ * emitted no `<cols>` element at all, with no error and no repair note
472
+ * (holy-sheet#8, fixed in PHP 2.4.0; this is the twin).
473
+ *
474
+ * The MAP IS APPLIED LAST and wins, matching PHP. It is the mechanism that
475
+ * already worked, so anyone who reached for it to work around this bug must not
476
+ * now find a leftover `width` quietly overriding it.
477
+ */
478
+ private normalizeWidths;
463
479
  private normalizeColumnWidths;
464
480
  private columnFormat;
465
481
  private buildCell;
package/dist/index.js CHANGED
@@ -613,7 +613,7 @@ var Normalizer = class {
613
613
  name,
614
614
  cells,
615
615
  this.normalizeMerges(sheet.mergedRegions ?? []),
616
- this.normalizeColumnWidths(sheet.columnWidths ?? {}),
616
+ this.normalizeWidths(sheet),
617
617
  toInt(sheet.frozenRows ?? 0),
618
618
  toInt(sheet.frozenCols ?? 0)
619
619
  );
@@ -659,6 +659,36 @@ var Normalizer = class {
659
659
  }
660
660
  return out;
661
661
  }
662
+ /**
663
+ * The two ways a width can be stated, folded into one map.
664
+ *
665
+ * `columns[].width` widens the column at that POSITION; the sheet-level
666
+ * `columnWidths` map keys the same columns by 0-based index. Both have been
667
+ * described in the shared `skills/holy-sheet.schema.json` ("Same as
668
+ * columnWidths but per-column") for as long as the field has existed, and only
669
+ * the map was ever read — so a width written the way the schema documents it
670
+ * emitted no `<cols>` element at all, with no error and no repair note
671
+ * (holy-sheet#8, fixed in PHP 2.4.0; this is the twin).
672
+ *
673
+ * The MAP IS APPLIED LAST and wins, matching PHP. It is the mechanism that
674
+ * already worked, so anyone who reached for it to work around this bug must not
675
+ * now find a leftover `width` quietly overriding it.
676
+ */
677
+ normalizeWidths(sheet) {
678
+ const out = /* @__PURE__ */ new Map();
679
+ for (const [colIdx, columnDef] of (sheet.columns ?? []).entries()) {
680
+ if (columnDef === null || typeof columnDef !== "object") continue;
681
+ if (columnDef.width === void 0) continue;
682
+ const index = ColumnWidths.index(colIdx);
683
+ const width = ColumnWidths.width(columnDef.width);
684
+ if (index === null || width === null) continue;
685
+ out.set(index, width);
686
+ }
687
+ for (const [index, width] of this.normalizeColumnWidths(sheet.columnWidths ?? {})) {
688
+ out.set(index, width);
689
+ }
690
+ return new Map([...out.entries()].sort((a, b) => a[0] - b[0]));
691
+ }
662
692
  normalizeColumnWidths(widths) {
663
693
  const out = /* @__PURE__ */ new Map();
664
694
  for (const [key, px] of Object.entries(widths)) {
@@ -1660,6 +1690,17 @@ var Validator = class {
1660
1690
  )
1661
1691
  );
1662
1692
  }
1693
+ if (col.width !== void 0 && ColumnWidths.width(col.width) === null) {
1694
+ errors.push(
1695
+ error(
1696
+ `${path}.width`,
1697
+ "a non-negative number of pixels",
1698
+ typeOf(col.width),
1699
+ col.width,
1700
+ "A column width is a number of pixels, like 120. The sheet-level columnWidths map takes precedence over it."
1701
+ )
1702
+ );
1703
+ }
1663
1704
  return errors;
1664
1705
  }
1665
1706
  };
@@ -5136,7 +5177,7 @@ var holy_sheet_schema_default = {
5136
5177
  };
5137
5178
 
5138
5179
  // src/agent.ts
5139
- var VERSION = "2.4.3";
5180
+ var VERSION = "2.5.0";
5140
5181
  function toU8(input) {
5141
5182
  return input instanceof Uint8Array ? input : new Uint8Array(input);
5142
5183
  }