@ricsam/formula-engine 0.2.5 → 0.2.7
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/core/engine-snapshot.cjs +2 -2
- package/dist/cjs/core/engine-snapshot.cjs.map +2 -2
- package/dist/cjs/core/engine.cjs +3 -3
- package/dist/cjs/core/engine.cjs.map +3 -3
- package/dist/cjs/core/managers/dependency-manager.cjs +15 -17
- package/dist/cjs/core/managers/dependency-manager.cjs.map +3 -3
- package/dist/cjs/core/managers/evaluation-manager.cjs +15 -17
- package/dist/cjs/core/managers/evaluation-manager.cjs.map +3 -3
- package/dist/cjs/evaluator/evaluation-context.cjs +22 -6
- package/dist/cjs/evaluator/evaluation-context.cjs.map +3 -3
- package/dist/cjs/evaluator/formula-evaluator.cjs +3 -3
- package/dist/cjs/evaluator/formula-evaluator.cjs.map +3 -3
- package/dist/cjs/package.json +1 -1
- package/dist/mjs/core/engine-snapshot.mjs +2 -2
- package/dist/mjs/core/engine-snapshot.mjs.map +2 -2
- package/dist/mjs/core/engine.mjs +3 -3
- package/dist/mjs/core/engine.mjs.map +3 -3
- package/dist/mjs/core/managers/dependency-manager.mjs +15 -17
- package/dist/mjs/core/managers/dependency-manager.mjs.map +3 -3
- package/dist/mjs/core/managers/evaluation-manager.mjs +15 -17
- package/dist/mjs/core/managers/evaluation-manager.mjs.map +3 -3
- package/dist/mjs/evaluator/evaluation-context.mjs +23 -6
- package/dist/mjs/evaluator/evaluation-context.mjs.map +3 -3
- package/dist/mjs/evaluator/formula-evaluator.mjs +3 -3
- package/dist/mjs/evaluator/formula-evaluator.mjs.map +3 -3
- package/dist/mjs/package.json +1 -1
- package/dist/types/core/engine-snapshot.d.ts +13 -13
- package/dist/types/core/managers/dependency-manager.d.ts +0 -1
- package/dist/types/evaluator/evaluation-context.d.ts +3 -0
- package/package.json +1 -1
|
@@ -437,6 +437,12 @@ class EvaluationManager {
|
|
|
437
437
|
if (node.resolved) {
|
|
438
438
|
return;
|
|
439
439
|
}
|
|
440
|
+
const finalizePersistentNode = () => {
|
|
441
|
+
if (node instanceof VirtualCellValueNode) {
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
this.dependencyManager.registerNode(node);
|
|
445
|
+
};
|
|
440
446
|
if (!(node instanceof VirtualCellValueNode)) {
|
|
441
447
|
this.dependencyManager.unregisterNode(node);
|
|
442
448
|
}
|
|
@@ -447,7 +453,7 @@ class EvaluationManager {
|
|
|
447
453
|
if (spillOrigin.evaluationResult.type === "spilled-values") {
|
|
448
454
|
const result = spillOrigin.evaluationResult.evaluate({ x: 0, y: 0 }, ctx);
|
|
449
455
|
node.setEvaluationResult(result);
|
|
450
|
-
|
|
456
|
+
finalizePersistentNode();
|
|
451
457
|
return;
|
|
452
458
|
}
|
|
453
459
|
}
|
|
@@ -476,7 +482,7 @@ class EvaluationManager {
|
|
|
476
482
|
node.setEvaluationResult({
|
|
477
483
|
type: "does-not-spill"
|
|
478
484
|
});
|
|
479
|
-
|
|
485
|
+
finalizePersistentNode();
|
|
480
486
|
return;
|
|
481
487
|
}
|
|
482
488
|
const result = {
|
|
@@ -484,9 +490,7 @@ class EvaluationManager {
|
|
|
484
490
|
result: this.convertScalarValueToCellValue(content)
|
|
485
491
|
};
|
|
486
492
|
node.setEvaluationResult(result);
|
|
487
|
-
|
|
488
|
-
this.dependencyManager.registerNode(node);
|
|
489
|
-
}
|
|
493
|
+
finalizePersistentNode();
|
|
490
494
|
return;
|
|
491
495
|
}
|
|
492
496
|
let evaluation = captureEvaluationErrors(node, () => this.formulaEvaluator.evaluateFormula(content.slice(1), ctx));
|
|
@@ -507,7 +511,7 @@ class EvaluationManager {
|
|
|
507
511
|
}
|
|
508
512
|
if (node instanceof SpillMetaNode) {
|
|
509
513
|
node.setEvaluationResult(evaluation);
|
|
510
|
-
|
|
514
|
+
finalizePersistentNode();
|
|
511
515
|
} else {
|
|
512
516
|
const spillMetaNode = this.dependencyManager.getSpillMetaNode(node.key.replace(/^[^:]+:/, "spill-meta:"));
|
|
513
517
|
node.addDependency(spillMetaNode);
|
|
@@ -521,9 +525,7 @@ class EvaluationManager {
|
|
|
521
525
|
node.setEvaluationResult(evaluation);
|
|
522
526
|
}
|
|
523
527
|
}
|
|
524
|
-
|
|
525
|
-
this.dependencyManager.registerNode(node);
|
|
526
|
-
}
|
|
528
|
+
finalizePersistentNode();
|
|
527
529
|
return;
|
|
528
530
|
}
|
|
529
531
|
if (evaluation.type === "value") {
|
|
@@ -531,20 +533,16 @@ class EvaluationManager {
|
|
|
531
533
|
node.setEvaluationResult({
|
|
532
534
|
type: "does-not-spill"
|
|
533
535
|
});
|
|
534
|
-
|
|
536
|
+
finalizePersistentNode();
|
|
535
537
|
return;
|
|
536
538
|
} else {
|
|
537
539
|
node.setEvaluationResult(evaluation);
|
|
538
|
-
|
|
539
|
-
this.dependencyManager.registerNode(node);
|
|
540
|
-
}
|
|
540
|
+
finalizePersistentNode();
|
|
541
541
|
return;
|
|
542
542
|
}
|
|
543
543
|
}
|
|
544
544
|
node.setEvaluationResult(evaluation);
|
|
545
|
-
|
|
546
|
-
this.dependencyManager.registerNode(node);
|
|
547
|
-
}
|
|
545
|
+
finalizePersistentNode();
|
|
548
546
|
}
|
|
549
547
|
evaluateDependencyNode(dependency) {
|
|
550
548
|
if (dependency instanceof EmptyCellEvaluationNode) {
|
|
@@ -725,4 +723,4 @@ export {
|
|
|
725
723
|
EvaluationManager
|
|
726
724
|
};
|
|
727
725
|
|
|
728
|
-
//# debugId=
|
|
726
|
+
//# debugId=E28F2E811FD149C364756E2164756E21
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/core/managers/evaluation-manager.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { flags } from \"../../debug/flags.mjs\";\nimport { AstEvaluationNode } from \"../../evaluator/dependency-nodes/ast-evaluation-node.mjs\";\nimport { CellValueNode } from \"../../evaluator/dependency-nodes/cell-value-node.mjs\";\nimport { EvaluationContext } from \"../../evaluator/evaluation-context.mjs\";\nimport {\n EvaluationError,\n SheetNotFoundError,\n} from \"../../evaluator/evaluation-error.mjs\";\nimport { RangeEvaluationNode } from \"../../evaluator/range-evaluation-node.mjs\";\nimport { normalizeSerializedCellValue } from \"../../parser/formatter.mjs\";\nimport { FormulaEvaluator } from \"../../evaluator/formula-evaluator.mjs\";\nimport {\n FormulaError,\n type CellAddress,\n type CellInRangeResult,\n type CellValue,\n type ErrorEvaluationResult,\n type EvaluateAllCellsResult,\n type EvaluationOrder,\n type FunctionEvaluationResult,\n type SerializedCellValue,\n type SingleEvaluationResult,\n type SpreadsheetRange,\n type ValueEvaluationResult,\n} from \"../types.mjs\";\nimport {\n captureEvaluationErrors,\n getAbsoluteRange,\n cellAddressToKey,\n checkRangeIntersection,\n getCellReference,\n getRangeIntersection,\n getRelativeRange,\n isCellInRange,\n parseCellReference,\n rangeAddressToKey,\n} from \"../utils.mjs\";\nimport type { DependencyManager } from \"./dependency-manager.mjs\";\nimport type { WorkbookManager } from \"./workbook-manager.mjs\";\nimport { SpillMetaNode } from \"../../evaluator/dependency-nodes/spill-meta-node.mjs\";\nimport { EmptyCellEvaluationNode } from \"../../evaluator/dependency-nodes/empty-cell-evaluation-node.mjs\";\nimport type { TableManager } from \"./table-manager.mjs\";\nimport type { DependencyNode } from \"./dependency-node.mjs\";\nimport { VirtualCellValueNode } from \"../../evaluator/dependency-nodes/virtual-cell-value-node.mjs\";\nimport { ResourceDependencyNode } from \"../../evaluator/dependency-nodes/resource-dependency-node.mjs\";\nimport type {\n NodeSnapshotId,\n SerializedCellInRangeResultSnapshot,\n SerializedErrorEvaluationResultSnapshot,\n SerializedEvaluateAllCellsResultSnapshot,\n SerializedFunctionEvaluationResultSnapshot,\n SerializedSingleEvaluationResultSnapshot,\n SerializedSpillMetaEvaluationResultSnapshot,\n SerializedSpilledValuesEvaluationResultSnapshot,\n} from \"../engine-snapshot.mjs\";\nimport type { MutationInvalidation } from \"../commands/types.mjs\";\n\nexport class EvaluationManager {\n private isEvaluating = false;\n\n constructor(\n private workbookManager: WorkbookManager,\n private tableManager: TableManager,\n private formulaEvaluator: FormulaEvaluator,\n private dependencyManager: DependencyManager\n ) {}\n\n clearEvaluationCache(): void {\n this.dependencyManager.clearEvaluationCache();\n }\n\n private dependsOnNode(\n candidate: DependencyNode,\n target: DependencyNode,\n visited: Set<DependencyNode> = new Set()\n ): boolean {\n if (candidate === target) {\n return true;\n }\n\n if (visited.has(candidate)) {\n return false;\n }\n visited.add(candidate);\n\n for (const dep of candidate.getDependencies()) {\n if (this.dependsOnNode(dep, target, visited)) {\n return true;\n }\n }\n\n return false;\n }\n\n invalidateFromMutation(footprint: MutationInvalidation): void {\n this.dependencyManager.invalidateFromMutation(footprint);\n }\n\n evaluationResultToSerializedValue(\n evaluation: SingleEvaluationResult,\n cellAddress: CellAddress,\n debug?: boolean\n ): SerializedCellValue {\n if (\n evaluation.type !== \"error\" &&\n evaluation.type !== \"awaiting-evaluation\"\n ) {\n const value = evaluation.result;\n\n return value.type === \"infinity\"\n ? value.sign === \"positive\"\n ? \"INFINITY\"\n : \"-INFINITY\"\n : value.value;\n }\n\n if (evaluation.type === \"awaiting-evaluation\") {\n return (\n evaluation.errAddress.key +\n \" is awaiting evaluation of \" +\n evaluation.waitingFor.key\n );\n }\n\n if (debug) {\n const errAddress = evaluation.errAddress.key;\n if (errAddress === cellAddressToKey(cellAddress)) {\n return evaluation.err + \" \" + evaluation.message;\n }\n return (\n evaluation.err +\n \" in \" +\n evaluation.errAddress.key +\n \" \" +\n evaluation.message\n );\n }\n\n return evaluation.err;\n }\n\n private buildSnapshotOrigin(\n node: CellValueNode | SpillMetaNode | AstEvaluationNode\n ): CellAddress {\n if (\"cellAddress\" in node) {\n return node.cellAddress;\n }\n\n const contextDependency = node.getContextDependency();\n return {\n workbookName: contextDependency.workbookName ?? \"__snapshot__\",\n sheetName: contextDependency.sheetName ?? \"__snapshot__\",\n colIndex: contextDependency.colIndex ?? 0,\n rowIndex: contextDependency.rowIndex ?? 0,\n };\n }\n\n private serializeErrorEvaluationResultSnapshot(\n evaluation: Exclude<ErrorEvaluationResult, { type: \"awaiting-evaluation\" }>,\n getNodeSnapshotId: (node: DependencyNode) => NodeSnapshotId\n ): SerializedErrorEvaluationResultSnapshot {\n return {\n type: \"error\",\n err: evaluation.err,\n message: evaluation.message,\n errAddressId: getNodeSnapshotId(evaluation.errAddress),\n sourceCell: evaluation.sourceCell,\n };\n }\n\n serializeSingleEvaluationResultSnapshot(\n evaluation: SingleEvaluationResult,\n getNodeSnapshotId: (node: DependencyNode) => NodeSnapshotId\n ): SerializedSingleEvaluationResultSnapshot | undefined {\n if (evaluation.type === \"awaiting-evaluation\") {\n return undefined;\n }\n\n if (evaluation.type === \"error\") {\n return this.serializeErrorEvaluationResultSnapshot(\n evaluation,\n getNodeSnapshotId\n );\n }\n\n return {\n type: \"value\",\n result: evaluation.result,\n sourceCell: evaluation.sourceCell,\n };\n }\n\n deserializeSingleEvaluationResultSnapshot(\n evaluation: SerializedSingleEvaluationResultSnapshot,\n resolveNodeSnapshotId: (nodeId: NodeSnapshotId) => DependencyNode\n ): SingleEvaluationResult {\n if (evaluation.type === \"error\") {\n return {\n type: \"error\",\n err: evaluation.err,\n message: evaluation.message,\n errAddress: resolveNodeSnapshotId(evaluation.errAddressId),\n sourceCell: evaluation.sourceCell,\n };\n }\n\n return {\n type: \"value\",\n result: evaluation.result,\n sourceCell: evaluation.sourceCell,\n };\n }\n\n serializeEvaluateAllCellsResultSnapshot(\n evaluation: EvaluateAllCellsResult,\n getNodeSnapshotId: (node: DependencyNode) => NodeSnapshotId\n ): SerializedEvaluateAllCellsResultSnapshot | undefined {\n if (evaluation.type === \"awaiting-evaluation\") {\n return undefined;\n }\n\n if (evaluation.type === \"error\") {\n return this.serializeErrorEvaluationResultSnapshot(\n evaluation,\n getNodeSnapshotId\n );\n }\n\n const values: SerializedCellInRangeResultSnapshot[] = [];\n for (const value of evaluation.values) {\n const serialized = this.serializeSingleEvaluationResultSnapshot(\n value.result,\n getNodeSnapshotId\n );\n if (!serialized) {\n return undefined;\n }\n values.push({\n relativePos: value.relativePos,\n result: serialized,\n });\n }\n\n return {\n type: \"values\",\n values,\n };\n }\n\n deserializeEvaluateAllCellsResultSnapshot(\n evaluation: SerializedEvaluateAllCellsResultSnapshot,\n resolveNodeSnapshotId: (nodeId: NodeSnapshotId) => DependencyNode\n ): EvaluateAllCellsResult {\n if (evaluation.type === \"error\") {\n return this.deserializeSingleEvaluationResultSnapshot(\n evaluation,\n resolveNodeSnapshotId\n ) as ErrorEvaluationResult;\n }\n\n return {\n type: \"values\",\n values: evaluation.values.map((value) => ({\n relativePos: value.relativePos,\n result: this.deserializeSingleEvaluationResultSnapshot(\n value.result,\n resolveNodeSnapshotId\n ),\n })),\n };\n }\n\n serializeFunctionEvaluationResultSnapshot(\n evaluation: FunctionEvaluationResult,\n options: {\n sourceNode: CellValueNode | SpillMetaNode | AstEvaluationNode;\n getNodeSnapshotId: (node: DependencyNode) => NodeSnapshotId;\n }\n ): SerializedFunctionEvaluationResultSnapshot | undefined {\n if (evaluation.type !== \"spilled-values\") {\n return this.serializeSingleEvaluationResultSnapshot(\n evaluation,\n options.getNodeSnapshotId\n );\n }\n\n const origin = this.buildSnapshotOrigin(options.sourceNode);\n const spillArea = evaluation.spillArea(origin);\n const relativeSpillArea = getRelativeRange(spillArea, {\n colIndex: origin.colIndex,\n rowIndex: origin.rowIndex,\n });\n\n if (evaluation.sourceRange) {\n return {\n type: \"spilled-values\",\n spill: {\n kind: \"source-range\",\n relativeSpillArea,\n source: evaluation.source,\n sourceCell: evaluation.sourceCell,\n sourceRange: evaluation.sourceRange,\n },\n };\n }\n\n if (\n relativeSpillArea.width.type !== \"number\" ||\n relativeSpillArea.height.type !== \"number\"\n ) {\n return undefined;\n }\n\n const context = new EvaluationContext(\n this.tableManager,\n options.sourceNode,\n origin\n );\n const values: SerializedCellInRangeResultSnapshot[] = [];\n\n for (let y = 0; y < relativeSpillArea.height.value; y++) {\n for (let x = 0; x < relativeSpillArea.width.value; x++) {\n const result = captureEvaluationErrors(options.sourceNode, () =>\n evaluation.evaluate({ x, y }, context)\n );\n const serialized = this.serializeSingleEvaluationResultSnapshot(\n result,\n options.getNodeSnapshotId\n );\n if (!serialized) {\n return undefined;\n }\n values.push({\n relativePos: { x, y },\n result: serialized,\n });\n }\n }\n\n return {\n type: \"spilled-values\",\n spill: {\n kind: \"materialized\",\n relativeSpillArea,\n source: evaluation.source,\n sourceCell: evaluation.sourceCell,\n sourceRange: evaluation.sourceRange,\n values,\n },\n };\n }\n\n deserializeFunctionEvaluationResultSnapshot(\n evaluation: SerializedFunctionEvaluationResultSnapshot,\n resolveNodeSnapshotId: (nodeId: NodeSnapshotId) => DependencyNode\n ): FunctionEvaluationResult {\n if (evaluation.type !== \"spilled-values\") {\n return this.deserializeSingleEvaluationResultSnapshot(\n evaluation,\n resolveNodeSnapshotId\n );\n }\n\n const spillSnapshot = evaluation.spill;\n if (spillSnapshot.kind === \"materialized\") {\n const values = new Map(\n spillSnapshot.values.map((value) => [\n `${value.relativePos.x},${value.relativePos.y}`,\n this.deserializeSingleEvaluationResultSnapshot(\n value.result,\n resolveNodeSnapshotId\n ),\n ])\n );\n\n return {\n type: \"spilled-values\",\n source: spillSnapshot.source,\n sourceCell: spillSnapshot.sourceCell,\n sourceRange: spillSnapshot.sourceRange,\n spillArea: (origin) =>\n getAbsoluteRange(spillSnapshot.relativeSpillArea, {\n colIndex: origin.colIndex,\n rowIndex: origin.rowIndex,\n }),\n evaluate: (spillOffset) =>\n values.get(`${spillOffset.x},${spillOffset.y}`) ?? {\n type: \"value\",\n result: this.convertScalarValueToCellValue(\"\"),\n },\n evaluateAllCells: () => ({\n type: \"values\",\n values: spillSnapshot.values.map((value) => ({\n relativePos: value.relativePos,\n result: this.deserializeSingleEvaluationResultSnapshot(\n value.result,\n resolveNodeSnapshotId\n ),\n })),\n }),\n };\n }\n\n return {\n type: \"spilled-values\",\n source: spillSnapshot.source,\n sourceCell: spillSnapshot.sourceCell,\n sourceRange: spillSnapshot.sourceRange,\n spillArea: (origin) =>\n getAbsoluteRange(spillSnapshot.relativeSpillArea, {\n colIndex: origin.colIndex,\n rowIndex: origin.rowIndex,\n }),\n evaluate: (spillOffset, context) => {\n const cellAddress: CellAddress = {\n workbookName: spillSnapshot.sourceRange.workbookName,\n sheetName: spillSnapshot.sourceRange.sheetName,\n colIndex: spillSnapshot.sourceRange.range.start.col + spillOffset.x,\n rowIndex: spillSnapshot.sourceRange.range.start.row + spillOffset.y,\n };\n\n const evalNode = this.dependencyManager.getCellValueOrEmptyCellNode(\n cellAddressToKey(cellAddress)\n );\n context.dependencyNode.addDependency(evalNode);\n return evalNode.evaluationResult;\n },\n evaluateAllCells: ({ intersection, context, origin }) => {\n let range = spillSnapshot.sourceRange.range;\n if (intersection) {\n const relativeRange = getRelativeRange(intersection, origin);\n const projectedIntersection = getAbsoluteRange(relativeRange, {\n colIndex: spillSnapshot.sourceRange.range.start.col,\n rowIndex: spillSnapshot.sourceRange.range.start.row,\n });\n const nextRange = getRangeIntersection(\n spillSnapshot.sourceRange.range,\n projectedIntersection\n );\n if (nextRange) {\n range = nextRange;\n }\n }\n\n const rangeAddress = {\n workbookName: spillSnapshot.sourceRange.workbookName,\n sheetName: spillSnapshot.sourceRange.sheetName,\n range,\n };\n\n const rangeNode = this.dependencyManager.getRangeNode(\n rangeAddressToKey(rangeAddress)\n );\n context.dependencyNode.addDependency(rangeNode);\n return rangeNode.result;\n },\n };\n }\n\n serializeSpillMetaEvaluationResultSnapshot(\n evaluation: SpillMetaNode[\"evaluationResult\"],\n options: {\n sourceNode: CellValueNode | SpillMetaNode | AstEvaluationNode;\n getNodeSnapshotId: (node: DependencyNode) => NodeSnapshotId;\n }\n ): SerializedSpillMetaEvaluationResultSnapshot | undefined {\n if (evaluation.type === \"does-not-spill\") {\n return { type: \"does-not-spill\" };\n }\n\n if (evaluation.type === \"error\") {\n return this.serializeErrorEvaluationResultSnapshot(\n evaluation,\n options.getNodeSnapshotId\n );\n }\n\n const serialized = this.serializeFunctionEvaluationResultSnapshot(\n evaluation,\n options\n );\n if (!serialized || serialized.type !== \"spilled-values\") {\n return undefined;\n }\n\n return serialized;\n }\n\n deserializeSpillMetaEvaluationResultSnapshot(\n evaluation: SerializedSpillMetaEvaluationResultSnapshot,\n resolveNodeSnapshotId: (nodeId: NodeSnapshotId) => DependencyNode\n ): SpillMetaNode[\"evaluationResult\"] {\n if (evaluation.type === \"does-not-spill\") {\n return evaluation;\n }\n\n if (evaluation.type === \"error\") {\n return this.deserializeSingleEvaluationResultSnapshot(\n evaluation,\n resolveNodeSnapshotId\n ) as SpillMetaNode[\"evaluationResult\"];\n }\n\n return this.deserializeFunctionEvaluationResultSnapshot(\n evaluation,\n resolveNodeSnapshotId\n ) as SpillMetaNode[\"evaluationResult\"];\n }\n\n evaluateEmptyCell(node: EmptyCellEvaluationNode): void {\n if (node.resolved) {\n const result = node.evaluationResult;\n if (result && result.type !== \"awaiting-evaluation\") {\n return;\n }\n }\n\n this.dependencyManager.unregisterNode(node);\n node.resetDirectDepsUpdated();\n\n const ctx = new EvaluationContext(\n this.tableManager,\n node,\n node.cellAddress\n );\n const inSpilled = this.dependencyManager.getSpillValue(node.cellAddress);\n\n if (inSpilled) {\n // if we are spilling then we can just add the spill origin as a dependency and evaluate the spilled value\n const spillTarget = this.dependencyManager.getSpilledAddress(\n node.cellAddress,\n inSpilled\n );\n const spillOriginKey = cellAddressToKey(inSpilled.origin).replace(\n /^[^:]+:/,\n \"spill-meta:\"\n );\n const spillMetaNode =\n this.dependencyManager.getSpillMetaNode(spillOriginKey);\n node.addDependency(spillMetaNode);\n const result = spillMetaNode.evaluationResult;\n if (result.type === \"spilled-values\") {\n // let's evaluate the spilled value to extract dependencies\n const evaluation = captureEvaluationErrors(spillMetaNode, () => {\n return result.evaluate(spillTarget.spillOffset, ctx);\n });\n node.setEvaluationResult(evaluation);\n }\n } else {\n // upgrade any frontier dependencies that spill into the range\n node.upgradeFrontierDependencies();\n\n const evaluationResult: SingleEvaluationResult = {\n type: \"value\",\n result: this.convertScalarValueToCellValue(\"\"),\n };\n // for now let's just store the empty value, the next time the cell is evaluated isSpilled will be true and the spilled value will be evaluated\n node.setEvaluationResult(evaluationResult);\n }\n\n this.dependencyManager.registerNode(node);\n }\n\n evaluateRangeNode(node: RangeEvaluationNode): void {\n if (node.resolved) {\n return;\n }\n\n this.dependencyManager.unregisterNode(node);\n node.resetDirectDepsUpdated();\n\n const result = captureEvaluationErrors(node, (): EvaluateAllCellsResult => {\n node.upgradeFrontierDependencies();\n\n const evalOrder = node.getRangeEvalOrder();\n const circularEntryCache = new Map<DependencyNode, boolean>();\n const shouldSkipCircularEntry = (candidate: DependencyNode) => {\n const cached = circularEntryCache.get(candidate);\n if (cached !== undefined) {\n return cached;\n }\n\n // If a cell inside the range depends back on the range itself, including\n // its current value would count a circular result back into the same\n // aggregate on a later rerun.\n const isCircular = this.dependsOnNode(candidate, node);\n circularEntryCache.set(candidate, isCircular);\n return isCircular;\n };\n\n const results: CellInRangeResult[] = [];\n\n for (const entry of evalOrder) {\n if (entry.type === \"value\") {\n if (shouldSkipCircularEntry(entry.node)) {\n continue;\n }\n\n const entryAddress = entry.address;\n const result = entry.node.evaluationResult;\n\n const relativePos = {\n x: entryAddress.colIndex - node.address.range.start.col,\n y: entryAddress.rowIndex - node.address.range.start.row,\n };\n\n results.push({ result: result, relativePos });\n } else if (\n entry.type === \"empty_cell\" ||\n entry.type === \"empty_range\"\n ) {\n for (const candidateNode of entry.candidates) {\n if (shouldSkipCircularEntry(candidateNode)) {\n continue;\n }\n\n if (candidateNode.evaluationResult.type === \"spilled-values\") {\n const spillArea = candidateNode.evaluationResult.spillArea(\n candidateNode.cellAddress\n );\n if (entry.type === \"empty_range\") {\n const intersects = checkRangeIntersection(\n spillArea,\n entry.address.range\n );\n if (intersects) {\n // When a spilled range intersects with our target range, we need to evaluate\n // only the cells that fall within the intersection area.\n //\n // Example: If cell A10 contains a spilled range that covers A10:B11,\n // and our target range is B10:INFINITY, then we only want to evaluate\n // the intersection B10:B11 from the spilled range.\n //\n // The evaluateAllCells method expects the intersection to be passed\n // so it can limit evaluation to only the relevant cells.\n const ctx = new EvaluationContext(\n this.tableManager,\n node,\n candidateNode.cellAddress\n );\n const spilledResults =\n candidateNode.evaluationResult.evaluateAllCells.call(\n this.formulaEvaluator,\n {\n context: ctx,\n evaluate: candidateNode.evaluationResult.evaluate,\n intersection: entry.address.range,\n origin: candidateNode.cellAddress,\n lookupOrder: \"col-major\",\n }\n );\n\n if (spilledResults.type === \"values\") {\n results.push(...spilledResults.values);\n } else {\n return spilledResults;\n }\n }\n } else {\n const intersects = isCellInRange(entry.address, spillArea);\n if (intersects) {\n // When a spilled range intersects with our target range, we need to evaluate\n // only the cells that fall within the intersection area.\n //\n // Example: If cell A10 contains a spilled range that covers A10:B11,\n // and our target range is B10:INFINITY, then we only want to evaluate\n // the intersection B10:B11 from the spilled range.\n //\n // The evaluateAllCells method expects the intersection to be passed\n // so it can limit evaluation to only the relevant cells.\n\n const relativePos = {\n x:\n entry.address.colIndex -\n candidateNode.cellAddress.colIndex,\n y:\n entry.address.rowIndex -\n candidateNode.cellAddress.rowIndex,\n };\n const ctx = new EvaluationContext(\n this.tableManager,\n node,\n candidateNode.cellAddress\n );\n const spilledResult = candidateNode.evaluationResult.evaluate(\n relativePos,\n ctx\n );\n\n results.push({\n relativePos: {\n x: entry.address.colIndex - node.address.range.start.col,\n y: entry.address.rowIndex - node.address.range.start.row,\n },\n result: spilledResult,\n });\n }\n }\n }\n }\n }\n }\n\n return {\n type: \"values\",\n values: results,\n };\n });\n\n node.setResult(result);\n this.dependencyManager.registerNode(node);\n }\n\n evaluateCellNode(\n node: CellValueNode | SpillMetaNode | VirtualCellValueNode\n ): void {\n // Enable caching for resolved nodes\n if (node.resolved) {\n return;\n }\n\n if (!(node instanceof VirtualCellValueNode)) {\n this.dependencyManager.unregisterNode(node);\n }\n node.resetDirectDepsUpdated();\n\n const ctx = new EvaluationContext(\n this.tableManager,\n node,\n node.cellAddress\n );\n\n if (node instanceof CellValueNode && node.spillMeta) {\n // we are evaluating a e.g. A1 in A1=SEQUENCE(10), where we want the value in the cell in A1, i.e. 1\n // As A1 is already pointing to a spill meta node, everything has been setup already,\n // we just need to evaluate the spill origin and assign the result to the currentDepNode\n const spillOrigin = node.spillMeta;\n if (spillOrigin.evaluationResult.type === \"spilled-values\") {\n const result = spillOrigin.evaluationResult.evaluate(\n { x: 0, y: 0 },\n ctx\n );\n node.setEvaluationResult(result);\n this.dependencyManager.registerNode(node);\n return;\n }\n }\n\n let content: SerializedCellValue;\n try {\n if (node instanceof VirtualCellValueNode) {\n content = node.cellValue;\n } else {\n content = this.workbookManager.getSerializedCellValue(node.cellAddress);\n }\n } catch (err) {\n const evaluationResult: ErrorEvaluationResult = {\n type: \"error\",\n err: FormulaError.ERROR,\n message: \"Syntax error\",\n errAddress: node,\n };\n node.setEvaluationResult(evaluationResult);\n if (!(node instanceof VirtualCellValueNode)) {\n this.dependencyManager.registerNode(node);\n }\n return;\n }\n\n if (typeof content !== \"string\" || !content.startsWith(\"=\")) {\n if (node instanceof SpillMetaNode) {\n node.setEvaluationResult({\n type: \"does-not-spill\",\n });\n this.dependencyManager.registerNode(node);\n return;\n }\n // Static value cells cannot have frontier dependencies\n const result: ValueEvaluationResult = {\n type: \"value\",\n result: this.convertScalarValueToCellValue(content),\n };\n node.setEvaluationResult(result);\n if (!(node instanceof VirtualCellValueNode)) {\n this.dependencyManager.registerNode(node);\n }\n return;\n }\n\n let evaluation: FunctionEvaluationResult = captureEvaluationErrors(\n node,\n () => this.formulaEvaluator.evaluateFormula(content.slice(1), ctx)\n );\n\n // the evaluated cell IS A spilling formula, e.g. if dependencyKey points to A1, then the formula is e.g. A1=SEQUENCE(10), or A1=A3:B5\n if (evaluation.type === \"spilled-values\") {\n const spillArea = evaluation.spillArea(node.cellAddress);\n\n if (!this.canSpill(node.cellAddress, spillArea)) {\n // Override evaluation with SPILL error, but continue execution to set up nodes\n evaluation = {\n type: \"error\",\n err: FormulaError.SPILL,\n message: \"Cannot spill - area is blocked\",\n errAddress: node,\n };\n } else {\n // Spill succeeds - register it\n this.dependencyManager.setSpilledValue(node.key, {\n spillOnto: spillArea,\n origin: node.cellAddress,\n });\n }\n\n // Set up spill meta node and evaluation results (even if spill failed)\n if (node instanceof SpillMetaNode) {\n // we have already setup an origin/spill meta node relationship,\n // so we are just reevaluating the spill meta node here\n node.setEvaluationResult(evaluation);\n this.dependencyManager.registerNode(node);\n } else {\n const spillMetaNode = this.dependencyManager.getSpillMetaNode(\n node.key.replace(/^[^:]+:/, \"spill-meta:\")\n );\n\n node.addDependency(spillMetaNode);\n node.setSpillMetaNode(spillMetaNode);\n spillMetaNode.setEvaluationResult(evaluation);\n this.dependencyManager.registerNode(spillMetaNode);\n\n if (evaluation.type === \"spilled-values\") {\n const originResult = evaluation.evaluate({ x: 0, y: 0 }, ctx);\n node.setEvaluationResult(originResult);\n } else {\n // Spill failed - set error on origin cell\n node.setEvaluationResult(evaluation);\n }\n }\n if (!(node instanceof VirtualCellValueNode)) {\n this.dependencyManager.registerNode(node);\n }\n return;\n }\n\n if (evaluation.type === \"value\") {\n if (node instanceof SpillMetaNode) {\n node.setEvaluationResult({\n type: \"does-not-spill\",\n });\n this.dependencyManager.registerNode(node);\n return;\n } else {\n node.setEvaluationResult(evaluation);\n if (!(node instanceof VirtualCellValueNode)) {\n this.dependencyManager.registerNode(node);\n }\n return;\n }\n }\n\n node.setEvaluationResult(evaluation);\n if (!(node instanceof VirtualCellValueNode)) {\n this.dependencyManager.registerNode(node);\n }\n }\n\n evaluateDependencyNode(dependency: DependencyNode): void {\n if (dependency instanceof EmptyCellEvaluationNode) {\n this.evaluateEmptyCell(dependency);\n return;\n }\n if (dependency instanceof RangeEvaluationNode) {\n this.evaluateRangeNode(dependency);\n return;\n }\n if (\n dependency instanceof CellValueNode ||\n dependency instanceof VirtualCellValueNode\n ) {\n this.evaluateCellNode(dependency);\n return;\n }\n if (dependency instanceof AstEvaluationNode) {\n return;\n }\n if (dependency instanceof ResourceDependencyNode) {\n return;\n }\n if (dependency instanceof SpillMetaNode) {\n this.evaluateCellNode(dependency);\n return;\n }\n throw new Error(\"Invalid dependency: \" + (dependency as any).key);\n }\n\n /**\n * User exposed method to evaluate a formula\n */\n evaluateFormula(\n /**\n * formula for example\n */\n cellValue: SerializedCellValue,\n cellAddress: CellAddress\n ): SerializedCellValue {\n if (this.isEvaluating) {\n throw new Error(\"Evaluation in progress\");\n }\n\n const node = this.dependencyManager.getVirtualCellValueNode(\n cellAddress,\n cellValue\n );\n\n if (node.evaluationResult.type === \"awaiting-evaluation\") {\n this.evaluateCell(node);\n }\n\n const result = node.evaluationResult;\n\n return this.evaluationResultToSerializedValue(result, cellAddress);\n }\n\n /**\n * Evaluates a cell by building the evaluation order and evaluating the dependencies in order\n */\n evaluateCell(\n node: CellValueNode | EmptyCellEvaluationNode | VirtualCellValueNode\n ): void {\n if (this.isEvaluating) {\n throw new Error(\"Evaluation in progress\");\n }\n this.isEvaluating = true;\n\n let precalculatedPlan: EvaluationOrder | undefined;\n\n let requiresReRun = true;\n while (requiresReRun) {\n requiresReRun = false;\n\n // Use DependencyManager to build evaluation order\n const evaluationPlan =\n precalculatedPlan ?? this.dependencyManager.buildEvaluationOrder(node);\n\n if (evaluationPlan.hasCycle) {\n const evaluationResult: ErrorEvaluationResult = {\n type: \"error\",\n err: FormulaError.CYCLE,\n message: Array.from(evaluationPlan.cycleNodes ?? [])\n .map((node) => node.key)\n .join(\" -> \"),\n errAddress: node,\n };\n // cycle detected\n if (evaluationPlan.cycleNodes) {\n for (const node of evaluationPlan.cycleNodes) {\n if (\n !(node instanceof RangeEvaluationNode) &&\n !(node instanceof ResourceDependencyNode)\n ) {\n node.setEvaluationResult(evaluationResult);\n }\n }\n }\n this.isEvaluating = false;\n }\n\n // Evaluate all dependencies in order\n const timeStart = performance.now();\n const durations: { duration: number; key: string }[] = [];\n let numResolved = 0;\n if (flags.isProfiling && evaluationPlan.evaluationOrder.size > -1) {\n // console.profile();\n }\n evaluationPlan.evaluationOrder.forEach((dependency) => {\n const start = performance.now();\n if (dependency.resolved) {\n numResolved++;\n }\n this.evaluateDependencyNode(dependency);\n\n const end = performance.now();\n if (flags.isProfiling && evaluationPlan.evaluationOrder.size > -1) {\n durations.push({ duration: end - start, key: dependency.key });\n }\n });\n if (flags.isProfiling && evaluationPlan.evaluationOrder.size > -1) {\n // console.profileEnd();\n }\n if (flags.isProfiling && evaluationPlan.evaluationOrder.size > -1) {\n const percentResolved = Math.round(\n (100 * numResolved) / evaluationPlan.evaluationOrder.size\n );\n const avgDuration =\n durations.reduce((a, b) => a + b.duration, 0) / durations.length || 0;\n console.log(\n `%c[Evaluation] %c${evaluationPlan.evaluationOrder.size} deps | %c${(\n performance.now() - timeStart\n ).toFixed(\n 1\n )}ms | %c${percentResolved}% resolved | %c${avgDuration.toFixed(\n 2\n )}ms avg`,\n \"color:#83aaff;font-weight:bold;\",\n \"color:#fff;font-weight:bold;\",\n \"color:#7fff9e\",\n \"color:#85baff\",\n \"color:#ffdfa3\"\n );\n }\n\n this.dependencyManager.markResolvedNodes(node);\n\n const nextEvaluationPlan =\n this.dependencyManager.buildEvaluationOrder(node);\n\n this.dependencyManager.updateResolvedSCCs(nextEvaluationPlan);\n\n precalculatedPlan = nextEvaluationPlan;\n\n // Check if new dependencies were discovered during evaluation\n if (nextEvaluationPlan.hash !== evaluationPlan.hash) {\n requiresReRun = true;\n } else {\n this.isEvaluating = false;\n return;\n }\n }\n this.isEvaluating = false;\n }\n\n convertScalarValueToCellValue(val: SerializedCellValue): CellValue {\n if (val === \"INFINITY\") {\n return { type: \"infinity\", sign: \"positive\" };\n }\n if (val === \"-INFINITY\") {\n return { type: \"infinity\", sign: \"negative\" };\n }\n if (typeof val === \"number\") {\n return { type: \"number\", value: val };\n }\n if (typeof val === \"boolean\") {\n return { type: \"boolean\", value: val };\n }\n if (typeof val === \"undefined\") {\n return { type: \"string\", value: \"\" };\n }\n return { type: \"string\", value: val };\n }\n\n // todo optimize using workbook manager\n canSpill(spillCandidate: CellAddress, spillArea: SpreadsheetRange): boolean {\n // Check if the spill origin cell is inside a table - spilling formulas cannot exist in tables\n if (this.tableManager.isCellInTable(spillCandidate)) {\n return false;\n }\n\n // Check if the spill area would intersect with any table - formulas cannot spill into tables\n if (\n this.tableManager.doesRangeIntersectTable(\n spillCandidate.workbookName,\n spillCandidate.sheetName,\n spillArea\n )\n ) {\n return false;\n }\n\n const sheet = this.workbookManager.getSheet(spillCandidate);\n if (!sheet) {\n throw new SheetNotFoundError(spillCandidate.sheetName);\n }\n const cellId = getCellReference(spillCandidate);\n const content = sheet.content.get(cellId);\n if (!content) {\n throw new EvaluationError(FormulaError.REF, `Cell not found: ${cellId}`);\n }\n for (const spilledValue of this.dependencyManager.spilledValues) {\n if (\n spilledValue.origin.workbookName !== spillCandidate.workbookName ||\n spilledValue.origin.sheetName !== spillCandidate.sheetName\n ) {\n continue;\n }\n if (\n spilledValue.origin.colIndex === spillCandidate.colIndex &&\n spilledValue.origin.rowIndex === spillCandidate.rowIndex\n ) {\n // we are already have a spill, this one will be replaced\n continue;\n }\n\n if (checkRangeIntersection(spillArea, spilledValue.spillOnto)) {\n return false;\n }\n }\n // let's just check the raw data if there is something in the range\n for (const key of sheet.content.keys()) {\n const cellAddress = parseCellReference(key);\n const endCol = spillArea.end.col;\n const endRow = spillArea.end.row;\n\n if (\n cellAddress.colIndex === spillCandidate.colIndex &&\n cellAddress.rowIndex === spillCandidate.rowIndex\n ) {\n continue;\n }\n\n if (endCol.type === \"number\" && endRow.type === \"number\") {\n if (\n cellAddress.colIndex >= spillArea.start.col &&\n cellAddress.colIndex <= endCol.value &&\n cellAddress.rowIndex >= spillArea.start.row &&\n cellAddress.rowIndex <= endRow.value\n ) {\n if (\n normalizeSerializedCellValue(sheet.content.get(key)) !== undefined\n ) {\n // there is something in the range, so we can't spill\n return false;\n }\n }\n }\n }\n\n return true;\n }\n\n getCellEvaluationResult(\n cellAddress: CellAddress\n ): SingleEvaluationResult | undefined {\n if (this.isEvaluating) {\n throw new Error(\"Evaluation in progress\");\n }\n\n const nodeKey = cellAddressToKey(cellAddress);\n const node = this.dependencyManager.getCellValueOrEmptyCellNode(nodeKey);\n\n const sheet = this.workbookManager.getSheet(cellAddress);\n if (!sheet) {\n throw new SheetNotFoundError(cellAddress.sheetName);\n }\n\n if (node.evaluationResult.type === \"awaiting-evaluation\") {\n // if (cellAddressToKey(cellAddress).includes(\"G10\")) {\n // console.group(\"Evaluation of G10\");\n // flags.isProfiling = true;\n // console.time(\"Evaluation of G10\");\n // console.profile(\"Evaluation of G10\");\n // }\n this.evaluateCell(node);\n // if (flags.isProfiling) {\n // flags.isProfiling = false;\n // console.timeEnd(\"Evaluation of G10\");\n // console.profileEnd(\"Evaluation of G10\");\n // console.groupEnd();\n // }\n }\n\n const result = node.evaluationResult;\n\n return result;\n }\n}\n"
|
|
5
|
+
"import { flags } from \"../../debug/flags.mjs\";\nimport { AstEvaluationNode } from \"../../evaluator/dependency-nodes/ast-evaluation-node.mjs\";\nimport { CellValueNode } from \"../../evaluator/dependency-nodes/cell-value-node.mjs\";\nimport { EvaluationContext } from \"../../evaluator/evaluation-context.mjs\";\nimport {\n EvaluationError,\n SheetNotFoundError,\n} from \"../../evaluator/evaluation-error.mjs\";\nimport { RangeEvaluationNode } from \"../../evaluator/range-evaluation-node.mjs\";\nimport { normalizeSerializedCellValue } from \"../../parser/formatter.mjs\";\nimport { FormulaEvaluator } from \"../../evaluator/formula-evaluator.mjs\";\nimport {\n FormulaError,\n type CellAddress,\n type CellInRangeResult,\n type CellValue,\n type ErrorEvaluationResult,\n type EvaluateAllCellsResult,\n type EvaluationOrder,\n type FunctionEvaluationResult,\n type SerializedCellValue,\n type SingleEvaluationResult,\n type SpreadsheetRange,\n type ValueEvaluationResult,\n} from \"../types.mjs\";\nimport {\n captureEvaluationErrors,\n getAbsoluteRange,\n cellAddressToKey,\n checkRangeIntersection,\n getCellReference,\n getRangeIntersection,\n getRelativeRange,\n isCellInRange,\n parseCellReference,\n rangeAddressToKey,\n} from \"../utils.mjs\";\nimport type { DependencyManager } from \"./dependency-manager.mjs\";\nimport type { WorkbookManager } from \"./workbook-manager.mjs\";\nimport { SpillMetaNode } from \"../../evaluator/dependency-nodes/spill-meta-node.mjs\";\nimport { EmptyCellEvaluationNode } from \"../../evaluator/dependency-nodes/empty-cell-evaluation-node.mjs\";\nimport type { TableManager } from \"./table-manager.mjs\";\nimport type { DependencyNode } from \"./dependency-node.mjs\";\nimport { VirtualCellValueNode } from \"../../evaluator/dependency-nodes/virtual-cell-value-node.mjs\";\nimport { ResourceDependencyNode } from \"../../evaluator/dependency-nodes/resource-dependency-node.mjs\";\nimport type {\n NodeSnapshotId,\n SerializedCellInRangeResultSnapshot,\n SerializedErrorEvaluationResultSnapshot,\n SerializedEvaluateAllCellsResultSnapshot,\n SerializedFunctionEvaluationResultSnapshot,\n SerializedSingleEvaluationResultSnapshot,\n SerializedSpillMetaEvaluationResultSnapshot,\n SerializedSpilledValuesEvaluationResultSnapshot,\n} from \"../engine-snapshot.mjs\";\nimport type { MutationInvalidation } from \"../commands/types.mjs\";\n\nexport class EvaluationManager {\n private isEvaluating = false;\n\n constructor(\n private workbookManager: WorkbookManager,\n private tableManager: TableManager,\n private formulaEvaluator: FormulaEvaluator,\n private dependencyManager: DependencyManager\n ) {}\n\n clearEvaluationCache(): void {\n this.dependencyManager.clearEvaluationCache();\n }\n\n private dependsOnNode(\n candidate: DependencyNode,\n target: DependencyNode,\n visited: Set<DependencyNode> = new Set()\n ): boolean {\n if (candidate === target) {\n return true;\n }\n\n if (visited.has(candidate)) {\n return false;\n }\n visited.add(candidate);\n\n for (const dep of candidate.getDependencies()) {\n if (this.dependsOnNode(dep, target, visited)) {\n return true;\n }\n }\n\n return false;\n }\n\n invalidateFromMutation(footprint: MutationInvalidation): void {\n this.dependencyManager.invalidateFromMutation(footprint);\n }\n\n evaluationResultToSerializedValue(\n evaluation: SingleEvaluationResult,\n cellAddress: CellAddress,\n debug?: boolean\n ): SerializedCellValue {\n if (\n evaluation.type !== \"error\" &&\n evaluation.type !== \"awaiting-evaluation\"\n ) {\n const value = evaluation.result;\n\n return value.type === \"infinity\"\n ? value.sign === \"positive\"\n ? \"INFINITY\"\n : \"-INFINITY\"\n : value.value;\n }\n\n if (evaluation.type === \"awaiting-evaluation\") {\n return (\n evaluation.errAddress.key +\n \" is awaiting evaluation of \" +\n evaluation.waitingFor.key\n );\n }\n\n if (debug) {\n const errAddress = evaluation.errAddress.key;\n if (errAddress === cellAddressToKey(cellAddress)) {\n return evaluation.err + \" \" + evaluation.message;\n }\n return (\n evaluation.err +\n \" in \" +\n evaluation.errAddress.key +\n \" \" +\n evaluation.message\n );\n }\n\n return evaluation.err;\n }\n\n private buildSnapshotOrigin(\n node: CellValueNode | SpillMetaNode | AstEvaluationNode\n ): CellAddress {\n if (\"cellAddress\" in node) {\n return node.cellAddress;\n }\n\n const contextDependency = node.getContextDependency();\n return {\n workbookName: contextDependency.workbookName ?? \"__snapshot__\",\n sheetName: contextDependency.sheetName ?? \"__snapshot__\",\n colIndex: contextDependency.colIndex ?? 0,\n rowIndex: contextDependency.rowIndex ?? 0,\n };\n }\n\n private serializeErrorEvaluationResultSnapshot(\n evaluation: Exclude<ErrorEvaluationResult, { type: \"awaiting-evaluation\" }>,\n getNodeSnapshotId: (node: DependencyNode) => NodeSnapshotId\n ): SerializedErrorEvaluationResultSnapshot {\n return {\n type: \"error\",\n err: evaluation.err,\n message: evaluation.message,\n errAddressId: getNodeSnapshotId(evaluation.errAddress),\n sourceCell: evaluation.sourceCell,\n };\n }\n\n serializeSingleEvaluationResultSnapshot(\n evaluation: SingleEvaluationResult,\n getNodeSnapshotId: (node: DependencyNode) => NodeSnapshotId\n ): SerializedSingleEvaluationResultSnapshot | undefined {\n if (evaluation.type === \"awaiting-evaluation\") {\n return undefined;\n }\n\n if (evaluation.type === \"error\") {\n return this.serializeErrorEvaluationResultSnapshot(\n evaluation,\n getNodeSnapshotId\n );\n }\n\n return {\n type: \"value\",\n result: evaluation.result,\n sourceCell: evaluation.sourceCell,\n };\n }\n\n deserializeSingleEvaluationResultSnapshot(\n evaluation: SerializedSingleEvaluationResultSnapshot,\n resolveNodeSnapshotId: (nodeId: NodeSnapshotId) => DependencyNode\n ): SingleEvaluationResult {\n if (evaluation.type === \"error\") {\n return {\n type: \"error\",\n err: evaluation.err,\n message: evaluation.message,\n errAddress: resolveNodeSnapshotId(evaluation.errAddressId),\n sourceCell: evaluation.sourceCell,\n };\n }\n\n return {\n type: \"value\",\n result: evaluation.result,\n sourceCell: evaluation.sourceCell,\n };\n }\n\n serializeEvaluateAllCellsResultSnapshot(\n evaluation: EvaluateAllCellsResult,\n getNodeSnapshotId: (node: DependencyNode) => NodeSnapshotId\n ): SerializedEvaluateAllCellsResultSnapshot | undefined {\n if (evaluation.type === \"awaiting-evaluation\") {\n return undefined;\n }\n\n if (evaluation.type === \"error\") {\n return this.serializeErrorEvaluationResultSnapshot(\n evaluation,\n getNodeSnapshotId\n );\n }\n\n const values: SerializedCellInRangeResultSnapshot[] = [];\n for (const value of evaluation.values) {\n const serialized = this.serializeSingleEvaluationResultSnapshot(\n value.result,\n getNodeSnapshotId\n );\n if (!serialized) {\n return undefined;\n }\n values.push({\n relativePos: value.relativePos,\n result: serialized,\n });\n }\n\n return {\n type: \"values\",\n values,\n };\n }\n\n deserializeEvaluateAllCellsResultSnapshot(\n evaluation: SerializedEvaluateAllCellsResultSnapshot,\n resolveNodeSnapshotId: (nodeId: NodeSnapshotId) => DependencyNode\n ): EvaluateAllCellsResult {\n if (evaluation.type === \"error\") {\n return this.deserializeSingleEvaluationResultSnapshot(\n evaluation,\n resolveNodeSnapshotId\n ) as ErrorEvaluationResult;\n }\n\n return {\n type: \"values\",\n values: evaluation.values.map((value) => ({\n relativePos: value.relativePos,\n result: this.deserializeSingleEvaluationResultSnapshot(\n value.result,\n resolveNodeSnapshotId\n ),\n })),\n };\n }\n\n serializeFunctionEvaluationResultSnapshot(\n evaluation: FunctionEvaluationResult,\n options: {\n sourceNode: CellValueNode | SpillMetaNode | AstEvaluationNode;\n getNodeSnapshotId: (node: DependencyNode) => NodeSnapshotId;\n }\n ): SerializedFunctionEvaluationResultSnapshot | undefined {\n if (evaluation.type !== \"spilled-values\") {\n return this.serializeSingleEvaluationResultSnapshot(\n evaluation,\n options.getNodeSnapshotId\n );\n }\n\n const origin = this.buildSnapshotOrigin(options.sourceNode);\n const spillArea = evaluation.spillArea(origin);\n const relativeSpillArea = getRelativeRange(spillArea, {\n colIndex: origin.colIndex,\n rowIndex: origin.rowIndex,\n });\n\n if (evaluation.sourceRange) {\n return {\n type: \"spilled-values\",\n spill: {\n kind: \"source-range\",\n relativeSpillArea,\n source: evaluation.source,\n sourceCell: evaluation.sourceCell,\n sourceRange: evaluation.sourceRange,\n },\n };\n }\n\n if (\n relativeSpillArea.width.type !== \"number\" ||\n relativeSpillArea.height.type !== \"number\"\n ) {\n return undefined;\n }\n\n const context = new EvaluationContext(\n this.tableManager,\n options.sourceNode,\n origin\n );\n const values: SerializedCellInRangeResultSnapshot[] = [];\n\n for (let y = 0; y < relativeSpillArea.height.value; y++) {\n for (let x = 0; x < relativeSpillArea.width.value; x++) {\n const result = captureEvaluationErrors(options.sourceNode, () =>\n evaluation.evaluate({ x, y }, context)\n );\n const serialized = this.serializeSingleEvaluationResultSnapshot(\n result,\n options.getNodeSnapshotId\n );\n if (!serialized) {\n return undefined;\n }\n values.push({\n relativePos: { x, y },\n result: serialized,\n });\n }\n }\n\n return {\n type: \"spilled-values\",\n spill: {\n kind: \"materialized\",\n relativeSpillArea,\n source: evaluation.source,\n sourceCell: evaluation.sourceCell,\n sourceRange: evaluation.sourceRange,\n values,\n },\n };\n }\n\n deserializeFunctionEvaluationResultSnapshot(\n evaluation: SerializedFunctionEvaluationResultSnapshot,\n resolveNodeSnapshotId: (nodeId: NodeSnapshotId) => DependencyNode\n ): FunctionEvaluationResult {\n if (evaluation.type !== \"spilled-values\") {\n return this.deserializeSingleEvaluationResultSnapshot(\n evaluation,\n resolveNodeSnapshotId\n );\n }\n\n const spillSnapshot = evaluation.spill;\n if (spillSnapshot.kind === \"materialized\") {\n const values = new Map(\n spillSnapshot.values.map((value) => [\n `${value.relativePos.x},${value.relativePos.y}`,\n this.deserializeSingleEvaluationResultSnapshot(\n value.result,\n resolveNodeSnapshotId\n ),\n ])\n );\n\n return {\n type: \"spilled-values\",\n source: spillSnapshot.source,\n sourceCell: spillSnapshot.sourceCell,\n sourceRange: spillSnapshot.sourceRange,\n spillArea: (origin) =>\n getAbsoluteRange(spillSnapshot.relativeSpillArea, {\n colIndex: origin.colIndex,\n rowIndex: origin.rowIndex,\n }),\n evaluate: (spillOffset) =>\n values.get(`${spillOffset.x},${spillOffset.y}`) ?? {\n type: \"value\",\n result: this.convertScalarValueToCellValue(\"\"),\n },\n evaluateAllCells: () => ({\n type: \"values\",\n values: spillSnapshot.values.map((value) => ({\n relativePos: value.relativePos,\n result: this.deserializeSingleEvaluationResultSnapshot(\n value.result,\n resolveNodeSnapshotId\n ),\n })),\n }),\n };\n }\n\n return {\n type: \"spilled-values\",\n source: spillSnapshot.source,\n sourceCell: spillSnapshot.sourceCell,\n sourceRange: spillSnapshot.sourceRange,\n spillArea: (origin) =>\n getAbsoluteRange(spillSnapshot.relativeSpillArea, {\n colIndex: origin.colIndex,\n rowIndex: origin.rowIndex,\n }),\n evaluate: (spillOffset, context) => {\n const cellAddress: CellAddress = {\n workbookName: spillSnapshot.sourceRange.workbookName,\n sheetName: spillSnapshot.sourceRange.sheetName,\n colIndex: spillSnapshot.sourceRange.range.start.col + spillOffset.x,\n rowIndex: spillSnapshot.sourceRange.range.start.row + spillOffset.y,\n };\n\n const evalNode = this.dependencyManager.getCellValueOrEmptyCellNode(\n cellAddressToKey(cellAddress)\n );\n context.dependencyNode.addDependency(evalNode);\n return evalNode.evaluationResult;\n },\n evaluateAllCells: ({ intersection, context, origin }) => {\n let range = spillSnapshot.sourceRange.range;\n if (intersection) {\n const relativeRange = getRelativeRange(intersection, origin);\n const projectedIntersection = getAbsoluteRange(relativeRange, {\n colIndex: spillSnapshot.sourceRange.range.start.col,\n rowIndex: spillSnapshot.sourceRange.range.start.row,\n });\n const nextRange = getRangeIntersection(\n spillSnapshot.sourceRange.range,\n projectedIntersection\n );\n if (nextRange) {\n range = nextRange;\n }\n }\n\n const rangeAddress = {\n workbookName: spillSnapshot.sourceRange.workbookName,\n sheetName: spillSnapshot.sourceRange.sheetName,\n range,\n };\n\n const rangeNode = this.dependencyManager.getRangeNode(\n rangeAddressToKey(rangeAddress)\n );\n context.dependencyNode.addDependency(rangeNode);\n return rangeNode.result;\n },\n };\n }\n\n serializeSpillMetaEvaluationResultSnapshot(\n evaluation: SpillMetaNode[\"evaluationResult\"],\n options: {\n sourceNode: CellValueNode | SpillMetaNode | AstEvaluationNode;\n getNodeSnapshotId: (node: DependencyNode) => NodeSnapshotId;\n }\n ): SerializedSpillMetaEvaluationResultSnapshot | undefined {\n if (evaluation.type === \"does-not-spill\") {\n return { type: \"does-not-spill\" };\n }\n\n if (evaluation.type === \"error\") {\n return this.serializeErrorEvaluationResultSnapshot(\n evaluation,\n options.getNodeSnapshotId\n );\n }\n\n const serialized = this.serializeFunctionEvaluationResultSnapshot(\n evaluation,\n options\n );\n if (!serialized || serialized.type !== \"spilled-values\") {\n return undefined;\n }\n\n return serialized;\n }\n\n deserializeSpillMetaEvaluationResultSnapshot(\n evaluation: SerializedSpillMetaEvaluationResultSnapshot,\n resolveNodeSnapshotId: (nodeId: NodeSnapshotId) => DependencyNode\n ): SpillMetaNode[\"evaluationResult\"] {\n if (evaluation.type === \"does-not-spill\") {\n return evaluation;\n }\n\n if (evaluation.type === \"error\") {\n return this.deserializeSingleEvaluationResultSnapshot(\n evaluation,\n resolveNodeSnapshotId\n ) as SpillMetaNode[\"evaluationResult\"];\n }\n\n return this.deserializeFunctionEvaluationResultSnapshot(\n evaluation,\n resolveNodeSnapshotId\n ) as SpillMetaNode[\"evaluationResult\"];\n }\n\n evaluateEmptyCell(node: EmptyCellEvaluationNode): void {\n if (node.resolved) {\n const result = node.evaluationResult;\n if (result && result.type !== \"awaiting-evaluation\") {\n return;\n }\n }\n\n this.dependencyManager.unregisterNode(node);\n node.resetDirectDepsUpdated();\n\n const ctx = new EvaluationContext(\n this.tableManager,\n node,\n node.cellAddress\n );\n const inSpilled = this.dependencyManager.getSpillValue(node.cellAddress);\n\n if (inSpilled) {\n // if we are spilling then we can just add the spill origin as a dependency and evaluate the spilled value\n const spillTarget = this.dependencyManager.getSpilledAddress(\n node.cellAddress,\n inSpilled\n );\n const spillOriginKey = cellAddressToKey(inSpilled.origin).replace(\n /^[^:]+:/,\n \"spill-meta:\"\n );\n const spillMetaNode =\n this.dependencyManager.getSpillMetaNode(spillOriginKey);\n node.addDependency(spillMetaNode);\n const result = spillMetaNode.evaluationResult;\n if (result.type === \"spilled-values\") {\n // let's evaluate the spilled value to extract dependencies\n const evaluation = captureEvaluationErrors(spillMetaNode, () => {\n return result.evaluate(spillTarget.spillOffset, ctx);\n });\n node.setEvaluationResult(evaluation);\n }\n } else {\n // upgrade any frontier dependencies that spill into the range\n node.upgradeFrontierDependencies();\n\n const evaluationResult: SingleEvaluationResult = {\n type: \"value\",\n result: this.convertScalarValueToCellValue(\"\"),\n };\n // for now let's just store the empty value, the next time the cell is evaluated isSpilled will be true and the spilled value will be evaluated\n node.setEvaluationResult(evaluationResult);\n }\n\n this.dependencyManager.registerNode(node);\n }\n\n evaluateRangeNode(node: RangeEvaluationNode): void {\n if (node.resolved) {\n return;\n }\n\n this.dependencyManager.unregisterNode(node);\n node.resetDirectDepsUpdated();\n\n const result = captureEvaluationErrors(node, (): EvaluateAllCellsResult => {\n node.upgradeFrontierDependencies();\n\n const evalOrder = node.getRangeEvalOrder();\n const circularEntryCache = new Map<DependencyNode, boolean>();\n const shouldSkipCircularEntry = (candidate: DependencyNode) => {\n const cached = circularEntryCache.get(candidate);\n if (cached !== undefined) {\n return cached;\n }\n\n // If a cell inside the range depends back on the range itself, including\n // its current value would count a circular result back into the same\n // aggregate on a later rerun.\n const isCircular = this.dependsOnNode(candidate, node);\n circularEntryCache.set(candidate, isCircular);\n return isCircular;\n };\n\n const results: CellInRangeResult[] = [];\n\n for (const entry of evalOrder) {\n if (entry.type === \"value\") {\n if (shouldSkipCircularEntry(entry.node)) {\n continue;\n }\n\n const entryAddress = entry.address;\n const result = entry.node.evaluationResult;\n\n const relativePos = {\n x: entryAddress.colIndex - node.address.range.start.col,\n y: entryAddress.rowIndex - node.address.range.start.row,\n };\n\n results.push({ result: result, relativePos });\n } else if (\n entry.type === \"empty_cell\" ||\n entry.type === \"empty_range\"\n ) {\n for (const candidateNode of entry.candidates) {\n if (shouldSkipCircularEntry(candidateNode)) {\n continue;\n }\n\n if (candidateNode.evaluationResult.type === \"spilled-values\") {\n const spillArea = candidateNode.evaluationResult.spillArea(\n candidateNode.cellAddress\n );\n if (entry.type === \"empty_range\") {\n const intersects = checkRangeIntersection(\n spillArea,\n entry.address.range\n );\n if (intersects) {\n // When a spilled range intersects with our target range, we need to evaluate\n // only the cells that fall within the intersection area.\n //\n // Example: If cell A10 contains a spilled range that covers A10:B11,\n // and our target range is B10:INFINITY, then we only want to evaluate\n // the intersection B10:B11 from the spilled range.\n //\n // The evaluateAllCells method expects the intersection to be passed\n // so it can limit evaluation to only the relevant cells.\n const ctx = new EvaluationContext(\n this.tableManager,\n node,\n candidateNode.cellAddress\n );\n const spilledResults =\n candidateNode.evaluationResult.evaluateAllCells.call(\n this.formulaEvaluator,\n {\n context: ctx,\n evaluate: candidateNode.evaluationResult.evaluate,\n intersection: entry.address.range,\n origin: candidateNode.cellAddress,\n lookupOrder: \"col-major\",\n }\n );\n\n if (spilledResults.type === \"values\") {\n results.push(...spilledResults.values);\n } else {\n return spilledResults;\n }\n }\n } else {\n const intersects = isCellInRange(entry.address, spillArea);\n if (intersects) {\n // When a spilled range intersects with our target range, we need to evaluate\n // only the cells that fall within the intersection area.\n //\n // Example: If cell A10 contains a spilled range that covers A10:B11,\n // and our target range is B10:INFINITY, then we only want to evaluate\n // the intersection B10:B11 from the spilled range.\n //\n // The evaluateAllCells method expects the intersection to be passed\n // so it can limit evaluation to only the relevant cells.\n\n const relativePos = {\n x:\n entry.address.colIndex -\n candidateNode.cellAddress.colIndex,\n y:\n entry.address.rowIndex -\n candidateNode.cellAddress.rowIndex,\n };\n const ctx = new EvaluationContext(\n this.tableManager,\n node,\n candidateNode.cellAddress\n );\n const spilledResult = candidateNode.evaluationResult.evaluate(\n relativePos,\n ctx\n );\n\n results.push({\n relativePos: {\n x: entry.address.colIndex - node.address.range.start.col,\n y: entry.address.rowIndex - node.address.range.start.row,\n },\n result: spilledResult,\n });\n }\n }\n }\n }\n }\n }\n\n return {\n type: \"values\",\n values: results,\n };\n });\n\n node.setResult(result);\n this.dependencyManager.registerNode(node);\n }\n\n evaluateCellNode(\n node: CellValueNode | SpillMetaNode | VirtualCellValueNode\n ): void {\n // Enable caching for resolved nodes\n if (node.resolved) {\n return;\n }\n\n const finalizePersistentNode = () => {\n if (node instanceof VirtualCellValueNode) {\n return;\n }\n\n this.dependencyManager.registerNode(node);\n };\n\n if (!(node instanceof VirtualCellValueNode)) {\n this.dependencyManager.unregisterNode(node);\n }\n node.resetDirectDepsUpdated();\n\n const ctx = new EvaluationContext(\n this.tableManager,\n node,\n node.cellAddress\n );\n\n if (node instanceof CellValueNode && node.spillMeta) {\n // we are evaluating a e.g. A1 in A1=SEQUENCE(10), where we want the value in the cell in A1, i.e. 1\n // As A1 is already pointing to a spill meta node, everything has been setup already,\n // we just need to evaluate the spill origin and assign the result to the currentDepNode\n const spillOrigin = node.spillMeta;\n if (spillOrigin.evaluationResult.type === \"spilled-values\") {\n const result = spillOrigin.evaluationResult.evaluate(\n { x: 0, y: 0 },\n ctx\n );\n node.setEvaluationResult(result);\n finalizePersistentNode();\n return;\n }\n }\n\n let content: SerializedCellValue;\n try {\n if (node instanceof VirtualCellValueNode) {\n content = node.cellValue;\n } else {\n content = this.workbookManager.getSerializedCellValue(node.cellAddress);\n }\n } catch (err) {\n const evaluationResult: ErrorEvaluationResult = {\n type: \"error\",\n err: FormulaError.ERROR,\n message: \"Syntax error\",\n errAddress: node,\n };\n node.setEvaluationResult(evaluationResult);\n if (!(node instanceof VirtualCellValueNode)) {\n this.dependencyManager.registerNode(node);\n }\n return;\n }\n\n if (typeof content !== \"string\" || !content.startsWith(\"=\")) {\n if (node instanceof SpillMetaNode) {\n node.setEvaluationResult({\n type: \"does-not-spill\",\n });\n finalizePersistentNode();\n return;\n }\n // Static value cells cannot have frontier dependencies\n const result: ValueEvaluationResult = {\n type: \"value\",\n result: this.convertScalarValueToCellValue(content),\n };\n node.setEvaluationResult(result);\n finalizePersistentNode();\n return;\n }\n\n let evaluation: FunctionEvaluationResult = captureEvaluationErrors(\n node,\n () => this.formulaEvaluator.evaluateFormula(content.slice(1), ctx)\n );\n\n // the evaluated cell IS A spilling formula, e.g. if dependencyKey points to A1, then the formula is e.g. A1=SEQUENCE(10), or A1=A3:B5\n if (evaluation.type === \"spilled-values\") {\n const spillArea = evaluation.spillArea(node.cellAddress);\n\n if (!this.canSpill(node.cellAddress, spillArea)) {\n // Override evaluation with SPILL error, but continue execution to set up nodes\n evaluation = {\n type: \"error\",\n err: FormulaError.SPILL,\n message: \"Cannot spill - area is blocked\",\n errAddress: node,\n };\n } else {\n // Spill succeeds - register it\n this.dependencyManager.setSpilledValue(node.key, {\n spillOnto: spillArea,\n origin: node.cellAddress,\n });\n }\n\n // Set up spill meta node and evaluation results (even if spill failed)\n if (node instanceof SpillMetaNode) {\n // we have already setup an origin/spill meta node relationship,\n // so we are just reevaluating the spill meta node here\n node.setEvaluationResult(evaluation);\n finalizePersistentNode();\n } else {\n const spillMetaNode = this.dependencyManager.getSpillMetaNode(\n node.key.replace(/^[^:]+:/, \"spill-meta:\")\n );\n\n node.addDependency(spillMetaNode);\n node.setSpillMetaNode(spillMetaNode);\n spillMetaNode.setEvaluationResult(evaluation);\n this.dependencyManager.registerNode(spillMetaNode);\n\n if (evaluation.type === \"spilled-values\") {\n const originResult = evaluation.evaluate({ x: 0, y: 0 }, ctx);\n node.setEvaluationResult(originResult);\n } else {\n // Spill failed - set error on origin cell\n node.setEvaluationResult(evaluation);\n }\n }\n finalizePersistentNode();\n return;\n }\n\n if (evaluation.type === \"value\") {\n if (node instanceof SpillMetaNode) {\n node.setEvaluationResult({\n type: \"does-not-spill\",\n });\n finalizePersistentNode();\n return;\n } else {\n node.setEvaluationResult(evaluation);\n finalizePersistentNode();\n return;\n }\n }\n\n node.setEvaluationResult(evaluation);\n finalizePersistentNode();\n }\n\n evaluateDependencyNode(dependency: DependencyNode): void {\n if (dependency instanceof EmptyCellEvaluationNode) {\n this.evaluateEmptyCell(dependency);\n return;\n }\n if (dependency instanceof RangeEvaluationNode) {\n this.evaluateRangeNode(dependency);\n return;\n }\n if (\n dependency instanceof CellValueNode ||\n dependency instanceof VirtualCellValueNode\n ) {\n this.evaluateCellNode(dependency);\n return;\n }\n if (dependency instanceof AstEvaluationNode) {\n return;\n }\n if (dependency instanceof ResourceDependencyNode) {\n return;\n }\n if (dependency instanceof SpillMetaNode) {\n this.evaluateCellNode(dependency);\n return;\n }\n throw new Error(\"Invalid dependency: \" + (dependency as any).key);\n }\n\n /**\n * User exposed method to evaluate a formula\n */\n evaluateFormula(\n /**\n * formula for example\n */\n cellValue: SerializedCellValue,\n cellAddress: CellAddress\n ): SerializedCellValue {\n if (this.isEvaluating) {\n throw new Error(\"Evaluation in progress\");\n }\n\n const node = this.dependencyManager.getVirtualCellValueNode(\n cellAddress,\n cellValue\n );\n\n if (node.evaluationResult.type === \"awaiting-evaluation\") {\n this.evaluateCell(node);\n }\n\n const result = node.evaluationResult;\n\n return this.evaluationResultToSerializedValue(result, cellAddress);\n }\n\n /**\n * Evaluates a cell by building the evaluation order and evaluating the dependencies in order\n */\n evaluateCell(\n node: CellValueNode | EmptyCellEvaluationNode | VirtualCellValueNode\n ): void {\n if (this.isEvaluating) {\n throw new Error(\"Evaluation in progress\");\n }\n this.isEvaluating = true;\n\n let precalculatedPlan: EvaluationOrder | undefined;\n\n let requiresReRun = true;\n while (requiresReRun) {\n requiresReRun = false;\n\n // Use DependencyManager to build evaluation order\n const evaluationPlan =\n precalculatedPlan ?? this.dependencyManager.buildEvaluationOrder(node);\n\n if (evaluationPlan.hasCycle) {\n const evaluationResult: ErrorEvaluationResult = {\n type: \"error\",\n err: FormulaError.CYCLE,\n message: Array.from(evaluationPlan.cycleNodes ?? [])\n .map((node) => node.key)\n .join(\" -> \"),\n errAddress: node,\n };\n // cycle detected\n if (evaluationPlan.cycleNodes) {\n for (const node of evaluationPlan.cycleNodes) {\n if (\n !(node instanceof RangeEvaluationNode) &&\n !(node instanceof ResourceDependencyNode)\n ) {\n node.setEvaluationResult(evaluationResult);\n }\n }\n }\n this.isEvaluating = false;\n }\n\n // Evaluate all dependencies in order\n const timeStart = performance.now();\n const durations: { duration: number; key: string }[] = [];\n let numResolved = 0;\n if (flags.isProfiling && evaluationPlan.evaluationOrder.size > -1) {\n // console.profile();\n }\n evaluationPlan.evaluationOrder.forEach((dependency) => {\n const start = performance.now();\n if (dependency.resolved) {\n numResolved++;\n }\n this.evaluateDependencyNode(dependency);\n\n const end = performance.now();\n if (flags.isProfiling && evaluationPlan.evaluationOrder.size > -1) {\n durations.push({ duration: end - start, key: dependency.key });\n }\n });\n if (flags.isProfiling && evaluationPlan.evaluationOrder.size > -1) {\n // console.profileEnd();\n }\n if (flags.isProfiling && evaluationPlan.evaluationOrder.size > -1) {\n const percentResolved = Math.round(\n (100 * numResolved) / evaluationPlan.evaluationOrder.size\n );\n const avgDuration =\n durations.reduce((a, b) => a + b.duration, 0) / durations.length || 0;\n console.log(\n `%c[Evaluation] %c${evaluationPlan.evaluationOrder.size} deps | %c${(\n performance.now() - timeStart\n ).toFixed(\n 1\n )}ms | %c${percentResolved}% resolved | %c${avgDuration.toFixed(\n 2\n )}ms avg`,\n \"color:#83aaff;font-weight:bold;\",\n \"color:#fff;font-weight:bold;\",\n \"color:#7fff9e\",\n \"color:#85baff\",\n \"color:#ffdfa3\"\n );\n }\n\n this.dependencyManager.markResolvedNodes(node);\n\n const nextEvaluationPlan =\n this.dependencyManager.buildEvaluationOrder(node);\n\n this.dependencyManager.updateResolvedSCCs(nextEvaluationPlan);\n\n precalculatedPlan = nextEvaluationPlan;\n\n // Check if new dependencies were discovered during evaluation\n if (nextEvaluationPlan.hash !== evaluationPlan.hash) {\n requiresReRun = true;\n } else {\n this.isEvaluating = false;\n return;\n }\n }\n this.isEvaluating = false;\n }\n\n convertScalarValueToCellValue(val: SerializedCellValue): CellValue {\n if (val === \"INFINITY\") {\n return { type: \"infinity\", sign: \"positive\" };\n }\n if (val === \"-INFINITY\") {\n return { type: \"infinity\", sign: \"negative\" };\n }\n if (typeof val === \"number\") {\n return { type: \"number\", value: val };\n }\n if (typeof val === \"boolean\") {\n return { type: \"boolean\", value: val };\n }\n if (typeof val === \"undefined\") {\n return { type: \"string\", value: \"\" };\n }\n return { type: \"string\", value: val };\n }\n\n // todo optimize using workbook manager\n canSpill(spillCandidate: CellAddress, spillArea: SpreadsheetRange): boolean {\n // Check if the spill origin cell is inside a table - spilling formulas cannot exist in tables\n if (this.tableManager.isCellInTable(spillCandidate)) {\n return false;\n }\n\n // Check if the spill area would intersect with any table - formulas cannot spill into tables\n if (\n this.tableManager.doesRangeIntersectTable(\n spillCandidate.workbookName,\n spillCandidate.sheetName,\n spillArea\n )\n ) {\n return false;\n }\n\n const sheet = this.workbookManager.getSheet(spillCandidate);\n if (!sheet) {\n throw new SheetNotFoundError(spillCandidate.sheetName);\n }\n const cellId = getCellReference(spillCandidate);\n const content = sheet.content.get(cellId);\n if (!content) {\n throw new EvaluationError(FormulaError.REF, `Cell not found: ${cellId}`);\n }\n for (const spilledValue of this.dependencyManager.spilledValues) {\n if (\n spilledValue.origin.workbookName !== spillCandidate.workbookName ||\n spilledValue.origin.sheetName !== spillCandidate.sheetName\n ) {\n continue;\n }\n if (\n spilledValue.origin.colIndex === spillCandidate.colIndex &&\n spilledValue.origin.rowIndex === spillCandidate.rowIndex\n ) {\n // we are already have a spill, this one will be replaced\n continue;\n }\n\n if (checkRangeIntersection(spillArea, spilledValue.spillOnto)) {\n return false;\n }\n }\n // let's just check the raw data if there is something in the range\n for (const key of sheet.content.keys()) {\n const cellAddress = parseCellReference(key);\n const endCol = spillArea.end.col;\n const endRow = spillArea.end.row;\n\n if (\n cellAddress.colIndex === spillCandidate.colIndex &&\n cellAddress.rowIndex === spillCandidate.rowIndex\n ) {\n continue;\n }\n\n if (endCol.type === \"number\" && endRow.type === \"number\") {\n if (\n cellAddress.colIndex >= spillArea.start.col &&\n cellAddress.colIndex <= endCol.value &&\n cellAddress.rowIndex >= spillArea.start.row &&\n cellAddress.rowIndex <= endRow.value\n ) {\n if (\n normalizeSerializedCellValue(sheet.content.get(key)) !== undefined\n ) {\n // there is something in the range, so we can't spill\n return false;\n }\n }\n }\n }\n\n return true;\n }\n\n getCellEvaluationResult(\n cellAddress: CellAddress\n ): SingleEvaluationResult | undefined {\n if (this.isEvaluating) {\n throw new Error(\"Evaluation in progress\");\n }\n\n const nodeKey = cellAddressToKey(cellAddress);\n const node = this.dependencyManager.getCellValueOrEmptyCellNode(nodeKey);\n\n const sheet = this.workbookManager.getSheet(cellAddress);\n if (!sheet) {\n throw new SheetNotFoundError(cellAddress.sheetName);\n }\n\n if (node.evaluationResult.type === \"awaiting-evaluation\") {\n // if (cellAddressToKey(cellAddress).includes(\"G10\")) {\n // console.group(\"Evaluation of G10\");\n // flags.isProfiling = true;\n // console.time(\"Evaluation of G10\");\n // console.profile(\"Evaluation of G10\");\n // }\n this.evaluateCell(node);\n // if (flags.isProfiling) {\n // flags.isProfiling = false;\n // console.timeEnd(\"Evaluation of G10\");\n // console.profileEnd(\"Evaluation of G10\");\n // console.groupEnd();\n // }\n }\n\n const result = node.evaluationResult;\n\n return result;\n }\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";AAAA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAIA;AACA;AAEA;AAAA;AAAA;AAcA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAcA;AACA;AAGA;AACA;AAAA;AAaO,MAAM,kBAAkB;AAAA,EAInB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EANF,eAAe;AAAA,EAEvB,WAAW,CACD,iBACA,cACA,kBACA,mBACR;AAAA,IAJQ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,EAGV,oBAAoB,GAAS;AAAA,IAC3B,KAAK,kBAAkB,qBAAqB;AAAA;AAAA,EAGtC,aAAa,CACnB,WACA,QACA,UAA+B,IAAI,KAC1B;AAAA,IACT,IAAI,cAAc,QAAQ;AAAA,MACxB,OAAO;AAAA,IACT;AAAA,IAEA,IAAI,QAAQ,IAAI,SAAS,GAAG;AAAA,MAC1B,OAAO;AAAA,IACT;AAAA,IACA,QAAQ,IAAI,SAAS;AAAA,IAErB,WAAW,OAAO,UAAU,gBAAgB,GAAG;AAAA,MAC7C,IAAI,KAAK,cAAc,KAAK,QAAQ,OAAO,GAAG;AAAA,QAC5C,OAAO;AAAA,MACT;AAAA,IACF;AAAA,IAEA,OAAO;AAAA;AAAA,EAGT,sBAAsB,CAAC,WAAuC;AAAA,IAC5D,KAAK,kBAAkB,uBAAuB,SAAS;AAAA;AAAA,EAGzD,iCAAiC,CAC/B,YACA,aACA,OACqB;AAAA,IACrB,IACE,WAAW,SAAS,WACpB,WAAW,SAAS,uBACpB;AAAA,MACA,MAAM,QAAQ,WAAW;AAAA,MAEzB,OAAO,MAAM,SAAS,aAClB,MAAM,SAAS,aACb,aACA,cACF,MAAM;AAAA,I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AA,MACrB,MAAM,IAAI,MAAM,wBAAwB;AAAA,IAC1C;AAAA,IAEA,MAAM,UAAU,iBAAiB,WAAW;AAAA,IAC5C,MAAM,OAAO,KAAK,kBAAkB,4BAA4B,OAAO;AAAA,IAEvE,MAAM,QAAQ,KAAK,gBAAgB,SAAS,WAAW;AAAA,IACvD,IAAI,CAAC,OAAO;AAAA,MACV,MAAM,IAAI,mBAAmB,YAAY,SAAS;AAAA,IACpD;AAAA,IAEA,IAAI,KAAK,iBAAiB,SAAS,uBAAuB;AAAA,MAOxD,KAAK,aAAa,IAAI;AAAA,IAOxB;AAAA,IAEA,MAAM,SAAS,KAAK;AAAA,IAEpB,OAAO;AAAA;AAEX;",
|
|
8
|
+
"debugId": "E28F2E811FD149C364756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
// src/evaluator/evaluation-context.ts
|
|
2
|
+
var NO_TABLE_CONTEXT_NAME = "__no_current_table__";
|
|
3
|
+
|
|
2
4
|
class EvaluationContext {
|
|
3
5
|
_cellAddress;
|
|
4
6
|
_tableName;
|
|
7
|
+
_cacheTableName;
|
|
5
8
|
_dependencyNode;
|
|
6
9
|
constructor(tableManager, dependencyNode, cellAddress) {
|
|
7
10
|
this._dependencyNode = dependencyNode;
|
|
8
11
|
this._cellAddress = cellAddress;
|
|
9
12
|
const table = tableManager.isCellInTable(cellAddress);
|
|
10
13
|
this._tableName = table?.name;
|
|
14
|
+
this._cacheTableName = table?.name ?? NO_TABLE_CONTEXT_NAME;
|
|
11
15
|
}
|
|
12
16
|
get dependencyNode() {
|
|
13
17
|
return this._dependencyNode;
|
|
@@ -22,6 +26,9 @@ class EvaluationContext {
|
|
|
22
26
|
get tableName() {
|
|
23
27
|
return this._tableName;
|
|
24
28
|
}
|
|
29
|
+
get cacheTableName() {
|
|
30
|
+
return this._cacheTableName;
|
|
31
|
+
}
|
|
25
32
|
addContextDependency(...types) {
|
|
26
33
|
for (const type of types) {
|
|
27
34
|
switch (type) {
|
|
@@ -38,7 +45,7 @@ class EvaluationContext {
|
|
|
38
45
|
this._contextDependency.sheetName = this._cellAddress.sheetName;
|
|
39
46
|
break;
|
|
40
47
|
case "table":
|
|
41
|
-
this._contextDependency.tableName = this.
|
|
48
|
+
this._contextDependency.tableName = this.cacheTableName;
|
|
42
49
|
break;
|
|
43
50
|
default:
|
|
44
51
|
throw new Error(`Invalid context dependency type: ${type}`);
|
|
@@ -87,18 +94,27 @@ function eligibleKeysForContext(ctx) {
|
|
|
87
94
|
if (ctx.tableName === undefined && (mask >> tableIdx & 1) === 1)
|
|
88
95
|
continue;
|
|
89
96
|
const dep = {};
|
|
97
|
+
let specificity = 0;
|
|
90
98
|
for (let i = 0;i < n; i++) {
|
|
91
99
|
if ((mask >> i & 1) === 1) {
|
|
92
100
|
const k = DIM_ORDER[i];
|
|
93
101
|
const v = ctx[k];
|
|
94
|
-
if (v !== undefined)
|
|
102
|
+
if (v !== undefined) {
|
|
95
103
|
dep[k] = v;
|
|
104
|
+
specificity++;
|
|
105
|
+
}
|
|
96
106
|
}
|
|
97
107
|
}
|
|
98
|
-
results.push(
|
|
108
|
+
results.push({
|
|
109
|
+
key: keyFromDependency(dep),
|
|
110
|
+
specificity,
|
|
111
|
+
mask
|
|
112
|
+
});
|
|
99
113
|
}
|
|
100
|
-
|
|
101
|
-
|
|
114
|
+
results.sort((left, right) => right.specificity - left.specificity || right.mask - left.mask);
|
|
115
|
+
const orderedKeys = results.map((result) => result.key);
|
|
116
|
+
contextCacheKey.set(mostRestrictiveKey, orderedKeys);
|
|
117
|
+
return orderedKeys;
|
|
102
118
|
}
|
|
103
119
|
function getContextDependencyKey(contextDependency) {
|
|
104
120
|
const keys = [];
|
|
@@ -117,7 +133,8 @@ export {
|
|
|
117
133
|
eligibleKeysForContext,
|
|
118
134
|
dependencyMatchesContext,
|
|
119
135
|
contextDependencyKeys,
|
|
136
|
+
NO_TABLE_CONTEXT_NAME,
|
|
120
137
|
EvaluationContext
|
|
121
138
|
};
|
|
122
139
|
|
|
123
|
-
//# debugId=
|
|
140
|
+
//# debugId=BC42659798DC10D764756E2164756E21
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/evaluator/evaluation-context.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import type { DependencyNode } from \"../core/managers/dependency-node.mjs\";\nimport type { TableManager } from \"../core/managers/table-manager.mjs\";\nimport type { CellAddress } from \"../core/types.mjs\";\n\nexport class EvaluationContext {\n private _cellAddress: CellAddress;\n private _tableName: string | undefined;\n /**\n * Can be a range or a cell\n */\n private _dependencyNode: DependencyNode;\n constructor(\n tableManager: TableManager,\n dependencyNode: DependencyNode,\n cellAddress: CellAddress\n ) {\n this._dependencyNode = dependencyNode;\n this._cellAddress = cellAddress;\n const table = tableManager.isCellInTable(cellAddress);\n this._tableName = table?.name;\n }\n\n get dependencyNode() {\n return this._dependencyNode;\n }\n\n private _contextDependency: ContextDependency = {};\n\n getContextDependency() {\n return this._contextDependency;\n }\n\n /**\n * The cell context, the address of the cell being evaluated\n * and the context in which results should be stored\n */\n get cellAddress() {\n return this._cellAddress;\n }\n\n get tableName() {\n return this._tableName;\n }\n\n addContextDependency(...types: ContextDependencyType[]) {\n for (const type of types) {\n switch (type) {\n case \"row\":\n this._contextDependency.rowIndex = this._cellAddress.rowIndex;\n break;\n case \"col\":\n this._contextDependency.colIndex = this._cellAddress.colIndex;\n break;\n case \"workbook\":\n this._contextDependency.workbookName = this._cellAddress.workbookName;\n break;\n case \"sheet\":\n this._contextDependency.sheetName = this._cellAddress.sheetName;\n break;\n case \"table\":\n this._contextDependency.tableName = this.
|
|
5
|
+
"import type { DependencyNode } from \"../core/managers/dependency-node.mjs\";\nimport type { TableManager } from \"../core/managers/table-manager.mjs\";\nimport type { CellAddress } from \"../core/types.mjs\";\n\nexport const NO_TABLE_CONTEXT_NAME = \"__no_current_table__\";\n\nexport class EvaluationContext {\n private _cellAddress: CellAddress;\n private _tableName: string | undefined;\n private _cacheTableName: string;\n /**\n * Can be a range or a cell\n */\n private _dependencyNode: DependencyNode;\n constructor(\n tableManager: TableManager,\n dependencyNode: DependencyNode,\n cellAddress: CellAddress\n ) {\n this._dependencyNode = dependencyNode;\n this._cellAddress = cellAddress;\n const table = tableManager.isCellInTable(cellAddress);\n this._tableName = table?.name;\n this._cacheTableName = table?.name ?? NO_TABLE_CONTEXT_NAME;\n }\n\n get dependencyNode() {\n return this._dependencyNode;\n }\n\n private _contextDependency: ContextDependency = {};\n\n getContextDependency() {\n return this._contextDependency;\n }\n\n /**\n * The cell context, the address of the cell being evaluated\n * and the context in which results should be stored\n */\n get cellAddress() {\n return this._cellAddress;\n }\n\n get tableName() {\n return this._tableName;\n }\n\n get cacheTableName() {\n return this._cacheTableName;\n }\n\n addContextDependency(...types: ContextDependencyType[]) {\n for (const type of types) {\n switch (type) {\n case \"row\":\n this._contextDependency.rowIndex = this._cellAddress.rowIndex;\n break;\n case \"col\":\n this._contextDependency.colIndex = this._cellAddress.colIndex;\n break;\n case \"workbook\":\n this._contextDependency.workbookName = this._cellAddress.workbookName;\n break;\n case \"sheet\":\n this._contextDependency.sheetName = this._cellAddress.sheetName;\n break;\n case \"table\":\n this._contextDependency.tableName = this.cacheTableName;\n break;\n default:\n throw new Error(`Invalid context dependency type: ${type}`);\n }\n }\n }\n\n /**\n * When evaluating an AST node,\n * we need to append the subtree context\n * dependencies to the current context dependency\n */\n appendContextDependency(contextDependency: ContextDependency) {\n this._contextDependency = {\n ...this._contextDependency,\n ...Object.fromEntries(\n Object.entries(contextDependency).filter(\n ([key, value]) => value !== undefined\n )\n ),\n };\n }\n}\n\n/**\n * Each value has the same value as the origin cell\n * the defined keys are the ones the ast node is dependent on\n * e.g. A3=ROW() will have a context dependency of { rowIndex: 3 }\n *\n * The keys are ANDed together, e.g. { workbookName: \"Sheet1\", sheetName: \"Sheet2\" }\n * means the ast node is dependent on the workbook \"Sheet1\" and the sheet \"Sheet2\"\n */\nexport type ContextDependency = {\n workbookName?: string;\n sheetName?: string;\n tableName?: string;\n rowIndex?: number;\n colIndex?: number;\n};\n\nexport const contextDependencyKeys = [\n \"workbookName\",\n \"sheetName\",\n \"tableName\",\n \"rowIndex\",\n \"colIndex\",\n] as const;\n\n/**\n * These are some distinct scenarios where context dependencies are added\n */\nexport type ContextDependencyType =\n | \"row\"\n | \"col\"\n | \"workbook\"\n | \"sheet\"\n | \"table\";\n\n// * [astKey], // `=1+1`\n// * [astKey, sheetKey, workbookKey], // `B3`\n// * [astKey, workbookKey], // `Table1[Column1]`\n// * [astKey, workbookKey], // `Sheet1!B3`\n// * [astKey, cellAddress.rowIndex], // `ROW()`\n// * [astKey, cellAddress.colIndex], // `COL()`\n// * [astKey, cellAddress.rowIndex, cellAddress.colIndex] // `CELL(\"address\")`\n// * [astKey, tableKey, cellAddress.rowIndex], // `@Column1`\n// * [astKey, workbookKey, cellAddress.rowIndex], // `Table1[@Column1]`\n\ntype Dim = \"workbookName\" | \"sheetName\" | \"tableName\" | \"rowIndex\" | \"colIndex\";\nconst DIM_ORDER: readonly Dim[] = [\n \"workbookName\",\n \"sheetName\",\n \"tableName\",\n \"rowIndex\",\n \"colIndex\",\n] as const;\n\n/** Build the canonical cache key string for a dependency. */\nexport function keyFromDependency(dep: ContextDependency): string {\n return DIM_ORDER.map((k) =>\n dep[k] !== undefined ? `${k}:[${(dep as any)[k]}]` : `${k}:*`\n ).join(\",\");\n}\n\ntype Context = {\n workbookName: string;\n sheetName: string;\n tableName?: string;\n rowIndex: number;\n colIndex: number;\n};\n\n/** True if `dep` matches `ctx` (i.e., every specified field equals the context’s field). */\nexport function dependencyMatchesContext(\n ctx: Context,\n dep: ContextDependency\n): boolean {\n return DIM_ORDER.every(\n (k) => dep[k] === undefined || (dep as any)[k] === (ctx as any)[k]\n );\n}\n\nconst contextCacheKey = new Map<string, string[]>();\n\n/**\n * Generate every cache key that would be eligible for `ctx`.\n * By default returns keys ordered from most-specific to least-specific.\n */\nexport function eligibleKeysForContext(ctx: Context): string[] {\n const mostRestrictiveKey = keyFromDependency(ctx);\n const cachedKeys = contextCacheKey.get(mostRestrictiveKey);\n if (cachedKeys) {\n return cachedKeys;\n }\n\n const results: Array<{ key: string; specificity: number; mask: number }> = [];\n const n = DIM_ORDER.length;\n\n // If tableName is undefined in the context, the lookup is not modeling table\n // membership at all, so we cannot generate keys that specify it.\n const tableIdx = DIM_ORDER.indexOf(\"tableName\");\n\n const totalMasks = 1 << n; // 2^n\n for (let mask = 0; mask < totalMasks; mask++) {\n // Skip combos that specify tableName when ctx.tableName is undefined.\n if (ctx.tableName === undefined && ((mask >> tableIdx) & 1) === 1) continue;\n\n const dep: ContextDependency = {};\n let specificity = 0;\n for (let i = 0; i < n; i++) {\n if (((mask >> i) & 1) === 1) {\n const k = DIM_ORDER[i];\n const v = (ctx as any)[k!];\n // Only assign when the dimension participates in the context.\n if (v !== undefined) {\n (dep as any)[k!] = v;\n specificity++;\n }\n }\n }\n results.push({\n key: keyFromDependency(dep),\n specificity,\n mask,\n });\n }\n\n results.sort(\n (left, right) =>\n right.specificity - left.specificity || right.mask - left.mask\n );\n\n const orderedKeys = results.map((result) => result.key);\n\n contextCacheKey.set(mostRestrictiveKey, orderedKeys);\n\n return orderedKeys;\n}\n\nexport function getContextDependencyKey(contextDependency: ContextDependency) {\n const keys: (string | number)[] = [];\n contextDependencyKeys.forEach((key) => {\n if (contextDependency[key] !== undefined) {\n keys.push(`${key}:[${contextDependency[key]}]`);\n } else {\n keys.push(`${key}:*`);\n }\n });\n return keys.join(\",\");\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";AAIO,MAAM,kBAAkB;AAAA,EACrB;AAAA,EACA;AAAA,EAIA;AAAA,EACR,WAAW,CACT,cACA,gBACA,aACA;AAAA,IACA,KAAK,kBAAkB;AAAA,IACvB,KAAK,eAAe;AAAA,IACpB,MAAM,QAAQ,aAAa,cAAc,WAAW;AAAA,IAC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IAAY;AAAA,QAEvB,IAAI,MAAM,WAAW;AAAA,UAClB,IAAY,KAAM;AAAA,UACnB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,QAAQ,KAAK;AAAA,MACX,KAAK,kBAAkB,GAAG;AAAA,MAC1B;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,QAAQ,KACN,CAAC,MAAM,UACL,MAAM,cAAc,KAAK,eAAe,MAAM,OAAO,KAAK,IAC9D;AAAA,EAEA,MAAM,cAAc,QAAQ,IAAI,CAAC,WAAW,OAAO,GAAG;AAAA,EAEtD,gBAAgB,IAAI,oBAAoB,WAAW;AAAA,EAEnD,OAAO;AAAA;AAGF,SAAS,uBAAuB,CAAC,mBAAsC;AAAA,EAC5E,MAAM,OAA4B,CAAC;AAAA,EACnC,sBAAsB,QAAQ,CAAC,QAAQ;AAAA,IACrC,IAAI,kBAAkB,SAAS,WAAW;AAAA,MACxC,KAAK,KAAK,GAAG,QAAQ,kBAAkB,OAAO;AAAA,IAChD,EAAO;AAAA,MACL,KAAK,KAAK,GAAG,OAAO;AAAA;AAAA,GAEvB;AAAA,EACD,OAAO,KAAK,KAAK,GAAG;AAAA;",
|
|
8
|
+
"debugId": "BC42659798DC10D764756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -57,7 +57,7 @@ class FormulaEvaluator {
|
|
|
57
57
|
evaluateNode(node, context) {
|
|
58
58
|
const currentContext = {
|
|
59
59
|
...context.cellAddress,
|
|
60
|
-
tableName: context.
|
|
60
|
+
tableName: context.cacheTableName
|
|
61
61
|
};
|
|
62
62
|
const astNode = this.dependencyManager.getAstNode(node, currentContext);
|
|
63
63
|
context.dependencyNode.addDependency(astNode);
|
|
@@ -134,7 +134,7 @@ class FormulaEvaluator {
|
|
|
134
134
|
context.addContextDependency("workbook");
|
|
135
135
|
table = this.tableManager.getTables(context.cellAddress.workbookName).get(node.tableName);
|
|
136
136
|
} else {
|
|
137
|
-
context.addContextDependency("workbook", "table");
|
|
137
|
+
context.addContextDependency("workbook", "sheet", "table");
|
|
138
138
|
table = this.tableManager.isCellInTable(context.cellAddress);
|
|
139
139
|
}
|
|
140
140
|
if (node.isCurrentRow) {
|
|
@@ -815,4 +815,4 @@ export {
|
|
|
815
815
|
FormulaEvaluator
|
|
816
816
|
};
|
|
817
817
|
|
|
818
|
-
//# debugId=
|
|
818
|
+
//# debugId=4126D554F58B6F4364756E2164756E21
|