@silurus/ooxml 0.58.0 → 0.59.0
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 +41 -1
- package/dist/docx-MHQa7gm7.js +1911 -0
- package/dist/docx.mjs +2 -2
- package/dist/index.mjs +3 -3
- package/dist/{pptx-B6H-We19.js → pptx-BiatvxSp.js} +781 -676
- package/dist/pptx.mjs +2 -2
- package/dist/render-worker-host-D7EpeMT0.js +27 -0
- package/dist/render-worker-host-DcreJHMg.js +27 -0
- package/dist/render-worker-host-Dg-fxkvs.js +27 -0
- package/dist/{src-B06n2_Dm.js → src-Csbp6xwR.js} +763 -644
- package/dist/types/docx.d.ts +38 -0
- package/dist/types/index.d.ts +130 -10
- package/dist/types/pptx.d.ts +38 -4
- package/dist/types/xlsx.d.ts +51 -6
- package/dist/{xlsx-DWmV5sAA.js → xlsx-BcQbbV_c.js} +877 -815
- package/dist/xlsx.mjs +2 -2
- package/package.json +1 -1
- package/dist/docx-BBTq20zc.js +0 -1811
package/README.md
CHANGED
|
@@ -86,6 +86,46 @@ per-render argument. (Excel stores "Insert > Equation" as OMML inside the shared
|
|
|
86
86
|
DrawingML `<xdr:txBody>` grammar, so `XlsxViewer` renders equations embedded in
|
|
87
87
|
shapes / text boxes the same way.)
|
|
88
88
|
|
|
89
|
+
### Off-main-thread rendering
|
|
90
|
+
|
|
91
|
+
By default the headless engines parse in a worker but render on the main thread.
|
|
92
|
+
Pass `mode: 'worker'` to `.load()` to parse **and** render entirely inside a Web
|
|
93
|
+
Worker — the main thread only paints the returned `ImageBitmap` via a
|
|
94
|
+
`bitmaprenderer` context, keeping it free for scrolling and input. It requires
|
|
95
|
+
`Worker` + `OffscreenCanvas`.
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
import { PptxPresentation } from '@silurus/ooxml/pptx';
|
|
99
|
+
|
|
100
|
+
// Render entirely inside a Web Worker — the main thread only paints bitmaps.
|
|
101
|
+
const pres = await PptxPresentation.load('/deck.pptx', { mode: 'worker' });
|
|
102
|
+
const canvas = document.getElementById('pptx-canvas') as HTMLCanvasElement;
|
|
103
|
+
const bitmap = await pres.renderSlideToBitmap(0, { width: 960, dpr: window.devicePixelRatio });
|
|
104
|
+
const ctx = canvas.getContext('bitmaprenderer') as ImageBitmapRenderingContext;
|
|
105
|
+
ctx.transferFromImageBitmap(bitmap); // consumes the bitmap
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
The `*ToBitmap` method exists on all three engines —
|
|
109
|
+
`PptxPresentation.renderSlideToBitmap(slideIndex, opts)`,
|
|
110
|
+
`DocxDocument.renderPageToBitmap(pageIndex, opts)`, and
|
|
111
|
+
`XlsxWorkbook.renderViewportToBitmap(sheetIndex, viewport, opts)` (the xlsx
|
|
112
|
+
variant **requires** `opts.width` and `opts.height`, since a worker has no DOM
|
|
113
|
+
element to measure). They work in **both** modes — in main mode they render to
|
|
114
|
+
an internal `OffscreenCanvas` — so you can write mode-agnostic code.
|
|
115
|
+
|
|
116
|
+
Notes:
|
|
117
|
+
|
|
118
|
+
- The returned `ImageBitmap` is owned by the caller: `transferFromImageBitmap`
|
|
119
|
+
consumes it, or call `bitmap.close()` when done.
|
|
120
|
+
- The canvas-target methods (`renderSlide(canvas)`, `renderPage(canvas)`,
|
|
121
|
+
`renderViewport(canvas)`) are unavailable in worker mode — use the `*ToBitmap`
|
|
122
|
+
variants instead.
|
|
123
|
+
- OMML equations require `mode: 'main'`; in worker mode they are skipped (with a
|
|
124
|
+
console warning).
|
|
125
|
+
- Trade-off: worker mode keeps the main thread responsive, but each frame is
|
|
126
|
+
transferred back as an `ImageBitmap`, so a single render can be marginally
|
|
127
|
+
slower than `mode: 'main'`. Choose it for non-blocking UI, not raw speed.
|
|
128
|
+
|
|
89
129
|
---
|
|
90
130
|
|
|
91
131
|
<details>
|
|
@@ -617,7 +657,7 @@ cd packages/pptx/parser && wasm-pack build --target web && cp pkg/pptx_parser_bg
|
|
|
617
657
|
new PptxViewer(canvas, { maxZipEntryBytes: 64 * 1024 * 1024 }); // 64 MiB
|
|
618
658
|
```
|
|
619
659
|
Supported uniformly by `DocxViewer`, `PptxViewer`, and `XlsxViewer`. Zero / negative values fall back to the default.
|
|
620
|
-
- **No network by default.** The library does not send telemetry or analytics, and does not contact third-party services unless you ask it to. In particular, theme webfonts
|
|
660
|
+
- **No network by default.** The library does not send telemetry or analytics, and does not contact third-party services unless you ask it to. In particular, theme webfonts, Office font metric substitutes (Carlito/Caladea), and the script fallback fonts are **not** loaded from Google Fonts unless you pass `useGoogleFonts: true` to the relevant `Viewer` / `load(...)` options — supported uniformly by `DocxViewer`, `PptxViewer`, and `XlsxViewer`. When enabled, fonts for non-Latin scripts are supplied on demand from Noto families so text does not fall back to tofu: Arabic (Noto Naskh/Sans Arabic), CJK (Noto Sans/Serif KR · SC · TC · JP, picked per document language so shared Han glyphs take the right shapes), Cyrillic (Noto Sans/Serif), Hebrew (Noto Sans/Serif Hebrew, RTL), Thai (Noto Sans Thai) and Devanagari (Noto Sans Devanagari). No font binaries ship in the bundle. Enabling this option causes the end-user's browser to send an HTTP request (IP and User-Agent) to `fonts.googleapis.com`, which may have GDPR implications for your application — consider self-hosting the required fonts via `@font-face` instead.
|
|
621
661
|
- **XML parsing.** Uses `roxmltree`, which does not resolve external entities (XXE-safe by default).
|
|
622
662
|
|
|
623
663
|
## License
|