@silurus/ooxml 0.74.6 → 0.75.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 (47) hide show
  1. package/README.md +105 -6
  2. package/dist/bounded-raw-part-cache-BTfZD_Sz.js +1248 -0
  3. package/dist/{docx-DftZMp7R.js → document-pull-client-H80_E10V.js} +11165 -11517
  4. package/dist/docx-BX0mJqS1.js +1274 -0
  5. package/dist/docx.mjs +6 -3
  6. package/dist/docx_parser_bg.wasm +0 -0
  7. package/dist/duotone-bitmap-by-path-Dv5Ikbzl.js +28 -0
  8. package/dist/find-cursor-Dc5iM6s7.js +815 -0
  9. package/dist/highlight-rect-cCvVU-MW.js +48 -0
  10. package/dist/hyperlink-D85FexTa.js +27 -0
  11. package/dist/index.mjs +4 -4
  12. package/dist/{highlight-rect-IjFkGg4X.js → line-distribute-DkLgIa7B.js} +37 -84
  13. package/dist/{find-cursor-DtgyGs5V.js → line-metrics-qwIyTk7Q.js} +1169 -3641
  14. package/dist/math.mjs +1 -1
  15. package/dist/node.mjs +998 -0
  16. package/dist/pptx-BEYjiTnZ.js +822 -0
  17. package/dist/pptx-CXgyi7wu.js +1705 -0
  18. package/dist/pptx.mjs +7 -3
  19. package/dist/pptx_parser_bg.wasm +0 -0
  20. package/dist/preload-BEouWnlI.js +132 -0
  21. package/dist/render-C0wMf5eT.js +71 -0
  22. package/dist/render-worker-host-CLdOlxFu.js +27 -0
  23. package/dist/render-worker-host-DZ4u0RFs.js +27 -0
  24. package/dist/render-worker-host-s3J-mWBP.js +27 -0
  25. package/dist/renderer-CwzTv9hH.js +5225 -0
  26. package/dist/resource-measurement-6aReN3K0.js +93 -0
  27. package/dist/slide-pull-client-D_T0AIoX.js +175 -0
  28. package/dist/svg-image-by-path-C1M3N2pT.js +1623 -0
  29. package/dist/transfer-3QEJrsJa.js +6 -0
  30. package/dist/types/docx.d.ts +290 -105
  31. package/dist/types/index.d.ts +399 -142
  32. package/dist/types/math.d.ts +1 -1
  33. package/dist/types/node.d.ts +4855 -0
  34. package/dist/types/pptx.d.ts +431 -245
  35. package/dist/types/xlsx.d.ts +320 -120
  36. package/dist/visible-index-CKvgpUrf.js +17 -0
  37. package/dist/worksheet-pull-worker-DCei8u-4.js +347 -0
  38. package/dist/{xlsx-BqMHvfsE.js → xlsx-DJyPlzjB.js} +1499 -1284
  39. package/dist/xlsx.mjs +7 -3
  40. package/dist/xlsx_parser_bg.wasm +0 -0
  41. package/package.json +12 -2
  42. package/dist/pptx-qbadwIv4.js +0 -6761
  43. package/dist/render-worker-host-Bcm9j4-H.js +0 -27
  44. package/dist/render-worker-host-BqSTDaYt.js +0 -27
  45. package/dist/render-worker-host-C523QxVw.js +0 -27
  46. package/dist/visible-index-C3_3gBg-.js +0 -50
  47. /package/dist/{mathjax-BPjQ2C_j.js → mathjax-Dqo857oC.js} +0 -0
@@ -1,4 +1,4 @@
1
- //#region dist/.types-work/mathjax-6BV6bQWa.d.ts
1
+ //#region dist/.types-work/mathjax-BO1uUSCW.d.ts
2
2
  //#region packages/core/src/math/mathjax.d.ts
3
3
  interface MathSvg {
4
4
  /** standalone `<svg>…</svg>` markup. */
@@ -29,7 +29,7 @@ interface MathRenderer {
29
29
  mathMLToSvg(mathml: string): Promise<MathSvg>;
30
30
  }
31
31
  //#endregion
32
- //#region dist/.types-work/find-highlight-B8ft6Y0g.d.ts
32
+ //#region dist/.types-work/hyperlink-CHHEOeCL.d.ts
33
33
  //#region packages/core/src/types/math.d.ts
34
34
  type MathStyle = 'roman' | 'italic' | 'bold' | 'boldItalic';
35
35
  interface MathRun {
@@ -963,7 +963,157 @@ interface LegendManualLayout {
963
963
  h: number;
964
964
  }
965
965
  //#endregion
966
+ //#region packages/core/src/errors/ooxml-error.d.ts
967
+ /**
968
+ * Machine-readable code for a typed load-time failure.
969
+ *
970
+ * The container-level failures the `load()` factories detect on the main thread
971
+ * before handing bytes to the parser worker (see `sniffCfb` / `decryptOoxml`).
972
+ * This is the seed of the broader typed-error surface tracked as PD4 (OoxmlError
973
+ * typed errors). Add codes here rather than throwing bare `Error(string)`, so
974
+ * callers can `switch` on `err.code` instead of matching message text.
975
+ *
976
+ * - `'encrypted'` — password-protected, but no `password` was
977
+ * supplied (pass `LoadOptions.password` to decrypt).
978
+ * - `'invalid-password'` — a `password` was supplied but did not match.
979
+ * - `'unsupported-encryption'`— encrypted with a scheme other than Agile
980
+ * (Standard / Extensible / a legacy binary encryptor), which this library
981
+ * cannot decrypt (PD8 implements Agile only).
982
+ * - `'legacy-binary-format'` — a raw .doc / .xls / .ppt (not OOXML).
983
+ * - `'not-ooxml'` — a CFB of an unrecognised kind, or otherwise
984
+ * not an OOXML ZIP.
985
+ */
986
+ type OoxmlErrorCode = 'encrypted' | 'invalid-password' | 'unsupported-encryption' | 'legacy-binary-format' | 'not-ooxml';
987
+ type OoxmlErrorStage = 'container' | 'decompression' | 'parsing' | 'serialization' | 'layout' | 'rendering' | 'worker';
988
+ /**
989
+ * @deprecated Use {@link OoxmlErrorStage}. Retained as a compatibility alias
990
+ * for the short-lived resource-governance API that exposed this vocabulary;
991
+ * scheduled for removal in a future breaking release.
992
+ */
993
+ type OoxmlErrorSource = 'container' | 'zip-part' | 'parser' | 'serializer' | 'layout' | 'renderer' | 'worker';
994
+ /**
995
+ * Typed error thrown by the docx / pptx / xlsx `load()` factories for failures
996
+ * that carry a stable, programmatic {@link OoxmlErrorCode} (e.g. a
997
+ * password-protected or legacy-binary file detected from its container magic).
998
+ *
999
+ * Note on workers: `instanceof OoxmlError` does not survive a structured-clone
1000
+ * across the worker boundary. Detection that needs a typed error is therefore
1001
+ * done on the main thread (before the worker is involved) so a genuine
1002
+ * `OoxmlError` instance is thrown to the caller. Errors that must cross the
1003
+ * worker boundary should carry the `code` string and be reconstructed on the
1004
+ * main side.
1005
+ */
1006
+ declare class OoxmlError extends Error {
1007
+ readonly code: OoxmlErrorCode;
1008
+ constructor(code: OoxmlErrorCode, message: string);
1009
+ }
1010
+ type OoxmlFormat = 'docx' | 'xlsx' | 'pptx';
1011
+ interface OoxmlResourceUsageSnapshot {
1012
+ readonly archiveEntryCount: number;
1013
+ readonly declaredInflatedBytes: number;
1014
+ /** Largest actual decompressed size observed for one ZIP entry. */
1015
+ readonly largestInflatedEntryBytes?: number;
1016
+ readonly distinctInflatedBytes: number;
1017
+ readonly operationInflatedBytes: number;
1018
+ }
1019
+ type ExtensibleLiteral<Known extends string> = Known | (string & Record<never, never>);
1020
+ /**
1021
+ * Resource family reported by a policy or hard-quota violation.
1022
+ *
1023
+ * The known literals provide editor completion. The string tail is deliberate:
1024
+ * adding a future format-owned unit must not break exhaustive switches compiled
1025
+ * against an older host while a newer worker is already able to report it.
1026
+ */
1027
+ type OoxmlResourceName = ExtensibleLiteral<'archive' | 'archive-entry' | 'xml-event' | 'xml-context' | 'xml-tree' | 'worksheet-row' | 'worksheet-shell'>;
1028
+ /** Measurement axis used by an OOXML resource violation. Extensible by design. */
1029
+ type OoxmlResourceMetric = ExtensibleLiteral<'declared-inflated-bytes' | 'actual-inflated-bytes' | 'entry-count' | 'central-directory-bytes' | 'distinct-inflated-bytes' | 'bytes' | 'depth' | 'projected-bytes'>;
1030
+ /** Stable public violation record. Valid resource/metric pairings are enforced
1031
+ * by the emitting parser and the worker decoder rather than by a closed public
1032
+ * union that would require a breaking expansion for every new hard quota. */
1033
+ interface OoxmlResourceViolation {
1034
+ readonly format: OoxmlFormat;
1035
+ readonly operation: string;
1036
+ readonly resource: OoxmlResourceName;
1037
+ readonly metric: OoxmlResourceMetric;
1038
+ readonly part?: string;
1039
+ readonly limit: number;
1040
+ readonly observed: number;
1041
+ readonly configurable: boolean;
1042
+ readonly usage: OoxmlResourceUsageSnapshot;
1043
+ }
1044
+ interface OoxmlResourceLimitErrorDetails {
1045
+ readonly stage: OoxmlErrorStage;
1046
+ readonly violation: OoxmlResourceViolation;
1047
+ }
1048
+ /** Deterministic rejection caused by a measured OOXML resource-policy breach. */
1049
+ declare class OoxmlResourceLimitError extends Error {
1050
+ readonly code: "ooxml-resource-limit";
1051
+ readonly details: OoxmlResourceLimitErrorDetails;
1052
+ constructor(message: string, details: OoxmlResourceLimitErrorDetails);
1053
+ }
1054
+ //#endregion
1055
+ //#region packages/core/src/types/resource-metrics.d.ts
1056
+ /** Configured public admission policy used for one measured operation. */
1057
+ interface OoxmlResourcePolicySnapshot {
1058
+ readonly maxArchiveEntryBytes: number | null;
1059
+ readonly maxTotalInflatedBytes: number | null;
1060
+ }
1061
+ interface OoxmlResourceMetricsCheckpoint {
1062
+ readonly name: string;
1063
+ readonly elapsedMs: number;
1064
+ readonly usage?: OoxmlResourceUsageSnapshot;
1065
+ }
1066
+ /**
1067
+ * Content-free, machine-readable resource report for an OOXML load or bounded
1068
+ * Node session. Byte counters describe measured package work, not the JavaScript
1069
+ * heap, WASM allocator overhead, decoded images, canvas, or GPU. Browser engines
1070
+ * and Viewers can return a newer snapshot after lazy package access.
1071
+ *
1072
+ * No source URL, filename, OOXML part name, document text, password, or raw
1073
+ * error message is included. Sizes, counts, and timings are still
1074
+ * document-derived metadata; applications apply their own consent, retention,
1075
+ * and telemetry policy.
1076
+ */
1077
+ interface OoxmlResourceMetrics {
1078
+ /** Version of this metrics payload, independent of the package version. */
1079
+ readonly schemaVersion: 1;
1080
+ /**
1081
+ * Browser factories report `load`; bounded Node sessions report `session`.
1082
+ */
1083
+ readonly scope: 'load' | 'session';
1084
+ readonly format: OoxmlFormat;
1085
+ readonly mode: 'main' | 'worker' | 'node';
1086
+ /** Outcome of this measured load/session, not of later render operations. */
1087
+ readonly status: 'ok' | 'error';
1088
+ /** Compressed or decrypted OOXML container bytes supplied to the parser. */
1089
+ readonly sourceBytes?: number;
1090
+ readonly elapsedMs: number;
1091
+ readonly policy: Readonly<OoxmlResourcePolicySnapshot>;
1092
+ /** Last complete observed package-usage checkpoint. */
1093
+ readonly usage?: OoxmlResourceUsageSnapshot;
1094
+ readonly checkpoints: readonly OoxmlResourceMetricsCheckpoint[];
1095
+ readonly outcome?: Readonly<Record<string, number>>;
1096
+ readonly error?: Readonly<{
1097
+ readonly code?: string;
1098
+ readonly stage?: string;
1099
+ readonly resource?: string;
1100
+ readonly metric?: string;
1101
+ }>;
1102
+ }
1103
+ //#endregion
966
1104
  //#region packages/core/src/types/load-options.d.ts
1105
+ /** A positive safe-integer byte count, or `null` to disable one public limit. */
1106
+ type OoxmlResourceLimit = number | null;
1107
+ /** Admission limits for the inflated contents of one OOXML package session. */
1108
+ interface OoxmlResourceLimits {
1109
+ /**
1110
+ * Maximum permitted inflated size for any one archive entry, including
1111
+ * media. Enforced against both the ZIP declaration and actual output.
1112
+ */
1113
+ maxArchiveEntryBytes?: OoxmlResourceLimit;
1114
+ /** Maximum actual inflated bytes across distinct entries in the session. */
1115
+ maxTotalInflatedBytes?: OoxmlResourceLimit;
1116
+ }
967
1117
  /**
968
1118
  * Common load-time options shared by the docx / pptx / xlsx
969
1119
  * `Document.load` / `Presentation.load` / `Workbook.load` factories and their
@@ -1030,12 +1180,44 @@ interface LoadOptions$3 {
1030
1180
  */
1031
1181
  wasmUrl?: string | URL;
1032
1182
  /**
1033
- * Override the per-entry ZIP decompression cap (bytes) used by the zip-bomb
1034
- * guard in the Rust parser. Defaults to 512 MiB. Raise it to load documents
1035
- * with very large embedded media, or lower it to tighten the budget for
1036
- * untrusted input. Zero / negative values fall back to the default.
1183
+ * @deprecated Use `resourceLimits.maxArchiveEntryBytes`. Scheduled for
1184
+ * removal in a future breaking release.
1185
+ *
1186
+ * Existing positive safe-integer values remain an all-entry inflated-byte
1187
+ * limit. Zero, negative, and NaN values retain their historical fallback
1188
+ * behavior; other invalid positive values reject during `load()`.
1037
1189
  */
1038
1190
  maxZipEntryBytes?: number;
1191
+ /**
1192
+ * Inflated archive admission limits for one document session. Omitted fields
1193
+ * use the library defaults. A positive safe integer overrides a default;
1194
+ * `null` disables that configurable limit only. Limits are admission policy,
1195
+ * not guarantees of exact browser-process memory use.
1196
+ */
1197
+ resourceLimits?: OoxmlResourceLimits;
1198
+ /**
1199
+ * Emit one content-free resource-usage card after load succeeds or fails.
1200
+ * Includes observed archive counters and configured limits, but never source
1201
+ * URLs, part names, document text, passwords, or error messages.
1202
+ */
1203
+ debug?: boolean;
1204
+ /**
1205
+ * Receive the initial content-free, machine-readable report that powers the
1206
+ * debug card, without enabling console output. After resource options validate,
1207
+ * the callback runs once when the current load settles, including failed loads
1208
+ * for which no renderer instance is returned. The callback is not awaited;
1209
+ * synchronous exceptions and rejected promises are ignored and never change
1210
+ * load results.
1211
+ *
1212
+ * A browser report covers the underlying document/workbook/presentation
1213
+ * factory. It does not wait for a Viewer's first canvas paint; that paint and
1214
+ * later lazy worksheet, slide, image, or media access may increase counters or
1215
+ * surface a separate render error. Successfully opened packages include the
1216
+ * declared package total and source byte size in the report. On a successful
1217
+ * load, call `getResourceMetrics()` on the returned engine or Viewer for a fresh
1218
+ * snapshot that includes subsequently observed lazy package work.
1219
+ */
1220
+ onResourceMetrics?: (metrics: OoxmlResourceMetrics) => void;
1039
1221
  /**
1040
1222
  * Reject the parse request if the parser worker does not answer within this
1041
1223
  * many milliseconds. Opt-in safety net for a wedged or crashed worker that
@@ -1058,44 +1240,81 @@ interface LoadOptions$3 {
1058
1240
  math?: MathRenderer;
1059
1241
  }
1060
1242
  //#endregion
1061
- //#region packages/core/src/errors/ooxml-error.d.ts
1243
+ //#region packages/core/src/image/pixel-budget.d.ts
1244
+ type OoxmlDecodedImageLimitMetric = 'image-pixels' | 'active-decoded-bytes';
1245
+ /** Catchable hard-quota crossing for decoded image surfaces. */
1246
+ declare class OoxmlDecodedImageLimitError extends RangeError {
1247
+ readonly metric: OoxmlDecodedImageLimitMetric;
1248
+ readonly limit: number;
1249
+ readonly observed: number;
1250
+ readonly code: "ooxml-decoded-image-limit";
1251
+ constructor(metric: OoxmlDecodedImageLimitMetric, limit: number, observed: number);
1252
+ }
1253
+ declare function isOoxmlDecodedImageLimitError(error: unknown): error is OoxmlDecodedImageLimitError;
1254
+ //#endregion
1255
+ //#region packages/core/src/interaction/hyperlink.d.ts
1062
1256
  /**
1063
- * Machine-readable code for a typed load-time failure.
1257
+ * Shared hyperlink model + URL sanitisation for docx / pptx / xlsx (IX1).
1064
1258
  *
1065
- * The container-level failures the `load()` factories detect on the main thread
1066
- * before handing bytes to the parser worker (see `sniffCfb` / `decryptOoxml`).
1067
- * This is the seed of the broader typed-error surface tracked as PD4 (OoxmlError
1068
- * typed errors). Add codes here rather than throwing bare `Error(string)`, so
1069
- * callers can `switch` on `err.code` instead of matching message text.
1259
+ * All three formats carry the same two ECMA-376 concepts:
1260
+ * - an **external** hyperlink an absolute URL resolved from a relationship
1261
+ * part target (`document.xml.rels` for docx §17.16.22, the slide rels for
1262
+ * pptx §21.1.2.3.5, the worksheet rels for xlsx §18.3.1.47), with
1263
+ * `TargetMode="External"`.
1264
+ * - an **internal** hyperlink — a jump within the document itself:
1265
+ * docx `w:anchor` -> a `<w:bookmarkStart w:name>` (§17.16.23), pptx
1266
+ * `action="ppaction://hlinksldjump"` -> a slide, xlsx `location` -> a defined
1267
+ * name or a `Sheet!A1` cell reference.
1070
1268
  *
1071
- * - `'encrypted'` — password-protected, but no `password` was
1072
- * supplied (pass `LoadOptions.password` to decrypt).
1073
- * - `'invalid-password'` — a `password` was supplied but did not match.
1074
- * - `'unsupported-encryption'`— encrypted with a scheme other than Agile
1075
- * (Standard / Extensible / a legacy binary encryptor), which this library
1076
- * cannot decrypt (PD8 implements Agile only).
1077
- * - `'legacy-binary-format'` — a raw .doc / .xls / .ppt (not OOXML).
1078
- * - `'not-ooxml'` — a CFB of an unrecognised kind, or otherwise
1079
- * not an OOXML ZIP.
1269
+ * The parsers (Rust, one per format) do the format-specific rels lookup and hand
1270
+ * each run / shape / cell a {@link HyperlinkTarget}. Everything downstream — the
1271
+ * text-layer overlay, the viewer default click behaviour, and any integrator
1272
+ * callback — is format-agnostic and consumes this one shape. Keeping the type +
1273
+ * the pure `sanitizeHyperlinkUrl` predicate here (not duplicated per package)
1274
+ * follows the cross-package unification principle: a scheme-allowlist bug fixed
1275
+ * once is fixed everywhere.
1080
1276
  */
1081
- type OoxmlErrorCode = 'encrypted' | 'invalid-password' | 'unsupported-encryption' | 'legacy-binary-format' | 'not-ooxml';
1082
1277
  /**
1083
- * Typed error thrown by the docx / pptx / xlsx `load()` factories for failures
1084
- * that carry a stable, programmatic {@link OoxmlErrorCode} (e.g. a
1085
- * password-protected or legacy-binary file detected from its container magic).
1278
+ * A resolved hyperlink attached to a run, shape, or cell.
1086
1279
  *
1087
- * Note on workers: `instanceof OoxmlError` does not survive a structured-clone
1088
- * across the worker boundary. Detection that needs a typed error is therefore
1089
- * done on the main thread (before the worker is involved) so a genuine
1090
- * `OoxmlError` instance is thrown to the caller. Errors that must cross the
1091
- * worker boundary should carry the `code` string and be reconstructed on the
1092
- * main side.
1280
+ * - `external` `url` is the raw target as authored in the file. It is NOT
1281
+ * guaranteed safe; run it through {@link sanitizeHyperlinkUrl} before
1282
+ * navigating. It is kept verbatim here so an integrator can apply its own
1283
+ * policy (e.g. allow `file:` on a trusted intranet viewer).
1284
+ * - `internal` `ref` is the in-document destination, verbatim from the file:
1285
+ * docx: the bookmark name (`w:anchor`).
1286
+ * pptx: the internal action (e.g. `ppaction://hlinksldjump`), with the
1287
+ * resolved 0-based `slideIndex` when the rels target names a slide.
1288
+ * xlsx: the `location` string (a defined name or `Sheet1!A1`).
1093
1289
  */
1094
- declare class OoxmlError extends Error {
1095
- readonly code: OoxmlErrorCode;
1096
- constructor(code: OoxmlErrorCode, message: string);
1097
- }
1290
+ type HyperlinkTarget = {
1291
+ kind: 'external';
1292
+ url: string;
1293
+ } | {
1294
+ kind: 'internal';
1295
+ ref: string;
1296
+ slideIndex?: number;
1297
+ };
1298
+ /**
1299
+ * The default action a viewer takes for an **external** hyperlink click when
1300
+ * the integrator supplies no `onHyperlinkClick` handler: sanitise the URL and,
1301
+ * if allowed, open it in a new tab with `noopener,noreferrer` so the opened page
1302
+ * gets no `window.opener` handle back into this document. A blocked scheme is a
1303
+ * silent no-op (returns `false`) — the click does nothing rather than navigate
1304
+ * somewhere dangerous.
1305
+ *
1306
+ * Internal targets are intentionally NOT handled here: the in-document jump
1307
+ * (page / slide / cell) is format-specific and lives in each viewer.
1308
+ *
1309
+ * Split out (not inlined in three viewers) so the "open in new tab, drop opener,
1310
+ * refuse unsafe schemes" policy is defined once. `win` is injected for tests;
1311
+ * defaults to the ambient `window`.
1312
+ *
1313
+ * @returns `true` if navigation was initiated, `false` if the URL was blocked.
1314
+ */
1315
+ declare function openExternalHyperlink(url: string, allowed?: readonly string[], win?: Pick<Window, 'open'> | undefined): boolean;
1098
1316
  //#endregion
1317
+ //#region dist/.types-work/find-highlight-gMP3FAnW.d.ts
1099
1318
  //#region packages/core/src/autoResize.d.ts
1100
1319
  interface AutoResizeOptions {
1101
1320
  /**
@@ -1208,68 +1427,6 @@ interface ZoomableViewer {
1208
1427
  fitPage(): void | Promise<void>;
1209
1428
  }
1210
1429
  //#endregion
1211
- //#region packages/core/src/interaction/hyperlink.d.ts
1212
- /**
1213
- * Shared hyperlink model + URL sanitisation for docx / pptx / xlsx (IX1).
1214
- *
1215
- * All three formats carry the same two ECMA-376 concepts:
1216
- * - an **external** hyperlink — an absolute URL resolved from a relationship
1217
- * part target (`document.xml.rels` for docx §17.16.22, the slide rels for
1218
- * pptx §21.1.2.3.5, the worksheet rels for xlsx §18.3.1.47), with
1219
- * `TargetMode="External"`.
1220
- * - an **internal** hyperlink — a jump within the document itself:
1221
- * docx `w:anchor` -> a `<w:bookmarkStart w:name>` (§17.16.23), pptx
1222
- * `action="ppaction://hlinksldjump"` -> a slide, xlsx `location` -> a defined
1223
- * name or a `Sheet!A1` cell reference.
1224
- *
1225
- * The parsers (Rust, one per format) do the format-specific rels lookup and hand
1226
- * each run / shape / cell a {@link HyperlinkTarget}. Everything downstream — the
1227
- * text-layer overlay, the viewer default click behaviour, and any integrator
1228
- * callback — is format-agnostic and consumes this one shape. Keeping the type +
1229
- * the pure `sanitizeHyperlinkUrl` predicate here (not duplicated per package)
1230
- * follows the cross-package unification principle: a scheme-allowlist bug fixed
1231
- * once is fixed everywhere.
1232
- */
1233
- /**
1234
- * A resolved hyperlink attached to a run, shape, or cell.
1235
- *
1236
- * - `external` — `url` is the raw target as authored in the file. It is NOT
1237
- * guaranteed safe; run it through {@link sanitizeHyperlinkUrl} before
1238
- * navigating. It is kept verbatim here so an integrator can apply its own
1239
- * policy (e.g. allow `file:` on a trusted intranet viewer).
1240
- * - `internal` — `ref` is the in-document destination, verbatim from the file:
1241
- * docx: the bookmark name (`w:anchor`).
1242
- * pptx: the internal action (e.g. `ppaction://hlinksldjump`), with the
1243
- * resolved 0-based `slideIndex` when the rels target names a slide.
1244
- * xlsx: the `location` string (a defined name or `Sheet1!A1`).
1245
- */
1246
- type HyperlinkTarget = {
1247
- kind: 'external';
1248
- url: string;
1249
- } | {
1250
- kind: 'internal';
1251
- ref: string;
1252
- slideIndex?: number;
1253
- };
1254
- /**
1255
- * The default action a viewer takes for an **external** hyperlink click when
1256
- * the integrator supplies no `onHyperlinkClick` handler: sanitise the URL and,
1257
- * if allowed, open it in a new tab with `noopener,noreferrer` so the opened page
1258
- * gets no `window.opener` handle back into this document. A blocked scheme is a
1259
- * silent no-op (returns `false`) — the click does nothing rather than navigate
1260
- * somewhere dangerous.
1261
- *
1262
- * Internal targets are intentionally NOT handled here: the in-document jump
1263
- * (page / slide / cell) is format-specific and lives in each viewer.
1264
- *
1265
- * Split out (not inlined in three viewers) so the "open in new tab, drop opener,
1266
- * refuse unsafe schemes" policy is defined once. `win` is injected for tests;
1267
- * defaults to the ambient `window`.
1268
- *
1269
- * @returns `true` if navigation was initiated, `false` if the URL was blocked.
1270
- */
1271
- declare function openExternalHyperlink(url: string, allowed?: readonly string[], win?: Pick<Window, 'open'> | undefined): boolean;
1272
- //#endregion
1273
1430
  //#region packages/core/src/search/text-index.d.ts
1274
1431
  /**
1275
1432
  * The slice of one run a match covers: the run's index in the original `runs[]`
@@ -1344,7 +1501,7 @@ interface FindHighlightColors {
1344
1501
  active?: string;
1345
1502
  }
1346
1503
  //#endregion
1347
- //#region dist/.types-work/docx-BatSd3II.d.ts
1504
+ //#region dist/.types-work/renderer-CU7Ays06.d.ts
1348
1505
  //#region packages/docx/src/types.d.ts
1349
1506
  interface DocxDocumentModel {
1350
1507
  section: SectionProps;
@@ -2875,14 +3032,15 @@ interface DocxTextRunInfo {
2875
3032
  eastAsianVert?: boolean;
2876
3033
  }
2877
3034
  //#endregion
3035
+ //#region dist/.types-work/docx-VDKt2JLe.d.ts
2878
3036
  //#region packages/docx/src/worker-protocol.d.ts
2879
3037
  /** Serializable subset of RenderPageOptions (callbacks cannot cross the wire). */
2880
3038
  type WireRenderPageOptions = Omit<RenderPageOptions, 'onTextRun'>;
2881
3039
  //#endregion
2882
3040
  //#region packages/docx/src/document.d.ts
2883
3041
  /** Options for {@link DocxDocument.load}. Extends the shared load-options type
2884
- * from `@silurus/ooxml-core` (`useGoogleFonts`, `maxZipEntryBytes`) with the
2885
- * opt-in math engine. */
3042
+ * from `@silurus/ooxml-core` (`useGoogleFonts`, `resourceLimits`, and the
3043
+ * deprecated `maxZipEntryBytes` alias) with the opt-in math engine. */
2886
3044
  interface LoadOptions$2 extends LoadOptions$3 {
2887
3045
  /**
2888
3046
  * Opt-in OMML equation engine. Import it from the separate `@silurus/ooxml/math`
@@ -2910,7 +3068,9 @@ type RenderPageToBitmapOptions = WireRenderPageOptions & {
2910
3068
  onTextRun?: (run: DocxTextRunInfo) => void;
2911
3069
  };
2912
3070
  declare class DocxDocument {
3071
+ private _metrics;
2913
3072
  private _document;
3073
+ private _source;
2914
3074
  private _meta;
2915
3075
  /** Lazily-built `bookmarkName → 0-based page index` map for internal hyperlink
2916
3076
  * anchors (IX-nav). Built on first {@link getBookmarkPage} from the paginated
@@ -2920,7 +3080,7 @@ declare class DocxDocument {
2920
3080
  private _mode;
2921
3081
  private _worker;
2922
3082
  private _bridge;
2923
- private _imageCache;
3083
+ private readonly _rawParts;
2924
3084
  /** Embedded `FontFace` objects this document registered into `document.fonts`
2925
3085
  * (main mode only — in worker mode the worker owns them and terminates with
2926
3086
  * its own FontFaceSet). Released in {@link destroy} so they do not leak into
@@ -2962,6 +3122,11 @@ declare class DocxDocument {
2962
3122
  * which de-obfuscates (ECMA-376 §17.8.1) and registers each as a FontFace.
2963
3123
  */
2964
3124
  getFontBytes(partPath: string): Promise<Uint8Array>;
3125
+ private _resourceUsage;
3126
+ /** Return a fresh content-free metrics snapshot, including lazy archive work
3127
+ * completed since load. Collection is always active; `debug` only controls
3128
+ * console presentation. */
3129
+ getResourceMetrics(): Promise<OoxmlResourceMetrics>;
2965
3130
  /**
2966
3131
  * Project the document to GitHub-flavoured markdown: headings (from
2967
3132
  * `<w:outlineLvl>`), bullet / numbered lists, tables (with vMerge
@@ -3116,7 +3281,19 @@ interface DocxViewerOptions extends RenderPageOptions, LoadOptions$2 {
3116
3281
  * text. Set it to disable clickable links entirely — e.g. in a preview where
3117
3282
  * navigation must not leave the current view. */
3118
3283
  enableHyperlinks?: boolean;
3119
- /** Called on parse or render errors. */
3284
+ /**
3285
+ * Receives load failures and asynchronous render failures handled by the
3286
+ * Viewer. Supplying this callback changes load-failure delivery: `load()`
3287
+ * invokes it and resolves; without it, the same load/parse failure rejects
3288
+ * `load()`. Viewer-managed render failures invoke it, or fall back to
3289
+ * `console.error` when omitted.
3290
+ *
3291
+ * Stable cases can be narrowed with `OoxmlError`,
3292
+ * `OoxmlResourceLimitError`, or `OoxmlDecodedImageLimitError` re-exported by
3293
+ * this package. Other failures remain `Error` values; do not parse message
3294
+ * text as an API. A `code` of `parser-crashed` identifies a recognized WASM
3295
+ * trap, not a reliably classified OOM.
3296
+ */
3120
3297
  onError?: (err: Error) => void;
3121
3298
  }
3122
3299
  declare class DocxViewer implements ZoomableViewer {
@@ -3287,6 +3464,8 @@ declare class DocxViewer implements ZoomableViewer {
3287
3464
  /** Rebuild the highlight overlay for the current page from cached runs
3288
3465
  * (no page re-render). */
3289
3466
  private _redrawHighlights;
3467
+ /** Latest content-free resource metrics for the loaded document. */
3468
+ getResourceMetrics(): Promise<OoxmlResourceMetrics>;
3290
3469
  /**
3291
3470
  * Terminate the parser worker and release resources.
3292
3471
  *
@@ -3457,7 +3636,11 @@ interface DocxScrollViewerOptions extends Omit<RenderPageOptions, 'onTextRun'>,
3457
3636
  * per-slot render failures (both main `renderPage` and worker
3458
3637
  * `renderPageToBitmap` rejections); a failed page is left blank rather than
3459
3638
  * crashing the loop. Without an `onError`, render failures are logged via
3460
- * `console.error` so they are never fully silent. */
3639
+ * `console.error` so they are never fully silent. Stable cases can be
3640
+ * narrowed with `OoxmlError`, `OoxmlResourceLimitError`, or
3641
+ * `OoxmlDecodedImageLimitError` re-exported by this package. Other failures
3642
+ * remain `Error` values; a `code` of `parser-crashed` identifies a recognized
3643
+ * WASM trap, not a reliably classified OOM. */
3461
3644
  onError?: (err: Error) => void;
3462
3645
  }
3463
3646
  declare class DocxScrollViewer implements ZoomableViewer {
@@ -3918,6 +4101,8 @@ declare class DocxScrollViewer implements ZoomableViewer {
3918
4101
  */
3919
4102
  private _onResize;
3920
4103
  get topVisiblePage(): number;
4104
+ /** Return the owning engine's latest content-free package-usage snapshot. */
4105
+ getResourceMetrics(): Promise<OoxmlResourceMetrics>;
3921
4106
  /**
3922
4107
  * Tear down the viewer: remove the DOM subtree and (only for a self-loaded
3923
4108
  * engine) destroy the engine. An injected engine is left intact — the caller
@@ -4004,10 +4189,10 @@ type DocxHighlightColors = FindHighlightColors;
4004
4189
  */
4005
4190
  declare function buildDocxHighlightLayer(layer: HTMLDivElement, runs: DocxTextRunInfo[], matches: DocxHighlightMatch[], cssWidth: number, cssHeight: number, measureForFont: (font: string) => (s: string) => number, colors?: DocxHighlightColors): void;
4006
4191
  declare namespace docx_d_exports {
4007
- export { AnchorHostMetrics, AutoResizeOptions, BodyElement, BorderSpec, CellBorders, CellElement, ChartRun, ColSpec, ColumnsSpec, DocComment, DocNote, DocParagraph, DocRevision, DocRun, DocSettings, DocTable, DocTableCell, DocTableRow, DocxDocument, DocxDocumentModel, DocxHighlightColors, DocxHighlightMatch, DocxMatchLocation, DocxRunBorder, DocxScrollViewer, DocxScrollViewerOptions, DocxTextRun, DocxTextRunInfo, DocxViewer, DocxViewerOptions, EmbeddedFontRef, FieldRun, FindHighlightColors, FindMatch, FindMatchesOptions, FramePr, GradientStop$1 as GradientStop, HeaderFooter, HeadersFooters, HyperlinkTarget, ImageRun, LineEnd, LineNumbering, LineSpacing, LoadOptions$2 as LoadOptions, NoteRef, NumberingInfo, OoxmlError, OoxmlErrorCode, PTabRun, PageBorderEdge, PageBorders, PageNumType, ParaBorderEdge, ParagraphBorders, PathCmd$2 as PathCmd, RenderPageOptions, RenderPageToBitmapOptions, RubyAnnotation, RunRevision, SectionGeom, SectionProps, ShapeRun, ShapeText$1 as ShapeText, ShapeTextRun$1 as ShapeTextRun, TabStop$1 as TabStop, TableBorders, TblpPr, TextPath, WireRenderPageOptions, autoResize, buildDocxHighlightLayer, buildDocxTextLayer, noteText, openExternalHyperlink };
4192
+ export { AnchorHostMetrics, AutoResizeOptions, BodyElement, BorderSpec, CellBorders, CellElement, ChartRun, ColSpec, ColumnsSpec, DocComment, DocNote, DocParagraph, DocRevision, DocRun, DocSettings, DocTable, DocTableCell, DocTableRow, DocxDocument, DocxDocumentModel, DocxHighlightColors, DocxHighlightMatch, DocxMatchLocation, DocxRunBorder, DocxScrollViewer, DocxScrollViewerOptions, DocxTextRun, DocxTextRunInfo, DocxViewer, DocxViewerOptions, EmbeddedFontRef, FieldRun, FindHighlightColors, FindMatch, FindMatchesOptions, FramePr, GradientStop$1 as GradientStop, HeaderFooter, HeadersFooters, HyperlinkTarget, ImageRun, LineEnd, LineNumbering, LineSpacing, LoadOptions$2 as LoadOptions, NoteRef, NumberingInfo, OoxmlDecodedImageLimitError, OoxmlDecodedImageLimitMetric, OoxmlError, OoxmlErrorCode, OoxmlErrorSource, OoxmlErrorStage, OoxmlFormat, OoxmlResourceLimit, OoxmlResourceLimitError, OoxmlResourceLimitErrorDetails, OoxmlResourceLimits, OoxmlResourceMetric, OoxmlResourceMetrics, OoxmlResourceMetricsCheckpoint, OoxmlResourceName, OoxmlResourcePolicySnapshot, OoxmlResourceUsageSnapshot, OoxmlResourceViolation, PTabRun, PageBorderEdge, PageBorders, PageNumType, ParaBorderEdge, ParagraphBorders, PathCmd$2 as PathCmd, RenderPageOptions, RenderPageToBitmapOptions, RubyAnnotation, RunRevision, SectionGeom, SectionProps, ShapeRun, ShapeText$1 as ShapeText, ShapeTextRun$1 as ShapeTextRun, TabStop$1 as TabStop, TableBorders, TblpPr, TextPath, WireRenderPageOptions, autoResize, buildDocxHighlightLayer, buildDocxTextLayer, isOoxmlDecodedImageLimitError, noteText, openExternalHyperlink };
4008
4193
  }
4009
4194
  //#endregion
4010
- //#region dist/.types-work/common-Bva7_XCn.d.ts
4195
+ //#region dist/.types-work/common-Bgczc_Eb.d.ts
4011
4196
  //#region packages/core/src/types/common.d.ts
4012
4197
  type PathCmd$1 = {
4013
4198
  cmd: 'moveTo';
@@ -4479,7 +4664,7 @@ interface RenderOptions {
4479
4664
  skipMediaControls?: boolean;
4480
4665
  }
4481
4666
  //#endregion
4482
- //#region dist/.types-work/pptx-lmtZXJAj.d.ts
4667
+ //#region dist/.types-work/pptx-B9ExAlcU.d.ts
4483
4668
  //#region packages/pptx/src/types.d.ts
4484
4669
  /**
4485
4670
  * Picture bullet — ECMA-376 §21.1.2.4.2 `<a:buBlip><a:blip r:embed>`. The
@@ -5178,18 +5363,22 @@ interface RenderSlideOptions {
5178
5363
  * await pres.renderSlide(canvas, 0, { width: 960 });
5179
5364
  */
5180
5365
  declare class PptxPresentation {
5366
+ private _metrics;
5181
5367
  private readonly _worker;
5182
5368
  private readonly _bridge;
5183
5369
  private _mode;
5184
- private _presentation;
5185
- private _meta;
5370
+ private _preflight;
5371
+ private _slides;
5372
+ private _slidePullClient;
5373
+ /** First fatal package/model violation for this presentation generation. */
5374
+ private _resourceFailure;
5186
5375
  /** Lazily-built `partName → slide index` map for internal hyperlink slide
5187
5376
  * jumps (IX-nav). Cleared on {@link destroy}; built on first
5188
- * {@link getSlideIndexByPartName}/{@link resolveInternalTarget} from either
5189
- * the parsed slides (main) or the worker meta's `partNames` (worker). */
5377
+ * {@link getSlideIndexByPartName}/{@link resolveInternalTarget} from the
5378
+ * common compact preflight in either render mode. */
5190
5379
  private _slidePartIndex;
5191
- private _mediaCache;
5192
- private _imageCache;
5380
+ /** One bounded retained-byte owner shared by images and media. */
5381
+ private readonly _rawParts;
5193
5382
  /** Google-Fonts `FontFace` objects this deck preloaded into `document.fonts`
5194
5383
  * (main mode only — in worker mode the worker owns them and terminates with
5195
5384
  * its own FontFaceSet). Released in {@link destroy} so they do not leak into
@@ -5201,11 +5390,14 @@ declare class PptxPresentation {
5201
5390
  * images for a shared zip path like ppt/media/image1.png). Reusing the same
5202
5391
  * reference across every render also lets those caches hit across slides. */
5203
5392
  private readonly _fetchImage;
5393
+ private readonly _fetchMedia;
5204
5394
  /** Opt-in OMML equation engine, injected once at {@link load}. Every
5205
5395
  * `renderSlide` / `presentSlide` reuses it — equations render when present,
5206
5396
  * and are skipped (engine tree-shaken) when omitted. */
5207
5397
  private _math;
5208
5398
  private constructor();
5399
+ private _assertResourceHealthy;
5400
+ private _rethrowWithResourceFailure;
5209
5401
  /** Parse a PPTX from URL or ArrayBuffer. */
5210
5402
  static load(source: string | ArrayBuffer, opts?: LoadOptions$1): Promise<PptxPresentation>;
5211
5403
  private _parse;
@@ -5248,8 +5440,7 @@ declare class PptxPresentation {
5248
5440
  * caller's policy (see {@link PptxViewer}'s `hiddenSlideMode` modes).
5249
5441
  */
5250
5442
  isHidden(slideIndex: number): boolean;
5251
- /** The per-slide `partName` array (`sldIdLst` order) from either the parsed
5252
- * model (main) or the worker meta (worker). Backs the lazy part-index map. */
5443
+ /** The compact preflight's per-slide `partName` array (`sldIdLst` order). */
5253
5444
  private _partNames;
5254
5445
  /** Lazily build (and cache) the `partName → index` map. Nulled by
5255
5446
  * {@link destroy} so a reused reference never serves a stale deck's indices. */
@@ -5261,7 +5452,7 @@ declare class PptxPresentation {
5261
5452
  * (`<a:hlinkClick action="ppaction://hlinksldjump" r:id>`, ECMA-376
5262
5453
  * §21.1.2.3.5) resolves against: the click's rel Target names a slide part, and
5263
5454
  * this turns it into the index a viewer can navigate to. Works in both `main`
5264
- * and `worker` mode (the part names ride along in the worker meta).
5455
+ * and `worker` mode through the same compact preflight contract.
5265
5456
  */
5266
5457
  getSlideIndexByPartName(partName: string): number | undefined;
5267
5458
  /**
@@ -5310,7 +5501,7 @@ declare class PptxPresentation {
5310
5501
  collectSlideRuns(slideIndex: number, width?: number): Promise<PptxTextRunInfo[]>;
5311
5502
  /**
5312
5503
  * Extract raw media bytes for a zip path referenced by {@link MediaElement}.
5313
- * Results are cached by path for the lifetime of this instance.
5504
+ * Results share a count- and byte-bounded cache with embedded images.
5314
5505
  */
5315
5506
  getMedia(mediaPath: string): Promise<Blob>;
5316
5507
  private _findMimeTypeForPath;
@@ -5318,10 +5509,13 @@ declare class PptxPresentation {
5318
5509
  * Extract raw bytes for an embedded image by zip path (e.g.
5319
5510
  * "ppt/media/image1.png"), wrapped in a Blob of the given MIME type. Mirrors
5320
5511
  * {@link getMedia}; results are cached by path for the lifetime of this
5321
- * instance. The renderer routes its `fetchImage` option here so images are
5512
+ * instance within a common count and byte budget. The renderer routes its `fetchImage` option here so images are
5322
5513
  * decoded lazily rather than inlined as base64 at parse time.
5323
5514
  */
5324
5515
  getImage(imagePath: string, mimeType: string): Promise<Blob>;
5516
+ /** Return a fresh content-free metrics snapshot, including lazy slide and
5517
+ * media work completed since load. */
5518
+ getResourceMetrics(): Promise<OoxmlResourceMetrics>;
5325
5519
  /**
5326
5520
  * Project the presentation to GitHub-flavoured markdown: title slides become
5327
5521
  * `#` headings, body shapes become nested bullets at each paragraph's `lvl`,
@@ -5356,7 +5550,19 @@ type HiddenSlideMode = 'show' | 'skip' | 'dim';
5356
5550
  interface PptxViewerOptions extends RenderOptions, LoadOptions$1 {
5357
5551
  /** Called when a slide finishes rendering */
5358
5552
  onSlideChange?: (index: number, total: number) => void;
5359
- /** Called on parse, render, or embedded-media playback errors. */
5553
+ /**
5554
+ * Receives load failures plus asynchronous render or embedded-media failures
5555
+ * handled by the Viewer. Supplying this callback changes load-failure
5556
+ * delivery: `load()` invokes it and resolves; without it, the same load/parse
5557
+ * failure rejects `load()`. Viewer-managed failures invoke it, or fall back
5558
+ * to `console.error` when omitted.
5559
+ *
5560
+ * Stable cases can be narrowed with `OoxmlError`,
5561
+ * `OoxmlResourceLimitError`, or `OoxmlDecodedImageLimitError` re-exported by
5562
+ * this package. Other failures remain `Error` values; do not parse message
5563
+ * text as an API. A `code` of `parser-crashed` identifies a recognized WASM
5564
+ * trap, not a reliably classified OOM.
5565
+ */
5360
5566
  onError?: (err: Error) => void;
5361
5567
  /** IX9 zoom contract ({@link ZoomableViewer}) — the clamp range for
5362
5568
  * {@link PptxViewer.setScale} / `zoomIn` / `zoomOut` / `fitWidth` / `fitPage`,
@@ -5654,6 +5860,8 @@ declare class PptxViewer implements ZoomableViewer {
5654
5860
  * teardown. Mirrors the scroll viewers' `_reportRenderError` so all three
5655
5861
  * single-canvas viewers agree. */
5656
5862
  private _reportRenderError;
5863
+ /** Latest content-free resource metrics for the loaded presentation. */
5864
+ getResourceMetrics(): Promise<OoxmlResourceMetrics>;
5657
5865
  /**
5658
5866
  * Clean up the viewer and terminate the background worker.
5659
5867
  *
@@ -5794,7 +6002,11 @@ interface PptxScrollViewerOptions extends Omit<RenderSlideOptions, 'onTextRun'>,
5794
6002
  * `renderSlideToBitmap` rejections) and embedded-media fetch/decode/playback
5795
6003
  * failures. A failed slide is left blank rather than crashing the loop.
5796
6004
  * Without an `onError`, failures are logged via `console.error` so they are
5797
- * never fully silent. */
6005
+ * never fully silent. Stable cases can be narrowed with `OoxmlError`,
6006
+ * `OoxmlResourceLimitError`, or `OoxmlDecodedImageLimitError` re-exported by
6007
+ * this package. Other failures remain `Error` values; a `code` of
6008
+ * `parser-crashed` identifies a recognized WASM trap, not a reliably
6009
+ * classified OOM. */
5798
6010
  onError?: (err: Error) => void;
5799
6011
  /**
5800
6012
  * IX1 (design decision — NOT user-confirmed, integrator may veto). Fires on a
@@ -6308,6 +6520,8 @@ declare class PptxScrollViewer implements ZoomableViewer {
6308
6520
  */
6309
6521
  private _onResize;
6310
6522
  get topVisibleSlide(): number;
6523
+ /** Return the owning engine's latest content-free package-usage snapshot. */
6524
+ getResourceMetrics(): Promise<OoxmlResourceMetrics>;
6311
6525
  /**
6312
6526
  * Tear down the viewer: remove the DOM subtree and (only for a self-loaded
6313
6527
  * engine) destroy the engine. An injected engine is left intact — the caller
@@ -6382,10 +6596,10 @@ type PptxHighlightColors = FindHighlightColors;
6382
6596
  */
6383
6597
  declare function buildPptxHighlightLayer(layer: HTMLDivElement, runs: PptxTextRunInfo[], matches: PptxHighlightMatch[], cssWidth: number, cssHeight: number, measureForFont: (font: string) => (s: string) => number, colors?: PptxHighlightColors): void;
6384
6598
  declare namespace pptx_d_exports {
6385
- export { AutoResizeOptions, Bevel3d, BlipBullet, Bullet, Camera3d, ChartElement, ChartModel, ChartSeries, DimOptions, Fill, FillRect, FindHighlightColors, FindMatch, FindMatchesOptions, Glow, GradientFill, GradientStop, HiddenSlideMode, HyperlinkTarget, ImageFill, LightRig, LineBreak, LoadOptions$1 as LoadOptions, MediaElement, NoFill, OoxmlError, OoxmlErrorCode, Paragraph, PathCmd$1 as PathCmd, PictureElement, PptxComment, PptxHighlightColors, PptxHighlightMatch, PptxMatchLocation, PptxPresentation, PptxScrollViewer, PptxScrollViewerOptions, PptxTextRunInfo, PptxViewer, PptxViewerOptions, Presentation, PresentationHandle, Reflection, RenderOptions, RenderSlideOptions, RenderSlideToBitmapOptions, Rot3d, Scene3d, Shadow, ShapeElement, Slide, SlideElement, SoftEdge, SolidFill, Sp3d, SpaceLine, Stroke, TabStop, TableCell, TableElement, TableRow, TextBody, TextRect, TextRun, TextRunCallback, TextRunData, TileInfo, autoResize, buildPptxHighlightLayer, buildPptxTextLayer, openExternalHyperlink, renderSlide };
6599
+ export { AutoResizeOptions, Bevel3d, BlipBullet, Bullet, Camera3d, ChartElement, ChartModel, ChartSeries, DimOptions, Fill, FillRect, FindHighlightColors, FindMatch, FindMatchesOptions, Glow, GradientFill, GradientStop, HiddenSlideMode, HyperlinkTarget, ImageFill, LightRig, LineBreak, LoadOptions$1 as LoadOptions, MediaElement, NoFill, OoxmlDecodedImageLimitError, OoxmlDecodedImageLimitMetric, OoxmlError, OoxmlErrorCode, OoxmlErrorSource, OoxmlErrorStage, OoxmlFormat, OoxmlResourceLimit, OoxmlResourceLimitError, OoxmlResourceLimitErrorDetails, OoxmlResourceLimits, OoxmlResourceMetric, OoxmlResourceMetrics, OoxmlResourceMetricsCheckpoint, OoxmlResourceName, OoxmlResourcePolicySnapshot, OoxmlResourceUsageSnapshot, OoxmlResourceViolation, Paragraph, PathCmd$1 as PathCmd, PictureElement, PptxComment, PptxHighlightColors, PptxHighlightMatch, PptxMatchLocation, PptxPresentation, PptxScrollViewer, PptxScrollViewerOptions, PptxTextRunInfo, PptxViewer, PptxViewerOptions, Presentation, PresentationHandle, Reflection, RenderOptions, RenderSlideOptions, RenderSlideToBitmapOptions, Rot3d, Scene3d, Shadow, ShapeElement, Slide, SlideElement, SoftEdge, SolidFill, Sp3d, SpaceLine, Stroke, TabStop, TableCell, TableElement, TableRow, TextBody, TextRect, TextRun, TextRunCallback, TextRunData, TileInfo, autoResize, buildPptxHighlightLayer, buildPptxTextLayer, isOoxmlDecodedImageLimitError, openExternalHyperlink, renderSlide };
6386
6600
  }
6387
6601
  //#endregion
6388
- //#region dist/.types-work/xlsx-DAB_laks.d.ts
6602
+ //#region dist/.types-work/xlsx-yYJn5jBA.d.ts
6389
6603
  //#region packages/xlsx/src/types.d.ts
6390
6604
  interface Workbook {
6391
6605
  sheets: SheetMeta[];
@@ -6798,18 +7012,24 @@ interface DataValidation {
6798
7012
  }
6799
7013
  /**
6800
7014
  * @deprecated Chart series are now the core {@link ChartModel}'s `ChartSeries`.
6801
- * Kept as an alias for backward-compatible imports.
7015
+ * Kept as an alias for backward-compatible imports; scheduled for removal in a
7016
+ * future breaking release.
6802
7017
  */
6803
7018
  type XlsxChartSeries = ChartSeries;
6804
- /** @deprecated Use `ChartSeriesDataLabels` from @silurus/ooxml-core. */
7019
+ /** @deprecated Use `ChartSeriesDataLabels` from @silurus/ooxml-core. Scheduled
7020
+ * for removal in a future breaking release. */
6805
7021
  type SeriesDataLabels = ChartSeriesDataLabels;
6806
- /** @deprecated Use `ChartDataLabelOverride` from @silurus/ooxml-core. */
7022
+ /** @deprecated Use `ChartDataLabelOverride` from @silurus/ooxml-core. Scheduled
7023
+ * for removal in a future breaking release. */
6807
7024
  type DataLabelOverride = ChartDataLabelOverride;
6808
- /** @deprecated Use `ChartDataPointOverride` from @silurus/ooxml-core. */
7025
+ /** @deprecated Use `ChartDataPointOverride` from @silurus/ooxml-core. Scheduled
7026
+ * for removal in a future breaking release. */
6809
7027
  type DataPointOverride = ChartDataPointOverride;
6810
- /** @deprecated Use `ChartErrBars` from @silurus/ooxml-core. */
7028
+ /** @deprecated Use `ChartErrBars` from @silurus/ooxml-core. Scheduled for
7029
+ * removal in a future breaking release. */
6811
7030
  type ErrBars = ChartErrBars;
6812
- /** @deprecated Use `ChartManualLayout` from @silurus/ooxml-core. */
7031
+ /** @deprecated Use `ChartManualLayout` from @silurus/ooxml-core. Scheduled for
7032
+ * removal in a future breaking release. */
6813
7033
  type ManualLayout = ChartManualLayout;
6814
7034
  interface ChartAnchor {
6815
7035
  fromCol: number;
@@ -7537,8 +7757,8 @@ type WireRenderViewportOptions = Omit<RenderViewportOptions, 'onTextRun' | 'load
7537
7757
  //#endregion
7538
7758
  //#region packages/xlsx/src/workbook.d.ts
7539
7759
  /** Options for {@link XlsxWorkbook.load}. Extends the shared load-options type
7540
- * from `@silurus/ooxml-core` (`useGoogleFonts`, `maxZipEntryBytes`, `math`)
7541
- * with the worker-rendering mode. */
7760
+ * from `@silurus/ooxml-core` (`useGoogleFonts`, `resourceLimits`, the
7761
+ * deprecated `maxZipEntryBytes` alias, and `math`) with worker rendering. */
7542
7762
  interface LoadOptions extends LoadOptions$3 {
7543
7763
  /**
7544
7764
  * 'main' (default): parse in a worker, render on the main thread (current
@@ -7550,25 +7770,28 @@ interface LoadOptions extends LoadOptions$3 {
7550
7770
  mode?: 'main' | 'worker';
7551
7771
  }
7552
7772
  declare class XlsxWorkbook {
7773
+ private metrics;
7553
7774
  private worker;
7554
7775
  private bridge;
7555
7776
  private parsedWorkbook;
7556
7777
  private sheetCache;
7557
- /** Cache of decoded image sources keyed by their zip `imagePath`. Shared
7558
- * across sheets. */
7559
- private imageCache;
7778
+ /** One materialization per sheet at a time. This becomes the ownership seam
7779
+ * for the bounded worksheet cursor: concurrent callers share one cursor and
7780
+ * one eventual mutable compatibility object instead of doubling peak work. */
7781
+ private sheetLoads;
7560
7782
  /** Cache of fetched image *bytes* (as Blobs) keyed by zip path, populated by
7561
7783
  * {@link XlsxWorkbook.getImage}. Twin of pptx/docx's per-instance
7562
- * `_imageCache`; kept separate from {@link XlsxWorkbook.imageCache} (decoded
7563
- * sources) so each layer dedupes independently. */
7564
- private imageBlobCache;
7784
+ * raw-part owner; decoded sources are owned separately by core. */
7785
+ private readonly rawParts;
7786
+ /** Public archive-queue reservations. Kept separate so an active render does
7787
+ * not await a same-path load that is queued behind that render. */
7788
+ private queuedImageLoads;
7565
7789
  /** One stable closure per instance: core's path-keyed SVG cache namespaces on
7566
7790
  * this identity, so two open workbooks never swap a shared zip path (e.g.
7567
7791
  * xl/media/image1.svg). Reusing one reference also lets the SVG cache hit
7568
7792
  * across viewport renders. */
7569
7793
  private readonly _fetchImage;
7570
- private rawData;
7571
- private maxZipEntryBytes;
7794
+ private resourcePolicy;
7572
7795
  /** Opt-in OMML equation engine, injected once at {@link load}. Every
7573
7796
  * `renderViewport` call reuses it — equations in shapes render when present,
7574
7797
  * and are skipped (engine tree-shaken) when omitted. */
@@ -7580,6 +7803,16 @@ declare class XlsxWorkbook {
7580
7803
  * so a web font shared with another open workbook survives until both go). */
7581
7804
  private googleFontFaces;
7582
7805
  private _mode;
7806
+ private generation;
7807
+ private nextSheetSessionId;
7808
+ private archiveOperationTail;
7809
+ private sheetSessions;
7810
+ private workerTimeoutMs;
7811
+ private retainedSheetUsage;
7812
+ /** First fatal model/package violation. Compatibility materialization happens
7813
+ * on main, so this latch is the document-level poison boundary for every
7814
+ * later public operation on the same workbook instance. */
7815
+ private resourceFailure;
7583
7816
  private constructor();
7584
7817
  /** Parse an XLSX from a URL or ArrayBuffer. */
7585
7818
  static load(source: string | ArrayBuffer, opts?: LoadOptions): Promise<XlsxWorkbook>;
@@ -7605,6 +7838,12 @@ declare class XlsxWorkbook {
7605
7838
  */
7606
7839
  isHidden(sheetIndex: number): boolean;
7607
7840
  getWorksheet(sheetIndex: number): Promise<Worksheet>;
7841
+ /** Return a fresh content-free metrics snapshot, including lazy worksheet and
7842
+ * media work completed since load. */
7843
+ getResourceMetrics(): Promise<OoxmlResourceMetrics>;
7844
+ private loadWorksheet;
7845
+ private loadWorksheetStream;
7846
+ private runArchiveOperation;
7608
7847
  /**
7609
7848
  * Fetch an embedded image's bytes by zip path (e.g. `xl/media/image1.png`),
7610
7849
  * wrapped in a Blob of the given MIME. The bytes are pulled through the
@@ -7613,11 +7852,12 @@ declare class XlsxWorkbook {
7613
7852
  * instance. The renderer's `fetchImage` option points here so image bytes are
7614
7853
  * extracted lazily rather than inlined as base64 at parse time.
7615
7854
  *
7616
- * Routed through the worker even though the main thread also retains
7617
- * `rawData`, to keep all WASM `extract_image` decoding on the worker (the
7618
- * route-through-worker decision).
7855
+ * Routed through the persistent worker so all WASM `extract_image` decoding
7856
+ * stays with the archive owner.
7619
7857
  */
7620
7858
  getImage(imagePath: string, mimeType: string): Promise<Blob>;
7859
+ private getImageWithinArchiveOperation;
7860
+ private requestImage;
7621
7861
  /**
7622
7862
  * Project the workbook to GitHub-flavoured markdown: each sheet becomes a
7623
7863
  * `## SheetName` section followed by a pipe table of its populated bounding
@@ -7684,7 +7924,9 @@ declare class XlsxWorkbook {
7684
7924
  width: number;
7685
7925
  height: number;
7686
7926
  }): Promise<ImageBitmap>;
7927
+ private withWorksheetArchiveOperation;
7687
7928
  destroy(): void;
7929
+ private assertResourceHealthy;
7688
7930
  }
7689
7931
  //#endregion
7690
7932
  //#region packages/xlsx/src/find.d.ts
@@ -7743,6 +7985,19 @@ interface XlsxViewerOptions extends LoadOptions$3 {
7743
7985
  * `onReady`).
7744
7986
  */
7745
7987
  onSheetChange?: (index: number, total: number) => void;
7988
+ /**
7989
+ * Receives load failures and asynchronous render failures handled by the
7990
+ * Viewer. Supplying this callback changes load-failure delivery: `load()`
7991
+ * invokes it and resolves; without it, the same load/parse failure rejects
7992
+ * `load()`. Viewer-managed render failures invoke it, or fall back to
7993
+ * `console.error` when omitted.
7994
+ *
7995
+ * Stable cases can be narrowed with `OoxmlError`,
7996
+ * `OoxmlResourceLimitError`, or `OoxmlDecodedImageLimitError` re-exported by
7997
+ * this package. Other failures remain `Error` values; do not parse message
7998
+ * text as an API. A `code` of `parser-crashed` identifies a recognized WASM
7999
+ * trap, not a reliably classified OOM.
8000
+ */
7746
8001
  onError?: (err: Error) => void;
7747
8002
  /** Called when the selected cell range changes. null means no selection. */
7748
8003
  onSelectionChange?: (selection: CellRange | null) => void;
@@ -8384,6 +8639,8 @@ declare class XlsxViewer implements ZoomableViewer {
8384
8639
  get sheetNames(): string[];
8385
8640
  /** The underlying <canvas> element the grid is drawn on. */
8386
8641
  get canvasElement(): HTMLCanvasElement;
8642
+ /** Latest content-free resource metrics for the loaded workbook. */
8643
+ getResourceMetrics(): Promise<OoxmlResourceMetrics>;
8387
8644
  /**
8388
8645
  * Tear down the viewer and release resources.
8389
8646
  *
@@ -8417,7 +8674,7 @@ declare class XlsxViewer implements ZoomableViewer {
8417
8674
  */
8418
8675
  declare function resolveSharedStrings(ws: Worksheet, sharedStrings: SharedString[]): Worksheet;
8419
8676
  declare namespace xlsx_d_exports {
8420
- export { AutoResizeOptions, Border, BorderEdge, Cell, CellAddress, CellFill, CellFont, CellRange, CellValue, CellXf, CfIcon, CfRule, CfStop, CfValue, ChartAnchor, ChartDataLabelOverride, ChartDataPointOverride, ChartErrBars, ChartManualLayout, ChartModel, ChartSeries, ChartSeriesDataLabels, ConditionalFormat, DataLabelOverride, DataPointOverride, DataValidation, DefinedName, Duotone, Dxf, ErrBars, FindHighlightColors, FindMatch, FindMatchesOptions, GradientFillSpec, HiddenSheetMode, Hyperlink, HyperlinkTarget, ImageAnchor, LegendManualLayout, LoadOptions, ManualLayout, MergeCell, NumFmt, OoxmlError, OoxmlErrorCode, OutlinePr, ParsedWorkbook, PathCmd, PathInfo, PhoneticAlignment, PhoneticProperties, PhoneticRun, PhoneticType, PivotCacheSource, PivotDataField, PivotDiagnostic, PivotLocation, PivotMetadataStatus, PivotPageField, PivotPartialReason, PivotTableMetadata, RenderViewportOptions, ResolvedList, Row, Run, RunFont, SelectionMode, SeriesDataLabels, ShapeAnchor, ShapeGeom, ShapeInfo, ShapeParagraph, ShapeText, ShapeTextRun, SharedString, SheetMeta, SheetVisibility, SlicerAnchor, SlicerElementStyle, SlicerItem, SlicerStyle, Sparkline, SparklineGroup, Styles, TableColumnInfo, TableInfo, ViewportRange, WireRenderViewportOptions, WireSizeOverrides, Workbook, Worksheet, XlsxChartSeries, XlsxComment, XlsxMatchLocation, XlsxTextRunInfo, XlsxViewer, XlsxViewerOptions, XlsxWorkbook, autoResize, openExternalHyperlink, resolveSharedStrings };
8677
+ export { AutoResizeOptions, Border, BorderEdge, Cell, CellAddress, CellFill, CellFont, CellRange, CellValue, CellXf, CfIcon, CfRule, CfStop, CfValue, ChartAnchor, ChartDataLabelOverride, ChartDataPointOverride, ChartErrBars, ChartManualLayout, ChartModel, ChartSeries, ChartSeriesDataLabels, ConditionalFormat, DataLabelOverride, DataPointOverride, DataValidation, DefinedName, Duotone, Dxf, ErrBars, FindHighlightColors, FindMatch, FindMatchesOptions, GradientFillSpec, HiddenSheetMode, Hyperlink, HyperlinkTarget, ImageAnchor, LegendManualLayout, LoadOptions, ManualLayout, MergeCell, NumFmt, OoxmlDecodedImageLimitError, OoxmlDecodedImageLimitMetric, OoxmlError, OoxmlErrorCode, OoxmlErrorSource, OoxmlErrorStage, OoxmlFormat, OoxmlResourceLimit, OoxmlResourceLimitError, OoxmlResourceLimitErrorDetails, OoxmlResourceLimits, OoxmlResourceMetric, OoxmlResourceMetrics, OoxmlResourceMetricsCheckpoint, OoxmlResourceName, OoxmlResourcePolicySnapshot, OoxmlResourceUsageSnapshot, OoxmlResourceViolation, OutlinePr, ParsedWorkbook, PathCmd, PathInfo, PhoneticAlignment, PhoneticProperties, PhoneticRun, PhoneticType, PivotCacheSource, PivotDataField, PivotDiagnostic, PivotLocation, PivotMetadataStatus, PivotPageField, PivotPartialReason, PivotTableMetadata, RenderViewportOptions, ResolvedList, Row, Run, RunFont, SelectionMode, SeriesDataLabels, ShapeAnchor, ShapeGeom, ShapeInfo, ShapeParagraph, ShapeText, ShapeTextRun, SharedString, SheetMeta, SheetVisibility, SlicerAnchor, SlicerElementStyle, SlicerItem, SlicerStyle, Sparkline, SparklineGroup, Styles, TableColumnInfo, TableInfo, ViewportRange, WireRenderViewportOptions, WireSizeOverrides, Workbook, Worksheet, XlsxChartSeries, XlsxComment, XlsxMatchLocation, XlsxTextRunInfo, XlsxViewer, XlsxViewerOptions, XlsxWorkbook, autoResize, isOoxmlDecodedImageLimitError, openExternalHyperlink, resolveSharedStrings };
8421
8678
  }
8422
8679
  //#endregion
8423
8680
  export { docx_d_exports as docx, pptx_d_exports as pptx, xlsx_d_exports as xlsx };