documonster 0.21.0 → 0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/README_zh.md +1 -1
- package/dist/esm/modules/excel/stream/workbook-reader.browser.js +7 -24
- package/dist/iife/documonster.archive.iife.min.js +1 -1
- package/dist/iife/documonster.csv.iife.min.js +1 -1
- package/dist/iife/documonster.draw.iife.min.js +1 -1
- package/dist/iife/documonster.excel.iife.min.js +46 -46
- package/dist/iife/documonster.formula.iife.min.js +1 -1
- package/dist/iife/documonster.markdown.iife.min.js +1 -1
- package/dist/iife/documonster.mermaid.iife.min.js +1 -1
- package/dist/iife/documonster.pdf.iife.min.js +1 -1
- package/dist/iife/documonster.stream.iife.min.js +1 -1
- package/dist/iife/documonster.word.iife.min.js +1 -1
- package/dist/iife/documonster.xml.iife.min.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -211,7 +211,7 @@ const buffer = await Workbook.toBuffer(wb);
|
|
|
211
211
|
|
|
212
212
|
```html
|
|
213
213
|
<!-- Script tag (no bundler) — one IIFE per module, each under the shared `Documonster` global -->
|
|
214
|
-
<script src="https://unpkg.com/documonster@0.21.
|
|
214
|
+
<script src="https://unpkg.com/documonster@0.21.1/dist/iife/documonster.excel.iife.min.js"></script>
|
|
215
215
|
<script>
|
|
216
216
|
const { Workbook, Cell } = Documonster.Excel;
|
|
217
217
|
const wb = Workbook.create();
|
package/README_zh.md
CHANGED
|
@@ -198,7 +198,7 @@ const buffer = await Workbook.toBuffer(wb);
|
|
|
198
198
|
|
|
199
199
|
```html
|
|
200
200
|
<!-- Script 标签(无需打包工具)— 每个模块一个 IIFE,共享同一个 `Documonster` 全局 -->
|
|
201
|
-
<script src="https://unpkg.com/documonster@0.21.
|
|
201
|
+
<script src="https://unpkg.com/documonster@0.21.1/dist/iife/documonster.excel.iife.min.js"></script>
|
|
202
202
|
<script>
|
|
203
203
|
const { Workbook, Cell } = Documonster.Excel;
|
|
204
204
|
const wb = Workbook.create();
|
|
@@ -73,7 +73,7 @@ import { MetadataXform } from "../xlsx/xform/core/metadata-xform.js";
|
|
|
73
73
|
import { RelationshipsXform } from "../xlsx/xform/core/relationships-xform.js";
|
|
74
74
|
import { parseXformStream } from "../xlsx/xform/parse-xform.js";
|
|
75
75
|
import { StylesXform } from "../xlsx/xform/style/styles-xform.js";
|
|
76
|
-
import { Readable, Transform } from "#platform/modules/stream/index";
|
|
76
|
+
import { Readable, Transform, isReadableStream, readableFromWeb } from "#platform/modules/stream/index";
|
|
77
77
|
import { EventEmitter } from "../../../utils/event-emitter.js";
|
|
78
78
|
import { assertLimitOption } from "../../../utils/limits.js";
|
|
79
79
|
import { decodeOoxmlEscape } from "#platform/utils/utils";
|
|
@@ -189,35 +189,18 @@ export class WorkbookReaderBase extends EventEmitter {
|
|
|
189
189
|
if (input instanceof Readable) {
|
|
190
190
|
return input;
|
|
191
191
|
}
|
|
192
|
-
//
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
// differ. Probe the optional members through a structural view.
|
|
199
|
-
const ReadableCtor = Readable;
|
|
200
|
-
const fromWeb = ReadableCtor.fromWeb;
|
|
201
|
-
if (typeof fromWeb === "function") {
|
|
202
|
-
return fromWeb(input);
|
|
203
|
-
}
|
|
204
|
-
// Browser wrapper supports `{ stream }` constructor option.
|
|
205
|
-
// Node's Readable does not, so this is best-effort.
|
|
206
|
-
try {
|
|
207
|
-
return new ReadableCtor({
|
|
208
|
-
stream: input
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
catch {
|
|
212
|
-
throw new ExcelFileError("<ReadableStream>", "read", "Could not recognise input");
|
|
213
|
-
}
|
|
192
|
+
// A Web ReadableStream — a fetch() body, a File's stream(). The module's
|
|
193
|
+
// adapter, not the class's `fromWeb`: it hands the lock back once the
|
|
194
|
+
// workbook has been read or the reader is abandoned, where Node's keeps
|
|
195
|
+
// it for good. It returns an instance of this entry's Readable.
|
|
196
|
+
if (isReadableStream(input)) {
|
|
197
|
+
return readableFromWeb(input);
|
|
214
198
|
}
|
|
215
199
|
let data = input;
|
|
216
200
|
if (data instanceof ArrayBuffer) {
|
|
217
201
|
data = new Uint8Array(data);
|
|
218
202
|
}
|
|
219
203
|
if (data instanceof Uint8Array) {
|
|
220
|
-
// Cross-platform: both Node's Readable and our browser Readable implement `.from()`.
|
|
221
204
|
return Readable.from([data]);
|
|
222
205
|
}
|
|
223
206
|
throw new ExcelFileError(String(input), "read", "Could not recognise input");
|