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 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.0/dist/iife/documonster.excel.iife.min.js"></script>
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.0/dist/iife/documonster.excel.iife.min.js"></script>
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
- // Accept Web ReadableStream (browser fetch() body, Node 18+ fetch(), etc.)
193
- if (input &&
194
- typeof input === "object" &&
195
- typeof input.getReader === "function") {
196
- // Cross-platform feature detection: the imported `Readable` may resolve to
197
- // either the Node or browser variant, whose static/constructor surfaces
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");
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * documonster v0.21.0
2
+ * documonster v0.21.1
3
3
  * Zero-dependency TypeScript toolkit for Excel, Word, PDF, CSV, Markdown, XML & ZIP — one API across Node.js, Bun & browsers.
4
4
  * (c) 2025 cjnoname
5
5
  * Released under the Apache-2.0 License
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * documonster v0.21.0
2
+ * documonster v0.21.1
3
3
  * Zero-dependency TypeScript toolkit for Excel, Word, PDF, CSV, Markdown, XML & ZIP — one API across Node.js, Bun & browsers.
4
4
  * (c) 2025 cjnoname
5
5
  * Released under the Apache-2.0 License
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * documonster v0.21.0
2
+ * documonster v0.21.1
3
3
  * Zero-dependency TypeScript toolkit for Excel, Word, PDF, CSV, Markdown, XML & ZIP — one API across Node.js, Bun & browsers.
4
4
  * (c) 2025 cjnoname
5
5
  * Released under the Apache-2.0 License