@silurus/ooxml 0.58.0 → 0.59.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 +41 -1
- package/dist/docx-MHQa7gm7.js +1911 -0
- package/dist/docx.mjs +2 -2
- package/dist/index.mjs +3 -3
- package/dist/{pptx-B6H-We19.js → pptx-BiatvxSp.js} +781 -676
- package/dist/pptx.mjs +2 -2
- package/dist/render-worker-host-D7EpeMT0.js +27 -0
- package/dist/render-worker-host-DcreJHMg.js +27 -0
- package/dist/render-worker-host-Dg-fxkvs.js +27 -0
- package/dist/{src-B06n2_Dm.js → src-Csbp6xwR.js} +763 -644
- package/dist/types/docx.d.ts +38 -0
- package/dist/types/index.d.ts +130 -10
- package/dist/types/pptx.d.ts +38 -4
- package/dist/types/xlsx.d.ts +51 -6
- package/dist/{xlsx-DWmV5sAA.js → xlsx-BcQbbV_c.js} +877 -815
- package/dist/xlsx.mjs +2 -2
- package/package.json +1 -1
- package/dist/docx-BBTq20zc.js +0 -1811
package/dist/types/docx.d.ts
CHANGED
|
@@ -151,6 +151,7 @@ export declare type DocRun = {
|
|
|
151
151
|
nodes: MathNode[];
|
|
152
152
|
display: boolean;
|
|
153
153
|
fontSize: number;
|
|
154
|
+
jc?: string;
|
|
154
155
|
};
|
|
155
156
|
|
|
156
157
|
export declare interface DocSettings {
|
|
@@ -164,6 +165,10 @@ export declare interface DocSettings {
|
|
|
164
165
|
/** §17.15.1.59 `w:noLineBreaksAfter@w:val` — custom set of characters that
|
|
165
166
|
* cannot end a line (行末禁則). Replaces the default when present. */
|
|
166
167
|
noLineBreaksAfter?: string;
|
|
168
|
+
/** §22.1.2.30 `m:mathPr/m:defJc@m:val` — document-wide default math
|
|
169
|
+
* justification (ST_Jc math: left|right|center|centerGroup). `undefined`
|
|
170
|
+
* ⇒ the renderer uses the spec default `centerGroup`. */
|
|
171
|
+
mathDefJc?: string;
|
|
167
172
|
}
|
|
168
173
|
|
|
169
174
|
export declare interface DocTable {
|
|
@@ -228,7 +233,9 @@ export declare interface DocTableRow {
|
|
|
228
233
|
|
|
229
234
|
export declare class DocxDocument {
|
|
230
235
|
private _document;
|
|
236
|
+
private _meta;
|
|
231
237
|
private _pages;
|
|
238
|
+
private _mode;
|
|
232
239
|
private _worker;
|
|
233
240
|
private _bridge;
|
|
234
241
|
private constructor();
|
|
@@ -236,6 +243,10 @@ export declare class DocxDocument {
|
|
|
236
243
|
private _parse;
|
|
237
244
|
destroy(): void;
|
|
238
245
|
get pageCount(): number;
|
|
246
|
+
/**
|
|
247
|
+
* The raw parsed document model. Available only in `mode: 'main'`; in
|
|
248
|
+
* `mode: 'worker'` the model stays in the worker and this throws.
|
|
249
|
+
*/
|
|
239
250
|
get document(): DocxDocumentModel;
|
|
240
251
|
/**
|
|
241
252
|
* ECMA-376 §17.13.4 — the document's comments (`word/comments.xml`), each with
|
|
@@ -262,6 +273,16 @@ export declare class DocxDocument {
|
|
|
262
273
|
get endnotes(): DocNote[];
|
|
263
274
|
private _getPages;
|
|
264
275
|
renderPage(target: HTMLCanvasElement | OffscreenCanvas, pageIndex: number, opts?: RenderPageOptions): Promise<void>;
|
|
276
|
+
/**
|
|
277
|
+
* Render a page and return it as an ImageBitmap. Works in both modes; in
|
|
278
|
+
* worker mode the render runs entirely off the main thread. Paint with:
|
|
279
|
+
* `canvas.getContext('bitmaprenderer').transferFromImageBitmap(bitmap)`.
|
|
280
|
+
*
|
|
281
|
+
* The returned ImageBitmap is owned by the caller: pass it to
|
|
282
|
+
* `transferFromImageBitmap` (which consumes it) or call `bitmap.close()`
|
|
283
|
+
* when done, or its backing memory is held until GC.
|
|
284
|
+
*/
|
|
285
|
+
renderPageToBitmap(pageIndex: number, opts?: WireRenderPageOptions): Promise<ImageBitmap>;
|
|
265
286
|
}
|
|
266
287
|
|
|
267
288
|
export declare interface DocxDocumentModel {
|
|
@@ -384,6 +405,12 @@ export declare class DocxViewer {
|
|
|
384
405
|
private _wrapper;
|
|
385
406
|
private _textLayer;
|
|
386
407
|
private _opts;
|
|
408
|
+
private readonly _mode;
|
|
409
|
+
/** The canvas's bitmaprenderer context, used only in worker mode (a canvas
|
|
410
|
+
* holds one context type for its lifetime; the main-mode 2d render path is
|
|
411
|
+
* never used on the same canvas). */
|
|
412
|
+
private _bitmapCtx;
|
|
413
|
+
private _warnedNoTextSelection;
|
|
387
414
|
constructor(canvas: HTMLCanvasElement, opts?: DocxViewerOptions);
|
|
388
415
|
/**
|
|
389
416
|
* Load a DOCX from URL or ArrayBuffer and render the first page.
|
|
@@ -520,6 +547,14 @@ export declare interface LoadOptions extends LoadOptions_2 {
|
|
|
520
547
|
* omitted, equations are skipped and the ~3 MB engine never enters the bundle.
|
|
521
548
|
*/
|
|
522
549
|
math?: MathRenderer;
|
|
550
|
+
/**
|
|
551
|
+
* 'main' (default): parse in a worker, render on the main thread (current
|
|
552
|
+
* behaviour). 'worker': parse, paginate AND render inside the worker; use
|
|
553
|
+
* {@link DocxDocument.renderPageToBitmap} and paint the returned ImageBitmap
|
|
554
|
+
* via an `ImageBitmapRenderingContext`. Requires OffscreenCanvas. The math
|
|
555
|
+
* engine is unavailable in this mode (equations are skipped).
|
|
556
|
+
*/
|
|
557
|
+
mode?: 'main' | 'worker';
|
|
523
558
|
}
|
|
524
559
|
|
|
525
560
|
/**
|
|
@@ -919,4 +954,7 @@ export declare interface TabStop {
|
|
|
919
954
|
leader: 'none' | 'dot' | 'hyphen' | 'underscore' | 'heavy' | 'middleDot';
|
|
920
955
|
}
|
|
921
956
|
|
|
957
|
+
/** Serializable subset of RenderPageOptions (callbacks cannot cross the wire). */
|
|
958
|
+
export declare type WireRenderPageOptions = Omit<RenderPageOptions, 'onTextRun'>;
|
|
959
|
+
|
|
922
960
|
export { }
|
package/dist/types/index.d.ts
CHANGED
|
@@ -976,6 +976,7 @@ declare type DocRun = {
|
|
|
976
976
|
nodes: MathNode[];
|
|
977
977
|
display: boolean;
|
|
978
978
|
fontSize: number;
|
|
979
|
+
jc?: string;
|
|
979
980
|
};
|
|
980
981
|
|
|
981
982
|
declare interface DocSettings {
|
|
@@ -989,6 +990,10 @@ declare interface DocSettings {
|
|
|
989
990
|
/** §17.15.1.59 `w:noLineBreaksAfter@w:val` — custom set of characters that
|
|
990
991
|
* cannot end a line (行末禁則). Replaces the default when present. */
|
|
991
992
|
noLineBreaksAfter?: string;
|
|
993
|
+
/** §22.1.2.30 `m:mathPr/m:defJc@m:val` — document-wide default math
|
|
994
|
+
* justification (ST_Jc math: left|right|center|centerGroup). `undefined`
|
|
995
|
+
* ⇒ the renderer uses the spec default `centerGroup`. */
|
|
996
|
+
mathDefJc?: string;
|
|
992
997
|
}
|
|
993
998
|
|
|
994
999
|
declare interface DocTable {
|
|
@@ -1055,6 +1060,7 @@ export declare namespace docx {
|
|
|
1055
1060
|
export {
|
|
1056
1061
|
DocxDocument,
|
|
1057
1062
|
LoadOptions_4 as LoadOptions,
|
|
1063
|
+
WireRenderPageOptions,
|
|
1058
1064
|
DocxViewer,
|
|
1059
1065
|
DocxViewerOptions,
|
|
1060
1066
|
autoResize,
|
|
@@ -1100,7 +1106,9 @@ export declare namespace docx {
|
|
|
1100
1106
|
|
|
1101
1107
|
declare class DocxDocument {
|
|
1102
1108
|
private _document;
|
|
1109
|
+
private _meta;
|
|
1103
1110
|
private _pages;
|
|
1111
|
+
private _mode;
|
|
1104
1112
|
private _worker;
|
|
1105
1113
|
private _bridge;
|
|
1106
1114
|
private constructor();
|
|
@@ -1108,6 +1116,10 @@ declare class DocxDocument {
|
|
|
1108
1116
|
private _parse;
|
|
1109
1117
|
destroy(): void;
|
|
1110
1118
|
get pageCount(): number;
|
|
1119
|
+
/**
|
|
1120
|
+
* The raw parsed document model. Available only in `mode: 'main'`; in
|
|
1121
|
+
* `mode: 'worker'` the model stays in the worker and this throws.
|
|
1122
|
+
*/
|
|
1111
1123
|
get document(): DocxDocumentModel;
|
|
1112
1124
|
/**
|
|
1113
1125
|
* ECMA-376 §17.13.4 — the document's comments (`word/comments.xml`), each with
|
|
@@ -1134,6 +1146,16 @@ declare class DocxDocument {
|
|
|
1134
1146
|
get endnotes(): DocNote[];
|
|
1135
1147
|
private _getPages;
|
|
1136
1148
|
renderPage(target: HTMLCanvasElement | OffscreenCanvas, pageIndex: number, opts?: RenderPageOptions): Promise<void>;
|
|
1149
|
+
/**
|
|
1150
|
+
* Render a page and return it as an ImageBitmap. Works in both modes; in
|
|
1151
|
+
* worker mode the render runs entirely off the main thread. Paint with:
|
|
1152
|
+
* `canvas.getContext('bitmaprenderer').transferFromImageBitmap(bitmap)`.
|
|
1153
|
+
*
|
|
1154
|
+
* The returned ImageBitmap is owned by the caller: pass it to
|
|
1155
|
+
* `transferFromImageBitmap` (which consumes it) or call `bitmap.close()`
|
|
1156
|
+
* when done, or its backing memory is held until GC.
|
|
1157
|
+
*/
|
|
1158
|
+
renderPageToBitmap(pageIndex: number, opts?: WireRenderPageOptions): Promise<ImageBitmap>;
|
|
1137
1159
|
}
|
|
1138
1160
|
|
|
1139
1161
|
declare interface DocxDocumentModel {
|
|
@@ -1256,6 +1278,12 @@ declare class DocxViewer {
|
|
|
1256
1278
|
private _wrapper;
|
|
1257
1279
|
private _textLayer;
|
|
1258
1280
|
private _opts;
|
|
1281
|
+
private readonly _mode;
|
|
1282
|
+
/** The canvas's bitmaprenderer context, used only in worker mode (a canvas
|
|
1283
|
+
* holds one context type for its lifetime; the main-mode 2d render path is
|
|
1284
|
+
* never used on the same canvas). */
|
|
1285
|
+
private _bitmapCtx;
|
|
1286
|
+
private _warnedNoTextSelection;
|
|
1259
1287
|
constructor(canvas: HTMLCanvasElement, opts?: DocxViewerOptions);
|
|
1260
1288
|
/**
|
|
1261
1289
|
* Load a DOCX from URL or ArrayBuffer and render the first page.
|
|
@@ -1571,9 +1599,16 @@ declare interface LineSpacing {
|
|
|
1571
1599
|
explicit?: boolean;
|
|
1572
1600
|
}
|
|
1573
1601
|
|
|
1574
|
-
/** Options for {@link PptxPresentation.load}.
|
|
1575
|
-
|
|
1576
|
-
|
|
1602
|
+
/** Options for {@link PptxPresentation.load}. */
|
|
1603
|
+
declare type LoadOptions = LoadOptions_2 & {
|
|
1604
|
+
/**
|
|
1605
|
+
* 'main' (default): parse in a worker, render on the main thread (current
|
|
1606
|
+
* behaviour). 'worker': parse AND render inside the worker; use
|
|
1607
|
+
* {@link PptxPresentation.renderSlideToBitmap} and paint the returned
|
|
1608
|
+
* ImageBitmap via an `ImageBitmapRenderingContext`. Requires OffscreenCanvas.
|
|
1609
|
+
*/
|
|
1610
|
+
mode?: 'main' | 'worker';
|
|
1611
|
+
};
|
|
1577
1612
|
|
|
1578
1613
|
/**
|
|
1579
1614
|
* Common load-time options shared by the docx / pptx / xlsx
|
|
@@ -1615,9 +1650,19 @@ declare interface LoadOptions_2 {
|
|
|
1615
1650
|
math?: MathRenderer;
|
|
1616
1651
|
}
|
|
1617
1652
|
|
|
1618
|
-
/** Options for {@link XlsxWorkbook.load}.
|
|
1619
|
-
* `@silurus/ooxml-core` (`useGoogleFonts`, `maxZipEntryBytes`)
|
|
1620
|
-
|
|
1653
|
+
/** Options for {@link XlsxWorkbook.load}. Extends the shared load-options type
|
|
1654
|
+
* from `@silurus/ooxml-core` (`useGoogleFonts`, `maxZipEntryBytes`, `math`)
|
|
1655
|
+
* with the worker-rendering mode. */
|
|
1656
|
+
declare interface LoadOptions_3 extends LoadOptions_2 {
|
|
1657
|
+
/**
|
|
1658
|
+
* 'main' (default): parse in a worker, render on the main thread (current
|
|
1659
|
+
* behaviour). 'worker': parse AND render inside the worker; use
|
|
1660
|
+
* {@link XlsxWorkbook.renderViewportToBitmap} and paint the returned
|
|
1661
|
+
* ImageBitmap via an `ImageBitmapRenderingContext`. Requires OffscreenCanvas.
|
|
1662
|
+
* The math engine is unavailable in this mode (equations are skipped).
|
|
1663
|
+
*/
|
|
1664
|
+
mode?: 'main' | 'worker';
|
|
1665
|
+
}
|
|
1621
1666
|
|
|
1622
1667
|
/** Options for {@link DocxDocument.load}. Extends the shared load-options type
|
|
1623
1668
|
* from `@silurus/ooxml-core` (`useGoogleFonts`, `maxZipEntryBytes`) with the
|
|
@@ -1629,6 +1674,14 @@ declare interface LoadOptions_4 extends LoadOptions_2 {
|
|
|
1629
1674
|
* omitted, equations are skipped and the ~3 MB engine never enters the bundle.
|
|
1630
1675
|
*/
|
|
1631
1676
|
math?: MathRenderer;
|
|
1677
|
+
/**
|
|
1678
|
+
* 'main' (default): parse in a worker, render on the main thread (current
|
|
1679
|
+
* behaviour). 'worker': parse, paginate AND render inside the worker; use
|
|
1680
|
+
* {@link DocxDocument.renderPageToBitmap} and paint the returned ImageBitmap
|
|
1681
|
+
* via an `ImageBitmapRenderingContext`. Requires OffscreenCanvas. The math
|
|
1682
|
+
* engine is unavailable in this mode (equations are skipped).
|
|
1683
|
+
*/
|
|
1684
|
+
mode?: 'main' | 'worker';
|
|
1632
1685
|
}
|
|
1633
1686
|
|
|
1634
1687
|
declare interface ManualLayout {
|
|
@@ -2076,6 +2129,7 @@ export declare namespace pptx {
|
|
|
2076
2129
|
PptxPresentation,
|
|
2077
2130
|
LoadOptions,
|
|
2078
2131
|
RenderSlideOptions,
|
|
2132
|
+
RenderSlideToBitmapOptions,
|
|
2079
2133
|
renderSlide,
|
|
2080
2134
|
RenderOptions,
|
|
2081
2135
|
PptxTextRunInfo,
|
|
@@ -2157,7 +2211,9 @@ declare interface PptxComment {
|
|
|
2157
2211
|
declare class PptxPresentation {
|
|
2158
2212
|
private readonly _worker;
|
|
2159
2213
|
private readonly _bridge;
|
|
2214
|
+
private _mode;
|
|
2160
2215
|
private _presentation;
|
|
2216
|
+
private _meta;
|
|
2161
2217
|
private _mediaCache;
|
|
2162
2218
|
private _workerReady;
|
|
2163
2219
|
private _workerReadyCallbacks;
|
|
@@ -2197,7 +2253,17 @@ declare class PptxPresentation {
|
|
|
2197
2253
|
*/
|
|
2198
2254
|
getNotes(slideIndex: number): string | null;
|
|
2199
2255
|
/** Render a slide onto the given canvas. */
|
|
2200
|
-
renderSlide(canvas: HTMLCanvasElement, slideIndex: number, opts?: RenderSlideOptions): Promise<void>;
|
|
2256
|
+
renderSlide(canvas: HTMLCanvasElement | OffscreenCanvas, slideIndex: number, opts?: RenderSlideOptions): Promise<void>;
|
|
2257
|
+
/**
|
|
2258
|
+
* Render a slide and return it as an ImageBitmap. Works in both modes; in
|
|
2259
|
+
* worker mode the entire render runs off the main thread. Paint with:
|
|
2260
|
+
* `canvas.getContext('bitmaprenderer').transferFromImageBitmap(bitmap)`.
|
|
2261
|
+
*
|
|
2262
|
+
* The returned ImageBitmap is owned by the caller: pass it to
|
|
2263
|
+
* `transferFromImageBitmap` (which consumes it) or call `bitmap.close()`
|
|
2264
|
+
* when done, or its backing memory is held until GC.
|
|
2265
|
+
*/
|
|
2266
|
+
renderSlideToBitmap(slideIndex: number, opts?: RenderSlideToBitmapOptions): Promise<ImageBitmap>;
|
|
2201
2267
|
/**
|
|
2202
2268
|
* Extract raw media bytes for a zip path referenced by {@link MediaElement}.
|
|
2203
2269
|
* Results are cached by path for the lifetime of this instance.
|
|
@@ -2265,6 +2331,12 @@ declare class PptxViewer {
|
|
|
2265
2331
|
private readonly opts;
|
|
2266
2332
|
private currentSlide;
|
|
2267
2333
|
private handle;
|
|
2334
|
+
private readonly _mode;
|
|
2335
|
+
/** The canvas's bitmaprenderer context, used only by the static worker-mode
|
|
2336
|
+
* render path. The media-playback path keeps a 2d context (via presentSlide),
|
|
2337
|
+
* so this is obtained only when worker mode renders without media playback. */
|
|
2338
|
+
private _bitmapCtx;
|
|
2339
|
+
private _warnedNoTextSelection;
|
|
2268
2340
|
constructor(canvas: HTMLCanvasElement, opts?: PptxViewerOptions);
|
|
2269
2341
|
/**
|
|
2270
2342
|
* Load a PPTX from URL or ArrayBuffer and render the first slide.
|
|
@@ -2431,6 +2503,15 @@ declare interface RenderSlideOptions {
|
|
|
2431
2503
|
skipMediaControls?: boolean;
|
|
2432
2504
|
}
|
|
2433
2505
|
|
|
2506
|
+
/** Options for {@link PptxPresentation.renderSlideToBitmap}. */
|
|
2507
|
+
declare interface RenderSlideToBitmapOptions {
|
|
2508
|
+
/** Slide width in CSS pixels. Defaults to 960. */
|
|
2509
|
+
width?: number;
|
|
2510
|
+
/** Device pixel ratio. Defaults to window.devicePixelRatio (workers have none). */
|
|
2511
|
+
dpr?: number;
|
|
2512
|
+
/* Excluded from this release type: skipMediaControls */
|
|
2513
|
+
}
|
|
2514
|
+
|
|
2434
2515
|
declare interface RenderViewportOptions {
|
|
2435
2516
|
width?: number;
|
|
2436
2517
|
height?: number;
|
|
@@ -2443,8 +2524,8 @@ declare interface RenderViewportOptions {
|
|
|
2443
2524
|
freezeCols?: number;
|
|
2444
2525
|
/** Scale factor applied to all cell/header dimensions (default 1). */
|
|
2445
2526
|
cellScale?: number;
|
|
2446
|
-
/** Pre-
|
|
2447
|
-
loadedImages?: Map<string,
|
|
2527
|
+
/** Pre-decoded image sources keyed by their dataUrl (for ImageAnchor rendering). */
|
|
2528
|
+
loadedImages?: Map<string, CanvasImageSource>;
|
|
2448
2529
|
/** Called once per cell that contains text, with canvas-pixel position and cell address. */
|
|
2449
2530
|
onTextRun?: (info: XlsxTextRunInfo) => void;
|
|
2450
2531
|
/** Highlighted row range for selected row headers (1-indexed inclusive).
|
|
@@ -3317,6 +3398,13 @@ declare interface ViewportRange {
|
|
|
3317
3398
|
cols: number;
|
|
3318
3399
|
}
|
|
3319
3400
|
|
|
3401
|
+
/** Serializable subset of RenderPageOptions (callbacks cannot cross the wire). */
|
|
3402
|
+
declare type WireRenderPageOptions = Omit<RenderPageOptions, 'onTextRun'>;
|
|
3403
|
+
|
|
3404
|
+
/** Serializable subset of RenderViewportOptions: drop the callback and the
|
|
3405
|
+
* image cache (the worker owns its own). */
|
|
3406
|
+
declare type WireRenderViewportOptions = Omit<RenderViewportOptions, 'onTextRun' | 'loadedImages'>;
|
|
3407
|
+
|
|
3320
3408
|
declare interface Workbook {
|
|
3321
3409
|
sheets: SheetMeta[];
|
|
3322
3410
|
}
|
|
@@ -3397,6 +3485,7 @@ export declare namespace xlsx {
|
|
|
3397
3485
|
export {
|
|
3398
3486
|
XlsxWorkbook,
|
|
3399
3487
|
LoadOptions_3 as LoadOptions,
|
|
3488
|
+
WireRenderViewportOptions,
|
|
3400
3489
|
XlsxViewer,
|
|
3401
3490
|
ResolvedList,
|
|
3402
3491
|
XlsxViewerOptions,
|
|
@@ -3563,6 +3652,12 @@ declare class XlsxViewer {
|
|
|
3563
3652
|
private currentSheet;
|
|
3564
3653
|
private currentWorksheet;
|
|
3565
3654
|
private opts;
|
|
3655
|
+
/** 'main' renders on this thread; 'worker' paints worker-produced bitmaps. */
|
|
3656
|
+
private readonly _mode;
|
|
3657
|
+
/** The canvas's bitmaprenderer context, used only in worker mode. A canvas
|
|
3658
|
+
* holds one context type for its lifetime, so this is obtained once and the
|
|
3659
|
+
* main-mode 2d render path is never used on the same canvas. */
|
|
3660
|
+
private _bitmapCtx;
|
|
3566
3661
|
private resizeObserver;
|
|
3567
3662
|
/**
|
|
3568
3663
|
* Start-anchored horizontal scroll position (the {@link effectiveScrollLeft}
|
|
@@ -3817,6 +3912,15 @@ declare interface XlsxViewerOptions {
|
|
|
3817
3912
|
* dependency-injection contract as the docx/pptx viewers.
|
|
3818
3913
|
*/
|
|
3819
3914
|
math?: MathRenderer;
|
|
3915
|
+
/**
|
|
3916
|
+
* `'main'` (default): parse in a worker, render on the main thread. `'worker'`:
|
|
3917
|
+
* parse AND render entirely inside the worker and paint the returned
|
|
3918
|
+
* ImageBitmap onto the viewer's canvas, so document rendering never blocks the
|
|
3919
|
+
* UI thread. All interaction (scroll, sheet tabs, frozen panes, zoom, cell
|
|
3920
|
+
* selection) is unchanged. Requires `Worker` + `OffscreenCanvas`. Equations
|
|
3921
|
+
* require `'main'` (the math engine cannot cross the worker boundary).
|
|
3922
|
+
*/
|
|
3923
|
+
mode?: 'main' | 'worker';
|
|
3820
3924
|
}
|
|
3821
3925
|
|
|
3822
3926
|
declare class XlsxWorkbook {
|
|
@@ -3824,7 +3928,7 @@ declare class XlsxWorkbook {
|
|
|
3824
3928
|
private bridge;
|
|
3825
3929
|
private parsedWorkbook;
|
|
3826
3930
|
private sheetCache;
|
|
3827
|
-
/** Cache of
|
|
3931
|
+
/** Cache of decoded image bitmaps keyed by their data URL. Shared across sheets. */
|
|
3828
3932
|
private imageCache;
|
|
3829
3933
|
private rawData;
|
|
3830
3934
|
private maxZipEntryBytes;
|
|
@@ -3832,6 +3936,7 @@ declare class XlsxWorkbook {
|
|
|
3832
3936
|
* `renderViewport` call reuses it — equations in shapes render when present,
|
|
3833
3937
|
* and are skipped (engine tree-shaken) when omitted. */
|
|
3834
3938
|
private math;
|
|
3939
|
+
private _mode;
|
|
3835
3940
|
private constructor();
|
|
3836
3941
|
/** Parse an XLSX from a URL or ArrayBuffer. */
|
|
3837
3942
|
static load(source: string | ArrayBuffer, opts?: LoadOptions_3): Promise<XlsxWorkbook>;
|
|
@@ -3859,6 +3964,21 @@ declare class XlsxWorkbook {
|
|
|
3859
3964
|
*/
|
|
3860
3965
|
resolveValidationList(sheetIndex: number, formula1: string | undefined): Promise<ResolvedList>;
|
|
3861
3966
|
renderViewport(target: HTMLCanvasElement | OffscreenCanvas, sheetIndex: number, viewport: ViewportRange, opts?: RenderViewportOptions): Promise<void>;
|
|
3967
|
+
/**
|
|
3968
|
+
* Render a sheet viewport and return it as an ImageBitmap (both modes; in
|
|
3969
|
+
* worker mode the render runs entirely off the main thread). `opts.width` /
|
|
3970
|
+
* `opts.height` are required: there is no DOM element to measure in a worker
|
|
3971
|
+
* or on an OffscreenCanvas. Paint with
|
|
3972
|
+
* `canvas.getContext('bitmaprenderer').transferFromImageBitmap(bitmap)`.
|
|
3973
|
+
*
|
|
3974
|
+
* The returned ImageBitmap is owned by the caller: pass it to
|
|
3975
|
+
* `transferFromImageBitmap` (which consumes it) or call `bitmap.close()`
|
|
3976
|
+
* when done, or its backing memory is held until GC.
|
|
3977
|
+
*/
|
|
3978
|
+
renderViewportToBitmap(sheetIndex: number, viewport: ViewportRange, opts: WireRenderViewportOptions & {
|
|
3979
|
+
width: number;
|
|
3980
|
+
height: number;
|
|
3981
|
+
}): Promise<ImageBitmap>;
|
|
3862
3982
|
destroy(): void;
|
|
3863
3983
|
}
|
|
3864
3984
|
|
package/dist/types/pptx.d.ts
CHANGED
|
@@ -604,9 +604,16 @@ export declare interface LineBreak {
|
|
|
604
604
|
type: 'break';
|
|
605
605
|
}
|
|
606
606
|
|
|
607
|
-
/** Options for {@link PptxPresentation.load}.
|
|
608
|
-
|
|
609
|
-
|
|
607
|
+
/** Options for {@link PptxPresentation.load}. */
|
|
608
|
+
export declare type LoadOptions = LoadOptions_2 & {
|
|
609
|
+
/**
|
|
610
|
+
* 'main' (default): parse in a worker, render on the main thread (current
|
|
611
|
+
* behaviour). 'worker': parse AND render inside the worker; use
|
|
612
|
+
* {@link PptxPresentation.renderSlideToBitmap} and paint the returned
|
|
613
|
+
* ImageBitmap via an `ImageBitmapRenderingContext`. Requires OffscreenCanvas.
|
|
614
|
+
*/
|
|
615
|
+
mode?: 'main' | 'worker';
|
|
616
|
+
};
|
|
610
617
|
|
|
611
618
|
/**
|
|
612
619
|
* Common load-time options shared by the docx / pptx / xlsx
|
|
@@ -980,7 +987,9 @@ export declare interface PptxComment {
|
|
|
980
987
|
export declare class PptxPresentation {
|
|
981
988
|
private readonly _worker;
|
|
982
989
|
private readonly _bridge;
|
|
990
|
+
private _mode;
|
|
983
991
|
private _presentation;
|
|
992
|
+
private _meta;
|
|
984
993
|
private _mediaCache;
|
|
985
994
|
private _workerReady;
|
|
986
995
|
private _workerReadyCallbacks;
|
|
@@ -1020,7 +1029,17 @@ export declare class PptxPresentation {
|
|
|
1020
1029
|
*/
|
|
1021
1030
|
getNotes(slideIndex: number): string | null;
|
|
1022
1031
|
/** Render a slide onto the given canvas. */
|
|
1023
|
-
renderSlide(canvas: HTMLCanvasElement, slideIndex: number, opts?: RenderSlideOptions): Promise<void>;
|
|
1032
|
+
renderSlide(canvas: HTMLCanvasElement | OffscreenCanvas, slideIndex: number, opts?: RenderSlideOptions): Promise<void>;
|
|
1033
|
+
/**
|
|
1034
|
+
* Render a slide and return it as an ImageBitmap. Works in both modes; in
|
|
1035
|
+
* worker mode the entire render runs off the main thread. Paint with:
|
|
1036
|
+
* `canvas.getContext('bitmaprenderer').transferFromImageBitmap(bitmap)`.
|
|
1037
|
+
*
|
|
1038
|
+
* The returned ImageBitmap is owned by the caller: pass it to
|
|
1039
|
+
* `transferFromImageBitmap` (which consumes it) or call `bitmap.close()`
|
|
1040
|
+
* when done, or its backing memory is held until GC.
|
|
1041
|
+
*/
|
|
1042
|
+
renderSlideToBitmap(slideIndex: number, opts?: RenderSlideToBitmapOptions): Promise<ImageBitmap>;
|
|
1024
1043
|
/**
|
|
1025
1044
|
* Extract raw media bytes for a zip path referenced by {@link MediaElement}.
|
|
1026
1045
|
* Results are cached by path for the lifetime of this instance.
|
|
@@ -1088,6 +1107,12 @@ export declare class PptxViewer {
|
|
|
1088
1107
|
private readonly opts;
|
|
1089
1108
|
private currentSlide;
|
|
1090
1109
|
private handle;
|
|
1110
|
+
private readonly _mode;
|
|
1111
|
+
/** The canvas's bitmaprenderer context, used only by the static worker-mode
|
|
1112
|
+
* render path. The media-playback path keeps a 2d context (via presentSlide),
|
|
1113
|
+
* so this is obtained only when worker mode renders without media playback. */
|
|
1114
|
+
private _bitmapCtx;
|
|
1115
|
+
private _warnedNoTextSelection;
|
|
1091
1116
|
constructor(canvas: HTMLCanvasElement, opts?: PptxViewerOptions);
|
|
1092
1117
|
/**
|
|
1093
1118
|
* Load a PPTX from URL or ArrayBuffer and render the first slide.
|
|
@@ -1233,6 +1258,15 @@ export declare interface RenderSlideOptions {
|
|
|
1233
1258
|
skipMediaControls?: boolean;
|
|
1234
1259
|
}
|
|
1235
1260
|
|
|
1261
|
+
/** Options for {@link PptxPresentation.renderSlideToBitmap}. */
|
|
1262
|
+
export declare interface RenderSlideToBitmapOptions {
|
|
1263
|
+
/** Slide width in CSS pixels. Defaults to 960. */
|
|
1264
|
+
width?: number;
|
|
1265
|
+
/** Device pixel ratio. Defaults to window.devicePixelRatio (workers have none). */
|
|
1266
|
+
dpr?: number;
|
|
1267
|
+
/* Excluded from this release type: skipMediaControls */
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1236
1270
|
/**
|
|
1237
1271
|
* 3D rotation in sphere coordinates — ECMA-376 §20.1.5.11 (`CT_SphereCoords`).
|
|
1238
1272
|
* Angles are in **degrees** (the XML carries 60000ths of a degree; the parser
|
package/dist/types/xlsx.d.ts
CHANGED
|
@@ -456,9 +456,19 @@ export declare interface LegendManualLayout {
|
|
|
456
456
|
h: number;
|
|
457
457
|
}
|
|
458
458
|
|
|
459
|
-
/** Options for {@link XlsxWorkbook.load}.
|
|
460
|
-
* `@silurus/ooxml-core` (`useGoogleFonts`, `maxZipEntryBytes`)
|
|
461
|
-
|
|
459
|
+
/** Options for {@link XlsxWorkbook.load}. Extends the shared load-options type
|
|
460
|
+
* from `@silurus/ooxml-core` (`useGoogleFonts`, `maxZipEntryBytes`, `math`)
|
|
461
|
+
* with the worker-rendering mode. */
|
|
462
|
+
export declare interface LoadOptions extends LoadOptions_2 {
|
|
463
|
+
/**
|
|
464
|
+
* 'main' (default): parse in a worker, render on the main thread (current
|
|
465
|
+
* behaviour). 'worker': parse AND render inside the worker; use
|
|
466
|
+
* {@link XlsxWorkbook.renderViewportToBitmap} and paint the returned
|
|
467
|
+
* ImageBitmap via an `ImageBitmapRenderingContext`. Requires OffscreenCanvas.
|
|
468
|
+
* The math engine is unavailable in this mode (equations are skipped).
|
|
469
|
+
*/
|
|
470
|
+
mode?: 'main' | 'worker';
|
|
471
|
+
}
|
|
462
472
|
|
|
463
473
|
/**
|
|
464
474
|
* Common load-time options shared by the docx / pptx / xlsx
|
|
@@ -714,8 +724,8 @@ export declare interface RenderViewportOptions {
|
|
|
714
724
|
freezeCols?: number;
|
|
715
725
|
/** Scale factor applied to all cell/header dimensions (default 1). */
|
|
716
726
|
cellScale?: number;
|
|
717
|
-
/** Pre-
|
|
718
|
-
loadedImages?: Map<string,
|
|
727
|
+
/** Pre-decoded image sources keyed by their dataUrl (for ImageAnchor rendering). */
|
|
728
|
+
loadedImages?: Map<string, CanvasImageSource>;
|
|
719
729
|
/** Called once per cell that contains text, with canvas-pixel position and cell address. */
|
|
720
730
|
onTextRun?: (info: XlsxTextRunInfo) => void;
|
|
721
731
|
/** Highlighted row range for selected row headers (1-indexed inclusive).
|
|
@@ -1044,6 +1054,10 @@ export declare interface ViewportRange {
|
|
|
1044
1054
|
cols: number;
|
|
1045
1055
|
}
|
|
1046
1056
|
|
|
1057
|
+
/** Serializable subset of RenderViewportOptions: drop the callback and the
|
|
1058
|
+
* image cache (the worker owns its own). */
|
|
1059
|
+
export declare type WireRenderViewportOptions = Omit<RenderViewportOptions, 'onTextRun' | 'loadedImages'>;
|
|
1060
|
+
|
|
1047
1061
|
export declare interface Workbook {
|
|
1048
1062
|
sheets: SheetMeta[];
|
|
1049
1063
|
}
|
|
@@ -1219,6 +1233,12 @@ export declare class XlsxViewer {
|
|
|
1219
1233
|
private currentSheet;
|
|
1220
1234
|
private currentWorksheet;
|
|
1221
1235
|
private opts;
|
|
1236
|
+
/** 'main' renders on this thread; 'worker' paints worker-produced bitmaps. */
|
|
1237
|
+
private readonly _mode;
|
|
1238
|
+
/** The canvas's bitmaprenderer context, used only in worker mode. A canvas
|
|
1239
|
+
* holds one context type for its lifetime, so this is obtained once and the
|
|
1240
|
+
* main-mode 2d render path is never used on the same canvas. */
|
|
1241
|
+
private _bitmapCtx;
|
|
1222
1242
|
private resizeObserver;
|
|
1223
1243
|
/**
|
|
1224
1244
|
* Start-anchored horizontal scroll position (the {@link effectiveScrollLeft}
|
|
@@ -1473,6 +1493,15 @@ export declare interface XlsxViewerOptions {
|
|
|
1473
1493
|
* dependency-injection contract as the docx/pptx viewers.
|
|
1474
1494
|
*/
|
|
1475
1495
|
math?: MathRenderer;
|
|
1496
|
+
/**
|
|
1497
|
+
* `'main'` (default): parse in a worker, render on the main thread. `'worker'`:
|
|
1498
|
+
* parse AND render entirely inside the worker and paint the returned
|
|
1499
|
+
* ImageBitmap onto the viewer's canvas, so document rendering never blocks the
|
|
1500
|
+
* UI thread. All interaction (scroll, sheet tabs, frozen panes, zoom, cell
|
|
1501
|
+
* selection) is unchanged. Requires `Worker` + `OffscreenCanvas`. Equations
|
|
1502
|
+
* require `'main'` (the math engine cannot cross the worker boundary).
|
|
1503
|
+
*/
|
|
1504
|
+
mode?: 'main' | 'worker';
|
|
1476
1505
|
}
|
|
1477
1506
|
|
|
1478
1507
|
export declare class XlsxWorkbook {
|
|
@@ -1480,7 +1509,7 @@ export declare class XlsxWorkbook {
|
|
|
1480
1509
|
private bridge;
|
|
1481
1510
|
private parsedWorkbook;
|
|
1482
1511
|
private sheetCache;
|
|
1483
|
-
/** Cache of
|
|
1512
|
+
/** Cache of decoded image bitmaps keyed by their data URL. Shared across sheets. */
|
|
1484
1513
|
private imageCache;
|
|
1485
1514
|
private rawData;
|
|
1486
1515
|
private maxZipEntryBytes;
|
|
@@ -1488,6 +1517,7 @@ export declare class XlsxWorkbook {
|
|
|
1488
1517
|
* `renderViewport` call reuses it — equations in shapes render when present,
|
|
1489
1518
|
* and are skipped (engine tree-shaken) when omitted. */
|
|
1490
1519
|
private math;
|
|
1520
|
+
private _mode;
|
|
1491
1521
|
private constructor();
|
|
1492
1522
|
/** Parse an XLSX from a URL or ArrayBuffer. */
|
|
1493
1523
|
static load(source: string | ArrayBuffer, opts?: LoadOptions): Promise<XlsxWorkbook>;
|
|
@@ -1515,6 +1545,21 @@ export declare class XlsxWorkbook {
|
|
|
1515
1545
|
*/
|
|
1516
1546
|
resolveValidationList(sheetIndex: number, formula1: string | undefined): Promise<ResolvedList>;
|
|
1517
1547
|
renderViewport(target: HTMLCanvasElement | OffscreenCanvas, sheetIndex: number, viewport: ViewportRange, opts?: RenderViewportOptions): Promise<void>;
|
|
1548
|
+
/**
|
|
1549
|
+
* Render a sheet viewport and return it as an ImageBitmap (both modes; in
|
|
1550
|
+
* worker mode the render runs entirely off the main thread). `opts.width` /
|
|
1551
|
+
* `opts.height` are required: there is no DOM element to measure in a worker
|
|
1552
|
+
* or on an OffscreenCanvas. Paint with
|
|
1553
|
+
* `canvas.getContext('bitmaprenderer').transferFromImageBitmap(bitmap)`.
|
|
1554
|
+
*
|
|
1555
|
+
* The returned ImageBitmap is owned by the caller: pass it to
|
|
1556
|
+
* `transferFromImageBitmap` (which consumes it) or call `bitmap.close()`
|
|
1557
|
+
* when done, or its backing memory is held until GC.
|
|
1558
|
+
*/
|
|
1559
|
+
renderViewportToBitmap(sheetIndex: number, viewport: ViewportRange, opts: WireRenderViewportOptions & {
|
|
1560
|
+
width: number;
|
|
1561
|
+
height: number;
|
|
1562
|
+
}): Promise<ImageBitmap>;
|
|
1518
1563
|
destroy(): void;
|
|
1519
1564
|
}
|
|
1520
1565
|
|