@silurus/ooxml 0.70.0 → 0.70.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
|
@@ -29,11 +29,15 @@ 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. Vite, webpack 5, Rollup
|
|
33
|
-
>
|
|
34
|
-
>
|
|
35
|
-
>
|
|
36
|
-
>
|
|
32
|
+
> and fetched (streaming-compiled) at load time. Vite, webpack 5, Rollup and
|
|
33
|
+
> Parcel detect that reference and copy the asset automatically — no extra
|
|
34
|
+
> WebAssembly plugin is required. esbuild and the Angular CLI (whose application
|
|
35
|
+
> builder is esbuild-based) do **not** process that reference
|
|
36
|
+
> ([esbuild#795](https://github.com/evanw/esbuild/issues/795)): copy the `.wasm`
|
|
37
|
+
> into your served output yourself and point the viewer at it with the `wasmUrl`
|
|
38
|
+
> load option — see the [Angular example](#framework-examples) for the two-step
|
|
39
|
+
> setup. `wasmUrl` also serves the parser WASM from a CDN or any path you
|
|
40
|
+
> control:
|
|
37
41
|
>
|
|
38
42
|
> ```typescript
|
|
39
43
|
> new DocxViewer(canvas, { wasmUrl: 'https://cdn.example.com/docx_parser_bg.wasm' });
|
|
@@ -376,6 +380,28 @@ onMounted(async () => {
|
|
|
376
380
|
<details>
|
|
377
381
|
<summary><strong>Angular 19</strong></summary>
|
|
378
382
|
|
|
383
|
+
The Angular CLI's esbuild-based builder does not process the `new URL('…', import.meta.url)`
|
|
384
|
+
asset reference the parsers use ([angular-cli#22388](https://github.com/angular/angular-cli/issues/22388)),
|
|
385
|
+
so the `.wasm` never reaches the build output — and under `ng serve` the dependency
|
|
386
|
+
optimizer additionally rewrites the reference into its own cache path. **Both steps
|
|
387
|
+
below are required** (the asset copy alone fixes only production builds; `ng serve`
|
|
388
|
+
still 404s without `wasmUrl`):
|
|
389
|
+
|
|
390
|
+
```jsonc
|
|
391
|
+
// angular.json — copy the parser WASM into the served root
|
|
392
|
+
// (restart `ng serve` after editing this file)
|
|
393
|
+
"architect": {
|
|
394
|
+
"build": {
|
|
395
|
+
"options": {
|
|
396
|
+
"assets": [
|
|
397
|
+
{ "glob": "*_parser_bg.wasm", "input": "node_modules/@silurus/ooxml/dist", "output": "/" },
|
|
398
|
+
{ "glob": "**/*", "input": "public" }
|
|
399
|
+
]
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
```
|
|
404
|
+
|
|
379
405
|
```typescript
|
|
380
406
|
// Angular 19 — standalone component with signal-based state
|
|
381
407
|
import {
|
|
@@ -404,6 +430,7 @@ export class PptxViewerComponent implements AfterViewInit {
|
|
|
404
430
|
|
|
405
431
|
ngAfterViewInit(): void {
|
|
406
432
|
this.viewer = new PptxViewer(this.canvasEl().nativeElement, {
|
|
433
|
+
wasmUrl: '/pptx_parser_bg.wasm',
|
|
407
434
|
onSlideChange: (i, t) => { this.current.set(i); this.total.set(t); },
|
|
408
435
|
});
|
|
409
436
|
this.viewer.load('/deck.pptx');
|
|
@@ -414,7 +441,10 @@ export class PptxViewerComponent implements AfterViewInit {
|
|
|
414
441
|
}
|
|
415
442
|
```
|
|
416
443
|
|
|
417
|
-
>
|
|
444
|
+
> The `*_parser_bg.wasm` glob copies all three parsers; narrow it to
|
|
445
|
+
> `pptx_parser_bg.wasm` if you only use one format. If you deploy under a
|
|
446
|
+
> non-root `base href`, adjust `wasmUrl` so it resolves under your base (a
|
|
447
|
+
> relative `wasmUrl` is resolved against the document URL).
|
|
418
448
|
|
|
419
449
|
</details>
|
|
420
450
|
|
|
@@ -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-BGWUAYkh.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-
|
|
1
|
+
import { t as e } from "./pptx-ECIKr-R_.js";
|
|
2
2
|
import { t } from "./xlsx-CCmtIDr_.js";
|
|
3
|
-
import { t as n } from "./docx-
|
|
3
|
+
import { t as n } from "./docx-BGWUAYkh.js";
|
|
4
4
|
export { n as docx, e as pptx, t as xlsx };
|
|
@@ -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-ECIKr-R_.js";
|
|
3
3
|
export { n as PptxPresentation, r as PptxScrollViewer, a as PptxViewer, e as autoResize, i as buildPptxTextLayer, t as renderSlide };
|
package/package.json
CHANGED