@sheetxl/io-xlsx 0.8.0-beta.2 → 0.8.0-beta.20

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.
Files changed (217) hide show
  1. package/LICENSE.md +8 -7
  2. package/browser/esm/Bw35-W8cnzxxvqQy.mjs +104 -0
  3. package/browser/esm/{CMHb6pUUmsCP9r_9.mjs → C16bEh6IrUpJONhS.mjs} +3 -3
  4. package/browser/esm/CPK1-z95jtLOfCXG.mjs +2474 -0
  5. package/browser/esm/CSOuRlSN9bhykqDr.mjs +4627 -0
  6. package/browser/esm/{DhqYgh9G2vLn7mIE.mjs → D2872f7aTugYxhht.mjs} +3 -3
  7. package/browser/esm/D7ogsrtXfjU5NW7r.mjs +10312 -0
  8. package/browser/esm/D8CQKL3Y3CMFOPqD.mjs +7007 -0
  9. package/browser/esm/{CMzkLUwbgA73RvCb.mjs → DpPFQ7-tBwVyjvWr.mjs} +3 -3
  10. package/browser/esm/{IZf0hIeLYj3T0Xvu.mjs → PgUWs0pPSCSFYJtU.mjs} +194 -144
  11. package/browser/esm/RFSuXvJ9sgsaA2LC.mjs +2433 -0
  12. package/browser/esm/{_UDbQq5-pHbU1f82.mjs → S4Uq85YdUb6O5Pz0.mjs} +2 -2
  13. package/browser/esm/index.mjs +3 -4
  14. package/licenses/dependencies.txt +2 -2
  15. package/node/esm/BOAucs-qLpjtUOcZ.mjs +6957 -0
  16. package/node/esm/{CY-pSutJLHskZfXZ.mjs → BSHqfcsR9hY-JB30.mjs} +2 -2
  17. package/node/esm/{CB1ijGbhl-e2l6Mm.mjs → C6eSWtTkyDQKbQdT.mjs} +3 -3
  18. package/node/esm/{Bi_kZVtZams7taqa.mjs → CPhiu1T7tl-leKh2.mjs} +3 -3
  19. package/node/esm/D2vDZOgLcv-YiWnB.mjs +4741 -0
  20. package/node/esm/DFw0ibBUmPyd-wey.mjs +2479 -0
  21. package/node/esm/DGuQIj077oygCTGu.mjs +2562 -0
  22. package/node/esm/Qn2Bv4QG3mOLiJHh.mjs +7269 -0
  23. package/node/esm/index.mjs +65 -28
  24. package/package.json +8 -9
  25. package/types/src/AutoFilterRules.d.ts +85 -22
  26. package/types/src/ConditionalFormatRules.d.ts +2 -2
  27. package/types/src/DataTableFormula.d.ts +26 -0
  28. package/types/src/DataValidationRules.d.ts +0 -5
  29. package/types/src/DefinedNameAttributes.d.ts +8 -0
  30. package/types/src/ExcelCalcStamp.d.ts +0 -36
  31. package/types/src/ExcelCompat.d.ts +15 -143
  32. package/types/src/ExcelFunctionFacts.d.ts +0 -272
  33. package/types/src/ExcelReservedNames.d.ts +0 -65
  34. package/types/src/KnownFonts.d.ts +37 -0
  35. package/types/src/LegacyFormula.d.ts +1 -46
  36. package/types/src/OOXMLExtensions.d.ts +30 -2
  37. package/types/src/PageLayoutAttributes.d.ts +8 -0
  38. package/types/src/Plugin.d.ts +15 -3
  39. package/types/src/ProtectionAttributes.d.ts +2 -2
  40. package/types/src/SheetKinds.d.ts +42 -0
  41. package/types/src/SheetViewAttributes.d.ts +4 -0
  42. package/types/src/SortExtent.d.ts +16 -0
  43. package/types/src/SourcePackage.d.ts +0 -44
  44. package/types/src/SparklineGroups.d.ts +52 -0
  45. package/types/src/Types.d.ts +13 -3
  46. package/types/src/XlsxHeader.d.ts +19 -0
  47. package/types/src/chart/ChartExXml.d.ts +38 -0
  48. package/types/src/chart/ChartPartXml.d.ts +47 -0
  49. package/types/src/chart/ChartSpaceXml.d.ts +37 -0
  50. package/types/src/chart/_XmlTree.d.ts +34 -0
  51. package/types/src/chart/_chartCodecs.d.ts +12 -0
  52. package/types/src/chart/_chartExCodecs.d.ts +7 -0
  53. package/types/src/chart/_chartExFold.d.ts +14 -0
  54. package/types/src/chart/_chartExMarkup.d.ts +236 -0
  55. package/types/src/chart/_chartExStyle.d.ts +13 -0
  56. package/types/src/chart/_codec.d.ts +78 -0
  57. package/types/src/chart/_drawingml.d.ts +10 -0
  58. package/types/src/chart/_xml.d.ts +70 -0
  59. package/types/src/pivot/PivotArea.d.ts +20 -0
  60. package/types/src/pivot/PivotCacheRead.d.ts +30 -0
  61. package/types/src/pivot/PivotCacheWrite.d.ts +23 -0
  62. package/types/src/pivot/PivotFilters.d.ts +29 -0
  63. package/types/src/pivot/PivotFormats.d.ts +60 -0
  64. package/types/src/pivot/PivotTableRead.d.ts +44 -0
  65. package/types/src/pivot/PivotTableWrite.d.ts +13 -0
  66. package/types/src/pivot/_PivotCacheXml.d.ts +48 -0
  67. package/types/src/pivot/_PivotTableXml.d.ts +23 -0
  68. package/types/src/reader/CellControls.d.ts +18 -0
  69. package/types/src/reader/DocumentPropertiesRead.d.ts +16 -0
  70. package/types/src/reader/DummyFunctionUnwrap.d.ts +43 -23
  71. package/types/src/reader/HeaderStyles.d.ts +15 -0
  72. package/types/src/reader/IsoDateCell.d.ts +20 -0
  73. package/types/src/reader/LibreOfficeDataTable.d.ts +12 -0
  74. package/types/src/reader/PivotButtons.d.ts +14 -0
  75. package/types/src/reader/PivotCellFormats.d.ts +22 -0
  76. package/types/src/reader/SlicerJoin.d.ts +26 -0
  77. package/types/src/reader/ZipReader.d.ts +1 -1
  78. package/types/src/reader/_SlicerRecord.d.ts +59 -0
  79. package/types/src/reader/dom/CustGeomUtils.d.ts +7 -0
  80. package/types/src/reader/dom/DOMTransformer.d.ts +2 -2
  81. package/types/src/reader/domVisitors/AppPropertiesVisitor.d.ts +13 -1
  82. package/types/src/reader/domVisitors/AutoFilterVisitor.d.ts +8 -3
  83. package/types/src/reader/domVisitors/ColorContainerVisitor.d.ts +15 -2
  84. package/types/src/reader/domVisitors/CommentVisitor.d.ts +7 -2
  85. package/types/src/reader/domVisitors/DrawingCxnSpVisitor.d.ts +1 -0
  86. package/types/src/reader/domVisitors/DrawingElementVisitor.d.ts +34 -1
  87. package/types/src/reader/domVisitors/DrawingGraphicFrameVisitor.d.ts +9 -0
  88. package/types/src/reader/domVisitors/DrawingGrpSpVisitor.d.ts +14 -2
  89. package/types/src/reader/domVisitors/DrawingPicVisitor.d.ts +30 -2
  90. package/types/src/reader/domVisitors/DrawingSpVisitor.d.ts +20 -1
  91. package/types/src/reader/domVisitors/DrawingVisitor.d.ts +10 -0
  92. package/types/src/reader/domVisitors/ExternalLinkVisitor.d.ts +1 -11
  93. package/types/src/reader/domVisitors/FeaturePropertyBagVisitor.d.ts +18 -0
  94. package/types/src/reader/domVisitors/FmtSchemeVisitor.d.ts +0 -11
  95. package/types/src/reader/domVisitors/FontSchemeVisitor.d.ts +3 -2
  96. package/types/src/reader/domVisitors/FormControlPrVisitor.d.ts +9 -0
  97. package/types/src/reader/domVisitors/ObjectDefaultsVisitor.d.ts +11 -0
  98. package/types/src/reader/domVisitors/ShapeTextVisitor.d.ts +44 -0
  99. package/types/src/reader/domVisitors/SheetColorContainerVisitor.d.ts +2 -2
  100. package/types/src/reader/domVisitors/SheetStyleVisitor.d.ts +26 -5
  101. package/types/src/reader/domVisitors/SlicerCacheDefinitionVisitor.d.ts +11 -2
  102. package/types/src/reader/domVisitors/SlicersVisitor.d.ts +9 -3
  103. package/types/src/reader/domVisitors/SortStateVisitor.d.ts +2 -2
  104. package/types/src/reader/domVisitors/TextPropertiesVisitor.d.ts +13 -1
  105. package/types/src/reader/domVisitors/ThreadedCommentVisitor.d.ts +9 -0
  106. package/types/src/reader/domVisitors/ThreadedCommentsVisitor.d.ts +2 -2
  107. package/types/src/reader/domVisitors/TimelinesVisitor.d.ts +13 -0
  108. package/types/src/reader/domVisitors/WorkbookVisitor.d.ts +0 -9
  109. package/types/src/reader/domVisitors/_Dxfs.d.ts +10 -0
  110. package/types/src/reader/domVisitors/index.d.ts +10 -36
  111. package/types/src/reader/saxVisitors/ContentTypesVisitor.d.ts +1 -0
  112. package/types/src/reader/saxVisitors/SharedStringsVisitor.d.ts +31 -6
  113. package/types/src/reader/saxVisitors/WorksheetVisitor.d.ts +26 -8
  114. package/types/src/richValue/ErrorRichValueHandler.d.ts +22 -0
  115. package/types/src/richValue/IRichValueHandler.d.ts +109 -0
  116. package/types/src/richValue/LocalImageRichValueHandler.d.ts +18 -0
  117. package/types/src/richValue/RichDataParts.d.ts +69 -0
  118. package/types/src/richValue/RichRecordWriter.d.ts +61 -0
  119. package/types/src/richValue/RichValueHandlers.d.ts +25 -0
  120. package/types/src/richValue/RichValueResolver.d.ts +54 -0
  121. package/types/src/richValue/WebImageRichValueHandler.d.ts +37 -0
  122. package/types/src/richValue/index.d.ts +7 -0
  123. package/types/src/utils/DrawingMLText.d.ts +39 -0
  124. package/types/src/utils/FormControls.d.ts +170 -0
  125. package/types/src/utils/SharedNames.d.ts +13 -0
  126. package/types/src/utils/SpreadsheetFont.d.ts +38 -0
  127. package/types/src/utils/VmlNoteShapes.d.ts +88 -35
  128. package/types/src/utils/VmlNoteStyle.d.ts +25 -0
  129. package/types/src/utils/VmlPrefixes.d.ts +24 -0
  130. package/types/src/vba/VBAProject.d.ts +0 -19
  131. package/types/src/writer/EvaluationSheet.d.ts +5 -0
  132. package/types/src/writer/builder/Emitter.d.ts +5 -0
  133. package/types/src/writer/builder/OpcXmlUtils.d.ts +0 -8
  134. package/types/src/writer/builder/PackageBuilder.d.ts +4 -41
  135. package/types/src/writer/builder/Types.d.ts +28 -28
  136. package/types/src/writer/emitters/CommentsEmitter.d.ts +10 -4
  137. package/types/src/writer/emitters/DrawingEmitter.d.ts +2 -2
  138. package/types/src/writer/emitters/ExternalLinkEmitter.d.ts +0 -11
  139. package/types/src/writer/emitters/FeaturePropertyBagEmitter.d.ts +8 -0
  140. package/types/src/writer/emitters/LegacyDrawingEmitter.d.ts +4 -4
  141. package/types/src/writer/emitters/PivotTableEmitter.d.ts +30 -1
  142. package/types/src/writer/emitters/PropsCoreEmitter.d.ts +7 -2
  143. package/types/src/writer/emitters/PropsCustomEmitter.d.ts +15 -0
  144. package/types/src/writer/emitters/RichValuePartsEmitters.d.ts +36 -0
  145. package/types/src/writer/emitters/RichValueRelEmitter.d.ts +12 -0
  146. package/types/src/writer/emitters/RichValueStructureEmitter.d.ts +4 -3
  147. package/types/src/writer/emitters/RichValueTypesEmitter.d.ts +3 -2
  148. package/types/src/writer/emitters/RichValueWebImageEmitter.d.ts +24 -0
  149. package/types/src/writer/emitters/SharedStringsEmitter.d.ts +6 -3
  150. package/types/src/writer/emitters/SlicerEmitter.d.ts +132 -0
  151. package/types/src/writer/emitters/StylesEmitter.d.ts +35 -2
  152. package/types/src/writer/emitters/TableEmitter.d.ts +14 -0
  153. package/types/src/writer/emitters/ThreadedCommentsEmitter.d.ts +7 -1
  154. package/types/src/writer/emitters/WorkbookEmitter.d.ts +24 -2
  155. package/types/src/writer/emitters/WorksheetEmitter.d.ts +4 -3
  156. package/types/src/writer/utils/AutoFilter.d.ts +3 -3
  157. package/types/src/writer/utils/CellControlComplements.d.ts +29 -0
  158. package/types/src/writer/utils/CustGeomUtils.d.ts +5 -0
  159. package/types/src/writer/utils/DateSystem.d.ts +6 -0
  160. package/types/src/writer/utils/DefaultRows.d.ts +22 -0
  161. package/types/src/writer/utils/DrawMLUtils.d.ts +42 -3
  162. package/types/src/writer/utils/DummyFunction.d.ts +0 -25
  163. package/types/src/writer/utils/DxfCollector.d.ts +14 -11
  164. package/types/src/writer/utils/PrstGeomUtils.d.ts +6 -0
  165. package/types/src/writer/utils/RichValueCollector.d.ts +81 -129
  166. package/types/src/writer/utils/SheetStyleLayout.d.ts +86 -0
  167. package/types/src/writer/utils/TextUtils.d.ts +26 -2
  168. package/types/src/writer/utils/UnsupportedFunctions.d.ts +2 -2
  169. package/types/src/writer/utils/XfVariants.d.ts +61 -0
  170. package/browser/cjs/B6sirGz6w-Bm7Ofo.cjs +0 -1
  171. package/browser/cjs/B7_pDFYCVzt-3hUs.cjs +0 -1
  172. package/browser/cjs/BzOEBR0jaxXg9wvt.cjs +0 -5
  173. package/browser/cjs/C8oC1tPbhgR0Dqtx.cjs +0 -2
  174. package/browser/cjs/CIpMN7SDVREKQUQE.cjs +0 -6
  175. package/browser/cjs/Ca-xJDjg5bOpUPXX.cjs +0 -1
  176. package/browser/cjs/D3EWCPfCu-qMOIGd.cjs +0 -1
  177. package/browser/cjs/DULsYP_GcPGLVYSE.cjs +0 -11
  178. package/browser/cjs/DtBN3UOzNJjYBwJ6.cjs +0 -1
  179. package/browser/cjs/index.cjs +0 -1
  180. package/browser/cjs/sNZR19Wk-XQ2xZ9E.cjs +0 -1
  181. package/browser/cjs/xQ6-wbTw5UzZUM1Y.cjs +0 -1
  182. package/browser/esm/B9q618XELV7uWJsA.mjs +0 -67
  183. package/browser/esm/BwbMurFOptAFs7gC.mjs +0 -5214
  184. package/browser/esm/D75_rfogFUfXADKc.mjs +0 -3324
  185. package/browser/esm/DfuBawaydlvgZMR-.mjs +0 -4428
  186. package/browser/esm/DoMlKUCnMSlR2qX5.mjs +0 -159
  187. package/browser/esm/DtpWa7tZahylJ3HS.mjs +0 -2310
  188. package/node/esm/BD03jrMQ_UKA196-.mjs +0 -4535
  189. package/node/esm/BxHvzSROx_N_7nJH.mjs +0 -2356
  190. package/node/esm/CO1M1H1N6fB422K-.mjs +0 -2959
  191. package/node/esm/CWpezSa6TERGEv-B.mjs +0 -3410
  192. package/node/esm/Dezt2uIDqlxjiuk5.mjs +0 -170
  193. package/types/src/legacyChart/OOXMLMappings.d.ts +0 -8
  194. package/types/src/legacyChart/OOXMLUtils.d.ts +0 -78
  195. package/types/src/legacyChart/ToOOXMLConverter.d.ts +0 -30
  196. package/types/src/reader/domVisitors/AxisVisitor.d.ts +0 -12
  197. package/types/src/reader/domVisitors/BarChartTypeVisitor.d.ts +0 -6
  198. package/types/src/reader/domVisitors/ChartSpaceVisitor.d.ts +0 -6
  199. package/types/src/reader/domVisitors/ChartTypeVisitor.d.ts +0 -7
  200. package/types/src/reader/domVisitors/ChartVisitor.d.ts +0 -7
  201. package/types/src/reader/domVisitors/DataLabelsVisitor.d.ts +0 -8
  202. package/types/src/reader/domVisitors/DataPointVisitor.d.ts +0 -6
  203. package/types/src/reader/domVisitors/HyperlinkVisitor.d.ts +0 -6
  204. package/types/src/reader/domVisitors/LayoutVisitor.d.ts +0 -5
  205. package/types/src/reader/domVisitors/LegendEntryVisitor.d.ts +0 -5
  206. package/types/src/reader/domVisitors/LegendVisitor.d.ts +0 -5
  207. package/types/src/reader/domVisitors/MarkerVisitor.d.ts +0 -5
  208. package/types/src/reader/domVisitors/NegativeShapeVisitor.d.ts +0 -6
  209. package/types/src/reader/domVisitors/PlotAreaVisitor.d.ts +0 -5
  210. package/types/src/reader/domVisitors/RichValueDataVisitor.d.ts +0 -7
  211. package/types/src/reader/domVisitors/RichValueStructureVisitor.d.ts +0 -6
  212. package/types/src/reader/domVisitors/SeriesVisitor.d.ts +0 -8
  213. package/types/src/reader/domVisitors/TitleVisitor.d.ts +0 -9
  214. package/types/src/writer/emitters/ChartColorsEmitter.d.ts +0 -7
  215. package/types/src/writer/emitters/ChartEmitter.d.ts +0 -14
  216. package/types/src/writer/emitters/ChartStyleEmitter.d.ts +0 -46
  217. package/types/src/writer/utils/HiddenFormulaXfs.d.ts +0 -28
@@ -1,4 +1,6 @@
1
- import { Scalar } from '@sheetxl/sdk';
1
+ import { IWorkbook, Scalar } from '@sheetxl/sdk';
2
+ import { EmitContext } from '../builder';
3
+ import { RichItemText, RichStructureKey, RichStyleDef, RichValueKeyFlags, RichValueSink, RichValueStructureDef } from '../../richValue';
2
4
  import { MetadataCollector } from './MetadataCollector';
3
5
  /**
4
6
  * Accumulates rich-value entries so that RichValueEmitter and
@@ -20,84 +22,33 @@ import { MetadataCollector } from './MetadataCollector';
20
22
  * ## XML output relationship
21
23
  *
22
24
  * ```
23
- * rdrichvaluestructure.xml – one <s> per unique handler type
25
+ * rdrichvaluestructure.xml – one <s> per structure written
24
26
  * rdrichvalue.xml – one <rv> per registered entry (s= → structure index)
25
27
  * metadata.xml futureMetadata XLRICHVALUE – one <bk> per unique rdrichvalue entry
26
28
  * metadata.xml valueMetadata – one <bk> per cell (vm= index)
27
29
  * ```
28
- */
29
- /**
30
- * OOXML primitive-value type codes used in `<k t="…">` attributes inside
31
- * `<rvStructures>`.
32
- *
33
- * "d" - Date/Time (ISO-8601 string)
34
- * "i" - Integer (32-bit signed)
35
- * "b" - Boolean
36
- * "e" - Error value
37
- * "s" - Inline string
38
- * "r" - Nested rich value
39
- * "a" - Array data (rdarray.xml)
40
- * "spb" - Supporting property bag
41
- */
42
- export type RichPrimitiveType = 'd' | 'i' | 'b' | 'e' | 's' | 'r' | 'a' | 'spb';
43
- /**
44
- * One property slot in a rich-value schema.
45
30
  *
46
- * - `name` – OOXML key name (`n=` attribute on `<k>`).
47
- * - `type` – OOXML primitive type (`t=` attribute on `<k>`).
48
- * - `defaultValue` – Serialized fallback used when the property is absent or
49
- * `undefined` on the raw value object. Defaults to `''`.
31
+ * What each value writes is its {@link IRichValueHandler}'s ({@link RichValueHandlers}).
50
32
  */
51
- export type RichValueProp = [name: string, type: RichPrimitiveType, defaultValue?: string];
52
- /**
53
- * Base class (and usable concrete class) for rich-value handler/schema types.
54
- *
55
- * Instantiate directly for pure-schema handlers:
56
- * ```ts
57
- * const MyHandler = new RichValueHandler('_myType', [
58
- * ['foo', 'i', '0'],
59
- * ['bar', 's', ''],
60
- * ]);
61
- * ```
62
- *
63
- * Subclass and override {@link getValues} for handlers that need custom
64
- * serialization logic.
65
- *
66
- * Pass instances to {@link RichValueCollector.register}.
67
- */
68
- export declare class RichValueHandler {
69
- /**
70
- * The OOXML structure type name (value of the `t=` attribute on `<s>`
71
- * inside `<rvStructures>`). E.g. `"_error"`.
72
- */
73
- readonly type: string;
74
- /**
75
- * Ordered property definitions written as `<k n="…" t="…"/>` inside the
76
- * matching `<s>` element in `rdrichvaluestructure.xml`.
77
- */
78
- readonly props: ReadonlyArray<RichValueProp>;
79
- constructor(type: string, props: ReadonlyArray<RichValueProp>);
80
- /**
81
- * Extracts the serializable string values for one `<rv>` entry in
82
- * `rdrichvalue.xml`. The array is parallel to {@link props}.
83
- *
84
- * The default implementation reads each property by name from `rawValue`
85
- * (treated as a `Record<string, unknown>`) and falls back to the prop's
86
- * `defaultValue` (or `''`) when the property is absent or `undefined`.
87
- *
88
- * Override in subclasses for custom serialization logic.
89
- *
90
- * @param rawValue The raw value that was passed to
91
- * {@link RichValueCollector.add} / `_register`.
92
- */
93
- getValues(rawValue: Record<string, unknown>): string[];
94
- }
95
33
  /** One registered rich-value entry. */
96
34
  export interface RichValueEntry {
97
- /** The handler (type descriptor / callback) for this entry. */
98
- handler: RichValueHandler;
99
- /** The raw value provided at registration time. */
100
- rawValue: any;
35
+ /** The structure the entry is written as. */
36
+ structure: RichValueStructureDef;
37
+ /** The `<v>`s, parallel to the structure's keys. */
38
+ values: readonly string[];
39
+ /** The `<fb>` cached number, for a formatted number. */
40
+ fb?: string;
41
+ }
42
+ /** One `<a>` of rdarray.xml. */
43
+ export interface RichArrayEntry {
44
+ rows: number;
45
+ columns: number;
46
+ items: readonly RichItemText[];
47
+ }
48
+ /** One `<spb>`: its bag structure's index and its `<v>`s. */
49
+ export interface RichBagEntry {
50
+ s: number;
51
+ values: readonly string[];
101
52
  }
102
53
  /**
103
54
  * Accumulates rich-value entries across all sheets.
@@ -107,12 +58,29 @@ export interface RichValueEntry {
107
58
  *
108
59
  * Stored in `sharedStates` under the key `"persistRichTypes"`.
109
60
  */
110
- export declare class RichValueCollector {
61
+ export declare class RichValueCollector implements RichValueSink {
111
62
  private readonly _metaCollector;
63
+ private readonly _workbook;
112
64
  private readonly _entries;
113
65
  private readonly _keyMap;
66
+ /** The writers started, by handler, in the order their structures are first written. */
67
+ private readonly _writers;
68
+ private readonly _structureIndex;
69
+ private readonly _structures;
70
+ private readonly _arrays;
71
+ private readonly _arrayKeys;
72
+ private readonly _bagStructures;
73
+ private readonly _bagStructureKeys;
74
+ private readonly _bags;
75
+ private readonly _bagKeys;
76
+ private readonly _bagArrays;
77
+ private readonly _bagArrayKeys;
78
+ private readonly _richStyles;
79
+ private readonly _richStyleKeys;
80
+ private readonly _keyFlags;
81
+ private readonly _records;
114
82
  private _onWarn;
115
- constructor(metaCollector: MetadataCollector, onWarn?: (message: string, value?: any) => void);
83
+ constructor(metaCollector: MetadataCollector, workbook: IWorkbook, onWarn?: (message: string, value?: any) => void);
116
84
  /**
117
85
  * Registers a cell value and returns the **1-based `vm=`** attribute value
118
86
  * to write on the `<c>` element — exactly like `persistStrings.add(text)`
@@ -122,37 +90,32 @@ export declare class RichValueCollector {
122
90
  * attrsCol.vm = '' + persistRichTypes.add(value);
123
91
  * ```
124
92
  *
125
- * Internally:
126
- * 1. Deduplicates the raw value → 0-based rdrichvalue.xml index (`rdRvIdx`)
127
- * 2. Deduplicates the futureMetadata XLRICHVALUE block (`rvFMBkIdx`)
128
- * 3. Appends a per-cell valueMetadata entry → 1-based `vm=`
129
- *
130
- * Dispatches on value type:
131
- * - `ScalarType.Error` with code > 7 → built-in `_error` handler
132
- * - Future: `ScalarType.RichData` → IRichType registry
93
+ * A value no handler writes is written as `#UNKNOWN!`.
133
94
  *
134
95
  * @param value The raw `Scalar` value from the cell iterator.
96
+ * @param formula The cell's formula text, or `null` for a literal: where a picture came from.
135
97
  * @returns 1-based `vm=` attribute value.
136
98
  */
137
- add(value: Scalar): number;
138
- /**
139
- * Registers (and deduplicates) a single `#UNKNOWN!` fallback rich-value entry.
140
- *
141
- * Used whenever a value cannot be serialized — produces valid OOXML and renders
142
- * as `#UNKNOWN!` in Excel rather than silently corrupting the `vm=` index.
143
- *
144
- * `#UNKNOWN!` is FormulaError code 12; OOXML `errorType` is `code - 1 = 11`.
145
- */
146
- private _registerFallback;
147
- /**
148
- * Low-level deduplicated entry registration.
149
- *
150
- * @param key Deduplication key (e.g. `"_error:9"`).
151
- * @param rawValue Forwarded to `handler.getValues()`.
152
- * @param handler Callback descriptor for this rich-value type.
153
- * @returns 0-based index into `rdrichvalue.xml`.
154
- */
155
- private _register;
99
+ add(value: Scalar, formula?: string | null): number;
100
+ /** {@inheritDoc RichValueSink.addHandled} */
101
+ addHandled(value: Scalar): number | null;
102
+ private _addHandled;
103
+ private _writerFor;
104
+ /** {@inheritDoc RichValueSink.structureFor} */
105
+ structureFor(t: string, keys: readonly RichStructureKey[]): RichValueStructureDef;
106
+ /** {@inheritDoc RichValueSink.addValue} */
107
+ addValue(structure: RichValueStructureDef, values: readonly string[], fb?: string): number;
108
+ /** {@inheritDoc RichValueSink.addArray} */
109
+ addArray(rows: number, columns: number, items: readonly RichItemText[]): number;
110
+ /** {@inheritDoc RichValueSink.addBag} */
111
+ addBag(keys: readonly RichStructureKey[], values: readonly string[]): number;
112
+ /** {@inheritDoc RichValueSink.addBagArray} */
113
+ addBagArray(items: readonly RichItemText[]): number;
114
+ /** {@inheritDoc RichValueSink.addRichStyle} */
115
+ addRichStyle(style: RichStyleDef): number;
116
+ /** {@inheritDoc RichValueSink.addKeyFlags} */
117
+ addKeyFlags(t: string, key: string, flags: readonly (readonly [name: string, value: string])[]): void;
118
+ private _intern;
156
119
  /** Number of registered (deduplicated) entries. */
157
120
  getCount(): number;
158
121
  /** Whether any entries have been registered. */
@@ -162,39 +125,28 @@ export declare class RichValueCollector {
162
125
  */
163
126
  getEntries(): readonly RichValueEntry[];
164
127
  /**
165
- * Returns the unique handler types in the order they are first encountered.
128
+ * The structures written, in the order they are first encountered.
166
129
  * Used by RichValueStructureEmitter to build `<rvStructures>`.
167
130
  */
168
- uniqueHandlers(): RichValueHandler[];
131
+ getStructures(): RichValueStructureDef[];
169
132
  /**
170
- * Returns the 0-based index of `handler` within the unique-handlers list
171
- * produced by {@link uniqueHandlers}. This is the `s=` attribute value on
133
+ * The 0-based index of `structure` within {@link getStructures}: the `s=` attribute value on
172
134
  * `<rv>` in `rdrichvalue.xml`.
173
135
  */
174
- handlerStructureIndex(handler: RichValueHandler): number;
136
+ getStructureIndex(structure: RichValueStructureDef): number;
137
+ /** The arrays written (rdarray.xml), in index order. */
138
+ getArrays(): readonly RichArrayEntry[];
139
+ /** The supporting property bag structures, bags and bag arrays written. */
140
+ getBags(): {
141
+ structures: readonly (readonly RichStructureKey[])[];
142
+ bags: readonly RichBagEntry[];
143
+ arrays: readonly (readonly RichItemText[])[];
144
+ };
145
+ /** The rich styles written, in index order (a bag names the first as 1). */
146
+ getRichStyles(): readonly RichStyleDef[];
147
+ /** The key flags each written structure declares in `rdRichValueTypes.xml`. */
148
+ getKeyFlags(): [structure: string, flags: readonly RichValueKeyFlags[]][];
149
+ /** Adds the parts the written structures need beyond the rich values. */
150
+ addParts(ctx: EmitContext): void;
175
151
  }
176
- /**
177
- // #PYTHON! contains a correlationId
178
- <s t="_error">
179
- <k n="correlationId" t="s"/>
180
- <k n="errorMessage" t="s"/>
181
- <k n="errorName" t="s"/>
182
- <k n="errorType" t="i"/>
183
- <k n="subType" t="i"/>
184
- </s>
185
-
186
-
187
- // #SPILL! contains row column offset
188
- <s t="_error">
189
- <k n="colOffset" t="i"/>
190
- <k n="errorType" t="i"/>
191
- <k n="rwOffset" t="i"/>
192
- <k n="subType" t="i"/>
193
- </s>
194
-
195
- // unknown has no subtype
196
- <s t="_error">
197
- <k n="errorType" t="i"/>
198
- </s>
199
- */
200
152
  //# sourceMappingURL=RichValueCollector.d.ts.map
@@ -0,0 +1,86 @@
1
+ import { IRange, ICellStyle, ITypes, IWorkbook, IWorksheet } from '@sheetxl/sdk';
2
+ import { XlsxHeader } from '../../XlsxHeader';
3
+ import { CellControlComplements } from './CellControlComplements';
4
+ export { type XlsxHeader };
5
+ /**
6
+ * A worksheet as the sheet part writes it: the model's JSON with whole-row and whole-column styles
7
+ * moved onto `rows`/`cols` and borders split so every cell of a range draws the same edges.
8
+ */
9
+ export interface XlsxWorksheetJSON extends Omit<IWorksheet.JSON, 'rows' | 'cols'> {
10
+ cols?: IRange.JSONReference<XlsxHeader>[];
11
+ rows?: IRange.JSONReference<XlsxHeader>[];
12
+ }
13
+ type StyledCells = [coords: IRange.Coords, styleId: number][];
14
+ /**
15
+ * Looks style JSON up by direct style id, and mints ids for new JSON.
16
+ *
17
+ * @remarks
18
+ * An id is an xf: a style plus the cell control complement it carries, if any (see
19
+ * `CellControlComplements`). The two stay apart; they meet only in the id.
20
+ */
21
+ export interface StyleIdScope {
22
+ getElementJSON(id: number): ICellStyle.JSON;
23
+ /** The control complement xf `id` carries, or `undefined`. */
24
+ getElementComplement?(id: number): number | undefined;
25
+ getElementID(json: ICellStyle.JSON, complement?: number): number | null;
26
+ }
27
+ /**
28
+ * Direct style ids keyed by the style's JSON, the same way the SDK's persist scope keys them
29
+ * (`JSONStableStringify`, Normal at 0), so a style keeps one xf however often it is minted. A style
30
+ * under a cell control is a second xf, keyed by the pair.
31
+ */
32
+ export declare class StyleIds implements StyleIdScope {
33
+ private _byKey;
34
+ readonly list: ICellStyle.JSON[];
35
+ /** The control complement each xf carries, by id; parallel to {@link list}. */
36
+ readonly complements: (number | undefined)[];
37
+ constructor(normal: ICellStyle.JSON | null | undefined);
38
+ getElementJSON(id: number): ICellStyle.JSON;
39
+ getElementComplement(id: number): number | undefined;
40
+ getElementID(json: ICellStyle.JSON | null | undefined, complement?: number): number;
41
+ }
42
+ /**
43
+ * Lays out every worksheet's styles the way xlsx stores them, re-minting the workbook's direct styles
44
+ * in the order the sheets cite them.
45
+ *
46
+ * @remarks
47
+ * Replaces `json.styles.direct`. Cell xf indices are direct style ids, so the list is minted sheet by
48
+ * sheet and range by range, with each split piece in its range's place and each re-derived border
49
+ * after.
50
+ *
51
+ * @returns The sheet part's JSON for each worksheet, keyed by the model's JSON for it.
52
+ */
53
+ export declare function layoutWorkbookStyles(json: IWorkbook.JSON, sheets: readonly (IWorksheet | null)[], complements?: CellControlComplements, warn?: (message: string, onceKey: string) => void): Map<IWorksheet.JSON, XlsxWorksheetJSON>;
54
+ /**
55
+ * Breaks a bordered range into pieces whose every cell draws the same edges, which is all a cell xf
56
+ * can say.
57
+ *
58
+ * @remarks
59
+ * A range that reaches the grid's terminal row or column (a `<col style>` reads back as a
60
+ * full-height range) has no closing border at the boundary, so no end sliver is split off there: a
61
+ * style-only piece at the last row or column materializes real `<c>` records, and Excel then treats
62
+ * the whole grid as the used range.
63
+ */
64
+ export declare function splitStyleBordersIntoSame(coords: IRange.Coords, json: ICellStyle.JSON, entireCoords?: IRange.Coords): IRange.JSONReferenceTuple<ICellStyle.JSON>[];
65
+ export interface StyleRanges {
66
+ cols: ITypes.RunCoordValue<XlsxHeader>[];
67
+ rows: ITypes.RunCoordValue<XlsxHeader>[];
68
+ cells: StyledCells;
69
+ }
70
+ /**
71
+ * Moves styles that cover most of a row or column onto `<row s>` / `<col style>`, leaving the cells
72
+ * only what the headers do not already say.
73
+ *
74
+ * @remarks
75
+ * 1. A style whose cells cover more than half of a column (or row) and reach the grid's edge
76
+ * becomes that column's (or row's) style. A style the columns already carry across most of the
77
+ * sheet is not repeated on rows.
78
+ * 2. An overlap sweep then finds what each crossing of cells and headers still has to write.
79
+ *
80
+ * A style's border is relative to the range it is stored with (a row or column style's range is the
81
+ * whole row or column), so ids are not position-independent: wherever a range is written smaller
82
+ * than the entry it came from, its id is re-derived from the style's JSON through `ids`, and two
83
+ * entries sharing an id agree on a crossing only if they draw the same edges there.
84
+ */
85
+ export declare function promoteStylesToHeaders(styles: StyleRanges, entireCoords: IRange.Coords, ids: StyleIdScope): StyleRanges;
86
+ //# sourceMappingURL=SheetStyleLayout.d.ts.map
@@ -1,8 +1,32 @@
1
- import { IStyleCollection } from '@sheetxl/sdk';
1
+ import { IStyleCollection, IText, ITextFrame } from '@sheetxl/sdk';
2
2
  import { EmitContext } from '../builder';
3
- export declare const fromRunProps: (styles: IStyleCollection, runProps: Record<string, any>, // TODO - ITextRun
3
+ /**
4
+ * The attributes of an `rPr`/`defRPr`/`endParaRPr` from run properties. Keys the chart style
5
+ * tables state as raw attributes (`lang`, `kern` in points…) pass through, as do their `b`, `i`
6
+ * and `italic` spellings; the modeled keys ({@link IText.RunPropertiesJSON}) are converted.
7
+ */
8
+ export declare const fromRunProps: (styles: IStyleCollection, runProps: Record<string, any>, // IText.RunPropertiesJSON, or a chart style's raw attributes
4
9
  defaultAttribs?: Record<string, any>) => Record<string, any>;
10
+ /**
11
+ * An `rPr`, `defRPr` or `endParaRPr` with its children, in the schema's order: outline, fill,
12
+ * effects, highlight, fonts, hyperlink.
13
+ */
14
+ export declare const writeRunProperties: (ctx: EmitContext, styles: IStyleCollection, tag: string, props: IText.RunPropertiesJSON | undefined, defaultAttribs?: Record<string, any>) => void;
15
+ /**
16
+ * A `pPr`, `defPPr` or `lvlNpPr`: attributes, then spacing, bullet, tabs and the default run, in
17
+ * the schema's order.
18
+ */
19
+ export declare const writeParagraphProperties: (ctx: EmitContext, styles: IStyleCollection, tag: string, props: IText.ParagraphPropertiesJSON) => void;
20
+ /**
21
+ * A `txBody` from the modeled text. What the JSON leaves out is SheetXL's default; where
22
+ * DrawingML's differs (overflow, a run's size) the default is stated, so the file means the same.
23
+ */
5
24
  export declare const writeTxBody: (ctx: EmitContext, styles: IStyleCollection, jsonText: any) => void;
25
+ /**
26
+ * A text body's `bodyPr` and `lstStyle` without its paragraphs, as a theme's object default states
27
+ * them. Both are written, empty when there is no text.
28
+ */
29
+ export declare const writeBodyAndListStyle: (ctx: EmitContext, styles: IStyleCollection, text: ITextFrame.JSON | undefined) => void;
6
30
  export declare const writeDefaultRProperties: (ctx: EmitContext, styles: IStyleCollection, defRPr: Record<string, any>) => void;
7
31
  export declare const writeBodyProperties: (ctx: EmitContext, styles: IStyleCollection, bodyPr: Record<string, any> | undefined) => void;
8
32
  //# sourceMappingURL=TextUtils.d.ts.map
@@ -1,4 +1,4 @@
1
- import { ISheet, IRange } from '@sheetxl/sdk';
1
+ import { IWorksheet, IRange } from '@sheetxl/sdk';
2
2
  /**
3
3
  * Which formulas on a sheet call a function Excel does not have.
4
4
  *
@@ -15,5 +15,5 @@ export interface UnsupportedFunctions {
15
15
  /** Whether formula `index` calls anything in {@link names}. */
16
16
  affects(index: number): boolean;
17
17
  }
18
- export declare const collectUnsupportedFunctions: (sheet: ISheet, jsonFormulas: IRange.JSONReferenceTuple<string>[] | undefined) => Promise<UnsupportedFunctions>;
18
+ export declare const collectUnsupportedFunctions: (sheet: IWorksheet, jsonFormulas: IRange.JSONReferenceTuple<string>[] | undefined) => Promise<UnsupportedFunctions>;
19
19
  //# sourceMappingURL=UnsupportedFunctions.d.ts.map
@@ -0,0 +1,61 @@
1
+ import { ICellStyle, IStyleCollection } from '@sheetxl/sdk';
2
+ export declare const XF_VARIANTS_SHARED_STATE = "xfVariants";
3
+ /**
4
+ * The cell xfs written as twins of a direct style, carrying what the model keeps somewhere other
5
+ * than the style:
6
+ *
7
+ * - `hidden="1"`, for sheets whose protection hides formulas. xlsx has no sheet-level form of
8
+ * `IWorksheetProtection.showFormulas: false`; Excel only hides a formula whose format says
9
+ * `hidden="1"`. So a sheet that hides formulas writes every format it uses as a hidden twin,
10
+ * unless the format itself grants `showFormulas`.
11
+ * - `pivotButton="1"`, for the cells a pivot table shows a field button on. The button is the
12
+ * table's (`IPivotTable.JSON.buttons`), not the format's.
13
+ * - what a pivot table's definition gives a cell (`IPivotTable.getStyleAt`): a row label set left
14
+ * and indented by its level, a data field's or a field's number format, and the formats a user
15
+ * put on the table (`IPivotTable.JSON.formats`). Excel reads them from the cell's format; the
16
+ * model derives them from the table's definition. The cell's own format wins where it sets them,
17
+ * as it does in the model.
18
+ *
19
+ * Twins are appended after the direct styles and shared by every sheet that asks for one.
20
+ * `cellXfs[0]` is never changed in place: it is workbook-wide, and each twin is per sheet or per
21
+ * cell.
22
+ *
23
+ * Worksheets allocate while they emit; `StylesEmitter` writes the twins afterwards.
24
+ */
25
+ export declare class XfVariants {
26
+ private _json;
27
+ private _styles;
28
+ /** The cellXfs written for the direct styles; the twins start here. */
29
+ private _directCount;
30
+ /** Twin by xf, flags, label indent, number format and user format. */
31
+ private _variants;
32
+ /** A user format's key, by the object a table answered with. */
33
+ private _userKeys;
34
+ private _sources;
35
+ private _shown;
36
+ constructor(json: IStyleCollection.JSON | undefined, styles: IStyleCollection);
37
+ /**
38
+ * The xf to write in place of `xf`.
39
+ *
40
+ * @param hidden The sheet hides formulas.
41
+ * @param pivotButton The cell shows a pivot table's field button.
42
+ * @param labelIndent The cell is a pivot table's row label, indented by this many characters.
43
+ * @param numberFormat The number format a pivot table gives the cell.
44
+ * @param user The style the formats a user put on a pivot table give the cell.
45
+ */
46
+ getXf(xf: number, hidden: boolean, pivotButton: boolean, labelIndent?: number | null, numberFormat?: string | null, user?: ICellStyle.Properties | null): number;
47
+ /** The direct xf behind each twin and its flags, in twin order. */
48
+ getSources(): readonly XfVariants.Source[];
49
+ private _isShown;
50
+ }
51
+ export declare namespace XfVariants {
52
+ interface Source {
53
+ xf: number;
54
+ hidden: boolean;
55
+ pivotButton: boolean;
56
+ labelIndent: number | null;
57
+ numberFormat: string | null;
58
+ user: ICellStyle.Properties | null;
59
+ }
60
+ }
61
+ //# sourceMappingURL=XfVariants.d.ts.map
@@ -1 +0,0 @@
1
- const e=require("./xQ6-wbTw5UzZUM1Y.cjs");let t=require("@sheetxl/utils");var n,r,i=class e{static{this.SIGNATURE=[208,207,17,224,161,177,26,225]}static{this.FATSECT=4294967293}static{this.DIFSECT=4294967292}static{this.ENDOFCHAIN=4294967294}static{this.FREESECT=4294967295}static{this.NOSTREAM=4294967295}static{this.SECTOR_SIZE=512}static{this.MINI_SECTOR_SIZE=64}static{this.MINI_CUTOFF=4096}static{this.DIR_ENTRY_SIZE=128}static{this.DIFAT_HEADER_COUNT=109}constructor(){this.sectors=[],this.fat=[]}static write(t){return new e()._build(t)}allocate(t){let n=e.SECTOR_SIZE,r=Math.max(1,Math.ceil(t.byteLength/n)),i=this.sectors.length;for(let a=0;a<r;a++){let o=new Uint8Array(n);o.set(t.subarray(a*n,Math.min((a+1)*n,t.byteLength))),this.sectors.push(o),this.fat.push(a===r-1?e.ENDOFCHAIN:i+a+1)}return i}_build(t){let{SECTOR_SIZE:n,MINI_SECTOR_SIZE:r,MINI_CUTOFF:i,ENDOFCHAIN:a,FREESECT:o,FATSECT:s,DIFSECT:c,NOSTREAM:l,DIR_ENTRY_SIZE:u,DIFAT_HEADER_COUNT:d}=e,f=[],p=0,m=t.map(e=>{if(e.data.byteLength>=i)return{entry:e,mini:!1,start:-1};let t=p,n=Math.max(1,Math.ceil(e.data.byteLength/r)),a=new Uint8Array(n*r);return a.set(e.data),f.push(a),p+=n,{entry:e,mini:!0,start:t}});for(let e of m)e.mini||(e.start=e.entry.data.byteLength===0?a:this.allocate(e.entry.data));let h=a,g=p*r;if(p>0){let e=new Uint8Array(g),t=0;for(let n of f)e.set(n,t),t+=n.byteLength;h=this.allocate(e)}let _=a,v=0;if(p>0){let e=n/4;v=Math.ceil(p/e);let t=new Uint8Array(v*n),i=new DataView(t.buffer);t.fill(255);let o=0;for(let e of m){if(!e.mini)continue;let t=Math.max(1,Math.ceil(e.entry.data.byteLength/r));for(let e=0;e<t;e++,o++)i.setUint32(4*o,e===t-1?a:o+1,!0)}_=this.allocate(t),v=Math.ceil(t.byteLength/n)}let y=[];y.push(this._directoryEntry({name:`Root Entry`,type:5,child:t.length>0?1:l,start:h===a?0:h,size:g}));let b=m.map((e,t)=>({place:e,index:t})).sort((e,t)=>{let n=e.place.entry.name,r=t.place.entry.name;return n.length===r.length?n.toUpperCase()<r.toUpperCase()?-1:+(n.toUpperCase()>r.toUpperCase()):n.length-r.length}),x=new Map;b.forEach((e,t)=>x.set(e.index,t+1)),m.forEach((e,t)=>{let n=x.get(t)-1,r=b[n+1];y.push(this._directoryEntry({name:e.entry.name,type:2,right:r?x.get(r.index):l,start:e.mini?e.start:e.start===a?0:e.start,size:e.entry.data.byteLength}))});let S=[y[0]];b.forEach(e=>S.push(y[e.index+1]));let C=n/u,w=Math.ceil(S.length/C),T=new Uint8Array(w*n);for(let e=0;e<w*C;e++){let t=S[e]??this._directoryEntry({name:``,type:0});T.set(t,e*u)}let E=this.allocate(T),D=n/4,O=D-1,k=this.sectors.length,A=1,j=0;for(let e=0;e<16;e++){let e=k+A+j,t=Math.max(1,Math.ceil(e/D)),n=t<=d?0:Math.ceil((t-d)/O);if(t===A&&n===j)break;A=t,j=n}let M=[],N=[];for(let e=0;e<A;e++)M.push(k+e);for(let e=0;e<j;e++)N.push(k+A+e);for(let e of M)this.fat[e]=s;for(let e of N)this.fat[e]=c;let P=new Uint8Array(A*n);P.fill(255);let F=new DataView(P.buffer);for(let e=0;e<this.fat.length;e++)F.setUint32(4*e,this.fat[e],!0);let I=new Uint8Array(n+(k+A+j)*n),L=new DataView(I.buffer);I.set(e.SIGNATURE,0),L.setUint16(24,62,!0),L.setUint16(26,3,!0),L.setUint16(28,65534,!0),L.setUint16(30,9,!0),L.setUint16(32,6,!0),L.setUint32(44,A,!0),L.setUint32(48,E,!0),L.setUint32(56,i,!0),L.setUint32(60,_,!0),L.setUint32(64,v,!0),L.setUint32(68,j>0?N[0]:a,!0),L.setUint32(72,j,!0);for(let e=0;e<d;e++)L.setUint32(76+4*e,e<A?M[e]:o,!0);for(let e=0;e<k;e++)I.set(this.sectors[e],n+e*n);I.set(P,n+M[0]*n);for(let e=0;e<j;e++){let t=n+N[e]*n;for(let n=0;n<O;n++){let r=d+e*O+n;L.setUint32(t+4*n,r<A?M[r]:o,!0)}L.setUint32(t+4*O,e===j-1?a:N[e+1],!0)}return I}_directoryEntry(t){let{NOSTREAM:n}=e,r=new Uint8Array(e.DIR_ENTRY_SIZE),i=new DataView(r.buffer),a=t.name;for(let e=0;e<a.length&&e<31;e++)i.setUint16(2*e,a.charCodeAt(e),!0);return i.setUint16(64,a.length>0?2*(Math.min(a.length,31)+1):0,!0),r[66]=t.type,r[67]=1,i.setUint32(68,t.left??n,!0),i.setUint32(72,t.right??n,!0),i.setUint32(76,t.child??n,!0),i.setUint32(116,t.start??0,!0),i.setUint32(120,t.size??0,!0),i.setUint32(124,0,!0),r}};(function(e){let t=e=>{let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n},n=(e,t,n)=>{let r=((e,t)=>{let n=RegExp(`\\b${t}\\s*=\\s*"([^"]*)"`).exec(e);return n?n[1]:null})(e,t);if(r===null)throw Error(`Malformed encryption descriptor: <${n}> is missing '${t}'.`);return r},r=(e,r)=>({saltValue:t(n(e,`saltValue`,r)),blockSize:parseInt(n(e,`blockSize`,r),10),keyBits:parseInt(n(e,`keyBits`,r),10),hashSize:parseInt(n(e,`hashSize`,r),10),cipherAlgorithm:n(e,`cipherAlgorithm`,r),cipherChaining:n(e,`cipherChaining`,r),hashAlgorithm:n(e,`hashAlgorithm`,r)}),i=(e,t)=>{let n=RegExp(`<(?:\\w+:)?${t}\\b[^>]*>`).exec(e);return n?n[0]:null},a=e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=String.fromCharCode(e[n]);return btoa(t)};e.build=e=>{let t=`saltSize="${e.saltSize}" blockSize="${e.blockSize}" keyBits="${e.keyBits}" hashSize="${e.hashSize}" cipherAlgorithm="${e.cipherAlgorithm}" cipherChaining="${e.cipherChaining}" hashAlgorithm="${e.hashAlgorithm}"`,n=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n<encryption xmlns="http://schemas.microsoft.com/office/2006/encryption" xmlns:p="http://schemas.microsoft.com/office/2006/keyEncryptor/password" xmlns:c="http://schemas.microsoft.com/office/2006/keyEncryptor/certificate"><keyData ${t} saltValue="${a(e.keyDataSalt)}"/><dataIntegrity encryptedHmacKey="${a(e.encryptedHmacKey)}" encryptedHmacValue="${a(e.encryptedHmacValue)}"/><keyEncryptors><keyEncryptor uri="http://schemas.microsoft.com/office/2006/keyEncryptor/password"><p:encryptedKey spinCount="${e.spinCount}" ${t} saltValue="${a(e.encryptorSalt)}" encryptedVerifierHashInput="${a(e.encryptedVerifierHashInput)}" encryptedVerifierHashValue="${a(e.encryptedVerifierHashValue)}" encryptedKeyValue="${a(e.encryptedKeyValue)}"/></keyEncryptor></keyEncryptors></encryption>`,r=new TextEncoder().encode(n),i=new Uint8Array(8+r.byteLength),o=new DataView(i.buffer);return o.setUint16(0,4,!0),o.setUint16(2,4,!0),o.setUint32(4,64,!0),i.set(r,8),i},e.parse=e=>{if(e.byteLength<8)throw Error(`Malformed EncryptionInfo stream (too short).`);let a=new DataView(e.buffer,e.byteOffset,e.byteLength),o=a.getUint16(0,!0),s=a.getUint16(2,!0);if(o===4&&s===4){let a=new TextDecoder().decode(e.subarray(8)),o=i(a,`keyData`);if(!o)throw Error(`Malformed encryption descriptor: no <keyData>.`);let s=i(a,`encryptedKey`);if(!s)throw Error(`This file is encrypted with a scheme SheetXL cannot open (no password key encryptor).`);let c=i(a,`dataIntegrity`);return{scheme:`agile`,keyData:r(o,`keyData`),passwordKeyEncryptor:{...r(s,`encryptedKey`),spinCount:parseInt(n(s,`spinCount`,`encryptedKey`),10),encryptedVerifierHashInput:t(n(s,`encryptedVerifierHashInput`,`encryptedKey`)),encryptedVerifierHashValue:t(n(s,`encryptedVerifierHashValue`,`encryptedKey`)),encryptedKeyValue:t(n(s,`encryptedKeyValue`,`encryptedKey`))},dataIntegrity:c?{encryptedHmacKey:t(n(c,`encryptedHmacKey`,`dataIntegrity`)),encryptedHmacValue:t(n(c,`encryptedHmacValue`,`dataIntegrity`))}:null}}return{scheme:o===2?`rc4-cryptoapi`:s===2?`standard`:`rc4`,versionMajor:o,versionMinor:s}}})(n||={}),function(e){let t={verifierHashInput:new Uint8Array([254,167,210,118,59,75,158,121]),verifierHashValue:new Uint8Array([215,170,15,109,48,97,52,78]),keyValue:new Uint8Array([20,110,11,231,171,172,208,214]),hmacKey:new Uint8Array([95,178,173,1,12,185,225,246]),hmacValue:new Uint8Array([160,103,127,2,178,44,132,51])},n=async()=>globalThis.crypto,r=e=>{switch(e.toUpperCase().replace(/[^A-Z0-9]/g,``)){case`SHA1`:return`SHA-1`;case`SHA256`:return`SHA-256`;case`SHA384`:return`SHA-384`;case`SHA512`:return`SHA-512`;default:throw Error(`Unsupported encryption hash algorithm '${e}'.`)}},i=e=>{let t=new Uint8Array(e.byteLength);return t.set(e),t},a=(...e)=>{let t=0;for(let n of e)t+=n.byteLength;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n},o=(e,t)=>{if(e.byteLength>=t)return i(e.subarray(0,t));let n=new Uint8Array(t).fill(54);return n.set(e),n},s=e=>{let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),t},c=async(e,t,...n)=>new Uint8Array(await e.subtle.digest(t,a(...n))),l=()=>typeof MessageChannel==`function`?new Promise(e=>{let t=new MessageChannel;t.port1.onmessage=()=>{t.port1.close(),t.port2.close(),e()},t.port2.postMessage(null)}):new Promise(e=>{setTimeout(e,0)}),u=async(e,t,n,r,i)=>{let a=new Uint8Array(2*t.length),o=new DataView(a.buffer);for(let e=0;e<t.length;e++)o.setUint16(2*e,t.charCodeAt(e),!0);let u=await c(e,r,n,a);for(let t=0;t<i;t++)u=await c(e,r,s(t),u),t%2048==0&&await l();return u},d=async(e,t,n,r,i)=>o(await c(e,r,t,n),i),f=async(e,t,n,r,i)=>o(await c(e,r,t,s(n)),i),p=async(e,t,n,r,i)=>o(await c(e,r,t,n),i),m=async(e,t,n,r)=>{let a=await e.subtle.importKey(`raw`,i(n),{name:`HMAC`,hash:{name:t}},!1,[`sign`]);return new Uint8Array(await e.subtle.sign(`HMAC`,a,i(r)))},h=async(e,t,n,r)=>{let o=i(r);if(o.byteLength===0)return o;if(o.byteLength%16!=0)throw Error(`Malformed encrypted payload (not block aligned).`);let s=await e.subtle.importKey(`raw`,t,{name:`AES-CBC`},!1,[`encrypt`,`decrypt`]),c=i(o.subarray(o.byteLength-16)),l=new Uint8Array(16).fill(16),u=new Uint8Array(await e.subtle.encrypt({name:`AES-CBC`,iv:c},s,l)).subarray(0,16),d=await e.subtle.decrypt({name:`AES-CBC`,iv:n},s,a(o,u));return new Uint8Array(d)};e.resolveSecretKey=async(e,a)=>{let s=e.passwordKeyEncryptor;if(!/^AES$/i.test(s.cipherAlgorithm)||!/CBC$/i.test(s.cipherChaining))throw Error(`Unsupported encryption cipher '${s.cipherAlgorithm}/${s.cipherChaining}'.`);let l=await n(),f=r(s.hashAlgorithm),p=s.keyBits/8,m=await u(l,a,s.saltValue,f,s.spinCount),g=o(s.saltValue,s.blockSize),_=await d(l,m,t.verifierHashInput,f,p),v=await h(l,_,g,s.encryptedVerifierHashInput),y=await d(l,m,t.verifierHashValue,f,p),b=await h(l,y,g,s.encryptedVerifierHashValue),x=await c(l,f,v),S=+(x.byteLength>b.byteLength);for(let e=0;e<b.byteLength;e++)S|=(e<x.byteLength?x[e]:0)^b[e];if(S!==0)return null;let C=await d(l,m,t.keyValue,f,p),w=await h(l,C,g,s.encryptedKeyValue);return i(w.subarray(0,e.keyData.keyBits/8))};let g=async(e,t,n,r)=>{let a=i(r);if(a.byteLength===0)return a;if(a.byteLength%16!=0)throw Error(`Malformed plaintext (not block aligned).`);let o=await e.subtle.importKey(`raw`,t,{name:`AES-CBC`},!1,[`encrypt`]),s=new Uint8Array(await e.subtle.encrypt({name:`AES-CBC`,iv:n},o,a));return i(s.subarray(0,a.byteLength))},_=(e,t)=>e%t===0?e:e+(t-e%t),v=4096;e.decryptPackage=async(e,t,i)=>{if(i.byteLength<8)throw Error(`Malformed EncryptedPackage stream (too short).`);let a=await n(),{keyData:o}=e,s=r(o.hashAlgorithm),c=new DataView(i.buffer,i.byteOffset,i.byteLength),l=c.getUint32(0,!0)+4294967296*c.getUint32(4,!0),u=i.subarray(8),d=new Uint8Array(Math.min(l,u.byteLength)),p=0;for(let e=0;e*v<u.byteLength;e++){let n=e*v,r=u.subarray(n,Math.min(n+v,u.byteLength)),i=r.byteLength%o.blockSize;if(i){let e=new Uint8Array(r.byteLength+o.blockSize-i);e.set(r),r=e}let c=await f(a,o.saltValue,e,s,o.blockSize),l=await h(a,t,c,r),m=Math.min(l.byteLength,d.byteLength-p);if(m<=0)break;d.set(l.subarray(0,m),p),p+=m}return d.subarray(0,p)},e.verifyIntegrity=async(e,i,a)=>{let o=e.dataIntegrity;if(!o)return!0;let s=await n(),{keyData:c}=e,l=r(c.hashAlgorithm),u=(await h(s,i,await p(s,c.saltValue,t.hmacKey,l,c.blockSize),o.encryptedHmacKey)).subarray(0,c.hashSize),d=(await h(s,i,await p(s,c.saltValue,t.hmacValue,l,c.blockSize),o.encryptedHmacValue)).subarray(0,c.hashSize),f=await m(s,l,u,a);if(f.byteLength<c.hashSize)return!1;let g=0;for(let e=0;e<c.hashSize;e++)g|=d[e]^f[e];return g===0};let y=e.DEFAULTS={hashAlgorithm:`SHA512`,cipherAlgorithm:`AES`,cipherChaining:`ChainingModeCBC`,saltSize:16,blockSize:16,keyBits:256,hashSize:64,spinCount:1e5};e.encrypt=async(e,i)=>{let a=await n(),s=r(y.hashAlgorithm),l=y.keyBits/8,h=e=>{let t=new Uint8Array(e);return a.getRandomValues(t),t},b=h(l),x=h(y.saltSize),S=h(y.saltSize),C=h(y.saltSize),w=await u(a,i,S,s,y.spinCount),T=o(S,y.blockSize),E=await d(a,w,t.verifierHashInput,s,l),D=await g(a,E,T,C),O=await c(a,s,C),k=await d(a,w,t.verifierHashValue,s,l),A=new Uint8Array(_(O.byteLength,y.blockSize));A.set(O);let j=await g(a,k,T,A),M=await d(a,w,t.keyValue,s,l),N=await g(a,M,T,b),P=e.byteLength,F=Math.max(1,Math.ceil(P/v)),I=new Uint8Array(_(P,y.blockSize)||y.blockSize);for(let t=0;t<F;t++){let n=t*v,r=e.subarray(n,Math.min(n+v,P)),i=new Uint8Array(_(r.byteLength,y.blockSize));i.set(r);let o=await f(a,x,t,s,y.blockSize);I.set(await g(a,b,o,i),n)}let L=new Uint8Array(8+I.byteLength),R=new DataView(L.buffer);R.setUint32(0,P>>>0,!0),R.setUint32(4,Math.floor(P/4294967296),!0),L.set(I,8);let z=h(y.hashSize),B=new Uint8Array(_(z.byteLength,y.blockSize));B.set(z);let V=await g(a,b,await p(a,x,t.hmacKey,s,y.blockSize),B),H=await m(a,s,z,L),U=new Uint8Array(_(H.byteLength,y.blockSize));return U.set(H),{keyDataSalt:x,encryptorSalt:S,encryptedVerifierHashInput:D,encryptedVerifierHashValue:j,encryptedKeyValue:N,encryptedHmacKey:V,encryptedHmacValue:await g(a,b,await p(a,x,t.hmacValue,s,y.blockSize),U),encryptedPackage:L}}}(r||={});var a=[208,207,17,224,161,177,26,225],o=`EncryptionInfo`,s=`EncryptedPackage`,c=t=>{if(!(e=>{if(e.byteLength<a.length)return!1;let t=new Uint8Array(e,0,a.length);for(let e=0;e<a.length;e++)if(t[e]!==a[e])return!1;return!0})(t))return null;let n;try{n=e.t.read(new Uint8Array(t))}catch{return null}let r=n.readStream(o),i=n.readStream(s);return r&&i?{info:r,encryptedPackage:i}:null},l={key:`offcrypto`,description:`Office Document Encryption`,detect:e=>c(e)!==null,async decode(e,i){let a=c(e);if(!a)throw Error(`Not an encrypted Office container.`);let o=n.parse(a.info);if(o.scheme!==`agile`)throw Error(`This file uses ${(e=>{switch(e){case`standard`:return`Standard ECMA-376 encryption (Office 2007)`;case`rc4-cryptoapi`:return`RC4 CryptoAPI encryption (Office 2002-2003)`;case`rc4`:return`RC4/XOR obfuscation (Office 97-2000)`;default:return e}})(o.scheme)}, which SheetXL cannot open yet. Re-save it from Excel to upgrade it to the current encryption.`);let s=await r.resolveSecretKey(o,i);if(!s)throw new t.InvalidPasswordError;if(o.dataIntegrity&&!await r.verifyIntegrity(o,s,a.encryptedPackage))throw Error(`This file failed its integrity check — it has been altered or is damaged since it was encrypted.`);let l=await r.decryptPackage(o,s,a.encryptedPackage);return l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength)},async encode(e,t){if(!t)throw Error(`A password is required to encrypt.`);let a=await r.encrypt(new Uint8Array(e),t),c=n.build({...r.DEFAULTS,keyDataSalt:a.keyDataSalt,encryptorSalt:a.encryptorSalt,encryptedVerifierHashInput:a.encryptedVerifierHashInput,encryptedVerifierHashValue:a.encryptedVerifierHashValue,encryptedKeyValue:a.encryptedKeyValue,encryptedHmacKey:a.encryptedHmacKey,encryptedHmacValue:a.encryptedHmacValue}),l=i.write([{name:o,data:c},{name:s,data:a.encryptedPackage}]);return l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength)}};exports.OffCryptoEncryption=l;
@@ -1 +0,0 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(o,s,c)=>(c=o==null?{}:e(i(o)),((e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c,l=r(i),u=0,d=l.length;u<d;u++)c=l[u],a.call(e,c)||c===o||t(e,c,{get:(e=>i[e]).bind(null,c),enumerable:!(s=n(i,c))||s.enumerable});return e})(!s&&o&&o.__esModule?c:t(c,`default`,{value:o,enumerable:!0}),o));Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return o}});