@particle-academy/holy-sheet 2.1.0 → 2.2.1

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
@@ -102,8 +102,8 @@ interface BuilderOptions {
102
102
  enclosure?: string;
103
103
  }
104
104
 
105
- /** Feature-parity baseline with PHP holy-sheet; bumped independently on npm. */
106
- declare const VERSION = "1.0.0";
105
+ /** This package's own version, pinned to package.json by `version.test.ts`. */
106
+ declare const VERSION = "2.2.1";
107
107
  type Any$5 = any;
108
108
  /**
109
109
  * Agent — the structured-tool surface for Holy Sheet. Mirrors PHP `Agent`.
@@ -140,7 +140,7 @@ type Any$4 = any;
140
140
  * over `Agent`. Provided for parity / DI ergonomics; most callers use `Agent`.
141
141
  */
142
142
  declare class HolySheet {
143
- static readonly VERSION = "1.0.0";
143
+ static readonly VERSION = "2.2.1";
144
144
  validate(schema: Any$4): ValidationError[];
145
145
  toBytes(schema: Any$4): Uint8Array;
146
146
  write(schema: Any$4, path: string): Promise<WriteResult>;
package/dist/index.d.ts CHANGED
@@ -102,8 +102,8 @@ interface BuilderOptions {
102
102
  enclosure?: string;
103
103
  }
104
104
 
105
- /** Feature-parity baseline with PHP holy-sheet; bumped independently on npm. */
106
- declare const VERSION = "1.0.0";
105
+ /** This package's own version, pinned to package.json by `version.test.ts`. */
106
+ declare const VERSION = "2.2.1";
107
107
  type Any$5 = any;
108
108
  /**
109
109
  * Agent — the structured-tool surface for Holy Sheet. Mirrors PHP `Agent`.
@@ -140,7 +140,7 @@ type Any$4 = any;
140
140
  * over `Agent`. Provided for parity / DI ergonomics; most callers use `Agent`.
141
141
  */
142
142
  declare class HolySheet {
143
- static readonly VERSION = "1.0.0";
143
+ static readonly VERSION = "2.2.1";
144
144
  validate(schema: Any$4): ValidationError[];
145
145
  toBytes(schema: Any$4): Uint8Array;
146
146
  write(schema: Any$4, path: string): Promise<WriteResult>;
package/dist/index.js CHANGED
@@ -509,16 +509,6 @@ var Normalizer = class {
509
509
  }
510
510
  normalizeSheet(sheet) {
511
511
  const name = String(sheet.name);
512
- if (sheet.cells != null) {
513
- return new Sheet(
514
- name,
515
- this.normalizeCellMap(sheet.cells),
516
- this.normalizeMerges(sheet.mergedRegions ?? []),
517
- this.normalizeColumnWidths(sheet.columnWidths ?? {}),
518
- toInt(sheet.frozenRows ?? 0),
519
- toInt(sheet.frozenCols ?? 0)
520
- );
521
- }
522
512
  const cells = /* @__PURE__ */ new Map();
523
513
  const columns = sheet.columns ?? [];
524
514
  const rows = sheet.rows ?? [];
@@ -570,6 +560,22 @@ var Normalizer = class {
570
560
  cells.set(address, new Cell(address, null, `${excelFunc}(${rangeStart}:${rangeEnd})`, combined));
571
561
  }
572
562
  }
563
+ if (sheet.cells != null) {
564
+ for (const [address, cell] of this.normalizeCellMap(sheet.cells)) {
565
+ const beneath = cells.get(address);
566
+ cells.set(
567
+ address,
568
+ beneath?.format ? new Cell(
569
+ cell.address,
570
+ cell.value,
571
+ cell.formula,
572
+ beneath.format.mergeWith(cell.format),
573
+ cell.comment,
574
+ cell.cachedValue
575
+ ) : cell
576
+ );
577
+ }
578
+ }
573
579
  return new Sheet(
574
580
  name,
575
581
  cells,
@@ -582,12 +588,20 @@ var Normalizer = class {
582
588
  normalizeCellMap(map) {
583
589
  const cells = /* @__PURE__ */ new Map();
584
590
  for (const [address, cellData] of Object.entries(map)) {
585
- const format = cellData && isPlainObject(cellData.format) ? CellFormat.fromInput(cellData.format) : null;
586
- const comment = cellData && isPlainObject(cellData.comment) ? new CellComment(
591
+ if (!isPlainObject(cellData)) {
592
+ const [bare, formula] = promoteFormula(cellData);
593
+ cells.set(
594
+ address,
595
+ new Cell(address, formula !== null ? null : this.coerceValue(bare, null), formula)
596
+ );
597
+ continue;
598
+ }
599
+ const format = isPlainObject(cellData.format) ? CellFormat.fromInput(cellData.format) : null;
600
+ const comment = isPlainObject(cellData.comment) ? new CellComment(
587
601
  String(cellData.comment.text ?? ""),
588
602
  cellData.comment.author ?? null,
589
603
  cellData.comment.color ?? null
590
- ) : null;
604
+ ) : typeof cellData.comment === "string" ? new CellComment(cellData.comment) : null;
591
605
  const rawValue = cellData?.value ?? null;
592
606
  cells.set(
593
607
  address,
@@ -660,7 +674,13 @@ var Normalizer = class {
660
674
  value.computedValue ?? null
661
675
  );
662
676
  }
663
- return new Cell(address, this.coerceValue(value, columnFormat), null, columnFormat);
677
+ const [bare, formula] = promoteFormula(value);
678
+ return new Cell(
679
+ address,
680
+ formula !== null ? null : this.coerceValue(bare, columnFormat),
681
+ formula,
682
+ columnFormat
683
+ );
664
684
  }
665
685
  coerceValue(value, format) {
666
686
  if (value === null || value === void 0) return null;
@@ -682,6 +702,12 @@ var Normalizer = class {
682
702
  return value;
683
703
  }
684
704
  };
705
+ function promoteFormula(value) {
706
+ if (typeof value === "string" && value.length > 1 && value[0] === "=") {
707
+ return [null, value.slice(1)];
708
+ }
709
+ return [value, null];
710
+ }
685
711
  function toInt(v) {
686
712
  const n = Math.trunc(Number(v));
687
713
  return Number.isFinite(n) ? n : 0;
@@ -3124,7 +3150,7 @@ var holy_sheet_schema_default = {
3124
3150
  };
3125
3151
 
3126
3152
  // src/agent.ts
3127
- var VERSION = "1.0.0";
3153
+ var VERSION = "2.2.1";
3128
3154
  function toU8(input) {
3129
3155
  return input instanceof Uint8Array ? input : new Uint8Array(input);
3130
3156
  }