@silurus/ooxml 0.80.2 → 0.81.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.
Files changed (54) hide show
  1. package/README.md +57 -77
  2. package/dist/assets/render-worker-C2ACcLes.js +11 -0
  3. package/dist/assets/render-worker-Cx5uR77k.js +10 -0
  4. package/dist/assets/render-worker-DtU8oQZ7.js +24 -0
  5. package/dist/{canvas-viewer-mechanics-D-r6wHY_.js → canvas-viewer-mechanics-CqxKRGCp.js} +1 -1
  6. package/dist/chart-ex.mjs +1017 -0
  7. package/dist/{document-pull-client-Cukkyojh.js → document-pull-client-Ux4a_ax8.js} +4540 -4412
  8. package/dist/{docx-BlELeDNF.js → docx-SEyQ4gS-.js} +79 -75
  9. package/dist/docx.mjs +5 -4
  10. package/dist/docx_parser_bg.wasm +0 -0
  11. package/dist/index.mjs +3 -3
  12. package/dist/{line-distribute-Bvtp0Gt6.js → line-distribute-BBGvvwLt.js} +17 -16
  13. package/dist/{line-metrics-DdEJYxjx.js → line-metrics-Baz31mML.js} +663 -7488
  14. package/dist/math.mjs +29 -24
  15. package/dist/node.mjs +248 -247
  16. package/dist/plot-area-frame-Dg1VIpUU.js +3669 -0
  17. package/dist/{pptx-JBkXh6Cy.js → pptx-5lQrMvMR.js} +236 -232
  18. package/dist/pptx.mjs +6 -5
  19. package/dist/pptx_parser_bg.wasm +0 -0
  20. package/dist/region-map.mjs +102 -97
  21. package/dist/{render-CoqMHcbF.js → render-DEHjijQD.js} +1 -1
  22. package/dist/{render-worker-host-CM1JXVqg.js → render-worker-host-B1nbV_k7.js} +1 -1
  23. package/dist/{render-worker-host-DFtd9Z-J.js → render-worker-host-Bze5M6k5.js} +1 -1
  24. package/dist/{render-worker-host-Br7ZDyGE.js → render-worker-host-Dg_74V64.js} +1 -1
  25. package/dist/renderer-DuopJE1K.js +5855 -0
  26. package/dist/{renderer-module-contract-BNGz8HvO.js → renderer-module-contract-0bO_5SC0.js} +4 -3
  27. package/dist/{resource-measurement-CgMubiAI.js → resource-measurement-DRLp4nFt.js} +12 -11
  28. package/dist/{session-DkPblDiq.js → session-CNVc3VJ4.js} +8 -8
  29. package/dist/{slide-pull-client-m2blvngt.js → slide-pull-client-CzutXnGc.js} +888 -1082
  30. package/dist/three-d-BYiWCNlz.js +1345 -0
  31. package/dist/three-d.mjs +1238 -798
  32. package/dist/types/chart-ex.d.ts +949 -0
  33. package/dist/types/docx.d.ts +325 -18
  34. package/dist/types/index.d.ts +325 -26
  35. package/dist/types/math.d.ts +1 -1
  36. package/dist/types/node.d.ts +303 -14
  37. package/dist/types/pptx.d.ts +314 -22
  38. package/dist/types/region-map.d.ts +318 -6
  39. package/dist/types/three-d.d.ts +318 -6
  40. package/dist/types/xlsx.d.ts +317 -18
  41. package/dist/{worksheet-pull-client-BntP6RiO.js → worksheet-pull-client-Cxj3Ej0s.js} +19 -19
  42. package/dist/{xlsx-dhsUXUpX.js → xlsx-Bl3TIEVu.js} +1313 -1279
  43. package/dist/xlsx.mjs +6 -5
  44. package/dist/xlsx_parser_bg.wasm +0 -0
  45. package/package.json +7 -1
  46. package/dist/assets/render-worker-BD1_LaFD.js +0 -9
  47. package/dist/assets/render-worker-BIqMQFkZ.js +0 -8
  48. package/dist/assets/render-worker-DuvX4_li.js +0 -22
  49. package/dist/chart-number-format-qLhnk6hj.js +0 -475
  50. package/dist/three-d-C28kqDym.js +0 -1086
  51. /package/dist/{highlight-rect-BuX5rWP4.js → highlight-rect-BqcZMHUE.js} +0 -0
  52. /package/dist/{mathjax-DgAl7Yi5.js → mathjax-DJa-Q93p.js} +0 -0
  53. /package/dist/{transfer-CKZ79zFw.js → transfer-D0U6Uhn4.js} +0 -0
  54. /package/dist/{visible-index-BjesVGhg.js → visible-index-DbDuGMCE.js} +0 -0
package/README.md CHANGED
@@ -76,39 +76,13 @@ pnpm add @silurus/ooxml
76
76
  > new DocxViewer(canvas, { wasmUrl: 'https://cdn.example.com/docx_parser_bg.wasm' });
77
77
  > ```
78
78
 
79
- > **Bundle size note**: the package is ESM-only (`.mjs`). npm's *Unpacked
80
- > Size* sums every entry bundle **and** the standalone MathJax + STIX Two Math
81
- > asset, so the reported figure is much larger than any single app build. For
82
- > v0.79.0, the complete npm package is approximately 13.0 MB unpacked (4.3 MB
83
- > as the downloaded tarball), while a format-specific application graph is
84
- > approximately:
85
- >
86
- > | Imported entry | Reachable assets | gzip | Includes |
87
- > |---|---:|---:|---|
88
- > | `@silurus/ooxml/docx` | 4.0 MB | 1.2 MB | DOCX renderer, parser WASM, and lazy worker |
89
- > | `@silurus/ooxml/xlsx` | 2.6 MB | 0.82 MB | XLSX renderer, parser WASM, and lazy worker |
90
- > | `@silurus/ooxml/pptx` | 2.5 MB | 0.78 MB | PPTX renderer, parser WASM, and lazy worker |
91
- > | `@silurus/ooxml/math` | 3.1 MB | 1.1 MB | Optional MathJax + STIX Two Math engine |
92
- > | `@silurus/ooxml/three-d` | 92 KB | 27 KB | Optional model-space 3-D chart mesh and camera |
93
- > | `@silurus/ooxml/region-map` | 236 KB | 66 KB | Optional offline Region Map renderer and fixed country geometry |
94
- >
95
- > These are production-artifact estimates, not initial-load figures: each row
96
- > sums all assets reachable from that entry, including parser WASM and worker
97
- > chunks loaded on demand. Exact output varies by bundler and compression. Import
98
- > only the format you need (for example, `@silurus/ooxml/pptx`) so the other
99
- > formats can be tree-shaken. The math engine is a **separate entry** whose
100
- > main-thread chunk is a ~1 KB loader referencing the ~3 MB engine as a
101
- > **sibling file**, not an inline data URL. The engine is fetched lazily, only
102
- > when a document contains equations, and only if you imported
103
- > `@silurus/ooxml/math` and passed it to a viewer (see
104
- > [Rendering equations](#rendering-equations)). Never import the `math` entry
105
- > and the loader chunk never enters your graph at all.
106
- >
107
- > The 3-D chart and Region Map renderers follow the same dependency-injection
108
- > boundary: import and pass only the optional renderer modules an application
109
- > needs. Their implementations are not eagerly loaded or evaluated in main
110
- > mode. Worker mode fetches a self-contained render-worker asset that includes
111
- > the worker-side built-ins, so consumer bundlers can copy it safely.
79
+ > **Bundle size note**: the package is ESM-only (`.mjs`). npm's *Unpacked Size*
80
+ > includes every entry and optional asset, so it is not the size of a
81
+ > format-specific application graph. See the current production measurements on
82
+ > the stable [Bundle size](https://ooxml.silurus.dev/bundle-size/) page. Import
83
+ > only the format and optional renderer entries your application needs. In main
84
+ > mode, MathJax, ChartEx, 3-D and Region Map implementations remain outside the
85
+ > graph unless imported; the separately loaded worker asset is self-contained.
112
86
 
113
87
  ---
114
88
 
@@ -209,22 +183,30 @@ shapes / text boxes the same way.)
209
183
 
210
184
  ### Optional chart renderers
211
185
 
212
- Model-space 3-D charts and offline country-level Region Maps are separate
213
- entries. Inject them once in the same load options object as `math`; omitting a
214
- renderer keeps it out of the ordinary render path. The built-in renderers work
215
- in both main and worker modes. Without `threeD`, 3-D chart groups
186
+ Classic DrawingML 2-D chart families are included in every format entry.
187
+ Microsoft ChartEx, model-space 3-D charts and offline country-level Region Maps
188
+ are separate entries. Inject them once in the same load options object as
189
+ `math`; omitting a renderer keeps it out of the ordinary render path. The
190
+ built-in renderers work in both main and worker modes. Without `chartEx`,
191
+ ChartEx families show the standard unsupported-chart placeholder. Without
192
+ `threeD`, 3-D chart groups
216
193
  fall back to their canonical 2-D family. Without `regionMap`, Region Maps show
217
- the standard unsupported-chart placeholder.
194
+ the standard unsupported-chart placeholder. The code-size boundary applies to
195
+ the default main-mode application graph. The separately loaded render-worker
196
+ asset stays self-contained for broad bundler compatibility and therefore
197
+ contains its built-in optional renderer implementations.
218
198
 
219
199
  ```typescript
220
200
  import { XlsxViewer } from '@silurus/ooxml/xlsx';
221
201
  import { threeD } from '@silurus/ooxml/three-d';
222
202
  import { regionMap } from '@silurus/ooxml/region-map';
203
+ import { chartEx } from '@silurus/ooxml/chart-ex';
223
204
 
224
205
  const container = document.getElementById('xlsx-container') as HTMLElement;
225
206
  const workbookViewer = new XlsxViewer(container, {
226
207
  threeD,
227
208
  regionMap,
209
+ chartEx,
228
210
  mode: 'worker',
229
211
  });
230
212
  await workbookViewer.load('/workbook-with-advanced-charts.xlsx');
@@ -272,10 +254,10 @@ Notes:
272
254
  - The canvas-target methods (`renderSlide(canvas)`, `renderPage(canvas)`,
273
255
  `renderViewport(canvas)`) are unavailable in worker mode — use the `*ToBitmap`
274
256
  variants instead.
275
- - The built-in math, 3-D chart, and Region Map renderers work in both modes
276
- through the same `math`, `threeD`, and `regionMap` options. Custom renderer
277
- objects are main-realm code and therefore use the feature's documented
278
- fallback in `mode: 'worker'`.
257
+ - The built-in math, ChartEx, 3-D chart, and Region Map renderers work in both
258
+ modes through the same `math`, `chartEx`, `threeD`, and `regionMap` options.
259
+ Custom renderer objects are main-realm code and therefore use the feature's
260
+ documented fallback in `mode: 'worker'`.
279
261
  - A DOCX document that requires browser-only OpenType vertical-glyph selection
280
262
  automatically uses effective main mode for correct shaping. Read
281
263
  `document.mode` after loading when your integration needs to observe this
@@ -526,38 +508,33 @@ flowchart TB
526
508
  end
527
509
 
528
510
  subgraph browser["🌐 Runtime (Browser)"]
529
- subgraph core_pkg["@silurus/ooxml-core (shared primitives)"]
530
- CORE["renderChart · resolveFill · applyStroke\nbuildCustomPath · autoResize · shared types"]
531
- end
532
- subgraph docx_pkg["@silurus/ooxml · docx"]
533
- DV["DocxViewer"] --> DD["DocxDocument"]
534
- DD --> DW["worker.ts\n〈Web Worker — parse only〉"]
535
- DD --> DR["renderer.ts\n〈Canvas 2D — main thread〉"]
536
- end
537
- subgraph xlsx_pkg["@silurus/ooxml · xlsx"]
538
- XV["XlsxViewer"] --> XB["XlsxWorkbook"]
539
- XB --> XW["worker.ts\n〈Web Worker — parse only〉"]
540
- XB --> XR["renderer.ts\n〈Canvas 2D — main thread〉"]
541
- end
542
- subgraph pptx_pkg["@silurus/ooxml · pptx"]
543
- PV["PptxViewer"] --> PP["PptxPresentation"]
544
- PP --> PW["worker.ts\n〈Web Worker — parse only〉"]
545
- PP --> PR["renderer.ts\n〈Canvas 2D — main thread〉"]
546
- end
547
- DR -. uses .-> CORE
548
- XR -. uses .-> CORE
549
- PR -. uses .-> CORE
511
+ VIEWER["DOCX / XLSX / PPTX Viewer"] --> ENGINE["format headless engine"]
512
+ ENGINE -->|mode: main| PARSE["parser worker\n〈WASM parse〉"]
513
+ PARSE --> MODEL["validated document model"]
514
+ MODEL --> MAIN["layout + Canvas paint\n〈main thread〉"]
515
+ ENGINE -->|mode: worker| RENDER_WORKER["render-worker.ts\n〈WASM parse + layout + paint〉"]
516
+ RENDER_WORKER --> BITMAP["ImageBitmap"]
517
+ MAIN --> CANVAS["<canvas>"]
518
+ BITMAP --> CANVAS
519
+ CORE["@silurus/ooxml-core\nshared layout and paint primitives"]
520
+ MAIN -. uses .-> CORE
521
+ RENDER_WORKER -. uses .-> CORE
550
522
  end
551
523
 
552
- docx_wasm --> DW
553
- xlsx_wasm --> XW
554
- pptx_wasm --> PW
555
- DR --> canvas["<canvas>"]
556
- XR --> canvas
557
- PR --> canvas
524
+ docx_wasm --> PARSE
525
+ xlsx_wasm --> PARSE
526
+ pptx_wasm --> PARSE
527
+ docx_wasm --> RENDER_WORKER
528
+ xlsx_wasm --> RENDER_WORKER
529
+ pptx_wasm --> RENDER_WORKER
558
530
  ```
559
531
 
560
- All three formats follow the same shape: the worker parses the `.docx` / `.xlsx` / `.pptx` archive via WASM and posts a JSON model back to the main thread, where the renderer draws to the canvas. Rendering stays on the main thread so the canvas shares the document's `FontFaceSet` — an `OffscreenCanvas` in a worker has its own font registry and would silently fall back to a system font, producing subtly different text measurements (and wrap positions) from the installed theme webfonts. `@silurus/ooxml-core` holds the cross-format primitives that the three renderers all depend on: a unified chart renderer (bar / line / area / radar / waterfall), shape helpers (`resolveFill`, `applyStroke`, `buildCustomPath`, `hexToRgba`), the `autoResize` viewer utility, and the shared type definitions.
532
+ All three formats use the same public mode boundary. In the default `main` mode,
533
+ WASM parsing runs in a Worker and the validated model is laid out and painted on
534
+ the main thread. In `worker` mode, parsing, layout and Canvas paint run in a
535
+ render Worker, which returns an `ImageBitmap` for presentation. Built-in optional
536
+ renderers use the same injection options in both modes. `@silurus/ooxml-core`
537
+ owns the layout, paint and type primitives shared by DOCX, XLSX and PPTX.
561
538
 
562
539
  ### Key files
563
540
 
@@ -566,10 +543,11 @@ All three formats follow the same shape: the worker parses the `.docx` / `.xlsx`
566
543
  | `packages/docx/parser/src/lib.rs` | Rust WASM parser — DOCX ZIP → `Document` JSON |
567
544
  | `packages/xlsx/parser/src/lib.rs` | Rust WASM parser — XLSX ZIP → `Workbook` JSON |
568
545
  | `packages/pptx/parser/src/lib.rs` | Rust WASM parser — PPTX ZIP → `Presentation` JSON |
569
- | `packages/docx/src/renderer.ts` | Canvas 2D rendering engine with text layout (main thread) |
570
- | `packages/xlsx/src/renderer.ts` | Canvas 2D rendering engine with virtual scroll (main thread) |
571
- | `packages/pptx/src/renderer.ts` | Canvas 2D rendering engine (main thread) |
572
- | `packages/*/src/worker.ts` | Web Worker: WASM init and parsing only (one per format) |
546
+ | `packages/docx/src/renderer.ts` | DOCX Canvas 2D rendering and text layout |
547
+ | `packages/xlsx/src/renderer.ts` | XLSX Canvas 2D viewport rendering |
548
+ | `packages/pptx/src/renderer.ts` | PPTX Canvas 2D rendering |
549
+ | `packages/*/src/worker.ts` | Main-mode parser Worker entry |
550
+ | `packages/*/src/render-worker.ts` | Worker-mode parser, layout and Canvas paint entry |
573
551
  | `packages/*/src/viewer.ts` | Public Viewer API — canvas lifecycle, navigation |
574
552
  | `packages/core/src/index.ts` | Cross-format primitives — chart renderer, shape helpers, `autoResize`, shared types |
575
553
 
@@ -628,6 +606,7 @@ file without uploading it.
628
606
  | | Table indent (`w:tblInd`, §17.4.50) | ✅ |
629
607
  | | Right-to-left table column order (`w:bidiVisual`, §17.4.1) | ✅ |
630
608
  | | 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) | ✅ |
609
+ | | ChartEx (waterfall / histogram / Pareto / funnel / box & whisker / treemap / sunburst) | ✅ opt-in |
631
610
  | | Math equations (OMML `m:oMath` / `m:oMathPara`, rendered via MathJax — opt-in `@silurus/ooxml/math`) | ✅ |
632
611
  | | Images (inline and anchored, with text wrap) | ✅ |
633
612
  | | SVG images (`asvg:svgBlip` MS-2016 extension — vector drawn from the embedded `.svg`, raster fallback) | ✅ |
@@ -687,6 +666,7 @@ file without uploading it.
687
666
  | | Drawing shapes / text boxes (`xdr:sp`, `xdr:txBody` — 186 preset geometries via the shared engine, with `avLst` adjust handles) | ✅ |
688
667
  | | Math equations in shapes (OMML `m:oMath` / `m:oMathPara` in `xdr:txBody`, incl. `a14:m` / `mc:AlternateContent`; rendered via MathJax — opt-in `@silurus/ooxml/math`) | ✅ |
689
668
  | | Charts (bar, line, area, pie, doughnut, radar, scatter / bubble) | ✅ |
669
+ | | ChartEx (waterfall / histogram / Pareto / funnel / box & whisker / treemap / sunburst) | ✅ opt-in |
690
670
  | | Chart markers (circle / square / diamond / triangle / x / plus / star / dot / dash, per-point `<c:dPt>` overrides; markers-only scatter series draw a marker legend key) | ✅ |
691
671
  | | Chart data labels (`<c:dLbl>` per-point with CELLRANGE / VALUE / SERIESNAME / CATEGORYNAME field references, position `l`/`r`/`t`/`b`/`ctr`/`outEnd`) | ✅ |
692
672
  | | Chart error bars (`<c:errBars>` X/Y direction, `cust` / `fixedVal` / `stdErr` / `stdDev` / `percentage`, dashed/styled lines) | ✅ |
@@ -732,12 +712,12 @@ file without uploading it.
732
712
  | | Groups (`grpSp`) with nested transforms | ✅ |
733
713
  | | Connectors (`cxnSp`) | ✅ |
734
714
  | | Tables (`tbl` in `graphicFrame`) | ✅ |
735
- | | Charts (bar, line, area, radar, waterfall) | ✅ |
715
+ | | Charts (bar, line, area, radar) | ✅ |
736
716
  | | Charts (pie, doughnut) | ✅ |
737
717
  | | Charts (scatter — `scatterStyle` marker / line / smooth variants) | ✅ |
738
718
  | | Charts (bubble — `bubbleSize` per-point area scaling) | ✅ |
739
- | | Charts (combo — bar + line with a secondary value axis on the right) | ✅ |
740
- | | Charts (chartEx — funnel / histogram / treemap / sunburst / box &amp; whisker) | ✅ |
719
+ | | Charts (ordered classic combo groups observed bar/line/area, scatter/bubble, and stock/line combinations; unsupported mixes fail closed) | ✅ |
720
+ | | ChartEx (waterfall / histogram / Pareto / funnel / box &amp; whisker / treemap / sunburst) | ✅ opt-in |
741
721
  | | Charts (stock — high / low / close candlesticks) | ✅ |
742
722
  | | SmartArt (renders the PowerPoint-saved drawing layout `dsp:drawing`, or a staged fallback to a text list when no drawing part is present; no native diagram layout engine) | ✅ |
743
723
  | | OLE embedded objects (`p:oleObj` — the baked preview `p:pic` is drawn; the embedded app is not run) | ✅ |