@silurus/ooxml 0.70.0 → 0.70.2
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 +44 -6
- package/dist/{docx-DkL5ADAb.js → docx-BKsYFx78.js} +2 -1
- package/dist/docx.mjs +1 -1
- package/dist/index.mjs +3 -3
- package/dist/math.mjs +1 -1
- package/dist/{pptx-BU8N1QPE.js → pptx-B4xa92BQ.js} +2 -1
- package/dist/pptx.mjs +1 -1
- package/dist/{xlsx-CCmtIDr_.js → xlsx-B1XUgnO7.js} +1 -1
- package/dist/xlsx.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,11 +29,23 @@ pnpm add @silurus/ooxml
|
|
|
29
29
|
|
|
30
30
|
> **Bundler note**: the Rust parsers ship as real `.wasm` asset files next to the
|
|
31
31
|
> JavaScript, referenced with the standard `new URL('…', import.meta.url)` form
|
|
32
|
-
> and fetched (streaming-compiled) at load time.
|
|
33
|
-
>
|
|
34
|
-
>
|
|
35
|
-
>
|
|
36
|
-
>
|
|
32
|
+
> and fetched (streaming-compiled) at load time. Verified to work with zero
|
|
33
|
+
> config: **webpack 5**, **Next.js** (Turbopack, dev and build), **Vite 8**
|
|
34
|
+
> (dev and build), **Vite 7 production builds**, and a plain
|
|
35
|
+
> `<script type="module">` with no bundler at all. Two setups need a hand:
|
|
36
|
+
>
|
|
37
|
+
> - **Vite 7 dev server**: the dependency optimizer rewrites the asset reference
|
|
38
|
+
> into its own cache path and the load fails (fixed in Vite 8). Add
|
|
39
|
+
> `optimizeDeps: { exclude: ['@silurus/ooxml'] }` to your `vite.config` —
|
|
40
|
+
> production builds are unaffected.
|
|
41
|
+
> - **esbuild / Angular CLI** (whose application builder is esbuild-based):
|
|
42
|
+
> `new URL` asset references are not processed
|
|
43
|
+
> ([esbuild#795](https://github.com/evanw/esbuild/issues/795)). Copy the
|
|
44
|
+
> `.wasm` into your served output and point the viewer at it with the
|
|
45
|
+
> `wasmUrl` load option — see the [Angular example](#framework-examples) for
|
|
46
|
+
> the two-step setup.
|
|
47
|
+
>
|
|
48
|
+
> `wasmUrl` also serves the parser WASM from a CDN or any path you control:
|
|
37
49
|
>
|
|
38
50
|
> ```typescript
|
|
39
51
|
> new DocxViewer(canvas, { wasmUrl: 'https://cdn.example.com/docx_parser_bg.wasm' });
|
|
@@ -376,6 +388,28 @@ onMounted(async () => {
|
|
|
376
388
|
<details>
|
|
377
389
|
<summary><strong>Angular 19</strong></summary>
|
|
378
390
|
|
|
391
|
+
The Angular CLI's esbuild-based builder does not process the `new URL('…', import.meta.url)`
|
|
392
|
+
asset reference the parsers use ([angular-cli#22388](https://github.com/angular/angular-cli/issues/22388)),
|
|
393
|
+
so the `.wasm` never reaches the build output — and under `ng serve` the dependency
|
|
394
|
+
optimizer additionally rewrites the reference into its own cache path. **Both steps
|
|
395
|
+
below are required** (the asset copy alone fixes only production builds; `ng serve`
|
|
396
|
+
still 404s without `wasmUrl`):
|
|
397
|
+
|
|
398
|
+
```jsonc
|
|
399
|
+
// angular.json — copy the parser WASM into the served root
|
|
400
|
+
// (restart `ng serve` after editing this file)
|
|
401
|
+
"architect": {
|
|
402
|
+
"build": {
|
|
403
|
+
"options": {
|
|
404
|
+
"assets": [
|
|
405
|
+
{ "glob": "*_parser_bg.wasm", "input": "node_modules/@silurus/ooxml/dist", "output": "/" },
|
|
406
|
+
{ "glob": "**/*", "input": "public" }
|
|
407
|
+
]
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
```
|
|
412
|
+
|
|
379
413
|
```typescript
|
|
380
414
|
// Angular 19 — standalone component with signal-based state
|
|
381
415
|
import {
|
|
@@ -404,6 +438,7 @@ export class PptxViewerComponent implements AfterViewInit {
|
|
|
404
438
|
|
|
405
439
|
ngAfterViewInit(): void {
|
|
406
440
|
this.viewer = new PptxViewer(this.canvasEl().nativeElement, {
|
|
441
|
+
wasmUrl: '/pptx_parser_bg.wasm',
|
|
407
442
|
onSlideChange: (i, t) => { this.current.set(i); this.total.set(t); },
|
|
408
443
|
});
|
|
409
444
|
this.viewer.load('/deck.pptx');
|
|
@@ -414,7 +449,10 @@ export class PptxViewerComponent implements AfterViewInit {
|
|
|
414
449
|
}
|
|
415
450
|
```
|
|
416
451
|
|
|
417
|
-
>
|
|
452
|
+
> The `*_parser_bg.wasm` glob copies all three parsers; narrow it to
|
|
453
|
+
> `pptx_parser_bg.wasm` if you only use one format. If you deploy under a
|
|
454
|
+
> non-root `base href`, adjust `wasmUrl` so it resolves under your base (a
|
|
455
|
+
> relative `wasmUrl` is resolved against the document URL).
|
|
418
456
|
|
|
419
457
|
</details>
|
|
420
458
|
|
|
@@ -44,7 +44,7 @@ function ue(e) {
|
|
|
44
44
|
}
|
|
45
45
|
//#endregion
|
|
46
46
|
//#region packages/docx/src/wasm/docx_parser_bg.wasm?url
|
|
47
|
-
var de = new URL(
|
|
47
|
+
var de = new URL("docx_parser_bg.wasm", import.meta.url).href, fe = (e) => {
|
|
48
48
|
let t = e.text;
|
|
49
49
|
return typeof t == "string" ? t : void 0;
|
|
50
50
|
}, pe = (e) => e.rtl === !0, me = (e) => e.digitsAsAN === !0;
|
|
@@ -3549,6 +3549,7 @@ var ii = class {
|
|
|
3549
3549
|
_lastFitWidth = 0;
|
|
3550
3550
|
_pageShadow;
|
|
3551
3551
|
constructor(e, t = {}) {
|
|
3552
|
+
if (e.tagName === "CANVAS") throw Error("DocxScrollViewer takes a container element (e.g. a <div>), not a <canvas> — the viewer creates and manages its own canvases. Pass a block container; for the single-page canvas API use DocxViewer.");
|
|
3552
3553
|
if (this._container = e, this._opts = t, this._pageShadow = t.pageShadow ?? oi, this._injected = !!t.document, this._injected) {
|
|
3553
3554
|
let e = t.document;
|
|
3554
3555
|
if (t.mode !== void 0 && t.mode !== e.mode) throw Error(`DocxScrollViewer: opts.mode='${t.mode}' conflicts with the injected engine's mode='${e.mode}'. Omit opts.mode when injecting an engine — the engine owns its render mode.`);
|
package/dist/docx.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { k as e } from "./line-metrics-DG9p1RvA.js";
|
|
2
|
-
import { a as t, i as n, n as r, o as i, r as a } from "./docx-
|
|
2
|
+
import { a as t, i as n, n as r, o as i, r as a } from "./docx-BKsYFx78.js";
|
|
3
3
|
export { i as DocxDocument, a as DocxScrollViewer, n as DocxViewer, e as autoResize, t as buildDocxTextLayer, r as noteText };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "./pptx-
|
|
2
|
-
import { t } from "./xlsx-
|
|
3
|
-
import { t as n } from "./docx-
|
|
1
|
+
import { t as e } from "./pptx-B4xa92BQ.js";
|
|
2
|
+
import { t } from "./xlsx-B1XUgnO7.js";
|
|
3
|
+
import { t as n } from "./docx-BKsYFx78.js";
|
|
4
4
|
export { n as docx, e as pptx, t as xlsx };
|
package/dist/math.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as e } from "./mathjax-BRfWlbSJ.js";
|
|
2
2
|
//#region packages/core/assets/mathjax-stix2.js?url
|
|
3
|
-
var t = new URL(
|
|
3
|
+
var t = new URL("mathjax-stix2.js", import.meta.url).href, n = null;
|
|
4
4
|
function r() {
|
|
5
5
|
return new URL(t, import.meta.url).href;
|
|
6
6
|
}
|
|
@@ -2661,7 +2661,7 @@ function sr(e) {
|
|
|
2661
2661
|
}
|
|
2662
2662
|
//#endregion
|
|
2663
2663
|
//#region packages/pptx/src/wasm/pptx_parser_bg.wasm?url
|
|
2664
|
-
var cr = new URL(
|
|
2664
|
+
var cr = new URL("pptx_parser_bg.wasm", import.meta.url).href, lr = class e {
|
|
2665
2665
|
_worker;
|
|
2666
2666
|
_bridge;
|
|
2667
2667
|
_mode = "main";
|
|
@@ -3007,6 +3007,7 @@ var cr = new URL(new URL("pptx_parser_bg.wasm", import.meta.url).href, import.me
|
|
|
3007
3007
|
_lastFitWidth = 0;
|
|
3008
3008
|
_pageShadow;
|
|
3009
3009
|
constructor(e, t = {}) {
|
|
3010
|
+
if (e.tagName === "CANVAS") throw Error("PptxScrollViewer takes a container element (e.g. a <div>), not a <canvas> — the viewer creates and manages its own canvases. Pass a block container; for the single-slide canvas API use PptxViewer.");
|
|
3010
3011
|
if (this._container = e, this._opts = t, this._pageShadow = t.pageShadow ?? pr, this._injected = !!t.presentation, this._injected) {
|
|
3011
3012
|
let e = t.presentation;
|
|
3012
3013
|
if (t.mode !== void 0 && t.mode !== e.mode) throw Error(`PptxScrollViewer: opts.mode='${t.mode}' conflicts with the injected engine's mode='${e.mode}'. Omit opts.mode when injecting an engine — the engine owns its render mode.`);
|
package/dist/pptx.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { k as e } from "./line-metrics-DG9p1RvA.js";
|
|
2
|
-
import { a as t, i as n, n as r, o as i, r as a } from "./pptx-
|
|
2
|
+
import { a as t, i as n, n as r, o as i, r as a } from "./pptx-B4xa92BQ.js";
|
|
3
3
|
export { n as PptxPresentation, r as PptxScrollViewer, a as PptxViewer, e as autoResize, i as buildPptxTextLayer, t as renderSlide };
|
|
@@ -108,7 +108,7 @@ function ae(e) {
|
|
|
108
108
|
}
|
|
109
109
|
//#endregion
|
|
110
110
|
//#region packages/xlsx/src/wasm/xlsx_parser_bg.wasm?url
|
|
111
|
-
var oe = new URL(
|
|
111
|
+
var oe = new URL("xlsx_parser_bg.wasm", import.meta.url).href;
|
|
112
112
|
//#endregion
|
|
113
113
|
//#region packages/xlsx/src/sheet-visibility.ts
|
|
114
114
|
function se(e, t) {
|
package/dist/xlsx.mjs
CHANGED
package/package.json
CHANGED