@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,98 @@
1
+ import { G as e, W as t, cn as n } from "./bounded-raw-part-cache-B7JoC1CD.js";
2
+ import { a as r, g as i, i as a, j as o, l as s, r as c } from "./document-pull-client-CxONDGbk.js";
3
+ import { r as l } from "./wasm-loader-rlgHmcSv.js";
4
+ import { r as u } from "./document-pull-worker-AMyXYpPq.js";
5
+ import { i as d, t as f } from "./docx-D91ER1_S.js";
6
+ import { t as p } from "./model-source-DJGzDtGb.js";
7
+ //#region packages/node/src/docx-model-source.ts
8
+ var m = class extends f {
9
+ constructor(...e) {
10
+ super(...e);
11
+ }
12
+ renderPage(e, t = {}) {
13
+ return super.renderPage(e, {
14
+ ...t,
15
+ showTrackedChanges: !0
16
+ });
17
+ }
18
+ };
19
+ async function h(e, i, a) {
20
+ let l = n(i.cjkFallback), { acquired: u, viewDefaults: d } = await v(e, i, a, c);
21
+ try {
22
+ if (i.signal?.aborted) {
23
+ let e = /* @__PURE__ */ Error("DOCX document session was aborted");
24
+ throw e.name = "AbortError", e;
25
+ }
26
+ let e = i.factory.createCanvas(1, 1), t = s(u.result, {
27
+ cjkFallback: l,
28
+ measureContext: e.getContext("2d"),
29
+ allowFootnoteContinuation: i.allowFootnoteContinuation !== !1
30
+ }), n = _(i.currentDate), a = r(u.result, t, n), c = d.showTrackedChanges === !0, p = c ? a.layoutVariants.layoutFor(o(n, n, !0)) : a.layoutVariants.defaultLayout, h = new (c ? m : f)(u.closeArchive, u.archive, u.result, t, p, i.factory, n, u.usage, u.metrics, i.signal);
31
+ return u.metrics.observeUsage(h.resourceUsage), u.metrics.checkpoint("pagination ready"), h;
32
+ } catch (e) {
33
+ try {
34
+ u.closeArchive();
35
+ } catch {}
36
+ let n = t(e) ?? e;
37
+ throw u.metrics.fail(n), n;
38
+ }
39
+ }
40
+ async function g(e, t, n) {
41
+ return l(async () => {
42
+ let { acquired: r } = await v(e, t, n, a), i = !1;
43
+ return {
44
+ acquired: r,
45
+ markSucceeded: () => {
46
+ i = !0;
47
+ },
48
+ close: async () => {
49
+ try {
50
+ r.closeArchive(), i && r.metrics.succeed({ documents: 1 });
51
+ } catch (e) {
52
+ throw r.metrics.fail(e), e;
53
+ }
54
+ }
55
+ };
56
+ }, async ({ acquired: e, markSucceeded: t }) => {
57
+ try {
58
+ let n = i(e.result);
59
+ return e.metrics.checkpoint("document materialized", e.usage), t(), n;
60
+ } catch (t) {
61
+ throw e.metrics.fail(t), t;
62
+ }
63
+ });
64
+ }
65
+ function _(e) {
66
+ let t = e instanceof Date ? e.getTime() : e ?? Date.now();
67
+ if (!Number.isFinite(t)) throw RangeError("currentDate must resolve to finite epoch milliseconds");
68
+ return t;
69
+ }
70
+ async function v(t, n, r, i) {
71
+ let { acquireDocxSessionFromArchive: a, validateDocxModelSourceArchive: o, validateDocxModelSourceViewDefaults: s } = await import("./model-source-session-CDuijwv1.js"), c = await p(t, "docx", {
72
+ ...n,
73
+ source: n.legacyDoc
74
+ }, o, (t) => e(t) ?? u(t));
75
+ if (c.kind === "ooxml") return {
76
+ acquired: await d(c.bytes, r(), n, i),
77
+ viewDefaults: {}
78
+ };
79
+ let l;
80
+ try {
81
+ l = s(c.opened.viewDefaults);
82
+ } catch (e) {
83
+ try {
84
+ c.opened.close();
85
+ } catch {}
86
+ throw e;
87
+ }
88
+ return {
89
+ acquired: await a({
90
+ archive: c.opened.archive,
91
+ sourceByteLength: c.sourceByteLength,
92
+ closeArchive: c.opened.close
93
+ }, n, i),
94
+ viewDefaults: l
95
+ };
96
+ }
97
+ //#endregion
98
+ export { g as materializeDocxSource, h as openDocxSource };
@@ -0,0 +1,455 @@
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/docx/src/internal/worker-document-source.ts
352
+ var W = [
353
+ "open_document_cursor",
354
+ "pull_document_chunk",
355
+ "document_chunk_done",
356
+ "acknowledge_document_chunk",
357
+ "cancel_document_cursor",
358
+ "close_document_session",
359
+ "assert_healthy",
360
+ "extract_image"
361
+ ];
362
+ function G(e) {
363
+ return _(e, "DOCX", W), e;
364
+ }
365
+ function K(e) {
366
+ for (let t of Object.keys(e)) if (t !== "showTrackedChanges") throw TypeError(`unsupported DOCX model source view default: ${t}`);
367
+ return e.showTrackedChanges === void 0 ? {} : { showTrackedChanges: e.showTrackedChanges };
368
+ }
369
+ var q = (e, t, n) => h(e, t, G, void 0, n), J = class {
370
+ ooxmlHost;
371
+ openSource;
372
+ modelSource;
373
+ pending;
374
+ copyBytes(e) {
375
+ return f(e);
376
+ }
377
+ extractImage(e) {
378
+ return this.execute((t) => this.copyBytes(t.extract_image(e)));
379
+ }
380
+ constructor(e, t = q) {
381
+ this.ooxmlHost = e, this.openSource = t;
382
+ }
383
+ get kind() {
384
+ return this.modelSource ? "model-source" : "ooxml";
385
+ }
386
+ async openModelSource(e, t, n = []) {
387
+ if (this.modelSource || this.pending || this.ooxmlHost.archive) throw Error("Document source already loaded or opening");
388
+ let r = {};
389
+ this.pending = r;
390
+ try {
391
+ let i = await this.openSource(t, e, n), a;
392
+ try {
393
+ if (a = K(i.viewDefaults), this.pending !== r || this.ooxmlHost.archive) throw Error("Document source open was superseded");
394
+ } catch (e) {
395
+ try {
396
+ i.close();
397
+ } catch {}
398
+ throw e;
399
+ }
400
+ let o = H(i.archive, "pull_document_chunk");
401
+ return this.modelSource = {
402
+ archive: i.archive,
403
+ transferArchive: o,
404
+ viewDefaults: a,
405
+ close: i.close
406
+ }, a;
407
+ } finally {
408
+ this.pending === r && (this.pending = void 0);
409
+ }
410
+ }
411
+ get viewDefaults() {
412
+ return this.modelSource?.viewDefaults ?? {};
413
+ }
414
+ cursor() {
415
+ return this.modelSource?.archive ?? this.ooxmlHost.archive;
416
+ }
417
+ execute(e) {
418
+ let t = this.modelSource;
419
+ if (!t) {
420
+ let t = this.ooxmlHost.archive;
421
+ if (!t) throw Error("Document not loaded");
422
+ return this.ooxmlHost.run(() => e(t));
423
+ }
424
+ return U(() => e(t.transferArchive), () => {
425
+ this.modelSource === t && this.closeModelSource();
426
+ });
427
+ }
428
+ resourceUsage() {
429
+ let e = this.modelSource;
430
+ if (e) return v(e.archive, "resource_usage") ? this.execute(() => e.archive.resource_usage()) : void 0;
431
+ let t = this.ooxml();
432
+ return this.ooxmlHost.run(() => t.resource_usage());
433
+ }
434
+ toMarkdown() {
435
+ let e = this.modelSource;
436
+ if (e) {
437
+ if (!v(e.archive, "to_markdown")) throw y("Markdown conversion");
438
+ return this.execute(() => e.archive.to_markdown());
439
+ }
440
+ let t = this.ooxml();
441
+ return this.ooxmlHost.run(() => t.to_markdown());
442
+ }
443
+ closeModelSource() {
444
+ this.pending = void 0;
445
+ let e = this.modelSource;
446
+ this.modelSource = void 0, e?.close();
447
+ }
448
+ ooxml() {
449
+ let e = this.ooxmlHost.archive;
450
+ if (!e) throw Error("Document not loaded");
451
+ return e;
452
+ }
453
+ };
454
+ //#endregion
455
+ export { J as WorkerDocumentSourceOwner };
package/dist/docx.mjs CHANGED
@@ -1,7 +1,7 @@
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 { a as i, c as a, i as o, l as s, n as c, o as l, r as u, s as d } from "./docx-BF9WXrYH.js";
4
- import { l as f, s as p } from "./pixel-budget-9P63Bsk5.js";
5
- import { i as m, s as h } from "./raster-target-ojDdQizC.js";
6
- import { n as g, r as _ } from "./comments-Diid5ujN.js";
7
- export { a as DocxDocument, u as DocxScrollViewer, o as DocxViewer, p as OoxmlDecodedImageLimitError, e as OoxmlError, n as OoxmlResourceLimitError, m as TiffDecodeError, r as autoResize, l as buildDocxHighlightLayer, d as buildDocxTextLayer, f as isOoxmlDecodedImageLimitError, h as isTiffDecodeError, c as noteText, t as openExternalHyperlink, i as readDocxTextSelectionContext, g as resolveCommentAnchorRuns, _ as resolveDocxCommentThreads, s as resolveRevisionAnchorRuns };
1
+ import { $a as e, eo as t } from "./plot-area-frame-CaJFvZ7p.js";
2
+ import { u as n } from "./bounded-raw-part-cache-B7JoC1CD.js";
3
+ import { a as r, c as i, d as a, f as o, i as s, n as c, o as l, p as u, r as d, s as f } from "./docx-DhDnKEI6.js";
4
+ import { f as p, u as m } from "./pixel-budget-BpTYrepD.js";
5
+ import { i as h, t as g } from "./tiff-contract-C6M3QcPp.js";
6
+ import { D as _ } from "./canvas-viewer-mechanics-DfQqRKkD.js";
7
+ export { i as DocxDocument, d as DocxScrollViewer, s as DocxViewer, m as OoxmlDecodedImageLimitError, e as OoxmlError, t as OoxmlResourceLimitError, g as TiffDecodeError, _ as autoResize, l as buildDocxHighlightLayer, f as buildDocxTextLayer, p as isOoxmlDecodedImageLimitError, h as isTiffDecodeError, c as noteText, n as openExternalHyperlink, r as readDocxTextSelectionContext, o as resolveCommentAnchorRuns, u as resolveDocxCommentThreads, a as resolveRevisionAnchorRuns };
Binary file