@rowsncolumns/fast-formula-parser 6.2.44 → 6.2.45
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/cjs/index.js +31 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +31 -2
- package/dist/esm/index.js.map +1 -1
- package/index.d.ts +12 -0
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -53227,6 +53227,11 @@ class FormulaParser {
|
|
|
53227
53227
|
);
|
|
53228
53228
|
this.onRange = config.onRange;
|
|
53229
53229
|
this.onCell = config.onCell;
|
|
53230
|
+
// Observer of every cell / range the evaluation actually reads, with the
|
|
53231
|
+
// cell being evaluated. `INDIRECT` / `OFFSET` targets only exist at run
|
|
53232
|
+
// time, so this is how a host learns the dynamic precedents of a formula
|
|
53233
|
+
// (the dependency parser cannot see them).
|
|
53234
|
+
this.onReferenceResolved = config.onReferenceResolved;
|
|
53230
53235
|
// Optional host callback reporting row visibility for SUBTOTAL:
|
|
53231
53236
|
// ({sheet, row}) => {hiddenByFilter?: boolean, hiddenByUser?: boolean}
|
|
53232
53237
|
this.onRowHidden = config.onRowHidden;
|
|
@@ -53376,18 +53381,36 @@ class FormulaParser {
|
|
|
53376
53381
|
const bounds = this.onSpilledRange(ref);
|
|
53377
53382
|
if (bounds instanceof FormulaError) return bounds;
|
|
53378
53383
|
if (bounds && bounds.from && bounds.to) {
|
|
53379
|
-
|
|
53384
|
+
const spilled = {
|
|
53380
53385
|
from: bounds.from,
|
|
53381
53386
|
to: bounds.to,
|
|
53382
53387
|
sheet: bounds.sheet ?? ref.sheet,
|
|
53383
|
-
}
|
|
53388
|
+
};
|
|
53389
|
+
this.noteReferenceResolved("range", spilled, finalPosition);
|
|
53390
|
+
return this.onRange(spilled);
|
|
53384
53391
|
}
|
|
53385
53392
|
}
|
|
53386
53393
|
return FormulaError.REF;
|
|
53387
53394
|
}
|
|
53395
|
+
this.noteReferenceResolved("cell", ref, finalPosition);
|
|
53388
53396
|
return this.onCell(ref);
|
|
53389
53397
|
}
|
|
53390
53398
|
|
|
53399
|
+
/**
|
|
53400
|
+
* Tell the host which reference an evaluation is about to read.
|
|
53401
|
+
* @param {"cell"|"range"} kind
|
|
53402
|
+
* @param ref - the resolved reference (sheet already defaulted)
|
|
53403
|
+
* @param position - the cell being evaluated, when known
|
|
53404
|
+
*/
|
|
53405
|
+
noteReferenceResolved(kind, ref, position) {
|
|
53406
|
+
if (typeof this.onReferenceResolved !== "function") return;
|
|
53407
|
+
try {
|
|
53408
|
+
this.onReferenceResolved({ kind, ref, position });
|
|
53409
|
+
} catch {
|
|
53410
|
+
// An observer must never break the evaluation.
|
|
53411
|
+
}
|
|
53412
|
+
}
|
|
53413
|
+
|
|
53391
53414
|
/**
|
|
53392
53415
|
* Get values from the range reference.
|
|
53393
53416
|
* @param ref
|
|
@@ -53402,6 +53425,7 @@ class FormulaParser {
|
|
|
53402
53425
|
if (ref.sheetEnd != null) {
|
|
53403
53426
|
return this.get3DRange(ref, true);
|
|
53404
53427
|
}
|
|
53428
|
+
this.noteReferenceResolved("range", ref, finalPosition);
|
|
53405
53429
|
return this.onRange(ref);
|
|
53406
53430
|
}
|
|
53407
53431
|
|
|
@@ -53438,6 +53462,11 @@ class FormulaParser {
|
|
|
53438
53462
|
for (const sheet of sheets) {
|
|
53439
53463
|
const { sheetEnd: _ignored, ...perSheet } = ref;
|
|
53440
53464
|
perSheet.sheet = sheet;
|
|
53465
|
+
this.noteReferenceResolved(
|
|
53466
|
+
isRange ? "range" : "cell",
|
|
53467
|
+
perSheet,
|
|
53468
|
+
this.position,
|
|
53469
|
+
);
|
|
53441
53470
|
const value = isRange ? this.onRange(perSheet) : this.onCell(perSheet);
|
|
53442
53471
|
if (value instanceof FormulaError) return value;
|
|
53443
53472
|
if (Array.isArray(value)) {
|