@sheetxl/sdk 0.7.26 → 0.7.28-beta.1
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/THIRD-PARTY-NOTICES.md +34 -0
- package/browser/cjs/B7_pDFYCVzt-3hUs.cjs +1 -0
- package/browser/cjs/D590vnHyyrIYenQ7.cjs +33 -0
- package/browser/cjs/DfVZ_U2YapkL3Y3y.cjs +1 -0
- package/browser/cjs/DsII2GRIYGbaZjIE.cjs +1 -0
- package/browser/cjs/Dv3x6zut1ZRUt3IF.cjs +10 -0
- package/browser/cjs/index.cjs +3 -6
- package/browser/cjs/nE4y6hua6AwWSil7.cjs +1 -0
- package/browser/cjs/nMss3hrHzgX9s6dC.cjs +57 -0
- package/browser/esm/AyOmyt_vaPirbWnn.mjs +49986 -0
- package/browser/esm/BJ5lU2Y0r4Vy8n4q.mjs +109 -0
- package/browser/esm/BvaEmG7AaTSm7dFt.mjs +818 -0
- package/browser/esm/CWKJatjtHKfWtM2b.mjs +503 -0
- package/browser/esm/CkhE5KvHQvKzw4Ll.mjs +4436 -0
- package/browser/esm/Dpwf1IgHZjpEpK-K.mjs +24 -0
- package/browser/esm/index.mjs +3225 -62
- package/browser/esm/uFvYxePB3xD2HrP0.mjs +14 -0
- package/licenses/dependencies.txt +74 -193
- package/node/esm/CYXOvL3qwWeDE0xf.mjs +114 -0
- package/node/esm/Dgmq_XXiU2AQw1tX.mjs +22 -0
- package/node/esm/index.mjs +53619 -23254
- package/node/esm/qxrG4h6T0dAo8eZ6.mjs +837 -0
- package/package.json +19 -14
- package/resources/contents.json +21 -0
- package/resources/locales/contents.json +19 -0
- package/resources/locales/de/grammar.json +16 -0
- package/resources/locales/de/model.msg.json +510 -0
- package/resources/locales/en/model.msg.json +525 -0
- package/types/index.d.ts +2 -21294
- package/types/scripting-enums.json +1009 -0
- package/types/scripting.d.ts +26540 -31455
- package/types/src/address/AddressUtils.d.ts +252 -0
- package/types/src/address/_AddressMessages.d.ts +7 -0
- package/types/src/address/index.d.ts +35 -0
- package/types/src/anchored/AbstractAnchored.d.ts +200 -0
- package/types/src/anchored/Anchored.d.ts +154 -0
- package/types/src/anchored/AnchoredMap.d.ts +178 -0
- package/types/src/anchored/IAnchored.d.ts +118 -0
- package/types/src/anchored/IAnchoredMap.d.ts +207 -0
- package/types/src/anchored/_AnchorMessages.d.ts +3 -0
- package/types/src/anchored/index.d.ts +2 -0
- package/types/src/autoFill/AutoFill.d.ts +161 -0
- package/types/src/autoFill/IAutoFill.d.ts +117 -0
- package/types/src/autoFill/index.d.ts +3 -0
- package/types/src/border/IBorder.d.ts +284 -0
- package/types/src/border/index.d.ts +2 -0
- package/types/src/calculation/Calculation.d.ts +440 -0
- package/types/src/calculation/FormulaLiterals.d.ts +18 -0
- package/types/src/calculation/ICalculation.d.ts +1016 -0
- package/types/src/calculation/INamedFormulasCollection.d.ts +141 -0
- package/types/src/calculation/NamedFormulaCollection.d.ts +671 -0
- package/types/src/calculation/TokenType.d.ts +117 -0
- package/types/src/calculation/Types.d.ts +110 -0
- package/types/src/calculation/_CalculationMessages.d.ts +3 -0
- package/types/src/calculation/builtInNames.d.ts +2 -0
- package/types/src/calculation/compiler/ASTTypes.d.ts +180 -0
- package/types/src/calculation/compiler/CompilerLocale.d.ts +69 -0
- package/types/src/calculation/compiler/CompilerUtils.d.ts +331 -0
- package/types/src/calculation/compiler/FormulaCompiler.d.ts +69 -0
- package/types/src/calculation/compiler/FormulaLexer.d.ts +85 -0
- package/types/src/calculation/compiler/FormulaParser.d.ts +270 -0
- package/types/src/calculation/compiler/FormulaSeparators.d.ts +35 -0
- package/types/src/calculation/compiler/LiteTransform.d.ts +15 -0
- package/types/src/calculation/compiler/ParserUtils.d.ts +167 -0
- package/types/src/calculation/compiler/SRLexer.d.ts +19 -0
- package/types/src/calculation/compiler/SRParser.d.ts +38 -0
- package/types/src/calculation/compiler/Types.d.ts +274 -0
- package/types/src/calculation/compiler/index.d.ts +3 -0
- package/types/src/calculation/executor/CalcExecutor.d.ts +115 -0
- package/types/src/calculation/executor/CalcExecutorUtils.d.ts +11 -0
- package/types/src/calculation/executor/index.d.ts +3 -0
- package/types/src/calculation/formula/Formula.d.ts +168 -0
- package/types/src/calculation/formula/FormulaBlock.d.ts +207 -0
- package/types/src/calculation/formula/IFormulaBlock.d.ts +181 -0
- package/types/src/calculation/formula/LambdaValue.d.ts +166 -0
- package/types/src/calculation/formula/TokenUtils.d.ts +26 -0
- package/types/src/calculation/formula/index.d.ts +4 -0
- package/types/src/calculation/functions/Operators.d.ts +30 -0
- package/types/src/calculation/functions/index.d.ts +2 -0
- package/types/src/calculation/functions/initializeFunctions.d.ts +22 -0
- package/types/src/calculation/grid/CalcGrid.d.ts +205 -0
- package/types/src/calculation/grid/CalcGridUtils.d.ts +172 -0
- package/types/src/calculation/grid/ICalcGrid.d.ts +500 -0
- package/types/src/calculation/grid/index.d.ts +3 -0
- package/types/src/calculation/index.d.ts +5 -0
- package/types/src/calculation/spatial/ContentfulSpatialValue.d.ts +25 -0
- package/types/src/calculation/spatial/FormulaSpatialValue.d.ts +120 -0
- package/types/src/calculation/spatial/PrecedentSpatialValue.d.ts +115 -0
- package/types/src/calculation/spatial/SpillEntry.d.ts +40 -0
- package/types/src/calculation/spatial/index.d.ts +5 -0
- package/types/src/calculation/state/CalcNode.d.ts +71 -0
- package/types/src/calculation/state/CalcScope.d.ts +35 -0
- package/types/src/calculation/state/CalcState.d.ts +28 -0
- package/types/src/calculation/state/CalculationContext.d.ts +125 -0
- package/types/src/calculation/state/IContextContainer.d.ts +320 -0
- package/types/src/calculation/state/index.d.ts +6 -0
- package/types/src/calculation/symbol/FunctionSymbolProvider.d.ts +44 -0
- package/types/src/calculation/symbol/ISymbolRegistry.d.ts +93 -0
- package/types/src/calculation/symbol/IndirectSymbolProvider.d.ts +144 -0
- package/types/src/calculation/symbol/SheetSymbolProvider.d.ts +18 -0
- package/types/src/calculation/symbol/SymbolRegistry.d.ts +19 -0
- package/types/src/calculation/symbol/TableColumnSymbolProvider.d.ts +21 -0
- package/types/src/calculation/symbol/TableSymbolProvider.d.ts +19 -0
- package/types/src/calculation/symbol/index.d.ts +9 -0
- package/types/src/cell/ICell.d.ts +672 -0
- package/types/src/cell/ICellHeader.d.ts +142 -0
- package/types/src/cell/ICellProtection.d.ts +41 -0
- package/types/src/cell/index.d.ts +4 -0
- package/types/src/cellRange/ICellHeaderRange.d.ts +306 -0
- package/types/src/cellRange/ICellHeaderRanges.d.ts +107 -0
- package/types/src/cellRange/ICellRange.d.ts +2509 -0
- package/types/src/cellRange/ICellRanges.d.ts +407 -0
- package/types/src/cellRange/ICellRegion.d.ts +133 -0
- package/types/src/cellRange/_GraphNode.d.ts +38 -0
- package/types/src/cellRange/index.d.ts +6 -0
- package/types/src/chart/Chart.d.ts +53 -0
- package/types/src/chart/IChart.d.ts +42 -0
- package/types/src/chart/index.d.ts +5 -0
- package/types/src/collections/ArraysGrid.d.ts +72 -0
- package/types/src/collections/BooleanList.d.ts +67 -0
- package/types/src/collections/GridMap.d.ts +47 -0
- package/types/src/collections/HashMap.d.ts +15 -0
- package/types/src/collections/IGrid.d.ts +278 -0
- package/types/src/collections/IList.d.ts +89 -0
- package/types/src/collections/IMap.d.ts +45 -0
- package/types/src/collections/IReadableList.d.ts +120 -0
- package/types/src/collections/ISortedMap.d.ts +171 -0
- package/types/src/collections/ISparseGrid.d.ts +61 -0
- package/types/src/collections/ISparseList.d.ts +103 -0
- package/types/src/collections/ISpatialMap.d.ts +515 -0
- package/types/src/collections/ISpatialMap3D.d.ts +116 -0
- package/types/src/collections/IWritableList.d.ts +41 -0
- package/types/src/collections/ImmutableList.d.ts +52 -0
- package/types/src/collections/IteratorUtils.d.ts +91 -0
- package/types/src/collections/MixedTypedArrayList.d.ts +140 -0
- package/types/src/collections/OverlappingRangeIterator.d.ts +91 -0
- package/types/src/collections/RTree.d.ts +111 -0
- package/types/src/collections/RepeatingList.d.ts +20 -0
- package/types/src/collections/SortedMap.d.ts +396 -0
- package/types/src/collections/SparseGrid.d.ts +99 -0
- package/types/src/collections/SparseList.d.ts +90 -0
- package/types/src/collections/SpatialMap.d.ts +102 -0
- package/types/src/collections/SpatialMap3D.d.ts +64 -0
- package/types/src/collections/Tuple.d.ts +160 -0
- package/types/src/collections/_CollectionUtils.d.ts +25 -0
- package/types/src/collections/_GridUtils.d.ts +268 -0
- package/types/src/collections/_RunUtils.d.ts +170 -0
- package/types/src/collections/_SpatialUtils.d.ts +115 -0
- package/types/src/collections/index.d.ts +21 -0
- package/types/src/color/Color.d.ts +120 -0
- package/types/src/color/ColorSpace.d.ts +45 -0
- package/types/src/color/IColor.d.ts +1110 -0
- package/types/src/color/_BuiltInIndexDefs.d.ts +4 -0
- package/types/src/color/_BuiltInNamedDefs.d.ts +29 -0
- package/types/src/color/_BuiltInSchemeDefs.d.ts +7 -0
- package/types/src/color/_ColorUtils.d.ts +93 -0
- package/types/src/color/index.d.ts +3 -0
- package/types/src/comment/IComment.d.ts +108 -0
- package/types/src/comment/index.d.ts +2 -0
- package/types/src/condition/AnchoredConditional.d.ts +263 -0
- package/types/src/condition/BuiltInOperators/AbstractOperator.d.ts +83 -0
- package/types/src/condition/BuiltInOperators/AfterEqualToOperator.d.ts +8 -0
- package/types/src/condition/BuiltInOperators/AfterOperator.d.ts +8 -0
- package/types/src/condition/BuiltInOperators/AndOperator.d.ts +12 -0
- package/types/src/condition/BuiltInOperators/AverageOperator.d.ts +12 -0
- package/types/src/condition/BuiltInOperators/BeforeEqualToOperator.d.ts +8 -0
- package/types/src/condition/BuiltInOperators/BeforeOperator.d.ts +8 -0
- package/types/src/condition/BuiltInOperators/BetweenOperator.d.ts +12 -0
- package/types/src/condition/BuiltInOperators/BlankOperator.d.ts +9 -0
- package/types/src/condition/BuiltInOperators/ColorOperator.d.ts +8 -0
- package/types/src/condition/BuiltInOperators/ContainsOperator.d.ts +8 -0
- package/types/src/condition/BuiltInOperators/EndsWithOperator.d.ts +8 -0
- package/types/src/condition/BuiltInOperators/EqualToOperator.d.ts +11 -0
- package/types/src/condition/BuiltInOperators/ErrorOperator.d.ts +9 -0
- package/types/src/condition/BuiltInOperators/ExpressionOperator.d.ts +17 -0
- package/types/src/condition/BuiltInOperators/GreaterThanEqualToOperator.d.ts +8 -0
- package/types/src/condition/BuiltInOperators/GreaterThanOperator.d.ts +8 -0
- package/types/src/condition/BuiltInOperators/IconOperator.d.ts +8 -0
- package/types/src/condition/BuiltInOperators/InSetOperator.d.ts +14 -0
- package/types/src/condition/BuiltInOperators/LessThanEqualToOperator.d.ts +8 -0
- package/types/src/condition/BuiltInOperators/LessThanOperator.d.ts +8 -0
- package/types/src/condition/BuiltInOperators/NotOperator.d.ts +12 -0
- package/types/src/condition/BuiltInOperators/OrOperator.d.ts +12 -0
- package/types/src/condition/BuiltInOperators/StartsWithOperator.d.ts +8 -0
- package/types/src/condition/BuiltInOperators/TimePeriodOperator.d.ts +13 -0
- package/types/src/condition/BuiltInOperators/TopNOperator.d.ts +12 -0
- package/types/src/condition/BuiltInOperators/UniqueOperator.d.ts +8 -0
- package/types/src/condition/BuiltInOperators/ValidEmailOperator.d.ts +8 -0
- package/types/src/condition/BuiltInOperators/ValidUrlOperator.d.ts +8 -0
- package/types/src/condition/BuiltInOperators/index.d.ts +59 -0
- package/types/src/condition/BuiltinSelectors/BaseSelector.d.ts +43 -0
- package/types/src/condition/BuiltinSelectors/DateSelector.d.ts +14 -0
- package/types/src/condition/BuiltinSelectors/ListSelector.d.ts +12 -0
- package/types/src/condition/BuiltinSelectors/TextLengthSelector.d.ts +16 -0
- package/types/src/condition/BuiltinSelectors/TimeSelector.d.ts +14 -0
- package/types/src/condition/BuiltinSelectors/WholeSelector.d.ts +14 -0
- package/types/src/condition/BuiltinSelectors/index.d.ts +18 -0
- package/types/src/condition/Condition.d.ts +123 -0
- package/types/src/condition/ICondition.d.ts +915 -0
- package/types/src/condition/_ConditionUtils.d.ts +190 -0
- package/types/src/condition/index.d.ts +3 -0
- package/types/src/conditionalFormat/ConditionalEntry.d.ts +20 -0
- package/types/src/conditionalFormat/ConditionalFormat.d.ts +190 -0
- package/types/src/conditionalFormat/ConditionalFormatCollection.d.ts +20 -0
- package/types/src/conditionalFormat/IConditionalFormat.d.ts +518 -0
- package/types/src/conditionalFormat/IConditionalFormatCollection.d.ts +70 -0
- package/types/src/conditionalFormat/_ConditionalMessages.d.ts +2 -0
- package/types/src/conditionalFormat/index.d.ts +3 -0
- package/types/src/dataValidation/DataValidation.d.ts +121 -0
- package/types/src/dataValidation/DataValidationCollection.d.ts +20 -0
- package/types/src/dataValidation/IDataValidation.d.ts +327 -0
- package/types/src/dataValidation/IDataValidationCollection.d.ts +63 -0
- package/types/src/dataValidation/_DataValidationMessages.d.ts +2 -0
- package/types/src/dataValidation/_Utils.d.ts +10 -0
- package/types/src/dataValidation/index.d.ts +3 -0
- package/types/src/date/DateUtils.d.ts +8 -0
- package/types/src/date/_DateUtils.d.ts +122 -0
- package/types/src/date/index.d.ts +2 -0
- package/types/src/externalBook/ExternalBookCollection.d.ts +36 -0
- package/types/src/externalBook/IExternalBook.d.ts +97 -0
- package/types/src/externalBook/IExternalBookCollection.d.ts +29 -0
- package/types/src/externalBook/index.d.ts +3 -0
- package/types/src/fill/IEffect.d.ts +389 -0
- package/types/src/fill/IFill.d.ts +597 -0
- package/types/src/fill/IStroke.d.ts +265 -0
- package/types/src/fill/_BuiltInPatterns.d.ts +27 -0
- package/types/src/fill/index.d.ts +4 -0
- package/types/src/filter/IFilter.d.ts +83 -0
- package/types/src/filter/index.d.ts +2 -0
- package/types/src/font/CanvasFontMeasurer.d.ts +25 -0
- package/types/src/font/ExtendedTextMetrics.d.ts +1 -0
- package/types/src/font/Font.d.ts +19 -0
- package/types/src/font/FontKitFontMeasurer.d.ts +11 -0
- package/types/src/font/FontUtils.d.ts +9 -0
- package/types/src/font/IFont.d.ts +261 -0
- package/types/src/font/IFontCollection.d.ts +31 -0
- package/types/src/font/SimpleFontMeasurer.d.ts +4 -0
- package/types/src/font/_FontUtils.d.ts +22 -0
- package/types/src/font/index.d.ts +5 -0
- package/types/src/history/IHistory.d.ts +110 -0
- package/types/src/history/index.d.ts +2 -0
- package/types/src/hyperlink/IHyperlink.d.ts +96 -0
- package/types/src/hyperlink/_Hyperlink.d.ts +21 -0
- package/types/src/hyperlink/index.d.ts +2 -0
- package/types/src/i18n/LanguagePack.d.ts +97 -0
- package/types/src/i18n/LocaleProfile.d.ts +15 -0
- package/types/src/i18n/_CurrencyData.d.ts +20 -0
- package/types/src/i18n/functionLocales.d.ts +6 -0
- package/types/src/i18n/index.d.ts +4 -0
- package/types/src/i18n/locales.d.ts +3 -0
- package/types/src/index.d.ts +71 -0
- package/types/src/io/AbstractBackingStore.d.ts +53 -0
- package/types/src/io/ArrayBackingStore.d.ts +34 -0
- package/types/src/io/IWorkbookIO.d.ts +1322 -0
- package/types/src/io/WorkbookIO.d.ts +91 -0
- package/types/src/io/WorkbookOrigin.d.ts +114 -0
- package/types/src/io/WorkbookRegistry.d.ts +49 -0
- package/types/src/io/index.d.ts +5 -0
- package/types/src/lib/file/file.browser.d.ts +41 -0
- package/types/src/lib/file/file.node.d.ts +25 -0
- package/types/src/lib/utils/_Utils.d.ts +20 -0
- package/types/src/lib/utils/banner.d.ts +6 -0
- package/types/src/lib/utils/utils.browser.d.ts +28 -0
- package/types/src/lib/utils/utils.node.d.ts +42 -0
- package/types/src/license/LicenseDetails.d.ts +22 -0
- package/types/src/license/LicenseManager.d.ts +63 -0
- package/types/src/license/index.d.ts +3 -0
- package/types/src/license/license-key.d.ts +33 -0
- package/types/src/listener/IListener.d.ts +62 -0
- package/types/src/listener/ListenerEmitter.d.ts +47 -0
- package/types/src/listener/index.d.ts +2 -0
- package/types/src/model/AbstractModel.d.ts +90 -0
- package/types/src/model/IModel.d.ts +108 -0
- package/types/src/model/_ModelMessages.d.ts +2 -0
- package/types/src/model/index.d.ts +3 -0
- package/types/src/movable/CustomElement.d.ts +42 -0
- package/types/src/movable/ICustomElement.d.ts +29 -0
- package/types/src/movable/IGroup.d.ts +30 -0
- package/types/src/movable/IMovable.d.ts +327 -0
- package/types/src/movable/IMovableCollection.d.ts +129 -0
- package/types/src/movable/IMovableSelection.d.ts +49 -0
- package/types/src/movable/Movable.d.ts +221 -0
- package/types/src/movable/MovableCollection.d.ts +29 -0
- package/types/src/movable/_MovableUtils.d.ts +4 -0
- package/types/src/movable/index.d.ts +4 -0
- package/types/src/named/AbstractNamed.d.ts +41 -0
- package/types/src/named/INamed.d.ts +225 -0
- package/types/src/named/INamedCollection.d.ts +230 -0
- package/types/src/named/NamedCollection.d.ts +302 -0
- package/types/src/named/_BuiltInNamed.d.ts +6 -0
- package/types/src/named/index.d.ts +3 -0
- package/types/src/numFmt/BuiltInFormats.d.ts +49 -0
- package/types/src/numFmt/IFormatEngine.d.ts +149 -0
- package/types/src/numFmt/NumberFormatBuilder.d.ts +46 -0
- package/types/src/numFmt/NumberFormatParser.d.ts +168 -0
- package/types/src/numFmt/NumberFormatStyles.d.ts +43 -0
- package/types/src/numFmt/NumberFormatType.d.ts +79 -0
- package/types/src/numFmt/NumfmtFormatEngine.d.ts +33 -0
- package/types/src/numFmt/_BuiltInNumberFormats.d.ts +12 -0
- package/types/src/numFmt/_FormatCell.d.ts +52 -0
- package/types/src/numFmt/_NumFmtUtils.d.ts +102 -0
- package/types/src/numFmt/index.d.ts +105 -0
- package/types/src/numFmt/vendor/numfmt/_sheetxl.d.ts +15 -0
- package/types/src/numFmt/vendor/numfmt/index.d.ts +721 -0
- package/types/src/picture/IPicture.d.ts +69 -0
- package/types/src/picture/Picture.d.ts +67 -0
- package/types/src/picture/index.d.ts +2 -0
- package/types/src/primitives/CompositeRangeStats.d.ts +63 -0
- package/types/src/primitives/Criteria.d.ts +35 -0
- package/types/src/primitives/FormulaContext.d.ts +2 -0
- package/types/src/primitives/PrimitiveUtils.d.ts +255 -0
- package/types/src/primitives/Range.d.ts +221 -0
- package/types/src/primitives/RangeStats.d.ts +48 -0
- package/types/src/primitives/ReferenceRange.d.ts +19 -0
- package/types/src/primitives/Runtime.d.ts +55 -0
- package/types/src/primitives/ScalarCollation.d.ts +174 -0
- package/types/src/primitives/TextFold.d.ts +62 -0
- package/types/src/primitives/_PrimitiveMessages.d.ts +3 -0
- package/types/src/primitives/index.d.ts +7 -0
- package/types/src/primitives/stats/AggregateStats.d.ts +119 -0
- package/types/src/primitives/stats/Cancellation.d.ts +43 -0
- package/types/src/primitives/stats/FrequencyStats.d.ts +94 -0
- package/types/src/primitives/stats/Ranked.d.ts +26 -0
- package/types/src/primitives/stats/ScalarOrder.d.ts +18 -0
- package/types/src/primitives/stats/SortedNumbers.d.ts +48 -0
- package/types/src/primitives/stats/index.d.ts +7 -0
- package/types/src/print/IPrint.d.ts +234 -0
- package/types/src/print/index.d.ts +2 -0
- package/types/src/protectedRange/IProtectedRange.d.ts +239 -0
- package/types/src/protectedRange/IProtectedRangeCollection.d.ts +73 -0
- package/types/src/protectedRange/ProtectedRange.d.ts +101 -0
- package/types/src/protectedRange/ProtectedRangeCollection.d.ts +21 -0
- package/types/src/protectedRange/index.d.ts +3 -0
- package/types/src/protection/DefaultProtection.d.ts +43 -0
- package/types/src/protection/IProtection.d.ts +170 -0
- package/types/src/protection/PasswordHasher.d.ts +35 -0
- package/types/src/protection/index.d.ts +6 -0
- package/types/src/resource/IResource.d.ts +98 -0
- package/types/src/resource/IResourceCollection.d.ts +96 -0
- package/types/src/resource/Resource.d.ts +39 -0
- package/types/src/resource/ResourceCollection.d.ts +19 -0
- package/types/src/resource/_ResourceMessages.d.ts +4 -0
- package/types/src/resource/index.d.ts +5 -0
- package/types/src/resource/resourceKinds.d.ts +23 -0
- package/types/src/richData/index.d.ts +1 -0
- package/types/src/scripting/FunctionCollection.d.ts +88 -0
- package/types/src/scripting/IFunctionCollection.d.ts +208 -0
- package/types/src/scripting/IModule.d.ts +82 -0
- package/types/src/scripting/IModuleCollection.d.ts +79 -0
- package/types/src/scripting/IScript.d.ts +289 -0
- package/types/src/scripting/ITypedFunction.d.ts +61 -0
- package/types/src/scripting/MacroFunction.d.ts +15 -0
- package/types/src/scripting/Module.d.ts +39 -0
- package/types/src/scripting/ModuleCollection.d.ts +56 -0
- package/types/src/scripting/Runtime.d.ts +16 -0
- package/types/src/scripting/Scripts.d.ts +79 -0
- package/types/src/scripting/TypedFunction.d.ts +161 -0
- package/types/src/scripting/_FunctionIndex.d.ts +111 -0
- package/types/src/scripting/_FunctionMessages.d.ts +6 -0
- package/types/src/scripting/_ModuleUtils.d.ts +5 -0
- package/types/src/scripting/_ScriptUtils.d.ts +18 -0
- package/types/src/scripting/enumManifest.browser.d.ts +9 -0
- package/types/src/scripting/enumManifest.node.d.ts +13 -0
- package/types/src/scripting/index.d.ts +4 -0
- package/types/src/selection/IRangeSelection.d.ts +307 -0
- package/types/src/selection/RangeSelection.d.ts +144 -0
- package/types/src/selection/_RangeSelectionUtils.d.ts +32 -0
- package/types/src/selection/index.d.ts +2 -0
- package/types/src/shape/IShape.d.ts +279 -0
- package/types/src/shape/Shape.d.ts +54 -0
- package/types/src/shape/index.d.ts +2 -0
- package/types/src/sheet/CellRegion.d.ts +106 -0
- package/types/src/sheet/ICellContainerOptions.d.ts +97 -0
- package/types/src/sheet/ISheet.d.ts +1074 -0
- package/types/src/sheet/ISheetCollection.d.ts +70 -0
- package/types/src/sheet/NamedCellRange.d.ts +45 -0
- package/types/src/sheet/NamedRange.d.ts +30 -0
- package/types/src/sheet/Sheet.d.ts +1068 -0
- package/types/src/sheet/SheetCell.d.ts +335 -0
- package/types/src/sheet/SheetCollection.d.ts +18 -0
- package/types/src/sheet/SheetRange.d.ts +362 -0
- package/types/src/sheet/SheetRanges.d.ts +225 -0
- package/types/src/sheet/_CopyUtils.d.ts +33 -0
- package/types/src/sheet/_InvalidSheetRange.d.ts +70 -0
- package/types/src/sheet/_SheetAutoFitUtils.d.ts +18 -0
- package/types/src/sheet/_SheetCoords.d.ts +54 -0
- package/types/src/sheet/_SheetFilterUtils.d.ts +9 -0
- package/types/src/sheet/_SheetMessages.d.ts +11 -0
- package/types/src/sheet/_SheetMutations.d.ts +137 -0
- package/types/src/sheet/_SheetSortUtils.d.ts +9 -0
- package/types/src/sheet/_SheetStateReader.d.ts +161 -0
- package/types/src/sheet/_SheetStateTypes.d.ts +446 -0
- package/types/src/sheet/_SheetUtils.d.ts +265 -0
- package/types/src/sheet/clipboard/IHTMLParser.d.ts +92 -0
- package/types/src/sheet/clipboard/RangeClipboardItems.d.ts +55 -0
- package/types/src/sheet/clipboard/SheetHTMLTableParser.d.ts +29 -0
- package/types/src/sheet/clipboard/SheetHTMLTableWriter.d.ts +46 -0
- package/types/src/sheet/clipboard/_ClipboardUtils.d.ts +10 -0
- package/types/src/sheet/clipboard/index.d.ts +2 -0
- package/types/src/sheet/index.d.ts +6 -0
- package/types/src/sheet/listener/RangesListener.d.ts +32 -0
- package/types/src/sheet/listener/RangesListenerEntry.d.ts +19 -0
- package/types/src/sheet/listener/index.d.ts +3 -0
- package/types/src/sheet/spatial/MergeEntry.d.ts +17 -0
- package/types/src/sheet/spatial/index.d.ts +2 -0
- package/types/src/sheet/style/SheetCellStyle.d.ts +540 -0
- package/types/src/sheet/style/SheetDirectStyle.d.ts +130 -0
- package/types/src/sheet/style/SheetNamedStyle.d.ts +47 -0
- package/types/src/sheet/style/SheetTableStyle.d.ts +47 -0
- package/types/src/sheet/style/UsedRangeSpatialMap.d.ts +80 -0
- package/types/src/sheet/style/_Resolvers.d.ts +41 -0
- package/types/src/sheet/style/_StyleUtils.d.ts +69 -0
- package/types/src/sheet/style/index.d.ts +1 -0
- package/types/src/sheetHeader/ISheetHeader.d.ts +217 -0
- package/types/src/sheetHeader/SheetCellHeader.d.ts +61 -0
- package/types/src/sheetHeader/SheetCellHeaderRange.d.ts +54 -0
- package/types/src/sheetHeader/SheetCellHeaderRanges.d.ts +46 -0
- package/types/src/sheetHeader/SheetHeader.d.ts +257 -0
- package/types/src/sheetHeader/_HeaderUtils.d.ts +94 -0
- package/types/src/sheetHeader/_InvalidSheetHeaderRange.d.ts +7 -0
- package/types/src/sheetHeader/index.d.ts +2 -0
- package/types/src/sheetProtection/ISheetProtection.d.ts +150 -0
- package/types/src/sheetProtection/SheetProtection.d.ts +39 -0
- package/types/src/sheetProtection/index.d.ts +2 -0
- package/types/src/sheetView/ISheetView.d.ts +439 -0
- package/types/src/sheetView/SheetView.d.ts +113 -0
- package/types/src/sheetView/_SheetViewUtils.d.ts +19 -0
- package/types/src/sheetView/index.d.ts +2 -0
- package/types/src/slicer/ISlicer.d.ts +38 -0
- package/types/src/slicer/Slicer.d.ts +41 -0
- package/types/src/slicer/index.d.ts +2 -0
- package/types/src/sort/ISort.d.ts +318 -0
- package/types/src/sort/Sort.d.ts +48 -0
- package/types/src/sort/_SortUtils.d.ts +12 -0
- package/types/src/sort/index.d.ts +3 -0
- package/types/src/string/IStringCollection.d.ts +50 -0
- package/types/src/string/StringCollection.d.ts +26 -0
- package/types/src/string/index.d.ts +3 -0
- package/types/src/style/IStyle.d.ts +485 -0
- package/types/src/style/IStyleCollection.d.ts +292 -0
- package/types/src/style/StyleCollection.d.ts +125 -0
- package/types/src/style/_BuiltInStyleDefs.d.ts +18 -0
- package/types/src/style/_BuiltInStyleNames.d.ts +20 -0
- package/types/src/style/index.d.ts +5 -0
- package/types/src/table/AnchoredTable.d.ts +349 -0
- package/types/src/table/AutoTable.d.ts +64 -0
- package/types/src/table/ITable.d.ts +714 -0
- package/types/src/table/ITableCollection.d.ts +88 -0
- package/types/src/table/ITableStyle.d.ts +318 -0
- package/types/src/table/Table.d.ts +8 -0
- package/types/src/table/TableCollection.d.ts +20 -0
- package/types/src/table/_AutoTableColumn.d.ts +27 -0
- package/types/src/table/_BuiltInTableStyles.d.ts +9 -0
- package/types/src/table/_FilterField.d.ts +30 -0
- package/types/src/table/_NamedTable.d.ts +84 -0
- package/types/src/table/_NamedTableSource.d.ts +57 -0
- package/types/src/table/_SortField.d.ts +29 -0
- package/types/src/table/_TableColumn.d.ts +51 -0
- package/types/src/table/_TableMessages.d.ts +5 -0
- package/types/src/table/_TableUtils.d.ts +94 -0
- package/types/src/table/index.d.ts +5 -0
- package/types/src/text/AutoNumberingScheme.d.ts +175 -0
- package/types/src/text/Bullet.d.ts +34 -0
- package/types/src/text/IText.d.ts +53 -0
- package/types/src/text/ITextFrame.d.ts +313 -0
- package/types/src/text/TextBoxAlignment.d.ts +141 -0
- package/types/src/text/TextFrame.d.ts +43 -0
- package/types/src/text/TextLine.d.ts +24 -0
- package/types/src/text/TextParagraph.d.ts +61 -0
- package/types/src/text/TextRotation.d.ts +106 -0
- package/types/src/text/TextRun.d.ts +85 -0
- package/types/src/text/TextUtils.d.ts +165 -0
- package/types/src/text/TextVisitor.d.ts +11 -0
- package/types/src/text/TextWrapper.d.ts +78 -0
- package/types/src/text/_TextUtils.d.ts +90 -0
- package/types/src/text/impl/Phrase.d.ts +3 -0
- package/types/src/text/impl/TabStrategy.d.ts +9 -0
- package/types/src/text/impl/WordWrapUtils.d.ts +6 -0
- package/types/src/text/index.d.ts +7 -0
- package/types/src/text/richtext/IStyledFont.d.ts +330 -0
- package/types/src/text/richtext/index.d.ts +2 -0
- package/types/src/theme/ITheme.d.ts +252 -0
- package/types/src/theme/IThemeCollection.d.ts +84 -0
- package/types/src/theme/ThemeCollection.d.ts +62 -0
- package/types/src/theme/_BuiltInColorSchemes.d.ts +3 -0
- package/types/src/theme/_BuiltInFontSchemes.d.ts +3 -0
- package/types/src/theme/_BuiltInThemeDefs.d.ts +3 -0
- package/types/src/theme/_ThemeMessages.d.ts +3 -0
- package/types/src/theme/_ThemeUtils.d.ts +3 -0
- package/types/src/theme/index.d.ts +4 -0
- package/types/src/transaction/ITransaction.d.ts +594 -0
- package/types/src/transaction/Transaction.d.ts +184 -0
- package/types/src/transaction/TransactionSaveStateManager.d.ts +85 -0
- package/types/src/transaction/TransactionUndoManager.d.ts +60 -0
- package/types/src/transaction/index.d.ts +5 -0
- package/types/src/type/ICollection.d.ts +110 -0
- package/types/src/type/IProperties.d.ts +51 -0
- package/types/src/type/ITypes.d.ts +69 -0
- package/types/src/type/Registry.d.ts +66 -0
- package/types/src/type/index.d.ts +5 -0
- package/types/src/utils/GeomUtils.d.ts +61 -0
- package/types/src/utils/ObjectPath.d.ts +9 -0
- package/types/src/utils/Profiler.d.ts +38 -0
- package/types/src/utils/_CSSUtils.d.ts +156 -0
- package/types/src/utils/_GeomUtils.d.ts +14 -0
- package/types/src/utils/_RangeCoordUtils.d.ts +84 -0
- package/types/src/utils/_RangeSetUtils.d.ts +55 -0
- package/types/src/utils/index.d.ts +2 -0
- package/types/src/workbook/IWorkbook.d.ts +711 -0
- package/types/src/workbook/Workbook.d.ts +342 -0
- package/types/src/workbook/WorkbookRange.d.ts +25 -0
- package/types/src/workbook/WorkbookRanges.d.ts +39 -0
- package/types/src/workbook/_WorkbookMessages.d.ts +8 -0
- package/types/src/workbook/_WorkbookUtils.d.ts +35 -0
- package/types/src/workbook/index.d.ts +3 -0
- package/types/src/workbookProtection/IWorkbookProtection.d.ts +57 -0
- package/types/src/workbookProtection/WorkbookProtection.d.ts +14 -0
- package/types/src/workbookProtection/index.d.ts +2 -0
- package/types/src/workbookView/IWorkbookView.d.ts +134 -0
- package/types/src/workbookView/WorkbookView.d.ts +49 -0
- package/types/src/workbookView/index.d.ts +3 -0
- package/browser/cjs/8p8T3dD14wnIxaBG.cjs +0 -6
- package/browser/cjs/95PbxEGMp0S1al9b.cjs +0 -6
- package/browser/cjs/B5N-CDhD5v6HYM0I.cjs +0 -6
- package/browser/cjs/BKgMJ6JZUiena1iM.cjs +0 -6
- package/browser/cjs/BSW7L4QsMahkhhhy.cjs +0 -6
- package/browser/cjs/Be4ZjrWJHL1nRmQu.cjs +0 -6
- package/browser/cjs/BkyqIhWBqIxRof6b.cjs +0 -6
- package/browser/cjs/BzjrR52QeojqLbOx.cjs +0 -7
- package/browser/cjs/C4h0pgfUOocSJ3Ke.cjs +0 -6
- package/browser/cjs/CKDSsq1v8jGWlRAi.cjs +0 -55
- package/browser/cjs/CYMVELYS8FNeFpiq.cjs +0 -6
- package/browser/cjs/CYg51Fs361BHxyRI.cjs +0 -6
- package/browser/cjs/CdzYFZ-48HrcE5LQ.cjs +0 -6
- package/browser/cjs/CfKjVPVp-cWgnToo.cjs +0 -6
- package/browser/cjs/D-u1ccCpAGvsjKOp.cjs +0 -6
- package/browser/cjs/D5fl40nw9aOYcQli.cjs +0 -6
- package/browser/cjs/D6KrtS3oZrLOAxO5.cjs +0 -6
- package/browser/cjs/DXQv5Gx-Wtfyk89a.cjs +0 -6
- package/browser/cjs/Di10f5RB2IX9PFHR.cjs +0 -6
- package/browser/cjs/DnOACT9Vxcz9_frM.cjs +0 -15
- package/browser/cjs/Dr2RqSffQZyFVpHL.cjs +0 -6
- package/browser/cjs/Dz0rduQbyCjN2Ni_.cjs +0 -6
- package/browser/cjs/JrzBZL5--Ock2uVj.cjs +0 -6
- package/browser/cjs/VLEyvfkmKqqUCKxv.cjs +0 -124
- package/browser/cjs/W8tk-2bTTSDGstfk.cjs +0 -6
- package/browser/cjs/pc9KfujdfWA19P_V.cjs +0 -6
- package/browser/cjs/qiB3rVaQVJILQk_N.cjs +0 -6
- package/browser/esm/BBYOqwrtztJDWz3c.mjs +0 -10
- package/browser/esm/BBst2hgdCPhA3DPd.mjs +0 -10
- package/browser/esm/BFrnY1TEgniZNVl8.mjs +0 -10
- package/browser/esm/BR4W7_ucdFJi03RO.mjs +0 -10
- package/browser/esm/BUci9XBsYBUNnQub.mjs +0 -10
- package/browser/esm/B_DMz5brejp8Mgto.mjs +0 -10
- package/browser/esm/B_EdCIINiuU7UuR6.mjs +0 -10
- package/browser/esm/BklwssraNXGXEaP2.mjs +0 -10
- package/browser/esm/BvccAibR-3R_xO8l.mjs +0 -10
- package/browser/esm/Bza5H7E2GGoHxEt7.mjs +0 -10
- package/browser/esm/C0brjreeBKRcVYN4.mjs +0 -10
- package/browser/esm/C1hdw7eWXk0zq1SS.mjs +0 -10
- package/browser/esm/C4Y3MpHe_UzFZEaF.mjs +0 -10
- package/browser/esm/CATfU6MHTqOkz5FJ.mjs +0 -10
- package/browser/esm/CDe9GrlTNhuZzOVh.mjs +0 -23841
- package/browser/esm/C_bcVsMhltCNyQij.mjs +0 -10
- package/browser/esm/CqpHJSTi0m49GR_q.mjs +0 -10
- package/browser/esm/CvVXzwNYb-2OZMBj.mjs +0 -426
- package/browser/esm/CwIFvNV1kcbLsXJg.mjs +0 -10
- package/browser/esm/D7xtXncwRYiPYQ3v.mjs +0 -10
- package/browser/esm/D8BmFg9FFVHUz_W1.mjs +0 -10
- package/browser/esm/DRm-FWBKVOv2Jp6x.mjs +0 -10
- package/browser/esm/Due-pSw1d9_zz_19.mjs +0 -12
- package/browser/esm/DvipK7b_PuSzB8G-.mjs +0 -10
- package/browser/esm/aTyRGVa5Smj2T_9l.mjs +0 -10
- package/browser/esm/lRUYQdaIClvoTNGo.mjs +0 -4022
- package/browser/esm/xXGFfp-8v8jL5akS.mjs +0 -5653
- package/node/esm/BBst2hgdCPhA3DPd.mjs +0 -10
- package/node/esm/BFrnY1TEgniZNVl8.mjs +0 -10
- package/node/esm/BLNq3EgGCGKtzrGq.mjs +0 -10
- package/node/esm/BLS0f7etFu8fozVg.mjs +0 -10
- package/node/esm/BMyNI7ZZi2ICO6Bn.mjs +0 -10
- package/node/esm/BR4W7_ucdFJi03RO.mjs +0 -10
- package/node/esm/B_EdCIINiuU7UuR6.mjs +0 -10
- package/node/esm/BhKeh1i4iDAeImus.mjs +0 -1072
- package/node/esm/BklwssraNXGXEaP2.mjs +0 -10
- package/node/esm/Bza5H7E2GGoHxEt7.mjs +0 -10
- package/node/esm/C0brjreeBKRcVYN4.mjs +0 -10
- package/node/esm/C1hdw7eWXk0zq1SS.mjs +0 -10
- package/node/esm/C4Y3MpHe_UzFZEaF.mjs +0 -10
- package/node/esm/CATfU6MHTqOkz5FJ.mjs +0 -10
- package/node/esm/COhANehqT9YVLl76.mjs +0 -10
- package/node/esm/CqpHJSTi0m49GR_q.mjs +0 -10
- package/node/esm/CuijIC4hIp5bpx9B.mjs +0 -10
- package/node/esm/CwIFvNV1kcbLsXJg.mjs +0 -10
- package/node/esm/D7xtXncwRYiPYQ3v.mjs +0 -10
- package/node/esm/D8BmFg9FFVHUz_W1.mjs +0 -10
- package/node/esm/DPs0koPRfrHYG1yO.mjs +0 -13
- package/node/esm/DVM4Cwe0h2V1V4vm.mjs +0 -10
- package/node/esm/DvipK7b_PuSzB8G-.mjs +0 -10
- package/node/esm/aTyRGVa5Smj2T_9l.mjs +0 -10
- package/node/esm/qLqMotWYwBIdEVhE.mjs +0 -2458
|
@@ -0,0 +1,1322 @@
|
|
|
1
|
+
import { FetchArgs, Base64Args, ITaskProgress, MaybePromise } from '@sheetxl/utils';
|
|
2
|
+
import { IListener } from '../listener';
|
|
3
|
+
import { ITransaction } from '../transaction';
|
|
4
|
+
import { IWorkbook } from '../workbook';
|
|
5
|
+
/**
|
|
6
|
+
* Interface for workbook input/output operations across multiple source types and formats.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* This interface provides a flexible I/O system with **two independent dimensions**:
|
|
10
|
+
*
|
|
11
|
+
* ### **Source Type** (Where/How data is stored)
|
|
12
|
+
* The physical location or container of the workbook data:
|
|
13
|
+
* - **File**: Local file system files (`File` objects)
|
|
14
|
+
* - **Blob**: Binary data blobs (from canvas, clipboard, etc.)
|
|
15
|
+
* - **URL/Fetch**: Remote resources fetched via HTTP/HTTPS
|
|
16
|
+
* - **ArrayBuffer**: Raw binary data in memory
|
|
17
|
+
* - **Base64**: Base64-encoded strings
|
|
18
|
+
* - **Stream**: Streaming data (`ReadableStream`)
|
|
19
|
+
*
|
|
20
|
+
* ### **Format Type** (How data is encoded)
|
|
21
|
+
* The encoding/file format of the workbook data:
|
|
22
|
+
* - **sxl**: SheetXL format
|
|
23
|
+
* - **xlsx**: Excel 2007+ format (Office Open XML)
|
|
24
|
+
* - **csv**: Comma-separated values
|
|
25
|
+
* - **xml**: Excel 2003 XML format
|
|
26
|
+
* - And other registered formats
|
|
27
|
+
*
|
|
28
|
+
* ### How They Work Together
|
|
29
|
+
* Any **source type** can contain any **format type**. For example:
|
|
30
|
+
* - A `File` could contain `sxl`, `xlsx`, `csv` data
|
|
31
|
+
* - A `URL` could point to an `sxl`, `xlsx`, or `csv` file
|
|
32
|
+
* - An `ArrayBuffer` could hold `sxl`, `xlsx`, or `csv` data
|
|
33
|
+
*
|
|
34
|
+
* The system automatically detects the format type from:
|
|
35
|
+
* - File extensions (`.xlsx`, `.csv`, etc.)
|
|
36
|
+
* - MIME types (`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`)
|
|
37
|
+
* - Content sniffing (examining the actual data)
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* // Example 1: File source with xlsx format
|
|
42
|
+
* const wb = await WorkbookIO.read({ source: fileObject }); // Auto-detects .xlsx
|
|
43
|
+
*
|
|
44
|
+
* // Example 2: URL source with csv format
|
|
45
|
+
* const wb = await WorkbookIO.read({ source: 'https://example.com/data.csv' });
|
|
46
|
+
*
|
|
47
|
+
* // Example 3: ArrayBuffer source with explicit format
|
|
48
|
+
* const wb = await WorkbookIO.read({
|
|
49
|
+
* source: arrayBuffer,
|
|
50
|
+
* format: 'xlsx' // Format can't be auto-detected or forced
|
|
51
|
+
* });
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export interface IWorkbookIO extends IListener.ISource<IWorkbookIO, IWorkbookIO.Events>, ITransaction.ICommitSource {
|
|
55
|
+
/**
|
|
56
|
+
* Reads a workbook from any source type with automatic format detection.
|
|
57
|
+
*
|
|
58
|
+
* @param sourceOrOptions Configuration specifying the source and optional format. Can also be passed
|
|
59
|
+
* directly as a `string` (URL, path, or data URI) as a shorthand for `{ source: string }`. Omit
|
|
60
|
+
* the source entirely to let the active {@link IWorkbookIO.IBackingStore} resolve one (e.g. an
|
|
61
|
+
* open picker in the browser).
|
|
62
|
+
*
|
|
63
|
+
* @returns A promise resolving to the decoded {@link IWorkbook}, or `null` if no source was
|
|
64
|
+
* resolved (e.g. the user cancelled an open picker). All read metadata — path, display name,
|
|
65
|
+
* resource type (format), size — lives on the workbook's {@link IWorkbook.getOrigin | origin}
|
|
66
|
+
* handle; there is no separate details object.
|
|
67
|
+
*
|
|
68
|
+
* @throws {Error} When the source type cannot be detected or accessed
|
|
69
|
+
* @throws {Error} When no appropriate format handler is available for the detected format
|
|
70
|
+
* @throws {Error} When the read operation fails (corrupt file, network error, etc.)
|
|
71
|
+
*
|
|
72
|
+
* @remarks
|
|
73
|
+
* ## Source Type Automatic-Detection
|
|
74
|
+
* The method automatically determines the **source type** (where data comes from):
|
|
75
|
+
*
|
|
76
|
+
* | Input Pattern | Detected Source Type | Example |
|
|
77
|
+
* |--------------|---------------------|---------|
|
|
78
|
+
* | `{ base64: "..." }` | Base64 string | `{ base64: "iVBORw0K..." }` |
|
|
79
|
+
* | `{ input: "..." }` | Fetch/URL | `{ input: "https://api.example.com" }` |
|
|
80
|
+
* | String starting with `data:` | Base64 data URI | `"data:application/json;base64,..."` |
|
|
81
|
+
* | String starting with `http://` or `https://` | Remote URL | `"https://example.com/file.xlsx"` |
|
|
82
|
+
* | String starting with `/`, `./`, `../` | Relative/absolute path | `"./data/workbook.csv"` |
|
|
83
|
+
* | Other strings | Treated as URL/path | `"workbook.xlsx"` |
|
|
84
|
+
* | `File` object | Browser File API | `<input type="file">` result |
|
|
85
|
+
* | `Blob` object | Binary data blob | Canvas, clipboard, etc. |
|
|
86
|
+
* | `ArrayBuffer` or TypedArray | Binary buffer | Raw bytes in memory |
|
|
87
|
+
* | `ReadableStream` | Streaming data | Converted to buffer first |
|
|
88
|
+
* | `Promise<T>` | Async source | Resolved, then re-detected |
|
|
89
|
+
* | `() => T` | Lazy source | Invoked, then re-detected |
|
|
90
|
+
*
|
|
91
|
+
* ## Format Type Automatic-Detection
|
|
92
|
+
* The method automatically determines the **format type** (how data is encoded):
|
|
93
|
+
* 1. **File extension** from source name (`.sxl`, `.xlsx`, `.csv`)
|
|
94
|
+
* 2. **MIME type** from HTTP response headers
|
|
95
|
+
* 3. **Content inspection** by examining magic bytes/signatures
|
|
96
|
+
* 4. **Explicit format** via `options.format`
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* // Auto-detect everything from a File object
|
|
101
|
+
* const wb = await WorkbookIO.read({ source: fileInput.files[0] });
|
|
102
|
+
* console.log(wb!.getName(), wb!.getOrigin().getPath());
|
|
103
|
+
*
|
|
104
|
+
* // Fetch from URL (auto-detects format from extension or Content-Type)
|
|
105
|
+
* const wb = await WorkbookIO.read({
|
|
106
|
+
* source: 'https://example.com/spreadsheet.xlsx'
|
|
107
|
+
* });
|
|
108
|
+
*
|
|
109
|
+
* // ArrayBuffer with explicit format (can't be auto-detected)
|
|
110
|
+
* const wb = await WorkbookIO.read({
|
|
111
|
+
* source: sxlArrayBuffer,
|
|
112
|
+
* format: 'sxl'
|
|
113
|
+
* });
|
|
114
|
+
*
|
|
115
|
+
* // Lazy loading with progress callback
|
|
116
|
+
* const wb = await WorkbookIO.read({
|
|
117
|
+
* source: async () => await fetch('/api/workbook').then(r => r.arrayBuffer()),
|
|
118
|
+
* progress: (amount) => console.log(`${amount}%:`)
|
|
119
|
+
* });
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
read<T extends IWorkbookIO.ReadOptions = IWorkbookIO.ReadOptions>(sourceOrOptions?: string | IWorkbookIO.Origin | T): Promise<IWorkbook | null>;
|
|
123
|
+
/**
|
|
124
|
+
* Resolves an address (a path or URL) to an {@link IWorkbookIO.Origin} handle. No I/O is
|
|
125
|
+
* performed.
|
|
126
|
+
*
|
|
127
|
+
* @param pathOrUrl The path or URL to resolve.
|
|
128
|
+
*
|
|
129
|
+
* @remarks
|
|
130
|
+
* The canonical way to mint a handle for {@link IWorkbookIO.read} / {@link IWorkbookIO.write};
|
|
131
|
+
* the string shorthands on those methods are sugar over this. The handle binds to the *active*
|
|
132
|
+
* {@link IWorkbookIO.IBackingStore} at mint time.
|
|
133
|
+
*/
|
|
134
|
+
getOrigin(pathOrUrl: string): IWorkbookIO.Origin;
|
|
135
|
+
/**
|
|
136
|
+
* Writes a workbook via the configured {@link IWorkbookIO.IBackingStore}: a **Save** (no
|
|
137
|
+
* target — write back to the workbook's own {@link IWorkbook.getOrigin | origin}) or an
|
|
138
|
+
* **Export** (an explicit target — write a copy; the workbook's origin is untouched).
|
|
139
|
+
*
|
|
140
|
+
* @param workbook The workbook instance to write.
|
|
141
|
+
* @param target An explicit destination — a file name/path or an {@link IWorkbookIO.Origin} —
|
|
142
|
+
* for an **export**. Omit (or pass options in its place) for a **save**.
|
|
143
|
+
* @param options Encoding options (format, progress).
|
|
144
|
+
*
|
|
145
|
+
* @returns A promise resolving to the {@link IWorkbookIO.Origin} handle actually written — the
|
|
146
|
+
* workbook's own origin for a save, the target handle for an export, updated with the written
|
|
147
|
+
* size — or `null` if the operation was cancelled (e.g. the user dismissed a save dialog).
|
|
148
|
+
*
|
|
149
|
+
* @remarks
|
|
150
|
+
* **Save** (`write(workbook)`): the destination is the workbook's origin. A bound, writable
|
|
151
|
+
* origin is re-saved silently. An unbound or read-only origin makes the store resolve a
|
|
152
|
+
* destination (a save dialog in the browser; an error in bare Node) — and on success the IO
|
|
153
|
+
* layer **fills that origin in place**, so the next save is silent. The rule: *the store fills
|
|
154
|
+
* in a handle it resolved itself; it never overrides a handle the caller supplied.*
|
|
155
|
+
*
|
|
156
|
+
* **Export** (`write(workbook, target)`): writes a copy to the target. The workbook's origin —
|
|
157
|
+
* its identity — is never touched, and the export does **not** mark the workbook clean
|
|
158
|
+
* ({@link IWorkbookIO.addCommitListener} fires for saves only). Re-targeting a workbook ("Save
|
|
159
|
+
* As") is {@link IWorkbookIO.writeAs} — the explicit rebind verb.
|
|
160
|
+
*
|
|
161
|
+
* Replacing the store (via {@link IWorkbookIO.setBackingStore}) redirects writing entirely — e.g.
|
|
162
|
+
* a VSCode extension posting bytes to the editor host, or a CLI prompting in the terminal.
|
|
163
|
+
*
|
|
164
|
+
* ### **Format Type** Auto-Detection
|
|
165
|
+
* If `options.format` is not provided, it is inferred from the destination's extension (the
|
|
166
|
+
* explicit target, else the workbook's origin). There is no implicit default.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```typescript
|
|
170
|
+
* // Save — back to the workbook's origin (or resolve a destination if it has none).
|
|
171
|
+
* const details = await workbookIO.write(workbook);
|
|
172
|
+
*
|
|
173
|
+
* // Export — a copy to an explicit destination; the origin is untouched.
|
|
174
|
+
* const details = await workbookIO.write(workbook, 'copy.xlsx');
|
|
175
|
+
*
|
|
176
|
+
* // Export in a specific format.
|
|
177
|
+
* const details = await workbookIO.write(workbook, 'report.csv', { format: 'csv' });
|
|
178
|
+
* ```
|
|
179
|
+
*
|
|
180
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API | File System Access API}
|
|
181
|
+
*/
|
|
182
|
+
write<T extends IWorkbookIO.WriteOptions = IWorkbookIO.WriteOptions>(workbook: IWorkbook, target?: string | IWorkbookIO.Origin | T, options?: T): Promise<IWorkbookIO.Origin | null>;
|
|
183
|
+
/**
|
|
184
|
+
* Save As: re-target the workbook's identity to `target`, then save. On success the workbook's
|
|
185
|
+
* {@link IWorkbook.getOrigin | origin} (and so its display name) follows the new destination; on
|
|
186
|
+
* cancel/failure the origin is restored — identity unchanged.
|
|
187
|
+
*
|
|
188
|
+
* @param workbook The workbook instance to re-target and save.
|
|
189
|
+
* @param target The new destination — a file name/path or an {@link IWorkbookIO.Origin}.
|
|
190
|
+
* @param options Encoding options (format, progress) plus
|
|
191
|
+
* {@link IWorkbookIO.WriteAsOptions.prompt} — re-targeting is this verb, *asking the user* is
|
|
192
|
+
* that option.
|
|
193
|
+
*
|
|
194
|
+
* @returns A promise resolving to the workbook's (re-targeted) {@link IWorkbookIO.Origin}, or
|
|
195
|
+
* `null` if the operation was cancelled.
|
|
196
|
+
*
|
|
197
|
+
* @remarks
|
|
198
|
+
* This is the **explicit rebind verb** — the one origin re-target {@link IWorkbookIO.write} never
|
|
199
|
+
* performs. It composes re-target + save so the whole flow stays coherent: the store resolves /
|
|
200
|
+
* persists against the workbook's own (re-targeted) handle — keeping platform session state (e.g.
|
|
201
|
+
* a browser file handle cache) keyed to the one live handle — and the save path marks the
|
|
202
|
+
* workbook clean via {@link IWorkbookIO.addCommitListener}. Handle mutation authority sits in the
|
|
203
|
+
* IO/store layer (the same layer that fills a resolved destination in), which is why this lives
|
|
204
|
+
* here and not on the model or a wrapper object.
|
|
205
|
+
*
|
|
206
|
+
* "Write a copy without moving the identity" is {@link IWorkbookIO.write} with a target (an
|
|
207
|
+
* export), not this.
|
|
208
|
+
*/
|
|
209
|
+
writeAs<T extends IWorkbookIO.WriteAsOptions = IWorkbookIO.WriteAsOptions>(workbook: IWorkbook, target: string | IWorkbookIO.Origin, options?: T): Promise<IWorkbookIO.Origin | null>;
|
|
210
|
+
/**
|
|
211
|
+
* Writes a workbook to an ArrayBuffer in the specified format.
|
|
212
|
+
*
|
|
213
|
+
* @param workbook The workbook instance to write
|
|
214
|
+
* @param options Write configuration including format type and encoding options
|
|
215
|
+
*
|
|
216
|
+
* @returns A promise resolving to an ArrayBuffer containing the encoded workbook data
|
|
217
|
+
*
|
|
218
|
+
* @remarks
|
|
219
|
+
* This method produces raw binary data in the **format type** you specify (sxl, xlsx, csv, etc.).
|
|
220
|
+
* The **source type** is always ArrayBuffer - use this for:
|
|
221
|
+
* - In-memory operations
|
|
222
|
+
* - Custom upload logic
|
|
223
|
+
* - Further processing before saving
|
|
224
|
+
*
|
|
225
|
+
* ## Format Type Auto-Detection
|
|
226
|
+
* - Specify via `options.format` (e.g., `'sxl'`, `'xlsx'`, `'csv'`)
|
|
227
|
+
* - If not provided, defaults to the first registered write format
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```typescript
|
|
231
|
+
* // Write as Excel format
|
|
232
|
+
* const buffer: ArrayBufferLike = await workbookIO.writeArrayBuffer(workbook, {
|
|
233
|
+
* format: 'xlsx'
|
|
234
|
+
* });
|
|
235
|
+
*
|
|
236
|
+
* // Write as CSV
|
|
237
|
+
* const csvBuffer: ArrayBufferLike = await workbookIO.writeArrayBuffer(workbook, {
|
|
238
|
+
* format: 'csv'
|
|
239
|
+
* });
|
|
240
|
+
*
|
|
241
|
+
* // Upload to server
|
|
242
|
+
* const buffer: ArrayBufferLike = await workbookIO.writeArrayBuffer(workbook, { format: 'xlsx' });
|
|
243
|
+
* await fetch('/api/upload', {
|
|
244
|
+
* method: 'POST',
|
|
245
|
+
* body: buffer
|
|
246
|
+
* });
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
writeArrayBuffer<T extends IWorkbookIO.WriteOptions = IWorkbookIO.WriteOptions>(workbook: IWorkbook, options?: T): Promise<ArrayBufferLike>;
|
|
250
|
+
/**
|
|
251
|
+
* Overrides the {@link IWorkbookIO.IBackingStore} used by {@link IWorkbookIO.write} (and,
|
|
252
|
+
* in future, reads).
|
|
253
|
+
*
|
|
254
|
+
* @param store A backing store that owns persistence, or `null` to restore the built-in
|
|
255
|
+
* platform store.
|
|
256
|
+
*
|
|
257
|
+
* @remarks
|
|
258
|
+
* Use this to redirect where workbooks are persisted — for example a VSCode extension that
|
|
259
|
+
* posts bytes to the editor host, or a server/cloud store. The store receives a
|
|
260
|
+
* {@link IWorkbookIO.WriteRequest} (with a helper to encode the workbook) and returns the
|
|
261
|
+
* written {@link IWorkbookIO.Origin} handle, or `null` to signal cancellation.
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* ```typescript
|
|
265
|
+
* // Route every write through a host (e.g. a VSCode extension).
|
|
266
|
+
* workbookIO.setBackingStore({
|
|
267
|
+
* async write({ format, origin, encode }) {
|
|
268
|
+
* const bytes = await encode();
|
|
269
|
+
* await host.writeActiveDocument(bytes);
|
|
270
|
+
* return { format, origin, size: bytes.byteLength };
|
|
271
|
+
* }
|
|
272
|
+
* });
|
|
273
|
+
* ```
|
|
274
|
+
*/
|
|
275
|
+
setBackingStore(store: IWorkbookIO.IBackingStore | null): void;
|
|
276
|
+
/**
|
|
277
|
+
* The active {@link IWorkbookIO.IBackingStore} — the override set via
|
|
278
|
+
* {@link IWorkbookIO.setBackingStore}, or the built-in platform store.
|
|
279
|
+
*/
|
|
280
|
+
getBackingStore(): IWorkbookIO.IBackingStore;
|
|
281
|
+
/**
|
|
282
|
+
* Whether the active {@link IWorkbookIO.IBackingStore} can persist workbooks (implements `write`).
|
|
283
|
+
*
|
|
284
|
+
* @remarks
|
|
285
|
+
* Reflects the active store's *own* capability — a UI-capability probe (e.g. enable Save), not a
|
|
286
|
+
* guarantee about a particular {@link IWorkbookIO.write} call. Use to gate save affordances.
|
|
287
|
+
*/
|
|
288
|
+
canWrite(): boolean;
|
|
289
|
+
/**
|
|
290
|
+
* Whether the active {@link IWorkbookIO.IBackingStore} provides its own `read` (interactive source
|
|
291
|
+
* acquisition).
|
|
292
|
+
*
|
|
293
|
+
* @remarks
|
|
294
|
+
* Reflects the active store's *own* capability — not the platform read fallback. A write-only
|
|
295
|
+
* override reports `false` even though {@link IWorkbookIO.read} of in-hand bytes still works via
|
|
296
|
+
* the fallback. Use to gate open / drag-drop affordances (and to release their shortcuts).
|
|
297
|
+
*/
|
|
298
|
+
canRead(): boolean;
|
|
299
|
+
/**
|
|
300
|
+
* Returns available read format types (encoding formats that can be read).
|
|
301
|
+
*
|
|
302
|
+
* @param options Optional filters to narrow down the format types
|
|
303
|
+
* @returns Array of format type definitions that can decode workbook data
|
|
304
|
+
*
|
|
305
|
+
* @remarks
|
|
306
|
+
* Returns **format types** (encoding formats like sxl, xlsx, csv), not source types.
|
|
307
|
+
* Each format type includes:
|
|
308
|
+
* - File extensions it supports (e.g., `['.xlsx', '.xlsm']`)
|
|
309
|
+
* - MIME type (e.g., `'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'`)
|
|
310
|
+
* - Handler function for decoding that format
|
|
311
|
+
*
|
|
312
|
+
* These format types work with **any source type** (File, URL, ArrayBuffer, etc.).
|
|
313
|
+
*
|
|
314
|
+
* @example
|
|
315
|
+
* ```typescript
|
|
316
|
+
* // Get all available read formats
|
|
317
|
+
* const allFormats = workbookIO.getReadFormats();
|
|
318
|
+
* console.log(allFormats.map(f => f.key)); // ['sxl', 'xlsx', 'csv', ...]
|
|
319
|
+
*
|
|
320
|
+
* // Find format by file extension
|
|
321
|
+
* const csvFormat = workbookIO.getReadFormats({ ext: '.csv' });
|
|
322
|
+
*
|
|
323
|
+
* // Find format by MIME type
|
|
324
|
+
* const xlsxFormat = workbookIO.getReadFormats({
|
|
325
|
+
* mimeType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
326
|
+
* });
|
|
327
|
+
* ```
|
|
328
|
+
*/
|
|
329
|
+
getReadFormats(options?: IWorkbookIO.GetFormatsOptions): Promise<IWorkbookIO.FormatType[]>;
|
|
330
|
+
/**
|
|
331
|
+
* Returns available write format types (encoding formats that can be written).
|
|
332
|
+
*
|
|
333
|
+
* @param options Optional filters to narrow down the format types.
|
|
334
|
+
* @returns Array of format type definitions that can encode workbook data
|
|
335
|
+
*
|
|
336
|
+
* @remarks
|
|
337
|
+
* Returns **format types** (encoding formats like sxl, xlsx, csv), not source types.
|
|
338
|
+
* Each format type includes:
|
|
339
|
+
* - File extension it produces (e.g., `'.xlsx'`)
|
|
340
|
+
* - MIME type (e.g., `'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'`)
|
|
341
|
+
* - Handler function for encoding that format
|
|
342
|
+
*
|
|
343
|
+
* The encoded data can then be written to **any source type** (File, ArrayBuffer, etc.).
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* ```typescript
|
|
347
|
+
* // Get all available write formats
|
|
348
|
+
* const allFormats = workbookIO.getWriteFormats();
|
|
349
|
+
* console.log(allFormats.map(f => f.key)); // ['sxl', 'xlsx', 'csv', ...]
|
|
350
|
+
*
|
|
351
|
+
* // Find format by extension
|
|
352
|
+
* const xlsxFormat = workbookIO.getWriteFormats({ ext: '.xlsx' });
|
|
353
|
+
*
|
|
354
|
+
* // Build a file type picker for UI
|
|
355
|
+
* const formats = workbookIO.getWriteFormats();
|
|
356
|
+
* const fileTypes = formats.map(f => ({
|
|
357
|
+
* description: f.description,
|
|
358
|
+
* accept: { [f.mimeType]: [f.ext] }
|
|
359
|
+
* }));
|
|
360
|
+
* ```
|
|
361
|
+
*/
|
|
362
|
+
getWriteFormats(options?: IWorkbookIO.GetFormatsOptions): Promise<IWorkbookIO.FormatType[]>;
|
|
363
|
+
/**
|
|
364
|
+
* Adds a new read format type to the I/O system.
|
|
365
|
+
*/
|
|
366
|
+
install(plugin: IWorkbookIO.Plugin): Promise<void>;
|
|
367
|
+
/**
|
|
368
|
+
* Subscribe to ambient I/O lifecycle events ({@link IWorkbookIO.Events.onRead | onRead},
|
|
369
|
+
* {@link IWorkbookIO.Events.onWrite | onWrite}).
|
|
370
|
+
*
|
|
371
|
+
* @remarks
|
|
372
|
+
* These fire on the (shared) I/O service for *every* workbook it reads or writes, so a listener
|
|
373
|
+
* filters on {@link IWorkbookIO.IOEvent.workbook} for the one it cares about. Useful for UI
|
|
374
|
+
* (busy/recent-files), telemetry, and dirty-tracking — bridge `onWrite` to
|
|
375
|
+
* {@link TransactionSaveStateManager.markSaved} using {@link IWorkbookIO.WriteEvent.commitId}.
|
|
376
|
+
*/
|
|
377
|
+
addListeners(listeners: IWorkbookIO.Listeners, options?: IListener.Options): IListener.Remove;
|
|
378
|
+
/**
|
|
379
|
+
* Subscribe to commits that were persisted.
|
|
380
|
+
* See {@link ITransaction.ICommitSource.addCommitListener}.
|
|
381
|
+
*
|
|
382
|
+
* @remarks
|
|
383
|
+
* Fires after a successful **save** — a {@link IWorkbookIO.write} with no explicit target — with
|
|
384
|
+
* the commit captured at encode time. It does NOT fire for an explicit-target export ("Save a
|
|
385
|
+
* Copy" must not mark the document clean), a cancelled write, or
|
|
386
|
+
* {@link IWorkbookIO.writeArrayBuffer} (a raw encode). Pass this directly to a
|
|
387
|
+
* {@link TransactionSaveStateManager} to track a workbook's dirty state with no extra wiring.
|
|
388
|
+
*/
|
|
389
|
+
addCommitListener(listener: ITransaction.ICommitSource.IListeners): IListener.Remove;
|
|
390
|
+
}
|
|
391
|
+
export declare namespace IWorkbookIO {
|
|
392
|
+
/**
|
|
393
|
+
* A light virtual file handle: where a workbook maps to — its path, display name, format, and
|
|
394
|
+
* whether it can be written back to. The IO analog of a `Uri` / `FileSystemFileHandle`.
|
|
395
|
+
*
|
|
396
|
+
* @remarks
|
|
397
|
+
* Minted and owned by the IO/store layer, never by the workbook model — but every workbook holds
|
|
398
|
+
* a stable, *read-only* reference to one (see {@link IWorkbook.getOrigin}), like the DOM's
|
|
399
|
+
* `document.URL`. The origin **object** is mutable in place by its owner (a save that resolves a
|
|
400
|
+
* destination fills an unbound origin; a store rename moves it), firing `onChange` so holders
|
|
401
|
+
* follow; the workbook's *reference* to it never changes.
|
|
402
|
+
*
|
|
403
|
+
* An **unbound** origin (`getPath()` returns `null`) belongs to an in-memory workbook with no
|
|
404
|
+
* destination yet. A **read-only** origin (`canWrite()` is `false`) is real provenance that cannot
|
|
405
|
+
* be silently re-saved — a fetched URL, a dropped file without a writable handle — signalling
|
|
406
|
+
* callers to resolve a destination ("Save As") instead.
|
|
407
|
+
*/
|
|
408
|
+
interface Origin extends IListener.ISource<Origin, Origin.IListeners> {
|
|
409
|
+
/**
|
|
410
|
+
* The display name (without extension), e.g. `'report'` — derived from the
|
|
411
|
+
* {@link getPath | path} when not set explicitly — or `null` for an unbound, unnamed origin.
|
|
412
|
+
* Display fallbacks (e.g. a localized "Untitled") are a UI concern.
|
|
413
|
+
*/
|
|
414
|
+
getName(): string | null;
|
|
415
|
+
/**
|
|
416
|
+
* The full path or URL, e.g. `'./out/report.xlsx'` or `'https://host/report.xlsx'`, or `null`
|
|
417
|
+
* for an unbound (in-memory) origin.
|
|
418
|
+
*/
|
|
419
|
+
getPath(): string | null;
|
|
420
|
+
/**
|
|
421
|
+
* The resolved format key (e.g. `'xlsx'`), or `null` if unknown. Derived from the
|
|
422
|
+
* {@link getPath | path} extension when not set explicitly.
|
|
423
|
+
*
|
|
424
|
+
* @remarks
|
|
425
|
+
* The handle's **resource type** — the analog of a `File.type` / `Content-Type`: most file
|
|
426
|
+
* systems make the type part of the handle, and so does this one. The full
|
|
427
|
+
* {@link IWorkbookIO.FormatType} (description, extensions, mime) is a
|
|
428
|
+
* `getReadFormats({ search: key })` / `getWriteFormats({ search: key })` lookup away.
|
|
429
|
+
*/
|
|
430
|
+
getFormat(): string | null;
|
|
431
|
+
/**
|
|
432
|
+
* The {@link getPath | path}'s file extension, lower-cased and without the dot (e.g. `'xlsx'`),
|
|
433
|
+
* or `null` when the origin is unbound or its path has no extension.
|
|
434
|
+
*
|
|
435
|
+
* @remarks
|
|
436
|
+
* The handle's **physical** type, as distinct from {@link getFormat}'s semantic one: a format
|
|
437
|
+
* key (`'SheetXL'`) is not a file extension (`'sxl'`), and one is not derivable from the other
|
|
438
|
+
* without the registry. Use this wherever a file *name* is being built (a suggested name, a
|
|
439
|
+
* download name); use `getFormat()` to resolve a handler.
|
|
440
|
+
*/
|
|
441
|
+
getExtension(): string | null;
|
|
442
|
+
/**
|
|
443
|
+
* The {@link IWorkbookIO.EncryptionType | encryption envelope} this source is wrapped in (e.g.
|
|
444
|
+
* `'offcrypto'`), or `null` when it is plaintext.
|
|
445
|
+
*
|
|
446
|
+
* @remarks
|
|
447
|
+
* The scheme actually **on disk** — discovered when the source is read, recorded when it is
|
|
448
|
+
* written, and `null` until then. For "is or *will be* encrypted", which is what chrome and the
|
|
449
|
+
* write path both actually ask, use {@link isEncrypted}.
|
|
450
|
+
*
|
|
451
|
+
* Never the password: origins are rendered into logs and REPL output, and ride events and
|
|
452
|
+
* progress callbacks, so a secret has no business here (see `PROTECTION-DESIGN.md` §5f).
|
|
453
|
+
*
|
|
454
|
+
* Use it to show a lock affordance, and to recognise that writing plaintext over it would be a
|
|
455
|
+
* downgrade — {@link IWorkbookIO.WriteOptions.password} makes that refusal explicit.
|
|
456
|
+
*
|
|
457
|
+
* Unrelated to sheet/workbook *protection*, which is a hash gate stored in the model.
|
|
458
|
+
*/
|
|
459
|
+
getEncryption(): string | null;
|
|
460
|
+
/**
|
|
461
|
+
* Whether this source is encrypted, or **would be** if written now.
|
|
462
|
+
*
|
|
463
|
+
* @remarks
|
|
464
|
+
* `true` when the source was read as encrypted, was written encrypted, or has had a password
|
|
465
|
+
* set via {@link setPassword} that no save has applied yet. That last case is why this exists
|
|
466
|
+
* separately from {@link getEncryption}, which reports the scheme actually on disk and is `null`
|
|
467
|
+
* until a save happens.
|
|
468
|
+
*
|
|
469
|
+
* This is the question chrome asks (show a lock?) and the question a write asks (would writing
|
|
470
|
+
* plaintext be a downgrade?).
|
|
471
|
+
*/
|
|
472
|
+
isEncrypted(): boolean;
|
|
473
|
+
/**
|
|
474
|
+
* Sets — or clears, with `null` — the password this source is encrypted with, for this session.
|
|
475
|
+
*
|
|
476
|
+
* @remarks
|
|
477
|
+
* **Set-only.** There is no getter on this interface: a password can be handed in and cleared,
|
|
478
|
+
* never read back. A UI collects one and passes it here; keeping a copy buys nothing and only
|
|
479
|
+
* widens the exposure. (The IO layer reads it through a privileged channel on the concrete
|
|
480
|
+
* `WorkbookOrigin`, the same way it mutates the rest of the handle.)
|
|
481
|
+
*
|
|
482
|
+
* Non-privileged, exactly like {@link setName}: both record what the *next* write should do,
|
|
483
|
+
* and neither is on disk until it happens. Clearing with `null` is the "remove password" verb
|
|
484
|
+
* and is carried into that write.
|
|
485
|
+
*
|
|
486
|
+
* The password lives and dies with the handle — nothing survives the session, and a closed
|
|
487
|
+
* workbook takes it with it.
|
|
488
|
+
*/
|
|
489
|
+
setPassword(password: string | null): void;
|
|
490
|
+
/**
|
|
491
|
+
* The last-known size of the source in bytes, or `null` if unknown — a stat-style property
|
|
492
|
+
* (the analog of `FileSystemFileHandle.getFile().size`), updated by the IO/store layer on
|
|
493
|
+
* each read/write of this handle.
|
|
494
|
+
*/
|
|
495
|
+
getSize(): number | null;
|
|
496
|
+
/**
|
|
497
|
+
* Whether this source can be written back to (a silent re-save). A read-only source (e.g. a
|
|
498
|
+
* fetched URL) returns `false`, signalling callers to prompt for a destination ("Save As").
|
|
499
|
+
*/
|
|
500
|
+
canWrite(): boolean;
|
|
501
|
+
/**
|
|
502
|
+
* Set the display name (a label, without extension). Fires `onChange` (and, through the
|
|
503
|
+
* workbook, `onNameChange`).
|
|
504
|
+
*
|
|
505
|
+
* @remarks
|
|
506
|
+
* Renaming the *label* is not privileged — it feeds display and the suggested file name of the
|
|
507
|
+
* next destination-resolving save, nothing else. The path/`canWrite` (real identity) remain
|
|
508
|
+
* owned by the IO/store layer. A rename is not a model edit and never enters the undo stack.
|
|
509
|
+
*/
|
|
510
|
+
setName(name: string | null): void;
|
|
511
|
+
}
|
|
512
|
+
namespace Origin {
|
|
513
|
+
/**
|
|
514
|
+
* IListener interface for {@link IWorkbookIO.Origin} events.
|
|
515
|
+
*/
|
|
516
|
+
interface Events {
|
|
517
|
+
/**
|
|
518
|
+
* Called when the origin changes in place (e.g. a save to a new location or a rename).
|
|
519
|
+
*/
|
|
520
|
+
onChange?(source: Origin): void;
|
|
521
|
+
}
|
|
522
|
+
interface IListeners extends IListener.Callbacks<Origin, Origin.Events> {
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Common fields shared by all ambient I/O events.
|
|
527
|
+
*/
|
|
528
|
+
interface IOEvent {
|
|
529
|
+
/**
|
|
530
|
+
* The workbook that was read or written. A listener filters on this to react to a specific
|
|
531
|
+
* workbook (the service is shared across all of them).
|
|
532
|
+
*/
|
|
533
|
+
workbook: IWorkbook;
|
|
534
|
+
/**
|
|
535
|
+
* The {@link IWorkbookIO.Origin} handle the operation actually used — the workbook's own
|
|
536
|
+
* origin for a read or a save; the (distinct) target handle for an export.
|
|
537
|
+
*
|
|
538
|
+
* @remarks
|
|
539
|
+
* Uniform across read and write, so an ambient listener (e.g. recent-files) can track "the
|
|
540
|
+
* handle just touched" without branching on the event kind.
|
|
541
|
+
*/
|
|
542
|
+
origin: IWorkbookIO.Origin;
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Fired after a workbook has been successfully read.
|
|
546
|
+
*/
|
|
547
|
+
interface ReadEvent extends IOEvent {
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Fired after a workbook has been successfully written via {@link IWorkbookIO.write}.
|
|
551
|
+
*
|
|
552
|
+
* @remarks
|
|
553
|
+
* Not fired by {@link IWorkbookIO.writeArrayBuffer} (a raw encode, used for exports / uploads) or
|
|
554
|
+
* by a cancelled write.
|
|
555
|
+
*/
|
|
556
|
+
interface WriteEvent extends IOEvent {
|
|
557
|
+
/**
|
|
558
|
+
* The workbook's transaction commit id at the moment its bytes were *encoded*.
|
|
559
|
+
*
|
|
560
|
+
* @remarks
|
|
561
|
+
* An opaque token identifying the persisted state. Pass it to
|
|
562
|
+
* {@link TransactionSaveStateManager.markSaved} so the workbook is marked clean as of exactly
|
|
563
|
+
* that state — edits made during the (async) write correctly remain unsaved.
|
|
564
|
+
*/
|
|
565
|
+
commitId: string | null;
|
|
566
|
+
/**
|
|
567
|
+
* `true` when the write was a **save** (to the workbook's own origin); `false` for an
|
|
568
|
+
* explicit-target **export** (a copy). Only saves mark the workbook clean — see
|
|
569
|
+
* {@link IWorkbookIO.addCommitListener}.
|
|
570
|
+
*/
|
|
571
|
+
save: boolean;
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* Ambient I/O lifecycle events. See {@link IWorkbookIO.addListeners}.
|
|
575
|
+
*/
|
|
576
|
+
interface Events {
|
|
577
|
+
/**
|
|
578
|
+
* Called after a workbook is successfully read.
|
|
579
|
+
*/
|
|
580
|
+
onRead?(source: IWorkbookIO, event: IWorkbookIO.ReadEvent): void;
|
|
581
|
+
/**
|
|
582
|
+
* Called after a workbook is successfully written via {@link IWorkbookIO.write}.
|
|
583
|
+
*/
|
|
584
|
+
onWrite?(source: IWorkbookIO, event: IWorkbookIO.WriteEvent): void;
|
|
585
|
+
}
|
|
586
|
+
interface Listeners extends IListener.Callbacks<IWorkbookIO, IWorkbookIO.Events> {
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Union type representing all possible io source types.
|
|
590
|
+
*
|
|
591
|
+
* @remarks
|
|
592
|
+
* This type encompasses all the different ways data can be provided
|
|
593
|
+
* for import operations, from simple strings to complex stream objects.
|
|
594
|
+
*/
|
|
595
|
+
type IOSource = string | File | Blob | ArrayBufferLike | Uint8Array<ArrayBufferLike> | ReadableStream<Uint8Array> | FetchArgs | Base64Args;
|
|
596
|
+
/**
|
|
597
|
+
* Union type representing all possible input sources for workbook imports.
|
|
598
|
+
*
|
|
599
|
+
* @remarks
|
|
600
|
+
* This type is used to define the source of data for importing workbooks,
|
|
601
|
+
* allowing for various formats such as URLs, files, and raw binary data.
|
|
602
|
+
*/
|
|
603
|
+
interface FormatType {
|
|
604
|
+
/**
|
|
605
|
+
* The key used to identify the type of import.
|
|
606
|
+
*
|
|
607
|
+
* @remarks
|
|
608
|
+
* Must be unique across all format types.
|
|
609
|
+
*/
|
|
610
|
+
key: string;
|
|
611
|
+
/**
|
|
612
|
+
* A human readable name for the format, as shown in a Save As type dropdown.
|
|
613
|
+
*
|
|
614
|
+
* @remarks
|
|
615
|
+
* This is a file-type NOUN PHRASE — `'<Family> <DocumentKind>'`, plus an optional `'(Variant)'`
|
|
616
|
+
* — not a brand and not an adjective: `'Excel Workbook'`, `'SheetXL Workbook'`,
|
|
617
|
+
* `'SheetXL Workbook (JSON)'`, `'Comma Separated Values'`. It goes verbatim into the native file
|
|
618
|
+
* picker's type list (the browser appends `(*.ext)` itself), so a bare brand (`'SheetXL'`) reads
|
|
619
|
+
* as a vendor rather than a file type, and a bare adjective (`'Comma Delimited'`) never says
|
|
620
|
+
* delimited *what*.
|
|
621
|
+
*
|
|
622
|
+
* A variant belongs in PARENTHESES when it is a noun (`'(JSON)'`), and before the document kind
|
|
623
|
+
* only when it is a true adjective (`'Excel Binary Workbook'`) — `'SheetXL JSON Workbook'`
|
|
624
|
+
* stacks three nouns with no grammatical joint. Excel ships the parenthesized-and-then-extension
|
|
625
|
+
* form itself: `'CSV (Comma delimited) (*.csv)'`.
|
|
626
|
+
*
|
|
627
|
+
* It is also substituted into sentences such as "Save as {description}", which is the other
|
|
628
|
+
* reason it must stand alone as a noun.
|
|
629
|
+
*/
|
|
630
|
+
description?: string;
|
|
631
|
+
/**
|
|
632
|
+
* The mime type of the import.
|
|
633
|
+
*/
|
|
634
|
+
mimeType: string;
|
|
635
|
+
/**
|
|
636
|
+
* Tags that are used by the UI.
|
|
637
|
+
*/
|
|
638
|
+
tags?: string[];
|
|
639
|
+
/**
|
|
640
|
+
* A format for users who go looking: real and fully supported, but not *featured*.
|
|
641
|
+
*
|
|
642
|
+
* @remarks
|
|
643
|
+
* It earns no entry of its own in curated chrome — the Save As menu, which is a short list of
|
|
644
|
+
* the formats most people want — while staying available everywhere the COMPLETE set is
|
|
645
|
+
* offered: the native picker's "save as type" dropdown, a `--format` argument, and
|
|
646
|
+
* {@link IWorkbookIO.getWriteFormats} itself. Nothing about reading or writing it is
|
|
647
|
+
* special-cased; only its prominence is.
|
|
648
|
+
*
|
|
649
|
+
* This is a *demotion*, not a hiding: a format nobody may write does not belong in the registry
|
|
650
|
+
* at all. Use it where a menu entry would cost more attention than it earns — `'SheetXL
|
|
651
|
+
* Workbook (JSON)'` next to `'SheetXL Workbook'`, whose difference (pretty-printed and
|
|
652
|
+
* uncompressed) matters to a developer and to no one else.
|
|
653
|
+
*
|
|
654
|
+
* @defaultValue false
|
|
655
|
+
*/
|
|
656
|
+
advanced?: boolean;
|
|
657
|
+
/**
|
|
658
|
+
* The file extensions that this type of supports.
|
|
659
|
+
*/
|
|
660
|
+
exts: string[];
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* A **registration-side** encryption envelope: a container that wraps a workbook's encoded bytes
|
|
664
|
+
* in an encrypted form, independent of what format those bytes are in.
|
|
665
|
+
*
|
|
666
|
+
* @remarks
|
|
667
|
+
* Encryption sits **above** the format handlers, not inside them: an envelope carries opaque
|
|
668
|
+
* bytes, so one implementation serves every registered format (and every format registered
|
|
669
|
+
* later) rather than each plugin growing its own crypto. {@link IWorkbookIO.read} detects an
|
|
670
|
+
* envelope on the acquired bytes and unwraps them before the format handler ever sees them;
|
|
671
|
+
* {@link IWorkbookIO.write} wraps the handler's output on the way out.
|
|
672
|
+
*
|
|
673
|
+
* Registered like a format ({@link Registry.registerEncryption}) so the code ships with the
|
|
674
|
+
* plugin that implements it — a host that installs no such plugin simply reports encrypted files
|
|
675
|
+
* as unsupported instead of failing to parse them.
|
|
676
|
+
*/
|
|
677
|
+
interface EncryptionType {
|
|
678
|
+
/**
|
|
679
|
+
* Unique identifier for this envelope (e.g. `'offcrypto'`).
|
|
680
|
+
*/
|
|
681
|
+
key: string;
|
|
682
|
+
/**
|
|
683
|
+
* A description of the envelope, for error messages and UI.
|
|
684
|
+
*/
|
|
685
|
+
description?: string;
|
|
686
|
+
/**
|
|
687
|
+
* Whether these bytes are wrapped in this envelope. Must be cheap (a magic-number/header
|
|
688
|
+
* check) and precise — a container shared with unencrypted files (e.g. CFB, which is also
|
|
689
|
+
* legacy `.xls`) has to inspect enough to be sure.
|
|
690
|
+
*/
|
|
691
|
+
detect(bytes: ArrayBufferLike): boolean | Promise<boolean>;
|
|
692
|
+
/**
|
|
693
|
+
* Unwraps the envelope, returning the plaintext bytes.
|
|
694
|
+
*
|
|
695
|
+
* @throws {InvalidPasswordError} When the password does not open the envelope — callers
|
|
696
|
+
* re-prompt on this specific error, so it must not be reported as a generic failure.
|
|
697
|
+
*/
|
|
698
|
+
decode(bytes: ArrayBufferLike, password: string): Promise<ArrayBufferLike>;
|
|
699
|
+
/**
|
|
700
|
+
* Wraps plaintext bytes in the envelope.
|
|
701
|
+
*/
|
|
702
|
+
encode(bytes: ArrayBufferLike, password: string): Promise<ArrayBufferLike>;
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* The context passed to {@link ReadOptions.onPassword}.
|
|
706
|
+
*/
|
|
707
|
+
interface PasswordRequest {
|
|
708
|
+
/**
|
|
709
|
+
* The handle being opened — use its name in the prompt.
|
|
710
|
+
*/
|
|
711
|
+
origin: IWorkbookIO.Origin;
|
|
712
|
+
/**
|
|
713
|
+
* The envelope that was detected (e.g. `'offcrypto'`).
|
|
714
|
+
*/
|
|
715
|
+
encryption: string;
|
|
716
|
+
/**
|
|
717
|
+
* Tries a password **without ending the prompt**, so a dialog can report "incorrect password"
|
|
718
|
+
* in place and let the user try again.
|
|
719
|
+
*
|
|
720
|
+
* @returns `true` if the password opens the source.
|
|
721
|
+
*
|
|
722
|
+
* @throws Anything other than a wrong password (a malformed container, an unsupported scheme) —
|
|
723
|
+
* those are not retryable and should surface to the user as errors.
|
|
724
|
+
*
|
|
725
|
+
* @remarks
|
|
726
|
+
* Calling this is optional but strongly preferred: **the caller owns the retry loop**, and this
|
|
727
|
+
* is what lets it stay in one dialog instead of closing and reopening one per attempt. A prompt
|
|
728
|
+
* that returns a password without validating it is still honored — it simply gets one attempt.
|
|
729
|
+
*
|
|
730
|
+
* Work is not repeated: a password that validated here is not decrypted a second time when the
|
|
731
|
+
* prompt resolves. Expect the call to take a noticeable moment (the derivation is deliberately
|
|
732
|
+
* expensive) and show a busy affordance rather than freezing the dialog.
|
|
733
|
+
*/
|
|
734
|
+
validate(password: string): Promise<boolean>;
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* A **registration-side** read format: the consumer-facing {@link FormatType} chrome plus the
|
|
738
|
+
* decode handler. Used by plugins / the registry only — the handler is never part of the
|
|
739
|
+
* consumption surface ({@link IWorkbookIO.getReadFormats} returns plain {@link FormatType}s).
|
|
740
|
+
*/
|
|
741
|
+
interface ReadFormatType extends FormatType {
|
|
742
|
+
/**
|
|
743
|
+
* The handler function for importing a workbook from this format.
|
|
744
|
+
*/
|
|
745
|
+
handler: ReadHandler;
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* A **registration-side** write format: the consumer-facing {@link FormatType} chrome plus the
|
|
749
|
+
* encode handler. Used by plugins / the registry only — the handler is never part of the
|
|
750
|
+
* consumption surface ({@link IWorkbookIO.getWriteFormats} returns plain {@link FormatType}s).
|
|
751
|
+
*/
|
|
752
|
+
interface WriteFormatType extends FormatType {
|
|
753
|
+
/**
|
|
754
|
+
* The handler function for exporting a workbook to this format.
|
|
755
|
+
*/
|
|
756
|
+
handler: WriteHandler;
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Options for reading and creating a workbook from various sources.
|
|
760
|
+
*/
|
|
761
|
+
interface ReadOptions {
|
|
762
|
+
/**
|
|
763
|
+
* The io source for reading. Can be a direct value, Promise, or function.
|
|
764
|
+
*
|
|
765
|
+
* @remarks
|
|
766
|
+
* Omit (or pass `null`) to let the active {@link IWorkbookIO.IBackingStore} resolve a source
|
|
767
|
+
* itself — for example a browser open picker. {@link IWorkbookIO.read} then resolves to `null`
|
|
768
|
+
* if nothing was opened (e.g. the user cancelled).
|
|
769
|
+
*/
|
|
770
|
+
source?: MaybePromise<IOSource> | (() => MaybePromise<IOSource>) | null;
|
|
771
|
+
/**
|
|
772
|
+
* Indicate the the workbook should be read-only.
|
|
773
|
+
*
|
|
774
|
+
* @remarks
|
|
775
|
+
* This is a shortcut to createWorkbookOptions.readonly = true
|
|
776
|
+
* If it is set in the createWorkbookOptions it will override this value.
|
|
777
|
+
*/
|
|
778
|
+
readonly?: boolean;
|
|
779
|
+
/**
|
|
780
|
+
* Read the workbook for calculation only, trading visual formatting for a faster, lighter read.
|
|
781
|
+
*
|
|
782
|
+
* @defaultValue false
|
|
783
|
+
*
|
|
784
|
+
* @remarks
|
|
785
|
+
* Use this when you need the data — values, formulas, and number formats — but not how it looks:
|
|
786
|
+
* headless calculation, server-side processing, data extraction. Calculated results are always
|
|
787
|
+
* correct; purely visual formatting (fonts, fills, borders, charts, images, …) may be skipped to
|
|
788
|
+
* save time and memory.
|
|
789
|
+
*/
|
|
790
|
+
calcOnly?: boolean;
|
|
791
|
+
/**
|
|
792
|
+
* Provide options to the workbook constructor.
|
|
793
|
+
*/
|
|
794
|
+
createWorkbookOptions?: IWorkbook.ConstructorOptions;
|
|
795
|
+
/**
|
|
796
|
+
* Optional file type hint (extension, MIME type, or import key).
|
|
797
|
+
*
|
|
798
|
+
* Used for type detection when it cannot be inferred from the source.
|
|
799
|
+
* Examples: 'xlsx', 'csv', 'application/json', 'Excel'
|
|
800
|
+
*/
|
|
801
|
+
format?: string;
|
|
802
|
+
/**
|
|
803
|
+
* Password for an encrypted source.
|
|
804
|
+
*
|
|
805
|
+
* @remarks
|
|
806
|
+
* Applies to **file encryption** (Excel's "password to open") — confidentiality of the bytes —
|
|
807
|
+
* and is handled by the IO layer for every format, not by any one format handler. It is
|
|
808
|
+
* unrelated to sheet/workbook *protection*, which is a hash-based UI gate stored in the model.
|
|
809
|
+
*
|
|
810
|
+
* Ignored when the source is not encrypted. Prefer {@link onPassword} for interactive callers:
|
|
811
|
+
* it can re-prompt when a password is rejected.
|
|
812
|
+
*/
|
|
813
|
+
password?: string;
|
|
814
|
+
/**
|
|
815
|
+
* Called **once** when the source is encrypted and no usable password is in hand.
|
|
816
|
+
*
|
|
817
|
+
* @param request The handle being opened, plus {@link PasswordRequest.validate} for trying a
|
|
818
|
+
* password without ending the prompt.
|
|
819
|
+
*
|
|
820
|
+
* @returns The accepted password, or `null` to cancel — {@link IWorkbookIO.read} then resolves
|
|
821
|
+
* to `null`, exactly as a dismissed open picker does.
|
|
822
|
+
*
|
|
823
|
+
* @remarks
|
|
824
|
+
* **The caller owns the retry loop.** Use `request.validate(password)` to test a password and
|
|
825
|
+
* keep prompting on `false`; return the password once it is accepted, or `null` when the user
|
|
826
|
+
* gives up. The IO layer does not re-invoke this, so a dialog opens once and stays open —
|
|
827
|
+
* rather than being torn down and rebuilt per attempt, which is visible as flicker.
|
|
828
|
+
*
|
|
829
|
+
* A caller that skips `validate` and returns a password directly gets exactly one attempt, and
|
|
830
|
+
* a wrong one raises `InvalidPasswordError`. That is the right shape for a non-interactive
|
|
831
|
+
* caller (a script, a server), which has nothing to re-prompt.
|
|
832
|
+
*/
|
|
833
|
+
onPassword?(request: IWorkbookIO.PasswordRequest): MaybePromise<string | null>;
|
|
834
|
+
/**
|
|
835
|
+
* Optional progress callback for long running imports.
|
|
836
|
+
*/
|
|
837
|
+
progress?: ITaskProgress<IWorkbookIO.Origin>;
|
|
838
|
+
/**
|
|
839
|
+
* Allows for different constructor arguments depending on the type of format detected.
|
|
840
|
+
*
|
|
841
|
+
* @remarks
|
|
842
|
+
* This will overwrite the options with the createWorkbookOptions provided.
|
|
843
|
+
*/
|
|
844
|
+
typedCreateWorkbookOptions?: Record<string, IWorkbook.ConstructorOptions>;
|
|
845
|
+
}
|
|
846
|
+
/**
|
|
847
|
+
* Options for writing and exporting a workbook — purely *how* to write (encoding concerns).
|
|
848
|
+
*
|
|
849
|
+
* @remarks
|
|
850
|
+
* The destination is not an option: it is the `target` parameter of {@link IWorkbookIO.write}
|
|
851
|
+
* (an export), or the workbook's own {@link IWorkbook.getOrigin | origin} when no target is
|
|
852
|
+
* given (a save). See `IO-DESIGN.md`.
|
|
853
|
+
*/
|
|
854
|
+
interface WriteOptions {
|
|
855
|
+
/**
|
|
856
|
+
* Optional file type hint (extension, MIME type, or export key).
|
|
857
|
+
*
|
|
858
|
+
* Used for type detection when it cannot be inferred from the destination.
|
|
859
|
+
* Examples: 'xlsx', 'csv', 'application/json', 'Excel'
|
|
860
|
+
*/
|
|
861
|
+
format?: string;
|
|
862
|
+
/**
|
|
863
|
+
* What to do about **file encryption** — a deliberate three-state field:
|
|
864
|
+
*
|
|
865
|
+
* | Value | Meaning |
|
|
866
|
+
* |---|---|
|
|
867
|
+
* | *omitted* | Keep the destination's current encryption |
|
|
868
|
+
* | `string` | Encrypt with this password |
|
|
869
|
+
* | `null` | Write plaintext **explicitly** — the "remove password" verb |
|
|
870
|
+
*
|
|
871
|
+
* @remarks
|
|
872
|
+
* Omitting it is *not* "write plaintext": re-saving an encrypted workbook must not quietly
|
|
873
|
+
* produce an unencrypted file, which is a security downgrade caused by a keystroke. When the
|
|
874
|
+
* destination is encrypted and no password is available, {@link IWorkbookIO.write} throws
|
|
875
|
+
* `PasswordRequiredError` rather than guessing. Removing encryption is possible, but has to be
|
|
876
|
+
* *said* — that is what `null` is for.
|
|
877
|
+
*
|
|
878
|
+
* Unrelated to sheet/workbook *protection*, which is model state and travels in the file.
|
|
879
|
+
*/
|
|
880
|
+
password?: string | null;
|
|
881
|
+
/**
|
|
882
|
+
* Optional progress callback for long running writes.
|
|
883
|
+
*/
|
|
884
|
+
progress?: ITaskProgress<IWorkbookIO.Origin>;
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* Options for {@link IWorkbookIO.writeAs} — everything a write takes, plus the one thing only a
|
|
888
|
+
* *reorigin* can mean.
|
|
889
|
+
*/
|
|
890
|
+
interface WriteAsOptions extends WriteOptions {
|
|
891
|
+
/**
|
|
892
|
+
* Force the store to **resolve a destination** even when the workbook's handle is already bound
|
|
893
|
+
* and writable — the "Save **As**" *interaction*.
|
|
894
|
+
*
|
|
895
|
+
* @remarks
|
|
896
|
+
* Without this a store persists silently to a handle it holds (see
|
|
897
|
+
* {@link IWorkbookIO.IBackingStore.write}), which is exactly right for Save and exactly wrong
|
|
898
|
+
* for a Save As the user asked for: re-targeting the origin to a name that happens to match the
|
|
899
|
+
* handle it already had would overwrite the original with no dialog at all.
|
|
900
|
+
*
|
|
901
|
+
* It is opt-in rather than implied by the verb, because {@link IWorkbookIO.writeAs} means
|
|
902
|
+
* *reorigin*, not *ask*: a script or host that named a real destination
|
|
903
|
+
* (`writeAs(wb, 'out/report.xlsx')`) wants it written, not a picker. Only the caller knows which
|
|
904
|
+
* of the two it is doing.
|
|
905
|
+
*
|
|
906
|
+
* "Resolve a destination" is the store's own affair — the native save picker in the browser.
|
|
907
|
+
* A store with no way to ask (a browser without the File System Access API, whose only write
|
|
908
|
+
* path is a download) simply writes; there is nothing to force.
|
|
909
|
+
*
|
|
910
|
+
* @defaultValue false
|
|
911
|
+
*/
|
|
912
|
+
prompt?: boolean;
|
|
913
|
+
}
|
|
914
|
+
/**
|
|
915
|
+
* A destination (and, optionally, source) for persisting workbooks — for example the local
|
|
916
|
+
* file system, a browser download, a VSCode host, or a cloud service.
|
|
917
|
+
*
|
|
918
|
+
* @remarks
|
|
919
|
+
* The active store is used by {@link IWorkbookIO.write} and can be replaced via
|
|
920
|
+
* {@link IWorkbookIO.setBackingStore}. A store is conceptually stateless from the caller's
|
|
921
|
+
* point of view; any session state it keeps (such as a browser `FileSystemFileHandle` for
|
|
922
|
+
* silent re-save) is a private implementation detail and never appears in these types.
|
|
923
|
+
*/
|
|
924
|
+
interface IBackingStore {
|
|
925
|
+
/**
|
|
926
|
+
* Persists the workbook described by the request.
|
|
927
|
+
*
|
|
928
|
+
* @returns The written {@link IWorkbookIO.Origin} handle (normally `request.origin`, updated
|
|
929
|
+
* in place), or `null` if cancelled.
|
|
930
|
+
*
|
|
931
|
+
* @remarks
|
|
932
|
+
* Optional. A read-only store omits it; {@link IWorkbookIO.canWrite} then reports `false` and
|
|
933
|
+
* {@link IWorkbookIO.write} throws. A store must implement at least one of `read` / `write`.
|
|
934
|
+
*/
|
|
935
|
+
write?(request: WriteRequest): Promise<IWorkbookIO.Origin | null>;
|
|
936
|
+
/**
|
|
937
|
+
* Acquires bytes for a workbook and decodes them (via {@link ReadRequest.decode}).
|
|
938
|
+
*
|
|
939
|
+
* @returns The decoded workbook, or `null` if the store could not produce one (e.g. the user
|
|
940
|
+
* cancelled an open picker, or the store does not recognize the source).
|
|
941
|
+
*
|
|
942
|
+
* @remarks
|
|
943
|
+
* Optional. {@link IWorkbookIO.read} uses the active store's `read` when present, and otherwise
|
|
944
|
+
* falls back to the built-in platform store — so a store that only overrides `write` still gets
|
|
945
|
+
* the default read behavior.
|
|
946
|
+
*/
|
|
947
|
+
read?(request: ReadRequest): Promise<IWorkbook | null>;
|
|
948
|
+
}
|
|
949
|
+
/**
|
|
950
|
+
* The request passed to {@link IWorkbookIO.IBackingStore.write}.
|
|
951
|
+
*
|
|
952
|
+
* @remarks
|
|
953
|
+
* The store receives the destination as an {@link IWorkbookIO.Origin} handle — never a
|
|
954
|
+
* fileName-vs-provenance ambiguity. Its contract:
|
|
955
|
+
* - **bound + writable** origin → persist to it silently (no dialog), *unless* {@link prompt}.
|
|
956
|
+
* - **unbound or read-only** origin, or {@link prompt} → resolve a destination itself (a save
|
|
957
|
+
* picker in the browser; an error in bare Node), using {@link suggestedName} for any
|
|
958
|
+
* prompt/default, and **update the handle in place** to the resolved destination (the store
|
|
959
|
+
* fills in a handle it resolved itself; it never overrides one that was already bound and
|
|
960
|
+
* writable).
|
|
961
|
+
*
|
|
962
|
+
* The store returns this same handle (updated in place — including the written `size`).
|
|
963
|
+
*/
|
|
964
|
+
interface WriteRequest {
|
|
965
|
+
/**
|
|
966
|
+
* The workbook being written.
|
|
967
|
+
*/
|
|
968
|
+
workbook: IWorkbook;
|
|
969
|
+
/**
|
|
970
|
+
* The resolved write format (consumer chrome — encoding runs through {@link encode}).
|
|
971
|
+
*/
|
|
972
|
+
format: FormatType;
|
|
973
|
+
/**
|
|
974
|
+
* The destination handle: the workbook's own origin for a save, or a minted one for an
|
|
975
|
+
* explicit-target export. May be unbound (`getPath()` `null`) — see the store contract above.
|
|
976
|
+
*/
|
|
977
|
+
origin: IWorkbookIO.Origin;
|
|
978
|
+
/**
|
|
979
|
+
* A suggested file name (with extension) for any destination prompt or default.
|
|
980
|
+
*/
|
|
981
|
+
suggestedName: string;
|
|
982
|
+
/**
|
|
983
|
+
* Resolve a destination even when {@link origin} is bound and writable — see
|
|
984
|
+
* {@link WriteAsOptions.prompt}, whose value this carries. A store that cannot ask ignores it.
|
|
985
|
+
*/
|
|
986
|
+
prompt?: boolean;
|
|
987
|
+
/**
|
|
988
|
+
* Encodes the workbook to bytes using the resolved format, or an alternate format key.
|
|
989
|
+
*
|
|
990
|
+
* @remarks
|
|
991
|
+
* Call this **after** resolving the destination (e.g. once a Save picker / permission prompt has
|
|
992
|
+
* returned). The first invocation also fires the caller's {@link ITaskProgress.onStart}, so
|
|
993
|
+
* encoding before the prompt resolves would show progress UI on top of the dialog. A store that
|
|
994
|
+
* is cancelled should return without calling `encode`, so `onStart` never fires for it.
|
|
995
|
+
*/
|
|
996
|
+
encode: (format?: string) => Promise<ArrayBufferLike>;
|
|
997
|
+
}
|
|
998
|
+
/**
|
|
999
|
+
* The request passed to {@link IWorkbookIO.IBackingStore.read}.
|
|
1000
|
+
*
|
|
1001
|
+
* @remarks
|
|
1002
|
+
* A store's job is **source acquisition** — turn `source` (or, when it is `null`, a location it
|
|
1003
|
+
* resolves itself, e.g. an open picker) into bytes — and then call {@link ReadRequest.decode},
|
|
1004
|
+
* which handles format detection and workbook construction. This mirrors how
|
|
1005
|
+
* {@link WriteRequest.encode} keeps format concerns out of the store.
|
|
1006
|
+
*/
|
|
1007
|
+
interface ReadRequest {
|
|
1008
|
+
/**
|
|
1009
|
+
* The source to read from, or `null` for the store to resolve a location itself.
|
|
1010
|
+
*/
|
|
1011
|
+
source: ReadOptions['source'] | null;
|
|
1012
|
+
/**
|
|
1013
|
+
* The read options (format hint, name, createWorkbookOptions, progress, etc.).
|
|
1014
|
+
*/
|
|
1015
|
+
options: Omit<ReadOptions, 'source'>;
|
|
1016
|
+
/**
|
|
1017
|
+
* Decodes acquired bytes into a workbook: resolves the format, unwraps any encryption envelope
|
|
1018
|
+
* (prompting via {@link ReadOptions.onPassword}), mints the origin handle (which the workbook
|
|
1019
|
+
* carries), runs the handler, and reports progress. The store supplies what it knows about the
|
|
1020
|
+
* source via {@link ReadInfo}.
|
|
1021
|
+
*
|
|
1022
|
+
* @returns The decoded workbook, or `null` if the caller cancelled a password prompt — a store
|
|
1023
|
+
* should return that `null` onward, the same as it would for a dismissed picker.
|
|
1024
|
+
*/
|
|
1025
|
+
decode(bytes: ArrayBufferLike, info?: ReadInfo): Promise<IWorkbook | null>;
|
|
1026
|
+
}
|
|
1027
|
+
/**
|
|
1028
|
+
* What a {@link IWorkbookIO.IBackingStore} knows about an acquired source, passed to
|
|
1029
|
+
* {@link ReadRequest.decode}.
|
|
1030
|
+
*/
|
|
1031
|
+
interface ReadInfo {
|
|
1032
|
+
/**
|
|
1033
|
+
* Explicit format hint (extension, MIME type, or key), if any.
|
|
1034
|
+
*/
|
|
1035
|
+
format?: string;
|
|
1036
|
+
/**
|
|
1037
|
+
* File extension derived from the source name, used for format detection.
|
|
1038
|
+
*/
|
|
1039
|
+
ext?: string;
|
|
1040
|
+
/**
|
|
1041
|
+
* The source's display name (without path), if known.
|
|
1042
|
+
*/
|
|
1043
|
+
name?: string;
|
|
1044
|
+
/**
|
|
1045
|
+
* The source's absolute path or URL, if known — recorded as the workbook's origin.
|
|
1046
|
+
*/
|
|
1047
|
+
absolutePath?: string;
|
|
1048
|
+
/**
|
|
1049
|
+
* The source size in bytes, if known.
|
|
1050
|
+
*/
|
|
1051
|
+
size?: number;
|
|
1052
|
+
/**
|
|
1053
|
+
* The detected source type (e.g. `'file'`, `'fetch'`), used for a fallback display name.
|
|
1054
|
+
*/
|
|
1055
|
+
sourceType?: string;
|
|
1056
|
+
/**
|
|
1057
|
+
* Whether the acquired source can be written back to (a silent re-save). Only the store knows —
|
|
1058
|
+
* e.g. a local fs path can (Node), a browser `File` can only when the store holds a writable
|
|
1059
|
+
* handle for it. Defaults to `false` when omitted; seeds the minted origin's
|
|
1060
|
+
* {@link IWorkbookIO.Origin.canWrite}.
|
|
1061
|
+
*/
|
|
1062
|
+
canWrite?: boolean;
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* For reading from an array into an IWorkbook.
|
|
1066
|
+
*
|
|
1067
|
+
* @param arrayBuffer The array buffer containing the workbook data.
|
|
1068
|
+
* @param options Optional options for loading the workbook, such as format type and workbook options.
|
|
1069
|
+
* @returns A promise that resolves to an IWorkbook instance.
|
|
1070
|
+
*/
|
|
1071
|
+
type ReadHandler = (arrayBuffer: ArrayBuffer, options?: Omit<IWorkbookIO.ReadOptions, 'source'>) => Promise<IWorkbook>;
|
|
1072
|
+
/**
|
|
1073
|
+
* Export for writing to an array from an IWorkbook
|
|
1074
|
+
*
|
|
1075
|
+
* @param workbook The workbook instance to export.
|
|
1076
|
+
* @param options Optional options for saving the workbook, such as compression and whitespace formatting.
|
|
1077
|
+
* @returns A promise that resolves to an array buffer representing the workbook
|
|
1078
|
+
*/
|
|
1079
|
+
type WriteHandler = (workbook: IWorkbook, options?: Omit<IWorkbookIO.WriteOptions, 'source'>) => Promise<ArrayBufferLike>;
|
|
1080
|
+
/**
|
|
1081
|
+
* Options for filtering and searching format types.
|
|
1082
|
+
*
|
|
1083
|
+
* @remarks
|
|
1084
|
+
* All options are combined using **AND logic**. A format must match all specified criteria to be included.
|
|
1085
|
+
*
|
|
1086
|
+
* ## Search vs Filters
|
|
1087
|
+
*
|
|
1088
|
+
* ### `search` - Case-insensitive partial match (OR across fields)
|
|
1089
|
+
* Searches across multiple fields (key, extensions, MIME type, tags, description) and includes
|
|
1090
|
+
* formats where **ANY** field contains the search term.
|
|
1091
|
+
*
|
|
1092
|
+
* ### Other options - Exact filters (AND across options)
|
|
1093
|
+
* All other options are exact filters that must match precisely. A format must satisfy
|
|
1094
|
+
* **ALL** specified filters to be included.
|
|
1095
|
+
*
|
|
1096
|
+
* @example
|
|
1097
|
+
* ```typescript
|
|
1098
|
+
* // Search: Find formats containing "excel" anywhere
|
|
1099
|
+
* getFormats({ search: 'excel' }); // Matches xlsx (in description), xml (in tags), etc.
|
|
1100
|
+
*
|
|
1101
|
+
* // Filter: Get only xlsx format
|
|
1102
|
+
* getFormats({ ext: '.xlsx' }); // Exact match on extension
|
|
1103
|
+
*
|
|
1104
|
+
* // Combined: Search for "excel" AND spreadsheet tag
|
|
1105
|
+
* getFormats({ search: 'excel', tags: 'spreadsheet' });
|
|
1106
|
+
*
|
|
1107
|
+
* // Multiple filters: xlsx extension AND spreadsheet tag
|
|
1108
|
+
* getFormats({ ext: '.xlsx', tags: 'spreadsheet' });
|
|
1109
|
+
* ```
|
|
1110
|
+
*/
|
|
1111
|
+
interface GetFormatsOptions {
|
|
1112
|
+
/**
|
|
1113
|
+
* Case-insensitive partial search across multiple fields.
|
|
1114
|
+
*
|
|
1115
|
+
* @remarks
|
|
1116
|
+
* Searches in: key, file extensions, MIME type, tags, and description.
|
|
1117
|
+
* Returns formats where **ANY** field contains the search term (OR logic).
|
|
1118
|
+
*
|
|
1119
|
+
* Use this for user-facing search boxes or fuzzy matching.
|
|
1120
|
+
*
|
|
1121
|
+
* @example
|
|
1122
|
+
* ```typescript
|
|
1123
|
+
* // Find all Excel-related formats
|
|
1124
|
+
* getFormats({ search: 'excel' });
|
|
1125
|
+
*
|
|
1126
|
+
* // Find formats with "xml" anywhere
|
|
1127
|
+
* getFormats({ search: 'xml' });
|
|
1128
|
+
* ```
|
|
1129
|
+
*/
|
|
1130
|
+
search?: string;
|
|
1131
|
+
/**
|
|
1132
|
+
* Filter by exact file extension (e.g., `'.xlsx'`, `'.csv'`).
|
|
1133
|
+
*
|
|
1134
|
+
* @remarks
|
|
1135
|
+
* - Include the dot prefix
|
|
1136
|
+
* - Case-insensitive exact match
|
|
1137
|
+
* - Use this when you know the exact extension you want
|
|
1138
|
+
*
|
|
1139
|
+
* @example
|
|
1140
|
+
* ```typescript
|
|
1141
|
+
* // Get only XLSX formats
|
|
1142
|
+
* getFormats({ ext: '.xlsx' });
|
|
1143
|
+
* ```
|
|
1144
|
+
*/
|
|
1145
|
+
ext?: string;
|
|
1146
|
+
/**
|
|
1147
|
+
* Filter by exact MIME type (e.g., `'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'`).
|
|
1148
|
+
*
|
|
1149
|
+
* @remarks
|
|
1150
|
+
* - Case-sensitive exact match
|
|
1151
|
+
* - Useful for matching HTTP Content-Type headers
|
|
1152
|
+
*
|
|
1153
|
+
* @example
|
|
1154
|
+
* ```typescript
|
|
1155
|
+
* // Get format by MIME type
|
|
1156
|
+
* getFormats({ mimeType: 'text/csv' });
|
|
1157
|
+
* ```
|
|
1158
|
+
*/
|
|
1159
|
+
mimeType?: string;
|
|
1160
|
+
/**
|
|
1161
|
+
* Filter by exact format key.
|
|
1162
|
+
*
|
|
1163
|
+
* @remarks
|
|
1164
|
+
* - Case-insensitive exact match
|
|
1165
|
+
* - The key is the unique identifier for each format (e.g., 'xlsx', 'csv', 'sxl')
|
|
1166
|
+
* - Use this when you need to find a specific format by its identifier
|
|
1167
|
+
*
|
|
1168
|
+
* @example
|
|
1169
|
+
* ```typescript
|
|
1170
|
+
* // Get the XLSX format
|
|
1171
|
+
* getFormats({ key: 'xlsx' });
|
|
1172
|
+
* ```
|
|
1173
|
+
*/
|
|
1174
|
+
key?: string;
|
|
1175
|
+
/**
|
|
1176
|
+
* Filter by exact tags (e.g., `'spreadsheet'`, `'text'`).
|
|
1177
|
+
*
|
|
1178
|
+
* @remarks
|
|
1179
|
+
* - Exact string match (case-sensitive)
|
|
1180
|
+
* - If multiple tags are needed, pass an array
|
|
1181
|
+
* - Returns formats that have **ALL** specified tags (AND logic)
|
|
1182
|
+
*
|
|
1183
|
+
* @example
|
|
1184
|
+
* ```typescript
|
|
1185
|
+
* // Get formats tagged as 'spreadsheet'
|
|
1186
|
+
* getFormats({ tags: 'spreadsheet' });
|
|
1187
|
+
*
|
|
1188
|
+
* // Get formats with both 'spreadsheet' and 'binary' tags
|
|
1189
|
+
* getFormats({ tags: ['spreadsheet', 'binary'] });
|
|
1190
|
+
* ```
|
|
1191
|
+
*/
|
|
1192
|
+
tags?: string | string[];
|
|
1193
|
+
}
|
|
1194
|
+
interface Registry {
|
|
1195
|
+
/**
|
|
1196
|
+
* Registers a new read format type or replaces an existing one.
|
|
1197
|
+
*
|
|
1198
|
+
* @param format The format type definition containing decoder logic.
|
|
1199
|
+
*
|
|
1200
|
+
* @remarks
|
|
1201
|
+
* Use this to add support for new workbook encoding formats (not source types).
|
|
1202
|
+
* If a format with the same `key` already exists, it will be replaced.
|
|
1203
|
+
*
|
|
1204
|
+
* This allows you to:
|
|
1205
|
+
* - Add custom format types (e.g., proprietary formats)
|
|
1206
|
+
* - Override built-in format handlers
|
|
1207
|
+
* - Extend format support for your application
|
|
1208
|
+
*
|
|
1209
|
+
* The registered format will work with **all source types** automatically.
|
|
1210
|
+
*
|
|
1211
|
+
* @example
|
|
1212
|
+
* ```typescript
|
|
1213
|
+
* // Register a custom XML-based format
|
|
1214
|
+
* workbookIO.registerReadFormat({
|
|
1215
|
+
* key: 'custom-xml',
|
|
1216
|
+
* description: 'Custom XML Workbook Format',
|
|
1217
|
+
* mimeType: 'application/x-custom-workbook+xml',
|
|
1218
|
+
* exts: ['.cwb', '.cxml'],
|
|
1219
|
+
* tags: ['xml', 'custom'],
|
|
1220
|
+
* handler: async (buffer, options) => {
|
|
1221
|
+
* // Decode buffer into IWorkbook
|
|
1222
|
+
* const xmlString = new TextDecoder().decode(buffer);
|
|
1223
|
+
* return parseCustomXML(xmlString);
|
|
1224
|
+
* }
|
|
1225
|
+
* });
|
|
1226
|
+
*
|
|
1227
|
+
* // Now any source type can use this format
|
|
1228
|
+
* await workbookIO.read({ source: 'data.cwb' }); // Auto-detected
|
|
1229
|
+
* await workbookIO.read({ source: fileObject, format: 'custom-xml' });
|
|
1230
|
+
* ```
|
|
1231
|
+
*/
|
|
1232
|
+
registerReadFormat(format: IWorkbookIO.ReadFormatType): Promise<void>;
|
|
1233
|
+
/**
|
|
1234
|
+
* Registers a new write format type or replaces an existing one.
|
|
1235
|
+
*
|
|
1236
|
+
* @param format The format type definition containing encoder logic.
|
|
1237
|
+
*
|
|
1238
|
+
* @remarks
|
|
1239
|
+
* Use this to add support for new workbook encoding formats (not source types).
|
|
1240
|
+
* If a format with the same `key` already exists, it will be replaced.
|
|
1241
|
+
*
|
|
1242
|
+
* This allows you to:
|
|
1243
|
+
* - Add custom format types (e.g., proprietary formats)
|
|
1244
|
+
* - Override built-in format handlers
|
|
1245
|
+
* - Extend format support for your application
|
|
1246
|
+
*
|
|
1247
|
+
* The registered format can then be written to **any source type** (File, ArrayBuffer, etc.).
|
|
1248
|
+
*
|
|
1249
|
+
* @example
|
|
1250
|
+
* ```typescript
|
|
1251
|
+
* // Register a custom JSON-based format
|
|
1252
|
+
* workbookIO.registerWriteFormat({
|
|
1253
|
+
* key: 'custom-json',
|
|
1254
|
+
* description: 'Custom JSON Workbook Format',
|
|
1255
|
+
* mimeType: 'application/json',
|
|
1256
|
+
* ext: '.cjson',
|
|
1257
|
+
* tags: ['json', 'custom'],
|
|
1258
|
+
* handler: async (workbook, options) => {
|
|
1259
|
+
* // Encode workbook into ArrayBuffer
|
|
1260
|
+
* const jsonString = JSON.stringify(customSerialize(workbook));
|
|
1261
|
+
* return new TextEncoder().encode(jsonString).buffer;
|
|
1262
|
+
* }
|
|
1263
|
+
* });
|
|
1264
|
+
*
|
|
1265
|
+
* // Use with any write method
|
|
1266
|
+
* await workbookIO.write(workbook, { fileName: 'report.cjson' });
|
|
1267
|
+
* const buffer = await workbookIO.writeArrayBuffer(workbook, { format: 'custom-json' });
|
|
1268
|
+
* ```
|
|
1269
|
+
*/
|
|
1270
|
+
registerWriteFormat(format: IWorkbookIO.WriteFormatType): Promise<void>;
|
|
1271
|
+
/**
|
|
1272
|
+
* Registers an encryption envelope, or replaces an existing one with the same `key`.
|
|
1273
|
+
*
|
|
1274
|
+
* @param encryption The envelope definition (detect / decode / encode).
|
|
1275
|
+
*
|
|
1276
|
+
* @remarks
|
|
1277
|
+
* An envelope is **format-independent** — it wraps whatever bytes a format handler produced —
|
|
1278
|
+
* so registering one enables password support for every registered format at once. See
|
|
1279
|
+
* {@link IWorkbookIO.EncryptionType}.
|
|
1280
|
+
*
|
|
1281
|
+
* @example
|
|
1282
|
+
* ```typescript
|
|
1283
|
+
* registry.registerEncryption({
|
|
1284
|
+
* key: 'offcrypto',
|
|
1285
|
+
* description: 'Office Document Encryption',
|
|
1286
|
+
* detect: (bytes) => isEncryptedOfficeContainer(bytes),
|
|
1287
|
+
* decode: (bytes, password) => decryptOffCrypto(bytes, password),
|
|
1288
|
+
* encode: (bytes, password) => encryptOffCrypto(bytes, password)
|
|
1289
|
+
* });
|
|
1290
|
+
* ```
|
|
1291
|
+
*/
|
|
1292
|
+
registerEncryption(encryption: IWorkbookIO.EncryptionType): Promise<void>;
|
|
1293
|
+
}
|
|
1294
|
+
/**
|
|
1295
|
+
* Interface for format plugins that can be installed into the workbook I/O system.
|
|
1296
|
+
*/
|
|
1297
|
+
interface Plugin {
|
|
1298
|
+
/**
|
|
1299
|
+
* The name of the plugin.
|
|
1300
|
+
*/
|
|
1301
|
+
name: string;
|
|
1302
|
+
/**
|
|
1303
|
+
* The version of the plugin.
|
|
1304
|
+
*/
|
|
1305
|
+
version?: string;
|
|
1306
|
+
/**
|
|
1307
|
+
* The description of the plugin.
|
|
1308
|
+
*/
|
|
1309
|
+
description?: string;
|
|
1310
|
+
/**
|
|
1311
|
+
* The author of the plugin.
|
|
1312
|
+
*/
|
|
1313
|
+
author?: string;
|
|
1314
|
+
/**
|
|
1315
|
+
* Function to register the new io types into a given IWorkbookIO instance.
|
|
1316
|
+
*
|
|
1317
|
+
* @param registry The IWorkbookIO registry to install the plugin into.
|
|
1318
|
+
*/
|
|
1319
|
+
register: (registry: IWorkbookIO.Registry) => Promise<void> | void;
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
//# sourceMappingURL=IWorkbookIO.d.ts.map
|