@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/cjs/index.js
CHANGED
|
@@ -53231,6 +53231,11 @@ class FormulaParser {
|
|
|
53231
53231
|
);
|
|
53232
53232
|
this.onRange = config.onRange;
|
|
53233
53233
|
this.onCell = config.onCell;
|
|
53234
|
+
// Observer of every cell / range the evaluation actually reads, with the
|
|
53235
|
+
// cell being evaluated. `INDIRECT` / `OFFSET` targets only exist at run
|
|
53236
|
+
// time, so this is how a host learns the dynamic precedents of a formula
|
|
53237
|
+
// (the dependency parser cannot see them).
|
|
53238
|
+
this.onReferenceResolved = config.onReferenceResolved;
|
|
53234
53239
|
// Optional host callback reporting row visibility for SUBTOTAL:
|
|
53235
53240
|
// ({sheet, row}) => {hiddenByFilter?: boolean, hiddenByUser?: boolean}
|
|
53236
53241
|
this.onRowHidden = config.onRowHidden;
|
|
@@ -53380,18 +53385,36 @@ class FormulaParser {
|
|
|
53380
53385
|
const bounds = this.onSpilledRange(ref);
|
|
53381
53386
|
if (bounds instanceof FormulaError) return bounds;
|
|
53382
53387
|
if (bounds && bounds.from && bounds.to) {
|
|
53383
|
-
|
|
53388
|
+
const spilled = {
|
|
53384
53389
|
from: bounds.from,
|
|
53385
53390
|
to: bounds.to,
|
|
53386
53391
|
sheet: bounds.sheet ?? ref.sheet,
|
|
53387
|
-
}
|
|
53392
|
+
};
|
|
53393
|
+
this.noteReferenceResolved("range", spilled, finalPosition);
|
|
53394
|
+
return this.onRange(spilled);
|
|
53388
53395
|
}
|
|
53389
53396
|
}
|
|
53390
53397
|
return FormulaError.REF;
|
|
53391
53398
|
}
|
|
53399
|
+
this.noteReferenceResolved("cell", ref, finalPosition);
|
|
53392
53400
|
return this.onCell(ref);
|
|
53393
53401
|
}
|
|
53394
53402
|
|
|
53403
|
+
/**
|
|
53404
|
+
* Tell the host which reference an evaluation is about to read.
|
|
53405
|
+
* @param {"cell"|"range"} kind
|
|
53406
|
+
* @param ref - the resolved reference (sheet already defaulted)
|
|
53407
|
+
* @param position - the cell being evaluated, when known
|
|
53408
|
+
*/
|
|
53409
|
+
noteReferenceResolved(kind, ref, position) {
|
|
53410
|
+
if (typeof this.onReferenceResolved !== "function") return;
|
|
53411
|
+
try {
|
|
53412
|
+
this.onReferenceResolved({ kind, ref, position });
|
|
53413
|
+
} catch {
|
|
53414
|
+
// An observer must never break the evaluation.
|
|
53415
|
+
}
|
|
53416
|
+
}
|
|
53417
|
+
|
|
53395
53418
|
/**
|
|
53396
53419
|
* Get values from the range reference.
|
|
53397
53420
|
* @param ref
|
|
@@ -53406,6 +53429,7 @@ class FormulaParser {
|
|
|
53406
53429
|
if (ref.sheetEnd != null) {
|
|
53407
53430
|
return this.get3DRange(ref, true);
|
|
53408
53431
|
}
|
|
53432
|
+
this.noteReferenceResolved("range", ref, finalPosition);
|
|
53409
53433
|
return this.onRange(ref);
|
|
53410
53434
|
}
|
|
53411
53435
|
|
|
@@ -53442,6 +53466,11 @@ class FormulaParser {
|
|
|
53442
53466
|
for (const sheet of sheets) {
|
|
53443
53467
|
const { sheetEnd: _ignored, ...perSheet } = ref;
|
|
53444
53468
|
perSheet.sheet = sheet;
|
|
53469
|
+
this.noteReferenceResolved(
|
|
53470
|
+
isRange ? "range" : "cell",
|
|
53471
|
+
perSheet,
|
|
53472
|
+
this.position,
|
|
53473
|
+
);
|
|
53445
53474
|
const value = isRange ? this.onRange(perSheet) : this.onCell(perSheet);
|
|
53446
53475
|
if (value instanceof FormulaError) return value;
|
|
53447
53476
|
if (Array.isArray(value)) {
|