@silurus/ooxml 0.1.0 → 0.3.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 +18 -0
- package/dist/autoResize-U2-IRmNE.js +48 -0
- package/dist/autoResize-ggn4hzd8.cjs +1 -0
- package/dist/docx-CBTSExoH.cjs +1 -0
- package/dist/docx-DPRNEbrA.js +763 -0
- package/dist/docx.cjs +1 -1
- package/dist/docx.mjs +3 -2
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +3 -3
- package/dist/paint-C7gG2pjf.cjs +1 -0
- package/dist/paint-CIAXt08M.js +98 -0
- package/dist/pptx-BTI_RpCN.js +1392 -0
- package/dist/pptx-D-l5vpjt.cjs +1 -0
- package/dist/pptx.cjs +1 -1
- package/dist/pptx.mjs +3 -2
- package/dist/types/docx.d.ts +93 -1
- package/dist/types/index.d.ts +122 -2
- package/dist/types/pptx.d.ts +47 -1
- package/dist/types/xlsx.d.ts +25 -0
- package/dist/xlsx-BbZiHoyu.cjs +4 -0
- package/dist/xlsx-DqnFMSVb.js +1069 -0
- package/dist/xlsx.cjs +1 -1
- package/dist/xlsx.mjs +3 -2
- package/package.json +1 -1
- package/dist/chunk-BwIEoMh7.cjs +0 -1
- package/dist/chunk-DmhlhrBa.js +0 -11
- package/dist/docx-Bpx5ZIHv.js +0 -721
- package/dist/docx-CVRWUA32.cjs +0 -1
- package/dist/pptx-D3vSvVQ6.js +0 -1475
- package/dist/pptx-DrZBtOP1.cjs +0 -1
- package/dist/xlsx-B-yZ85zA.js +0 -1068
- package/dist/xlsx-BhLRc4om.cjs +0 -4
package/README.md
CHANGED
|
@@ -2,10 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
# office-open-xml-viewer
|
|
4
4
|
|
|
5
|
+
[](https://www.npmjs.com/package/@silurus/ooxml)
|
|
6
|
+
[](https://www.npmjs.com/package/@silurus/ooxml)
|
|
7
|
+
[](./LICENSE)
|
|
8
|
+
|
|
5
9
|
**[Demo (Storybook)](https://yukiyokotani.github.io/office-open-xml-viewer/)**
|
|
6
10
|
|
|
7
11
|
A browser-based viewer for Office Open XML documents that renders to an HTML Canvas element.
|
|
8
12
|
The parsers are written in Rust and compiled to WebAssembly; the renderers use the Canvas 2D API.
|
|
13
|
+
Each format also exposes a headless engine (`PptxPresentation` / `DocxDocument` / `XlsxWorkbook`) that renders into any caller-supplied canvas, so you can compose your own UI — scroll views, thumbnail grids, master-detail panes — instead of being locked into the built-in viewer. See the `Examples` section in [the Storybook demo](https://yukiyokotani.github.io/office-open-xml-viewer/).
|
|
14
|
+
|
|
15
|
+
| PPTX | DOCX | XLSX |
|
|
16
|
+
|:---:|:---:|:---:|
|
|
17
|
+
|  |  |  |
|
|
9
18
|
|
|
10
19
|
```bash
|
|
11
20
|
npm install @silurus/ooxml
|
|
@@ -15,6 +24,8 @@ pnpm add @silurus/ooxml
|
|
|
15
24
|
|
|
16
25
|
> **Bundler note**: this package embeds `.wasm` files. With Vite add [`vite-plugin-wasm`](https://github.com/Menci/vite-plugin-wasm); with webpack use [`experiments.asyncWebAssembly`](https://webpack.js.org/configuration/experiments/).
|
|
17
26
|
|
|
27
|
+
> **Bundle size note**: npm's *Unpacked Size* figure sums ES (`.mjs`) and CJS (`.cjs`) outputs for all three formats. The size that actually lands in your app is much smaller — import only the format you need (e.g. `@silurus/ooxml/pptx`) and your bundler picks a single module format, so tree-shaking drops the other two formats entirely.
|
|
28
|
+
|
|
18
29
|
---
|
|
19
30
|
|
|
20
31
|
## Quick Start
|
|
@@ -494,6 +505,13 @@ cd packages/xlsx/parser && wasm-pack build --target web && cp pkg/xlsx_parser_bg
|
|
|
494
505
|
cd packages/docx/parser && wasm-pack build --target web && cp pkg/docx_parser_bg.wasm pkg/docx_parser.js ../src/wasm/
|
|
495
506
|
```
|
|
496
507
|
|
|
508
|
+
## Security & Privacy
|
|
509
|
+
|
|
510
|
+
- **Canvas-only rendering.** Documents are decoded and drawn to an `HTMLCanvasElement`. No script, link, form, or other active content from the source file is executed or injected into the DOM.
|
|
511
|
+
- **ZIP decompression cap.** Each entry in the source archive is limited to 512 MiB of uncompressed output to block zip-bomb DoS.
|
|
512
|
+
- **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, PPTX theme webfonts are **not** loaded from Google Fonts unless you pass `useGoogleFonts: true` to `PptxPresentation.load()` / `new PptxViewer(...)`. Enabling that 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.
|
|
513
|
+
- **XML parsing.** Uses `roxmltree`, which does not resolve external entities (XXE-safe by default).
|
|
514
|
+
|
|
497
515
|
## License
|
|
498
516
|
|
|
499
517
|
MIT
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var e = Object.defineProperty, t = (t, n) => {
|
|
3
|
+
let r = {};
|
|
4
|
+
for (var i in t) e(r, i, {
|
|
5
|
+
get: t[i],
|
|
6
|
+
enumerable: !0
|
|
7
|
+
});
|
|
8
|
+
return n || e(r, Symbol.toStringTag, { value: "Module" }), r;
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region packages/core/src/autoResize.ts
|
|
12
|
+
function n(e, t, n = {}) {
|
|
13
|
+
let r = n.pauseWhenHidden ?? !0, i = null, a = 0, o = 0, s = null, c = !1, l = !1, u = () => {
|
|
14
|
+
if (!l && !(r && typeof document < "u" && document.hidden)) {
|
|
15
|
+
if (s) {
|
|
16
|
+
c = !0;
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
i === null && (i = requestAnimationFrame(d));
|
|
20
|
+
}
|
|
21
|
+
}, d = async () => {
|
|
22
|
+
if (i = null, l) return;
|
|
23
|
+
let t = a, n = o;
|
|
24
|
+
try {
|
|
25
|
+
let r = e(t, n);
|
|
26
|
+
s = r instanceof Promise ? r : Promise.resolve(), await s;
|
|
27
|
+
} catch (e) {
|
|
28
|
+
console.error("[autoResize] render failed:", e);
|
|
29
|
+
} finally {
|
|
30
|
+
s = null, c && !l && (c = !1, u());
|
|
31
|
+
}
|
|
32
|
+
}, f = new ResizeObserver((e) => {
|
|
33
|
+
for (let t of e) {
|
|
34
|
+
let e = t.contentRect;
|
|
35
|
+
a = e.width, o = e.height;
|
|
36
|
+
}
|
|
37
|
+
u();
|
|
38
|
+
});
|
|
39
|
+
f.observe(t);
|
|
40
|
+
let p = () => {
|
|
41
|
+
typeof document < "u" && !document.hidden && u();
|
|
42
|
+
};
|
|
43
|
+
return r && typeof document < "u" && document.addEventListener("visibilitychange", p), () => {
|
|
44
|
+
l = !0, f.disconnect(), i !== null && (cancelAnimationFrame(i), i = null), r && typeof document < "u" && document.removeEventListener("visibilitychange", p);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { t as n, n as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};function n(e,t,n={}){let r=n.pauseWhenHidden??!0,i=null,a=0,o=0,s=null,c=!1,l=!1,u=()=>{if(!l&&!(r&&typeof document<`u`&&document.hidden)){if(s){c=!0;return}i===null&&(i=requestAnimationFrame(d))}},d=async()=>{if(i=null,l)return;let t=a,n=o;try{let r=e(t,n);s=r instanceof Promise?r:Promise.resolve(),await s}catch(e){console.error(`[autoResize] render failed:`,e)}finally{s=null,c&&!l&&(c=!1,u())}},f=new ResizeObserver(e=>{for(let t of e){let e=t.contentRect;a=e.width,o=e.height}u()});f.observe(t);let p=()=>{typeof document<`u`&&!document.hidden&&u()};return r&&typeof document<`u`&&document.addEventListener(`visibilitychange`,p),()=>{l=!0,f.disconnect(),i!==null&&(cancelAnimationFrame(i),i=null),r&&typeof document<`u`&&document.removeEventListener(`visibilitychange`,p)}}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return n}});
|