read-excel-file 9.3.3 → 9.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (255) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +32 -2
  3. package/browser/index.cjs +3 -0
  4. package/browser/index.d.ts +16 -0
  5. package/browser/index.js +4 -1
  6. package/bundle/read-excel-file.min.js +1 -1
  7. package/bundle/read-excel-file.min.js.map +1 -1
  8. package/commonjs/export/convertInputToNodeStream.js +0 -12
  9. package/commonjs/export/convertInputToNodeStream.js.map +1 -1
  10. package/commonjs/export/parseSheet.js +14 -7
  11. package/commonjs/export/parseSheet.js.map +1 -1
  12. package/commonjs/export/readSheetBrowser.js +3 -6
  13. package/commonjs/export/readSheetBrowser.js.map +1 -1
  14. package/commonjs/export/readSheetNode.js +3 -6
  15. package/commonjs/export/readSheetNode.js.map +1 -1
  16. package/commonjs/export/readSheetUniversal.js +2 -2
  17. package/commonjs/export/readSheetUniversal.js.map +1 -1
  18. package/commonjs/export/readSheetWebWorker.js +5 -5
  19. package/commonjs/export/readSheetWebWorker.js.map +1 -1
  20. package/commonjs/export/readXlsxFileBrowser.js +3 -6
  21. package/commonjs/export/readXlsxFileBrowser.js.map +1 -1
  22. package/commonjs/export/readXlsxFileNode.js +3 -6
  23. package/commonjs/export/readXlsxFileNode.js.map +1 -1
  24. package/commonjs/export/readXlsxFileUniversal.js +2 -2
  25. package/commonjs/export/readXlsxFileUniversal.js.map +1 -1
  26. package/commonjs/export/readXlsxFileWebWorker.js +5 -5
  27. package/commonjs/export/readXlsxFileWebWorker.js.map +1 -1
  28. package/commonjs/export/unpackXlsxFileBrowser.js +15 -4
  29. package/commonjs/export/unpackXlsxFileBrowser.js.map +1 -1
  30. package/commonjs/export/unpackXlsxFileBrowser.test.js.map +1 -0
  31. package/commonjs/export/unpackXlsxFileNode.js +32 -5
  32. package/commonjs/export/unpackXlsxFileNode.js.map +1 -1
  33. package/commonjs/export/unpackXlsxFileNode.test.js.map +1 -0
  34. package/commonjs/export/unpackXlsxFileUniversal.js +14 -3
  35. package/commonjs/export/unpackXlsxFileUniversal.js.map +1 -1
  36. package/commonjs/export/unpackXlsxFileUniversal.test.js.map +1 -0
  37. package/commonjs/parseSheetData/parseSheetData.js +9 -6
  38. package/commonjs/parseSheetData/parseSheetData.js.map +1 -1
  39. package/commonjs/saxen/parser.js +1 -1
  40. package/commonjs/saxen/parser.js.map +1 -1
  41. package/commonjs/utility/convertValuesFromUint8ArraysToStrings.js +100 -0
  42. package/commonjs/utility/convertValuesFromUint8ArraysToStrings.js.map +1 -0
  43. package/commonjs/xlsx/InvalidSpreadsheetError.js +55 -0
  44. package/commonjs/xlsx/InvalidSpreadsheetError.js.map +1 -0
  45. package/commonjs/xlsx/SheetNotFoundError.js +55 -0
  46. package/commonjs/xlsx/SheetNotFoundError.js.map +1 -0
  47. package/commonjs/xlsx/file/InputValidationStream.js +101 -0
  48. package/commonjs/xlsx/file/InputValidationStream.js.map +1 -0
  49. package/commonjs/xlsx/file/InputValidationStream.test.js.map +1 -0
  50. package/commonjs/xlsx/file/InvalidInputError.js +105 -0
  51. package/commonjs/xlsx/file/InvalidInputError.js.map +1 -0
  52. package/commonjs/xlsx/file/createFileTypeDetector.js +70 -0
  53. package/commonjs/xlsx/file/createFileTypeDetector.js.map +1 -0
  54. package/commonjs/xlsx/file/createFileTypeDetector.test.js.map +1 -0
  55. package/commonjs/xlsx/file/validateLeadingBytes.js +47 -0
  56. package/commonjs/xlsx/file/validateLeadingBytes.js.map +1 -0
  57. package/commonjs/xlsx/file/validateLeadingBytes.test.js.map +1 -0
  58. package/commonjs/xlsx/isDateFormat.js +32 -27
  59. package/commonjs/xlsx/isDateFormat.js.map +1 -1
  60. package/commonjs/xlsx/isDateFormatStyle.js +19 -21
  61. package/commonjs/xlsx/isDateFormatStyle.js.map +1 -1
  62. package/commonjs/xlsx/parseCell.js +252 -115
  63. package/commonjs/xlsx/parseCell.js.map +1 -1
  64. package/commonjs/xlsx/parseCellAddress.js +22 -18
  65. package/commonjs/xlsx/parseCellAddress.js.map +1 -1
  66. package/commonjs/xlsx/parseExcelDate.js +4 -124
  67. package/commonjs/xlsx/parseExcelDate.js.map +1 -1
  68. package/commonjs/xlsx/parseExcelDate.test.js.map +1 -1
  69. package/commonjs/xlsx/parseExcelTimestamp.js +139 -0
  70. package/commonjs/xlsx/parseExcelTimestamp.js.map +1 -0
  71. package/commonjs/xlsx/parseFilePaths.js +48 -47
  72. package/commonjs/xlsx/parseFilePaths.js.map +1 -1
  73. package/commonjs/xlsx/parseSharedStrings.js +91 -36
  74. package/commonjs/xlsx/parseSharedStrings.js.map +1 -1
  75. package/commonjs/xlsx/parseSheet.js +527 -69
  76. package/commonjs/xlsx/parseSheet.js.map +1 -1
  77. package/commonjs/xlsx/parseSpreadsheetContents.js +154 -83
  78. package/commonjs/xlsx/parseSpreadsheetContents.js.map +1 -1
  79. package/commonjs/xlsx/parseSpreadsheetInfo.js +60 -59
  80. package/commonjs/xlsx/parseSpreadsheetInfo.js.map +1 -1
  81. package/commonjs/xlsx/parseStyles.js +75 -75
  82. package/commonjs/xlsx/parseStyles.js.map +1 -1
  83. package/commonjs/xml/parseXml.js +112 -0
  84. package/commonjs/xml/parseXml.js.map +1 -0
  85. package/commonjs/xml/parseXml.test.js.map +1 -0
  86. package/commonjs/xml/parseXmlStream.js.map +1 -1
  87. package/commonjs/xml/parseXmlStream.sax.js +69 -28
  88. package/commonjs/xml/parseXmlStream.sax.js.map +1 -1
  89. package/commonjs/xml/parseXmlStream.saxen.js +66 -40
  90. package/commonjs/xml/parseXmlStream.saxen.js.map +1 -1
  91. package/commonjs/zip/UnzipError.js +55 -0
  92. package/commonjs/zip/UnzipError.js.map +1 -0
  93. package/commonjs/zip/unzipFromArrayBuffer.js +21 -1
  94. package/commonjs/zip/unzipFromArrayBuffer.js.map +1 -1
  95. package/commonjs/zip/unzipFromArrayBuffer.test.js.map +1 -0
  96. package/commonjs/zip/unzipFromStream.fflate.js +43 -35
  97. package/commonjs/zip/unzipFromStream.fflate.js.map +1 -1
  98. package/commonjs/zip/unzipFromStream.js +188 -6
  99. package/commonjs/zip/unzipFromStream.js.map +1 -1
  100. package/commonjs/zip/unzipFromStream.unzipper.js +19 -34
  101. package/commonjs/zip/unzipFromStream.unzipper.js.map +1 -1
  102. package/modules/export/convertInputToNodeStream.js +0 -12
  103. package/modules/export/convertInputToNodeStream.js.map +1 -1
  104. package/modules/export/parseSheet.js +13 -6
  105. package/modules/export/parseSheet.js.map +1 -1
  106. package/modules/export/readSheetBrowser.js +3 -5
  107. package/modules/export/readSheetBrowser.js.map +1 -1
  108. package/modules/export/readSheetNode.js +3 -5
  109. package/modules/export/readSheetNode.js.map +1 -1
  110. package/modules/export/readSheetUniversal.js +2 -2
  111. package/modules/export/readSheetUniversal.js.map +1 -1
  112. package/modules/export/readSheetWebWorker.js +7 -8
  113. package/modules/export/readSheetWebWorker.js.map +1 -1
  114. package/modules/export/readXlsxFileBrowser.js +3 -5
  115. package/modules/export/readXlsxFileBrowser.js.map +1 -1
  116. package/modules/export/readXlsxFileNode.js +3 -5
  117. package/modules/export/readXlsxFileNode.js.map +1 -1
  118. package/modules/export/readXlsxFileUniversal.js +2 -2
  119. package/modules/export/readXlsxFileUniversal.js.map +1 -1
  120. package/modules/export/readXlsxFileWebWorker.js +7 -8
  121. package/modules/export/readXlsxFileWebWorker.js.map +1 -1
  122. package/modules/export/unpackXlsxFileBrowser.js +15 -4
  123. package/modules/export/unpackXlsxFileBrowser.js.map +1 -1
  124. package/modules/export/unpackXlsxFileBrowser.test.js.map +1 -0
  125. package/modules/export/unpackXlsxFileNode.js +32 -5
  126. package/modules/export/unpackXlsxFileNode.js.map +1 -1
  127. package/modules/export/unpackXlsxFileNode.test.js.map +1 -0
  128. package/modules/export/unpackXlsxFileUniversal.js +14 -3
  129. package/modules/export/unpackXlsxFileUniversal.js.map +1 -1
  130. package/modules/export/unpackXlsxFileUniversal.test.js.map +1 -0
  131. package/modules/parseSheetData/parseSheetData.js +9 -6
  132. package/modules/parseSheetData/parseSheetData.js.map +1 -1
  133. package/modules/saxen/parser.js +1 -1
  134. package/modules/saxen/parser.js.map +1 -1
  135. package/modules/utility/convertValuesFromUint8ArraysToStrings.js +92 -0
  136. package/modules/utility/convertValuesFromUint8ArraysToStrings.js.map +1 -0
  137. package/modules/xlsx/InvalidSpreadsheetError.js +50 -0
  138. package/modules/xlsx/InvalidSpreadsheetError.js.map +1 -0
  139. package/modules/xlsx/SheetNotFoundError.js +50 -0
  140. package/modules/xlsx/SheetNotFoundError.js.map +1 -0
  141. package/modules/xlsx/file/InputValidationStream.js +96 -0
  142. package/modules/xlsx/file/InputValidationStream.js.map +1 -0
  143. package/modules/xlsx/file/InputValidationStream.test.js.map +1 -0
  144. package/modules/xlsx/file/InvalidInputError.js +100 -0
  145. package/modules/xlsx/file/InvalidInputError.js.map +1 -0
  146. package/modules/xlsx/file/createFileTypeDetector.js +63 -0
  147. package/modules/xlsx/file/createFileTypeDetector.js.map +1 -0
  148. package/modules/xlsx/file/createFileTypeDetector.test.js.map +1 -0
  149. package/modules/xlsx/file/validateLeadingBytes.js +37 -0
  150. package/modules/xlsx/file/validateLeadingBytes.js.map +1 -0
  151. package/modules/xlsx/file/validateLeadingBytes.test.js.map +1 -0
  152. package/modules/xlsx/isDateFormat.js +31 -27
  153. package/modules/xlsx/isDateFormat.js.map +1 -1
  154. package/modules/xlsx/isDateFormatStyle.js +18 -21
  155. package/modules/xlsx/isDateFormatStyle.js.map +1 -1
  156. package/modules/xlsx/parseCell.js +251 -111
  157. package/modules/xlsx/parseCell.js.map +1 -1
  158. package/modules/xlsx/parseCellAddress.js +21 -18
  159. package/modules/xlsx/parseCellAddress.js.map +1 -1
  160. package/modules/xlsx/parseExcelDate.js +4 -124
  161. package/modules/xlsx/parseExcelDate.js.map +1 -1
  162. package/modules/xlsx/parseExcelDate.test.js.map +1 -1
  163. package/modules/xlsx/parseExcelTimestamp.js +133 -0
  164. package/modules/xlsx/parseExcelTimestamp.js.map +1 -0
  165. package/modules/xlsx/parseFilePaths.js +48 -47
  166. package/modules/xlsx/parseFilePaths.js.map +1 -1
  167. package/modules/xlsx/parseSharedStrings.js +91 -37
  168. package/modules/xlsx/parseSharedStrings.js.map +1 -1
  169. package/modules/xlsx/parseSheet.js +526 -68
  170. package/modules/xlsx/parseSheet.js.map +1 -1
  171. package/modules/xlsx/parseSpreadsheetContents.js +153 -81
  172. package/modules/xlsx/parseSpreadsheetContents.js.map +1 -1
  173. package/modules/xlsx/parseSpreadsheetInfo.js +60 -59
  174. package/modules/xlsx/parseSpreadsheetInfo.js.map +1 -1
  175. package/modules/xlsx/parseStyles.js +75 -75
  176. package/modules/xlsx/parseStyles.js.map +1 -1
  177. package/modules/xml/parseXml.js +106 -0
  178. package/modules/xml/parseXml.js.map +1 -0
  179. package/modules/xml/parseXml.test.js.map +1 -0
  180. package/modules/xml/parseXmlStream.js +2 -0
  181. package/modules/xml/parseXmlStream.js.map +1 -1
  182. package/modules/xml/parseXmlStream.sax.js +69 -28
  183. package/modules/xml/parseXmlStream.sax.js.map +1 -1
  184. package/modules/xml/parseXmlStream.saxen.js +67 -40
  185. package/modules/xml/parseXmlStream.saxen.js.map +1 -1
  186. package/modules/zip/UnzipError.js +49 -0
  187. package/modules/zip/UnzipError.js.map +1 -0
  188. package/modules/zip/unzipFromArrayBuffer.js +21 -1
  189. package/modules/zip/unzipFromArrayBuffer.js.map +1 -1
  190. package/modules/zip/unzipFromArrayBuffer.test.js.map +1 -0
  191. package/modules/zip/unzipFromStream.fflate.js +41 -35
  192. package/modules/zip/unzipFromStream.fflate.js.map +1 -1
  193. package/modules/zip/unzipFromStream.js +124 -1
  194. package/modules/zip/unzipFromStream.js.map +1 -1
  195. package/modules/zip/unzipFromStream.unzipper.js +19 -35
  196. package/modules/zip/unzipFromStream.unzipper.js.map +1 -1
  197. package/node/index.cjs +3 -0
  198. package/node/index.d.ts +16 -0
  199. package/node/index.js +3 -0
  200. package/package.json +5 -3
  201. package/types/InvalidInputError.d.ts +16 -0
  202. package/types/InvalidSpreadsheetError.d.ts +4 -0
  203. package/types/SheetNotFoundError.d.ts +4 -0
  204. package/universal/index.cjs +3 -0
  205. package/universal/index.d.ts +16 -0
  206. package/universal/index.js +3 -0
  207. package/web-worker/index.cjs +3 -0
  208. package/web-worker/index.d.ts +16 -0
  209. package/web-worker/index.js +3 -0
  210. package/commonjs/export/convertValuesFromUint8ArraysToStrings.js +0 -23
  211. package/commonjs/export/convertValuesFromUint8ArraysToStrings.js.map +0 -1
  212. package/commonjs/xlsx/convertCellsToData2dArray.js +0 -84
  213. package/commonjs/xlsx/convertCellsToData2dArray.js.map +0 -1
  214. package/commonjs/xlsx/dropEmptyColumns.js +0 -40
  215. package/commonjs/xlsx/dropEmptyColumns.js.map +0 -1
  216. package/commonjs/xlsx/dropEmptyColumns.test.js.map +0 -1
  217. package/commonjs/xlsx/dropEmptyRows.js +0 -43
  218. package/commonjs/xlsx/dropEmptyRows.js.map +0 -1
  219. package/commonjs/xlsx/dropEmptyRows.test.js.map +0 -1
  220. package/commonjs/xlsx/parseCellValue.js +0 -186
  221. package/commonjs/xlsx/parseCellValue.js.map +0 -1
  222. package/commonjs/xlsx/parseNumber.js +0 -20
  223. package/commonjs/xlsx/parseNumber.js.map +0 -1
  224. package/commonjs/xlsx/parseSharedString.js +0 -64
  225. package/commonjs/xlsx/parseSharedString.js.map +0 -1
  226. package/commonjs/xlsx/parseSheetData.js +0 -68
  227. package/commonjs/xlsx/parseSheetData.js.map +0 -1
  228. package/commonjs/xlsx/reconstructSheetDimensionsFromSheetCells.js +0 -29
  229. package/commonjs/xlsx/reconstructSheetDimensionsFromSheetCells.js.map +0 -1
  230. package/commonjs/xml/parseXmlStream.saxen.code.js +0 -953
  231. package/commonjs/xml/parseXmlStream.saxen.code.js.map +0 -1
  232. package/commonjs/xml/parseXmlStream.test.js.map +0 -1
  233. package/modules/export/convertValuesFromUint8ArraysToStrings.js +0 -17
  234. package/modules/export/convertValuesFromUint8ArraysToStrings.js.map +0 -1
  235. package/modules/xlsx/convertCellsToData2dArray.js +0 -77
  236. package/modules/xlsx/convertCellsToData2dArray.js.map +0 -1
  237. package/modules/xlsx/dropEmptyColumns.js +0 -34
  238. package/modules/xlsx/dropEmptyColumns.js.map +0 -1
  239. package/modules/xlsx/dropEmptyColumns.test.js.map +0 -1
  240. package/modules/xlsx/dropEmptyRows.js +0 -37
  241. package/modules/xlsx/dropEmptyRows.js.map +0 -1
  242. package/modules/xlsx/dropEmptyRows.test.js.map +0 -1
  243. package/modules/xlsx/parseCellValue.js +0 -180
  244. package/modules/xlsx/parseCellValue.js.map +0 -1
  245. package/modules/xlsx/parseNumber.js +0 -14
  246. package/modules/xlsx/parseNumber.js.map +0 -1
  247. package/modules/xlsx/parseSharedString.js +0 -55
  248. package/modules/xlsx/parseSharedString.js.map +0 -1
  249. package/modules/xlsx/parseSheetData.js +0 -55
  250. package/modules/xlsx/parseSheetData.js.map +0 -1
  251. package/modules/xlsx/reconstructSheetDimensionsFromSheetCells.js +0 -23
  252. package/modules/xlsx/reconstructSheetDimensionsFromSheetCells.js.map +0 -1
  253. package/modules/xml/parseXmlStream.saxen.code.js +0 -947
  254. package/modules/xml/parseXmlStream.saxen.code.js.map +0 -1
  255. package/modules/xml/parseXmlStream.test.js.map +0 -1
@@ -1,34 +1,69 @@
1
1
  import { Readable } from 'node:stream';
2
2
  import sax from 'sax';
3
3
 
4
- // For some strange reason, using "streaming" mode results in
4
+ // For some strange reason, enabling "streaming" mode results in
5
5
  // quite a dramatic drop in performance.
6
6
  // For example, reading a `10 MB` `.xlsx` file in "streaming" mode is about `3.1` secs.
7
7
  // while in non-"streaming" mode it's about `1.4` secs.
8
8
  // Because of such strange performance issue, "streaming" mode is turned off.
9
9
  var STREAMING_MODE = false;
10
- export default function parseXmlStream(xml, _ref) {
11
- var createInitialState = _ref.createInitialState,
12
- onOpenTag = _ref.onOpenTag,
13
- onCloseTag = _ref.onCloseTag,
14
- onText = _ref.onText;
15
- return new Promise(function (resolve, reject) {
16
- var errored = false;
17
- var strict = true;
18
- var xmlns = true;
10
+
11
+ /**
12
+ * Parses XML markup in a streaming fashion by calling the supplied callback functions as the XML markup is being input.
13
+ * @param {any} state — The initial `state`. This `state` will supposedly be modified by the callback functions as the XML is being parsed.
14
+ * @param {function} [onOpenTag]
15
+ * @param {function} [onCloseTag]
16
+ * @param {function} [onText]
17
+ * @returns {object} An object with properties: `promise`, `write(string)`, `end()`. The `promise` resolves with nothing.
18
+ */
19
+ export default function parseXmlStream(createInitialState, onOpenTag, onCloseTag, onText) {
20
+ // This `state` will be modified by the callback functions as the XML is being parsed.
21
+ var state = createInitialState();
22
+ var errored = false;
23
+ var mustNotHaveErrored = function mustNotHaveErrored() {
24
+ if (errored) {
25
+ // If this error is thrown then it means that there's a bug in the code
26
+ // because the code should not have got here if the XML parsing process
27
+ // has already errored.
28
+ throw new Error('Errored');
29
+ }
30
+ };
31
+ var strict = true;
32
+ var xmlns = true;
33
+ var parser = STREAMING_MODE ? undefined : sax.parser(strict, parserOptions);
34
+
35
+ // This `stream` could be `.pipe()`d to:
36
+ // `Readable.from(xml).pipe(parserStream)`
37
+ var parserStream = STREAMING_MODE ? sax.createStream(strict, parserOptions) : undefined;
38
+
39
+ // Inputs a chunk of XML.
40
+ var write = function write(xml) {
41
+ mustNotHaveErrored();
42
+ parser.write(xml);
43
+ };
44
+
45
+ // No more chunks of XMl will be input.
46
+ var end = function end() {
47
+ mustNotHaveErrored();
48
+ parser.close();
49
+ };
50
+
51
+ // This `promise` resolves with the final `state` when finished parsing.
52
+ var promise = new Promise(function (resolve, reject) {
19
53
  var parserOptions = {
20
54
  lowercase: true,
21
55
  xmlns: xmlns
22
56
  };
23
57
  var prefixedTagNameToUnprefixedTagName = {};
24
- var state = createInitialState();
25
58
 
26
- // an error happened.
59
+ // on XML parsing error
27
60
  var onerror = function onerror(error) {
28
61
  if (errored) {
29
62
  return;
30
63
  }
31
64
  errored = true;
65
+ // P.S. When the parser encounters an error, it halts until manually resumed.
66
+ // I.e. at this stage the parser is in halted state until manually resumed.
32
67
  reject(error);
33
68
  };
34
69
 
@@ -54,6 +89,11 @@ export default function parseXmlStream(xml, _ref) {
54
89
  if (onCloseTag) {
55
90
  var tagName = xmlns ? prefixedTagNameToUnprefixedTagName[name] : name;
56
91
  if (xmlns && !tagName) {
92
+ // I think that `sax` already validates closing tags internally,
93
+ // i.e. it's likely that it already emits an "error" event
94
+ // when it encounters an unclosed tag, in which case this error
95
+ // is not technically possible. And if it ever gets thrown
96
+ // then that would mean that there's a bug in the code.
57
97
  throw new Error("Unknown closing tag: ".concat(name));
58
98
  }
59
99
  onCloseTag(tagName, state);
@@ -74,25 +114,26 @@ export default function parseXmlStream(xml, _ref) {
74
114
  resolve(state);
75
115
  };
76
116
  if (STREAMING_MODE) {
77
- var parser = sax.createStream(strict, parserOptions);
78
- parser.on('error', onerror);
79
- parser.on('text', ontext);
80
- parser.on('opentag', onopentag);
81
- parser.on('closetag', onclosetag);
82
- parser.on('attribute', onattribute);
83
- parser.on('end', onend);
84
- Readable.from(xml).pipe(parser);
117
+ parserStream.on('error', onerror);
118
+ parserStream.on('text', ontext);
119
+ parserStream.on('opentag', onopentag);
120
+ parserStream.on('closetag', onclosetag);
121
+ parserStream.on('attribute', onattribute);
122
+ parserStream.on('end', onend);
85
123
  } else {
86
- var _parser = sax.parser(strict, parserOptions);
87
- _parser.onerror = onerror;
88
- _parser.ontext = ontext;
89
- _parser.onopentag = onopentag;
90
- _parser.onclosetag = onclosetag;
91
- _parser.onattribute = onattribute;
92
- _parser.onend = onend;
93
- _parser.write(xml).end();
124
+ parser.onerror = onerror;
125
+ parser.ontext = ontext;
126
+ parser.onopentag = onopentag;
127
+ parser.onclosetag = onclosetag;
128
+ parser.onattribute = onattribute;
129
+ parser.onend = onend;
94
130
  }
95
131
  });
132
+ return {
133
+ promise: promise,
134
+ write: write,
135
+ end: end
136
+ };
96
137
  }
97
138
  function getAttributesWithoutXmlnsPrefixes(attributes) {
98
139
  return Object.keys(attributes).reduce(function (attributesWithoutPrefixes, nameWithPrefix) {
@@ -1 +1 @@
1
- {"version":3,"file":"parseXmlStream.sax.js","names":["Readable","sax","STREAMING_MODE","parseXmlStream","xml","_ref","createInitialState","onOpenTag","onCloseTag","onText","Promise","resolve","reject","errored","strict","xmlns","parserOptions","lowercase","prefixedTagNameToUnprefixedTagName","state","onerror","error","ontext","text","onopentag","node","name","local","getAttributesWithoutXmlnsPrefixes","attributes","onclosetag","tagName","Error","concat","onattribute","attribute","onend","parser","createStream","on","from","pipe","write","end","Object","keys","reduce","attributesWithoutPrefixes","nameWithPrefix","value"],"sources":["../../source/xml/parseXmlStream.sax.js"],"sourcesContent":["import { Readable } from 'node:stream'\r\n\r\nimport sax from 'sax'\r\n\r\n// For some strange reason, using \"streaming\" mode results in\r\n// quite a dramatic drop in performance.\r\n// For example, reading a `10 MB` `.xlsx` file in \"streaming\" mode is about `3.1` secs.\r\n// while in non-\"streaming\" mode it's about `1.4` secs.\r\n// Because of such strange performance issue, \"streaming\" mode is turned off.\r\nconst STREAMING_MODE = false\r\n\r\nexport default function parseXmlStream(xml, {\r\n\tcreateInitialState,\r\n\tonOpenTag,\r\n\tonCloseTag,\r\n\tonText\r\n}) {\r\n\treturn new Promise((resolve, reject) => {\r\n\t\tlet errored = false\r\n\r\n\t\tconst strict = true\r\n\t\tconst xmlns = true\r\n\t\tconst parserOptions = { lowercase: true, xmlns }\r\n\r\n\t\tconst prefixedTagNameToUnprefixedTagName = {}\r\n\t\tconst state = createInitialState()\r\n\r\n\t\t// an error happened.\r\n\t\tconst onerror = (error) => {\r\n\t\t\tif (errored) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t\terrored = true\r\n\t\t\treject(error)\r\n\t\t}\r\n\r\n\t\t// got some text. `text` is the string of text.\r\n\t\tconst ontext = (text) => {\r\n\t\t\tif (onText) {\r\n\t\t\t\tonText(text, state)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// opened a tag. `node` has \"name\" and \"attributes\"\r\n\t\tconst onopentag = (node) => {\r\n\t\t\tif (onOpenTag) {\r\n\t\t\t\tif (xmlns) {\r\n\t\t\t\t\tprefixedTagNameToUnprefixedTagName[node.name] = node.local\r\n\t\t\t\t}\r\n\t\t\t\tonOpenTag(\r\n\t\t\t\t\txmlns ? node.local : node.name,\r\n\t\t\t\t\txmlns ? getAttributesWithoutXmlnsPrefixes(node.attributes) : node.attributes,\r\n\t\t\t\t\tstate\r\n\t\t\t\t)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// closed a tag.\r\n\t\tconst onclosetag = (name) => {\r\n\t\t\tif (onCloseTag) {\r\n\t\t\t\tconst tagName = xmlns ? prefixedTagNameToUnprefixedTagName[name] : name\r\n\t\t\t\tif (xmlns && !tagName) {\r\n\t\t\t\t\tthrow new Error(`Unknown closing tag: ${name}`)\r\n\t\t\t\t}\r\n\t\t\t\tonCloseTag(tagName, state)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// an attribute. `attribute` has \"name\" and \"value\"\r\n\t\tconst onattribute = (attribute) => {\r\n\t\t\t// const name = xmlns ? attribute.local : attribute.name\r\n\t\t\t// const value = attribute.value\r\n\t\t}\r\n\r\n\t\t// parser stream is done, and ready to have more stuff written to it.\r\n\t\tconst onend = () => {\r\n\t\t\tif (errored) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t\tresolve(state)\r\n\t\t}\r\n\r\n\t\tif (STREAMING_MODE) {\r\n\t\t\tconst parser = sax.createStream(strict, parserOptions)\r\n\t\t\tparser.on('error', onerror)\r\n\t\t\tparser.on('text', ontext)\r\n\t\t\tparser.on('opentag', onopentag)\r\n\t\t\tparser.on('closetag', onclosetag)\r\n\t\t\tparser.on('attribute', onattribute)\r\n\t\t\tparser.on('end', onend)\r\n\t\t\tReadable.from(xml).pipe(parser)\r\n\t\t} else {\r\n\t\t\tconst parser = sax.parser(strict, parserOptions)\r\n\t\t\tparser.onerror = onerror\r\n\t\t\tparser.ontext = ontext\r\n\t\t\tparser.onopentag = onopentag\r\n\t\t\tparser.onclosetag = onclosetag\r\n\t\t\tparser.onattribute = onattribute\r\n\t\t\tparser.onend = onend\r\n\t\t\tparser.write(xml).end()\r\n\t\t}\r\n\t})\r\n}\r\n\r\nfunction getAttributesWithoutXmlnsPrefixes(attributes) {\r\n return Object.keys(attributes).reduce((attributesWithoutPrefixes, nameWithPrefix) => {\r\n attributesWithoutPrefixes[attributes[nameWithPrefix].local] = attributes[nameWithPrefix].value\r\n return attributesWithoutPrefixes\r\n }, {})\r\n}"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,aAAa;AAEtC,OAAOC,GAAG,MAAM,KAAK;;AAErB;AACA;AACA;AACA;AACA;AACA,IAAMC,cAAc,GAAG,KAAK;AAE5B,eAAe,SAASC,cAAcA,CAACC,GAAG,EAAAC,IAAA,EAKvC;EAAA,IAJFC,kBAAkB,GAAAD,IAAA,CAAlBC,kBAAkB;IAClBC,SAAS,GAAAF,IAAA,CAATE,SAAS;IACTC,UAAU,GAAAH,IAAA,CAAVG,UAAU;IACVC,MAAM,GAAAJ,IAAA,CAANI,MAAM;EAEN,OAAO,IAAIC,OAAO,CAAC,UAACC,OAAO,EAAEC,MAAM,EAAK;IACvC,IAAIC,OAAO,GAAG,KAAK;IAEnB,IAAMC,MAAM,GAAG,IAAI;IACnB,IAAMC,KAAK,GAAG,IAAI;IAClB,IAAMC,aAAa,GAAG;MAAEC,SAAS,EAAE,IAAI;MAAEF,KAAK,EAALA;IAAM,CAAC;IAEhD,IAAMG,kCAAkC,GAAG,CAAC,CAAC;IAC7C,IAAMC,KAAK,GAAGb,kBAAkB,CAAC,CAAC;;IAElC;IACA,IAAMc,OAAO,GAAG,SAAVA,OAAOA,CAAIC,KAAK,EAAK;MAC1B,IAAIR,OAAO,EAAE;QACZ;MACD;MACAA,OAAO,GAAG,IAAI;MACdD,MAAM,CAACS,KAAK,CAAC;IAC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","parseXmlStream","createInitialState","onOpenTag","onCloseTag","onText","state","errored","mustNotHaveErrored","Error","strict","xmlns","parser","undefined","parserOptions","parserStream","createStream","write","xml","end","close","promise","Promise","resolve","reject","lowercase","prefixedTagNameToUnprefixedTagName","onerror","error","ontext","text","onopentag","node","name","local","getAttributesWithoutXmlnsPrefixes","attributes","onclosetag","tagName","concat","onattribute","attribute","onend","on","Object","keys","reduce","attributesWithoutPrefixes","nameWithPrefix","value"],"sources":["../../source/xml/parseXmlStream.sax.js"],"sourcesContent":["import { Readable } from 'node:stream'\r\n\r\nimport sax from 'sax'\r\n\r\n// For some strange reason, enabling \"streaming\" mode results in\r\n// quite a dramatic drop in performance.\r\n// For example, reading a `10 MB` `.xlsx` file in \"streaming\" mode is about `3.1` secs.\r\n// while in non-\"streaming\" mode it's about `1.4` secs.\r\n// Because of such strange performance issue, \"streaming\" mode is turned off.\r\nconst STREAMING_MODE = false\r\n\r\n/**\r\n * Parses XML markup in a streaming fashion by calling the supplied callback functions as the XML markup is being input.\r\n * @param {any} state — The initial `state`. This `state` will supposedly be modified by the callback functions as the XML is being parsed.\r\n * @param {function} [onOpenTag]\r\n * @param {function} [onCloseTag]\r\n * @param {function} [onText]\r\n * @returns {object} An object with properties: `promise`, `write(string)`, `end()`. The `promise` resolves with nothing.\r\n */\r\nexport default function parseXmlStream(\r\n\tcreateInitialState,\r\n\tonOpenTag,\r\n\tonCloseTag,\r\n\tonText\r\n) {\r\n\t// This `state` will be modified by the callback functions as the XML is being parsed.\r\n\tconst state = createInitialState()\r\n\r\n let errored = false\r\n\r\n const mustNotHaveErrored = () => {\r\n if (errored) {\r\n // If this error is thrown then it means that there's a bug in the code\r\n // because the code should not have got here if the XML parsing process\r\n // has already errored.\r\n throw new Error('Errored')\r\n }\r\n }\r\n\r\n\tconst strict = true\r\n\tconst xmlns = true\r\n\r\n\tconst parser = STREAMING_MODE ? undefined : sax.parser(strict, parserOptions)\r\n\r\n\t// This `stream` could be `.pipe()`d to:\r\n\t// `Readable.from(xml).pipe(parserStream)`\r\n\tconst parserStream = STREAMING_MODE ? sax.createStream(strict, parserOptions) : undefined\r\n\r\n\t// Inputs a chunk of XML.\r\n\tconst write = (xml) => {\r\n\t\tmustNotHaveErrored()\r\n\t\tparser.write(xml)\r\n\t}\r\n\r\n\t// No more chunks of XMl will be input.\r\n\tconst end = () => {\r\n\t\tmustNotHaveErrored()\r\n\t\tparser.close()\r\n\t}\r\n\r\n\t// This `promise` resolves with the final `state` when finished parsing.\r\n\tconst promise = new Promise((resolve, reject) => {\r\n\t\tconst parserOptions = { lowercase: true, xmlns }\r\n\r\n\t\tconst prefixedTagNameToUnprefixedTagName = {}\r\n\r\n\t\t// on XML parsing error\r\n\t\tconst onerror = (error) => {\r\n\t\t\tif (errored) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t\terrored = true\r\n\t\t\t// P.S. When the parser encounters an error, it halts until manually resumed.\r\n\t\t\t// I.e. at this stage the parser is in halted state until manually resumed.\r\n\t\t\treject(error)\r\n\t\t}\r\n\r\n\t\t// got some text. `text` is the string of text.\r\n\t\tconst ontext = (text) => {\r\n\t\t\tif (onText) {\r\n\t\t\t\tonText(text, state)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// opened a tag. `node` has \"name\" and \"attributes\"\r\n\t\tconst onopentag = (node) => {\r\n\t\t\tif (onOpenTag) {\r\n\t\t\t\tif (xmlns) {\r\n\t\t\t\t\tprefixedTagNameToUnprefixedTagName[node.name] = node.local\r\n\t\t\t\t}\r\n\t\t\t\tonOpenTag(\r\n\t\t\t\t\txmlns ? node.local : node.name,\r\n\t\t\t\t\txmlns ? getAttributesWithoutXmlnsPrefixes(node.attributes) : node.attributes,\r\n\t\t\t\t\tstate\r\n\t\t\t\t)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// closed a tag.\r\n\t\tconst onclosetag = (name) => {\r\n\t\t\tif (onCloseTag) {\r\n\t\t\t\tconst tagName = xmlns ? prefixedTagNameToUnprefixedTagName[name] : name\r\n\t\t\t\tif (xmlns && !tagName) {\r\n\t\t\t\t\t// I think that `sax` already validates closing tags internally,\r\n\t\t\t\t\t// i.e. it's likely that it already emits an \"error\" event\r\n\t\t\t\t\t// when it encounters an unclosed tag, in which case this error\r\n\t\t\t\t\t// is not technically possible. And if it ever gets thrown\r\n\t\t\t\t\t// then that would mean that there's a bug in the code.\r\n\t\t\t\t\tthrow new Error(`Unknown closing tag: ${name}`)\r\n\t\t\t\t}\r\n\t\t\t\tonCloseTag(tagName, state)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// an attribute. `attribute` has \"name\" and \"value\"\r\n\t\tconst onattribute = (attribute) => {\r\n\t\t\t// const name = xmlns ? attribute.local : attribute.name\r\n\t\t\t// const value = attribute.value\r\n\t\t}\r\n\r\n\t\t// parser stream is done, and ready to have more stuff written to it.\r\n\t\tconst onend = () => {\r\n\t\t\tif (errored) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t\tresolve(state)\r\n\t\t}\r\n\r\n\t\tif (STREAMING_MODE) {\r\n\t\t\tparserStream.on('error', onerror)\r\n\t\t\tparserStream.on('text', ontext)\r\n\t\t\tparserStream.on('opentag', onopentag)\r\n\t\t\tparserStream.on('closetag', onclosetag)\r\n\t\t\tparserStream.on('attribute', onattribute)\r\n\t\t\tparserStream.on('end', onend)\r\n\t\t} else {\r\n\t\t\tparser.onerror = onerror\r\n\t\t\tparser.ontext = ontext\r\n\t\t\tparser.onopentag = onopentag\r\n\t\t\tparser.onclosetag = onclosetag\r\n\t\t\tparser.onattribute = onattribute\r\n\t\t\tparser.onend = onend\r\n\t\t}\r\n\t})\r\n\r\n\treturn {\r\n\t\tpromise,\r\n\t\twrite,\r\n\t\tend\r\n\t}\r\n}\r\n\r\nfunction getAttributesWithoutXmlnsPrefixes(attributes) {\r\n return Object.keys(attributes).reduce((attributesWithoutPrefixes, nameWithPrefix) => {\r\n attributesWithoutPrefixes[attributes[nameWithPrefix].local] = attributes[nameWith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EAAE,CAAC,CAAC,CAAC;AACR"}
@@ -3,32 +3,70 @@
3
3
  // https://gitlab.com/catamphetamine/read-excel-file/-/work_items/115
4
4
  // Because of that, `saxen` source code had to be copy-pasted.
5
5
  //
6
+ // Not to mention that it would have to be copy-pasted anyway for compatiblity with `worker-f`
7
+ // because `Parser` is not a "self-contained" function.
8
+ //
6
9
  // import { Parser } from 'saxen'
7
10
  import Parser from '../saxen/parser.js';
8
- export default function parseXmlStream(xml, _ref) {
9
- var createInitialState = _ref.createInitialState,
10
- onOpenTag = _ref.onOpenTag,
11
- onCloseTag = _ref.onCloseTag,
12
- onText = _ref.onText;
13
- // This function was put inside the `parseXmlStream()` function body
14
- // in order to prevent it from becoming an "external dependency"
15
- // when using `worker-f` package to run this code in a worker.
16
- var TAG_NAME_PREFIX = /.+:/;
17
- function trimXmlnsPrefix(tagName) {
18
- return tagName.replace(TAG_NAME_PREFIX, '');
11
+
12
+ /**
13
+ * Parses XML markup in a streaming fashion by calling the supplied callback functions as the XML markup is being input.
14
+ * @param {any} state — The initial `state`. This `state` will supposedly be modified by the callback functions as the XML is being parsed.
15
+ * @param {function} [onOpenTag]
16
+ * @param {function} [onCloseTag]
17
+ * @param {function} [onText]
18
+ * @returns {object} An object with properties: `promise`, `write(string)`, `end()`. The `promise` resolves with nothing.
19
+ */
20
+ export default function parseXmlStream(state, onOpenTag, onCloseTag, onText) {
21
+ var errored = false;
22
+ var mustNotHaveErrored = function mustNotHaveErrored() {
23
+ if (errored) {
24
+ // If this error is thrown then it means that there's a bug in the code
25
+ // because the code should not have got here if the XML parsing process
26
+ // has already errored.
27
+ throw new Error('Errored');
28
+ }
29
+ };
30
+ var resolvePromise;
31
+ var xmlns = true;
32
+
33
+ // `proxy: true` option enables "proxy" mode.
34
+ //
35
+ // In "proxy" mode, `onopentag` and `onclosetag` receive slightly different arguments:
36
+ // * element name is replaced with element object
37
+ // * getAttribute() function is not passed
38
+ //
39
+ var parser = new Parser({
40
+ proxy: true
41
+ });
42
+
43
+ // Parse XML "namespaces" (`xmlns` stuff).
44
+ if (xmlns) {
45
+ parser.ns();
19
46
  }
20
- return new Promise(function (resolve, reject) {
21
- var errored = false;
22
- var xmlns = true;
23
- var state = createInitialState();
47
+ var write = function write(xml) {
48
+ mustNotHaveErrored();
49
+ parser.write(xml);
50
+ };
51
+ var end = function end() {
52
+ mustNotHaveErrored();
53
+ parser.end();
54
+ resolvePromise();
55
+ };
56
+
57
+ // This `promise` resolves with the final `state` when finished parsing.
58
+ var promise = new Promise(function (resolve, reject) {
59
+ resolvePromise = resolve;
24
60
 
25
- // an error happened.
61
+ // on XML parsing error
26
62
  var onerror = function onerror(error) {
27
- if (errored) {
28
- return;
29
- }
30
63
  errored = true;
31
- reject(error);
64
+ // If the error is not re-thrown here, the parser will simply keep parsing,
65
+ // i.e. it doesn't halt after encountering an error and doesn't require manual resuming.
66
+ // So it must re-throw the error here in order for the parser to stop.
67
+ // Because the error is thrown inside a `new Promise()` constructor,
68
+ // the promise will reject automatically.
69
+ throw error;
32
70
  };
33
71
 
34
72
  // got some text. `text` is the string of text.
@@ -64,30 +102,19 @@ export default function parseXmlStream(xml, _ref) {
64
102
  onCloseTag(tagName, state);
65
103
  }
66
104
  };
67
-
68
- // `proxy: true` option enables "proxy" mode.
69
- //
70
- // In "proxy" mode, `onopentag` and `onclosetag` receive slightly different arguments:
71
- // * element name is replaced with element object
72
- // * getAttribute() function is not passed
73
- //
74
- var parser = new Parser({
75
- proxy: true
76
- });
77
-
78
- // Parse XML "namespaces" (`xmlns` stuff).
79
- if (xmlns) {
80
- parser.ns();
81
- }
82
105
  parser.on('error', onerror);
83
106
  parser.on('text', ontext);
84
107
  parser.on('openTag', onopentag);
85
108
  parser.on('closeTag', onclosetag);
86
- parser.parse(xml);
87
- if (errored) {
88
- return;
89
- }
90
- resolve(state);
91
109
  });
110
+ return {
111
+ promise: promise,
112
+ write: write,
113
+ end: end
114
+ };
115
+ }
116
+ var TAG_NAME_PREFIX = /.+:/;
117
+ function trimXmlnsPrefix(tagName) {
118
+ return tagName.replace(TAG_NAME_PREFIX, '');
92
119
  }
93
120
  //# sourceMappingURL=parseXmlStream.saxen.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseXmlStream.saxen.js","names":["Parser","parseXmlStream","xml","_ref","createInitialState","onOpenTag","onCloseTag","onText","TAG_NAME_PREFIX","trimXmlnsPrefix","tagName","replace","Promise","resolve","reject","errored","xmlns","state","onerror","error","ontext","text","decodeEntities","onopentag","element","selfClosing","getContext","attributes","attrs","name","originalName","onclosetag","parser","proxy","ns","on","parse"],"sources":["../../source/xml/parseXmlStream.saxen.js"],"sourcesContent":["// Starting from version `11.x`, `saxen` dropped CommonJS export.\r\n// CommonJS compatibility was requested by one of the users of this package:\r\n// https://gitlab.com/catamphetamine/read-excel-file/-/work_items/115\r\n// Because of that, `saxen` source code had to be copy-pasted.\r\n//\r\n// import { Parser } from 'saxen'\r\nimport Parser from '../saxen/parser.js'\r\n\r\nexport default function parseXmlStream(xml, {\r\n\tcreateInitialState,\r\n\tonOpenTag,\r\n\tonCloseTag,\r\n\tonText\r\n}) {\r\n\t// This function was put inside the `parseXmlStream()` function body\r\n\t// in order to prevent it from becoming an \"external dependency\"\r\n\t// when using `worker-f` package to run this code in a worker.\r\n\tconst TAG_NAME_PREFIX = /.+:/\r\n\tfunction trimXmlnsPrefix(tagName) {\r\n\t\treturn tagName.replace(TAG_NAME_PREFIX, '')\r\n\t}\r\n\r\n\treturn new Promise((resolve, reject) => {\r\n\t\tlet errored = false\r\n\r\n\t\tconst xmlns = true\r\n\r\n\t\tconst state = createInitialState()\r\n\r\n\t\t// an error happened.\r\n\t\tconst onerror = (error) => {\r\n\t\t\tif (errored) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t\terrored = true\r\n\t\t\treject(error)\r\n\t\t}\r\n\r\n\t\t// got some text. `text` is the string of text.\r\n\t\tconst ontext = (text, decodeEntities) => {\r\n\t\t\tif (onText) {\r\n\t\t\t\t// `saxen` doesn't decode character references (`é`, `&`, etc) in text:\r\n\t\t\t\t// instead, it provides a `decodeEntities()` function for the consumer to call.\r\n\t\t\t\tonText(decodeEntities(text), state)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// opened a tag. `node` has \"name\" and \"attributes\"\r\n\t\tconst onopentag = (element, decodeEntities, selfClosing, getContext) => {\r\n\t\t\tif (onOpenTag) {\r\n\t\t\t\t// `saxen` doesn't decode character references (`é`, `&`, etc)\r\n\t\t\t\t// in attribute values either, so decode them here.\r\n\t\t\t\tconst attributes = element.attrs\r\n\t\t\t\tfor (const name in attributes) {\r\n\t\t\t\t\tattributes[name] = decodeEntities(attributes[name])\r\n\t\t\t\t}\r\n\t\t\t\t// * `element.originalName` — The tag name as written in the XML string, retaining the original prefix regardless of the list of pre-configured namespace mappings.\r\n\t\t\t\t// * `element.name` — The tag name with the namespace prefix resolved against the list of pre-configured namespace mappings. I.e. the namespace prefix will potentially be replaced with one from the pre-configured namespace map.\r\n\t\t\t\tonOpenTag(\r\n\t\t\t\t\txmlns ? trimXmlnsPrefix(element.originalName) : element.name,\r\n\t\t\t\t\tattributes,\r\n\t\t\t\t\tstate\r\n\t\t\t\t)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// closed a tag.\r\n\t\tconst onclosetag = (element) => {\r\n\t\t\tif (onCloseTag) {\r\n\t\t\t\t// * `element.originalName` — The tag name as written in the XML string, retaining the original prefix regardless of the list of pre-configured namespace mappings.\r\n\t\t\t\t// * `element.name` — The tag name with the namespace prefix resolved against the list of pre-configured namespace mappings. I.e. the namespace prefix will potentially be replaced with one from the pre-configured namespace map.\r\n\t\t\t\tconst tagName = xmlns ? trimXmlnsPrefix(element.originalName) : element.name\r\n\t\t\t\tonCloseTag(tagName, state)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// `proxy: true` option enables \"proxy\" mode.\r\n\t\t//\r\n\t\t// In \"proxy\" mode, `onopentag` and `onclosetag` receive slightly different arguments:\r\n\t\t// * element name is replaced with element object\r\n\t\t// * getAttribute() function is not passed\r\n\t\t//\r\n\t\tconst parser = new Parser({ proxy: true })\r\n\r\n\t\t// Parse XML \"namespaces\" (`xmlns` stuff).\r\n\t\tif (xmlns) {\r\n\t\t\tparser.ns()\r\n\t\t}\r\n\r\n\t\tparser.on('error', onerror)\r\n\t\tparser.on('text', ontext)\r\n\t\tparser.on('openTag', onopentag)\r\n\t\tparser.on('closeTag', onclosetag)\r\n\r\n\t\tparser.parse(xml)\r\n\r\n\t\tif (errored) {\r\n\t\t\treturn\r\n\t\t}\r\n\t\tresolve(state)\r\n\t})\r\n}"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,MAAM,MAAM,oBAAoB;AAEvC,eAAe,SAASC,cAAcA,CAACC,GAAG,EAAAC,IAAA,EAKvC;EAAA,IAJFC,kBAAkB,GAAAD,IAAA,CAAlBC,kBAAkB;IAClBC,SAAS,GAAAF,IAAA,CAATE,SAAS;IACTC,UAAU,GAAAH,IAAA,CAAVG,UAAU;IACVC,MAAM,GAAAJ,IAAA,CAANI,MAAM;EAEN;EACA;EACA;EACA,IAAMC,eAAe,GAAG,KAAK;EAC7B,SAASC,eAAeA,CAACC,OAAO,EAAE;IACjC,OAAOA,OAAO,CAACC,OAAO,CAACH,eAAe,EAAE,EAAE,CAAC;EAC5C;EAEA,OAAO,IAAII,OAAO,CAAC,UAACC,OAAO,EAAEC,MAAM,EAAK;IACvC,IAAIC,OAAO,GAAG,KAAK;IAEnB,IAAMC,KAAK,GAAG,IAAI;IAElB,IAAMC,KAAK,GAAGb,kBAAkB,CAAC,CAAC;;IAElC;IACA,IAAMc,OAAO,GAAG,SAAVA,OAAOA,CAAIC,KAAK,EAAK;MAC1B,IAAIJ,OAAO,EAAE;QACZ;MACD;MACAA,OAAO,GAAG,IAAI;MACdD,MAAM,CAACK,KAAK,CAAC;IACd,CAAC;;IAED;IACA,IAAMC,MAAM,GAAG,SAATA,MAAMA,CAAIC,IAAI,EAAE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,MAAM,CAACG,EAAE,CAAC,UAAU,EAAEJ,UAAU,CAAC;IAEjCC,MAAM,CAACI,KAAK,CAAClC,GAAG,CAAC;IAEjB,IAAIa,OAAO,EAAE;MACZ;IACD;IACAF,OAAO,CAACI,KAAK,CAAC;EACf,CAAC,CAAC;AACH"}
1
+ {"version":3,"file":"parseXmlStream.saxen.js","names":["Parser","parseXmlStream","state","onOpenTag","onCloseTag","onText","errored","mustNotHaveErrored","Error","resolvePromise","xmlns","parser","proxy","ns","write","xml","end","promise","Promise","resolve","reject","onerror","error","ontext","text","decodeEntities","onopentag","element","selfClosing","getContext","attributes","attrs","name","trimXmlnsPrefix","originalName","onclosetag","tagName","on","TAG_NAME_PREFIX","replace"],"sources":["../../source/xml/parseXmlStream.saxen.js"],"sourcesContent":["// Starting from version `11.x`, `saxen` dropped CommonJS export.\r\n// CommonJS compatibility was requested by one of the users of this package:\r\n// https://gitlab.com/catamphetamine/read-excel-file/-/work_items/115\r\n// Because of that, `saxen` source code had to be copy-pasted.\r\n//\r\n// Not to mention that it would have to be copy-pasted anyway for compatiblity with `worker-f`\r\n// because `Parser` is not a \"self-contained\" function.\r\n//\r\n// import { Parser } from 'saxen'\r\nimport Parser from '../saxen/parser.js'\r\n\r\n/**\r\n * Parses XML markup in a streaming fashion by calling the supplied callback functions as the XML markup is being input.\r\n * @param {any} state — The initial `state`. This `state` will supposedly be modified by the callback functions as the XML is being parsed.\r\n * @param {function} [onOpenTag]\r\n * @param {function} [onCloseTag]\r\n * @param {function} [onText]\r\n * @returns {object} An object with properties: `promise`, `write(string)`, `end()`. The `promise` resolves with nothing.\r\n */\r\nexport default function parseXmlStream(\r\n state,\r\n onOpenTag,\r\n onCloseTag,\r\n onText\r\n) {\r\n let errored = false\r\n\r\n const mustNotHaveErrored = () => {\r\n if (errored) {\r\n // If this error is thrown then it means that there's a bug in the code\r\n // because the code should not have got here if the XML parsing process\r\n // has already errored.\r\n throw new Error('Errored')\r\n }\r\n }\r\n\r\n let resolvePromise\r\n\r\n const xmlns = true\r\n\r\n // `proxy: true` option enables \"proxy\" mode.\r\n //\r\n // In \"proxy\" mode, `onopentag` and `onclosetag` receive slightly different arguments:\r\n // * element name is replaced with element object\r\n // * getAttribute() function is not passed\r\n //\r\n const parser = new Parser({ proxy: true })\r\n\r\n // Parse XML \"namespaces\" (`xmlns` stuff).\r\n if (xmlns) {\r\n parser.ns()\r\n }\r\n\r\n const write = (xml) => {\r\n mustNotHaveErrored()\r\n parser.write(xml)\r\n }\r\n\r\n const end = () => {\r\n mustNotHaveErrored()\r\n parser.end()\r\n\t\tresolvePromise()\r\n }\r\n\r\n\t// This `promise` resolves with the final `state` when finished parsing.\r\n\tconst promise = new Promise((resolve, reject) => {\r\n resolvePromise = resolve\r\n\r\n // on XML parsing error\r\n const onerror = (error) => {\r\n errored = true\r\n // If the error is not re-thrown here, the parser will simply keep parsing,\r\n // i.e. it doesn't halt after encountering an error and doesn't require manual resuming.\r\n // So it must re-throw the error here in order for the parser to stop.\r\n // Because the error is thrown inside a `new Promise()` constructor,\r\n // the promise will reject automatically.\r\n throw error\r\n }\r\n\r\n // got some text. `text` is the string of text.\r\n const ontext = (text, decodeEntities) => {\r\n if (onText) {\r\n\t\t\t\t// `saxen` doesn't decode character references (`é`, `&`, etc) in text:\r\n\t\t\t\t// instead, it provides a `decodeEntities()` function for the consumer to call.\r\n\t\t\t\tonText(decodeEntities(text), state)\r\n }\r\n }\r\n\r\n // opened a tag. `node` has \"name\" and \"attributes\"\r\n const onopentag = (element, decodeEntities, selfClosing, getContext) => {\r\n if (onOpenTag) {\r\n\t\t\t\t// `saxen` doesn't decode character references (`é`, `&`, etc)\r\n\t\t\t\t// in attribute values either, so decode them here.\r\n\t\t\t\tconst attributes = element.attrs\r\n\t\t\t\tfor (const name in attributes) {\r\n\t\t\t\t\tattributes[name] = decodeEntities(attributes[name])\r\n\t\t\t\t}\r\n // * `element.originalName` — The tag name as written in the XML string, retaining the original prefix regardless of the list of pre-configured namespace mappings.\r\n // * `element.name` — The tag name with the namespace prefix resolved against the list of pre-configured namespace mappings. I.e. the namespace prefix will potentially be replaced with one from the pre-configured namespace map.\r\n onOpenTag(\r\n xmlns ? trimXmlnsPrefix(element.originalName) : element.name,\r\n\t\t\t\t\tattributes,\r\n state\r\n )\r\n }\r\n }\r\n\r\n // closed a tag.\r\n const onclosetag = (element) => {\r\n if (onCloseTag) {\r\n // * `element.originalName` — The tag name as written in the XML string, retaining the original prefix regardless of the list of pre-configured namespace mappings.\r\n // * `element.name` — The tag name with the namespace prefix resolved against the list of pre-configured namespace mappings. I.e. the namespace prefix will potentially be replaced with one from the pre-configured namespace map.\r\n const tagName = xmlns ? trimXmlnsPrefix(element.originalName) : element.name\r\n onCloseTag(tagName, state)\r\n }\r\n }\r\n\r\n parser.on('error', onerror)\r\n parser.on('text', ontext)\r\n parser.on('openTag', onopentag)\r\n parser.on('closeTag', onclosetag)\r\n })\r\n\r\n return { promise, write, end }\r\n}\r\n\r\nconst TAG_NAME_PREFIX = /.+:/\r\nfunction trimXmlnsPrefix(tagName) {\r\n return tagName.replace(TAG_NAME_PREFIX, '')\r\n}"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,MAAM,MAAM,oBAAoB;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,cAAcA,CACpCC,KAAK,EACLC,SAAS,EACTC,UAAU,EACVC,MAAM,EACN;EACA,IAAIC,OAAO,GAAG,KAAK;EAEnB,IAAMC,kBAAkB,GAAG,SAArBA,kBAAkBA,CAAA,EAAS;IAC/B,IAAID,OAAO,EAAE;MACX;MACA;MACA;MACA,MAAM,IAAIE,KAAK,CAAC,SAAS,CAAC;IAC5B;EACF,CAAC;EAED,IAAIC,cAAc;EAElB,IAAMC,KAAK,GAAG,IAAI;;EAElB;EACA;EACA;EACA;EACA;EACA;EACA,IAAMC,MAAM,GAAG,IAAIX,MAAM,CAAC;IAAEY,KAAK,EAAE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GP,OAAO,CAACK,IAAI,EACjEF,UAAU,EACL5B,KACF,CAAC;MACH;IACF,CAAC;;IAED;IACA,IAAMiC,UAAU,GAAG,SAAbA,UAAUA,CAAIR,OAAO,EAAK;MAC9B,IAAIvB,UAAU,EAAE;QACd;QACA;QACA,IAAMgC,OAAO,GAAG1B,KAAK,GAAGuB,eAAe,CAACN,OAAO,CAACO,YAAY,CAAC,GAAGP,OAAO,CAACK,IAAI;QAC5E5B,UAAU,CAACgC,OAAO,EAAElC,KAAK,CAAC;MAC5B;IACF,CAAC;IAEDS,MAAM,CAAC0B,EAAE,CAAC,OAAO,EAAEhB,OAAO,CAAC;IAC3BV,MAAM,CAAC0B,EAAE,CAAC,MAAM,EAAEd,MAAM,CAAC;IACzBZ,MAAM,CAAC0B,EAAE,CAAC,SAAS,EAAEX,SAAS,CAAC;IAC/Bf,MAAM,CAAC0B,EAAE,CAAC,UAAU,EAAEF,UAAU,CAAC;EACnC,CAAC,CAAC;EAEF,OAAO;IAAElB,OAAO,EAAPA,OAAO;IAAEH,KAAK,EAALA,KAAK;IAAEE,GAAG,EAAHA;EAAI,CAAC;AAChC;AAEA,IAAMsB,eAAe,GAAG,KAAK;AAC7B,SAASL,eAAeA,CAACG,OAAO,EAAE;EAChC,OAAOA,OAAO,CAACG,OAAO,CAACD,eAAe,EAAE,EAAE,CAAC;AAC7C"}
@@ -0,0 +1,49 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
3
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
5
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
8
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
10
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
11
+ function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
12
+ function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
13
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
14
+ function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
15
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
16
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
17
+ var UnzipError = /*#__PURE__*/function (_Error) {
18
+ _inherits(UnzipError, _Error);
19
+ var _super = _createSuper(UnzipError);
20
+ function UnzipError() {
21
+ _classCallCheck(this, UnzipError);
22
+ return _super.apply(this, arguments);
23
+ }
24
+ return _createClass(UnzipError);
25
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
26
+ export { UnzipError as default };
27
+ export function createUnzipError(error) {
28
+ var unzipError = new UnzipError(error.message);
29
+ // Keep original stack if it exists
30
+ if (error.stack) {
31
+ unzipError.stack = error.stack;
32
+ }
33
+ // Clean up stack trace a bit in Node.js/V8 environments
34
+ if (Error.captureStackTrace) {
35
+ Error.captureStackTrace(unzipError, createUnzipError);
36
+ }
37
+ // `Error.prototype.cause` property indicates the specific, original reason
38
+ // a given error occurred. Standardized in ES2022, it allows you to chain errors
39
+ // by catching a low-level exception and re-throwing a meaningful, high-level error
40
+ // without wiping out the diagnostic context or stack trace of the original failure.
41
+ //
42
+ // Adding a `.cause` property mimics modern error chaining for environments that support it
43
+ // while remaining completely harmless in older systems.
44
+ //
45
+ unzipError.cause = error;
46
+ // Return the error.
47
+ return unzipError;
48
+ }
49
+ //# sourceMappingURL=UnzipError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnzipError.js","names":["UnzipError","_Error","_inherits","_super","_createSuper","_classCallCheck","apply","arguments","_createClass","_wrapNativeSuper","Error","default","createUnzipError","error","unzipError","message","stack","captureStackTrace","cause"],"sources":["../../source/zip/UnzipError.js"],"sourcesContent":["export default class UnzipError extends Error {}\r\n\r\nexport function createUnzipError(error) {\r\n\tconst unzipError = new UnzipError(error.message)\r\n\t// Keep original stack if it exists\r\n\tif (error.stack) {\r\n\t\tunzipError.stack = error.stack\r\n\t}\r\n\t// Clean up stack trace a bit in Node.js/V8 environments\r\n\tif (Error.captureStackTrace) {\r\n\t\tError.captureStackTrace(unzipError, createUnzipError)\r\n\t}\r\n\t// `Error.prototype.cause` property indicates the specific, original reason\r\n\t// a given error occurred. Standardized in ES2022, it allows you to chain errors\r\n\t// by catching a low-level exception and re-throwing a meaningful, high-level error\r\n\t// without wiping out the diagnostic context or stack trace of the original failure.\r\n\t//\r\n\t// Adding a `.cause` property mimics modern error chaining for environments that support it\r\n\t// while remaining completely harmless in older systems.\r\n\t//\r\n\tunzipError.cause = error\r\n\t// Return the error.\r\n\treturn unzipError\r\n}"],"mappings":";;;;;;;;;;;;;;;;IAAqBA,UAAU,0BAAAC,MAAA;EAAAC,SAAA,CAAAF,UAAA,EAAAC,MAAA;EAAA,IAAAE,MAAA,GAAAC,YAAA,CAAAJ,UAAA;EAAA,SAAAA,WAAA;IAAAK,eAAA,OAAAL,UAAA;IAAA,OAAAG,MAAA,CAAAG,KAAA,OAAAC,SAAA;EAAA;EAAA,OAAAC,YAAA,CAAAR,UAAA;AAAA,gBAAAS,gBAAA,CAASC,KAAK;AAAA,SAAxBV,UAAU,IAAAW,OAAA;AAE/B,OAAO,SAASC,gBAAgBA,CAACC,KAAK,EAAE;EACvC,IAAMC,UAAU,GAAG,IAAId,UAAU,CAACa,KAAK,CAACE,OAAO,CAAC;EAChD;EACA,IAAIF,KAAK,CAACG,KAAK,EAAE;IAChBF,UAAU,CAACE,KAAK,GAAGH,KAAK,CAACG,KAAK;EAC/B;EACA;EACA,IAAIN,KAAK,CAACO,iBAAiB,EAAE;IAC5BP,KAAK,CAACO,iBAAiB,CAACH,UAAU,EAAEF,gBAAgB,CAAC;EACtD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACAE,UAAU,CAACI,KAAK,GAAGL,KAAK;EACxB;EACA,OAAOC,UAAU;AAClB"}
@@ -5,6 +5,7 @@
5
5
  // both creating a new worker and sending data back and forth.
6
6
  //
7
7
  import { unzip } from 'fflate';
8
+ import { createUnzipError } from './UnzipError.js';
8
9
 
9
10
  /**
10
11
  * Reads `*.zip` file contents. Ignores anything besides `.xml` or `.xml.rels` files.
@@ -20,7 +21,7 @@ export default function unzipFromArrayBuffer(input, options) {
20
21
  * @param {ArrayBuffer} input
21
22
  * @param {(ArrayBuffer) => Record<string, Uint8Array> | Promise<Record<string, Uint8Array>>} unzip
22
23
  * @param {boolean} isAsync — Should be `true` when `unzip()` returns a `Promise`, `false` otherwise.
23
- * @return {Promise<Record<string,Uint8Array>>|Record<string,Uint8Array>} Resolves to an object holding `*.zip` file entries.
24
+ * @return {Promise<Record<string,Uint8Array>> | Record<string,Uint8Array>} Resolves to an object holding `*.zip` file entries.
24
25
  */
25
26
  export function unzipFromArrayBufferUsingFunction(input) {
26
27
  var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
@@ -39,6 +40,15 @@ export function unzipFromArrayBufferUsingFunction(input) {
39
40
  }
40
41
  return true;
41
42
  }
43
+ }).then(function (result) {
44
+ return result;
45
+ }, function (error) {
46
+ // If `fflate` throws its specific error then it implies that the `.zip` file is not valid.
47
+ if (isFlateError(error)) {
48
+ throw createUnzipError(error);
49
+ } else {
50
+ throw error;
51
+ }
42
52
  });
43
53
  }
44
54
  function unzipAsync(archive) {
@@ -55,4 +65,14 @@ function unzipAsync(archive) {
55
65
  });
56
66
  });
57
67
  }
68
+
69
+ // This function attempts to guess if a given `error` was thrown by `fflate`.
70
+ function isFlateError(error) {
71
+ // `fflate` doesn't export a `FlateError` class.
72
+ // https://github.com/101arrowz/fflate/issues/290
73
+ // return error instanceof FlateError
74
+
75
+ // Here, it attempts to guess if an `error` is a `FlateError` by checking if `error.code` is a `number`.
76
+ return typeof error.code === 'number';
77
+ }
58
78
  //# sourceMappingURL=unzipFromArrayBuffer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"unzipFromArrayBuffer.js","names":["unzip","unzipFromArrayBuffer","input","options","unzipFromArrayBufferUsingFunction","unzipAsync","_ref","arguments","length","undefined","filter","isAsync","Uint8Array","file","path","name","archive","Promise","resolve","reject","error","files"],"sources":["../../source/zip/unzipFromArrayBuffer.js"],"sourcesContent":["// `fflate` uses \"synchronous\" decompressor on `.zip` files that're under `512KB`\r\n// (or when the compression level is too low), and an \"asynchronous\" (web worker)\r\n// decompressor otherwise, as it can be seen from the source code of the `unzip()` function.\r\n// This is because using web workers comes with an overhead of\r\n// both creating a new worker and sending data back and forth.\r\n//\r\nimport { unzip } from 'fflate'\r\n\r\n/**\r\n * Reads `*.zip` file contents. Ignores anything besides `.xml` or `.xml.rels` files.\r\n * @param {ArrayBuffer} input\r\n * @return {Promise<Record<string,Uint8Array>>} Resolves to an object holding `*.zip` file entries.\r\n */\r\nexport default function unzipFromArrayBuffer(input, options) {\r\n\treturn unzipFromArrayBufferUsingFunction(input, options, unzipAsync, true)\r\n}\r\n\r\n/**\r\n * Reads `*.zip` file contents. Ignores anything besides `.xml` or `.xml.rels` files.\r\n * @param {ArrayBuffer} input\r\n * @param {(ArrayBuffer) => Record<string, Uint8Array> | Promise<Record<string, Uint8Array>>} unzip\r\n * @param {boolean} isAsync — Should be `true` when `unzip()` returns a `Promise`, `false` otherwise.\r\n * @return {Promise<Record<string,Uint8Array>>|Record<string,Uint8Array>} Resolves to an object holding `*.zip` file entries.\r\n */\r\nexport function unzipFromArrayBufferUsingFunction(input, { filter } = {}, unzip, isAsync) {\r\n\t// Read the `.zip` archive.\r\n\t// `result` is either `object` or `Promise<object>`\r\n\treturn unzip(new Uint8Array(input), {\r\n\t\t// Ignore certain types of files.\r\n\t\tfilter: (file) => {\r\n\t\t\tif (filter) {\r\n\t\t\t\treturn filter({\r\n\t\t\t\t\tpath: file.name\r\n\t\t\t\t})\r\n\t\t\t}\r\n\t\t\treturn true\r\n\t\t}\r\n\t})\r\n}\r\n\r\nfunction unzipAsync(archive) {\r\n return new Promise((resolve, reject) => {\r\n\t\t// `unzip()` will resort to \"synchronous\" decompression in two edge cases:\r\n // * When the archive size is less than `512KB`.\r\n // * When the data is barely compressed, i.e. the compression ratio is less than 20% reduction in size.\r\n unzip(archive, (error, files) => {\r\n if (error) {\r\n reject(error)\r\n } else {\r\n resolve(files)\r\n }\r\n })\r\n })\r\n}"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,KAAK,QAAQ,QAAQ;;AAE9B;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,oBAAoBA,CAACC,KAAK,EAAEC,OAAO,EAAE;EAC5D,OAAOC,iCAAiC,CAACF,KAAK,EAAEC,OAAO,EAAEE,UAAU,EAAE,IAAI,CAAC;AAC3E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASD,iCAAiCA,CAACF,KAAK,EAAmC;EAAA,IAAAI,IAAA,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAApB,CAAC,CAAC;IAAbG,OAAM,GAAAJ,IAAA,CAANI,MAAM;EAAA,IAASV,KAAK,GAAAO,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAAA,IAAEE,OAAO,GAAAJ,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EACvF;EACA;EACA,OAAOT,KAAK,CAAC,IAAIY,UAAU,CAACV,KAAK,CAAC,EAAE;IACnC;IACAQ,MAAM,EAAE,SAAAA,OAACG,IAAI,EAAK;MACjB,IAAIH,OAAM,EAAE;QACX,OAAOA,OAAM,CAAC;UACbI,IAAI,EAAED,IAAI,CAACE;QACZ,CAAC,CAAC;MACH;MACA,OAAO,IAAI;IACZ;EACD,CAAC,CAAC;AACH;AAEA,SAASV,UAAUA,CAACW,OAAO,EAAE;EAC3B,OAAO,IAAIC,OAAO,CAAC,UAACC,OAAO,EAAEC,MAAM,EAAK;IACxC;IACE;IACA;IACAnB,KAAK,CAACgB,OAAO,EAAE,UAACI,KAAK,EAAEC,KAAK,EAAK;MAC/B,IAAID,KAAK,EAAE;QACTD,MAAM,CAACC,KAAK,CAAC;MACf,CAAC,MAAM;QACLF,OAAO,CAACG,KAAK,CAAC;MAChB;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ"}
1
+ {"version":3,"file":"unzipFromArrayBuffer.js","names":["unzip","createUnzipError","unzipFromArrayBuffer","input","options","unzipFromArrayBufferUsingFunction","unzipAsync","_ref","arguments","length","undefined","filter","isAsync","Uint8Array","file","path","name","then","result","error","isFlateError","archive","Promise","resolve","reject","files","code"],"sources":["../../source/zip/unzipFromArrayBuffer.js"],"sourcesContent":["// `fflate` uses \"synchronous\" decompressor on `.zip` files that're under `512KB`\r\n// (or when the compression level is too low), and an \"asynchronous\" (web worker)\r\n// decompressor otherwise, as it can be seen from the source code of the `unzip()` function.\r\n// This is because using web workers comes with an overhead of\r\n// both creating a new worker and sending data back and forth.\r\n//\r\nimport { unzip } from 'fflate'\r\n\r\nimport { createUnzipError } from './UnzipError.js'\r\n\r\n/**\r\n * Reads `*.zip` file contents. Ignores anything besides `.xml` or `.xml.rels` files.\r\n * @param {ArrayBuffer} input\r\n * @return {Promise<Record<string,Uint8Array>>} Resolves to an object holding `*.zip` file entries.\r\n */\r\nexport default function unzipFromArrayBuffer(input, options) {\r\n\treturn unzipFromArrayBufferUsingFunction(input, options, unzipAsync, true)\r\n}\r\n\r\n/**\r\n * Reads `*.zip` file contents. Ignores anything besides `.xml` or `.xml.rels` files.\r\n * @param {ArrayBuffer} input\r\n * @param {(ArrayBuffer) => Record<string, Uint8Array> | Promise<Record<string, Uint8Array>>} unzip\r\n * @param {boolean} isAsync — Should be `true` when `unzip()` returns a `Promise`, `false` otherwise.\r\n * @return {Promise<Record<string,Uint8Array>> | Record<string,Uint8Array>} Resolves to an object holding `*.zip` file entries.\r\n */\r\nexport function unzipFromArrayBufferUsingFunction(input, { filter } = {}, unzip, isAsync) {\r\n\t// Read the `.zip` archive.\r\n\t// `result` is either `object` or `Promise<object>`\r\n\treturn unzip(new Uint8Array(input), {\r\n\t\t// Ignore certain types of files.\r\n\t\tfilter: (file) => {\r\n\t\t\tif (filter) {\r\n\t\t\t\treturn filter({\r\n\t\t\t\t\tpath: file.name\r\n\t\t\t\t})\r\n\t\t\t}\r\n\t\t\treturn true\r\n\t\t}\r\n\t}).then(\r\n\t\tresult => result,\r\n\t\t(error) => {\r\n\t\t\t// If `fflate` throws its specific error then it implies that the `.zip` file is not valid.\r\n\t\t\tif (isFlateError(error)) {\r\n\t\t\t\tthrow createUnzipError(error)\r\n\t\t\t} else {\r\n\t\t\t\tthrow error\r\n\t\t\t}\r\n\t\t}\r\n\t)\r\n}\r\n\r\nfunction unzipAsync(archive) {\r\n return new Promise((resolve, reject) => {\r\n\t\t// `unzip()` will resort to \"synchronous\" decompression in two edge cases:\r\n // * When the archive size is less than `512KB`.\r\n // * When the data is barely compressed, i.e. the compression ratio is less than 20% reduction in size.\r\n unzip(archive, (error, files) => {\r\n if (error) {\r\n reject(error)\r\n } else {\r\n resolve(files)\r\n }\r\n })\r\n })\r\n}\r\n\r\n// This function attempts to guess if a given `error` was thrown by `fflate`.\r\nfunction isFlateError(error) {\r\n\t// `fflate` doesn't export a `FlateError` class.\r\n\t// https://github.com/101arrowz/fflate/issues/290\r\n\t// return error instanceof FlateError\r\n\r\n\t// Here, it attempts to guess if an `error` is a `FlateError` by checking if `error.code` is a `number`.\r\n\treturn typeof error.code === 'number'\r\n}\r\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,KAAK,QAAQ,QAAQ;AAE9B,SAASC,gBAAgB,QAAQ,iBAAiB;;AAElD;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,oBAAoBA,CAACC,KAAK,EAAEC,OAAO,EAAE;EAC5D,OAAOC,iCAAiC,CAACF,KAAK,EAAEC,OAAO,EAAEE,UAAU,EAAE,IAAI,CAAC;AAC3E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASD,iCAAiCA,CAACF,KAAK,EAAmC;EAAA,IAAAI,IAAA,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAApB,CAAC,CAAC;IAAbG,OAAM,GAAAJ,IAAA,CAANI,MAAM;EAAA,IAASX,KAAK,GAAAQ,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAAA,IAAEE,OAAO,GAAAJ,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EACvF;EACA;EACA,OAAOV,KAAK,CAAC,IAAIa,UAAU,CAACV,KAAK,CAAC,EAAE;IACnC;IACAQ,MAAM,EAAE,SAAAA,OAACG,IAAI,EAAK;MACjB,IAAIH,OAAM,EAAE;QACX,OAAOA,OAAM,CAAC;UACbI,IAAI,EAAED,IAAI,CAACE;QACZ,CAAC,CAAC;MACH;MACA,OAAO,IAAI;IACZ;EACD,CAAC,CAAC,CAACC,IAAI,CACN,UAAAC,MAAM;IAAA,OAAIA,MAAM;EAAA,GAChB,UAACC,KAAK,EAAK;IACV;IACA,IAAIC,YAAY,CAACD,KAAK,CAAC,EAAE;MACxB,MAAMlB,gBAAgB,CAACkB,KAAK,CAAC;IAC9B,CAAC,MAAM;MACN,MAAMA,KAAK;IACZ;EACD,CACD,CAAC;AACF;AAEA,SAASb,UAAUA,CAACe,OAAO,EAAE;EAC3B,OAAO,IAAIC,OAAO,CAAC,UAACC,OAAO,EAAEC,MAAM,EAAK;IACxC;IACE;IACA;IACAxB,KAAK,CAACqB,OAAO,EAAE,UAACF,KAAK,EAAEM,KAAK,EAAK;MAC/B,IAAIN,KAAK,EAAE;QACTK,MAAM,CAACL,KAAK,CAAC;MACf,CAAC,MAAM;QACLI,OAAO,CAACE,KAAK,CAAC;MAChB;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ;;AAEA;AACA,SAASL,YAAYA,CAACD,KAAK,EAAE;EAC5B;EACA;EACA;;EAEA;EACA,OAAO,OAAOA,KAAK,CAACO,IAAI,KAAK,QAAQ;AACtC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unzipFromArrayBuffer.test.js","names":["_regeneratorRuntime","e","t","r","Object","prototype","n","hasOwnProperty","o","defineProperty","value","i","Symbol","a","iterator","c","asyncIterator","u","toStringTag","define","enumerable","configurable","writable","wrap","Generator","create","Context","makeInvokeMethod","tryCatch","type","arg","call","h","l","f","s","y","GeneratorFunction","GeneratorFunctionPrototype","p","d","getPrototypeOf","v","values","g","defineIteratorMethods","forEach","_invoke","AsyncIterator","invoke","_typeof","resolve","__await","then","callInvokeWithMethodAndArg","Error","done","method","delegate","maybeInvokeDelegate","sent","_sent","dispatchException","abrupt","TypeError","resultName","next","nextLoc","pushTryEntry","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","push","resetTryEntry","completion","reset","isNaN","length","displayName","isGeneratorFunction","constructor","name","mark","setPrototypeOf","__proto__","awrap","async","Promise","keys","reverse","pop","prev","charAt","slice","stop","rval","handle","complete","finish","_catch","delegateYield","asyncGeneratorStep","gen","reject","_next","_throw","key","info","error","_asyncToGenerator","fn","self","args","arguments","apply","err","undefined","describe","it","expect","zipSync","strToU8","unzipFromArrayBuffer","_callee","zip","files","_callee$","_context","to","deep","equal"],"sources":["../../source/zip/unzipFromArrayBuffer.test.js"],"sourcesContent":["import { describe, it } from 'mocha'\r\nimport { expect } from 'chai'\r\n\r\nimport { zipSync, strToU8 } from 'fflate'\r\n\r\nimport unzipFromArrayBuffer from './unzipFromArrayBuffer.js'\r\n\r\ndescribe('unzipFromArrayBuffer', () => {\r\n\tit('should read a `.zip` archive', async () => {\r\n\t\tconst zip = zipSync({ 'a.xml': strToU8('<a/>') })\r\n\t\tconst files = await unzipFromArrayBuffer(zip)\r\n\t\texpect(Object.keys(files)).to.deep.equal(['a.xml'])\r\n\t})\r\n})"],"mappings":";+CACA,qJAAAA,mBAAA,YAAAA,oBAAA,WAAAC,CAAA,SAAAC,CAAA,EAAAD,CAAA,OAAAE,CAAA,GAAAC,MAAA,CAAAC,SAAA,EAAAC,CAAA,GAAAH,CAAA,CAAAI,cAAA,EAAAC,CAAA,GAAAJ,MAAA,CAAAK,cAAA,cAAAP,CAAA,EAAAD,CAAA,EAAAE,CAAA,IAAAD,CAAA,CAAAD,CAAA,IAAAE,CAAA,CAAAO,KAAA,KAAAC,CAAA,wBAAAC,MAAA,GAAAA,MAAA,OAAAC,CAAA,GAAAF,CAAA,CAAAG,QAAA,kBAAAC,CAAA,GAAAJ,CAAA,CAAAK,aAAA,uBAAAC,CAAA,GAAAN,CAAA,CAAAO,WAAA,8BAAAC,OAAAjB,CAAA,EAAAD,CAAA,EAAAE,CAAA,WAAAC,MAAA,CAAAK,cAAA,CAAAP,CAAA,EAAAD,CAAA,IAAAS,KAAA,EAAAP,CAAA,EAAAiB,UAAA,MAAAC,YAAA,MAAAC,QAAA,SAAAp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