@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/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # @particle-academy/holy-sheet
2
2
 
3
- [![Fancy UI suite](art/fancy-ui.svg)](https://particle.academy)
3
+ [![Fancified](art/fancified.svg)](https://particle.academy)
4
4
 
5
5
  Zero-dependency, **isomorphic** (browser + Node) `.xlsx` writer + reader +
6
6
  formula linter for agentic document creation. The Node/TypeScript mirror of the
7
7
  PHP [`particle-academy/holy-sheet`](https://github.com/Particle-Academy/holy-sheet)
8
- — same schema in, same `.xlsx` out (feature-parity with PHP 1.2.0; the PHP
9
- package has since shipped 1.3.0, whose additions are not yet mirrored here).
8
+ — same schema in, same `.xlsx` out (the PHP package's `dumpJson` and `Toolkit`
9
+ are not mirrored here; `CHANGELOG.md` records which PHP releases each fix mirrors).
10
10
 
11
11
  ```ts
12
12
  import { Agent } from "@particle-academy/holy-sheet";
package/dist/index.cjs CHANGED
@@ -615,7 +615,7 @@ var Normalizer = class {
615
615
  name,
616
616
  cells,
617
617
  this.normalizeMerges(sheet.mergedRegions ?? []),
618
- this.normalizeColumnWidths(sheet.columnWidths ?? {}),
618
+ this.normalizeWidths(sheet),
619
619
  toInt(sheet.frozenRows ?? 0),
620
620
  toInt(sheet.frozenCols ?? 0)
621
621
  );
@@ -661,6 +661,36 @@ var Normalizer = class {
661
661
  }
662
662
  return out;
663
663
  }
664
+ /**
665
+ * The two ways a width can be stated, folded into one map.
666
+ *
667
+ * `columns[].width` widens the column at that POSITION; the sheet-level
668
+ * `columnWidths` map keys the same columns by 0-based index. Both have been
669
+ * described in the shared `skills/holy-sheet.schema.json` ("Same as
670
+ * columnWidths but per-column") for as long as the field has existed, and only
671
+ * the map was ever read — so a width written the way the schema documents it
672
+ * emitted no `<cols>` element at all, with no error and no repair note
673
+ * (holy-sheet#8, fixed in PHP 2.4.0; this is the twin).
674
+ *
675
+ * The MAP IS APPLIED LAST and wins, matching PHP. It is the mechanism that
676
+ * already worked, so anyone who reached for it to work around this bug must not
677
+ * now find a leftover `width` quietly overriding it.
678
+ */
679
+ normalizeWidths(sheet) {
680
+ const out = /* @__PURE__ */ new Map();
681
+ for (const [colIdx, columnDef] of (sheet.columns ?? []).entries()) {
682
+ if (columnDef === null || typeof columnDef !== "object") continue;
683
+ if (columnDef.width === void 0) continue;
684
+ const index = ColumnWidths.index(colIdx);
685
+ const width = ColumnWidths.width(columnDef.width);
686
+ if (index === null || width === null) continue;
687
+ out.set(index, width);
688
+ }
689
+ for (const [index, width] of this.normalizeColumnWidths(sheet.columnWidths ?? {})) {
690
+ out.set(index, width);
691
+ }
692
+ return new Map([...out.entries()].sort((a, b) => a[0] - b[0]));
693
+ }
664
694
  normalizeColumnWidths(widths) {
665
695
  const out = /* @__PURE__ */ new Map();
666
696
  for (const [key, px] of Object.entries(widths)) {
@@ -1662,6 +1692,17 @@ var Validator = class {
1662
1692
  )
1663
1693
  );
1664
1694
  }
1695
+ if (col.width !== void 0 && ColumnWidths.width(col.width) === null) {
1696
+ errors.push(
1697
+ error(
1698
+ `${path}.width`,
1699
+ "a non-negative number of pixels",
1700
+ typeOf(col.width),
1701
+ col.width,
1702
+ "A column width is a number of pixels, like 120. The sheet-level columnWidths map takes precedence over it."
1703
+ )
1704
+ );
1705
+ }
1665
1706
  return errors;
1666
1707
  }
1667
1708
  };
@@ -5138,7 +5179,7 @@ var holy_sheet_schema_default = {
5138
5179
  };
5139
5180
 
5140
5181
  // src/agent.ts
5141
- var VERSION = "2.4.3";
5182
+ var VERSION = "2.5.0";
5142
5183
  function toU8(input) {
5143
5184
  return input instanceof Uint8Array ? input : new Uint8Array(input);
5144
5185
  }