@ricsam/formula-engine 0.0.3 → 0.0.5
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.cjs +12 -8
- package/dist/cjs/core/engine.cjs.map +3 -3
- package/dist/cjs/core/managers/dependency-manager.cjs +8 -8
- package/dist/cjs/core/managers/dependency-manager.cjs.map +3 -3
- package/dist/cjs/core/managers/evaluation-manager.cjs +10 -10
- package/dist/cjs/core/managers/evaluation-manager.cjs.map +2 -2
- package/dist/cjs/core/managers/frontier-dependency-manager.cjs.map +1 -1
- package/dist/cjs/core/managers/isDependencyNode.cjs +6 -6
- package/dist/cjs/core/managers/isDependencyNode.cjs.map +2 -2
- package/dist/cjs/core/managers/named-expression-manager.cjs.map +1 -1
- package/dist/cjs/core/managers/range-eval-order-builder.cjs +2 -2
- package/dist/cjs/core/managers/range-eval-order-builder.cjs.map +3 -3
- package/dist/cjs/core/managers/workbook-manager.cjs +3 -3
- package/dist/cjs/core/managers/workbook-manager.cjs.map +2 -2
- package/dist/cjs/core/types.cjs.map +2 -2
- package/dist/cjs/core/utils.cjs +2 -2
- package/dist/cjs/core/utils.cjs.map +2 -2
- package/dist/cjs/evaluator/arithmetic/add/add.cjs +2 -2
- package/dist/cjs/evaluator/arithmetic/add/add.cjs.map +2 -2
- package/dist/cjs/evaluator/arithmetic/divide/divide.cjs +2 -2
- package/dist/cjs/evaluator/arithmetic/divide/divide.cjs.map +2 -2
- package/dist/cjs/evaluator/arithmetic/multiply/multiply.cjs +2 -2
- package/dist/cjs/evaluator/arithmetic/multiply/multiply.cjs.map +2 -2
- package/dist/cjs/evaluator/arithmetic/power/power.cjs +2 -2
- package/dist/cjs/evaluator/arithmetic/power/power.cjs.map +2 -2
- package/dist/cjs/evaluator/arithmetic/subtract/subtract.cjs +2 -2
- package/dist/cjs/evaluator/arithmetic/subtract/subtract.cjs.map +2 -2
- package/dist/cjs/evaluator/comparison/equals.cjs.map +1 -1
- package/dist/cjs/evaluator/comparison/greater-than-or-equal.cjs +2 -2
- package/dist/cjs/evaluator/comparison/greater-than-or-equal.cjs.map +2 -2
- package/dist/cjs/evaluator/comparison/greater-than.cjs +2 -2
- package/dist/cjs/evaluator/comparison/greater-than.cjs.map +2 -2
- package/dist/cjs/evaluator/comparison/less-than-or-equal.cjs +2 -2
- package/dist/cjs/evaluator/comparison/less-than-or-equal.cjs.map +2 -2
- package/dist/cjs/evaluator/comparison/less-than.cjs +2 -2
- package/dist/cjs/evaluator/comparison/less-than.cjs.map +2 -2
- package/dist/cjs/evaluator/comparison/not-equals.cjs +2 -2
- package/dist/cjs/evaluator/comparison/not-equals.cjs.map +2 -2
- package/dist/cjs/evaluator/concatenation/concatenate.cjs +2 -2
- package/dist/cjs/evaluator/concatenation/concatenate.cjs.map +2 -2
- package/dist/cjs/evaluator/dependency-nodes/ast-evaluation-node.cjs +2 -2
- package/dist/cjs/evaluator/dependency-nodes/ast-evaluation-node.cjs.map +2 -2
- package/dist/cjs/evaluator/dependency-nodes/base-eval-node.cjs.map +2 -2
- package/dist/cjs/evaluator/dependency-nodes/cell-value-node.cjs +2 -2
- package/dist/cjs/evaluator/dependency-nodes/cell-value-node.cjs.map +2 -2
- package/dist/cjs/evaluator/dependency-nodes/empty-cell-evaluation-node.cjs +3 -3
- package/dist/cjs/evaluator/dependency-nodes/empty-cell-evaluation-node.cjs.map +2 -2
- package/dist/cjs/evaluator/dependency-nodes/spill-meta-node.cjs +2 -2
- package/dist/cjs/evaluator/dependency-nodes/spill-meta-node.cjs.map +2 -2
- package/dist/cjs/evaluator/evaluate-scalar-operator.cjs.map +1 -1
- package/dist/cjs/evaluator/evaluation-context.cjs.map +2 -2
- package/dist/cjs/evaluator/evaluation-error.cjs.map +1 -1
- package/dist/cjs/evaluator/formula-evaluator.cjs +6 -6
- package/dist/cjs/evaluator/formula-evaluator.cjs.map +3 -3
- package/dist/cjs/evaluator/range-evaluation-node.cjs +3 -3
- package/dist/cjs/evaluator/range-evaluation-node.cjs.map +2 -2
- package/dist/cjs/functions/_template/template.cjs.map +1 -1
- package/dist/cjs/functions/array/sequence/sequence.cjs +4 -4
- package/dist/cjs/functions/array/sequence/sequence.cjs.map +2 -2
- package/dist/cjs/functions/criteria-parser.cjs.map +1 -1
- package/dist/cjs/functions/criteria-utils.cjs +4 -4
- package/dist/cjs/functions/criteria-utils.cjs.map +3 -3
- package/dist/cjs/functions/{index.cjs → function-registry.cjs} +5 -5
- package/dist/cjs/functions/function-registry.cjs.map +10 -0
- package/dist/cjs/functions/function-utils.cjs.map +1 -1
- package/dist/cjs/functions/information/cell/cell.cjs +3 -3
- package/dist/cjs/functions/information/cell/cell.cjs.map +2 -2
- package/dist/cjs/functions/information/column/column.cjs +4 -4
- package/dist/cjs/functions/information/column/column.cjs.map +2 -2
- package/dist/cjs/functions/information/row/row.cjs +4 -4
- package/dist/cjs/functions/information/row/row.cjs.map +2 -2
- package/dist/cjs/functions/logical/and/and.cjs +2 -2
- package/dist/cjs/functions/logical/and/and.cjs.map +2 -2
- package/dist/cjs/functions/logical/if/if.cjs +2 -2
- package/dist/cjs/functions/logical/if/if.cjs.map +3 -3
- package/dist/cjs/functions/logical/iferror/iferror.cjs +3 -3
- package/dist/cjs/functions/logical/iferror/iferror.cjs.map +2 -2
- package/dist/cjs/functions/logical/or/or.cjs +2 -2
- package/dist/cjs/functions/logical/or/or.cjs.map +2 -2
- package/dist/cjs/functions/lookup/count/count-utils.cjs.map +1 -1
- package/dist/cjs/functions/lookup/count/count.cjs +2 -2
- package/dist/cjs/functions/lookup/count/count.cjs.map +2 -2
- package/dist/cjs/functions/lookup/count/countif.cjs +2 -2
- package/dist/cjs/functions/lookup/count/countif.cjs.map +2 -2
- package/dist/cjs/functions/lookup/count/countifs.cjs.map +1 -1
- package/dist/cjs/functions/lookup/index-lookup/index-lookup.cjs +2 -2
- package/dist/cjs/functions/lookup/index-lookup/index-lookup.cjs.map +2 -2
- package/dist/cjs/functions/lookup/match/match.cjs +2 -2
- package/dist/cjs/functions/lookup/match/match.cjs.map +2 -2
- package/dist/cjs/functions/lookup/xlookup/xlookup.cjs +2 -2
- package/dist/cjs/functions/lookup/xlookup/xlookup.cjs.map +2 -2
- package/dist/cjs/functions/math/average/average-utils.cjs +2 -2
- package/dist/cjs/functions/math/average/average-utils.cjs.map +2 -2
- package/dist/cjs/functions/math/average/average.cjs +2 -2
- package/dist/cjs/functions/math/average/average.cjs.map +2 -2
- package/dist/cjs/functions/math/average/averageif.cjs +3 -3
- package/dist/cjs/functions/math/average/averageif.cjs.map +3 -3
- package/dist/cjs/functions/math/average/averageifs.cjs.map +2 -2
- package/dist/cjs/functions/math/ceiling/ceiling.cjs +2 -2
- package/dist/cjs/functions/math/ceiling/ceiling.cjs.map +3 -3
- package/dist/cjs/functions/math/max/max-utils.cjs +2 -2
- package/dist/cjs/functions/math/max/max-utils.cjs.map +2 -2
- package/dist/cjs/functions/math/max/max.cjs +2 -2
- package/dist/cjs/functions/math/max/max.cjs.map +2 -2
- package/dist/cjs/functions/math/max/maxif.cjs +2 -2
- package/dist/cjs/functions/math/max/maxif.cjs.map +2 -2
- package/dist/cjs/functions/math/max/maxifs.cjs.map +2 -2
- package/dist/cjs/functions/math/min/min-utils.cjs +2 -2
- package/dist/cjs/functions/math/min/min-utils.cjs.map +2 -2
- package/dist/cjs/functions/math/min/min.cjs +2 -2
- package/dist/cjs/functions/math/min/min.cjs.map +3 -3
- package/dist/cjs/functions/math/min/minif.cjs +2 -2
- package/dist/cjs/functions/math/min/minif.cjs.map +2 -2
- package/dist/cjs/functions/math/min/minifs.cjs.map +2 -2
- package/dist/cjs/functions/math/sum/sum.cjs +2 -2
- package/dist/cjs/functions/math/sum/sum.cjs.map +2 -2
- package/dist/cjs/functions/math/sum/sumif.cjs +2 -2
- package/dist/cjs/functions/math/sum/sumif.cjs.map +2 -2
- package/dist/cjs/functions/math/sum/sumifs.cjs.map +2 -2
- package/dist/cjs/functions/math/sum/summation-utils.cjs.map +1 -1
- package/dist/cjs/functions/reference/address/address.cjs +2 -2
- package/dist/cjs/functions/reference/address/address.cjs.map +2 -2
- package/dist/cjs/functions/reference/indirect/indirect.cjs +3 -3
- package/dist/cjs/functions/reference/indirect/indirect.cjs.map +3 -3
- package/dist/cjs/functions/reference/offset/offset.cjs +3 -3
- package/dist/cjs/functions/reference/offset/offset.cjs.map +2 -2
- package/dist/cjs/functions/text/concatenate/concatenate.cjs +2 -2
- package/dist/cjs/functions/text/concatenate/concatenate.cjs.map +2 -2
- package/dist/cjs/functions/text/exact/exact.cjs +2 -2
- package/dist/cjs/functions/text/exact/exact.cjs.map +2 -2
- package/dist/cjs/functions/text/find/find.cjs +2 -2
- package/dist/cjs/functions/text/find/find.cjs.map +3 -3
- package/dist/cjs/functions/text/left/left.cjs +2 -2
- package/dist/cjs/functions/text/left/left.cjs.map +2 -2
- package/dist/cjs/functions/text/len/len.cjs +2 -2
- package/dist/cjs/functions/text/len/len.cjs.map +3 -3
- package/dist/cjs/functions/text/mid/mid.cjs +2 -2
- package/dist/cjs/functions/text/mid/mid.cjs.map +2 -2
- package/dist/cjs/functions/text/right/right.cjs +2 -2
- package/dist/cjs/functions/text/right/right.cjs.map +3 -3
- package/dist/cjs/functions/text/text-helpers.cjs +2 -2
- package/dist/cjs/functions/text/text-helpers.cjs.map +2 -2
- package/dist/cjs/functions/text/textjoin/textjoin.cjs +2 -2
- package/dist/cjs/functions/text/textjoin/textjoin.cjs.map +3 -3
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/parser/formatter.cjs +2 -2
- package/dist/cjs/parser/formatter.cjs.map +2 -2
- package/dist/mjs/core/engine.mjs +7 -9
- package/dist/mjs/core/engine.mjs.map +3 -3
- package/dist/mjs/core/managers/dependency-manager.mjs +8 -8
- package/dist/mjs/core/managers/dependency-manager.mjs.map +3 -3
- package/dist/mjs/core/managers/evaluation-manager.mjs +10 -10
- package/dist/mjs/core/managers/evaluation-manager.mjs.map +2 -2
- package/dist/mjs/core/managers/frontier-dependency-manager.mjs.map +1 -1
- package/dist/mjs/core/managers/isDependencyNode.mjs +6 -6
- package/dist/mjs/core/managers/isDependencyNode.mjs.map +2 -2
- package/dist/mjs/core/managers/named-expression-manager.mjs.map +1 -1
- package/dist/mjs/core/managers/range-eval-order-builder.mjs +2 -2
- package/dist/mjs/core/managers/range-eval-order-builder.mjs.map +3 -3
- package/dist/mjs/core/managers/workbook-manager.mjs +3 -3
- package/dist/mjs/core/managers/workbook-manager.mjs.map +2 -2
- package/dist/mjs/core/types.mjs.map +2 -2
- package/dist/mjs/core/utils.mjs +2 -2
- package/dist/mjs/core/utils.mjs.map +2 -2
- package/dist/mjs/evaluator/arithmetic/add/add.mjs +2 -2
- package/dist/mjs/evaluator/arithmetic/add/add.mjs.map +2 -2
- package/dist/mjs/evaluator/arithmetic/divide/divide.mjs +2 -2
- package/dist/mjs/evaluator/arithmetic/divide/divide.mjs.map +2 -2
- package/dist/mjs/evaluator/arithmetic/multiply/multiply.mjs +2 -2
- package/dist/mjs/evaluator/arithmetic/multiply/multiply.mjs.map +2 -2
- package/dist/mjs/evaluator/arithmetic/power/power.mjs +2 -2
- package/dist/mjs/evaluator/arithmetic/power/power.mjs.map +2 -2
- package/dist/mjs/evaluator/arithmetic/subtract/subtract.mjs +2 -2
- package/dist/mjs/evaluator/arithmetic/subtract/subtract.mjs.map +2 -2
- package/dist/mjs/evaluator/comparison/equals.mjs.map +1 -1
- package/dist/mjs/evaluator/comparison/greater-than-or-equal.mjs +2 -2
- package/dist/mjs/evaluator/comparison/greater-than-or-equal.mjs.map +2 -2
- package/dist/mjs/evaluator/comparison/greater-than.mjs +2 -2
- package/dist/mjs/evaluator/comparison/greater-than.mjs.map +2 -2
- package/dist/mjs/evaluator/comparison/less-than-or-equal.mjs +2 -2
- package/dist/mjs/evaluator/comparison/less-than-or-equal.mjs.map +2 -2
- package/dist/mjs/evaluator/comparison/less-than.mjs +2 -2
- package/dist/mjs/evaluator/comparison/less-than.mjs.map +2 -2
- package/dist/mjs/evaluator/comparison/not-equals.mjs +2 -2
- package/dist/mjs/evaluator/comparison/not-equals.mjs.map +2 -2
- package/dist/mjs/evaluator/concatenation/concatenate.mjs +2 -2
- package/dist/mjs/evaluator/concatenation/concatenate.mjs.map +2 -2
- package/dist/mjs/evaluator/dependency-nodes/ast-evaluation-node.mjs +2 -2
- package/dist/mjs/evaluator/dependency-nodes/ast-evaluation-node.mjs.map +2 -2
- package/dist/mjs/evaluator/dependency-nodes/base-eval-node.mjs.map +2 -2
- package/dist/mjs/evaluator/dependency-nodes/cell-value-node.mjs +2 -2
- package/dist/mjs/evaluator/dependency-nodes/cell-value-node.mjs.map +2 -2
- package/dist/mjs/evaluator/dependency-nodes/empty-cell-evaluation-node.mjs +3 -3
- package/dist/mjs/evaluator/dependency-nodes/empty-cell-evaluation-node.mjs.map +2 -2
- package/dist/mjs/evaluator/dependency-nodes/spill-meta-node.mjs +2 -2
- package/dist/mjs/evaluator/dependency-nodes/spill-meta-node.mjs.map +2 -2
- package/dist/mjs/evaluator/evaluate-scalar-operator.mjs.map +1 -1
- package/dist/mjs/evaluator/evaluation-context.mjs.map +2 -2
- package/dist/mjs/evaluator/evaluation-error.mjs.map +1 -1
- package/dist/mjs/evaluator/formula-evaluator.mjs +7 -7
- package/dist/mjs/evaluator/formula-evaluator.mjs.map +3 -3
- package/dist/mjs/evaluator/range-evaluation-node.mjs +3 -3
- package/dist/mjs/evaluator/range-evaluation-node.mjs.map +2 -2
- package/dist/mjs/functions/_template/template.mjs.map +1 -1
- package/dist/mjs/functions/array/sequence/sequence.mjs +4 -4
- package/dist/mjs/functions/array/sequence/sequence.mjs.map +2 -2
- package/dist/mjs/functions/criteria-parser.mjs.map +1 -1
- package/dist/mjs/functions/criteria-utils.mjs +8 -8
- package/dist/mjs/functions/criteria-utils.mjs.map +3 -3
- package/dist/mjs/functions/{index.mjs → function-registry.mjs} +2 -2
- package/dist/mjs/functions/function-registry.mjs.map +10 -0
- package/dist/mjs/functions/function-utils.mjs.map +1 -1
- package/dist/mjs/functions/information/cell/cell.mjs +3 -3
- package/dist/mjs/functions/information/cell/cell.mjs.map +2 -2
- package/dist/mjs/functions/information/column/column.mjs +4 -4
- package/dist/mjs/functions/information/column/column.mjs.map +2 -2
- package/dist/mjs/functions/information/row/row.mjs +4 -4
- package/dist/mjs/functions/information/row/row.mjs.map +2 -2
- package/dist/mjs/functions/logical/and/and.mjs +2 -2
- package/dist/mjs/functions/logical/and/and.mjs.map +2 -2
- package/dist/mjs/functions/logical/if/if.mjs +2 -2
- package/dist/mjs/functions/logical/if/if.mjs.map +3 -3
- package/dist/mjs/functions/logical/iferror/iferror.mjs +3 -3
- package/dist/mjs/functions/logical/iferror/iferror.mjs.map +2 -2
- package/dist/mjs/functions/logical/or/or.mjs +2 -2
- package/dist/mjs/functions/logical/or/or.mjs.map +2 -2
- package/dist/mjs/functions/lookup/count/count-utils.mjs.map +1 -1
- package/dist/mjs/functions/lookup/count/count.mjs +2 -2
- package/dist/mjs/functions/lookup/count/count.mjs.map +2 -2
- package/dist/mjs/functions/lookup/count/countif.mjs +2 -2
- package/dist/mjs/functions/lookup/count/countif.mjs.map +2 -2
- package/dist/mjs/functions/lookup/count/countifs.mjs.map +1 -1
- package/dist/mjs/functions/lookup/index-lookup/index-lookup.mjs +2 -2
- package/dist/mjs/functions/lookup/index-lookup/index-lookup.mjs.map +2 -2
- package/dist/mjs/functions/lookup/match/match.mjs +2 -2
- package/dist/mjs/functions/lookup/match/match.mjs.map +2 -2
- package/dist/mjs/functions/lookup/xlookup/xlookup.mjs +2 -2
- package/dist/mjs/functions/lookup/xlookup/xlookup.mjs.map +2 -2
- package/dist/mjs/functions/math/average/average-utils.mjs +2 -2
- package/dist/mjs/functions/math/average/average-utils.mjs.map +2 -2
- package/dist/mjs/functions/math/average/average.mjs +2 -2
- package/dist/mjs/functions/math/average/average.mjs.map +2 -2
- package/dist/mjs/functions/math/average/averageif.mjs +3 -3
- package/dist/mjs/functions/math/average/averageif.mjs.map +3 -3
- package/dist/mjs/functions/math/average/averageifs.mjs.map +2 -2
- package/dist/mjs/functions/math/ceiling/ceiling.mjs +2 -2
- package/dist/mjs/functions/math/ceiling/ceiling.mjs.map +3 -3
- package/dist/mjs/functions/math/max/max-utils.mjs +2 -2
- package/dist/mjs/functions/math/max/max-utils.mjs.map +2 -2
- package/dist/mjs/functions/math/max/max.mjs +2 -2
- package/dist/mjs/functions/math/max/max.mjs.map +2 -2
- package/dist/mjs/functions/math/max/maxif.mjs +2 -2
- package/dist/mjs/functions/math/max/maxif.mjs.map +2 -2
- package/dist/mjs/functions/math/max/maxifs.mjs.map +2 -2
- package/dist/mjs/functions/math/min/min-utils.mjs +2 -2
- package/dist/mjs/functions/math/min/min-utils.mjs.map +2 -2
- package/dist/mjs/functions/math/min/min.mjs +2 -2
- package/dist/mjs/functions/math/min/min.mjs.map +2 -2
- package/dist/mjs/functions/math/min/minif.mjs +2 -2
- package/dist/mjs/functions/math/min/minif.mjs.map +2 -2
- package/dist/mjs/functions/math/min/minifs.mjs.map +2 -2
- package/dist/mjs/functions/math/sum/sum.mjs +2 -2
- package/dist/mjs/functions/math/sum/sum.mjs.map +2 -2
- package/dist/mjs/functions/math/sum/sumif.mjs +2 -2
- package/dist/mjs/functions/math/sum/sumif.mjs.map +2 -2
- package/dist/mjs/functions/math/sum/sumifs.mjs.map +2 -2
- package/dist/mjs/functions/math/sum/summation-utils.mjs.map +1 -1
- package/dist/mjs/functions/reference/address/address.mjs +2 -2
- package/dist/mjs/functions/reference/address/address.mjs.map +2 -2
- package/dist/mjs/functions/reference/indirect/indirect.mjs +3 -3
- package/dist/mjs/functions/reference/indirect/indirect.mjs.map +3 -3
- package/dist/mjs/functions/reference/offset/offset.mjs +3 -3
- package/dist/mjs/functions/reference/offset/offset.mjs.map +2 -2
- package/dist/mjs/functions/text/concatenate/concatenate.mjs +2 -2
- package/dist/mjs/functions/text/concatenate/concatenate.mjs.map +2 -2
- package/dist/mjs/functions/text/exact/exact.mjs +2 -2
- package/dist/mjs/functions/text/exact/exact.mjs.map +2 -2
- package/dist/mjs/functions/text/find/find.mjs +2 -2
- package/dist/mjs/functions/text/find/find.mjs.map +3 -3
- package/dist/mjs/functions/text/left/left.mjs +3 -3
- package/dist/mjs/functions/text/left/left.mjs.map +2 -2
- package/dist/mjs/functions/text/len/len.mjs +2 -2
- package/dist/mjs/functions/text/len/len.mjs.map +3 -3
- package/dist/mjs/functions/text/mid/mid.mjs +3 -3
- package/dist/mjs/functions/text/mid/mid.mjs.map +2 -2
- package/dist/mjs/functions/text/right/right.mjs +4 -4
- package/dist/mjs/functions/text/right/right.mjs.map +3 -3
- package/dist/mjs/functions/text/text-helpers.mjs +2 -2
- package/dist/mjs/functions/text/text-helpers.mjs.map +2 -2
- package/dist/mjs/functions/text/textjoin/textjoin.mjs +2 -2
- package/dist/mjs/functions/text/textjoin/textjoin.mjs.map +3 -3
- package/dist/mjs/package.json +1 -1
- package/dist/mjs/parser/formatter.mjs +2 -2
- package/dist/mjs/parser/formatter.mjs.map +2 -2
- package/dist/types/core/engine.d.ts +5 -1
- package/dist/types/core/managers/dependency-manager.d.ts +7 -7
- package/dist/types/core/managers/dependency-node.d.ts +5 -5
- package/dist/types/core/managers/evaluation-manager.d.ts +4 -4
- package/dist/types/core/managers/frontier-dependency-manager.d.ts +2 -2
- package/dist/types/core/managers/named-expression-manager.d.ts +2 -2
- package/dist/types/core/managers/workbook-manager.d.ts +1 -1
- package/dist/types/core/types.d.ts +3 -3
- package/dist/types/evaluator/arithmetic/add/add.d.ts +1 -1
- package/dist/types/evaluator/arithmetic/divide/divide.d.ts +1 -1
- package/dist/types/evaluator/arithmetic/multiply/multiply.d.ts +1 -1
- package/dist/types/evaluator/arithmetic/power/power.d.ts +1 -1
- package/dist/types/evaluator/arithmetic/subtract/subtract.d.ts +1 -1
- package/dist/types/evaluator/comparison/equals.d.ts +1 -1
- package/dist/types/evaluator/comparison/greater-than-or-equal.d.ts +1 -1
- package/dist/types/evaluator/comparison/greater-than.d.ts +1 -1
- package/dist/types/evaluator/comparison/less-than-or-equal.d.ts +1 -1
- package/dist/types/evaluator/comparison/less-than.d.ts +1 -1
- package/dist/types/evaluator/comparison/not-equals.d.ts +1 -1
- package/dist/types/evaluator/concatenation/concatenate.d.ts +1 -1
- package/dist/types/evaluator/dependency-nodes/ast-evaluation-node.d.ts +2 -2
- package/dist/types/evaluator/dependency-nodes/base-eval-node.d.ts +1 -1
- package/dist/types/evaluator/dependency-nodes/cell-value-node.d.ts +1 -1
- package/dist/types/evaluator/dependency-nodes/empty-cell-evaluation-node.d.ts +4 -4
- package/dist/types/evaluator/dependency-nodes/spill-meta-node.d.ts +1 -1
- package/dist/types/evaluator/evaluate-scalar-operator.d.ts +1 -1
- package/dist/types/evaluator/evaluation-context.d.ts +3 -3
- package/dist/types/evaluator/evaluation-error.d.ts +2 -2
- package/dist/types/evaluator/formula-evaluator.d.ts +5 -5
- package/dist/types/evaluator/range-evaluation-node.d.ts +4 -4
- package/dist/types/functions/_template/template.d.ts +1 -1
- package/dist/types/functions/array/sequence/sequence.d.ts +1 -1
- package/dist/types/functions/criteria-parser.d.ts +1 -1
- package/dist/types/functions/criteria-utils.d.ts +5 -5
- package/dist/types/functions/{index.d.ts → function-registry.d.ts} +1 -1
- package/dist/types/functions/function-utils.d.ts +5 -5
- package/dist/types/functions/information/cell/cell.d.ts +1 -1
- package/dist/types/functions/information/column/column.d.ts +1 -1
- package/dist/types/functions/information/row/row.d.ts +1 -1
- package/dist/types/functions/logical/and/and.d.ts +1 -1
- package/dist/types/functions/logical/if/if.d.ts +1 -1
- package/dist/types/functions/logical/iferror/iferror.d.ts +1 -1
- package/dist/types/functions/logical/or/or.d.ts +1 -1
- package/dist/types/functions/lookup/count/count-utils.d.ts +2 -2
- package/dist/types/functions/lookup/count/count.d.ts +1 -1
- package/dist/types/functions/lookup/count/countif.d.ts +1 -1
- package/dist/types/functions/lookup/count/countifs.d.ts +1 -1
- package/dist/types/functions/lookup/index-lookup/index-lookup.d.ts +1 -1
- package/dist/types/functions/lookup/match/match.d.ts +1 -1
- package/dist/types/functions/lookup/xlookup/xlookup.d.ts +1 -1
- package/dist/types/functions/math/average/average-utils.d.ts +2 -2
- package/dist/types/functions/math/average/average.d.ts +1 -1
- package/dist/types/functions/math/average/averageif.d.ts +1 -1
- package/dist/types/functions/math/average/averageifs.d.ts +1 -1
- package/dist/types/functions/math/ceiling/ceiling.d.ts +1 -1
- package/dist/types/functions/math/max/max-utils.d.ts +2 -2
- package/dist/types/functions/math/max/max.d.ts +1 -1
- package/dist/types/functions/math/max/maxif.d.ts +1 -1
- package/dist/types/functions/math/max/maxifs.d.ts +1 -1
- package/dist/types/functions/math/min/min-utils.d.ts +2 -2
- package/dist/types/functions/math/min/min.d.ts +1 -1
- package/dist/types/functions/math/min/minif.d.ts +1 -1
- package/dist/types/functions/math/min/minifs.d.ts +1 -1
- package/dist/types/functions/math/sum/sum.d.ts +1 -1
- package/dist/types/functions/math/sum/sumif.d.ts +1 -1
- package/dist/types/functions/math/sum/sumifs.d.ts +1 -1
- package/dist/types/functions/math/sum/summation-utils.d.ts +1 -1
- package/dist/types/functions/reference/address/address.d.ts +1 -1
- package/dist/types/functions/reference/indirect/indirect.d.ts +1 -1
- package/dist/types/functions/reference/offset/offset.d.ts +1 -1
- package/dist/types/functions/text/concatenate/concatenate.d.ts +1 -1
- package/dist/types/functions/text/exact/exact.d.ts +1 -1
- package/dist/types/functions/text/find/find.d.ts +1 -1
- package/dist/types/functions/text/left/left.d.ts +1 -1
- package/dist/types/functions/text/len/len.d.ts +1 -1
- package/dist/types/functions/text/mid/mid.d.ts +1 -1
- package/dist/types/functions/text/right/right.d.ts +1 -1
- package/dist/types/functions/text/text-helpers.d.ts +3 -3
- package/dist/types/functions/text/textjoin/textjoin.d.ts +1 -1
- package/package.json +1 -1
- package/dist/cjs/core/managers/index.cjs +0 -49
- package/dist/cjs/core/managers/index.cjs.map +0 -10
- package/dist/cjs/functions/index.cjs.map +0 -10
- package/dist/mjs/core/managers/index.mjs +0 -21
- package/dist/mjs/core/managers/index.mjs.map +0 -10
- package/dist/mjs/functions/index.mjs.map +0 -10
- package/dist/types/core/managers/index.d.ts +0 -7
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/core/managers/evaluation-manager.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { flags } from \"src/debug/flags\";\nimport { AstEvaluationNode } from \"src/evaluator/dependency-nodes/ast-evaluation-node\";\nimport { CellValueNode } from \"src/evaluator/dependency-nodes/cell-value-node\";\nimport { EvaluationContext } from \"src/evaluator/evaluation-context\";\nimport {\n EvaluationError,\n SheetNotFoundError,\n} from \"src/evaluator/evaluation-error\";\nimport { RangeEvaluationNode } from \"src/evaluator/range-evaluation-node\";\nimport { normalizeSerializedCellValue } from \"src/parser/formatter\";\nimport { FormulaEvaluator } from \"../../evaluator/formula-evaluator.cjs\";\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 TableDefinition,\n type ValueEvaluationResult,\n} from \"../types.cjs\";\nimport {\n captureEvaluationErrors,\n cellAddressToKey,\n checkRangeIntersection,\n getCellReference,\n isCellInRange,\n isRangeOneCell,\n keyToCellAddress,\n parseCellReference,\n} from \"../utils.cjs\";\nimport type { DependencyManager } from \"./dependency-manager.cjs\";\nimport type { WorkbookManager } from \"./workbook-manager.cjs\";\nimport { SpillMetaNode } from \"src/evaluator/dependency-nodes/spill-meta-node\";\nimport { EmptyCellEvaluationNode } from \"src/evaluator/dependency-nodes/empty-cell-evaluation-node\";\nimport type { TableManager } from \"./table-manager.cjs\";\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 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 evaluateEmptyCell(node: EmptyCellEvaluationNode): void {\n node.resetDirectDepsUpdated();\n\n if (node.resolved) {\n const result = node.evaluationResult;\n if (result && result.type !== \"awaiting-evaluation\") {\n return;\n }\n }\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\n evaluateRangeNode(node: RangeEvaluationNode): void {\n if (node.resolved) {\n return;\n }\n\n node.resetDirectDepsUpdated();\n\n const result = captureEvaluationErrors(node, (): EvaluateAllCellsResult => {\n node.upgradeFrontierDependencies();\n\n const evalOrder = node.getRangeEvalOrder();\n\n const results: CellInRangeResult[] = [];\n\n for (const entry of evalOrder) {\n if (entry.type === \"value\") {\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 (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 }\n\n evaluateCellNode(node: CellValueNode | SpillMetaNode): void {\n // Enable caching for resolved nodes\n if (node.resolved) {\n return;\n }\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 return;\n }\n }\n\n let content: SerializedCellValue;\n try {\n content = this.workbookManager.getSerializedCellValue(node.cellAddress);\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 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 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 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 } 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\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 return;\n }\n\n if (evaluation.type === \"value\") {\n if (node instanceof SpillMetaNode) {\n node.setEvaluationResult({\n type: \"does-not-spill\",\n });\n return;\n } else {\n node.setEvaluationResult(evaluation);\n return;\n }\n }\n\n node.setEvaluationResult(evaluation);\n }\n\n evaluateDependencyNode(dependencyKey: string): void {\n if (dependencyKey.startsWith(\"empty:\")) {\n this.evaluateEmptyCell(\n this.dependencyManager.getEmptyCellNode(dependencyKey)\n );\n return;\n }\n if (dependencyKey.startsWith(\"range:\")) {\n this.evaluateRangeNode(\n this.dependencyManager.getRangeNode(dependencyKey)\n );\n return;\n }\n if (dependencyKey.startsWith(\"cell-value:\")) {\n const node =\n this.dependencyManager.getCellValueOrEmptyCellNode(dependencyKey);\n if (node instanceof EmptyCellEvaluationNode) {\n this.evaluateEmptyCell(node);\n return;\n }\n this.evaluateCellNode(node);\n return;\n }\n if (dependencyKey.startsWith(\"ast:\")) {\n // let the evaluateCellNode handle the evaluation\n // through formulaEvaluator.evaluateNode,\n // because an AST node must be evaluated in the context of the cell it is in\n return;\n }\n if (dependencyKey.startsWith(\"spill-meta:\")) {\n const node =\n this.dependencyManager.getSpillMetaOrEmptySpillMetaNode(dependencyKey);\n if (node instanceof EmptyCellEvaluationNode) {\n this.evaluateEmptyCell(node);\n return;\n }\n this.evaluateCellNode(node);\n return;\n }\n throw new Error(\"Invalid dependency key: \" + dependencyKey);\n }\n\n /**\n * Evaluates a cell by building the evaluation order and evaluating the dependencies in order\n */\n evaluateCell(node: CellValueNode | EmptyCellEvaluationNode): void {\n if (this.isEvaluating) {\n throw new Error(\"Evaluation in progress\");\n }\n this.isEvaluating = true;\n const sheet = this.workbookManager.getSheet(node.cellAddress);\n if (!sheet) {\n this.isEvaluating = false;\n throw new SheetNotFoundError(node.cellAddress.sheetName);\n }\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 (!(node instanceof RangeEvaluationNode)) {\n if (node instanceof AstEvaluationNode) {\n node.setEvaluationResult(evaluationResult);\n } else {\n node.setEvaluationResult(evaluationResult);\n }\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.key);\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${(performance.now() - timeStart).toFixed(1)}ms | %c${percentResolved}% resolved | %c${avgDuration.toFixed(2)}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 (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 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.cjs\";\nimport { AstEvaluationNode } from \"../../evaluator/dependency-nodes/ast-evaluation-node.cjs\";\nimport { CellValueNode } from \"../../evaluator/dependency-nodes/cell-value-node.cjs\";\nimport { EvaluationContext } from \"../../evaluator/evaluation-context.cjs\";\nimport {\n EvaluationError,\n SheetNotFoundError,\n} from \"../../evaluator/evaluation-error.cjs\";\nimport { RangeEvaluationNode } from \"../../evaluator/range-evaluation-node.cjs\";\nimport { normalizeSerializedCellValue } from \"../../parser/formatter.cjs\";\nimport { FormulaEvaluator } from \"../../evaluator/formula-evaluator.cjs\";\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 TableDefinition,\n type ValueEvaluationResult,\n} from \"../types.cjs\";\nimport {\n captureEvaluationErrors,\n cellAddressToKey,\n checkRangeIntersection,\n getCellReference,\n isCellInRange,\n isRangeOneCell,\n keyToCellAddress,\n parseCellReference,\n} from \"../utils.cjs\";\nimport type { DependencyManager } from \"./dependency-manager.cjs\";\nimport type { WorkbookManager } from \"./workbook-manager.cjs\";\nimport { SpillMetaNode } from \"../../evaluator/dependency-nodes/spill-meta-node.cjs\";\nimport { EmptyCellEvaluationNode } from \"../../evaluator/dependency-nodes/empty-cell-evaluation-node.cjs\";\nimport type { TableManager } from \"./table-manager.cjs\";\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 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 evaluateEmptyCell(node: EmptyCellEvaluationNode): void {\n node.resetDirectDepsUpdated();\n\n if (node.resolved) {\n const result = node.evaluationResult;\n if (result && result.type !== \"awaiting-evaluation\") {\n return;\n }\n }\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\n evaluateRangeNode(node: RangeEvaluationNode): void {\n if (node.resolved) {\n return;\n }\n\n node.resetDirectDepsUpdated();\n\n const result = captureEvaluationErrors(node, (): EvaluateAllCellsResult => {\n node.upgradeFrontierDependencies();\n\n const evalOrder = node.getRangeEvalOrder();\n\n const results: CellInRangeResult[] = [];\n\n for (const entry of evalOrder) {\n if (entry.type === \"value\") {\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 (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 }\n\n evaluateCellNode(node: CellValueNode | SpillMetaNode): void {\n // Enable caching for resolved nodes\n if (node.resolved) {\n return;\n }\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 return;\n }\n }\n\n let content: SerializedCellValue;\n try {\n content = this.workbookManager.getSerializedCellValue(node.cellAddress);\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 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 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 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 } 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\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 return;\n }\n\n if (evaluation.type === \"value\") {\n if (node instanceof SpillMetaNode) {\n node.setEvaluationResult({\n type: \"does-not-spill\",\n });\n return;\n } else {\n node.setEvaluationResult(evaluation);\n return;\n }\n }\n\n node.setEvaluationResult(evaluation);\n }\n\n evaluateDependencyNode(dependencyKey: string): void {\n if (dependencyKey.startsWith(\"empty:\")) {\n this.evaluateEmptyCell(\n this.dependencyManager.getEmptyCellNode(dependencyKey)\n );\n return;\n }\n if (dependencyKey.startsWith(\"range:\")) {\n this.evaluateRangeNode(\n this.dependencyManager.getRangeNode(dependencyKey)\n );\n return;\n }\n if (dependencyKey.startsWith(\"cell-value:\")) {\n const node =\n this.dependencyManager.getCellValueOrEmptyCellNode(dependencyKey);\n if (node instanceof EmptyCellEvaluationNode) {\n this.evaluateEmptyCell(node);\n return;\n }\n this.evaluateCellNode(node);\n return;\n }\n if (dependencyKey.startsWith(\"ast:\")) {\n // let the evaluateCellNode handle the evaluation\n // through formulaEvaluator.evaluateNode,\n // because an AST node must be evaluated in the context of the cell it is in\n return;\n }\n if (dependencyKey.startsWith(\"spill-meta:\")) {\n const node =\n this.dependencyManager.getSpillMetaOrEmptySpillMetaNode(dependencyKey);\n if (node instanceof EmptyCellEvaluationNode) {\n this.evaluateEmptyCell(node);\n return;\n }\n this.evaluateCellNode(node);\n return;\n }\n throw new Error(\"Invalid dependency key: \" + dependencyKey);\n }\n\n /**\n * Evaluates a cell by building the evaluation order and evaluating the dependencies in order\n */\n evaluateCell(node: CellValueNode | EmptyCellEvaluationNode): void {\n if (this.isEvaluating) {\n throw new Error(\"Evaluation in progress\");\n }\n this.isEvaluating = true;\n const sheet = this.workbookManager.getSheet(node.cellAddress);\n if (!sheet) {\n this.isEvaluating = false;\n throw new SheetNotFoundError(node.cellAddress.sheetName);\n }\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 (!(node instanceof RangeEvaluationNode)) {\n if (node instanceof AstEvaluationNode) {\n node.setEvaluationResult(evaluationResult);\n } else {\n node.setEvaluationResult(evaluationResult);\n }\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.key);\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${(performance.now() - timeStart).toFixed(1)}ms | %c${percentResolved}% resolved | %c${avgDuration.toFixed(2)}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 (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 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 //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ACE,YAAY,YAAY,UAAU,MAAM,OACxC,YAAY,YAAY,OAAO,SAC/B,YAAY,YAAY,UAAU,MAAM,OACxC,YAAY,YAAY,OAAO,OAC/B;AAAA,UACA,IACE,8CAA6B,MAAM,QAAQ,IAAI,GAAG,CAAC,MAAM,WACzD;AAAA,YAEA,OAAO;AAAA,UACT;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IAEA,OAAO;AAAA;AAAA,EAGT,uBAAuB,CACrB,aACoC;AAAA,IACpC,IAAI,KAAK,cAAc;AAAA,MACrB,MAAM,IAAI,MAAM,wBAAwB;AAAA,IAC1C;AAAA,IAEA,MAAM,UAAU,8BAAiB,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,2CAAmB,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": "
|
|
8
|
+
"debugId": "3C7FBADCCEDC262664756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/core/managers/frontier-dependency-manager.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { CellValueNode } from \"
|
|
5
|
+
"import { CellValueNode } from \"../../evaluator/dependency-nodes/cell-value-node.cjs\";\nimport type { CellAddress, CellInRangeResult, RangeAddress } from \"../types.cjs\";\nimport { cellAddressToKey, checkRangeIntersection } from \"../utils.cjs\";\nimport type { DependencyManager } from \"./dependency-manager.cjs\";\nimport type { DependencyNode } from \"./dependency-node.cjs\";\nimport type { WorkbookManager } from \"./workbook-manager.cjs\";\nimport type { SpillMetaNode } from \"../../evaluator/dependency-nodes/spill-meta-node.cjs\";\n\ntype EvalOrderEntry =\n | {\n type: \"value\";\n address: CellAddress;\n node: CellValueNode;\n }\n | {\n type: \"empty_cell\";\n address: CellAddress;\n candidates: SpillMetaNode[];\n }\n | {\n type: \"empty_range\";\n address: RangeAddress;\n candidates: SpillMetaNode[];\n };\n\nexport class FrontierDependencyManager {\n private evalOrder: EvalOrderEntry[];\n private _resolved: boolean = false;\n private _directDepsUpdated: boolean;\n\n constructor(\n private frontierRange: RangeAddress,\n protected workbookManager: WorkbookManager,\n protected evaluationManager: DependencyManager\n ) {\n const addressToSpillMetaNode = (address: CellAddress) => {\n const node = this.evaluationManager.getSpillMetaNode(\n cellAddressToKey(address).replace(/^[^:]+:/, \"spill-meta:\")\n );\n return node;\n };\n // todo maybe pass in lookupOrder\n let directDepsUpdated = false;\n this.evalOrder = this.workbookManager\n .buildRangeEvalOrder(\"col-major\", this.frontierRange)\n .map((entry): EvalOrderEntry => {\n if (entry.type === \"value\") {\n const addressToNode = (address: CellAddress) => {\n const node = this.evaluationManager.getCellValueNode(\n cellAddressToKey(address)\n );\n return node;\n };\n return {\n type: \"value\",\n address: entry.address,\n node: addressToNode(entry.address),\n };\n } else if (entry.type === \"empty_cell\") {\n return {\n type: \"empty_cell\",\n address: entry.address,\n candidates: entry.candidates.map(addressToSpillMetaNode),\n };\n } else if (entry.type === \"empty_range\") {\n return {\n type: \"empty_range\",\n address: entry.address,\n candidates: entry.candidates.map(addressToSpillMetaNode),\n };\n }\n throw new Error(\"Invalid entry type: \" + (entry as any).type);\n });\n for (const entry of this.evalOrder) {\n if (entry.type === \"empty_cell\" || entry.type === \"empty_range\") {\n for (const candidate of entry.candidates) {\n this._frontierDependencies.add(candidate);\n directDepsUpdated = true;\n }\n } else if (entry.type === \"value\") {\n this.addDependency(entry.node);\n directDepsUpdated = true;\n }\n }\n this._directDepsUpdated = directDepsUpdated;\n }\n\n /**\n * frontierDependencies is the set of dependency node keys that could spill values onto the target range (if evaluationResult is spilled-values)\n * Key is from cellAddressToKey\n *\n * soft edge dependencies, which can not cause cycles in the dependency graph\n */\n private _frontierDependencies: Set<SpillMetaNode> = new Set();\n\n /**\n * discardedFrontierDependencies is the set of dependency node keys that were discarded as frontier dependencies because\n * they they do not produce spilled values that spill onto the target range\n * Key is from cellAddressToKey\n */\n private _discardedFrontierDependencies: Set<SpillMetaNode> = new Set();\n\n /**\n * hard edge dependencies, which can cause cycles in the dependency graph\n */\n private _dependencies: Set<DependencyNode> = new Set();\n\n /**\n * cache, should maybe be stored in the cache manager\n */\n get iterateAllCells(): undefined | Iterable<CellInRangeResult> {\n return undefined;\n }\n\n public getRangeEvalOrder() {\n return this.evalOrder;\n }\n\n public get frontierDependencies() {\n return this._frontierDependencies\n .difference(this._discardedFrontierDependencies)\n .difference(this._dependencies);\n }\n\n public get discardedFrontierDependencies() {\n return this._discardedFrontierDependencies;\n }\n\n public maybeDiscardFrontierDependency(dependency: SpillMetaNode) {\n if (!this._resolved) {\n return;\n }\n if (this._discardedFrontierDependencies.has(dependency)) {\n return;\n }\n this._directDepsUpdated = true;\n this._discardedFrontierDependencies.add(dependency);\n }\n\n public maybeUpgradeFrontierDependency(dependency: SpillMetaNode) {\n if (!this._resolved) {\n return;\n }\n if (this._dependencies.has(dependency)) {\n return;\n }\n this._directDepsUpdated = true;\n this._dependencies.add(dependency);\n }\n\n /**\n * a range is considered resolved when the dependencies has been established\n */\n public resolve() {\n if (this.canResolve()) {\n this._resolved = true;\n }\n }\n\n public canResolve() {\n return !this._directDepsUpdated && this.frontierDependencies.size === 0;\n }\n\n public get resolved() {\n return this._resolved;\n }\n\n public get directDepsUpdated() {\n return this._directDepsUpdated;\n }\n\n public resetDirectDepsUpdated() {\n if (this._resolved) {\n return;\n }\n\n this._directDepsUpdated = false;\n }\n\n public getDependencies() {\n return this._dependencies;\n }\n\n public getFrontierDependencies() {\n return this.frontierDependencies;\n }\n\n public getAllDependencies() {\n return this._dependencies.union(this._frontierDependencies);\n }\n\n public getDiscardedFrontierDependencies() {\n return this.discardedFrontierDependencies;\n }\n\n public addDependency(dependency: DependencyNode) {\n this._dependencies.add(dependency);\n }\n\n public upgradeFrontierDependencies() {\n // todo can be optimized to not generate the frontier candidates every time\n // we can cache the frontier candidates for the current cell\n const frontierCandidates: SpillMetaNode[] = Array.from(\n this.frontierDependencies\n );\n\n for (const candidateNode of frontierCandidates) {\n const result = candidateNode.evaluationResult;\n\n // upgrade or downgrade frontier dependency\n if (result.type === \"spilled-values\") {\n const spillArea = result.spillArea(candidateNode.cellAddress);\n const intersects = checkRangeIntersection(\n this.frontierRange.range,\n spillArea\n );\n if (intersects) {\n this.maybeUpgradeFrontierDependency(candidateNode); // upgraded!\n } else {\n this.maybeDiscardFrontierDependency(candidateNode); // downgraded!\n }\n } else {\n this.maybeDiscardFrontierDependency(candidateNode); // downgraded!\n }\n }\n }\n}\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEyD,IAAzD;AAAA;AAuBO,MAAM,0BAA0B;AAAA,EAM3B;AAAA,EACE;AAAA,EACA;AAAA,EAPJ;AAAA,EACA,YAAqB;AAAA,EACrB;AAAA,EAER,WAAW,CACD,eACE,iBACA,mBACV;AAAA,IAHQ;AAAA,IACE;AAAA,IACA;AAAA,IAEV,MAAM,yBAAyB,CAAC,YAAyB;AAAA,MACvD,MAAM,OAAO,KAAK,kBAAkB,iBAClC,8BAAiB,OAAO,EAAE,QAAQ,WAAW,aAAa,CAC5D;AAAA,MACA,OAAO;AAAA;AAAA,IAGT,IAAI,oBAAoB;AAAA,IACxB,KAAK,YAAY,KAAK,gBACnB,oBAAoB,aAAa,KAAK,aAAa,EACnD,IAAI,CAAC,UAA0B;AAAA,MAC9B,IAAI,MAAM,SAAS,SAAS;AAAA,QAC1B,MAAM,gBAAgB,CAAC,YAAyB;AA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,KAAK,cAAc,IAAI,UAAU;AAAA;AAAA,EAG5B,2BAA2B,GAAG;AAAA,IAGnC,MAAM,qBAAsC,MAAM,KAChD,KAAK,oBACP;AAAA,IAEA,WAAW,iBAAiB,oBAAoB;AAAA,MAC9C,MAAM,SAAS,cAAc;AAAA,MAG7B,IAAI,OAAO,SAAS,kBAAkB;AAAA,QACpC,MAAM,YAAY,OAAO,UAAU,cAAc,WAAW;AAAA,QAC5D,MAAM,aAAa,oCACjB,KAAK,cAAc,OACnB,SACF;AAAA,QACA,IAAI,YAAY;AAAA,UACd,KAAK,+BAA+B,aAAa;AAAA,QACnD,EAAO;AAAA,UACL,KAAK,+BAA+B,aAAa;AAAA;AAAA,MAErD,EAAO;AAAA,QACL,KAAK,+BAA+B,aAAa;AAAA;AAAA,IAErD;AAAA;AAEJ;",
|
|
8
8
|
"debugId": "D495EAC5BB8789E664756E2164756E21",
|
|
@@ -32,13 +32,13 @@ __export(exports_isDependencyNode, {
|
|
|
32
32
|
isDependencyNode: () => isDependencyNode
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(exports_isDependencyNode);
|
|
35
|
-
var import_ast_evaluation_node = require("
|
|
36
|
-
var import_cell_value_node = require("
|
|
37
|
-
var import_empty_cell_evaluation_node = require("
|
|
38
|
-
var import_spill_meta_node = require("
|
|
39
|
-
var import_range_evaluation_node = require("
|
|
35
|
+
var import_ast_evaluation_node = require("../../evaluator/dependency-nodes/ast-evaluation-node.cjs");
|
|
36
|
+
var import_cell_value_node = require("../../evaluator/dependency-nodes/cell-value-node.cjs");
|
|
37
|
+
var import_empty_cell_evaluation_node = require("../../evaluator/dependency-nodes/empty-cell-evaluation-node.cjs");
|
|
38
|
+
var import_spill_meta_node = require("../../evaluator/dependency-nodes/spill-meta-node.cjs");
|
|
39
|
+
var import_range_evaluation_node = require("../../evaluator/range-evaluation-node.cjs");
|
|
40
40
|
function isDependencyNode(node) {
|
|
41
41
|
return node instanceof import_cell_value_node.CellValueNode || node instanceof import_range_evaluation_node.RangeEvaluationNode || node instanceof import_empty_cell_evaluation_node.EmptyCellEvaluationNode || node instanceof import_ast_evaluation_node.AstEvaluationNode || node instanceof import_spill_meta_node.SpillMetaNode;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
//# debugId=
|
|
44
|
+
//# debugId=98941B9B5A8FAEED64756E2164756E21
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/core/managers/isDependencyNode.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { AstEvaluationNode } from \"
|
|
5
|
+
"import { AstEvaluationNode } from \"../../evaluator/dependency-nodes/ast-evaluation-node.cjs\";\nimport { CellValueNode } from \"../../evaluator/dependency-nodes/cell-value-node.cjs\";\nimport { EmptyCellEvaluationNode } from \"../../evaluator/dependency-nodes/empty-cell-evaluation-node.cjs\";\nimport { SpillMetaNode } from \"../../evaluator/dependency-nodes/spill-meta-node.cjs\";\nimport { RangeEvaluationNode } from \"../../evaluator/range-evaluation-node.cjs\";\nimport type { DependencyNode } from \"./dependency-node.cjs\";\n\n\nexport function isDependencyNode(node: any): node is DependencyNode {\n return (\n node instanceof CellValueNode ||\n node instanceof RangeEvaluationNode ||\n node instanceof EmptyCellEvaluationNode ||\n node instanceof AstEvaluationNode ||\n node instanceof SpillMetaNode\n );\n}\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAkC,IAAlC;AAC8B,IAA9B;AACwC,IAAxC;AAC8B,IAA9B;AACoC,IAApC;AAIO,SAAS,gBAAgB,CAAC,MAAmC;AAAA,EAClE,OACE,gBAAgB,wCAChB,gBAAgB,oDAChB,gBAAgB,6DAChB,gBAAgB,gDAChB,gBAAgB;AAAA;",
|
|
8
|
-
"debugId": "
|
|
8
|
+
"debugId": "98941B9B5A8FAEED64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/core/managers/named-expression-manager.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import type { NamedExpression } from \"../types.cjs\";\nimport { renameNamedExpressionInFormula } from \"../named-expression-renamer.cjs\";\nimport type { EventManager } from \"./event-manager.cjs\";\nimport type { NamedExpressionNode } from \"src/parser/ast\";\nimport type { EvaluationContext } from \"src/evaluator/evaluation-context\";\n\nexport class NamedExpressionManager {\n sheetExpressions: Map<string, Map<string, Map<string, NamedExpression>>> =\n new Map();\n workbookExpressions: Map<string, Map<string, NamedExpression>> = new Map();\n globalExpressions: Map<string, NamedExpression> = new Map();\n\n addNamedExpression({\n expression,\n expressionName,\n sheetName,\n workbookName,\n }: {\n expression: string;\n expressionName: string;\n sheetName?: string;\n workbookName?: string;\n }): void {\n const namedExpression: NamedExpression = {\n name: expressionName,\n expression,\n };\n\n if (sheetName && !workbookName) {\n throw new Error(\"Missing workbookName\");\n }\n\n if (sheetName && workbookName) {\n let wbLevel = this.sheetExpressions.get(workbookName);\n if (!wbLevel) {\n wbLevel = new Map();\n this.sheetExpressions.set(workbookName, wbLevel);\n }\n\n let sheetLevel = wbLevel.get(sheetName);\n if (!sheetLevel) {\n sheetLevel = new Map();\n wbLevel.set(sheetName, sheetLevel);\n }\n\n sheetLevel.set(expressionName, namedExpression);\n } else if (workbookName) {\n let workbookNamedExpressions = this.workbookExpressions.get(workbookName);\n if (!workbookNamedExpressions) {\n workbookNamedExpressions = new Map();\n this.workbookExpressions.set(workbookName, workbookNamedExpressions);\n }\n\n workbookNamedExpressions.set(expressionName, namedExpression);\n } else {\n this.globalExpressions.set(expressionName, namedExpression);\n }\n }\n\n removeNamedExpression({\n expressionName,\n sheetName,\n workbookName,\n }: {\n expressionName: string;\n sheetName?: string;\n workbookName?: string;\n }): boolean {\n let found = false;\n\n if (sheetName && !workbookName) {\n throw new Error(\"Missing workbookName\");\n }\n\n if (sheetName && workbookName) {\n const wbLevel = this.sheetExpressions.get(workbookName);\n if (wbLevel) {\n const sheetLevel = wbLevel.get(sheetName);\n if (sheetLevel) {\n found = sheetLevel.delete(expressionName);\n }\n }\n } else if (workbookName) {\n const workbookNamedExpressions =\n this.workbookExpressions.get(workbookName);\n if (workbookNamedExpressions) {\n found = workbookNamedExpressions.delete(expressionName);\n }\n } else {\n found = this.globalExpressions.delete(expressionName);\n }\n\n return found;\n }\n\n updateNamedExpression({\n expression,\n expressionName,\n sheetName,\n workbookName,\n }: {\n expression: string;\n expressionName: string;\n sheetName?: string;\n workbookName?: string;\n }): void {\n // Check if the named expression exists\n let exists = false;\n\n if (sheetName && !workbookName) {\n throw new Error(\"Missing workbookName\");\n }\n\n if (sheetName && workbookName) {\n const wbLevel = this.sheetExpressions.get(workbookName);\n if (wbLevel) {\n const sheetLevel = wbLevel.get(sheetName);\n if (sheetLevel) {\n exists = sheetLevel.has(expressionName);\n }\n }\n } else if (workbookName) {\n const workbookNamedExpressions =\n this.workbookExpressions.get(workbookName);\n if (workbookNamedExpressions) {\n exists = workbookNamedExpressions.has(expressionName);\n }\n } else {\n exists = this.globalExpressions.has(expressionName);\n }\n\n if (!exists) {\n throw new Error(`Named expression '${expressionName}' does not exist`);\n }\n\n // Update is the same as add for existing expressions\n this.addNamedExpression({\n expression,\n expressionName,\n sheetName,\n workbookName,\n });\n }\n\n renameNamedExpression({\n expressionName,\n sheetName,\n workbookName,\n newName,\n }: {\n expressionName: string;\n sheetName?: string;\n workbookName?: string;\n newName: string;\n }): boolean {\n // Check if the named expression exists\n let targetMap: Map<string, NamedExpression> | undefined;\n if (sheetName && !workbookName) {\n throw new Error(\"Missing workbookName\");\n }\n\n let isGlobal = false;\n\n if (sheetName && workbookName) {\n const wbLevel = this.sheetExpressions.get(workbookName);\n if (wbLevel) {\n const sheetLevel = wbLevel.get(sheetName);\n if (sheetLevel) {\n targetMap = sheetLevel;\n }\n }\n } else if (workbookName) {\n targetMap = this.workbookExpressions.get(workbookName);\n } else {\n targetMap = this.globalExpressions;\n isGlobal = true;\n }\n\n if (!targetMap || !targetMap.has(expressionName)) {\n throw new Error(`Named expression '${expressionName}' does not exist`);\n }\n\n // Check if the new name already exists\n if (targetMap.has(newName)) {\n throw new Error(`Named expression '${newName}' already exists`);\n }\n\n // Get the expression to rename\n const namedExpression = targetMap.get(expressionName)!;\n\n // Update the name and re-add with new name\n const updatedExpression = { ...namedExpression, name: newName };\n targetMap.set(newName, updatedExpression);\n targetMap.delete(expressionName);\n\n return true;\n }\n\n updateAllNamedExpressions(updateCallback: (formula: string) => string): void {\n const update = (map: Map<string, NamedExpression>) => {\n map.forEach((namedExpr, name) => {\n // Don't update the expression we're renaming\n const updatedExpression = updateCallback(namedExpr.expression);\n\n if (updatedExpression !== namedExpr.expression) {\n map.set(name, {\n ...namedExpr,\n expression: updatedExpression,\n });\n }\n });\n };\n\n update(this.globalExpressions);\n\n this.workbookExpressions.forEach((workbookLevel) => {\n update(workbookLevel);\n });\n\n this.sheetExpressions.forEach((wbLevel) => {\n wbLevel.forEach((sheetLevel) => {\n update(sheetLevel);\n });\n });\n }\n\n /**\n * Replace all named expressions\n */\n setNamedExpressions(\n opts: (\n | {\n type: \"global\";\n }\n | {\n type: \"sheet\";\n sheetName: string;\n workbookName: string;\n }\n | {\n type: \"workbook\";\n workbookName: string;\n }\n ) & {\n expressions: Map<string, NamedExpression>;\n }\n ) {\n let map: Map<string, NamedExpression> | undefined;\n\n if (opts.type === \"sheet\") {\n map = this.sheetExpressions.get(opts.workbookName)?.get(opts.sheetName);\n } else if (opts.type === \"workbook\") {\n map = this.workbookExpressions.get(opts.workbookName);\n } else {\n map = this.globalExpressions;\n }\n\n if (!map) {\n throw new Error(\"Invalid options: \" + JSON.stringify(opts));\n }\n\n map.clear();\n\n opts.expressions.forEach((expression, name) => {\n map.set(name, expression);\n });\n }\n\n getNamedExpression(depNode: {\n name: string;\n scope:\n | {\n type: \"global\";\n }\n | {\n type: \"workbook\";\n workbookName: string;\n }\n | {\n type: \"sheet\";\n workbookName: string;\n sheetName: string;\n };\n }): NamedExpression | undefined {\n if (depNode.scope.type === \"global\") {\n return this.globalExpressions.get(depNode.name);\n }\n if (depNode.scope.type === \"workbook\") {\n return this.workbookExpressions\n .get(depNode.scope.workbookName)\n ?.get(depNode.name);\n }\n if (depNode.scope.type === \"sheet\") {\n return this.sheetExpressions\n .get(depNode.scope.workbookName)\n ?.get(depNode.scope.sheetName)\n ?.get(depNode.name);\n }\n return undefined;\n }\n\n resolveNamedExpression(\n namedExpression: Pick<\n NamedExpressionNode,\n \"name\" | \"sheetName\" | \"workbookName\"\n >,\n context: EvaluationContext\n ): string | undefined {\n // scenario 1: no sheetName nor workbookName\n if (!namedExpression.sheetName && !namedExpression.workbookName) {\n /**\n * the result of this formula will differ based on in which sheet and workbook we are\n * evaluating it in.\n */\n context.addContextDependency(\"sheet\", \"workbook\");\n\n // step 1, check if there is a named expression in the sheet scope\n const expression = this.sheetExpressions\n .get(context.cellAddress.workbookName)\n ?.get(context.cellAddress.sheetName)\n ?.get(namedExpression.name);\n if (expression) {\n return expression.expression;\n } else {\n // step 2, check if there is a named expression in the workbook scope\n const expression = this.workbookExpressions\n .get(context.cellAddress.workbookName)\n ?.get(namedExpression.name);\n if (expression) {\n return expression.expression;\n } else {\n // step 3, check if there is a named expression in the global scope\n const expression = this.globalExpressions.get(namedExpression.name);\n if (expression) {\n return expression.expression;\n }\n }\n }\n }\n\n // scenario 2: we only have a workbookName - a bit weird, but could happen\n if (namedExpression.workbookName && !namedExpression.sheetName) {\n // special case: if workbook is the current workbook, we should just resolve the named expression according to scenario 1\n if (\n namedExpression.workbookName ===\n context.cellAddress.workbookName\n ) {\n return this.resolveNamedExpression(\n {\n name: namedExpression.name,\n },\n context\n );\n }\n\n const expression = this.workbookExpressions\n .get(namedExpression.workbookName)\n ?.get(namedExpression.name);\n if (expression) {\n // step 1, check if there is a named expression in the workbook scope\n return expression.expression;\n } else {\n // step 2, check if there is a named expression in the global scope\n const expression = this.globalExpressions.get(namedExpression.name);\n if (expression) {\n return expression.expression;\n }\n }\n }\n\n // scenario 3: we only have a sheetName\n if (namedExpression.sheetName && !namedExpression.workbookName) {\n const expression = this.sheetExpressions\n .get(context.cellAddress.workbookName)\n ?.get(namedExpression.sheetName)\n ?.get(namedExpression.name);\n /**\n * the result of this formula will differ based on in which workbook we are\n * evaluating it in.\n */\n context.addContextDependency(\"workbook\");\n if (expression) {\n // step 1, check if there is a named expression in the current workbook against the sheet name\n return expression.expression;\n } else {\n // step 2, check if there is a named expression in the current workbook has a workbook scoped named expression\n const expression = this.workbookExpressions\n .get(context.cellAddress.workbookName)\n ?.get(namedExpression.name);\n if (expression) {\n return expression.expression;\n } else {\n // step 3, check if there is a named expression in the global scope\n const expression = this.globalExpressions.get(namedExpression.name);\n if (expression) {\n return expression.expression;\n }\n }\n }\n }\n\n // scenario 4: we have both sheetName and workbookName\n if (namedExpression.sheetName && namedExpression.workbookName) {\n const expression = this.sheetExpressions\n .get(namedExpression.workbookName)\n ?.get(namedExpression.sheetName)\n ?.get(namedExpression.name);\n if (expression) {\n // step 1, check if there is a named expression the the sheet scope\n return expression.expression;\n } else {\n // step 2, check if there is a named expression in the workbook scope\n const expression = this.workbookExpressions\n .get(namedExpression.workbookName)\n ?.get(namedExpression.name);\n if (expression) {\n return expression.expression;\n } else {\n // step 3, check if there is a named expression in the global scope\n const expression = this.globalExpressions.get(namedExpression.name);\n if (expression) {\n return expression.expression;\n }\n }\n }\n }\n }\n\n getNamedExpressions() {\n return {\n sheetExpressions: this.sheetExpressions,\n workbookExpressions: this.workbookExpressions,\n globalExpressions: this.globalExpressions,\n };\n }\n\n resetNamedExpressions(\n namedExpressions: ReturnType<typeof this.getNamedExpressions>\n ) {\n this.setNamedExpressions({\n type: \"global\",\n expressions: namedExpressions.globalExpressions,\n });\n\n namedExpressions.workbookExpressions.forEach(\n (workbookExpressions, workbookName) => {\n this.setNamedExpressions({\n type: \"workbook\",\n expressions: workbookExpressions,\n workbookName,\n });\n }\n );\n\n namedExpressions.sheetExpressions.forEach(\n (sheetExpressions, workbookName) => {\n sheetExpressions.forEach((sheetExpression, sheetName) => {\n this.setNamedExpressions({\n type: \"sheet\",\n expressions: sheetExpression,\n sheetName,\n workbookName,\n });\n });\n }\n );\n }\n\n /**\n * When adding a sheet, we need to initialize the new maps\n */\n addSheet(opts: { workbookName: string; sheetName: string }) {\n const wbLevel = this.sheetExpressions.get(opts.workbookName);\n if (!wbLevel) {\n throw new Error(\"Workbook not found\");\n }\n const sheetLevel = wbLevel.get(opts.sheetName);\n if (sheetLevel) {\n throw new Error(\"Sheet already exists\");\n }\n wbLevel.set(opts.sheetName, new Map());\n }\n\n /**\n * When adding a workbook, we need to initialize the new maps\n */\n addWorkbook(workbookName: string) {\n this.sheetExpressions.set(workbookName, new Map());\n this.workbookExpressions.set(workbookName, new Map());\n }\n\n /**\n * When removing a workbook, we need to remove the workbook from the sheet level\n */\n removeWorkbook(workbookName: string) {\n this.sheetExpressions.delete(workbookName);\n this.workbookExpressions.delete(workbookName);\n }\n\n /**\n * When removing a sheet, we need to remove the sheet from the workbook level\n */\n removeSheet(opts: { workbookName: string; sheetName: string }) {\n const wbLevel = this.sheetExpressions.get(opts.workbookName);\n if (!wbLevel) {\n throw new Error(\"Workbook not found\");\n }\n wbLevel.delete(opts.sheetName);\n }\n\n /**\n * Rename a sheet's named expressions, mainly used when renaming a sheet\n */\n renameSheet(options: {\n sheetName: string;\n newSheetName: string;\n workbookName: string;\n }): void {\n const wbLevel = this.sheetExpressions.get(options.workbookName);\n if (!wbLevel) {\n throw new Error(\"Workbook not found\");\n }\n const sheetLevel = wbLevel.get(options.sheetName);\n if (!sheetLevel) {\n throw new Error(\"Sheet not found\");\n }\n wbLevel.set(options.newSheetName, sheetLevel);\n wbLevel.delete(options.sheetName);\n }\n\n renameWorkbook(opts: { workbookName: string; newWorkbookName: string }) {\n const wbLevel = this.sheetExpressions.get(opts.workbookName);\n if (!wbLevel) {\n throw new Error(\"Workbook not found\");\n }\n this.sheetExpressions.set(opts.newWorkbookName, wbLevel);\n this.sheetExpressions.delete(opts.workbookName);\n\n const wbScopedExpressions = this.workbookExpressions.get(opts.workbookName);\n if (!wbScopedExpressions) {\n throw new Error(\"Workbook not found\");\n }\n this.workbookExpressions.set(opts.newWorkbookName, wbScopedExpressions);\n this.workbookExpressions.delete(opts.workbookName);\n }\n}\n"
|
|
5
|
+
"import type { NamedExpression } from \"../types.cjs\";\nimport { renameNamedExpressionInFormula } from \"../named-expression-renamer.cjs\";\nimport type { EventManager } from \"./event-manager.cjs\";\nimport type { NamedExpressionNode } from \"../../parser/ast.cjs\";\nimport type { EvaluationContext } from \"../../evaluator/evaluation-context.cjs\";\n\nexport class NamedExpressionManager {\n sheetExpressions: Map<string, Map<string, Map<string, NamedExpression>>> =\n new Map();\n workbookExpressions: Map<string, Map<string, NamedExpression>> = new Map();\n globalExpressions: Map<string, NamedExpression> = new Map();\n\n addNamedExpression({\n expression,\n expressionName,\n sheetName,\n workbookName,\n }: {\n expression: string;\n expressionName: string;\n sheetName?: string;\n workbookName?: string;\n }): void {\n const namedExpression: NamedExpression = {\n name: expressionName,\n expression,\n };\n\n if (sheetName && !workbookName) {\n throw new Error(\"Missing workbookName\");\n }\n\n if (sheetName && workbookName) {\n let wbLevel = this.sheetExpressions.get(workbookName);\n if (!wbLevel) {\n wbLevel = new Map();\n this.sheetExpressions.set(workbookName, wbLevel);\n }\n\n let sheetLevel = wbLevel.get(sheetName);\n if (!sheetLevel) {\n sheetLevel = new Map();\n wbLevel.set(sheetName, sheetLevel);\n }\n\n sheetLevel.set(expressionName, namedExpression);\n } else if (workbookName) {\n let workbookNamedExpressions = this.workbookExpressions.get(workbookName);\n if (!workbookNamedExpressions) {\n workbookNamedExpressions = new Map();\n this.workbookExpressions.set(workbookName, workbookNamedExpressions);\n }\n\n workbookNamedExpressions.set(expressionName, namedExpression);\n } else {\n this.globalExpressions.set(expressionName, namedExpression);\n }\n }\n\n removeNamedExpression({\n expressionName,\n sheetName,\n workbookName,\n }: {\n expressionName: string;\n sheetName?: string;\n workbookName?: string;\n }): boolean {\n let found = false;\n\n if (sheetName && !workbookName) {\n throw new Error(\"Missing workbookName\");\n }\n\n if (sheetName && workbookName) {\n const wbLevel = this.sheetExpressions.get(workbookName);\n if (wbLevel) {\n const sheetLevel = wbLevel.get(sheetName);\n if (sheetLevel) {\n found = sheetLevel.delete(expressionName);\n }\n }\n } else if (workbookName) {\n const workbookNamedExpressions =\n this.workbookExpressions.get(workbookName);\n if (workbookNamedExpressions) {\n found = workbookNamedExpressions.delete(expressionName);\n }\n } else {\n found = this.globalExpressions.delete(expressionName);\n }\n\n return found;\n }\n\n updateNamedExpression({\n expression,\n expressionName,\n sheetName,\n workbookName,\n }: {\n expression: string;\n expressionName: string;\n sheetName?: string;\n workbookName?: string;\n }): void {\n // Check if the named expression exists\n let exists = false;\n\n if (sheetName && !workbookName) {\n throw new Error(\"Missing workbookName\");\n }\n\n if (sheetName && workbookName) {\n const wbLevel = this.sheetExpressions.get(workbookName);\n if (wbLevel) {\n const sheetLevel = wbLevel.get(sheetName);\n if (sheetLevel) {\n exists = sheetLevel.has(expressionName);\n }\n }\n } else if (workbookName) {\n const workbookNamedExpressions =\n this.workbookExpressions.get(workbookName);\n if (workbookNamedExpressions) {\n exists = workbookNamedExpressions.has(expressionName);\n }\n } else {\n exists = this.globalExpressions.has(expressionName);\n }\n\n if (!exists) {\n throw new Error(`Named expression '${expressionName}' does not exist`);\n }\n\n // Update is the same as add for existing expressions\n this.addNamedExpression({\n expression,\n expressionName,\n sheetName,\n workbookName,\n });\n }\n\n renameNamedExpression({\n expressionName,\n sheetName,\n workbookName,\n newName,\n }: {\n expressionName: string;\n sheetName?: string;\n workbookName?: string;\n newName: string;\n }): boolean {\n // Check if the named expression exists\n let targetMap: Map<string, NamedExpression> | undefined;\n if (sheetName && !workbookName) {\n throw new Error(\"Missing workbookName\");\n }\n\n let isGlobal = false;\n\n if (sheetName && workbookName) {\n const wbLevel = this.sheetExpressions.get(workbookName);\n if (wbLevel) {\n const sheetLevel = wbLevel.get(sheetName);\n if (sheetLevel) {\n targetMap = sheetLevel;\n }\n }\n } else if (workbookName) {\n targetMap = this.workbookExpressions.get(workbookName);\n } else {\n targetMap = this.globalExpressions;\n isGlobal = true;\n }\n\n if (!targetMap || !targetMap.has(expressionName)) {\n throw new Error(`Named expression '${expressionName}' does not exist`);\n }\n\n // Check if the new name already exists\n if (targetMap.has(newName)) {\n throw new Error(`Named expression '${newName}' already exists`);\n }\n\n // Get the expression to rename\n const namedExpression = targetMap.get(expressionName)!;\n\n // Update the name and re-add with new name\n const updatedExpression = { ...namedExpression, name: newName };\n targetMap.set(newName, updatedExpression);\n targetMap.delete(expressionName);\n\n return true;\n }\n\n updateAllNamedExpressions(updateCallback: (formula: string) => string): void {\n const update = (map: Map<string, NamedExpression>) => {\n map.forEach((namedExpr, name) => {\n // Don't update the expression we're renaming\n const updatedExpression = updateCallback(namedExpr.expression);\n\n if (updatedExpression !== namedExpr.expression) {\n map.set(name, {\n ...namedExpr,\n expression: updatedExpression,\n });\n }\n });\n };\n\n update(this.globalExpressions);\n\n this.workbookExpressions.forEach((workbookLevel) => {\n update(workbookLevel);\n });\n\n this.sheetExpressions.forEach((wbLevel) => {\n wbLevel.forEach((sheetLevel) => {\n update(sheetLevel);\n });\n });\n }\n\n /**\n * Replace all named expressions\n */\n setNamedExpressions(\n opts: (\n | {\n type: \"global\";\n }\n | {\n type: \"sheet\";\n sheetName: string;\n workbookName: string;\n }\n | {\n type: \"workbook\";\n workbookName: string;\n }\n ) & {\n expressions: Map<string, NamedExpression>;\n }\n ) {\n let map: Map<string, NamedExpression> | undefined;\n\n if (opts.type === \"sheet\") {\n map = this.sheetExpressions.get(opts.workbookName)?.get(opts.sheetName);\n } else if (opts.type === \"workbook\") {\n map = this.workbookExpressions.get(opts.workbookName);\n } else {\n map = this.globalExpressions;\n }\n\n if (!map) {\n throw new Error(\"Invalid options: \" + JSON.stringify(opts));\n }\n\n map.clear();\n\n opts.expressions.forEach((expression, name) => {\n map.set(name, expression);\n });\n }\n\n getNamedExpression(depNode: {\n name: string;\n scope:\n | {\n type: \"global\";\n }\n | {\n type: \"workbook\";\n workbookName: string;\n }\n | {\n type: \"sheet\";\n workbookName: string;\n sheetName: string;\n };\n }): NamedExpression | undefined {\n if (depNode.scope.type === \"global\") {\n return this.globalExpressions.get(depNode.name);\n }\n if (depNode.scope.type === \"workbook\") {\n return this.workbookExpressions\n .get(depNode.scope.workbookName)\n ?.get(depNode.name);\n }\n if (depNode.scope.type === \"sheet\") {\n return this.sheetExpressions\n .get(depNode.scope.workbookName)\n ?.get(depNode.scope.sheetName)\n ?.get(depNode.name);\n }\n return undefined;\n }\n\n resolveNamedExpression(\n namedExpression: Pick<\n NamedExpressionNode,\n \"name\" | \"sheetName\" | \"workbookName\"\n >,\n context: EvaluationContext\n ): string | undefined {\n // scenario 1: no sheetName nor workbookName\n if (!namedExpression.sheetName && !namedExpression.workbookName) {\n /**\n * the result of this formula will differ based on in which sheet and workbook we are\n * evaluating it in.\n */\n context.addContextDependency(\"sheet\", \"workbook\");\n\n // step 1, check if there is a named expression in the sheet scope\n const expression = this.sheetExpressions\n .get(context.cellAddress.workbookName)\n ?.get(context.cellAddress.sheetName)\n ?.get(namedExpression.name);\n if (expression) {\n return expression.expression;\n } else {\n // step 2, check if there is a named expression in the workbook scope\n const expression = this.workbookExpressions\n .get(context.cellAddress.workbookName)\n ?.get(namedExpression.name);\n if (expression) {\n return expression.expression;\n } else {\n // step 3, check if there is a named expression in the global scope\n const expression = this.globalExpressions.get(namedExpression.name);\n if (expression) {\n return expression.expression;\n }\n }\n }\n }\n\n // scenario 2: we only have a workbookName - a bit weird, but could happen\n if (namedExpression.workbookName && !namedExpression.sheetName) {\n // special case: if workbook is the current workbook, we should just resolve the named expression according to scenario 1\n if (\n namedExpression.workbookName ===\n context.cellAddress.workbookName\n ) {\n return this.resolveNamedExpression(\n {\n name: namedExpression.name,\n },\n context\n );\n }\n\n const expression = this.workbookExpressions\n .get(namedExpression.workbookName)\n ?.get(namedExpression.name);\n if (expression) {\n // step 1, check if there is a named expression in the workbook scope\n return expression.expression;\n } else {\n // step 2, check if there is a named expression in the global scope\n const expression = this.globalExpressions.get(namedExpression.name);\n if (expression) {\n return expression.expression;\n }\n }\n }\n\n // scenario 3: we only have a sheetName\n if (namedExpression.sheetName && !namedExpression.workbookName) {\n const expression = this.sheetExpressions\n .get(context.cellAddress.workbookName)\n ?.get(namedExpression.sheetName)\n ?.get(namedExpression.name);\n /**\n * the result of this formula will differ based on in which workbook we are\n * evaluating it in.\n */\n context.addContextDependency(\"workbook\");\n if (expression) {\n // step 1, check if there is a named expression in the current workbook against the sheet name\n return expression.expression;\n } else {\n // step 2, check if there is a named expression in the current workbook has a workbook scoped named expression\n const expression = this.workbookExpressions\n .get(context.cellAddress.workbookName)\n ?.get(namedExpression.name);\n if (expression) {\n return expression.expression;\n } else {\n // step 3, check if there is a named expression in the global scope\n const expression = this.globalExpressions.get(namedExpression.name);\n if (expression) {\n return expression.expression;\n }\n }\n }\n }\n\n // scenario 4: we have both sheetName and workbookName\n if (namedExpression.sheetName && namedExpression.workbookName) {\n const expression = this.sheetExpressions\n .get(namedExpression.workbookName)\n ?.get(namedExpression.sheetName)\n ?.get(namedExpression.name);\n if (expression) {\n // step 1, check if there is a named expression the the sheet scope\n return expression.expression;\n } else {\n // step 2, check if there is a named expression in the workbook scope\n const expression = this.workbookExpressions\n .get(namedExpression.workbookName)\n ?.get(namedExpression.name);\n if (expression) {\n return expression.expression;\n } else {\n // step 3, check if there is a named expression in the global scope\n const expression = this.globalExpressions.get(namedExpression.name);\n if (expression) {\n return expression.expression;\n }\n }\n }\n }\n }\n\n getNamedExpressions() {\n return {\n sheetExpressions: this.sheetExpressions,\n workbookExpressions: this.workbookExpressions,\n globalExpressions: this.globalExpressions,\n };\n }\n\n resetNamedExpressions(\n namedExpressions: ReturnType<typeof this.getNamedExpressions>\n ) {\n this.setNamedExpressions({\n type: \"global\",\n expressions: namedExpressions.globalExpressions,\n });\n\n namedExpressions.workbookExpressions.forEach(\n (workbookExpressions, workbookName) => {\n this.setNamedExpressions({\n type: \"workbook\",\n expressions: workbookExpressions,\n workbookName,\n });\n }\n );\n\n namedExpressions.sheetExpressions.forEach(\n (sheetExpressions, workbookName) => {\n sheetExpressions.forEach((sheetExpression, sheetName) => {\n this.setNamedExpressions({\n type: \"sheet\",\n expressions: sheetExpression,\n sheetName,\n workbookName,\n });\n });\n }\n );\n }\n\n /**\n * When adding a sheet, we need to initialize the new maps\n */\n addSheet(opts: { workbookName: string; sheetName: string }) {\n const wbLevel = this.sheetExpressions.get(opts.workbookName);\n if (!wbLevel) {\n throw new Error(\"Workbook not found\");\n }\n const sheetLevel = wbLevel.get(opts.sheetName);\n if (sheetLevel) {\n throw new Error(\"Sheet already exists\");\n }\n wbLevel.set(opts.sheetName, new Map());\n }\n\n /**\n * When adding a workbook, we need to initialize the new maps\n */\n addWorkbook(workbookName: string) {\n this.sheetExpressions.set(workbookName, new Map());\n this.workbookExpressions.set(workbookName, new Map());\n }\n\n /**\n * When removing a workbook, we need to remove the workbook from the sheet level\n */\n removeWorkbook(workbookName: string) {\n this.sheetExpressions.delete(workbookName);\n this.workbookExpressions.delete(workbookName);\n }\n\n /**\n * When removing a sheet, we need to remove the sheet from the workbook level\n */\n removeSheet(opts: { workbookName: string; sheetName: string }) {\n const wbLevel = this.sheetExpressions.get(opts.workbookName);\n if (!wbLevel) {\n throw new Error(\"Workbook not found\");\n }\n wbLevel.delete(opts.sheetName);\n }\n\n /**\n * Rename a sheet's named expressions, mainly used when renaming a sheet\n */\n renameSheet(options: {\n sheetName: string;\n newSheetName: string;\n workbookName: string;\n }): void {\n const wbLevel = this.sheetExpressions.get(options.workbookName);\n if (!wbLevel) {\n throw new Error(\"Workbook not found\");\n }\n const sheetLevel = wbLevel.get(options.sheetName);\n if (!sheetLevel) {\n throw new Error(\"Sheet not found\");\n }\n wbLevel.set(options.newSheetName, sheetLevel);\n wbLevel.delete(options.sheetName);\n }\n\n renameWorkbook(opts: { workbookName: string; newWorkbookName: string }) {\n const wbLevel = this.sheetExpressions.get(opts.workbookName);\n if (!wbLevel) {\n throw new Error(\"Workbook not found\");\n }\n this.sheetExpressions.set(opts.newWorkbookName, wbLevel);\n this.sheetExpressions.delete(opts.workbookName);\n\n const wbScopedExpressions = this.workbookExpressions.get(opts.workbookName);\n if (!wbScopedExpressions) {\n throw new Error(\"Workbook not found\");\n }\n this.workbookExpressions.set(opts.newWorkbookName, wbScopedExpressions);\n this.workbookExpressions.delete(opts.workbookName);\n }\n}\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMO,MAAM,uBAAuB;AAAA,EAClC,mBACE,IAAI;AAAA,EACN,sBAAiE,IAAI;AAAA,EACrE,oBAAkD,IAAI;AAAA,EAEtD,kBAAkB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,KAMO;AAAA,IACP,MAAM,kBAAmC;AAAA,MACvC,MAAM;AAAA,MACN;AAAA,IACF;AAAA,IAEA,IAAI,aAAa,CAAC,cAAc;AAAA,MAC9B,MAAM,IAAI,MAAM,sBAAsB;AAAA,IACxC;AAAA,IAEA,IAAI,aAAa,cAAc;AAAA,MAC7B,IAAI,UAAU,KAAK,iBAAiB,IAAI,YAAY;AAAA,MACpD,IAAI,CAAC,SAAS;AAAA,QACZ,UAAU,IAAI;AAAA,QACd,KAAK,iBAAiB,IAAI,cAAc,OAAO;AAAA,MACjD;AAAA,MAEA,IAAI,aAAa,QAAQ,IAAI,SAAS;AAAA,MACtC,IAAI,CAAC,YAAY;AAAA,QACf,aAAa,IAAI;AAAA,QACjB,QAAQ,IAAI,WAAW,UAAU;AAAA,MACnC;AAAA,MAEA,WAAW,IAAI,gBAAgB,eAAe;AAAA,IAChD,EAAO,SAAI,cAAc;AAAA,MACvB,IAA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AAK,YAAY;AAAA,IAE9C,MAAM,sBAAsB,KAAK,oBAAoB,IAAI,KAAK,YAAY;AAAA,IAC1E,IAAI,CAAC,qBAAqB;AAAA,MACxB,MAAM,IAAI,MAAM,oBAAoB;AAAA,IACtC;AAAA,IACA,KAAK,oBAAoB,IAAI,KAAK,iBAAiB,mBAAmB;AAAA,IACtE,KAAK,oBAAoB,OAAO,KAAK,YAAY;AAAA;AAErD;",
|
|
8
8
|
"debugId": "0B80BB4B76771D4464756E2164756E21",
|
|
@@ -32,10 +32,10 @@ __export(exports_range_eval_order_builder, {
|
|
|
32
32
|
buildRangeEvalOrder: () => buildRangeEvalOrder
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(exports_range_eval_order_builder);
|
|
35
|
+
var import_evaluation_error = require("../../evaluator/evaluation-error.cjs");
|
|
35
36
|
var import_types = require("../types.cjs");
|
|
36
37
|
var import_utils = require("../utils.cjs");
|
|
37
38
|
var import_workbook_manager = require("./workbook-manager.cjs");
|
|
38
|
-
var import_evaluation_error = require("src/evaluator/evaluation-error");
|
|
39
39
|
function buildRangeEvalOrder(lookupOrder, lookupRange) {
|
|
40
40
|
const sheet = this.getSheet(lookupRange);
|
|
41
41
|
if (!sheet) {
|
|
@@ -641,4 +641,4 @@ function findAllDiagonalStepCandidates(targetCell, sheet) {
|
|
|
641
641
|
return unblockedCandidates;
|
|
642
642
|
}
|
|
643
643
|
|
|
644
|
-
//# debugId=
|
|
644
|
+
//# debugId=25EBF4FC98D8F2D464756E2164756E21
|