@cj-tech-master/excelts 9.2.1 → 9.3.0
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/README.md +25 -2
- package/README_zh.md +29 -6
- package/dist/browser/index.browser.d.ts +1 -1
- package/dist/browser/index.browser.js +4 -0
- package/dist/browser/index.d.ts +1 -1
- package/dist/browser/index.js +4 -0
- package/dist/browser/modules/excel/cell.d.ts +17 -3
- package/dist/browser/modules/excel/cell.js +170 -22
- package/dist/browser/modules/excel/defined-names.d.ts +96 -1
- package/dist/browser/modules/excel/defined-names.js +411 -21
- package/dist/browser/modules/excel/image.d.ts +11 -0
- package/dist/browser/modules/excel/image.js +24 -1
- package/dist/browser/modules/excel/stream/workbook-reader.browser.d.ts +9 -3
- package/dist/browser/modules/excel/stream/workbook-reader.browser.js +14 -0
- package/dist/browser/modules/excel/stream/workbook-reader.d.ts +2 -1
- package/dist/browser/modules/excel/stream/workbook-writer.browser.d.ts +39 -5
- package/dist/browser/modules/excel/stream/workbook-writer.browser.js +48 -1
- package/dist/browser/modules/excel/stream/workbook-writer.d.ts +3 -2
- package/dist/browser/modules/excel/stream/worksheet-reader.js +17 -1
- package/dist/browser/modules/excel/stream/worksheet-writer.d.ts +39 -6
- package/dist/browser/modules/excel/stream/worksheet-writer.js +45 -5
- package/dist/browser/modules/excel/table.js +15 -2
- package/dist/browser/modules/excel/types.d.ts +133 -2
- package/dist/browser/modules/excel/utils/col-cache.d.ts +1 -0
- package/dist/browser/modules/excel/utils/col-cache.js +15 -0
- package/dist/browser/modules/excel/utils/drawing-utils.d.ts +3 -3
- package/dist/browser/modules/excel/utils/drawing-utils.js +4 -0
- package/dist/browser/modules/excel/utils/external-link-formula.d.ts +76 -0
- package/dist/browser/modules/excel/utils/external-link-formula.js +208 -0
- package/dist/browser/modules/excel/utils/iterate-stream.d.ts +9 -3
- package/dist/browser/modules/excel/utils/iterate-stream.js +3 -1
- package/dist/browser/modules/excel/utils/ooxml-paths.d.ts +19 -0
- package/dist/browser/modules/excel/utils/ooxml-paths.js +37 -2
- package/dist/browser/modules/excel/utils/shared-strings.d.ts +8 -3
- package/dist/browser/modules/excel/utils/shared-strings.js +21 -2
- package/dist/browser/modules/excel/utils/workbook-protection.d.ts +30 -0
- package/dist/browser/modules/excel/utils/workbook-protection.js +30 -0
- package/dist/browser/modules/excel/workbook.browser.d.ts +257 -6
- package/dist/browser/modules/excel/workbook.browser.js +318 -34
- package/dist/browser/modules/excel/workbook.d.ts +1 -1
- package/dist/browser/modules/excel/worksheet.d.ts +3 -1
- package/dist/browser/modules/excel/worksheet.js +21 -2
- package/dist/browser/modules/excel/xlsx/rel-type.d.ts +15 -0
- package/dist/browser/modules/excel/xlsx/rel-type.js +16 -1
- package/dist/browser/modules/excel/xlsx/xform/book/defined-name-xform.d.ts +6 -5
- package/dist/browser/modules/excel/xlsx/xform/book/defined-name-xform.js +21 -86
- package/dist/browser/modules/excel/xlsx/xform/book/external-link-xform.d.ts +84 -0
- package/dist/browser/modules/excel/xlsx/xform/book/external-link-xform.js +330 -0
- package/dist/browser/modules/excel/xlsx/xform/book/external-reference-xform.d.ts +17 -0
- package/dist/browser/modules/excel/xlsx/xform/book/external-reference-xform.js +24 -0
- package/dist/browser/modules/excel/xlsx/xform/book/workbook-calc-properties-xform.d.ts +3 -0
- package/dist/browser/modules/excel/xlsx/xform/book/workbook-calc-properties-xform.js +11 -2
- package/dist/browser/modules/excel/xlsx/xform/book/workbook-protection-xform.d.ts +20 -0
- package/dist/browser/modules/excel/xlsx/xform/book/workbook-protection-xform.js +66 -0
- package/dist/browser/modules/excel/xlsx/xform/book/workbook-xform.js +38 -5
- package/dist/browser/modules/excel/xlsx/xform/core/content-types-xform.js +19 -1
- package/dist/browser/modules/excel/xlsx/xform/core/metadata-xform.d.ts +56 -0
- package/dist/browser/modules/excel/xlsx/xform/core/metadata-xform.js +158 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.d.ts +26 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.js +105 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.js +3 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/drawing-xform.js +10 -2
- package/dist/browser/modules/excel/xlsx/xform/sheet/cell-xform.d.ts +1 -1
- package/dist/browser/modules/excel/xlsx/xform/sheet/cell-xform.js +166 -8
- package/dist/browser/modules/excel/xlsx/xform/sheet/data-validations-xform.js +1 -1
- package/dist/browser/modules/excel/xlsx/xform/sheet/ignored-errors-xform.d.ts +21 -0
- package/dist/browser/modules/excel/xlsx/xform/sheet/ignored-errors-xform.js +80 -0
- package/dist/browser/modules/excel/xlsx/xform/sheet/worksheet-xform.js +9 -4
- package/dist/browser/modules/excel/xlsx/xform/style/border-xform.js +4 -1
- package/dist/browser/modules/excel/xlsx/xlsx.browser.d.ts +172 -13
- package/dist/browser/modules/excel/xlsx/xlsx.browser.js +410 -20
- package/dist/browser/modules/excel/xlsx/xlsx.d.ts +7 -4
- package/dist/browser/modules/excel/xlsx/xlsx.js +4 -5
- package/dist/browser/modules/formula/compile/address-utils.d.ts +62 -0
- package/dist/browser/modules/formula/compile/address-utils.js +83 -0
- package/dist/browser/modules/formula/compile/binder.d.ts +42 -0
- package/dist/browser/modules/formula/compile/binder.js +487 -0
- package/dist/browser/modules/formula/compile/bound-ast.d.ts +230 -0
- package/dist/browser/modules/formula/compile/bound-ast.js +80 -0
- package/dist/browser/modules/formula/compile/compiled-formula.d.ts +137 -0
- package/dist/browser/modules/formula/compile/compiled-formula.js +383 -0
- package/dist/browser/modules/formula/compile/dependency-analysis.d.ts +93 -0
- package/dist/browser/modules/formula/compile/dependency-analysis.js +432 -0
- package/dist/browser/modules/formula/compile/structured-ref-utils.d.ts +93 -0
- package/dist/browser/modules/formula/compile/structured-ref-utils.js +136 -0
- package/dist/browser/modules/formula/default-syntax-probe.d.ts +79 -0
- package/dist/browser/modules/formula/default-syntax-probe.js +83 -0
- package/dist/browser/modules/formula/functions/_date-context.d.ts +4 -0
- package/dist/browser/modules/formula/functions/_date-context.js +29 -0
- package/dist/browser/modules/formula/functions/_shared.d.ts +121 -0
- package/dist/browser/modules/formula/functions/_shared.js +381 -0
- package/dist/browser/modules/formula/functions/conditional.d.ts +27 -0
- package/dist/browser/modules/formula/functions/conditional.js +343 -0
- package/dist/browser/modules/formula/functions/database.d.ts +37 -0
- package/dist/browser/modules/formula/functions/database.js +274 -0
- package/dist/browser/modules/formula/functions/date.d.ts +61 -0
- package/dist/browser/modules/formula/functions/date.js +855 -0
- package/dist/browser/modules/formula/functions/dynamic-array.d.ts +23 -0
- package/dist/browser/modules/formula/functions/dynamic-array.js +860 -0
- package/dist/browser/modules/formula/functions/engineering.d.ts +57 -0
- package/dist/browser/modules/formula/functions/engineering.js +1128 -0
- package/dist/browser/modules/formula/functions/financial.d.ts +202 -0
- package/dist/browser/modules/formula/functions/financial.js +2296 -0
- package/dist/browser/modules/formula/functions/lookup.d.ts +18 -0
- package/dist/browser/modules/formula/functions/lookup.js +886 -0
- package/dist/browser/modules/formula/functions/math.d.ts +114 -0
- package/dist/browser/modules/formula/functions/math.js +1406 -0
- package/dist/browser/modules/formula/functions/statistical.d.ts +193 -0
- package/dist/browser/modules/formula/functions/statistical.js +3390 -0
- package/dist/browser/modules/formula/functions/text.d.ts +86 -0
- package/dist/browser/modules/formula/functions/text.js +1845 -0
- package/dist/browser/modules/formula/host-registry.d.ts +53 -0
- package/dist/browser/modules/formula/host-registry.js +69 -0
- package/dist/browser/modules/formula/index.d.ts +39 -0
- package/dist/browser/modules/formula/index.js +49 -0
- package/dist/browser/modules/formula/install.d.ts +62 -0
- package/dist/browser/modules/formula/install.js +88 -0
- package/dist/browser/modules/formula/integration/apply-writeback-plan.d.ts +26 -0
- package/dist/browser/modules/formula/integration/apply-writeback-plan.js +210 -0
- package/dist/browser/modules/formula/integration/calculate-formulas-impl.d.ts +30 -0
- package/dist/browser/modules/formula/integration/calculate-formulas-impl.js +616 -0
- package/dist/browser/modules/formula/integration/calculate-formulas.d.ts +67 -0
- package/dist/browser/modules/formula/integration/calculate-formulas.js +68 -0
- package/dist/browser/modules/formula/integration/formula-instance.d.ts +64 -0
- package/dist/browser/modules/formula/integration/formula-instance.js +79 -0
- package/dist/browser/modules/formula/integration/workbook-adapter.d.ts +26 -0
- package/dist/browser/modules/formula/integration/workbook-adapter.js +324 -0
- package/dist/browser/modules/formula/integration/workbook-snapshot.d.ts +267 -0
- package/dist/browser/modules/formula/integration/workbook-snapshot.js +77 -0
- package/dist/browser/modules/formula/materialize/build-writeback-plan.d.ts +34 -0
- package/dist/browser/modules/formula/materialize/build-writeback-plan.js +473 -0
- package/dist/browser/modules/formula/materialize/spill-engine.d.ts +9 -0
- package/dist/browser/modules/formula/materialize/spill-engine.js +38 -0
- package/dist/browser/modules/formula/materialize/types.d.ts +179 -0
- package/dist/browser/modules/formula/materialize/types.js +29 -0
- package/dist/browser/modules/formula/materialize/writeback-plan.d.ts +167 -0
- package/dist/browser/modules/formula/materialize/writeback-plan.js +27 -0
- package/dist/browser/modules/formula/runtime/evaluator.d.ts +151 -0
- package/dist/browser/modules/formula/runtime/evaluator.js +2291 -0
- package/dist/browser/modules/formula/runtime/function-registry.d.ts +47 -0
- package/dist/browser/modules/formula/runtime/function-registry.js +840 -0
- package/dist/browser/modules/formula/runtime/values.d.ts +211 -0
- package/dist/browser/modules/formula/runtime/values.js +385 -0
- package/dist/browser/modules/formula/syntax/ast.d.ts +129 -0
- package/dist/browser/modules/formula/syntax/ast.js +28 -0
- package/dist/browser/modules/formula/syntax/parser.d.ts +18 -0
- package/dist/browser/modules/formula/syntax/parser.js +439 -0
- package/dist/browser/modules/formula/syntax/token-types.d.ts +153 -0
- package/dist/browser/modules/formula/syntax/token-types.js +59 -0
- package/dist/browser/modules/formula/syntax/tokenizer.d.ts +10 -0
- package/dist/browser/modules/formula/syntax/tokenizer.js +1074 -0
- package/dist/browser/modules/pdf/excel-bridge.js +9 -0
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/modules/excel/cell.js +170 -22
- package/dist/cjs/modules/excel/defined-names.js +411 -21
- package/dist/cjs/modules/excel/image.js +24 -1
- package/dist/cjs/modules/excel/stream/workbook-reader.browser.js +14 -0
- package/dist/cjs/modules/excel/stream/workbook-writer.browser.js +48 -1
- package/dist/cjs/modules/excel/stream/worksheet-reader.js +17 -1
- package/dist/cjs/modules/excel/stream/worksheet-writer.js +45 -5
- package/dist/cjs/modules/excel/table.js +15 -2
- package/dist/cjs/modules/excel/utils/col-cache.js +15 -0
- package/dist/cjs/modules/excel/utils/drawing-utils.js +4 -0
- package/dist/cjs/modules/excel/utils/external-link-formula.js +212 -0
- package/dist/cjs/modules/excel/utils/iterate-stream.js +3 -1
- package/dist/cjs/modules/excel/utils/ooxml-paths.js +42 -2
- package/dist/cjs/modules/excel/utils/shared-strings.js +21 -2
- package/dist/cjs/modules/excel/utils/workbook-protection.js +33 -0
- package/dist/cjs/modules/excel/workbook.browser.js +318 -34
- package/dist/cjs/modules/excel/worksheet.js +20 -1
- package/dist/cjs/modules/excel/xlsx/rel-type.js +16 -1
- package/dist/cjs/modules/excel/xlsx/xform/book/defined-name-xform.js +21 -86
- package/dist/cjs/modules/excel/xlsx/xform/book/external-link-xform.js +333 -0
- package/dist/cjs/modules/excel/xlsx/xform/book/external-reference-xform.js +27 -0
- package/dist/cjs/modules/excel/xlsx/xform/book/workbook-calc-properties-xform.js +11 -2
- package/dist/cjs/modules/excel/xlsx/xform/book/workbook-protection-xform.js +69 -0
- package/dist/cjs/modules/excel/xlsx/xform/book/workbook-xform.js +38 -5
- package/dist/cjs/modules/excel/xlsx/xform/core/content-types-xform.js +18 -0
- package/dist/cjs/modules/excel/xlsx/xform/core/metadata-xform.js +161 -0
- package/dist/cjs/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.js +108 -0
- package/dist/cjs/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.js +3 -0
- package/dist/cjs/modules/excel/xlsx/xform/drawing/drawing-xform.js +10 -2
- package/dist/cjs/modules/excel/xlsx/xform/sheet/cell-xform.js +166 -8
- package/dist/cjs/modules/excel/xlsx/xform/sheet/data-validations-xform.js +1 -1
- package/dist/cjs/modules/excel/xlsx/xform/sheet/ignored-errors-xform.js +83 -0
- package/dist/cjs/modules/excel/xlsx/xform/sheet/worksheet-xform.js +9 -4
- package/dist/cjs/modules/excel/xlsx/xform/style/border-xform.js +4 -1
- package/dist/cjs/modules/excel/xlsx/xlsx.browser.js +408 -18
- package/dist/cjs/modules/excel/xlsx/xlsx.js +4 -5
- package/dist/cjs/modules/formula/compile/address-utils.js +89 -0
- package/dist/cjs/modules/formula/compile/binder.js +489 -0
- package/dist/cjs/modules/formula/compile/bound-ast.js +68 -0
- package/dist/cjs/modules/formula/compile/compiled-formula.js +387 -0
- package/dist/cjs/modules/formula/compile/dependency-analysis.js +437 -0
- package/dist/cjs/modules/formula/compile/structured-ref-utils.js +141 -0
- package/dist/cjs/modules/formula/default-syntax-probe.js +87 -0
- package/dist/cjs/modules/formula/functions/_date-context.js +33 -0
- package/dist/cjs/modules/formula/functions/_shared.js +396 -0
- package/dist/cjs/modules/formula/functions/conditional.js +354 -0
- package/dist/cjs/modules/formula/functions/database.js +288 -0
- package/dist/cjs/modules/formula/functions/date.js +883 -0
- package/dist/cjs/modules/formula/functions/dynamic-array.js +881 -0
- package/dist/cjs/modules/formula/functions/engineering.js +1183 -0
- package/dist/cjs/modules/formula/functions/financial.js +2348 -0
- package/dist/cjs/modules/formula/functions/lookup.js +902 -0
- package/dist/cjs/modules/formula/functions/math.js +1487 -0
- package/dist/cjs/modules/formula/functions/statistical.js +3488 -0
- package/dist/cjs/modules/formula/functions/text.js +1889 -0
- package/dist/cjs/modules/formula/host-registry.js +75 -0
- package/dist/cjs/modules/formula/index.js +58 -0
- package/dist/cjs/modules/formula/install.js +93 -0
- package/dist/cjs/modules/formula/integration/apply-writeback-plan.js +213 -0
- package/dist/cjs/modules/formula/integration/calculate-formulas-impl.js +619 -0
- package/dist/cjs/modules/formula/integration/calculate-formulas.js +71 -0
- package/dist/cjs/modules/formula/integration/formula-instance.js +82 -0
- package/dist/cjs/modules/formula/integration/workbook-adapter.js +327 -0
- package/dist/cjs/modules/formula/integration/workbook-snapshot.js +84 -0
- package/dist/cjs/modules/formula/materialize/build-writeback-plan.js +475 -0
- package/dist/cjs/modules/formula/materialize/spill-engine.js +42 -0
- package/dist/cjs/modules/formula/materialize/types.js +32 -0
- package/dist/cjs/modules/formula/materialize/writeback-plan.js +28 -0
- package/dist/cjs/modules/formula/runtime/evaluator.js +2298 -0
- package/dist/cjs/modules/formula/runtime/function-registry.js +846 -0
- package/dist/cjs/modules/formula/runtime/values.js +385 -0
- package/dist/cjs/modules/formula/syntax/ast.js +8 -0
- package/dist/cjs/modules/formula/syntax/parser.js +440 -0
- package/dist/cjs/modules/formula/syntax/token-types.js +32 -0
- package/dist/cjs/modules/formula/syntax/tokenizer.js +1076 -0
- package/dist/cjs/modules/pdf/excel-bridge.js +9 -0
- package/dist/esm/index.browser.js +4 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/modules/excel/cell.js +170 -22
- package/dist/esm/modules/excel/defined-names.js +411 -21
- package/dist/esm/modules/excel/image.js +24 -1
- package/dist/esm/modules/excel/stream/workbook-reader.browser.js +14 -0
- package/dist/esm/modules/excel/stream/workbook-writer.browser.js +48 -1
- package/dist/esm/modules/excel/stream/worksheet-reader.js +17 -1
- package/dist/esm/modules/excel/stream/worksheet-writer.js +45 -5
- package/dist/esm/modules/excel/table.js +15 -2
- package/dist/esm/modules/excel/utils/col-cache.js +15 -0
- package/dist/esm/modules/excel/utils/drawing-utils.js +4 -0
- package/dist/esm/modules/excel/utils/external-link-formula.js +208 -0
- package/dist/esm/modules/excel/utils/iterate-stream.js +3 -1
- package/dist/esm/modules/excel/utils/ooxml-paths.js +37 -2
- package/dist/esm/modules/excel/utils/shared-strings.js +21 -2
- package/dist/esm/modules/excel/utils/workbook-protection.js +30 -0
- package/dist/esm/modules/excel/workbook.browser.js +318 -34
- package/dist/esm/modules/excel/worksheet.js +21 -2
- package/dist/esm/modules/excel/xlsx/rel-type.js +16 -1
- package/dist/esm/modules/excel/xlsx/xform/book/defined-name-xform.js +21 -86
- package/dist/esm/modules/excel/xlsx/xform/book/external-link-xform.js +330 -0
- package/dist/esm/modules/excel/xlsx/xform/book/external-reference-xform.js +24 -0
- package/dist/esm/modules/excel/xlsx/xform/book/workbook-calc-properties-xform.js +11 -2
- package/dist/esm/modules/excel/xlsx/xform/book/workbook-protection-xform.js +66 -0
- package/dist/esm/modules/excel/xlsx/xform/book/workbook-xform.js +38 -5
- package/dist/esm/modules/excel/xlsx/xform/core/content-types-xform.js +19 -1
- package/dist/esm/modules/excel/xlsx/xform/core/metadata-xform.js +158 -0
- package/dist/esm/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.js +105 -0
- package/dist/esm/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.js +3 -0
- package/dist/esm/modules/excel/xlsx/xform/drawing/drawing-xform.js +10 -2
- package/dist/esm/modules/excel/xlsx/xform/sheet/cell-xform.js +166 -8
- package/dist/esm/modules/excel/xlsx/xform/sheet/data-validations-xform.js +1 -1
- package/dist/esm/modules/excel/xlsx/xform/sheet/ignored-errors-xform.js +80 -0
- package/dist/esm/modules/excel/xlsx/xform/sheet/worksheet-xform.js +9 -4
- package/dist/esm/modules/excel/xlsx/xform/style/border-xform.js +4 -1
- package/dist/esm/modules/excel/xlsx/xlsx.browser.js +410 -20
- package/dist/esm/modules/excel/xlsx/xlsx.js +4 -5
- package/dist/esm/modules/formula/compile/address-utils.js +83 -0
- package/dist/esm/modules/formula/compile/binder.js +487 -0
- package/dist/esm/modules/formula/compile/bound-ast.js +80 -0
- package/dist/esm/modules/formula/compile/compiled-formula.js +383 -0
- package/dist/esm/modules/formula/compile/dependency-analysis.js +432 -0
- package/dist/esm/modules/formula/compile/structured-ref-utils.js +136 -0
- package/dist/esm/modules/formula/default-syntax-probe.js +83 -0
- package/dist/esm/modules/formula/functions/_date-context.js +29 -0
- package/dist/esm/modules/formula/functions/_shared.js +381 -0
- package/dist/esm/modules/formula/functions/conditional.js +343 -0
- package/dist/esm/modules/formula/functions/database.js +274 -0
- package/dist/esm/modules/formula/functions/date.js +855 -0
- package/dist/esm/modules/formula/functions/dynamic-array.js +860 -0
- package/dist/esm/modules/formula/functions/engineering.js +1128 -0
- package/dist/esm/modules/formula/functions/financial.js +2296 -0
- package/dist/esm/modules/formula/functions/lookup.js +886 -0
- package/dist/esm/modules/formula/functions/math.js +1406 -0
- package/dist/esm/modules/formula/functions/statistical.js +3390 -0
- package/dist/esm/modules/formula/functions/text.js +1845 -0
- package/dist/esm/modules/formula/host-registry.js +69 -0
- package/dist/esm/modules/formula/index.js +49 -0
- package/dist/esm/modules/formula/install.js +88 -0
- package/dist/esm/modules/formula/integration/apply-writeback-plan.js +210 -0
- package/dist/esm/modules/formula/integration/calculate-formulas-impl.js +616 -0
- package/dist/esm/modules/formula/integration/calculate-formulas.js +68 -0
- package/dist/esm/modules/formula/integration/formula-instance.js +79 -0
- package/dist/esm/modules/formula/integration/workbook-adapter.js +324 -0
- package/dist/esm/modules/formula/integration/workbook-snapshot.js +77 -0
- package/dist/esm/modules/formula/materialize/build-writeback-plan.js +473 -0
- package/dist/esm/modules/formula/materialize/spill-engine.js +38 -0
- package/dist/esm/modules/formula/materialize/types.js +29 -0
- package/dist/esm/modules/formula/materialize/writeback-plan.js +27 -0
- package/dist/esm/modules/formula/runtime/evaluator.js +2291 -0
- package/dist/esm/modules/formula/runtime/function-registry.js +840 -0
- package/dist/esm/modules/formula/runtime/values.js +385 -0
- package/dist/esm/modules/formula/syntax/ast.js +28 -0
- package/dist/esm/modules/formula/syntax/parser.js +439 -0
- package/dist/esm/modules/formula/syntax/token-types.js +59 -0
- package/dist/esm/modules/formula/syntax/tokenizer.js +1074 -0
- package/dist/esm/modules/pdf/excel-bridge.js +9 -0
- package/dist/iife/excelts.iife.js +2302 -373
- package/dist/iife/excelts.iife.js.map +1 -1
- package/dist/iife/excelts.iife.min.js +34 -34
- package/dist/types/index.browser.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/modules/excel/cell.d.ts +17 -3
- package/dist/types/modules/excel/defined-names.d.ts +96 -1
- package/dist/types/modules/excel/image.d.ts +11 -0
- package/dist/types/modules/excel/stream/workbook-reader.browser.d.ts +9 -3
- package/dist/types/modules/excel/stream/workbook-reader.d.ts +2 -1
- package/dist/types/modules/excel/stream/workbook-writer.browser.d.ts +39 -5
- package/dist/types/modules/excel/stream/workbook-writer.d.ts +3 -2
- package/dist/types/modules/excel/stream/worksheet-writer.d.ts +39 -6
- package/dist/types/modules/excel/types.d.ts +133 -2
- package/dist/types/modules/excel/utils/col-cache.d.ts +1 -0
- package/dist/types/modules/excel/utils/drawing-utils.d.ts +3 -3
- package/dist/types/modules/excel/utils/external-link-formula.d.ts +76 -0
- package/dist/types/modules/excel/utils/iterate-stream.d.ts +9 -3
- package/dist/types/modules/excel/utils/ooxml-paths.d.ts +19 -0
- package/dist/types/modules/excel/utils/shared-strings.d.ts +8 -3
- package/dist/types/modules/excel/utils/workbook-protection.d.ts +30 -0
- package/dist/types/modules/excel/workbook.browser.d.ts +257 -6
- package/dist/types/modules/excel/workbook.d.ts +1 -1
- package/dist/types/modules/excel/worksheet.d.ts +3 -1
- package/dist/types/modules/excel/xlsx/rel-type.d.ts +15 -0
- package/dist/types/modules/excel/xlsx/xform/book/defined-name-xform.d.ts +6 -5
- package/dist/types/modules/excel/xlsx/xform/book/external-link-xform.d.ts +84 -0
- package/dist/types/modules/excel/xlsx/xform/book/external-reference-xform.d.ts +17 -0
- package/dist/types/modules/excel/xlsx/xform/book/workbook-calc-properties-xform.d.ts +3 -0
- package/dist/types/modules/excel/xlsx/xform/book/workbook-protection-xform.d.ts +20 -0
- package/dist/types/modules/excel/xlsx/xform/core/metadata-xform.d.ts +56 -0
- package/dist/types/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.d.ts +26 -0
- package/dist/types/modules/excel/xlsx/xform/sheet/cell-xform.d.ts +1 -1
- package/dist/types/modules/excel/xlsx/xform/sheet/ignored-errors-xform.d.ts +21 -0
- package/dist/types/modules/excel/xlsx/xlsx.browser.d.ts +172 -13
- package/dist/types/modules/excel/xlsx/xlsx.d.ts +7 -4
- package/dist/types/modules/formula/compile/address-utils.d.ts +62 -0
- package/dist/types/modules/formula/compile/binder.d.ts +42 -0
- package/dist/types/modules/formula/compile/bound-ast.d.ts +230 -0
- package/dist/types/modules/formula/compile/compiled-formula.d.ts +137 -0
- package/dist/types/modules/formula/compile/dependency-analysis.d.ts +93 -0
- package/dist/types/modules/formula/compile/structured-ref-utils.d.ts +93 -0
- package/dist/types/modules/formula/default-syntax-probe.d.ts +79 -0
- package/dist/types/modules/formula/functions/_date-context.d.ts +4 -0
- package/dist/types/modules/formula/functions/_shared.d.ts +121 -0
- package/dist/types/modules/formula/functions/conditional.d.ts +27 -0
- package/dist/types/modules/formula/functions/database.d.ts +37 -0
- package/dist/types/modules/formula/functions/date.d.ts +61 -0
- package/dist/types/modules/formula/functions/dynamic-array.d.ts +23 -0
- package/dist/types/modules/formula/functions/engineering.d.ts +57 -0
- package/dist/types/modules/formula/functions/financial.d.ts +202 -0
- package/dist/types/modules/formula/functions/lookup.d.ts +18 -0
- package/dist/types/modules/formula/functions/math.d.ts +114 -0
- package/dist/types/modules/formula/functions/statistical.d.ts +193 -0
- package/dist/types/modules/formula/functions/text.d.ts +86 -0
- package/dist/types/modules/formula/host-registry.d.ts +53 -0
- package/dist/types/modules/formula/index.d.ts +39 -0
- package/dist/types/modules/formula/install.d.ts +62 -0
- package/dist/types/modules/formula/integration/apply-writeback-plan.d.ts +26 -0
- package/dist/types/modules/formula/integration/calculate-formulas-impl.d.ts +30 -0
- package/dist/types/modules/formula/integration/calculate-formulas.d.ts +67 -0
- package/dist/types/modules/formula/integration/formula-instance.d.ts +64 -0
- package/dist/types/modules/formula/integration/workbook-adapter.d.ts +26 -0
- package/dist/types/modules/formula/integration/workbook-snapshot.d.ts +267 -0
- package/dist/types/modules/formula/materialize/build-writeback-plan.d.ts +34 -0
- package/dist/types/modules/formula/materialize/spill-engine.d.ts +9 -0
- package/dist/types/modules/formula/materialize/types.d.ts +179 -0
- package/dist/types/modules/formula/materialize/writeback-plan.d.ts +167 -0
- package/dist/types/modules/formula/runtime/evaluator.d.ts +151 -0
- package/dist/types/modules/formula/runtime/function-registry.d.ts +47 -0
- package/dist/types/modules/formula/runtime/values.d.ts +211 -0
- package/dist/types/modules/formula/syntax/ast.d.ts +129 -0
- package/dist/types/modules/formula/syntax/parser.d.ts +18 -0
- package/dist/types/modules/formula/syntax/token-types.d.ts +153 -0
- package/dist/types/modules/formula/syntax/tokenizer.d.ts +10 -0
- package/package.json +28 -28
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Compiled Formula — The output of the full compilation pipeline.
|
|
4
|
+
*
|
|
5
|
+
* A `CompiledFormula` packages together:
|
|
6
|
+
* - The original `FormulaInstance` metadata
|
|
7
|
+
* - The bound expression tree (from the binder)
|
|
8
|
+
* - Static dependency information
|
|
9
|
+
* - Metadata flags (volatile, dynamic refs, etc.)
|
|
10
|
+
*
|
|
11
|
+
* ## Static Dependency Extraction
|
|
12
|
+
*
|
|
13
|
+
* Dependencies are extracted from the `BoundExpr` tree. Since names and
|
|
14
|
+
* structured refs are already resolved by the binder, the dependency
|
|
15
|
+
* extraction is a simple tree walk that collects `BoundCellRef` and
|
|
16
|
+
* `BoundAreaRef` nodes.
|
|
17
|
+
*
|
|
18
|
+
* Runtime-dependent references (INDIRECT, OFFSET) cannot be captured
|
|
19
|
+
* statically — the `hasDynamicRefs` flag marks formulas that may have
|
|
20
|
+
* additional runtime dependencies. Those functions re-parse their dynamic
|
|
21
|
+
* arguments at evaluation time using their own parser invocation (the raw
|
|
22
|
+
* AST is not retained on the CompiledFormula).
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.extractStaticDeps = extractStaticDeps;
|
|
26
|
+
exports.detectDynamicArrayFunction = detectDynamicArrayFunction;
|
|
27
|
+
exports.detectSubtotalOutput = detectSubtotalOutput;
|
|
28
|
+
exports.analyzeExpr = analyzeExpr;
|
|
29
|
+
const token_types_1 = require("../syntax/token-types");
|
|
30
|
+
const structured_ref_utils_1 = require("./structured-ref-utils");
|
|
31
|
+
/**
|
|
32
|
+
* Extract static dependencies from a bound expression tree.
|
|
33
|
+
*
|
|
34
|
+
* @param expr - The bound expression tree to analyze
|
|
35
|
+
* @param snapshot - Optional snapshot for resolving structured references
|
|
36
|
+
* @param nameResolver - Optional resolver for formula-based defined name dependencies
|
|
37
|
+
*/
|
|
38
|
+
function extractStaticDeps(expr, snapshot, nameResolver) {
|
|
39
|
+
const cells = [];
|
|
40
|
+
const areas = [];
|
|
41
|
+
walkDeps(expr, cells, areas, snapshot?.tablesByName, nameResolver, new Set());
|
|
42
|
+
// Deduplicate — a formula like `=A1+A1+A1` would otherwise add three
|
|
43
|
+
// copies of A1 to the dep list, bloating both the dependency graph's
|
|
44
|
+
// intermediate storage and the `expandRefsToKeys` pass downstream. We
|
|
45
|
+
// use positional keys that mirror the Set<string> dedup logic that the
|
|
46
|
+
// graph builder already applies, so we can pay the cost here once
|
|
47
|
+
// instead of in every consumer. (R6 architectural note #5)
|
|
48
|
+
return { cells: dedupeCells(cells), areas: dedupeAreas(areas) };
|
|
49
|
+
}
|
|
50
|
+
function dedupeCells(cells) {
|
|
51
|
+
if (cells.length < 2) {
|
|
52
|
+
return cells;
|
|
53
|
+
}
|
|
54
|
+
const seen = new Set();
|
|
55
|
+
const out = [];
|
|
56
|
+
for (const c of cells) {
|
|
57
|
+
const key = `${c.sheet}\u0000${c.row}\u0001${c.col}`;
|
|
58
|
+
if (seen.has(key)) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
seen.add(key);
|
|
62
|
+
out.push(c);
|
|
63
|
+
}
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
66
|
+
function dedupeAreas(areas) {
|
|
67
|
+
if (areas.length < 2) {
|
|
68
|
+
return areas;
|
|
69
|
+
}
|
|
70
|
+
const seen = new Set();
|
|
71
|
+
const out = [];
|
|
72
|
+
for (const a of areas) {
|
|
73
|
+
const key = `${a.sheet}\u0000${a.top}\u0001${a.left}\u0002${a.bottom}\u0003${a.right}`;
|
|
74
|
+
if (seen.has(key)) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
seen.add(key);
|
|
78
|
+
out.push(a);
|
|
79
|
+
}
|
|
80
|
+
return out;
|
|
81
|
+
}
|
|
82
|
+
function walkDeps(expr, cells, areas, tablesByName, nameResolver, visitedNames) {
|
|
83
|
+
switch (expr.kind) {
|
|
84
|
+
case 2 /* BoundExprKind.CellRef */:
|
|
85
|
+
cells.push({ sheet: expr.sheet, row: expr.row, col: expr.col });
|
|
86
|
+
break;
|
|
87
|
+
case 3 /* BoundExprKind.AreaRef */:
|
|
88
|
+
areas.push({
|
|
89
|
+
sheet: expr.sheet,
|
|
90
|
+
top: expr.top,
|
|
91
|
+
left: expr.left,
|
|
92
|
+
bottom: expr.bottom,
|
|
93
|
+
right: expr.right
|
|
94
|
+
});
|
|
95
|
+
break;
|
|
96
|
+
case 4 /* BoundExprKind.ColRangeRef */:
|
|
97
|
+
areas.push({
|
|
98
|
+
sheet: expr.sheet,
|
|
99
|
+
top: 1,
|
|
100
|
+
left: expr.leftCol,
|
|
101
|
+
bottom: 1048576,
|
|
102
|
+
right: expr.rightCol
|
|
103
|
+
});
|
|
104
|
+
break;
|
|
105
|
+
case 5 /* BoundExprKind.RowRangeRef */:
|
|
106
|
+
areas.push({
|
|
107
|
+
sheet: expr.sheet,
|
|
108
|
+
top: expr.topRow,
|
|
109
|
+
left: 1,
|
|
110
|
+
bottom: expr.bottomRow,
|
|
111
|
+
right: 16384
|
|
112
|
+
});
|
|
113
|
+
break;
|
|
114
|
+
case 6 /* BoundExprKind.Ref3D */:
|
|
115
|
+
for (const sheet of expr.sheets) {
|
|
116
|
+
if (expr.inner.kind === 2 /* BoundExprKind.CellRef */) {
|
|
117
|
+
cells.push({ sheet, row: expr.inner.row, col: expr.inner.col });
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
areas.push({
|
|
121
|
+
sheet,
|
|
122
|
+
top: expr.inner.top,
|
|
123
|
+
left: expr.inner.left,
|
|
124
|
+
bottom: expr.inner.bottom,
|
|
125
|
+
right: expr.inner.right
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
break;
|
|
130
|
+
case 7 /* BoundExprKind.BinaryOp */:
|
|
131
|
+
walkDeps(expr.left, cells, areas, tablesByName, nameResolver, visitedNames);
|
|
132
|
+
walkDeps(expr.right, cells, areas, tablesByName, nameResolver, visitedNames);
|
|
133
|
+
break;
|
|
134
|
+
case 8 /* BoundExprKind.UnaryOp */:
|
|
135
|
+
walkDeps(expr.operand, cells, areas, tablesByName, nameResolver, visitedNames);
|
|
136
|
+
break;
|
|
137
|
+
case 9 /* BoundExprKind.Percent */:
|
|
138
|
+
walkDeps(expr.operand, cells, areas, tablesByName, nameResolver, visitedNames);
|
|
139
|
+
break;
|
|
140
|
+
case 10 /* BoundExprKind.Call */:
|
|
141
|
+
for (const arg of expr.args) {
|
|
142
|
+
walkDeps(arg, cells, areas, tablesByName, nameResolver, visitedNames);
|
|
143
|
+
}
|
|
144
|
+
break;
|
|
145
|
+
case 11 /* BoundExprKind.SpecialCall */:
|
|
146
|
+
for (const arg of expr.args) {
|
|
147
|
+
walkDeps(arg, cells, areas, tablesByName, nameResolver, visitedNames);
|
|
148
|
+
}
|
|
149
|
+
break;
|
|
150
|
+
case 12 /* BoundExprKind.Array */:
|
|
151
|
+
for (const row of expr.rows) {
|
|
152
|
+
for (const elem of row) {
|
|
153
|
+
walkDeps(elem, cells, areas, tablesByName, nameResolver, visitedNames);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
break;
|
|
157
|
+
case 14 /* BoundExprKind.Lambda */:
|
|
158
|
+
walkDeps(expr.body, cells, areas, tablesByName, nameResolver, visitedNames);
|
|
159
|
+
break;
|
|
160
|
+
case 15 /* BoundExprKind.StructuredRef */:
|
|
161
|
+
// Try to resolve structured reference to static deps using the table index.
|
|
162
|
+
// Only possible when we have the table name and the table exists in the snapshot.
|
|
163
|
+
if (tablesByName && expr.tableName) {
|
|
164
|
+
const resolved = tablesByName.get(expr.tableName.toLowerCase());
|
|
165
|
+
if (resolved) {
|
|
166
|
+
const t = resolved.table;
|
|
167
|
+
const geo = (0, structured_ref_utils_1.buildTableGeometry)(t);
|
|
168
|
+
// Permissive column resolution — static-deps is conservative, so
|
|
169
|
+
// unknown column names fall back to the full table width rather
|
|
170
|
+
// than being treated as errors.
|
|
171
|
+
const colRange = (0, structured_ref_utils_1.resolveStructuredRefColumns)(expr.columns, t, "permissive");
|
|
172
|
+
if (colRange === "error") {
|
|
173
|
+
// Not reachable in permissive mode, but guard for exhaustiveness.
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
// #This Row can't be resolved statically; we still record the data
|
|
177
|
+
// range as a conservative dependency bound.
|
|
178
|
+
const rowRange = (0, structured_ref_utils_1.resolveStructuredRefRows)(expr.specials, geo);
|
|
179
|
+
let rowTop = geo.dataRowStart;
|
|
180
|
+
let rowBottom = geo.dataRowEnd;
|
|
181
|
+
if (rowRange !== "thisRow" && rowRange !== "error") {
|
|
182
|
+
rowTop = rowRange.rowTop;
|
|
183
|
+
rowBottom = rowRange.rowBottom;
|
|
184
|
+
}
|
|
185
|
+
areas.push({
|
|
186
|
+
sheet: resolved.sheetName,
|
|
187
|
+
top: rowTop,
|
|
188
|
+
left: colRange.colLeft,
|
|
189
|
+
bottom: rowBottom,
|
|
190
|
+
right: colRange.colRight
|
|
191
|
+
});
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
// Cannot resolve — no static deps (will be handled at runtime)
|
|
196
|
+
break;
|
|
197
|
+
case 1 /* BoundExprKind.Literal */:
|
|
198
|
+
// No static dependencies
|
|
199
|
+
break;
|
|
200
|
+
case 13 /* BoundExprKind.NameExpr */:
|
|
201
|
+
// Try to resolve the defined name and extract its dependencies.
|
|
202
|
+
// Guard against infinite recursion with visitedNames.
|
|
203
|
+
if (nameResolver && visitedNames && !visitedNames.has(expr.upperName)) {
|
|
204
|
+
visitedNames.add(expr.upperName);
|
|
205
|
+
const resolved = nameResolver(expr.upperName);
|
|
206
|
+
if (resolved) {
|
|
207
|
+
for (const c of resolved.deps.cells) {
|
|
208
|
+
cells.push(c);
|
|
209
|
+
}
|
|
210
|
+
for (const a of resolved.deps.areas) {
|
|
211
|
+
areas.push(a);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
// ============================================================================
|
|
219
|
+
// Volatility / Dynamic Ref / Dynamic Array Detection
|
|
220
|
+
// ============================================================================
|
|
221
|
+
// Excel's volatile-function list: any formula containing one of these
|
|
222
|
+
// must be re-evaluated on every calc pass, because the result can change
|
|
223
|
+
// without any explicit input change. INDIRECT / OFFSET are additionally
|
|
224
|
+
// flagged as "dynamic ref" (their dependency set isn't known at compile
|
|
225
|
+
// time), but they're also volatile in the usual sense — the target
|
|
226
|
+
// cell's value may change even when the INDIRECT string itself is
|
|
227
|
+
// constant. INFO and CELL with the "row"/"col" info-type also qualify
|
|
228
|
+
// but those require per-invocation arg inspection; the coarse opt-in
|
|
229
|
+
// below is intentionally conservative.
|
|
230
|
+
const VOLATILE_FUNCTIONS = new Set([
|
|
231
|
+
"RAND",
|
|
232
|
+
"RANDBETWEEN",
|
|
233
|
+
"RANDARRAY",
|
|
234
|
+
"NOW",
|
|
235
|
+
"TODAY",
|
|
236
|
+
"INDIRECT",
|
|
237
|
+
"OFFSET",
|
|
238
|
+
"INFO",
|
|
239
|
+
"CELL"
|
|
240
|
+
]);
|
|
241
|
+
const DYNAMIC_REF_FUNCTIONS = new Set(["INDIRECT", "OFFSET"]);
|
|
242
|
+
/**
|
|
243
|
+
* Function names that naturally produce arrays and should trigger spill
|
|
244
|
+
* behavior even when `isDynamicArray` is not explicitly set in the XLSX model.
|
|
245
|
+
*/
|
|
246
|
+
const DYNAMIC_ARRAY_FUNCTION_NAMES = new Set([
|
|
247
|
+
"FILTER",
|
|
248
|
+
"SORT",
|
|
249
|
+
"UNIQUE",
|
|
250
|
+
"SORTBY",
|
|
251
|
+
"SEQUENCE",
|
|
252
|
+
"RANDARRAY",
|
|
253
|
+
"TOCOL",
|
|
254
|
+
"TOROW",
|
|
255
|
+
"CHOOSEROWS",
|
|
256
|
+
"CHOOSECOLS",
|
|
257
|
+
"VSTACK",
|
|
258
|
+
"HSTACK",
|
|
259
|
+
"WRAPROWS",
|
|
260
|
+
"WRAPCOLS",
|
|
261
|
+
"EXPAND",
|
|
262
|
+
"TAKE",
|
|
263
|
+
"DROP"
|
|
264
|
+
]);
|
|
265
|
+
/**
|
|
266
|
+
* Check if the formula's top-level expression is a known dynamic array
|
|
267
|
+
* function. Checks both the raw AST (for prefixed names like `_XLFN.FILTER`)
|
|
268
|
+
* and the bound expression (for the canonical uppercase name).
|
|
269
|
+
*/
|
|
270
|
+
function detectDynamicArrayFunction(ast, bound) {
|
|
271
|
+
// Check AST level (handles _XLFN. prefixed names)
|
|
272
|
+
if (ast.type === 9 /* NodeType.FunctionCall */) {
|
|
273
|
+
const upper = ast.name.toUpperCase();
|
|
274
|
+
if (DYNAMIC_ARRAY_FUNCTION_NAMES.has(upper)) {
|
|
275
|
+
return true;
|
|
276
|
+
}
|
|
277
|
+
const canonical = (0, token_types_1.stripFunctionPrefix)(upper);
|
|
278
|
+
if (DYNAMIC_ARRAY_FUNCTION_NAMES.has(canonical)) {
|
|
279
|
+
return true;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
// Check bound expression level
|
|
283
|
+
if (bound.kind === 10 /* BoundExprKind.Call */ && DYNAMIC_ARRAY_FUNCTION_NAMES.has(bound.name)) {
|
|
284
|
+
return true;
|
|
285
|
+
}
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Check if the formula's top-level expression is SUBTOTAL or AGGREGATE.
|
|
290
|
+
*
|
|
291
|
+
* Excel's SUBTOTAL/AGGREGATE functions deliberately skip any cell whose
|
|
292
|
+
* own source formula is itself a SUBTOTAL or AGGREGATE call — this is
|
|
293
|
+
* what makes the classic "totals row inside a filtered range" case not
|
|
294
|
+
* double-count. `buildRangeArray` reads this flag off the compiled
|
|
295
|
+
* formula to decide whether to set `subtotalMask[r][c]`.
|
|
296
|
+
*/
|
|
297
|
+
function detectSubtotalOutput(ast, bound) {
|
|
298
|
+
if (ast.type === 9 /* NodeType.FunctionCall */) {
|
|
299
|
+
const upper = ast.name.toUpperCase();
|
|
300
|
+
const canonical = (0, token_types_1.stripFunctionPrefix)(upper);
|
|
301
|
+
if (canonical === "SUBTOTAL" || canonical === "AGGREGATE") {
|
|
302
|
+
return true;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
if (bound.kind === 10 /* BoundExprKind.Call */ &&
|
|
306
|
+
(bound.name === "SUBTOTAL" || bound.name === "AGGREGATE")) {
|
|
307
|
+
return true;
|
|
308
|
+
}
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Analyze a bound expression for volatile functions and dynamic references.
|
|
313
|
+
*
|
|
314
|
+
* @param nameResolver - Optional; if a NameExpr resolves to a formula-based
|
|
315
|
+
* defined name containing INDIRECT/OFFSET, the outer formula inherits
|
|
316
|
+
* `hasDynamicRefs = true`.
|
|
317
|
+
*/
|
|
318
|
+
function analyzeExpr(expr, nameResolver) {
|
|
319
|
+
let isVolatile = false;
|
|
320
|
+
let hasDynamicRefs = false;
|
|
321
|
+
let containsLambda = false;
|
|
322
|
+
walkAnalyze(expr);
|
|
323
|
+
return { isVolatile, hasDynamicRefs, containsLambda };
|
|
324
|
+
function walkAnalyze(e) {
|
|
325
|
+
switch (e.kind) {
|
|
326
|
+
case 10 /* BoundExprKind.Call */:
|
|
327
|
+
if (VOLATILE_FUNCTIONS.has(e.name)) {
|
|
328
|
+
isVolatile = true;
|
|
329
|
+
}
|
|
330
|
+
for (const arg of e.args) {
|
|
331
|
+
walkAnalyze(arg);
|
|
332
|
+
}
|
|
333
|
+
break;
|
|
334
|
+
case 11 /* BoundExprKind.SpecialCall */:
|
|
335
|
+
if (DYNAMIC_REF_FUNCTIONS.has(e.name)) {
|
|
336
|
+
hasDynamicRefs = true;
|
|
337
|
+
}
|
|
338
|
+
if (VOLATILE_FUNCTIONS.has(e.name)) {
|
|
339
|
+
isVolatile = true;
|
|
340
|
+
}
|
|
341
|
+
for (const arg of e.args) {
|
|
342
|
+
walkAnalyze(arg);
|
|
343
|
+
}
|
|
344
|
+
break;
|
|
345
|
+
case 14 /* BoundExprKind.Lambda */:
|
|
346
|
+
containsLambda = true;
|
|
347
|
+
walkAnalyze(e.body);
|
|
348
|
+
break;
|
|
349
|
+
case 13 /* BoundExprKind.NameExpr */:
|
|
350
|
+
// If the name resolves to a formula that contains dynamic refs
|
|
351
|
+
// or volatile functions, the outer formula inherits both flags.
|
|
352
|
+
// Forgetting to propagate `isVolatile` meant that a defined name
|
|
353
|
+
// pointing at `NOW()` stayed cached between calculations — the
|
|
354
|
+
// bug drove R5-P0-5.
|
|
355
|
+
if (nameResolver) {
|
|
356
|
+
const resolved = nameResolver(e.upperName);
|
|
357
|
+
if (resolved?.hasDynamicRefs) {
|
|
358
|
+
hasDynamicRefs = true;
|
|
359
|
+
}
|
|
360
|
+
if (resolved?.isVolatile) {
|
|
361
|
+
isVolatile = true;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
break;
|
|
365
|
+
case 7 /* BoundExprKind.BinaryOp */:
|
|
366
|
+
walkAnalyze(e.left);
|
|
367
|
+
walkAnalyze(e.right);
|
|
368
|
+
break;
|
|
369
|
+
case 8 /* BoundExprKind.UnaryOp */:
|
|
370
|
+
walkAnalyze(e.operand);
|
|
371
|
+
break;
|
|
372
|
+
case 9 /* BoundExprKind.Percent */:
|
|
373
|
+
walkAnalyze(e.operand);
|
|
374
|
+
break;
|
|
375
|
+
case 12 /* BoundExprKind.Array */:
|
|
376
|
+
for (const row of e.rows) {
|
|
377
|
+
for (const elem of row) {
|
|
378
|
+
walkAnalyze(elem);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
break;
|
|
382
|
+
default:
|
|
383
|
+
// Literal, CellRef, AreaRef, etc. — no children to analyze
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|