@silurus/ooxml 0.62.0 → 0.64.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.
@@ -462,8 +462,20 @@ export declare interface ImageAnchor {
462
462
  * size. Authoritative when `editAs === "oneCell"`. 0 = unavailable. */
463
463
  nativeExtCx: number;
464
464
  nativeExtCy: number;
465
- /** Data URL (data:image/png;base64,...) */
466
- dataUrl: string;
465
+ /** Zip path of the blip inside the package (e.g. `xl/media/image1.png`). The
466
+ * blip's own `r:embed` raster fallback when an svgBlip extension is present;
467
+ * otherwise the only source. Falls back to the SVG part itself when the
468
+ * picture has no raster `r:embed`. Bytes are fetched lazily by path. */
469
+ imagePath: string;
470
+ /** MIME type of the blip at {@link ImageAnchor.imagePath} (e.g. `image/png`,
471
+ * or `image/svg+xml` for the SVG-only fallback). */
472
+ mimeType: string;
473
+ /** Vector original from the Microsoft `asvg:svgBlip` extension (MS-ODRAWXML),
474
+ * as a zip path. Preferred over `imagePath` (the raster fallback, or the SVG
475
+ * itself when no raster blip is embedded). Absent when the picture carries no
476
+ * svgBlip extension. Its MIME is always `image/svg+xml` and is owned by the
477
+ * SVG decoder. */
478
+ svgImagePath?: string;
467
479
  }
468
480
 
469
481
  export declare interface LegendManualLayout {
@@ -743,8 +755,15 @@ export declare interface RenderViewportOptions {
743
755
  freezeCols?: number;
744
756
  /** Scale factor applied to all cell/header dimensions (default 1). */
745
757
  cellScale?: number;
746
- /** Pre-decoded image sources keyed by their dataUrl (for ImageAnchor rendering). */
758
+ /** Pre-decoded image sources keyed by their zip `imagePath` (for ImageAnchor
759
+ * and group-leaf image rendering). */
747
760
  loadedImages?: Map<string, CanvasImageSource>;
761
+ /** Fetch an embedded image's bytes by zip path, wrapped in a Blob of the given
762
+ * MIME (twin of pptx/docx `fetchImage`). The orchestrator decodes these into
763
+ * {@link loadedImages} before the synchronous draw. Supplied by
764
+ * {@link XlsxWorkbook} (routing through the worker) or the render worker
765
+ * (reading its retained buffer). Absent ⇒ no images are decoded. */
766
+ fetchImage?: (path: string, mimeType: string) => Promise<Blob>;
748
767
  /** Called once per cell that contains text, with canvas-pixel position and cell address. */
749
768
  onTextRun?: (info: XlsxTextRunInfo) => void;
750
769
  /** Highlighted row range for selected row headers (1-indexed inclusive).
@@ -857,12 +876,22 @@ export declare type ShapeGeom = {
857
876
  type: 'custom';
858
877
  paths: PathInfo[];
859
878
  }
860
- /** Bitmap picture leaf inside a `<xdr:grpSp>`. `dataUrl` is a pre-encoded
861
- * `data:<mime>;base64,…` produced by the Rust parser from the drawing's
862
- * relationship target. */
879
+ /** Bitmap (or vector) picture leaf inside a `<xdr:grpSp>`. `imagePath` is the
880
+ * zip path of the drawing's relationship target the blip's raster `r:embed`
881
+ * fallback, or the SVG itself when no raster is embedded — and `mimeType` its
882
+ * MIME. Bytes are fetched lazily by path; nothing is inlined as base64. */
863
883
  | {
864
884
  type: 'image';
865
- dataUrl: string;
885
+ imagePath: string;
886
+ /** MIME type of the blip at {@link imagePath} (e.g. `image/png`, or
887
+ * `image/svg+xml` for the SVG-only fallback). */
888
+ mimeType: string;
889
+ /** Vector original from the Microsoft `asvg:svgBlip` extension
890
+ * (MS-ODRAWXML), as a zip path. Prefer this over `imagePath` (the raster
891
+ * fallback, or the SVG itself when no raster blip is embedded). Absent
892
+ * when the picture carries no svgBlip extension. Its MIME is always
893
+ * `image/svg+xml` and is owned by the SVG decoder. */
894
+ svgImagePath?: string;
866
895
  };
867
896
 
868
897
  export declare interface ShapeInfo {
@@ -1073,9 +1102,10 @@ export declare interface ViewportRange {
1073
1102
  cols: number;
1074
1103
  }
1075
1104
 
1076
- /** Serializable subset of RenderViewportOptions: drop the callback and the
1077
- * image cache (the worker owns its own). */
1078
- export declare type WireRenderViewportOptions = Omit<RenderViewportOptions, 'onTextRun' | 'loadedImages'>;
1105
+ /** Serializable subset of RenderViewportOptions: drop the callback, the image
1106
+ * cache, and the `fetchImage` loader (all non-cloneable; the worker owns its
1107
+ * own cache and supplies its own in-worker fetchImage). */
1108
+ export declare type WireRenderViewportOptions = Omit<RenderViewportOptions, 'onTextRun' | 'loadedImages' | 'fetchImage'>;
1079
1109
 
1080
1110
  export declare interface Workbook {
1081
1111
  sheets: SheetMeta[];
@@ -1528,8 +1558,19 @@ export declare class XlsxWorkbook {
1528
1558
  private bridge;
1529
1559
  private parsedWorkbook;
1530
1560
  private sheetCache;
1531
- /** Cache of decoded image bitmaps keyed by their data URL. Shared across sheets. */
1561
+ /** Cache of decoded image sources keyed by their zip `imagePath`. Shared
1562
+ * across sheets. */
1532
1563
  private imageCache;
1564
+ /** Cache of fetched image *bytes* (as Blobs) keyed by zip path, populated by
1565
+ * {@link XlsxWorkbook.getImage}. Twin of pptx/docx's per-instance
1566
+ * `_imageCache`; kept separate from {@link XlsxWorkbook.imageCache} (decoded
1567
+ * sources) so each layer dedupes independently. */
1568
+ private imageBlobCache;
1569
+ /** One stable closure per instance: core's path-keyed SVG cache namespaces on
1570
+ * this identity, so two open workbooks never swap a shared zip path (e.g.
1571
+ * xl/media/image1.svg). Reusing one reference also lets the SVG cache hit
1572
+ * across viewport renders. */
1573
+ private readonly _fetchImage;
1533
1574
  private rawData;
1534
1575
  private maxZipEntryBytes;
1535
1576
  /** Opt-in OMML equation engine, injected once at {@link load}. Every
@@ -1547,6 +1588,19 @@ export declare class XlsxWorkbook {
1547
1588
  * `null` for sheets that declare no tab color. */
1548
1589
  get tabColors(): (string | null)[];
1549
1590
  getWorksheet(sheetIndex: number): Promise<Worksheet>;
1591
+ /**
1592
+ * Fetch an embedded image's bytes by zip path (e.g. `xl/media/image1.png`),
1593
+ * wrapped in a Blob of the given MIME. The bytes are pulled through the
1594
+ * persistent worker via the `extractImage` message (twin of pptx/docx's
1595
+ * `getImage`/`getMedia`); results are cached by path for the lifetime of this
1596
+ * instance. The renderer's `fetchImage` option points here so image bytes are
1597
+ * extracted lazily rather than inlined as base64 at parse time.
1598
+ *
1599
+ * Routed through the worker even though the main thread also retains
1600
+ * `rawData`, to keep all WASM `extract_image` decoding on the worker (the
1601
+ * route-through-worker decision).
1602
+ */
1603
+ getImage(imagePath: string, mimeType: string): Promise<Blob>;
1550
1604
  /**
1551
1605
  * Resolve a `list`-type data-validation `formula1` (ECMA-376 §18.3.1.32) into
1552
1606
  * the set of allowed values to display, evaluated relative to `sheetIndex`