@silurus/ooxml 0.84.1 → 0.85.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 +44 -18
- package/dist/assets/render-worker-BRKOyWVH.js +24 -0
- package/dist/assets/render-worker-CtLMFj9r.js +10 -0
- package/dist/assets/render-worker-NZPOUOTU.js +11 -0
- package/dist/{canvas-viewer-mechanics-CIfhCgYA.js → canvas-viewer-mechanics-CfRzOhz5.js} +308 -234
- package/dist/chart-ex.mjs +270 -270
- package/dist/{comment-ui-runtime-CdMMApEN.js → comment-ui-runtime-CAbpuWi_.js} +4 -4
- package/dist/{comment-ui-runtime-C5qimVMD.js → comment-ui-runtime-DAKBCpsM.js} +5 -5
- package/dist/comment-ui-runtime-DTaaZdXC.js +2 -0
- package/dist/{comments-BAlAyIhb.js → comments-Brfxa3hQ.js} +1 -1
- package/dist/{document-pull-client-BXw6AAhY.js → document-pull-client-BkHHIdR4.js} +4661 -4357
- package/dist/{docx-BA1vB0V-.js → docx-_uelcAui.js} +338 -304
- package/dist/docx.mjs +7 -6
- package/dist/docx_parser_bg.wasm +0 -0
- package/dist/{dom-interaction-boundary-DS6BVyHA.js → dom-interaction-boundary-CMDDgICk.js} +1 -1
- package/dist/index.mjs +3 -3
- package/dist/line-distribute-CiKeWjBF.js +1023 -0
- package/dist/{line-metrics-CXyjyYd5.js → line-metrics-u87yCAfV.js} +2182 -705
- package/dist/math.mjs +2 -2
- package/dist/node.mjs +404 -394
- package/dist/pixel-budget-Dgjw269h.js +37 -0
- package/dist/{plot-area-frame-DuXZzovH.js → plot-area-frame-D5hEOgkJ.js} +691 -1418
- package/dist/{pptx-C17oBD8Z.js → pptx-WpBbS0mq.js} +255 -222
- package/dist/pptx.mjs +7 -6
- package/dist/pptx_parser_bg.wasm +0 -0
- package/dist/raster-target-whZhvVMt.js +87 -0
- package/dist/region-map.mjs +5 -5
- package/dist/{render-CVeGktZG.js → render-DrAAZWwH.js} +9 -6
- package/dist/{render-worker-host-BbhwA24Y.js → render-worker-host-CBVe8aeD.js} +1 -1
- package/dist/{render-worker-host-BWdhjVH_.js → render-worker-host-CHlwYJdK.js} +1 -1
- package/dist/{render-worker-host-CbaQivE7.js → render-worker-host-XDMsyVsv.js} +1 -1
- package/dist/{renderer-Bmky2yBc.js → renderer-XFSCOT6m.js} +1937 -1936
- package/dist/resource-measurement-6uR3Huao.js +150 -0
- package/dist/{session-Cl0RVnMs.js → session-DoPwA4gv.js} +79 -79
- package/dist/{slide-pull-client-BS0EeZo2.js → slide-pull-client-8i8C4VyD.js} +1054 -824
- package/dist/{three-d-B7LsKeOS.js → three-d-YYghQndN.js} +109 -110
- package/dist/three-d.mjs +726 -726
- package/dist/tiff.mjs +664 -78
- package/dist/types/chart-ex.d.ts +2 -2
- package/dist/types/docx.d.ts +31 -13
- package/dist/types/index.d.ts +46 -21
- package/dist/types/math.d.ts +1 -1
- package/dist/types/node.d.ts +11 -7
- package/dist/types/pptx.d.ts +35 -15
- package/dist/types/region-map.d.ts +2 -2
- package/dist/types/three-d.d.ts +2 -2
- package/dist/types/tiff.d.ts +13 -3
- package/dist/types/xlsx.d.ts +30 -13
- package/dist/{worksheet-pull-client-B0zfEVau.js → worksheet-pull-client-Btydoxto.js} +47 -47
- package/dist/{xlsx-FyKAiNo-.js → xlsx-Bd16V4Xx.js} +1395 -1196
- package/dist/xlsx.mjs +7 -6
- package/package.json +2 -2
- package/dist/assets/render-worker-BWPpayBu.js +0 -10
- package/dist/assets/render-worker-CiEWCh_T.js +0 -11
- package/dist/assets/render-worker-Cpmy3GDF.js +0 -24
- package/dist/comment-ui-runtime-aPzHfV_A.js +0 -2
- package/dist/line-distribute-MqInuujx.js +0 -1003
- package/dist/resource-measurement-esyGbzAF.js +0 -120
- package/dist/tiff-contract-Xjn3qXqK.js +0 -69
- /package/dist/{comment-occurrence-C34fWs_F.js → comment-occurrence-tj54AXXB.js} +0 -0
- /package/dist/{highlight-rect-MaCt0om0.js → highlight-rect-DBcYVJDv.js} +0 -0
- /package/dist/{mathjax-DPEX346v.js → mathjax-DS69BmJd.js} +0 -0
- /package/dist/{read-only-comment-decoration-BYCXoSdC.js → read-only-comment-decoration-Mv_SAiHy.js} +0 -0
- /package/dist/{read-only-comment-margin-C7b3l0ro.js → read-only-comment-margin-Cqu-Ir0C.js} +0 -0
- /package/dist/{renderer-module-contract-C6sYZvTV.js → renderer-module-contract-Cu-GKuPd.js} +0 -0
- /package/dist/{source-key-DORuuFb-.js → source-key-BkBB3X82.js} +0 -0
- /package/dist/{transfer-vNOFQuvv.js → transfer-mIj7E7NB.js} +0 -0
- /package/dist/{visible-index-DwJzuGmJ.js → visible-index-DPoQYSDt.js} +0 -0
package/README.md
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
> [!NOTE]
|
|
1
2
|
> **This entire codebase — Rust parsers, TypeScript renderers, tests, and tooling — is implemented by AI coding agents, primarily [Claude](https://claude.ai) and [Codex](https://openai.com/codex/)**, through iterative prompting. No human-written application code exists in this repository.
|
|
2
3
|
|
|
3
4
|
<details>
|
|
@@ -187,8 +188,9 @@ format graph. The built-in modules work in both main and worker modes. Without `
|
|
|
187
188
|
ChartEx families show the standard unsupported-chart placeholder. Without
|
|
188
189
|
`threeD`, 3-D chart groups
|
|
189
190
|
fall back to their canonical 2-D family. Without `regionMap`, Region Maps show
|
|
190
|
-
the standard unsupported-chart placeholder. Without `tiff`, TIFF
|
|
191
|
-
|
|
191
|
+
the standard unsupported-chart placeholder. Without `tiff`, recognized TIFF
|
|
192
|
+
parts report a render error instead of relying on the browser decoder or being
|
|
193
|
+
silently omitted. The code-size boundary applies to
|
|
192
194
|
the default main-mode application graph. The separately loaded render-worker
|
|
193
195
|
asset stays self-contained for broad bundler compatibility and therefore
|
|
194
196
|
contains its built-in optional renderer implementations.
|
|
@@ -219,11 +221,15 @@ represent safely. The specification/Office evidence boundary for automatic
|
|
|
219
221
|
chart behavior is documented in
|
|
220
222
|
[Chart compatibility evidence and scope](docs/chart-compatibility-evidence.md).
|
|
221
223
|
|
|
222
|
-
The
|
|
223
|
-
|
|
224
|
-
|
|
224
|
+
The bounded TIFF 6.0 codec decodes the first IFD/page of stripped, top-left
|
|
225
|
+
images in the uncompressed bilevel, 8-bit grayscale, RGB, RGBA and process-CMYK
|
|
226
|
+
classes, plus 1-bit CCITT Group 4. Unsupported or malformed first-page classes
|
|
227
|
+
fail with a diagnostic render error. It is not a general-purpose TIFF library,
|
|
228
|
+
but as a small
|
|
225
229
|
by-product the same `tiff.render()` method can provide a simple preview of a
|
|
226
|
-
supported standalone TIFF file.
|
|
230
|
+
supported standalone TIFF file. Its optional `TiffRenderOptions` argument can
|
|
231
|
+
request a bounded display-sized bitmap; the Office viewers supply those targets
|
|
232
|
+
automatically for layout-backed image paints. Try Yours and the VS Code extension enable
|
|
227
233
|
every first-party optional module; library applications can choose only the entries they need.
|
|
228
234
|
See [Production decisions](https://ooxml.silurus.dev/production/) for the full
|
|
229
235
|
module list and [Bundle size](https://ooxml.silurus.dev/bundle-size/) for current
|
|
@@ -305,10 +311,11 @@ await viewer.load('/deck.pptx');
|
|
|
305
311
|
```
|
|
306
312
|
|
|
307
313
|
The container must have a bounded height (e.g. `height: 100vh` or a flex child)
|
|
308
|
-
so the viewer can size its scroll host to it. Base zoom fits the
|
|
309
|
-
width to the container
|
|
310
|
-
|
|
311
|
-
|
|
314
|
+
so the viewer can size its scroll host to it. Base zoom fits the widest available
|
|
315
|
+
DOCX page, or the PPTX slide width, to the container and re-fits on resize. A
|
|
316
|
+
progressively loaded DOCX re-fits if a wider page appears; a `0`-width container
|
|
317
|
+
defers layout until it has width. Call `destroy()` to tear down (a self-loaded
|
|
318
|
+
engine is destroyed with it; a borrowed one is not — see below).
|
|
312
319
|
|
|
313
320
|
Pass `refitOnResize: false` when the viewport must not determine the document's
|
|
314
321
|
physical display size. An explicit pre-load `setScale(1)` then keeps the same
|
|
@@ -337,7 +344,9 @@ sheet sits inside a uniform desk margin; pass `0` for a flush edge.
|
|
|
337
344
|
bare-wheel still scrolls natively. Zoom is flicker-free — a rapid gesture shows a
|
|
338
345
|
CSS preview and settles into a crisp re-render when it pauses. Bounds are the
|
|
339
346
|
absolute scale factors `zoomMin` / `zoomMax` (default `0.1` / `4`), and
|
|
340
|
-
`setScale(scale)` sets it programmatically.
|
|
347
|
+
`setScale(scale)` sets it programmatically. When fitting needs a scale below
|
|
348
|
+
`zoomMin`, that fitted scale becomes the effective minimum so users can zoom in
|
|
349
|
+
and still return to the original fit. Pass `enableZoom: false` to disable.
|
|
341
350
|
|
|
342
351
|
**Text selection and find.** Pass `enableTextSelection: true` to overlay a
|
|
343
352
|
transparent, selectable text layer per page/slide for native copy. It works in
|
|
@@ -686,8 +695,8 @@ file without uploading it.
|
|
|
686
695
|
| | Charts (embedded DrawingML `c:chart` — bar / line / area / pie / doughnut / radar / scatter, via the shared core chart renderer; data labels honour `dLblPos`, §21.2.2.48) | ✅ |
|
|
687
696
|
| | ChartEx (waterfall / histogram / Pareto / funnel / box & whisker / treemap / sunburst) | ✅ opt-in |
|
|
688
697
|
| | Math equations (OMML `m:oMath` / `m:oMathPara`, rendered via MathJax — opt-in `@silurus/ooxml/math`) | ✅ |
|
|
689
|
-
| | Images (inline and anchored, with text wrap) | ✅ |
|
|
690
|
-
| | TIFF images (opt-in `@silurus/ooxml/tiff`;
|
|
698
|
+
| | Images (inline and anchored, with text wrap and adaptive display-sized decoding for oversized rasters) | ✅ |
|
|
699
|
+
| | TIFF images (opt-in `@silurus/ooxml/tiff`; bounded bilevel, grayscale, RGB(A), process-CMYK and CCITT Group 4) | ✅ |
|
|
691
700
|
| | SVG images (`asvg:svgBlip` MS-2016 extension — vector drawn from the embedded `.svg`, raster fallback) | ✅ |
|
|
692
701
|
| | Text boxes / drawing shapes (inline and anchored `wps:wsp` / `wps:txbx`, including solid, gradient, and image fills; `a:prstGeom` — 186 preset geometries via the shared engine; connector arrow heads `headEnd` / `tailEnd` (§20.1.8.3) and `prstDash` dash patterns (§20.1.8.48)). Text-box paragraphs run through the **same line-layout engine as body text**, so kinsoku 行頭/行末禁則 (§17.15.1.58–60), UAX#9 bidi (`w:bidi`, §17.3.1.6), justification (§17.18.44) and tab stops (§17.3.1.37) all apply inside a box | ✅ |
|
|
693
702
|
| | WMF **and EMF** metafile images (legacy vector, incl. inside text boxes) — rasterized via a built-in player: window→viewport mapping (MS-EMF map modes, world transform), pens/brushes, poly/rect/ellipse, text-out, path clipping, and embedded DIB blits | ✅ |
|
|
@@ -740,8 +749,8 @@ file without uploading it.
|
|
|
740
749
|
| | Row / column sizing (custom widths and heights) | ✅ |
|
|
741
750
|
| | Hidden rows / columns | ✅ |
|
|
742
751
|
| | Row / column outline grouping (`outlineLevel` / `collapsed` §18.3.1.73 / .13, `<outlinePr>` — gutter brackets, +/− collapse, numbered level buttons; view-only) | ✅ |
|
|
743
|
-
| **Elements** | Images (`<xdr:twoCellAnchor
|
|
744
|
-
| | TIFF images (opt-in `@silurus/ooxml/tiff`;
|
|
752
|
+
| **Elements** | Images (`<xdr:twoCellAnchor>`, with adaptive display-sized decoding for oversized rasters) | ✅ |
|
|
753
|
+
| | TIFF images (opt-in `@silurus/ooxml/tiff`; bounded bilevel, grayscale, RGB(A), process-CMYK and CCITT Group 4) | ✅ |
|
|
745
754
|
| | OLE embedded objects (`<oleObjects>` — the legacy VML `v:imagedata` preview keyed by `oleObject@shapeId` is drawn; an image-typed `objectPr` target is preferred when present, and the embedded app is not run) | ✅ |
|
|
746
755
|
| | SVG images (`asvg:svgBlip` MS-2016 extension — vector drawn from the embedded `.svg`, raster fallback) | ✅ |
|
|
747
756
|
| | Drawing shapes / text boxes (`xdr:sp`, `xdr:txBody` — 186 preset geometries via the shared engine, with `avLst` adjust handles) | ✅ |
|
|
@@ -788,8 +797,8 @@ file without uploading it.
|
|
|
788
797
|
| | Markdown export (`PptxPresentation.toMarkdown()` — title slides → headings, body → nested bullets, notes / comments collated) | ✅ |
|
|
789
798
|
| | Animations / transitions | ❌ Not planned |
|
|
790
799
|
| **Element types** | Shapes (`sp`) | ✅ |
|
|
791
|
-
| | Pictures (`pic
|
|
792
|
-
| | TIFF images (opt-in `@silurus/ooxml/tiff`;
|
|
800
|
+
| | Pictures (`pic`, with adaptive display-sized decoding for oversized rasters) | ✅ |
|
|
801
|
+
| | TIFF images (opt-in `@silurus/ooxml/tiff`; bounded bilevel, grayscale, RGB(A), process-CMYK and CCITT Group 4) | ✅ |
|
|
793
802
|
| | SVG images (`asvg:svgBlip` MS-2016 extension — vector drawn from the embedded `.svg`, PNG fallback) | ✅ |
|
|
794
803
|
| | Groups (`grpSp`) with nested transforms | ✅ |
|
|
795
804
|
| | Connectors (`cxnSp`) | ✅ |
|
|
@@ -952,6 +961,11 @@ Stable failures can be narrowed without parsing message strings:
|
|
|
952
961
|
(`code === 'ooxml-decoded-image-limit'`) — a raster crossed an image pixel or
|
|
953
962
|
active decoded-byte ceiling. Its `metric`, `limit`, and `observed` properties
|
|
954
963
|
are stable.
|
|
964
|
+
- `TiffDecodeError` (`code === 'ooxml-tiff-decode'`) — a recognized TIFF part
|
|
965
|
+
is malformed, uses a class the configured codec does not support, or fails
|
|
966
|
+
during bitmap handoff. Its message is diagnostic rather than a stable subtype.
|
|
967
|
+
Omitting the optional TIFF codec is not an error; the affected image is shown
|
|
968
|
+
as an unavailable-image placeholder while the rest of the document renders.
|
|
955
969
|
- An otherwise ordinary `Error` may carry `code === 'parser-crashed'` for a
|
|
956
970
|
recognized WASM trap. This does not mean “OOM”: panic, allocation failure,
|
|
957
971
|
stack overflow, and other traps can be indistinguishable at the current WASM
|
|
@@ -967,6 +981,7 @@ import {
|
|
|
967
981
|
OoxmlDecodedImageLimitError,
|
|
968
982
|
OoxmlError,
|
|
969
983
|
OoxmlResourceLimitError,
|
|
984
|
+
TiffDecodeError,
|
|
970
985
|
} from '@silurus/ooxml/docx';
|
|
971
986
|
|
|
972
987
|
const viewer = new DocxViewer(canvas, {
|
|
@@ -977,6 +992,8 @@ const viewer = new DocxViewer(canvas, {
|
|
|
977
992
|
showTooLargeMessage({ limit, observed });
|
|
978
993
|
} else if (error instanceof OoxmlDecodedImageLimitError) {
|
|
979
994
|
showImageTooLargeMessage(error);
|
|
995
|
+
} else if (error instanceof TiffDecodeError) {
|
|
996
|
+
showUnsupportedImageMessage();
|
|
980
997
|
} else if (error instanceof OoxmlError) {
|
|
981
998
|
handleContainerError(error.code);
|
|
982
999
|
} else {
|
|
@@ -1035,7 +1052,16 @@ try {
|
|
|
1035
1052
|
|
|
1036
1053
|
The report is content-free by construction: it does not include source URLs, filenames, package paths, document text, passwords, or raw error messages. It still contains document-derived sizes, counts, and timings, so applications remain responsible for consent, retention, and telemetry policy. The initial browser callback covers the underlying document/workbook/presentation factory and does not wait for a Viewer's first canvas paint; use `getResourceMetrics()` for the latest observed package counters. Bounded Node sessions accept both `onResourceMetrics` and `debug`. DOCX/PPTX report successful terminal metrics when their one-pass stream completes or the session is explicitly closed; XLSX reports success when the reusable workbook session is explicitly closed. Open-time and session-operation failures report immediately.
|
|
1037
1054
|
|
|
1038
|
-
Image decoding
|
|
1055
|
+
Image decoding uses a separate adaptive resource policy shared by all three formats. Target-resizable rasters—browser-decodable formats and TIFF when its optional codec is configured—keep their native decode while the complete visible paint fits the default 128 MiB decoded budget and the per-surface ceilings, preserving established output. When native ownership would cross either boundary, the renderer decodes those rasters at the current canvas/DPR requirement instead of retaining source pixels the paint cannot show. If even those display targets exceed the aggregate budget, it applies one uniform quality reduction across them; a later zoom requests a sharper cache variant. Image-bearing paints for the same loaded document are serialized so overlapping paints cannot each consume the full budget, while the admitted paint still runs up to two decodes concurrently. Formats or sources that cannot be decoder-resized remain on their format-specific path under the hard surface ceilings. Applications with a known environment can override the aggregate budget on Viewer or per-render options:
|
|
1056
|
+
```ts
|
|
1057
|
+
new PptxViewer(canvas, {
|
|
1058
|
+
imageResources: {
|
|
1059
|
+
decodedByteBudget: 256 * 1024 * 1024,
|
|
1060
|
+
strategy: 'adaptive', // or 'strict' to reject instead of reducing quality
|
|
1061
|
+
},
|
|
1062
|
+
});
|
|
1063
|
+
```
|
|
1064
|
+
`decodedByteBudget` accepts a positive safe integer from 4 bytes through 512 MiB. This configures planned and retained decoded RGBA ownership; it does not measure browser decoder intermediates or disable the encoded-source, per-axis, or per-surface hard safety ceilings. A strict aggregate crossing or any hard-ceiling crossing rejects with `OoxmlDecodedImageLimitError` (`code === 'ooxml-decoded-image-limit'`) instead of silently omitting the image.
|
|
1039
1065
|
|
|
1040
1066
|
The package counters and raster-image guards are deterministic admission limits, not exact JavaScript/WASM process-memory accounting. XML trees, document models, canvas backing stores, browser decoder overhead, renderer state, and browser-managed SVG/vector parse or decoded storage can still require several times the measured input. SVG has no portable decoded-byte measure or explicit browser release primitive; the library count-bounds its cache and revokes owned object URLs, but cannot charge it as RGBA bytes. The defaults therefore reduce risk but cannot promise that an OOM is impossible on every device. Running parse and render work in `mode: 'worker'` can contain many failures away from the main UI thread, but a Worker is not a separate operating-system process or a strict memory sandbox.
|
|
1041
1067
|
|