@ricsam/formula-engine 0.2.2 → 0.2.3
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/ast-traverser.cjs +19 -9
- package/dist/cjs/core/ast-traverser.cjs.map +2 -2
- package/dist/cjs/core/autofill-utils.cjs +19 -9
- package/dist/cjs/core/autofill-utils.cjs.map +2 -2
- package/dist/cjs/core/cell-mover.cjs +19 -9
- package/dist/cjs/core/cell-mover.cjs.map +2 -2
- package/dist/cjs/core/commands/command-executor.cjs +24 -13
- package/dist/cjs/core/commands/command-executor.cjs.map +3 -3
- package/dist/cjs/core/commands/content-commands.cjs +292 -9
- package/dist/cjs/core/commands/content-commands.cjs.map +3 -3
- package/dist/cjs/core/commands/metadata-commands.cjs +19 -9
- package/dist/cjs/core/commands/metadata-commands.cjs.map +2 -2
- package/dist/cjs/core/commands/named-expression-commands.cjs +138 -13
- package/dist/cjs/core/commands/named-expression-commands.cjs.map +3 -3
- package/dist/cjs/core/commands/structure-commands.cjs +216 -15
- package/dist/cjs/core/commands/structure-commands.cjs.map +3 -3
- package/dist/cjs/core/commands/style-commands.cjs +19 -9
- package/dist/cjs/core/commands/style-commands.cjs.map +2 -2
- package/dist/cjs/core/commands/table-commands.cjs +134 -13
- package/dist/cjs/core/commands/table-commands.cjs.map +3 -3
- package/dist/cjs/core/commands/types.cjs +36 -9
- package/dist/cjs/core/commands/types.cjs.map +3 -3
- package/dist/cjs/core/engine-snapshot.cjs +51 -0
- package/dist/cjs/core/engine-snapshot.cjs.map +10 -0
- package/dist/cjs/core/engine.cjs +51 -34
- package/dist/cjs/core/engine.cjs.map +3 -3
- package/dist/cjs/core/managers/cache-manager.cjs +123 -9
- package/dist/cjs/core/managers/cache-manager.cjs.map +3 -3
- package/dist/cjs/core/managers/copy-manager.cjs +19 -9
- package/dist/cjs/core/managers/copy-manager.cjs.map +2 -2
- package/dist/cjs/core/managers/dependency-manager.cjs +697 -9
- package/dist/cjs/core/managers/dependency-manager.cjs.map +3 -3
- package/dist/cjs/core/managers/dependency-node.cjs +14 -8
- package/dist/cjs/core/managers/dependency-node.cjs.map +1 -1
- package/dist/cjs/core/managers/evaluation-manager.cjs +296 -11
- package/dist/cjs/core/managers/evaluation-manager.cjs.map +3 -3
- package/dist/cjs/core/managers/event-manager.cjs +19 -9
- package/dist/cjs/core/managers/event-manager.cjs.map +2 -2
- package/dist/cjs/core/managers/frontier-dependency-manager.cjs +65 -12
- package/dist/cjs/core/managers/frontier-dependency-manager.cjs.map +3 -3
- package/dist/cjs/core/managers/isDependencyNode.cjs +19 -9
- package/dist/cjs/core/managers/isDependencyNode.cjs.map +2 -2
- package/dist/cjs/core/managers/named-expression-manager.cjs +121 -29
- package/dist/cjs/core/managers/named-expression-manager.cjs.map +3 -3
- package/dist/cjs/core/managers/range-eval-order-builder.cjs +19 -9
- package/dist/cjs/core/managers/range-eval-order-builder.cjs.map +2 -2
- package/dist/cjs/core/managers/reference-manager.cjs +25 -9
- package/dist/cjs/core/managers/reference-manager.cjs.map +3 -3
- package/dist/cjs/core/managers/schema-manager.cjs +19 -9
- package/dist/cjs/core/managers/schema-manager.cjs.map +2 -2
- package/dist/cjs/core/managers/style-manager.cjs +28 -9
- package/dist/cjs/core/managers/style-manager.cjs.map +3 -3
- package/dist/cjs/core/managers/table-manager.cjs +25 -9
- package/dist/cjs/core/managers/table-manager.cjs.map +3 -3
- package/dist/cjs/core/managers/workbook-manager.cjs +38 -13
- package/dist/cjs/core/managers/workbook-manager.cjs.map +3 -3
- package/dist/cjs/core/map-serializer.cjs +19 -9
- package/dist/cjs/core/map-serializer.cjs.map +2 -2
- package/dist/cjs/core/named-expression-renamer.cjs +19 -9
- package/dist/cjs/core/named-expression-renamer.cjs.map +2 -2
- package/dist/cjs/core/resource-keys.cjs +67 -0
- package/dist/cjs/core/resource-keys.cjs.map +10 -0
- package/dist/cjs/core/schema/cell-orm.cjs +19 -9
- package/dist/cjs/core/schema/cell-orm.cjs.map +2 -2
- package/dist/cjs/core/schema/grid-orm.cjs +19 -9
- package/dist/cjs/core/schema/grid-orm.cjs.map +2 -2
- package/dist/cjs/core/schema/schema-builder.cjs +19 -9
- package/dist/cjs/core/schema/schema-builder.cjs.map +2 -2
- package/dist/cjs/core/schema/schema-helpers.cjs +19 -9
- package/dist/cjs/core/schema/schema-helpers.cjs.map +2 -2
- package/dist/cjs/core/schema/schema.cjs +19 -9
- package/dist/cjs/core/schema/schema.cjs.map +2 -2
- package/dist/cjs/core/schema/table-orm.cjs +19 -9
- package/dist/cjs/core/schema/table-orm.cjs.map +2 -2
- package/dist/cjs/core/sheet-renamer.cjs +19 -9
- package/dist/cjs/core/sheet-renamer.cjs.map +2 -2
- package/dist/cjs/core/sheet-utils.cjs +19 -9
- package/dist/cjs/core/sheet-utils.cjs.map +2 -2
- package/dist/cjs/core/table-renamer.cjs +19 -9
- package/dist/cjs/core/table-renamer.cjs.map +2 -2
- package/dist/cjs/core/types.cjs +19 -9
- package/dist/cjs/core/types.cjs.map +2 -2
- package/dist/cjs/core/utils/color-utils.cjs +19 -9
- package/dist/cjs/core/utils/color-utils.cjs.map +2 -2
- package/dist/cjs/core/utils/range-serializer.cjs +19 -9
- package/dist/cjs/core/utils/range-serializer.cjs.map +2 -2
- package/dist/cjs/core/utils/range-utils.cjs +19 -9
- package/dist/cjs/core/utils/range-utils.cjs.map +2 -2
- package/dist/cjs/core/utils/spreadsheet-visualizer.cjs +19 -9
- package/dist/cjs/core/utils/spreadsheet-visualizer.cjs.map +2 -2
- package/dist/cjs/core/utils.cjs +19 -9
- package/dist/cjs/core/utils.cjs.map +2 -2
- package/dist/cjs/core/workbook-renamer.cjs +19 -9
- package/dist/cjs/core/workbook-renamer.cjs.map +2 -2
- package/dist/cjs/debug/flags.cjs +19 -9
- package/dist/cjs/debug/flags.cjs.map +2 -2
- package/dist/cjs/evaluator/arithmetic/add/add.cjs +19 -9
- package/dist/cjs/evaluator/arithmetic/add/add.cjs.map +2 -2
- package/dist/cjs/evaluator/arithmetic/divide/divide.cjs +19 -9
- package/dist/cjs/evaluator/arithmetic/divide/divide.cjs.map +2 -2
- package/dist/cjs/evaluator/arithmetic/multiply/multiply.cjs +19 -9
- package/dist/cjs/evaluator/arithmetic/multiply/multiply.cjs.map +2 -2
- package/dist/cjs/evaluator/arithmetic/power/power.cjs +19 -9
- package/dist/cjs/evaluator/arithmetic/power/power.cjs.map +2 -2
- package/dist/cjs/evaluator/arithmetic/subtract/subtract.cjs +19 -9
- package/dist/cjs/evaluator/arithmetic/subtract/subtract.cjs.map +2 -2
- package/dist/cjs/evaluator/comparison/equals.cjs +19 -9
- package/dist/cjs/evaluator/comparison/equals.cjs.map +2 -2
- package/dist/cjs/evaluator/comparison/greater-than-or-equal.cjs +19 -9
- package/dist/cjs/evaluator/comparison/greater-than-or-equal.cjs.map +2 -2
- package/dist/cjs/evaluator/comparison/greater-than.cjs +19 -9
- package/dist/cjs/evaluator/comparison/greater-than.cjs.map +2 -2
- package/dist/cjs/evaluator/comparison/less-than-or-equal.cjs +19 -9
- package/dist/cjs/evaluator/comparison/less-than-or-equal.cjs.map +2 -2
- package/dist/cjs/evaluator/comparison/less-than.cjs +19 -9
- package/dist/cjs/evaluator/comparison/less-than.cjs.map +2 -2
- package/dist/cjs/evaluator/comparison/not-equals.cjs +19 -9
- package/dist/cjs/evaluator/comparison/not-equals.cjs.map +2 -2
- package/dist/cjs/evaluator/concatenation/concatenate.cjs +19 -9
- package/dist/cjs/evaluator/concatenation/concatenate.cjs.map +2 -2
- package/dist/cjs/evaluator/dependency-nodes/ast-evaluation-node.cjs +19 -9
- package/dist/cjs/evaluator/dependency-nodes/ast-evaluation-node.cjs.map +2 -2
- package/dist/cjs/evaluator/dependency-nodes/base-eval-node.cjs +35 -9
- package/dist/cjs/evaluator/dependency-nodes/base-eval-node.cjs.map +3 -3
- package/dist/cjs/evaluator/dependency-nodes/cell-value-node.cjs +22 -9
- package/dist/cjs/evaluator/dependency-nodes/cell-value-node.cjs.map +3 -3
- package/dist/cjs/evaluator/dependency-nodes/empty-cell-evaluation-node.cjs +35 -11
- package/dist/cjs/evaluator/dependency-nodes/empty-cell-evaluation-node.cjs.map +3 -3
- package/dist/cjs/evaluator/dependency-nodes/resource-dependency-node.cjs +61 -0
- package/dist/cjs/evaluator/dependency-nodes/resource-dependency-node.cjs.map +10 -0
- package/dist/cjs/evaluator/dependency-nodes/spill-meta-node.cjs +19 -9
- package/dist/cjs/evaluator/dependency-nodes/spill-meta-node.cjs.map +2 -2
- package/dist/cjs/evaluator/dependency-nodes/virtual-cell-value-node.cjs +22 -9
- package/dist/cjs/evaluator/dependency-nodes/virtual-cell-value-node.cjs.map +3 -3
- package/dist/cjs/evaluator/evaluate-scalar-operator.cjs +19 -9
- package/dist/cjs/evaluator/evaluate-scalar-operator.cjs.map +2 -2
- package/dist/cjs/evaluator/evaluation-context.cjs +19 -9
- package/dist/cjs/evaluator/evaluation-context.cjs.map +2 -2
- package/dist/cjs/evaluator/evaluation-error.cjs +19 -9
- package/dist/cjs/evaluator/evaluation-error.cjs.map +2 -2
- package/dist/cjs/evaluator/formula-evaluator.cjs +55 -12
- package/dist/cjs/evaluator/formula-evaluator.cjs.map +3 -3
- package/dist/cjs/evaluator/range-evaluation-node.cjs +35 -11
- package/dist/cjs/evaluator/range-evaluation-node.cjs.map +3 -3
- package/dist/cjs/functions/_template/template.cjs +19 -9
- package/dist/cjs/functions/_template/template.cjs.map +2 -2
- package/dist/cjs/functions/array/sequence/sequence.cjs +19 -9
- package/dist/cjs/functions/array/sequence/sequence.cjs.map +2 -2
- package/dist/cjs/functions/criteria-parser.cjs +19 -9
- package/dist/cjs/functions/criteria-parser.cjs.map +2 -2
- package/dist/cjs/functions/criteria-utils.cjs +19 -9
- package/dist/cjs/functions/criteria-utils.cjs.map +2 -2
- package/dist/cjs/functions/function-registry.cjs +19 -9
- package/dist/cjs/functions/function-registry.cjs.map +2 -2
- package/dist/cjs/functions/function-utils.cjs +19 -9
- package/dist/cjs/functions/function-utils.cjs.map +2 -2
- package/dist/cjs/functions/information/cell/cell.cjs +19 -9
- package/dist/cjs/functions/information/cell/cell.cjs.map +2 -2
- package/dist/cjs/functions/information/column/column.cjs +19 -9
- package/dist/cjs/functions/information/column/column.cjs.map +2 -2
- package/dist/cjs/functions/information/row/row.cjs +19 -9
- package/dist/cjs/functions/information/row/row.cjs.map +2 -2
- package/dist/cjs/functions/logical/and/and.cjs +19 -9
- package/dist/cjs/functions/logical/and/and.cjs.map +2 -2
- package/dist/cjs/functions/logical/if/if.cjs +19 -9
- package/dist/cjs/functions/logical/if/if.cjs.map +2 -2
- package/dist/cjs/functions/logical/iferror/iferror.cjs +19 -9
- package/dist/cjs/functions/logical/iferror/iferror.cjs.map +2 -2
- package/dist/cjs/functions/logical/or/or.cjs +19 -9
- package/dist/cjs/functions/logical/or/or.cjs.map +2 -2
- package/dist/cjs/functions/lookup/count/count-utils.cjs +19 -9
- package/dist/cjs/functions/lookup/count/count-utils.cjs.map +2 -2
- package/dist/cjs/functions/lookup/count/count.cjs +19 -9
- package/dist/cjs/functions/lookup/count/count.cjs.map +2 -2
- package/dist/cjs/functions/lookup/count/countif.cjs +19 -9
- package/dist/cjs/functions/lookup/count/countif.cjs.map +2 -2
- package/dist/cjs/functions/lookup/count/countifs.cjs +19 -9
- package/dist/cjs/functions/lookup/count/countifs.cjs.map +2 -2
- package/dist/cjs/functions/lookup/index-lookup/index-lookup.cjs +19 -9
- package/dist/cjs/functions/lookup/index-lookup/index-lookup.cjs.map +2 -2
- package/dist/cjs/functions/lookup/match/match.cjs +21 -10
- package/dist/cjs/functions/lookup/match/match.cjs.map +3 -3
- package/dist/cjs/functions/lookup/xlookup/xlookup.cjs +19 -9
- package/dist/cjs/functions/lookup/xlookup/xlookup.cjs.map +2 -2
- package/dist/cjs/functions/math/average/average-utils.cjs +19 -9
- package/dist/cjs/functions/math/average/average-utils.cjs.map +2 -2
- package/dist/cjs/functions/math/average/average.cjs +19 -9
- package/dist/cjs/functions/math/average/average.cjs.map +2 -2
- package/dist/cjs/functions/math/average/averageif.cjs +19 -9
- package/dist/cjs/functions/math/average/averageif.cjs.map +2 -2
- package/dist/cjs/functions/math/average/averageifs.cjs +19 -9
- package/dist/cjs/functions/math/average/averageifs.cjs.map +2 -2
- package/dist/cjs/functions/math/ceiling/ceiling.cjs +19 -9
- package/dist/cjs/functions/math/ceiling/ceiling.cjs.map +2 -2
- package/dist/cjs/functions/math/max/max-utils.cjs +19 -9
- package/dist/cjs/functions/math/max/max-utils.cjs.map +2 -2
- package/dist/cjs/functions/math/max/max.cjs +19 -9
- package/dist/cjs/functions/math/max/max.cjs.map +2 -2
- package/dist/cjs/functions/math/max/maxif.cjs +19 -9
- package/dist/cjs/functions/math/max/maxif.cjs.map +2 -2
- package/dist/cjs/functions/math/max/maxifs.cjs +19 -9
- package/dist/cjs/functions/math/max/maxifs.cjs.map +2 -2
- package/dist/cjs/functions/math/min/min-utils.cjs +19 -9
- package/dist/cjs/functions/math/min/min-utils.cjs.map +2 -2
- package/dist/cjs/functions/math/min/min.cjs +19 -9
- package/dist/cjs/functions/math/min/min.cjs.map +2 -2
- package/dist/cjs/functions/math/min/minif.cjs +19 -9
- package/dist/cjs/functions/math/min/minif.cjs.map +2 -2
- package/dist/cjs/functions/math/min/minifs.cjs +19 -9
- package/dist/cjs/functions/math/min/minifs.cjs.map +2 -2
- package/dist/cjs/functions/math/sum/sum.cjs +19 -9
- package/dist/cjs/functions/math/sum/sum.cjs.map +2 -2
- package/dist/cjs/functions/math/sum/sumif.cjs +19 -9
- package/dist/cjs/functions/math/sum/sumif.cjs.map +2 -2
- package/dist/cjs/functions/math/sum/sumifs.cjs +19 -9
- package/dist/cjs/functions/math/sum/sumifs.cjs.map +2 -2
- package/dist/cjs/functions/math/sum/summation-utils.cjs +19 -9
- package/dist/cjs/functions/math/sum/summation-utils.cjs.map +2 -2
- package/dist/cjs/functions/reference/address/address.cjs +19 -9
- package/dist/cjs/functions/reference/address/address.cjs.map +2 -2
- package/dist/cjs/functions/reference/indirect/indirect.cjs +19 -9
- package/dist/cjs/functions/reference/indirect/indirect.cjs.map +2 -2
- package/dist/cjs/functions/reference/offset/offset.cjs +19 -9
- package/dist/cjs/functions/reference/offset/offset.cjs.map +2 -2
- package/dist/cjs/functions/text/concatenate/concatenate.cjs +21 -9
- package/dist/cjs/functions/text/concatenate/concatenate.cjs.map +3 -3
- package/dist/cjs/functions/text/exact/exact.cjs +19 -9
- package/dist/cjs/functions/text/exact/exact.cjs.map +2 -2
- package/dist/cjs/functions/text/find/find.cjs +19 -9
- package/dist/cjs/functions/text/find/find.cjs.map +2 -2
- package/dist/cjs/functions/text/left/left.cjs +19 -9
- package/dist/cjs/functions/text/left/left.cjs.map +2 -2
- package/dist/cjs/functions/text/len/len.cjs +19 -9
- package/dist/cjs/functions/text/len/len.cjs.map +2 -2
- package/dist/cjs/functions/text/mid/mid.cjs +19 -9
- package/dist/cjs/functions/text/mid/mid.cjs.map +2 -2
- package/dist/cjs/functions/text/right/right.cjs +19 -9
- package/dist/cjs/functions/text/right/right.cjs.map +2 -2
- package/dist/cjs/functions/text/text-helpers.cjs +19 -9
- package/dist/cjs/functions/text/text-helpers.cjs.map +2 -2
- package/dist/cjs/functions/text/textjoin/textjoin.cjs +19 -9
- package/dist/cjs/functions/text/textjoin/textjoin.cjs.map +2 -2
- package/dist/cjs/lib.cjs +24 -13
- package/dist/cjs/lib.cjs.map +2 -2
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/parser/ast.cjs +19 -9
- package/dist/cjs/parser/ast.cjs.map +2 -2
- package/dist/cjs/parser/formatter.cjs +19 -9
- package/dist/cjs/parser/formatter.cjs.map +2 -2
- package/dist/cjs/parser/grammar.cjs +19 -9
- package/dist/cjs/parser/grammar.cjs.map +2 -2
- package/dist/cjs/parser/lexer.cjs +19 -9
- package/dist/cjs/parser/lexer.cjs.map +2 -2
- package/dist/cjs/parser/parser.cjs +19 -9
- package/dist/cjs/parser/parser.cjs.map +2 -2
- package/dist/cjs/react/hooks.cjs +31 -10
- package/dist/cjs/react/hooks.cjs.map +2 -2
- package/dist/mjs/core/commands/command-executor.mjs +7 -5
- package/dist/mjs/core/commands/command-executor.mjs.map +3 -3
- package/dist/mjs/core/commands/content-commands.mjs +279 -2
- package/dist/mjs/core/commands/content-commands.mjs.map +3 -3
- package/dist/mjs/core/commands/named-expression-commands.mjs +121 -6
- package/dist/mjs/core/commands/named-expression-commands.mjs.map +3 -3
- package/dist/mjs/core/commands/structure-commands.mjs +204 -8
- package/dist/mjs/core/commands/structure-commands.mjs.map +3 -3
- package/dist/mjs/core/commands/table-commands.mjs +117 -6
- package/dist/mjs/core/commands/table-commands.mjs.map +3 -3
- package/dist/mjs/core/commands/types.mjs +18 -1
- package/dist/mjs/core/commands/types.mjs.map +3 -3
- package/dist/mjs/core/engine-snapshot.mjs +11 -0
- package/dist/mjs/core/engine-snapshot.mjs.map +10 -0
- package/dist/mjs/core/engine.mjs +35 -26
- package/dist/mjs/core/engine.mjs.map +3 -3
- package/dist/mjs/core/managers/cache-manager.mjs +105 -1
- package/dist/mjs/core/managers/cache-manager.mjs.map +3 -3
- package/dist/mjs/core/managers/dependency-manager.mjs +687 -2
- package/dist/mjs/core/managers/dependency-manager.mjs.map +3 -3
- package/dist/mjs/core/managers/evaluation-manager.mjs +283 -4
- package/dist/mjs/core/managers/evaluation-manager.mjs.map +3 -3
- package/dist/mjs/core/managers/frontier-dependency-manager.mjs +47 -4
- package/dist/mjs/core/managers/frontier-dependency-manager.mjs.map +3 -3
- package/dist/mjs/core/managers/named-expression-manager.mjs +104 -21
- package/dist/mjs/core/managers/named-expression-manager.mjs.map +3 -3
- package/dist/mjs/core/managers/reference-manager.mjs +7 -1
- package/dist/mjs/core/managers/reference-manager.mjs.map +3 -3
- package/dist/mjs/core/managers/style-manager.mjs +10 -1
- package/dist/mjs/core/managers/style-manager.mjs.map +3 -3
- package/dist/mjs/core/managers/table-manager.mjs +7 -1
- package/dist/mjs/core/managers/table-manager.mjs.map +3 -3
- package/dist/mjs/core/managers/workbook-manager.mjs +20 -5
- package/dist/mjs/core/managers/workbook-manager.mjs.map +3 -3
- package/dist/mjs/core/resource-keys.mjs +27 -0
- package/dist/mjs/core/resource-keys.mjs.map +10 -0
- package/dist/mjs/evaluator/dependency-nodes/base-eval-node.mjs +17 -1
- package/dist/mjs/evaluator/dependency-nodes/base-eval-node.mjs.map +3 -3
- package/dist/mjs/evaluator/dependency-nodes/cell-value-node.mjs +4 -1
- package/dist/mjs/evaluator/dependency-nodes/cell-value-node.mjs.map +3 -3
- package/dist/mjs/evaluator/dependency-nodes/empty-cell-evaluation-node.mjs +17 -3
- package/dist/mjs/evaluator/dependency-nodes/empty-cell-evaluation-node.mjs.map +3 -3
- package/dist/mjs/evaluator/dependency-nodes/resource-dependency-node.mjs +21 -0
- package/dist/mjs/evaluator/dependency-nodes/resource-dependency-node.mjs.map +10 -0
- package/dist/mjs/evaluator/dependency-nodes/virtual-cell-value-node.mjs +4 -1
- package/dist/mjs/evaluator/dependency-nodes/virtual-cell-value-node.mjs.map +3 -3
- package/dist/mjs/evaluator/formula-evaluator.mjs +42 -4
- package/dist/mjs/evaluator/formula-evaluator.mjs.map +3 -3
- package/dist/mjs/evaluator/range-evaluation-node.mjs +17 -3
- package/dist/mjs/evaluator/range-evaluation-node.mjs.map +3 -3
- package/dist/mjs/functions/lookup/match/match.mjs +3 -2
- package/dist/mjs/functions/lookup/match/match.mjs.map +3 -3
- package/dist/mjs/functions/text/concatenate/concatenate.mjs +3 -1
- package/dist/mjs/functions/text/concatenate/concatenate.mjs.map +3 -3
- package/dist/mjs/package.json +1 -1
- package/dist/types/core/commands/content-commands.d.ts +31 -1
- package/dist/types/core/commands/named-expression-commands.d.ts +16 -1
- package/dist/types/core/commands/structure-commands.d.ts +24 -1
- package/dist/types/core/commands/table-commands.d.ts +16 -1
- package/dist/types/core/commands/types.d.ts +25 -1
- package/dist/types/core/engine-snapshot.d.ts +138 -0
- package/dist/types/core/engine.d.ts +1 -0
- package/dist/types/core/managers/cache-manager.d.ts +9 -0
- package/dist/types/core/managers/dependency-manager.d.ts +56 -1
- package/dist/types/core/managers/dependency-node.d.ts +2 -1
- package/dist/types/core/managers/evaluation-manager.d.ts +21 -1
- package/dist/types/core/managers/frontier-dependency-manager.d.ts +12 -2
- package/dist/types/core/managers/named-expression-manager.d.ts +17 -1
- package/dist/types/core/managers/reference-manager.d.ts +3 -0
- package/dist/types/core/managers/style-manager.d.ts +3 -0
- package/dist/types/core/managers/table-manager.d.ts +3 -0
- package/dist/types/core/managers/workbook-manager.d.ts +4 -1
- package/dist/types/core/resource-keys.d.ts +14 -0
- package/dist/types/evaluator/dependency-nodes/base-eval-node.d.ts +5 -0
- package/dist/types/evaluator/dependency-nodes/cell-value-node.d.ts +1 -0
- package/dist/types/evaluator/dependency-nodes/empty-cell-evaluation-node.d.ts +8 -1
- package/dist/types/evaluator/dependency-nodes/resource-dependency-node.d.ts +8 -0
- package/dist/types/evaluator/dependency-nodes/virtual-cell-value-node.d.ts +1 -0
- package/dist/types/evaluator/range-evaluation-node.d.ts +8 -1
- package/package.json +6 -2
|
@@ -5,13 +5,25 @@ class FrontierDependencyManager {
|
|
|
5
5
|
frontierRange;
|
|
6
6
|
workbookManager;
|
|
7
7
|
evaluationManager;
|
|
8
|
-
evalOrder;
|
|
8
|
+
evalOrder = [];
|
|
9
9
|
_resolved = false;
|
|
10
|
-
_directDepsUpdated;
|
|
11
|
-
|
|
10
|
+
_directDepsUpdated = false;
|
|
11
|
+
evalOrderInitialized = false;
|
|
12
|
+
constructor(frontierRange, workbookManager, evaluationManager, options) {
|
|
12
13
|
this.frontierRange = frontierRange;
|
|
13
14
|
this.workbookManager = workbookManager;
|
|
14
15
|
this.evaluationManager = evaluationManager;
|
|
16
|
+
if (options?.skipInitialBuild) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
this.buildInitialEvalOrder();
|
|
20
|
+
}
|
|
21
|
+
buildInitialEvalOrder() {
|
|
22
|
+
this.evalOrderInitialized = true;
|
|
23
|
+
this.evalOrder = [];
|
|
24
|
+
this._frontierDependencies = new Set;
|
|
25
|
+
this._discardedFrontierDependencies = new Set;
|
|
26
|
+
this._dependencies = new Set;
|
|
15
27
|
const addressToSpillMetaNode = (address) => {
|
|
16
28
|
const node = this.evaluationManager.getSpillMetaNode(cellAddressToKey(address).replace(/^[^:]+:/, "spill-meta:"));
|
|
17
29
|
return node;
|
|
@@ -56,6 +68,11 @@ class FrontierDependencyManager {
|
|
|
56
68
|
}
|
|
57
69
|
this._directDepsUpdated = directDepsUpdated;
|
|
58
70
|
}
|
|
71
|
+
ensureEvalOrderBuilt() {
|
|
72
|
+
if (!this.evalOrderInitialized) {
|
|
73
|
+
this.buildInitialEvalOrder();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
59
76
|
_frontierDependencies = new Set;
|
|
60
77
|
_discardedFrontierDependencies = new Set;
|
|
61
78
|
_dependencies = new Set;
|
|
@@ -63,12 +80,36 @@ class FrontierDependencyManager {
|
|
|
63
80
|
return;
|
|
64
81
|
}
|
|
65
82
|
getRangeEvalOrder() {
|
|
83
|
+
this.ensureEvalOrderBuilt();
|
|
66
84
|
return this.evalOrder;
|
|
67
85
|
}
|
|
86
|
+
getFrontierRange() {
|
|
87
|
+
return this.frontierRange;
|
|
88
|
+
}
|
|
89
|
+
restoreResolvedSnapshot(options) {
|
|
90
|
+
this.evalOrder = [];
|
|
91
|
+
this.evalOrderInitialized = true;
|
|
92
|
+
this._frontierDependencies = new Set;
|
|
93
|
+
this._discardedFrontierDependencies = new Set;
|
|
94
|
+
this._dependencies = new Set(options.dependencies);
|
|
95
|
+
this._directDepsUpdated = false;
|
|
96
|
+
this._resolved = true;
|
|
97
|
+
}
|
|
98
|
+
invalidate() {
|
|
99
|
+
this.evalOrder = [];
|
|
100
|
+
this.evalOrderInitialized = false;
|
|
101
|
+
this._frontierDependencies = new Set;
|
|
102
|
+
this._discardedFrontierDependencies = new Set;
|
|
103
|
+
this._dependencies = new Set;
|
|
104
|
+
this._directDepsUpdated = false;
|
|
105
|
+
this._resolved = false;
|
|
106
|
+
}
|
|
68
107
|
get frontierDependencies() {
|
|
108
|
+
this.ensureEvalOrderBuilt();
|
|
69
109
|
return this._frontierDependencies.difference(this._discardedFrontierDependencies).difference(this._dependencies);
|
|
70
110
|
}
|
|
71
111
|
get discardedFrontierDependencies() {
|
|
112
|
+
this.ensureEvalOrderBuilt();
|
|
72
113
|
return this._discardedFrontierDependencies;
|
|
73
114
|
}
|
|
74
115
|
maybeDiscardFrontierDependency(dependency) {
|
|
@@ -112,12 +153,14 @@ class FrontierDependencyManager {
|
|
|
112
153
|
this._directDepsUpdated = false;
|
|
113
154
|
}
|
|
114
155
|
getDependencies() {
|
|
156
|
+
this.ensureEvalOrderBuilt();
|
|
115
157
|
return this._dependencies;
|
|
116
158
|
}
|
|
117
159
|
getFrontierDependencies() {
|
|
118
160
|
return this.frontierDependencies;
|
|
119
161
|
}
|
|
120
162
|
getAllDependencies() {
|
|
163
|
+
this.ensureEvalOrderBuilt();
|
|
121
164
|
return this._dependencies.union(this._frontierDependencies);
|
|
122
165
|
}
|
|
123
166
|
getDiscardedFrontierDependencies() {
|
|
@@ -148,4 +191,4 @@ export {
|
|
|
148
191
|
FrontierDependencyManager
|
|
149
192
|
};
|
|
150
193
|
|
|
151
|
-
//# debugId=
|
|
194
|
+
//# debugId=39D280E127FA1FB164756E2164756E21
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/core/managers/frontier-dependency-manager.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { CellValueNode } from \"../../evaluator/dependency-nodes/cell-value-node.mjs\";\nimport type { CellAddress, CellInRangeResult, RangeAddress } from \"../types.mjs\";\nimport { cellAddressToKey, checkRangeIntersection } from \"../utils.mjs\";\nimport type { DependencyManager } from \"./dependency-manager.mjs\";\nimport type { DependencyNode } from \"./dependency-node.mjs\";\nimport type { WorkbookManager } from \"./workbook-manager.mjs\";\nimport type { SpillMetaNode } from \"../../evaluator/dependency-nodes/spill-meta-node.mjs\";\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
|
|
5
|
+
"import { CellValueNode } from \"../../evaluator/dependency-nodes/cell-value-node.mjs\";\nimport type { CellAddress, CellInRangeResult, RangeAddress } from \"../types.mjs\";\nimport { cellAddressToKey, checkRangeIntersection } from \"../utils.mjs\";\nimport type { DependencyManager } from \"./dependency-manager.mjs\";\nimport type { DependencyNode } from \"./dependency-node.mjs\";\nimport type { WorkbookManager } from \"./workbook-manager.mjs\";\nimport type { SpillMetaNode } from \"../../evaluator/dependency-nodes/spill-meta-node.mjs\";\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 = false;\n private evalOrderInitialized: boolean = false;\n\n constructor(\n protected readonly frontierRange: RangeAddress,\n protected workbookManager: WorkbookManager,\n protected evaluationManager: DependencyManager,\n options?: { skipInitialBuild?: boolean }\n ) {\n if (options?.skipInitialBuild) {\n return;\n }\n\n this.buildInitialEvalOrder();\n }\n\n protected buildInitialEvalOrder() {\n this.evalOrderInitialized = true;\n this.evalOrder = [];\n this._frontierDependencies = new Set();\n this._discardedFrontierDependencies = new Set();\n this._dependencies = new Set();\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 protected ensureEvalOrderBuilt() {\n if (!this.evalOrderInitialized) {\n this.buildInitialEvalOrder();\n }\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 this.ensureEvalOrderBuilt();\n return this.evalOrder;\n }\n\n public getFrontierRange() {\n return this.frontierRange;\n }\n\n public restoreResolvedSnapshot(options: {\n dependencies: Set<DependencyNode>;\n }) {\n this.evalOrder = [];\n this.evalOrderInitialized = true;\n this._frontierDependencies = new Set();\n this._discardedFrontierDependencies = new Set();\n this._dependencies = new Set(options.dependencies);\n this._directDepsUpdated = false;\n this._resolved = true;\n }\n\n public invalidate() {\n this.evalOrder = [];\n this.evalOrderInitialized = false;\n this._frontierDependencies = new Set();\n this._discardedFrontierDependencies = new Set();\n this._dependencies = new Set();\n this._directDepsUpdated = false;\n this._resolved = false;\n }\n\n public get frontierDependencies() {\n this.ensureEvalOrderBuilt();\n return this._frontierDependencies\n .difference(this._discardedFrontierDependencies)\n .difference(this._dependencies);\n }\n\n public get discardedFrontierDependencies() {\n this.ensureEvalOrderBuilt();\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 this.ensureEvalOrderBuilt();\n return this._dependencies;\n }\n\n public getFrontierDependencies() {\n return this.frontierDependencies;\n }\n\n public getAllDependencies() {\n this.ensureEvalOrderBuilt();\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
|
-
"mappings": ";AAEA;AAAA;AAuBO,MAAM,0BAA0B;AAAA,
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";AAEA;AAAA;AAuBO,MAAM,0BAA0B;AAAA,EAOhB;AAAA,EACT;AAAA,EACA;AAAA,EARJ,YAA8B,CAAC;AAAA,EAC/B,YAAqB;AAAA,EACrB,qBAA8B;AAAA,EAC9B,uBAAgC;AAAA,EAExC,WAAW,CACU,eACT,iBACA,mBACV,SACA;AAAA,IAJmB;AAAA,IACT;AAAA,IACA;AAAA,IAGV,IAAI,SAAS,kBAAkB;AAAA,MAC7B;AAAA,IACF;AAAA,IAEA,KAAK,sBAAsB;AAAA;AAAA,EAGnB,qBAAqB,GAAG;AAAA,IAChC,KAAK,uBAAuB;AAAA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AO,KAAK;AAAA;AAAA,EAGP,aAAa,CAAC,YAA4B;AAAA,IAC/C,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,uBACjB,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
|
+
"debugId": "39D280E127FA1FB164756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
// src/core/managers/named-expression-manager.ts
|
|
2
|
+
import { getNamedExpressionResourceKey } from "../resource-keys.mjs";
|
|
3
|
+
|
|
2
4
|
class NamedExpressionManager {
|
|
3
5
|
sheetExpressions = new Map;
|
|
4
6
|
workbookExpressions = new Map;
|
|
@@ -140,7 +142,8 @@ class NamedExpressionManager {
|
|
|
140
142
|
return true;
|
|
141
143
|
}
|
|
142
144
|
updateAllNamedExpressions(updateCallback) {
|
|
143
|
-
const
|
|
145
|
+
const changed = new Set;
|
|
146
|
+
const update = (map, opts) => {
|
|
144
147
|
map.forEach((namedExpr, name) => {
|
|
145
148
|
const updatedExpression = updateCallback(namedExpr.expression);
|
|
146
149
|
if (updatedExpression !== namedExpr.expression) {
|
|
@@ -148,18 +151,24 @@ class NamedExpressionManager {
|
|
|
148
151
|
...namedExpr,
|
|
149
152
|
expression: updatedExpression
|
|
150
153
|
});
|
|
154
|
+
changed.add(getNamedExpressionResourceKey({
|
|
155
|
+
expressionName: name,
|
|
156
|
+
workbookName: opts.workbookName,
|
|
157
|
+
sheetName: opts.sheetName
|
|
158
|
+
}));
|
|
151
159
|
}
|
|
152
160
|
});
|
|
153
161
|
};
|
|
154
|
-
update(this.globalExpressions);
|
|
155
|
-
this.workbookExpressions.forEach((workbookLevel) => {
|
|
156
|
-
update(workbookLevel);
|
|
162
|
+
update(this.globalExpressions, {});
|
|
163
|
+
this.workbookExpressions.forEach((workbookLevel, workbookName) => {
|
|
164
|
+
update(workbookLevel, { workbookName });
|
|
157
165
|
});
|
|
158
|
-
this.sheetExpressions.forEach((wbLevel) => {
|
|
159
|
-
wbLevel.forEach((sheetLevel) => {
|
|
160
|
-
update(sheetLevel);
|
|
166
|
+
this.sheetExpressions.forEach((wbLevel, workbookName) => {
|
|
167
|
+
wbLevel.forEach((sheetLevel, sheetName) => {
|
|
168
|
+
update(sheetLevel, { workbookName, sheetName });
|
|
161
169
|
});
|
|
162
170
|
});
|
|
171
|
+
return Array.from(changed);
|
|
163
172
|
}
|
|
164
173
|
setNamedExpressions(opts) {
|
|
165
174
|
let map;
|
|
@@ -190,37 +199,66 @@ class NamedExpressionManager {
|
|
|
190
199
|
}
|
|
191
200
|
return;
|
|
192
201
|
}
|
|
193
|
-
|
|
202
|
+
resolveNamedExpressionWithScope(namedExpression, context) {
|
|
194
203
|
if (!namedExpression.sheetName && !namedExpression.workbookName) {
|
|
195
204
|
context.addContextDependency("sheet", "workbook");
|
|
196
205
|
const expression = this.sheetExpressions.get(context.cellAddress.workbookName)?.get(context.cellAddress.sheetName)?.get(namedExpression.name);
|
|
197
206
|
if (expression) {
|
|
198
|
-
return
|
|
207
|
+
return {
|
|
208
|
+
expression: expression.expression,
|
|
209
|
+
scope: {
|
|
210
|
+
type: "sheet",
|
|
211
|
+
workbookName: context.cellAddress.workbookName,
|
|
212
|
+
sheetName: context.cellAddress.sheetName
|
|
213
|
+
}
|
|
214
|
+
};
|
|
199
215
|
} else {
|
|
200
216
|
const expression2 = this.workbookExpressions.get(context.cellAddress.workbookName)?.get(namedExpression.name);
|
|
201
217
|
if (expression2) {
|
|
202
|
-
return
|
|
218
|
+
return {
|
|
219
|
+
expression: expression2.expression,
|
|
220
|
+
scope: {
|
|
221
|
+
type: "workbook",
|
|
222
|
+
workbookName: context.cellAddress.workbookName
|
|
223
|
+
}
|
|
224
|
+
};
|
|
203
225
|
} else {
|
|
204
226
|
const expression3 = this.globalExpressions.get(namedExpression.name);
|
|
205
227
|
if (expression3) {
|
|
206
|
-
return
|
|
228
|
+
return {
|
|
229
|
+
expression: expression3.expression,
|
|
230
|
+
scope: {
|
|
231
|
+
type: "global"
|
|
232
|
+
}
|
|
233
|
+
};
|
|
207
234
|
}
|
|
208
235
|
}
|
|
209
236
|
}
|
|
210
237
|
}
|
|
211
238
|
if (namedExpression.workbookName && !namedExpression.sheetName) {
|
|
212
239
|
if (namedExpression.workbookName === context.cellAddress.workbookName) {
|
|
213
|
-
return this.
|
|
240
|
+
return this.resolveNamedExpressionWithScope({
|
|
214
241
|
name: namedExpression.name
|
|
215
242
|
}, context);
|
|
216
243
|
}
|
|
217
244
|
const expression = this.workbookExpressions.get(namedExpression.workbookName)?.get(namedExpression.name);
|
|
218
245
|
if (expression) {
|
|
219
|
-
return
|
|
246
|
+
return {
|
|
247
|
+
expression: expression.expression,
|
|
248
|
+
scope: {
|
|
249
|
+
type: "workbook",
|
|
250
|
+
workbookName: namedExpression.workbookName
|
|
251
|
+
}
|
|
252
|
+
};
|
|
220
253
|
} else {
|
|
221
254
|
const expression2 = this.globalExpressions.get(namedExpression.name);
|
|
222
255
|
if (expression2) {
|
|
223
|
-
return
|
|
256
|
+
return {
|
|
257
|
+
expression: expression2.expression,
|
|
258
|
+
scope: {
|
|
259
|
+
type: "global"
|
|
260
|
+
}
|
|
261
|
+
};
|
|
224
262
|
}
|
|
225
263
|
}
|
|
226
264
|
}
|
|
@@ -228,15 +266,33 @@ class NamedExpressionManager {
|
|
|
228
266
|
const expression = this.sheetExpressions.get(context.cellAddress.workbookName)?.get(namedExpression.sheetName)?.get(namedExpression.name);
|
|
229
267
|
context.addContextDependency("workbook");
|
|
230
268
|
if (expression) {
|
|
231
|
-
return
|
|
269
|
+
return {
|
|
270
|
+
expression: expression.expression,
|
|
271
|
+
scope: {
|
|
272
|
+
type: "sheet",
|
|
273
|
+
workbookName: context.cellAddress.workbookName,
|
|
274
|
+
sheetName: namedExpression.sheetName
|
|
275
|
+
}
|
|
276
|
+
};
|
|
232
277
|
} else {
|
|
233
278
|
const expression2 = this.workbookExpressions.get(context.cellAddress.workbookName)?.get(namedExpression.name);
|
|
234
279
|
if (expression2) {
|
|
235
|
-
return
|
|
280
|
+
return {
|
|
281
|
+
expression: expression2.expression,
|
|
282
|
+
scope: {
|
|
283
|
+
type: "workbook",
|
|
284
|
+
workbookName: context.cellAddress.workbookName
|
|
285
|
+
}
|
|
286
|
+
};
|
|
236
287
|
} else {
|
|
237
288
|
const expression3 = this.globalExpressions.get(namedExpression.name);
|
|
238
289
|
if (expression3) {
|
|
239
|
-
return
|
|
290
|
+
return {
|
|
291
|
+
expression: expression3.expression,
|
|
292
|
+
scope: {
|
|
293
|
+
type: "global"
|
|
294
|
+
}
|
|
295
|
+
};
|
|
240
296
|
}
|
|
241
297
|
}
|
|
242
298
|
}
|
|
@@ -244,20 +300,41 @@ class NamedExpressionManager {
|
|
|
244
300
|
if (namedExpression.sheetName && namedExpression.workbookName) {
|
|
245
301
|
const expression = this.sheetExpressions.get(namedExpression.workbookName)?.get(namedExpression.sheetName)?.get(namedExpression.name);
|
|
246
302
|
if (expression) {
|
|
247
|
-
return
|
|
303
|
+
return {
|
|
304
|
+
expression: expression.expression,
|
|
305
|
+
scope: {
|
|
306
|
+
type: "sheet",
|
|
307
|
+
workbookName: namedExpression.workbookName,
|
|
308
|
+
sheetName: namedExpression.sheetName
|
|
309
|
+
}
|
|
310
|
+
};
|
|
248
311
|
} else {
|
|
249
312
|
const expression2 = this.workbookExpressions.get(namedExpression.workbookName)?.get(namedExpression.name);
|
|
250
313
|
if (expression2) {
|
|
251
|
-
return
|
|
314
|
+
return {
|
|
315
|
+
expression: expression2.expression,
|
|
316
|
+
scope: {
|
|
317
|
+
type: "workbook",
|
|
318
|
+
workbookName: namedExpression.workbookName
|
|
319
|
+
}
|
|
320
|
+
};
|
|
252
321
|
} else {
|
|
253
322
|
const expression3 = this.globalExpressions.get(namedExpression.name);
|
|
254
323
|
if (expression3) {
|
|
255
|
-
return
|
|
324
|
+
return {
|
|
325
|
+
expression: expression3.expression,
|
|
326
|
+
scope: {
|
|
327
|
+
type: "global"
|
|
328
|
+
}
|
|
329
|
+
};
|
|
256
330
|
}
|
|
257
331
|
}
|
|
258
332
|
}
|
|
259
333
|
}
|
|
260
334
|
}
|
|
335
|
+
resolveNamedExpression(namedExpression, context) {
|
|
336
|
+
return this.resolveNamedExpressionWithScope(namedExpression, context)?.expression;
|
|
337
|
+
}
|
|
261
338
|
getNamedExpressions() {
|
|
262
339
|
return {
|
|
263
340
|
sheetExpressions: this.sheetExpressions,
|
|
@@ -288,6 +365,12 @@ class NamedExpressionManager {
|
|
|
288
365
|
});
|
|
289
366
|
});
|
|
290
367
|
}
|
|
368
|
+
toSnapshot() {
|
|
369
|
+
return this.getNamedExpressions();
|
|
370
|
+
}
|
|
371
|
+
restoreFromSnapshot(snapshot) {
|
|
372
|
+
this.resetNamedExpressions(snapshot);
|
|
373
|
+
}
|
|
291
374
|
addSheet(opts) {
|
|
292
375
|
const wbLevel = this.sheetExpressions.get(opts.workbookName);
|
|
293
376
|
if (!wbLevel) {
|
|
@@ -345,4 +428,4 @@ export {
|
|
|
345
428
|
NamedExpressionManager
|
|
346
429
|
};
|
|
347
430
|
|
|
348
|
-
//# debugId=
|
|
431
|
+
//# debugId=76256477A2C9265564756E2164756E21
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/core/managers/named-expression-manager.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import type { NamedExpression } from \"../types.mjs\";\nimport { renameNamedExpressionInFormula } from \"../named-expression-renamer.mjs\";\nimport type { EventManager } from \"./event-manager.mjs\";\nimport type { NamedExpressionNode } from \"../../parser/ast.mjs\";\nimport type { EvaluationContext } from \"../../evaluator/evaluation-context.mjs\";\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.mjs\";\nimport type { NamedExpressionManagerSnapshot } from \"../engine-snapshot.mjs\";\nimport { renameNamedExpressionInFormula } from \"../named-expression-renamer.mjs\";\nimport type { EventManager } from \"./event-manager.mjs\";\nimport type { NamedExpressionNode } from \"../../parser/ast.mjs\";\nimport type { EvaluationContext } from \"../../evaluator/evaluation-context.mjs\";\nimport { getNamedExpressionResourceKey } from \"../resource-keys.mjs\";\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(\n updateCallback: (formula: string) => string\n ): string[] {\n const changed = new Set<string>();\n\n const update = (\n map: Map<string, NamedExpression>,\n opts: { workbookName?: string; sheetName?: string }\n ) => {\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 changed.add(\n getNamedExpressionResourceKey({\n expressionName: name,\n workbookName: opts.workbookName,\n sheetName: opts.sheetName,\n })\n );\n }\n });\n };\n\n update(this.globalExpressions, {});\n\n this.workbookExpressions.forEach((workbookLevel, workbookName) => {\n update(workbookLevel, { workbookName });\n });\n\n this.sheetExpressions.forEach((wbLevel, workbookName) => {\n wbLevel.forEach((sheetLevel, sheetName) => {\n update(sheetLevel, { workbookName, sheetName });\n });\n });\n\n return Array.from(changed);\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 resolveNamedExpressionWithScope(\n namedExpression: Pick<\n NamedExpressionNode,\n \"name\" | \"sheetName\" | \"workbookName\"\n >,\n context: EvaluationContext\n ):\n | {\n expression: string;\n scope:\n | { type: \"global\" }\n | { type: \"workbook\"; workbookName: string }\n | { type: \"sheet\"; workbookName: string; sheetName: string };\n }\n | 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 {\n expression: expression.expression,\n scope: {\n type: \"sheet\",\n workbookName: context.cellAddress.workbookName,\n sheetName: context.cellAddress.sheetName,\n },\n };\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 {\n expression: expression.expression,\n scope: {\n type: \"workbook\",\n workbookName: context.cellAddress.workbookName,\n },\n };\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 {\n expression: expression.expression,\n scope: {\n type: \"global\",\n },\n };\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.resolveNamedExpressionWithScope(\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 {\n expression: expression.expression,\n scope: {\n type: \"workbook\",\n workbookName: namedExpression.workbookName,\n },\n };\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 {\n expression: expression.expression,\n scope: {\n type: \"global\",\n },\n };\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 {\n expression: expression.expression,\n scope: {\n type: \"sheet\",\n workbookName: context.cellAddress.workbookName,\n sheetName: namedExpression.sheetName,\n },\n };\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 {\n expression: expression.expression,\n scope: {\n type: \"workbook\",\n workbookName: context.cellAddress.workbookName,\n },\n };\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 {\n expression: expression.expression,\n scope: {\n type: \"global\",\n },\n };\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 {\n expression: expression.expression,\n scope: {\n type: \"sheet\",\n workbookName: namedExpression.workbookName,\n sheetName: namedExpression.sheetName,\n },\n };\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 {\n expression: expression.expression,\n scope: {\n type: \"workbook\",\n workbookName: namedExpression.workbookName,\n },\n };\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 {\n expression: expression.expression,\n scope: {\n type: \"global\",\n },\n };\n }\n }\n }\n }\n }\n\n resolveNamedExpression(\n namedExpression: Pick<\n NamedExpressionNode,\n \"name\" | \"sheetName\" | \"workbookName\"\n >,\n context: EvaluationContext\n ): string | undefined {\n return this.resolveNamedExpressionWithScope(namedExpression, context)\n ?.expression;\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 toSnapshot(): NamedExpressionManagerSnapshot {\n return this.getNamedExpressions();\n }\n\n restoreFromSnapshot(snapshot: NamedExpressionManagerSnapshot) {\n this.resetNamedExpressions(snapshot);\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
|
-
"mappings": ";
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";AAMA;AAAA;AAEO,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,I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AiB;AAAA,IACnC;AAAA,IACA,QAAQ,IAAI,QAAQ,cAAc,UAAU;AAAA,IAC5C,QAAQ,OAAO,QAAQ,SAAS;AAAA;AAAA,EAGlC,cAAc,CAAC,MAAyD;AAAA,IACtE,MAAM,UAAU,KAAK,iBAAiB,IAAI,KAAK,YAAY;AAAA,IAC3D,IAAI,CAAC,SAAS;AAAA,MACZ,MAAM,IAAI,MAAM,oBAAoB;AAAA,IACtC;AAAA,IACA,KAAK,iBAAiB,IAAI,KAAK,iBAAiB,OAAO;AAAA,IACvD,KAAK,iBAAiB,OAAO,KAAK,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
|
+
"debugId": "76256477A2C9265564756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -85,9 +85,15 @@ class ReferenceManager {
|
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
+
toSnapshot() {
|
|
89
|
+
return this.getAllReferences();
|
|
90
|
+
}
|
|
91
|
+
restoreFromSnapshot(snapshot) {
|
|
92
|
+
this.resetReferences(snapshot);
|
|
93
|
+
}
|
|
88
94
|
}
|
|
89
95
|
export {
|
|
90
96
|
ReferenceManager
|
|
91
97
|
};
|
|
92
98
|
|
|
93
|
-
//# debugId=
|
|
99
|
+
//# debugId=662E1DA7C4CF1F8064756E2164756E21
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/core/managers/reference-manager.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * ReferenceManager - Manages tracked references for external elements\n * \n * Allows consumers to create stable references to ranges that automatically\n * update when sheets/workbooks are renamed and become invalid when deleted.\n */\n\nimport type { RangeAddress, TrackedReference } from \"../types.mjs\";\n\nexport class ReferenceManager {\n private references: Map<string, TrackedReference>;\n\n constructor() {\n this.references = new Map();\n }\n\n /**\n * Create a new tracked reference\n * Returns UUID for the reference\n */\n createRef(address: RangeAddress): string {\n const uuid = crypto.randomUUID();\n this.references.set(uuid, {\n id: uuid,\n address: {\n workbookName: address.workbookName,\n sheetName: address.sheetName,\n range: address.range,\n },\n isValid: true,\n });\n return uuid;\n }\n\n /**\n * Get the current address for a reference\n * Returns undefined if reference doesn't exist or is invalid\n */\n getRefAddress(refId: string): RangeAddress | undefined {\n const ref = this.references.get(refId);\n if (!ref || !ref.isValid) {\n return undefined;\n }\n return {\n workbookName: ref.address.workbookName,\n sheetName: ref.address.sheetName,\n range: ref.address.range,\n };\n }\n\n /**\n * Delete a reference\n * Returns true if reference was deleted, false if it didn't exist\n */\n deleteRef(refId: string): boolean {\n return this.references.delete(refId);\n }\n\n /**\n * Get all invalid reference IDs\n */\n getInvalidRefs(): string[] {\n const invalid: string[] = [];\n for (const [id, ref] of this.references) {\n if (!ref.isValid) {\n invalid.push(id);\n }\n }\n return invalid;\n }\n\n /**\n * Update references when sheet is renamed\n */\n updateSheetName(\n workbookName: string,\n oldSheetName: string,\n newSheetName: string\n ): void {\n for (const ref of this.references.values()) {\n if (\n ref.address.workbookName === workbookName &&\n ref.address.sheetName === oldSheetName\n ) {\n ref.address.sheetName = newSheetName;\n }\n }\n }\n\n /**\n * Update references when workbook is renamed\n */\n updateWorkbookName(oldWorkbookName: string, newWorkbookName: string): void {\n for (const ref of this.references.values()) {\n if (ref.address.workbookName === oldWorkbookName) {\n ref.address.workbookName = newWorkbookName;\n }\n }\n }\n\n /**\n * Mark references as invalid when sheet is removed\n */\n invalidateSheet(workbookName: string, sheetName: string): void {\n for (const ref of this.references.values()) {\n if (\n ref.address.workbookName === workbookName &&\n ref.address.sheetName === sheetName\n ) {\n ref.isValid = false;\n }\n }\n }\n\n /**\n * Mark references as invalid when workbook is removed\n */\n invalidateWorkbook(workbookName: string): void {\n for (const ref of this.references.values()) {\n if (ref.address.workbookName === workbookName) {\n ref.isValid = false;\n }\n }\n }\n\n /**\n * Get all references for serialization\n */\n getAllReferences(): Map<string, TrackedReference> {\n return new Map(this.references);\n }\n\n /**\n * Restore references from serialization\n */\n resetReferences(refs: Map<string, TrackedReference>): void {\n this.references.clear();\n for (const [id, ref] of refs) {\n this.references.set(id, {\n id: ref.id,\n address: {\n workbookName: ref.address.workbookName,\n sheetName: ref.address.sheetName,\n range: ref.address.range,\n },\n isValid: ref.isValid,\n });\n }\n }\n}\n\n"
|
|
5
|
+
"/**\n * ReferenceManager - Manages tracked references for external elements\n * \n * Allows consumers to create stable references to ranges that automatically\n * update when sheets/workbooks are renamed and become invalid when deleted.\n */\n\nimport type { RangeAddress, TrackedReference } from \"../types.mjs\";\nimport type { ReferenceManagerSnapshot } from \"../engine-snapshot.mjs\";\n\nexport class ReferenceManager {\n private references: Map<string, TrackedReference>;\n\n constructor() {\n this.references = new Map();\n }\n\n /**\n * Create a new tracked reference\n * Returns UUID for the reference\n */\n createRef(address: RangeAddress): string {\n const uuid = crypto.randomUUID();\n this.references.set(uuid, {\n id: uuid,\n address: {\n workbookName: address.workbookName,\n sheetName: address.sheetName,\n range: address.range,\n },\n isValid: true,\n });\n return uuid;\n }\n\n /**\n * Get the current address for a reference\n * Returns undefined if reference doesn't exist or is invalid\n */\n getRefAddress(refId: string): RangeAddress | undefined {\n const ref = this.references.get(refId);\n if (!ref || !ref.isValid) {\n return undefined;\n }\n return {\n workbookName: ref.address.workbookName,\n sheetName: ref.address.sheetName,\n range: ref.address.range,\n };\n }\n\n /**\n * Delete a reference\n * Returns true if reference was deleted, false if it didn't exist\n */\n deleteRef(refId: string): boolean {\n return this.references.delete(refId);\n }\n\n /**\n * Get all invalid reference IDs\n */\n getInvalidRefs(): string[] {\n const invalid: string[] = [];\n for (const [id, ref] of this.references) {\n if (!ref.isValid) {\n invalid.push(id);\n }\n }\n return invalid;\n }\n\n /**\n * Update references when sheet is renamed\n */\n updateSheetName(\n workbookName: string,\n oldSheetName: string,\n newSheetName: string\n ): void {\n for (const ref of this.references.values()) {\n if (\n ref.address.workbookName === workbookName &&\n ref.address.sheetName === oldSheetName\n ) {\n ref.address.sheetName = newSheetName;\n }\n }\n }\n\n /**\n * Update references when workbook is renamed\n */\n updateWorkbookName(oldWorkbookName: string, newWorkbookName: string): void {\n for (const ref of this.references.values()) {\n if (ref.address.workbookName === oldWorkbookName) {\n ref.address.workbookName = newWorkbookName;\n }\n }\n }\n\n /**\n * Mark references as invalid when sheet is removed\n */\n invalidateSheet(workbookName: string, sheetName: string): void {\n for (const ref of this.references.values()) {\n if (\n ref.address.workbookName === workbookName &&\n ref.address.sheetName === sheetName\n ) {\n ref.isValid = false;\n }\n }\n }\n\n /**\n * Mark references as invalid when workbook is removed\n */\n invalidateWorkbook(workbookName: string): void {\n for (const ref of this.references.values()) {\n if (ref.address.workbookName === workbookName) {\n ref.isValid = false;\n }\n }\n }\n\n /**\n * Get all references for serialization\n */\n getAllReferences(): Map<string, TrackedReference> {\n return new Map(this.references);\n }\n\n /**\n * Restore references from serialization\n */\n resetReferences(refs: Map<string, TrackedReference>): void {\n this.references.clear();\n for (const [id, ref] of refs) {\n this.references.set(id, {\n id: ref.id,\n address: {\n workbookName: ref.address.workbookName,\n sheetName: ref.address.sheetName,\n range: ref.address.range,\n },\n isValid: ref.isValid,\n });\n }\n }\n\n toSnapshot(): ReferenceManagerSnapshot {\n return this.getAllReferences();\n }\n\n restoreFromSnapshot(snapshot: ReferenceManagerSnapshot): void {\n this.resetReferences(snapshot);\n }\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";AAUO,MAAM,iBAAiB;AAAA,EACpB;AAAA,EAER,WAAW,GAAG;AAAA,IACZ,KA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BAAiB;AAAA,QAChD,IAAI,QAAQ,eAAe;AAAA,MAC7B;AAAA,IACF;AAAA;AAAA,EAMF,eAAe,CAAC,cAAsB,WAAyB;AAAA,IAC7D,WAAW,OAAO,KAAK,WAAW,OAAO,GAAG;AAAA,MAC1C,IACE,IAAI,QAAQ,iBAAiB,gBAC7B,IAAI,QAAQ,cAAc,WAC1B;AAAA,QACA,IAAI,UAAU;AAAA,MAChB;AAAA,IACF;AAAA;AAAA,EAMF,kBAAkB,CAAC,cAA4B;AAAA,IAC7C,WAAW,OAAO,KAAK,WAAW,OAAO,GAAG;AAAA,MAC1C,IAAI,IAAI,QAAQ,iBAAiB,cAAc;AAAA,QAC7C,IAAI,UAAU;AAAA,MAChB;AAAA,IACF;AAAA;AAAA,EAMF,gBAAgB,GAAkC;AAAA,IAChD,OAAO,IAAI,IAAI,KAAK,UAAU;AAAA;AAAA,EAMhC,eAAe,CAAC,MAA2C;AAAA,IACzD,KAAK,WAAW,MAAM;AAAA,IACtB,YAAY,IAAI,QAAQ,MAAM;AAAA,MAC5B,KAAK,WAAW,IAAI,IAAI;AAAA,QACtB,IAAI,IAAI;AAAA,QACR,SAAS;AAAA,UACP,cAAc,IAAI,QAAQ;AAAA,UAC1B,WAAW,IAAI,QAAQ;AAAA,UACvB,OAAO,IAAI,QAAQ;AAAA,QACrB;AAAA,QACA,SAAS,IAAI;AAAA,MACf,CAAC;AAAA,IACH;AAAA;AAAA,EAGF,UAAU,GAA6B;AAAA,IACrC,OAAO,KAAK,iBAAiB;AAAA;AAAA,EAG/B,mBAAmB,CAAC,UAA0C;AAAA,IAC5D,KAAK,gBAAgB,QAAQ;AAAA;AAEjC;",
|
|
8
|
+
"debugId": "662E1DA7C4CF1F8064756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -91,6 +91,15 @@ class StyleManager {
|
|
|
91
91
|
this.conditionalStyles = conditionalStyles ? [...conditionalStyles] : [];
|
|
92
92
|
this.cellStyles = cellStyles ? [...cellStyles] : [];
|
|
93
93
|
}
|
|
94
|
+
toSnapshot() {
|
|
95
|
+
return {
|
|
96
|
+
conditionalStyles: this.getAllConditionalStyles(),
|
|
97
|
+
cellStyles: this.getAllCellStyles()
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
restoreFromSnapshot(snapshot) {
|
|
101
|
+
this.resetStyles(snapshot.conditionalStyles, snapshot.cellStyles);
|
|
102
|
+
}
|
|
94
103
|
removeWorkbookStyles(workbookName) {
|
|
95
104
|
this.conditionalStyles = this.conditionalStyles.filter((style) => !style.areas.some((area) => area.workbookName === workbookName));
|
|
96
105
|
this.cellStyles = this.cellStyles.filter((style) => !style.areas.some((area) => area.workbookName === workbookName));
|
|
@@ -367,4 +376,4 @@ export {
|
|
|
367
376
|
StyleManager
|
|
368
377
|
};
|
|
369
378
|
|
|
370
|
-
//# debugId=
|
|
379
|
+
//# debugId=C28AECDA2EA2834464756E2164756E21
|