@silurus/ooxml 0.54.0 → 0.55.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 +8 -7
- package/dist/index.mjs +2 -2
- package/dist/{pptx-CFkdpZJb.js → pptx-BeLN0lIn.js} +8 -9
- package/dist/pptx.mjs +1 -1
- package/dist/types/docx.d.ts +10 -0
- package/dist/types/index.d.ts +30 -32
- package/dist/types/pptx.d.ts +26 -27
- package/dist/types/xlsx.d.ts +14 -5
- package/dist/{xlsx-Bz2w8zCX.js → xlsx-B0LYjpRC.js} +6 -5
- package/dist/xlsx.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ pptx.nextSlide();
|
|
|
61
61
|
|
|
62
62
|
### Rendering equations
|
|
63
63
|
|
|
64
|
-
OMML equations (`m:oMath` / `m:oMathPara`) in `.docx`
|
|
64
|
+
OMML equations (`m:oMath` / `m:oMathPara`) in `.docx`, `.pptx` and `.xlsx` are rendered with
|
|
65
65
|
[MathJax](https://www.mathjax.org/) + [STIX Two Math](https://github.com/stipub/stixfonts).
|
|
66
66
|
That engine is ~3 MB, so it is **opt-in**: import the `math` engine from the separate
|
|
67
67
|
`@silurus/ooxml/math` entry and pass it to the viewer. Pass it and equations render;
|
|
@@ -78,12 +78,13 @@ const docx = new DocxViewer(canvas, { math }); // ← equations now render
|
|
|
78
78
|
await docx.load('/paper-with-equations.docx');
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
-
The same `math` engine works for `
|
|
82
|
-
`
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
The same `math` engine works for every viewer (`DocxViewer`, `PptxViewer`,
|
|
82
|
+
`XlsxViewer`) and every headless engine (`DocxDocument`, `PptxPresentation`,
|
|
83
|
+
`XlsxWorkbook`). You inject it **once** where you create the object — the viewer
|
|
84
|
+
constructor or the `.load()` options — and every render reuses it; it is never a
|
|
85
|
+
per-render argument. (Excel stores "Insert > Equation" as OMML inside the shared
|
|
86
|
+
DrawingML `<xdr:txBody>` grammar, so `XlsxViewer` renders equations embedded in
|
|
87
|
+
shapes / text boxes the same way.)
|
|
87
88
|
|
|
88
89
|
---
|
|
89
90
|
|
package/dist/index.mjs
CHANGED
|
@@ -23315,6 +23315,7 @@ var ze = "data:application/wasm;base64,AGFzbQEAAAAB8gIwYAJ/fwBgAn9/AX9gA39/fwBgA
|
|
|
23315
23315
|
_mediaCache = /* @__PURE__ */ new Map();
|
|
23316
23316
|
_workerReady = !1;
|
|
23317
23317
|
_workerReadyCallbacks = [];
|
|
23318
|
+
_math;
|
|
23318
23319
|
constructor() {
|
|
23319
23320
|
this._worker = new Re(), this._bridge = new o(this._worker, {
|
|
23320
23321
|
correlate: (e) => "id" in e ? e.id : void 0,
|
|
@@ -23340,7 +23341,7 @@ var ze = "data:application/wasm;base64,AGFzbQEAAAAB8gIwYAJ/fwBgAn9/AX9gA39/fwBgA
|
|
|
23340
23341
|
if (!e.ok) throw Error(`Failed to fetch: ${e.status} ${e.statusText}`);
|
|
23341
23342
|
i = await e.arrayBuffer();
|
|
23342
23343
|
} else i = t;
|
|
23343
|
-
await r._parse(i, n.maxZipEntryBytes);
|
|
23344
|
+
r._math = n.math, await r._parse(i, n.maxZipEntryBytes);
|
|
23344
23345
|
let o = r._presentation;
|
|
23345
23346
|
return n.useGoogleFonts && o && await a([o.majorFont, o.minorFont], Be), r;
|
|
23346
23347
|
}
|
|
@@ -23378,7 +23379,7 @@ var ze = "data:application/wasm;base64,AGFzbQEAAAAB8gIwYAJ/fwBgAn9/AX9gA39/fwBgA
|
|
|
23378
23379
|
hlinkColor: this._presentation.hlinkColor ?? null,
|
|
23379
23380
|
fetchMedia: (e) => this.getMedia(e),
|
|
23380
23381
|
skipMediaControls: n.skipMediaControls,
|
|
23381
|
-
math:
|
|
23382
|
+
math: this._math
|
|
23382
23383
|
}, n.onTextRun);
|
|
23383
23384
|
}
|
|
23384
23385
|
async getMedia(e) {
|
|
@@ -23419,8 +23420,7 @@ var ze = "data:application/wasm;base64,AGFzbQEAAAAB8gIwYAJ/fwBgAn9/AX9gA39/fwBgA
|
|
|
23419
23420
|
width: a,
|
|
23420
23421
|
dpr: i,
|
|
23421
23422
|
skipMediaControls: !0,
|
|
23422
|
-
onTextRun: n.onTextRun
|
|
23423
|
-
math: n.math
|
|
23423
|
+
onTextRun: n.onTextRun
|
|
23424
23424
|
})
|
|
23425
23425
|
});
|
|
23426
23426
|
}
|
|
@@ -23444,7 +23444,8 @@ var ze = "data:application/wasm;base64,AGFzbQEAAAAB8gIwYAJ/fwBgAn9/AX9gA39/fwBgA
|
|
|
23444
23444
|
try {
|
|
23445
23445
|
this.engine = await Ve.load(e, {
|
|
23446
23446
|
useGoogleFonts: this.opts.useGoogleFonts,
|
|
23447
|
-
maxZipEntryBytes: this.opts.maxZipEntryBytes
|
|
23447
|
+
maxZipEntryBytes: this.opts.maxZipEntryBytes,
|
|
23448
|
+
math: this.opts.math
|
|
23448
23449
|
}), this.currentSlide = 0, await this.renderCurrentSlide();
|
|
23449
23450
|
} catch (e) {
|
|
23450
23451
|
let t = e instanceof Error ? e : Error(String(e));
|
|
@@ -23481,13 +23482,11 @@ var ze = "data:application/wasm;base64,AGFzbQEAAAAB8gIwYAJ/fwBgAn9/AX9gA39/fwBgA
|
|
|
23481
23482
|
try {
|
|
23482
23483
|
this.opts.enableMediaPlayback ? this.handle = await this.engine.presentSlide(this.canvas, this.currentSlide, {
|
|
23483
23484
|
width: e,
|
|
23484
|
-
dpr: t
|
|
23485
|
-
math: this.opts.math
|
|
23485
|
+
dpr: t
|
|
23486
23486
|
}) : await this.engine.renderSlide(this.canvas, this.currentSlide, {
|
|
23487
23487
|
width: e,
|
|
23488
23488
|
dpr: t,
|
|
23489
|
-
onTextRun: a
|
|
23490
|
-
math: this.opts.math
|
|
23489
|
+
onTextRun: a
|
|
23491
23490
|
}), this.opts.onSlideChange?.(this.currentSlide, this.slideCount);
|
|
23492
23491
|
} catch (e) {
|
|
23493
23492
|
this.opts.onError?.(e instanceof Error ? e : Error(String(e)));
|
package/dist/pptx.mjs
CHANGED
package/dist/types/docx.d.ts
CHANGED
|
@@ -436,6 +436,16 @@ declare interface LoadOptions_2 {
|
|
|
436
436
|
* untrusted input. Zero / negative values fall back to the default.
|
|
437
437
|
*/
|
|
438
438
|
maxZipEntryBytes?: number;
|
|
439
|
+
/**
|
|
440
|
+
* Opt-in OMML equation engine (MathJax + STIX Two Math, ~3 MB). Inject it
|
|
441
|
+
* **once** here and every render of this document / presentation / workbook
|
|
442
|
+
* uses it — the same dependency-injection contract across all three formats
|
|
443
|
+
* and their viewers. Import it from the separate `@silurus/ooxml/math` entry
|
|
444
|
+
* (`import { math } from '@silurus/ooxml/math'`). Omit it and equations are
|
|
445
|
+
* skipped and the engine tree-shakes away entirely (no network, no bundle
|
|
446
|
+
* cost).
|
|
447
|
+
*/
|
|
448
|
+
math?: MathRenderer;
|
|
439
449
|
}
|
|
440
450
|
|
|
441
451
|
/** Accent (`m:acc`), e.g. hat, bar, vector arrow over the base. */
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1182,6 +1182,16 @@ declare interface LoadOptions_2 {
|
|
|
1182
1182
|
* untrusted input. Zero / negative values fall back to the default.
|
|
1183
1183
|
*/
|
|
1184
1184
|
maxZipEntryBytes?: number;
|
|
1185
|
+
/**
|
|
1186
|
+
* Opt-in OMML equation engine (MathJax + STIX Two Math, ~3 MB). Inject it
|
|
1187
|
+
* **once** here and every render of this document / presentation / workbook
|
|
1188
|
+
* uses it — the same dependency-injection contract across all three formats
|
|
1189
|
+
* and their viewers. Import it from the separate `@silurus/ooxml/math` entry
|
|
1190
|
+
* (`import { math } from '@silurus/ooxml/math'`). Omit it and equations are
|
|
1191
|
+
* skipped and the engine tree-shakes away entirely (no network, no bundle
|
|
1192
|
+
* cost).
|
|
1193
|
+
*/
|
|
1194
|
+
math?: MathRenderer;
|
|
1185
1195
|
}
|
|
1186
1196
|
|
|
1187
1197
|
/** Options for {@link XlsxWorkbook.load}. The shared load-options type from
|
|
@@ -1634,6 +1644,10 @@ declare class PptxPresentation {
|
|
|
1634
1644
|
private _mediaCache;
|
|
1635
1645
|
private _workerReady;
|
|
1636
1646
|
private _workerReadyCallbacks;
|
|
1647
|
+
/** Opt-in OMML equation engine, injected once at {@link load}. Every
|
|
1648
|
+
* `renderSlide` / `presentSlide` reuses it — equations render when present,
|
|
1649
|
+
* and are skipped (engine tree-shaken) when omitted. */
|
|
1650
|
+
private _math;
|
|
1637
1651
|
private constructor();
|
|
1638
1652
|
/** Parse a PPTX from URL or ArrayBuffer. */
|
|
1639
1653
|
static load(source: string | ArrayBuffer, opts?: LoadOptions): Promise<PptxPresentation>;
|
|
@@ -1737,23 +1751,11 @@ declare class PptxViewer {
|
|
|
1737
1751
|
destroy(): void;
|
|
1738
1752
|
}
|
|
1739
1753
|
|
|
1740
|
-
declare interface PptxViewerOptions extends RenderOptions {
|
|
1754
|
+
declare interface PptxViewerOptions extends RenderOptions, LoadOptions {
|
|
1741
1755
|
/** Called when a slide finishes rendering */
|
|
1742
1756
|
onSlideChange?: (index: number, total: number) => void;
|
|
1743
1757
|
/** Called on parse or render errors */
|
|
1744
1758
|
onError?: (err: Error) => void;
|
|
1745
|
-
/**
|
|
1746
|
-
* Opt in to loading theme-declared webfonts from Google Fonts. Off by
|
|
1747
|
-
* default — see {@link PptxPresentation.load} for privacy implications.
|
|
1748
|
-
*/
|
|
1749
|
-
useGoogleFonts?: boolean;
|
|
1750
|
-
/**
|
|
1751
|
-
* Override the per-entry ZIP decompression cap (bytes) used by the zip-bomb
|
|
1752
|
-
* guard in the Rust parser. Defaults to 512 MiB. Raise this to load decks
|
|
1753
|
-
* with very large embedded media, or lower it to tighten the budget for
|
|
1754
|
-
* untrusted input. Zero / negative values fall back to the default.
|
|
1755
|
-
*/
|
|
1756
|
-
maxZipEntryBytes?: number;
|
|
1757
1759
|
/**
|
|
1758
1760
|
* Enable interactive audio/video playback. When true, slides are rendered
|
|
1759
1761
|
* via {@link PptxPresentation.presentSlide} so media elements become
|
|
@@ -1834,13 +1836,6 @@ declare interface RenderOptions {
|
|
|
1834
1836
|
* the static renderer drawing a duplicate play badge.
|
|
1835
1837
|
*/
|
|
1836
1838
|
skipMediaControls?: boolean;
|
|
1837
|
-
/**
|
|
1838
|
-
* Opt-in OMML equation engine. Import it from the separate `@silurus/ooxml/math`
|
|
1839
|
-
* entry and pass it in: `import { math } from '@silurus/ooxml/math'`. When
|
|
1840
|
-
* omitted, equations are skipped and the ~3 MB engine tree-shakes out of the
|
|
1841
|
-
* bundle entirely (it is referenced nowhere unless you import it).
|
|
1842
|
-
*/
|
|
1843
|
-
math?: MathRenderer;
|
|
1844
1839
|
}
|
|
1845
1840
|
|
|
1846
1841
|
declare interface RenderPageOptions {
|
|
@@ -1868,7 +1863,7 @@ declare interface RenderPageOptions {
|
|
|
1868
1863
|
* Render a single slide onto a <canvas> element.
|
|
1869
1864
|
* Returns the canvas for convenience.
|
|
1870
1865
|
*/
|
|
1871
|
-
declare function renderSlide(canvas: HTMLCanvasElement | OffscreenCanvas, slide: Slide, slideWidth: number, slideHeight: number, opts?:
|
|
1866
|
+
declare function renderSlide(canvas: HTMLCanvasElement | OffscreenCanvas, slide: Slide, slideWidth: number, slideHeight: number, opts?: SlideRenderOptions, onTextRun?: TextRunCallback): Promise<HTMLCanvasElement | OffscreenCanvas>;
|
|
1872
1867
|
|
|
1873
1868
|
/** Options for rendering a single slide onto a canvas. */
|
|
1874
1869
|
declare interface RenderSlideOptions {
|
|
@@ -1884,12 +1879,6 @@ declare interface RenderSlideOptions {
|
|
|
1884
1879
|
* its own play/pause chrome without duplication.
|
|
1885
1880
|
*/
|
|
1886
1881
|
skipMediaControls?: boolean;
|
|
1887
|
-
/**
|
|
1888
|
-
* Opt-in OMML equation engine. Import it from the separate `@silurus/ooxml/math`
|
|
1889
|
-
* entry and pass it in: `import { math } from '@silurus/ooxml/math'`. When
|
|
1890
|
-
* omitted, equations are skipped and the ~3 MB engine never enters the bundle.
|
|
1891
|
-
*/
|
|
1892
|
-
math?: MathRenderer;
|
|
1893
1882
|
}
|
|
1894
1883
|
|
|
1895
1884
|
declare interface RenderViewportOptions {
|
|
@@ -1906,11 +1895,6 @@ declare interface RenderViewportOptions {
|
|
|
1906
1895
|
cellScale?: number;
|
|
1907
1896
|
/** Pre-loaded Image elements keyed by their dataUrl (for ImageAnchor rendering). */
|
|
1908
1897
|
loadedImages?: Map<string, HTMLImageElement>;
|
|
1909
|
-
/** Opt-in OMML equation engine. Import it from the separate `@silurus/ooxml/math`
|
|
1910
|
-
* entry and pass it in (`import { math } from '@silurus/ooxml/math'`). When
|
|
1911
|
-
* omitted, equations in shapes are skipped and the ~3 MB engine never enters
|
|
1912
|
-
* the bundle. Same DI contract as docx/pptx. */
|
|
1913
|
-
math?: MathRenderer;
|
|
1914
1898
|
/** Called once per cell that contains text, with canvas-pixel position and cell address. */
|
|
1915
1899
|
onTextRun?: (info: XlsxTextRunInfo) => void;
|
|
1916
1900
|
/** Highlighted row range for selected row headers (1-indexed inclusive).
|
|
@@ -2295,6 +2279,16 @@ declare interface Slide {
|
|
|
2295
2279
|
|
|
2296
2280
|
declare type SlideElement = ShapeElement | PictureElement | TableElement | ChartElement | MediaElement;
|
|
2297
2281
|
|
|
2282
|
+
/**
|
|
2283
|
+
* Internal render options: the shared {@link RenderOptions} plus the opt-in
|
|
2284
|
+
* `math` engine. `math` is internal plumbing — the headless {@link
|
|
2285
|
+
* PptxPresentation} injects it once at load and threads it here on each draw,
|
|
2286
|
+
* so the public `RenderSlideOptions` deliberately does not expose it.
|
|
2287
|
+
*/
|
|
2288
|
+
declare type SlideRenderOptions = RenderOptions & {
|
|
2289
|
+
math?: MathRenderer;
|
|
2290
|
+
};
|
|
2291
|
+
|
|
2298
2292
|
/** ECMA-376 §20.1.8.31 (CT_SoftEdgesEffect) — feather radius in EMU. */
|
|
2299
2293
|
declare interface SoftEdge {
|
|
2300
2294
|
radius: number;
|
|
@@ -2929,6 +2923,10 @@ declare class XlsxWorkbook {
|
|
|
2929
2923
|
private imageCache;
|
|
2930
2924
|
private rawData;
|
|
2931
2925
|
private maxZipEntryBytes;
|
|
2926
|
+
/** Opt-in OMML equation engine, injected once at {@link load}. Every
|
|
2927
|
+
* `renderViewport` call reuses it — equations in shapes render when present,
|
|
2928
|
+
* and are skipped (engine tree-shaken) when omitted. */
|
|
2929
|
+
private math;
|
|
2932
2930
|
private constructor();
|
|
2933
2931
|
/** Parse an XLSX from a URL or ArrayBuffer. */
|
|
2934
2932
|
static load(source: string | ArrayBuffer, opts?: LoadOptions_3): Promise<XlsxWorkbook>;
|
package/dist/types/pptx.d.ts
CHANGED
|
@@ -376,6 +376,16 @@ declare interface LoadOptions_2 {
|
|
|
376
376
|
* untrusted input. Zero / negative values fall back to the default.
|
|
377
377
|
*/
|
|
378
378
|
maxZipEntryBytes?: number;
|
|
379
|
+
/**
|
|
380
|
+
* Opt-in OMML equation engine (MathJax + STIX Two Math, ~3 MB). Inject it
|
|
381
|
+
* **once** here and every render of this document / presentation / workbook
|
|
382
|
+
* uses it — the same dependency-injection contract across all three formats
|
|
383
|
+
* and their viewers. Import it from the separate `@silurus/ooxml/math` entry
|
|
384
|
+
* (`import { math } from '@silurus/ooxml/math'`). Omit it and equations are
|
|
385
|
+
* skipped and the engine tree-shakes away entirely (no network, no bundle
|
|
386
|
+
* cost).
|
|
387
|
+
*/
|
|
388
|
+
math?: MathRenderer;
|
|
379
389
|
}
|
|
380
390
|
|
|
381
391
|
/** Accent (`m:acc`), e.g. hat, bar, vector arrow over the base. */
|
|
@@ -661,6 +671,10 @@ export declare class PptxPresentation {
|
|
|
661
671
|
private _mediaCache;
|
|
662
672
|
private _workerReady;
|
|
663
673
|
private _workerReadyCallbacks;
|
|
674
|
+
/** Opt-in OMML equation engine, injected once at {@link load}. Every
|
|
675
|
+
* `renderSlide` / `presentSlide` reuses it — equations render when present,
|
|
676
|
+
* and are skipped (engine tree-shaken) when omitted. */
|
|
677
|
+
private _math;
|
|
664
678
|
private constructor();
|
|
665
679
|
/** Parse a PPTX from URL or ArrayBuffer. */
|
|
666
680
|
static load(source: string | ArrayBuffer, opts?: LoadOptions): Promise<PptxPresentation>;
|
|
@@ -764,23 +778,11 @@ export declare class PptxViewer {
|
|
|
764
778
|
destroy(): void;
|
|
765
779
|
}
|
|
766
780
|
|
|
767
|
-
export declare interface PptxViewerOptions extends RenderOptions {
|
|
781
|
+
export declare interface PptxViewerOptions extends RenderOptions, LoadOptions {
|
|
768
782
|
/** Called when a slide finishes rendering */
|
|
769
783
|
onSlideChange?: (index: number, total: number) => void;
|
|
770
784
|
/** Called on parse or render errors */
|
|
771
785
|
onError?: (err: Error) => void;
|
|
772
|
-
/**
|
|
773
|
-
* Opt in to loading theme-declared webfonts from Google Fonts. Off by
|
|
774
|
-
* default — see {@link PptxPresentation.load} for privacy implications.
|
|
775
|
-
*/
|
|
776
|
-
useGoogleFonts?: boolean;
|
|
777
|
-
/**
|
|
778
|
-
* Override the per-entry ZIP decompression cap (bytes) used by the zip-bomb
|
|
779
|
-
* guard in the Rust parser. Defaults to 512 MiB. Raise this to load decks
|
|
780
|
-
* with very large embedded media, or lower it to tighten the budget for
|
|
781
|
-
* untrusted input. Zero / negative values fall back to the default.
|
|
782
|
-
*/
|
|
783
|
-
maxZipEntryBytes?: number;
|
|
784
786
|
/**
|
|
785
787
|
* Enable interactive audio/video playback. When true, slides are rendered
|
|
786
788
|
* via {@link PptxPresentation.presentSlide} so media elements become
|
|
@@ -861,20 +863,13 @@ export declare interface RenderOptions {
|
|
|
861
863
|
* the static renderer drawing a duplicate play badge.
|
|
862
864
|
*/
|
|
863
865
|
skipMediaControls?: boolean;
|
|
864
|
-
/**
|
|
865
|
-
* Opt-in OMML equation engine. Import it from the separate `@silurus/ooxml/math`
|
|
866
|
-
* entry and pass it in: `import { math } from '@silurus/ooxml/math'`. When
|
|
867
|
-
* omitted, equations are skipped and the ~3 MB engine tree-shakes out of the
|
|
868
|
-
* bundle entirely (it is referenced nowhere unless you import it).
|
|
869
|
-
*/
|
|
870
|
-
math?: MathRenderer;
|
|
871
866
|
}
|
|
872
867
|
|
|
873
868
|
/**
|
|
874
869
|
* Render a single slide onto a <canvas> element.
|
|
875
870
|
* Returns the canvas for convenience.
|
|
876
871
|
*/
|
|
877
|
-
export declare function renderSlide(canvas: HTMLCanvasElement | OffscreenCanvas, slide: Slide, slideWidth: number, slideHeight: number, opts?:
|
|
872
|
+
export declare function renderSlide(canvas: HTMLCanvasElement | OffscreenCanvas, slide: Slide, slideWidth: number, slideHeight: number, opts?: SlideRenderOptions, onTextRun?: TextRunCallback): Promise<HTMLCanvasElement | OffscreenCanvas>;
|
|
878
873
|
|
|
879
874
|
/** Options for rendering a single slide onto a canvas. */
|
|
880
875
|
export declare interface RenderSlideOptions {
|
|
@@ -890,12 +885,6 @@ export declare interface RenderSlideOptions {
|
|
|
890
885
|
* its own play/pause chrome without duplication.
|
|
891
886
|
*/
|
|
892
887
|
skipMediaControls?: boolean;
|
|
893
|
-
/**
|
|
894
|
-
* Opt-in OMML equation engine. Import it from the separate `@silurus/ooxml/math`
|
|
895
|
-
* entry and pass it in: `import { math } from '@silurus/ooxml/math'`. When
|
|
896
|
-
* omitted, equations are skipped and the ~3 MB engine never enters the bundle.
|
|
897
|
-
*/
|
|
898
|
-
math?: MathRenderer;
|
|
899
888
|
}
|
|
900
889
|
|
|
901
890
|
declare interface Shadow {
|
|
@@ -968,6 +957,16 @@ export declare interface Slide {
|
|
|
968
957
|
|
|
969
958
|
export declare type SlideElement = ShapeElement | PictureElement | TableElement | ChartElement | MediaElement;
|
|
970
959
|
|
|
960
|
+
/**
|
|
961
|
+
* Internal render options: the shared {@link RenderOptions} plus the opt-in
|
|
962
|
+
* `math` engine. `math` is internal plumbing — the headless {@link
|
|
963
|
+
* PptxPresentation} injects it once at load and threads it here on each draw,
|
|
964
|
+
* so the public `RenderSlideOptions` deliberately does not expose it.
|
|
965
|
+
*/
|
|
966
|
+
declare type SlideRenderOptions = RenderOptions & {
|
|
967
|
+
math?: MathRenderer;
|
|
968
|
+
};
|
|
969
|
+
|
|
971
970
|
/** ECMA-376 §20.1.8.31 (CT_SoftEdgesEffect) — feather radius in EMU. */
|
|
972
971
|
declare interface SoftEdge {
|
|
973
972
|
radius: number;
|
package/dist/types/xlsx.d.ts
CHANGED
|
@@ -464,6 +464,16 @@ declare interface LoadOptions_2 {
|
|
|
464
464
|
* untrusted input. Zero / negative values fall back to the default.
|
|
465
465
|
*/
|
|
466
466
|
maxZipEntryBytes?: number;
|
|
467
|
+
/**
|
|
468
|
+
* Opt-in OMML equation engine (MathJax + STIX Two Math, ~3 MB). Inject it
|
|
469
|
+
* **once** here and every render of this document / presentation / workbook
|
|
470
|
+
* uses it — the same dependency-injection contract across all three formats
|
|
471
|
+
* and their viewers. Import it from the separate `@silurus/ooxml/math` entry
|
|
472
|
+
* (`import { math } from '@silurus/ooxml/math'`). Omit it and equations are
|
|
473
|
+
* skipped and the engine tree-shakes away entirely (no network, no bundle
|
|
474
|
+
* cost).
|
|
475
|
+
*/
|
|
476
|
+
math?: MathRenderer;
|
|
467
477
|
}
|
|
468
478
|
|
|
469
479
|
declare interface ManualLayout {
|
|
@@ -682,11 +692,6 @@ export declare interface RenderViewportOptions {
|
|
|
682
692
|
cellScale?: number;
|
|
683
693
|
/** Pre-loaded Image elements keyed by their dataUrl (for ImageAnchor rendering). */
|
|
684
694
|
loadedImages?: Map<string, HTMLImageElement>;
|
|
685
|
-
/** Opt-in OMML equation engine. Import it from the separate `@silurus/ooxml/math`
|
|
686
|
-
* entry and pass it in (`import { math } from '@silurus/ooxml/math'`). When
|
|
687
|
-
* omitted, equations in shapes are skipped and the ~3 MB engine never enters
|
|
688
|
-
* the bundle. Same DI contract as docx/pptx. */
|
|
689
|
-
math?: MathRenderer;
|
|
690
695
|
/** Called once per cell that contains text, with canvas-pixel position and cell address. */
|
|
691
696
|
onTextRun?: (info: XlsxTextRunInfo) => void;
|
|
692
697
|
/** Highlighted row range for selected row headers (1-indexed inclusive).
|
|
@@ -1249,6 +1254,10 @@ export declare class XlsxWorkbook {
|
|
|
1249
1254
|
private imageCache;
|
|
1250
1255
|
private rawData;
|
|
1251
1256
|
private maxZipEntryBytes;
|
|
1257
|
+
/** Opt-in OMML equation engine, injected once at {@link load}. Every
|
|
1258
|
+
* `renderViewport` call reuses it — equations in shapes render when present,
|
|
1259
|
+
* and are skipped (engine tree-shaken) when omitted. */
|
|
1260
|
+
private math;
|
|
1252
1261
|
private constructor();
|
|
1253
1262
|
/** Parse an XLSX from a URL or ArrayBuffer. */
|
|
1254
1263
|
static load(source: string | ArrayBuffer, opts?: LoadOptions): Promise<XlsxWorkbook>;
|
|
@@ -2748,6 +2748,7 @@ var dn = {
|
|
|
2748
2748
|
imageCache = /* @__PURE__ */ new Map();
|
|
2749
2749
|
rawData = null;
|
|
2750
2750
|
maxZipEntryBytes;
|
|
2751
|
+
math;
|
|
2751
2752
|
constructor() {
|
|
2752
2753
|
this.worker = new h(), this.bridge = new o(this.worker, {
|
|
2753
2754
|
correlate: (e) => e.id,
|
|
@@ -2770,7 +2771,7 @@ var dn = {
|
|
|
2770
2771
|
if (!t.ok) throw Error(`Failed to fetch: ${t.status} ${t.statusText}`);
|
|
2771
2772
|
n = await t.arrayBuffer();
|
|
2772
2773
|
} else n = e;
|
|
2773
|
-
if (this.rawData = n, this.maxZipEntryBytes = t.maxZipEntryBytes, this.parsedWorkbook = (await this.bridge.request((e) => ({
|
|
2774
|
+
if (this.rawData = n, this.maxZipEntryBytes = t.maxZipEntryBytes, this.math = t.math, this.parsedWorkbook = (await this.bridge.request((e) => ({
|
|
2774
2775
|
type: "parse",
|
|
2775
2776
|
id: e,
|
|
2776
2777
|
data: n.slice(0),
|
|
@@ -2816,7 +2817,7 @@ var dn = {
|
|
|
2816
2817
|
t.src = e, await new Promise((e, n) => {
|
|
2817
2818
|
t.onload = () => e(), t.onerror = () => n(/* @__PURE__ */ Error("image decode failed"));
|
|
2818
2819
|
}), this.imageCache.set(e, t);
|
|
2819
|
-
})).catch(() => {}),
|
|
2820
|
+
})).catch(() => {}), this.math && Pt(i) && await Ft(i, this.math);
|
|
2820
2821
|
let s = r.dpr ?? (typeof window < "u" ? window.devicePixelRatio : 1), c = e instanceof HTMLCanvasElement ? e.clientWidth || 800 : e.width, l = e instanceof HTMLCanvasElement ? e.clientHeight || 600 : e.height, u = r.width ?? c, d = r.height ?? l;
|
|
2821
2822
|
e.width = Math.round(u * s), e.height = Math.round(d * s), e instanceof HTMLCanvasElement && (e.style.width = `${u}px`, e.style.height = `${d}px`);
|
|
2822
2823
|
let f = e.getContext("2d");
|
|
@@ -2918,7 +2919,8 @@ var vn = class {
|
|
|
2918
2919
|
try {
|
|
2919
2920
|
this.wb = await fn.load(e, {
|
|
2920
2921
|
useGoogleFonts: this.opts.useGoogleFonts,
|
|
2921
|
-
maxZipEntryBytes: this.opts.maxZipEntryBytes
|
|
2922
|
+
maxZipEntryBytes: this.opts.maxZipEntryBytes,
|
|
2923
|
+
math: this.opts.math
|
|
2922
2924
|
}), this.buildTabs(), this.opts.onReady?.(this.wb.sheetNames), await this.showSheet(0);
|
|
2923
2925
|
} catch (e) {
|
|
2924
2926
|
let t = e instanceof Error ? e : Error(String(e));
|
|
@@ -3366,8 +3368,7 @@ var vn = class {
|
|
|
3366
3368
|
freezeRows: a,
|
|
3367
3369
|
freezeCols: o,
|
|
3368
3370
|
selectedRowRange: x,
|
|
3369
|
-
selectedColRange: S
|
|
3370
|
-
math: this.opts.math
|
|
3371
|
+
selectedColRange: S
|
|
3371
3372
|
});
|
|
3372
3373
|
}
|
|
3373
3374
|
computeHeaderHighlight() {
|
package/dist/xlsx.mjs
CHANGED
package/package.json
CHANGED