@silurus/ooxml 0.88.0 → 0.89.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 (128) hide show
  1. package/README.md +118 -23
  2. package/THIRD_PARTY_NOTICES.md +7 -6
  3. package/dist/abort-VrnK7mdP.js +10 -0
  4. package/dist/assets/render-worker-CUOU6mL2.js +16 -0
  5. package/dist/assets/render-worker-DOqrFhSU.js +15 -0
  6. package/dist/assets/render-worker-DvWUdZUN.js +35 -0
  7. package/dist/bounded-raw-part-cache-B7JoC1CD.js +64586 -0
  8. package/dist/bundled-asset-url-E2nXURF9.js +15 -0
  9. package/dist/canvas-viewer-mechanics-DfQqRKkD.js +675 -0
  10. package/dist/cfb-guard-9QTRTg7f.js +528 -0
  11. package/dist/chart-ex.mjs +692 -688
  12. package/dist/comment-overlay-controller-B5_zGgG5.js +994 -0
  13. package/dist/comment-ui-runtime-B7ZvovcS.js +2 -0
  14. package/dist/{comment-ui-runtime-DcJOYlw-.js → comment-ui-runtime-D_sb2K6s.js} +5 -5
  15. package/dist/{comment-ui-runtime-CWGqn5Vr.js → comment-ui-runtime-Jy-3goA9.js} +5 -5
  16. package/dist/delimited-text-worker-host-CikWU6_m.js +27 -0
  17. package/dist/document-model-source-BKNrXjAL.js +249 -0
  18. package/dist/document-pull-client-CxONDGbk.js +37833 -0
  19. package/dist/document-pull-worker-AMyXYpPq.js +104 -0
  20. package/dist/docx-D91ER1_S.js +495 -0
  21. package/dist/docx-DhDnKEI6.js +3563 -0
  22. package/dist/docx-model-source-CdrSt3hF.js +98 -0
  23. package/dist/docx-source-worker.mjs +455 -0
  24. package/dist/docx.mjs +7 -7
  25. package/dist/docx_parser_bg.wasm +0 -0
  26. package/dist/drawingml-shape-ChcGZNd8.js +310 -0
  27. package/dist/duotone-ekYik4ix.js +126 -0
  28. package/dist/emf-UT6I8rVi.js +1790 -0
  29. package/dist/font-preload-demand-CdJZUMCT.js +2058 -0
  30. package/dist/grid-geometry-uQOgViJU.js +384 -0
  31. package/dist/host-layout-DVMw8hDY.js +56 -0
  32. package/dist/host-layout-measure-CCEgaC_v.js +7 -0
  33. package/dist/in-process-pull-transport-DuXcPZng.js +29 -0
  34. package/dist/index.mjs +4 -4
  35. package/dist/internal-companion.mjs +12 -0
  36. package/dist/line-distribute-CPOV6csk.js +2716 -0
  37. package/dist/math.mjs +2 -2
  38. package/dist/mathjax-stix2.js +10 -10
  39. package/dist/model-source-DJGzDtGb.js +61 -0
  40. package/dist/model-source-kz_NkZqT.js +179 -0
  41. package/dist/model-source-session-Bu9CHFHc.js +71 -0
  42. package/dist/model-source-session-CDuijwv1.js +85 -0
  43. package/dist/model-source-session-sKpNiIJI.js +58 -0
  44. package/dist/node.mjs +7 -1327
  45. package/dist/{pixel-budget-9P63Bsk5.js → pixel-budget-BpTYrepD.js} +13 -10
  46. package/dist/plot-area-frame-CaJFvZ7p.js +8502 -0
  47. package/dist/pptx-CDP9dZHe.js +2936 -0
  48. package/dist/pptx-C_uxLVKB.js +183 -0
  49. package/dist/pptx-model-source-O7LhpOjz.js +37 -0
  50. package/dist/pptx-source-worker.mjs +446 -0
  51. package/dist/pptx.mjs +8 -7
  52. package/dist/pptx_parser_bg.wasm +0 -0
  53. package/dist/presentation-model-source-tmROzteR.js +77 -0
  54. package/dist/raster-target-YQ4G6rxo.js +42 -0
  55. package/dist/region-map.mjs +114 -150
  56. package/dist/{render-D3iqVKCo.js → render-CJVglUHl.js} +3 -3
  57. package/dist/{render-worker-host-B5wQfB7U.js → render-worker-host-BseIaVvm.js} +1 -1
  58. package/dist/{render-worker-host-D4123J27.js → render-worker-host-CyxPU4JU.js} +1 -1
  59. package/dist/{render-worker-host-Di3LxLc0.js → render-worker-host-aF6aWkC0.js} +1 -1
  60. package/dist/renderer-CkGLj0CC.js +5170 -0
  61. package/dist/renderer-Czw1cCC7.js +5823 -0
  62. package/dist/resource-measurement-mXw-WjMF.js +771 -0
  63. package/dist/session-Csv9maad.js +656 -0
  64. package/dist/slide-pull-client-DRZYwBTu.js +6515 -0
  65. package/dist/three-d-BK5siJgJ.js +878 -0
  66. package/dist/three-d.mjs +960 -945
  67. package/dist/{raster-target-ojDdQizC.js → tiff-contract-C6M3QcPp.js} +1 -42
  68. package/dist/tiff.mjs +401 -248
  69. package/dist/types/chart-ex.d.ts +149 -2
  70. package/dist/types/docx.d.ts +333 -96
  71. package/dist/types/index.d.ts +566 -301
  72. package/dist/types/internal-companion.d.ts +11 -0
  73. package/dist/types/math.d.ts +1 -1
  74. package/dist/types/node.d.ts +422 -9
  75. package/dist/types/pptx.d.ts +302 -95
  76. package/dist/types/region-map.d.ts +149 -2
  77. package/dist/types/three-d.d.ts +149 -2
  78. package/dist/types/tiff.d.ts +1 -1
  79. package/dist/types/xlsx.d.ts +343 -132
  80. package/dist/wasm-loader-rlgHmcSv.js +35 -0
  81. package/dist/wasm-runtime-generation-DX4y0Ecl.js +97 -0
  82. package/dist/workbook-model-source-BTC4ISTS.js +94 -0
  83. package/dist/worker-source-I1cIYBel.js +22 -0
  84. package/dist/worker-source-SbudzjYL.js +22 -0
  85. package/dist/worker-source-UAi3GNcM.js +22 -0
  86. package/dist/worksheet-pull-client-CkHgbtyM.js +579 -0
  87. package/dist/xlsx-CpSDPAEU.js +5809 -0
  88. package/dist/xlsx-D5569TPf.js +534 -0
  89. package/dist/xlsx-model-source-DPSkjFic.js +309 -0
  90. package/dist/xlsx-source-worker.mjs +525 -0
  91. package/dist/xlsx.mjs +8 -7
  92. package/dist/xlsx_parser_bg.wasm +0 -0
  93. package/package.json +42 -16
  94. package/dist/assets/render-worker-1uPAxMZr.js +0 -31
  95. package/dist/assets/render-worker-BlvJybji.js +0 -10
  96. package/dist/assets/render-worker-CzmiJfFL.js +0 -11
  97. package/dist/bounded-raw-part-cache-Cg1BsSZQ.js +0 -119
  98. package/dist/canvas-viewer-mechanics-DbLz0rYW.js +0 -1384
  99. package/dist/cjk-fallback-bLI3z70h.js +0 -46
  100. package/dist/comment-occurrence-C8Y2uoVr.js +0 -6
  101. package/dist/comment-ui-runtime-BsK8pmUT.js +0 -2
  102. package/dist/comments-Diid5ujN.js +0 -246
  103. package/dist/delimited-text-worker-host-BVY-Ecni.js +0 -27
  104. package/dist/document-pull-client-B9PTM-pL.js +0 -27280
  105. package/dist/docx-BF9WXrYH.js +0 -3103
  106. package/dist/dom-interaction-boundary-Cnm8DSBN.js +0 -223
  107. package/dist/highlight-rect-C5hkRqUr.js +0 -13
  108. package/dist/hyperlink-Cxzhet30.js +0 -36446
  109. package/dist/line-distribute-D1WNHKz_.js +0 -1023
  110. package/dist/line-metrics-B60C86uh.js +0 -60
  111. package/dist/plot-area-frame-DLTYKHNP.js +0 -4354
  112. package/dist/pptx-DkyYBYoL.js +0 -3065
  113. package/dist/renderer-B4GZb5We.js +0 -6492
  114. package/dist/resource-measurement-SHQCbkh2.js +0 -150
  115. package/dist/session-BGq81gRQ.js +0 -743
  116. package/dist/slide-pull-client-DiPnm240.js +0 -6253
  117. package/dist/source-key-DIJG8BA0.js +0 -42
  118. package/dist/three-d-DJBl8g8M.js +0 -1162
  119. package/dist/transfer-p6iCC2R7.js +0 -6
  120. package/dist/units-BzZ0gAxs.js +0 -4
  121. package/dist/worksheet-pull-client-BM8ywvbu.js +0 -458
  122. package/dist/xlsx-C9NVjgaV.js +0 -8484
  123. /package/dist/{chunk-DmhlhrBa.js → chunk-Dy4uBu1J.js} +0 -0
  124. /package/dist/{mathjax-DoyWZbSp.js → mathjax-BhwN6ilc.js} +0 -0
  125. /package/dist/{read-only-comment-decoration-Dz7eTQ4d.js → read-only-comment-decoration-PidH0wnP.js} +0 -0
  126. /package/dist/{read-only-comment-margin-DkgzASAl.js → read-only-comment-margin-B52rDVKo.js} +0 -0
  127. /package/dist/{renderer-module-contract-D91rkYHH.js → renderer-module-contract-CWM7jv6d.js} +0 -0
  128. /package/dist/{visible-index-BgiHEc1z.js → visible-index-FeVA0mGE.js} +0 -0
@@ -0,0 +1,183 @@
1
+ import { t as e } from "./slide-pull-client-DRZYwBTu.js";
2
+ import { eo as t } from "./plot-area-frame-CaJFvZ7p.js";
3
+ import { H as n, W as r, cn as i, jn as a, pt as o, t as s, ut as c } from "./bounded-raw-part-cache-B7JoC1CD.js";
4
+ import { n as l } from "./abort-VrnK7mdP.js";
5
+ import { n as u, r as d, t as f } from "./wasm-loader-rlgHmcSv.js";
6
+ import { i as p, n as m, r as h } from "./session-Csv9maad.js";
7
+ import { t as g } from "./in-process-pull-transport-DuXcPZng.js";
8
+ //#region packages/node/src/pptx.ts
9
+ var _ = "PPTX presentation session was aborted", v = f(() => u(import.meta.url, "pptx_parser_bg.wasm", "@silurus/ooxml-pptx/wasm-binary"));
10
+ async function y(e, t = {}) {
11
+ return b(e, t);
12
+ }
13
+ async function b(e, t = {}) {
14
+ if (t.legacyPpt !== void 0) {
15
+ let { openPptxSource: n } = await import("./pptx-model-source-O7LhpOjz.js");
16
+ return n(e, t, v);
17
+ }
18
+ let n = i(t.cjkFallback), r = await m(C(e), v(), t);
19
+ return new x(r.closeArchive, r.archive, r.bootstrap, r.metrics, t.signal, n);
20
+ }
21
+ var x = class {
22
+ closeArchive;
23
+ archive;
24
+ bootstrap;
25
+ metrics;
26
+ signal;
27
+ cjkFallback;
28
+ slideCount;
29
+ slideWidth;
30
+ slideHeight;
31
+ slidePull;
32
+ slideClient;
33
+ transport;
34
+ started = !1;
35
+ closed = !1;
36
+ closePromise;
37
+ usage;
38
+ consumedSlides = 0;
39
+ resourceFailure;
40
+ renderTail = Promise.resolve();
41
+ fetchImage = (e, t) => this.getPartInternal(e, t, (t) => t.extract_image(e));
42
+ fetchMedia = (e) => this.getPartInternal(e, "application/octet-stream", (t) => t.extract_media(e));
43
+ rawParts = new s({
44
+ maxEntries: 64,
45
+ maxBytes: a
46
+ });
47
+ constructor(t, n, r, i, a, o) {
48
+ this.closeArchive = t, this.archive = n, this.bootstrap = r, this.metrics = i, this.signal = a, this.cjkFallback = o, this.slideCount = r.slideCount, this.slideWidth = r.slideWidth, this.slideHeight = r.slideHeight, this.slidePull = new h(() => this.archive), this.transport = new g((e, t) => this.slidePull.dispatchSafely(e, t), () => void 0), this.slideClient = new e({
49
+ slideCount: this.slideCount,
50
+ transport: this.transport,
51
+ open: async (e, t) => {
52
+ this.slidePull.reserveOpen(t), await this.slidePull.open(e, t);
53
+ },
54
+ onUsage: (e) => {
55
+ this.usage = e, this.metrics.observeUsage(e);
56
+ }
57
+ });
58
+ }
59
+ materialize(e) {
60
+ return {
61
+ slideWidth: this.slideWidth,
62
+ slideHeight: this.slideHeight,
63
+ slides: e,
64
+ defaultTextColor: this.bootstrap.defaultTextColor,
65
+ majorFont: this.bootstrap.majorFont,
66
+ minorFont: this.bootstrap.minorFont,
67
+ ...this.bootstrap.hlinkColor ? { hlinkColor: this.bootstrap.hlinkColor } : {},
68
+ ...this.bootstrap.folHlinkColor ? { folHlinkColor: this.bootstrap.folHlinkColor } : {}
69
+ };
70
+ }
71
+ get resourceUsage() {
72
+ return this.closed ? this.usage : this.refreshResourceUsage();
73
+ }
74
+ async getImage(e, t) {
75
+ return this.assertOpen(), this.getPartInternal(e, t, (t) => t.extract_image(e)).catch((e) => this.failOperation(e));
76
+ }
77
+ async getMedia(e, t = "application/octet-stream") {
78
+ return this.assertOpen(), this.getPartInternal(e, t, (t) => t.extract_media(e)).catch((e) => this.failOperation(e));
79
+ }
80
+ async renderSlide(e, t, n) {
81
+ return this.assertOpen(), this.enqueueRender(async () => {
82
+ l(this.signal, _);
83
+ let { renderSlideNode: r } = await import("./render-CJVglUHl.js").then((e) => e.i);
84
+ await r(e, {
85
+ slideWidth: this.slideWidth,
86
+ slideHeight: this.slideHeight,
87
+ slides: [t],
88
+ defaultTextColor: this.bootstrap.defaultTextColor,
89
+ majorFont: this.bootstrap.majorFont,
90
+ minorFont: this.bootstrap.minorFont,
91
+ ...this.bootstrap.hlinkColor ? { hlinkColor: this.bootstrap.hlinkColor } : {},
92
+ ...this.bootstrap.folHlinkColor ? { folHlinkColor: this.bootstrap.folHlinkColor } : {}
93
+ }, 0, {
94
+ ...n,
95
+ cjkFallback: this.cjkFallback,
96
+ fetchImage: this.fetchImage,
97
+ fetchMedia: this.fetchMedia
98
+ }), l(this.signal, _);
99
+ }).catch((e) => this.failOperation(e));
100
+ }
101
+ [Symbol.asyncIterator]() {
102
+ return this.slides();
103
+ }
104
+ async *slides() {
105
+ if (this.closed) throw Error("PPTX presentation session is closed");
106
+ if (this.started) throw Error("PPTX presentation session is one-pass and was already consumed");
107
+ this.started = !0;
108
+ let e;
109
+ try {
110
+ for (let e = 0; e < this.slideCount; e += 1) {
111
+ l(this.signal, _);
112
+ let t = await this.slideClient.load(e);
113
+ if (!t) throw Error(`PPTX slide ${e} was not decoded`);
114
+ this.usage ??= await this.slidePull.run(() => p((e) => e(this.archive))), this.metrics.observeUsage(this.usage), this.consumedSlides = e + 1, yield t;
115
+ }
116
+ } catch (t) {
117
+ throw e = r(t) ?? t, this.metrics.fail(e), e;
118
+ } finally {
119
+ try {
120
+ await this.close();
121
+ } catch (t) {
122
+ if (e === void 0) throw t;
123
+ }
124
+ }
125
+ }
126
+ close() {
127
+ return this.closePromise ? this.closePromise : (this.closed = !0, this.slideClient.cancelAll(), this.closePromise = this.release(), this.closePromise);
128
+ }
129
+ async release() {
130
+ let e;
131
+ await this.renderTail, o(this.fetchImage), c(this.fetchImage);
132
+ try {
133
+ await this.slidePull.reset();
134
+ } catch (t) {
135
+ e = r(t) ?? t;
136
+ }
137
+ this.transport.terminate(), this.rawParts.clear();
138
+ try {
139
+ this.closeArchive();
140
+ } catch (t) {
141
+ e ??= r(t) ?? t;
142
+ }
143
+ if (e !== void 0) throw this.metrics.fail(e), e;
144
+ this.metrics.checkpoint("presentation session closed"), this.metrics.succeed({ slides: this.consumedSlides });
145
+ }
146
+ enqueueRender(e) {
147
+ let t = this.renderTail.then(e, e);
148
+ return this.renderTail = t.then(() => void 0, () => void 0), t;
149
+ }
150
+ getPartInternal(e, t, n) {
151
+ return this.rawParts.get(e, t, () => {
152
+ l(this.signal, _);
153
+ let e = n(this.archive);
154
+ return this.refreshResourceUsage(), new Blob([e], { type: t });
155
+ });
156
+ }
157
+ refreshResourceUsage() {
158
+ try {
159
+ this.usage = n(this.archive.resource_usage()), this.metrics.observeUsage(this.usage);
160
+ } catch {}
161
+ return this.usage;
162
+ }
163
+ assertOpen() {
164
+ if (this.closed) throw Error("PPTX presentation session is closed");
165
+ if (this.resourceFailure) throw this.resourceFailure;
166
+ }
167
+ failOperation(e) {
168
+ let n = r(e) ?? e;
169
+ throw n instanceof t && (this.resourceFailure ??= n), this.metrics.fail(n), n;
170
+ }
171
+ };
172
+ async function S(e, t = {}) {
173
+ return d(() => b(e, t), async (e) => {
174
+ let t = [];
175
+ for await (let n of e.slides()) t.push(n);
176
+ return e.materialize(t);
177
+ });
178
+ }
179
+ function C(e) {
180
+ return e instanceof Uint8Array ? e : new Uint8Array(e);
181
+ }
182
+ //#endregion
183
+ export { S as n, y as r, x as t };
@@ -0,0 +1,37 @@
1
+ import { cn as e } from "./bounded-raw-part-cache-B7JoC1CD.js";
2
+ import { n as t } from "./session-Csv9maad.js";
3
+ import { t as n } from "./pptx-C_uxLVKB.js";
4
+ import { t as r } from "./model-source-DJGzDtGb.js";
5
+ //#region packages/node/src/pptx-model-source.ts
6
+ async function i(t, r, i) {
7
+ let o = await a(t, r, i), s = new Proxy(o.archive, { get(e, t) {
8
+ if (t === "extract_media" && !e.extract_media) return () => {
9
+ throw Error("media extraction is unsupported for this source");
10
+ };
11
+ let n = Reflect.get(e, t);
12
+ return typeof n == "function" ? n.bind(e) : n;
13
+ } });
14
+ return new n(o.closeArchive, s, o.bootstrap, o.metrics, r.signal, e(r.cjkFallback));
15
+ }
16
+ async function a(e, n, i) {
17
+ let { acquirePptxSessionFromArchive: a, validatePptxModelSourceArchive: o, validatePptxModelSourceViewDefaults: s } = await import("./model-source-session-sKpNiIJI.js"), c = await r(e, "pptx", {
18
+ ...n,
19
+ source: n.legacyPpt
20
+ }, o);
21
+ if (c.kind === "ooxml") return t(c.bytes, i(), n);
22
+ try {
23
+ s(c.opened.viewDefaults);
24
+ } catch (e) {
25
+ try {
26
+ c.opened.close();
27
+ } catch {}
28
+ throw e;
29
+ }
30
+ return a({
31
+ archive: c.opened.archive,
32
+ sourceByteLength: c.sourceByteLength,
33
+ closeArchive: c.opened.close
34
+ }, n);
35
+ }
36
+ //#endregion
37
+ export { i as openPptxSource };
@@ -0,0 +1,446 @@
1
+ //#region packages/core/src/internal/abort.ts
2
+ function e(e) {
3
+ let t = Error(e);
4
+ return t.name = "AbortError", t;
5
+ }
6
+ function t(t, n) {
7
+ if (t?.aborted) throw e(n);
8
+ }
9
+ //#endregion
10
+ //#region packages/core/src/source/model-source.ts
11
+ var n = "model source load was aborted", r = "ooxml-model-source-module/v2", i = new Set([
12
+ "docx",
13
+ "xlsx",
14
+ "pptx"
15
+ ]), a = new Set([
16
+ "http:",
17
+ "https:",
18
+ "file:",
19
+ "blob:"
20
+ ]), o = [
21
+ "protocol",
22
+ "target",
23
+ "moduleUrl",
24
+ "config"
25
+ ], s = 8192, c = 32, l = 8192, u = 16, d = /^[A-Za-z][A-Za-z0-9_]{0,63}$/;
26
+ function f(e) {
27
+ if (!(e instanceof Uint8Array)) throw TypeError("model source archive must return Uint8Array bytes");
28
+ let t = new Uint8Array(e.byteLength);
29
+ return t.set(e), t.buffer;
30
+ }
31
+ function p(e, t) {
32
+ if (typeof e != "object" || !e || Array.isArray(e)) throw TypeError("model source module descriptor must be an object");
33
+ let n = Reflect.ownKeys(e);
34
+ if (n.length !== o.length || o.some((e) => !n.includes(e))) throw TypeError("model source module descriptor has unknown or missing fields");
35
+ let c = Object.getOwnPropertyDescriptors(e);
36
+ if (o.some((e) => !c[e]?.enumerable || !("value" in c[e]))) throw TypeError("model source module descriptor fields must be data properties");
37
+ let l = c.protocol.value, u = c.target.value, d = c.moduleUrl.value;
38
+ if (l !== "ooxml-model-source-module/v2") throw TypeError("unsupported model source module protocol");
39
+ if (typeof u != "string" || !i.has(u)) throw TypeError("unsupported model source target");
40
+ if (t !== void 0 && u !== t) throw TypeError(`a ${u} model source module cannot load ${t} input`);
41
+ if (typeof d != "string" || d.length === 0 || d.length > s || d.trim() !== d) throw TypeError("model source moduleUrl must be a nonempty absolute URL");
42
+ let f;
43
+ try {
44
+ f = new URL(d);
45
+ } catch {
46
+ throw TypeError("model source moduleUrl must be a nonempty absolute URL");
47
+ }
48
+ if (!a.has(f.protocol)) throw TypeError("model source moduleUrl protocol is unsupported");
49
+ return Object.freeze({
50
+ protocol: r,
51
+ target: u,
52
+ moduleUrl: d,
53
+ config: m(c.config.value)
54
+ });
55
+ }
56
+ function m(e) {
57
+ if (!b(e)) throw TypeError("model source config must be a plain object");
58
+ let t = Reflect.ownKeys(e);
59
+ if (t.length > c) throw RangeError(`model source config accepts at most ${c} entries`);
60
+ let n = {};
61
+ for (let r of t) {
62
+ if (typeof r != "string" || !d.test(r)) throw TypeError("model source config keys must be short identifiers");
63
+ let t = Object.getOwnPropertyDescriptor(e, r);
64
+ if (!t?.enumerable || !("value" in t)) throw TypeError("model source config entries must be data properties");
65
+ let i = t.value;
66
+ if (typeof i == "string") {
67
+ if (i.length > l) throw RangeError("model source config string is too long");
68
+ } else if (typeof i == "number") {
69
+ if (!Number.isFinite(i)) throw TypeError("model source config numbers must be finite");
70
+ } else if (typeof i != "boolean" && i !== null) throw TypeError("model source config values must be strings, numbers, booleans or null");
71
+ n[r] = i;
72
+ }
73
+ return Object.freeze(n);
74
+ }
75
+ async function h(e, r, i, a, o = []) {
76
+ let s = p(e);
77
+ t(a, n);
78
+ let c = await import(
79
+ /* @vite-ignore */
80
+ s.moduleUrl
81
+ ), l = typeof c == "object" && c ? c.openModelSource : void 0;
82
+ if (typeof l != "function") throw TypeError("model source module must export openModelSource()");
83
+ t(a, n);
84
+ let u = await l(r, s.config, a, o);
85
+ if (typeof u != "object" || !u) throw TypeError("openModelSource() must return an object");
86
+ let d = u, f = d.close;
87
+ if (typeof f != "function") throw TypeError("an opened model source must provide close()");
88
+ let m = !1, h = () => {
89
+ m || (m = !0, f.call(u));
90
+ };
91
+ try {
92
+ let e = i(d.archive), r = g(d.viewDefaults);
93
+ return t(a, n), Object.freeze({
94
+ archive: e,
95
+ viewDefaults: r,
96
+ close: h
97
+ });
98
+ } catch (e) {
99
+ try {
100
+ h();
101
+ } catch {}
102
+ throw e;
103
+ }
104
+ }
105
+ function g(e) {
106
+ if (e === void 0) return Object.freeze({});
107
+ if (!b(e)) throw TypeError("model source viewDefaults must be a plain object");
108
+ let t = Reflect.ownKeys(e);
109
+ if (t.length > u) throw RangeError("model source viewDefaults has too many entries");
110
+ let n = {};
111
+ for (let r of t) {
112
+ let t = typeof r == "string" ? Object.getOwnPropertyDescriptor(e, r) : void 0;
113
+ if (typeof r != "string" || !d.test(r) || !t?.enumerable || !("value" in t) || typeof t.value != "boolean") throw TypeError("model source viewDefaults entries must be boolean data properties");
114
+ n[r] = t.value;
115
+ }
116
+ return Object.freeze(n);
117
+ }
118
+ function _(e, t, n) {
119
+ if (typeof e != "object" && typeof e != "function" || e === null) throw TypeError(`${t} model source archive must be an object`);
120
+ for (let r of n) if (typeof e[r] != "function") throw TypeError(`${t} model source archive must implement ${r}()`);
121
+ }
122
+ function v(e, t) {
123
+ return (typeof e == "object" || typeof e == "function") && e !== null && typeof e[t] == "function";
124
+ }
125
+ function y(e) {
126
+ return /* @__PURE__ */ Error(`${e} is unsupported for this source`);
127
+ }
128
+ function b(e) {
129
+ if (typeof e != "object" || !e || Array.isArray(e)) return !1;
130
+ let t = Object.getPrototypeOf(e);
131
+ return t === Object.prototype || t === null;
132
+ }
133
+ //#endregion
134
+ //#region packages/core/src/errors/ooxml-error.ts
135
+ var x = class e extends Error {
136
+ code = "ooxml-resource-limit";
137
+ details;
138
+ constructor(t, n) {
139
+ super(t), this.name = "OoxmlResourceLimitError";
140
+ let r = n.violation, i = Object.freeze({
141
+ format: r.format,
142
+ operation: r.operation,
143
+ resource: r.resource,
144
+ metric: r.metric,
145
+ ...r.part === void 0 ? {} : { part: r.part },
146
+ limit: r.limit,
147
+ observed: r.observed,
148
+ configurable: r.configurable,
149
+ usage: Object.freeze({
150
+ archiveEntryCount: r.usage.archiveEntryCount,
151
+ declaredInflatedBytes: r.usage.declaredInflatedBytes,
152
+ ...r.usage.largestInflatedEntryBytes === void 0 ? {} : { largestInflatedEntryBytes: r.usage.largestInflatedEntryBytes },
153
+ distinctInflatedBytes: r.usage.distinctInflatedBytes,
154
+ operationInflatedBytes: r.usage.operationInflatedBytes
155
+ })
156
+ });
157
+ this.details = Object.freeze({
158
+ stage: n.stage,
159
+ violation: i
160
+ }), Object.setPrototypeOf(this, e.prototype);
161
+ }
162
+ }, S = "OOXML_RESOURCE_LIMIT:", C = 128, w = 256, T = 4096;
163
+ function E(e) {
164
+ return typeof e == "number" && Number.isSafeInteger(e) && e >= 0;
165
+ }
166
+ function D(e) {
167
+ if (!e || typeof e != "object" || Array.isArray(e)) return !1;
168
+ let t = e;
169
+ return E(t.archiveEntryCount) && E(t.declaredInflatedBytes) && (t.largestInflatedEntryBytes === void 0 || E(t.largestInflatedEntryBytes)) && E(t.distinctInflatedBytes) && E(t.operationInflatedBytes);
170
+ }
171
+ function O(e) {
172
+ return e === "docx" || e === "xlsx" || e === "pptx";
173
+ }
174
+ function k(e) {
175
+ return e === "container" || e === "decompression" || e === "parsing" || e === "serialization" || e === "layout" || e === "rendering" || e === "worker";
176
+ }
177
+ function A(e, t) {
178
+ return typeof e == "string" && e.length > 0 && e.length <= t && !/[\u0000-\u001f\u007f]/u.test(e);
179
+ }
180
+ function j(e) {
181
+ return A(e, C) && /^[a-z0-9][a-z0-9-]*$/u.test(e);
182
+ }
183
+ function M(e) {
184
+ return !A(e, T) || e.startsWith("/") || e.startsWith("\\") || e.includes("\\") || e.includes("?") || e.includes("#") || e.includes("://") || /^[a-z]:/iu.test(e) ? !1 : e.split("/").every((e) => e !== "" && e !== "." && e !== "..");
185
+ }
186
+ var N = new Map([
187
+ ["archive-entry:declared-inflated-bytes", {
188
+ stage: "container",
189
+ part: "required"
190
+ }],
191
+ ["archive-entry:actual-inflated-bytes", {
192
+ stage: "decompression",
193
+ part: "required"
194
+ }],
195
+ ["archive:entry-count", {
196
+ stage: "container",
197
+ part: "forbidden"
198
+ }],
199
+ ["archive:central-directory-bytes", {
200
+ stage: "container",
201
+ part: "forbidden",
202
+ configurable: !1
203
+ }],
204
+ ["archive:distinct-inflated-bytes", {
205
+ stage: "decompression",
206
+ part: "required"
207
+ }],
208
+ ["xml-event:bytes", {
209
+ stage: "parsing",
210
+ part: "optional",
211
+ configurable: !1
212
+ }],
213
+ ["xml-context:bytes", {
214
+ stage: "parsing",
215
+ part: "optional",
216
+ configurable: !1
217
+ }],
218
+ ["image-effect:work", {
219
+ stage: "parsing",
220
+ part: "forbidden",
221
+ configurable: !1
222
+ }],
223
+ ["chartex-allocation:elements", {
224
+ stage: "parsing",
225
+ part: "forbidden",
226
+ configurable: !1
227
+ }],
228
+ ["chartex-allocation:bytes", {
229
+ stage: "parsing",
230
+ part: "forbidden",
231
+ configurable: !1
232
+ }],
233
+ ["chart-cache:points", {
234
+ stage: "parsing",
235
+ part: "forbidden",
236
+ configurable: !1
237
+ }],
238
+ ["numbering-marker:bytes", {
239
+ stage: "parsing",
240
+ part: "forbidden",
241
+ configurable: !1
242
+ }],
243
+ ["chart-style-formats:entries", {
244
+ stage: "parsing",
245
+ part: "required",
246
+ configurable: !1
247
+ }],
248
+ ["chart-custom-number-formats:entries", {
249
+ stage: "parsing",
250
+ part: "required",
251
+ configurable: !1
252
+ }],
253
+ ["chart-number-format-bytes:bytes", {
254
+ stage: "parsing",
255
+ part: "required",
256
+ configurable: !1
257
+ }],
258
+ ["xml-tree:depth", {
259
+ stage: "parsing",
260
+ part: "optional",
261
+ configurable: !1
262
+ }],
263
+ ["worksheet-row:projected-bytes", {
264
+ stage: "parsing",
265
+ part: "optional",
266
+ configurable: !1
267
+ }],
268
+ ["worksheet-shell:projected-bytes", {
269
+ stage: "parsing",
270
+ part: "optional",
271
+ configurable: !1
272
+ }],
273
+ ["theme-style-reparse:bytes", {
274
+ stage: "parsing",
275
+ part: "forbidden",
276
+ configurable: !1
277
+ }],
278
+ ["style-inheritance:depth", {
279
+ stage: "parsing",
280
+ part: "required",
281
+ configurable: !1
282
+ }],
283
+ ["complex-field:depth", {
284
+ stage: "parsing",
285
+ part: "forbidden",
286
+ configurable: !1
287
+ }]
288
+ ]), P = new Set([...N.keys()].map((e) => e.slice(0, e.indexOf(":")))), F = new Set([...N.keys()].map((e) => e.slice(e.indexOf(":") + 1)));
289
+ function I(e) {
290
+ if (!e || typeof e != "object" || Array.isArray(e)) return !1;
291
+ let t = e;
292
+ return !O(t.format) || !A(t.operation, w) || !j(t.resource) || !j(t.metric) || !E(t.limit) || !E(t.observed) || typeof t.configurable != "boolean" || !D(t.usage) ? !1 : !("part" in t) || M(t.part);
293
+ }
294
+ function L(e) {
295
+ if (!e || typeof e != "object" || Array.isArray(e)) return !1;
296
+ let t = e;
297
+ if (!k(t.stage) || !I(t.violation)) return !1;
298
+ let n = t.violation, r = N.get(`${n.resource}:${n.metric}`);
299
+ return r ? t.stage !== r.stage || r.configurable === !1 && n.configurable !== !1 ? !1 : r.part === "required" ? n.part !== void 0 : r.part === "forbidden" ? n.part === void 0 : !0 : !(P.has(n.resource) && F.has(n.metric));
300
+ }
301
+ function R(e) {
302
+ let t = e.violation;
303
+ return `OOXML resource limit exceeded${t.part ? ` for ${t.part}` : ""} (${t.resource}, ${e.stage}): ${t.metric} ${t.observed} > ${t.limit}`;
304
+ }
305
+ function z(e) {
306
+ let t = e instanceof Error ? e.message : String(e);
307
+ if (!t.startsWith(S)) return;
308
+ let n;
309
+ try {
310
+ n = JSON.parse(t.slice(21));
311
+ } catch {
312
+ return;
313
+ }
314
+ if (!n || typeof n != "object") return;
315
+ let r = n;
316
+ if (!(r.code !== "ooxml-resource-limit" || !L(r.details))) return new x(R(r.details), r.details);
317
+ }
318
+ function B(e) {
319
+ try {
320
+ return e();
321
+ } catch (e) {
322
+ throw e instanceof x || typeof e != "string" && !(e instanceof Error) ? e : z(e) ?? e;
323
+ }
324
+ }
325
+ //#endregion
326
+ //#region packages/core/src/worker/wasm-guard.ts
327
+ function V(e) {
328
+ let t = globalThis.WebAssembly?.RuntimeError;
329
+ return t && e instanceof t || e instanceof RangeError ? !0 : e instanceof Error ? e.name === "RuntimeError" || e.name === "CompileError" || e.name === "LinkError" || e.name === "InternalError" || e.name === "OOMError" : !1;
330
+ }
331
+ //#endregion
332
+ //#region packages/core/src/source/worker-model-source.ts
333
+ function H(e, t) {
334
+ return new Proxy(e, { get(e, n) {
335
+ if (n === t) return (...n) => new Uint8Array(f(Reflect.apply(e[t], e, n)));
336
+ let r = Reflect.get(e, n);
337
+ return typeof r == "function" ? r.bind(e) : r;
338
+ } });
339
+ }
340
+ function U(e, t) {
341
+ try {
342
+ return B(e);
343
+ } catch (e) {
344
+ if (V(e)) try {
345
+ t();
346
+ } catch {}
347
+ throw e;
348
+ }
349
+ }
350
+ //#endregion
351
+ //#region packages/pptx/src/internal/worker-presentation-source.ts
352
+ var W = [
353
+ "pull_slide",
354
+ "slide_cursor_resource_usage",
355
+ "acknowledge_slide",
356
+ "cancel_slide",
357
+ "close_presentation_session",
358
+ "assert_healthy",
359
+ "presentation_bootstrap",
360
+ "extract_image"
361
+ ];
362
+ function G(e) {
363
+ return _(e, "PPTX", W), e;
364
+ }
365
+ function K(e) {
366
+ let [t] = Object.keys(e);
367
+ if (t !== void 0) throw TypeError(`unsupported PPTX model source view default: ${t}`);
368
+ }
369
+ var q = (e, t, n) => h(e, t, G, void 0, n), J = class {
370
+ ooxmlHost;
371
+ openSource;
372
+ modelSource;
373
+ copyBytes(e) {
374
+ return f(e);
375
+ }
376
+ extractImage(e) {
377
+ return this.execute((t) => this.copyBytes(t.extract_image(e)));
378
+ }
379
+ constructor(e, t = q) {
380
+ this.ooxmlHost = e, this.openSource = t;
381
+ }
382
+ get kind() {
383
+ return this.modelSource ? "model-source" : "ooxml";
384
+ }
385
+ async openModelSource(e, t, n = []) {
386
+ if (this.modelSource || this.ooxmlHost.archive) throw Error("Presentation source already loaded");
387
+ let r = await this.openSource(t, e, n);
388
+ try {
389
+ if (K(r.viewDefaults), this.modelSource || this.ooxmlHost.archive) throw Error("Presentation source open was superseded");
390
+ } catch (e) {
391
+ try {
392
+ r.close();
393
+ } catch {}
394
+ throw e;
395
+ }
396
+ let i = H(r.archive, "pull_slide");
397
+ return this.modelSource = {
398
+ archive: r.archive,
399
+ transferArchive: i,
400
+ close: r.close
401
+ }, r.archive;
402
+ }
403
+ cursor() {
404
+ return this.modelSource?.archive ?? this.ooxmlHost.archive;
405
+ }
406
+ execute(e) {
407
+ let t = this.modelSource;
408
+ if (!t) {
409
+ let t = this.ooxmlHost.archive;
410
+ if (!t) throw Error("Presentation not loaded");
411
+ return this.ooxmlHost.run(() => e(t));
412
+ }
413
+ return U(() => e(t.transferArchive), () => {
414
+ this.modelSource === t && this.closeModelSource();
415
+ });
416
+ }
417
+ extractMedia(e) {
418
+ return this.optional("extract_media", "media extraction", (t) => t.extract_media(e));
419
+ }
420
+ extractFont(e) {
421
+ return this.optional("extract_font", "font extraction", (t) => t.extract_font(e));
422
+ }
423
+ resourceUsage() {
424
+ let e = this.modelSource;
425
+ if (!(e && !v(e.archive, "resource_usage"))) return this.optional("resource_usage", "resource usage", (e) => e.resource_usage());
426
+ }
427
+ toMarkdown() {
428
+ return this.optional("to_markdown", "Markdown conversion", (e) => e.to_markdown());
429
+ }
430
+ closeModelSource() {
431
+ let e = this.modelSource;
432
+ this.modelSource = void 0, e?.close();
433
+ }
434
+ optional(e, t, n) {
435
+ let r = this.modelSource;
436
+ if (r) {
437
+ if (!v(r.archive, e)) throw y(t);
438
+ return this.execute(() => n(r.archive));
439
+ }
440
+ let i = this.ooxmlHost.archive;
441
+ if (!i) throw Error("Presentation not loaded");
442
+ return this.ooxmlHost.run(() => n(i));
443
+ }
444
+ };
445
+ //#endregion
446
+ export { J as WorkerPresentationSourceOwner };
package/dist/pptx.mjs CHANGED
@@ -1,7 +1,8 @@
1
- import { ln as e, r as t, un as n } from "./hyperlink-Cxzhet30.js";
2
- import { T as r } from "./canvas-viewer-mechanics-DbLz0rYW.js";
3
- import { l as i, s as a } from "./pixel-budget-9P63Bsk5.js";
4
- import { i as o, s } from "./raster-target-ojDdQizC.js";
5
- import { l as c } from "./slide-pull-client-DiPnm240.js";
6
- import { a as l, i as u, n as d, o as f, r as p, s as m } from "./pptx-DkyYBYoL.js";
7
- export { a as OoxmlDecodedImageLimitError, e as OoxmlError, n as OoxmlResourceLimitError, l as PptxPresentation, d as PptxScrollViewer, p as PptxViewer, o as TiffDecodeError, r as autoResize, f as buildPptxHighlightLayer, m as buildPptxTextLayer, i as isOoxmlDecodedImageLimitError, s as isTiffDecodeError, t as openExternalHyperlink, u as readPptxTextSelectionContext, c as renderSlide };
1
+ import { l as e } from "./slide-pull-client-DRZYwBTu.js";
2
+ import { $a as t, eo as n } from "./plot-area-frame-CaJFvZ7p.js";
3
+ import { u as r } from "./bounded-raw-part-cache-B7JoC1CD.js";
4
+ import { f as i, u as a } from "./pixel-budget-BpTYrepD.js";
5
+ import { i as o, t as s } from "./tiff-contract-C6M3QcPp.js";
6
+ import { D as c } from "./canvas-viewer-mechanics-DfQqRKkD.js";
7
+ import { a as l, c as u, i as d, l as f, n as p, o as m } from "./pptx-CDP9dZHe.js";
8
+ export { a as OoxmlDecodedImageLimitError, t as OoxmlError, n as OoxmlResourceLimitError, m as PptxPresentation, p as PptxScrollViewer, d as PptxViewer, s as TiffDecodeError, c as autoResize, u as buildPptxHighlightLayer, f as buildPptxTextLayer, i as isOoxmlDecodedImageLimitError, o as isTiffDecodeError, r as openExternalHyperlink, l as readPptxTextSelectionContext, e as renderSlide };
Binary file