@silurus/ooxml 0.88.0 → 0.89.1

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 (127) hide show
  1. package/README.md +118 -23
  2. package/THIRD_PARTY_NOTICES.md +8 -7
  3. package/dist/abort-VrnK7mdP.js +10 -0
  4. package/dist/assets/render-worker-C5G_Nr_A.js +35 -0
  5. package/dist/assets/render-worker-DQfWdNsm.js +16 -0
  6. package/dist/assets/render-worker-Ds7LjwU-.js +15 -0
  7. package/dist/{hyperlink-Cxzhet30.js → bounded-raw-part-cache-CsnNptAy.js} +4937 -7458
  8. package/dist/bundled-asset-url-E2nXURF9.js +15 -0
  9. package/dist/canvas-viewer-mechanics-BZ8QCrRi.js +675 -0
  10. package/dist/cfb-guard-dNeUiANF.js +528 -0
  11. package/dist/chart-ex.mjs +667 -663
  12. package/dist/comment-overlay-controller-CBvQx-En.js +994 -0
  13. package/dist/comment-ui-runtime-B7ZvovcS.js +2 -0
  14. package/dist/{comment-ui-runtime-DcJOYlw-.js → comment-ui-runtime-BKidRH36.js} +5 -5
  15. package/dist/{comment-ui-runtime-CWGqn5Vr.js → comment-ui-runtime-C47QoDUy.js} +5 -5
  16. package/dist/delimited-text-worker-host-CikWU6_m.js +27 -0
  17. package/dist/document-model-source-MzFPrxt0.js +249 -0
  18. package/dist/document-pull-client-BoJeuURD.js +35941 -0
  19. package/dist/document-pull-worker-CaP8XESP.js +104 -0
  20. package/dist/docx-BN70UhvX.js +495 -0
  21. package/dist/docx-BRRtSvk3.js +3563 -0
  22. package/dist/docx-model-source-CTO9iw_W.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-CHmq8kpM.js +310 -0
  27. package/dist/duotone-DN8P4aXe.js +126 -0
  28. package/dist/emf-CGFQIz6c.js +1790 -0
  29. package/dist/font-preload-demand-Dmy31xt-.js +2058 -0
  30. package/dist/grid-geometry-C3IG20ut.js +384 -0
  31. package/dist/host-layout-DVMw8hDY.js +56 -0
  32. package/dist/host-layout-measure-DsuQ2UJs.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-Bu8psjGd.js +2799 -0
  37. package/dist/math.mjs +2 -2
  38. package/dist/mathjax-stix2.js +10 -10
  39. package/dist/model-source-kz_NkZqT.js +179 -0
  40. package/dist/model-source-s5hRpk4w.js +61 -0
  41. package/dist/model-source-session-6fuaqbGs.js +71 -0
  42. package/dist/model-source-session-DqrR4XHR.js +85 -0
  43. package/dist/model-source-session-cPJSF_Ak.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-Bs_j4uu7.js +41811 -0
  47. package/dist/pptx-CaJ6ILnw.js +183 -0
  48. package/dist/pptx-_BOGcBym.js +2936 -0
  49. package/dist/pptx-model-source-B_9afw9R.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-CGHLyX32.js +77 -0
  54. package/dist/raster-target-YQ4G6rxo.js +42 -0
  55. package/dist/region-map.mjs +117 -153
  56. package/dist/{render-D3iqVKCo.js → render-CzbDzRKa.js} +3 -3
  57. package/dist/{render-worker-host-B5wQfB7U.js → render-worker-host-B1u6BOUd.js} +1 -1
  58. package/dist/{render-worker-host-D4123J27.js → render-worker-host-C-EECo68.js} +1 -1
  59. package/dist/{render-worker-host-Di3LxLc0.js → render-worker-host-DDqZTCVf.js} +1 -1
  60. package/dist/renderer-CD2cvVAF.js +5823 -0
  61. package/dist/renderer-DRoeb14O.js +5170 -0
  62. package/dist/resource-measurement-Dhhm7P_l.js +772 -0
  63. package/dist/session-XPmC0CUd.js +656 -0
  64. package/dist/slide-pull-client-tq7U_fYg.js +6485 -0
  65. package/dist/three-d-BKwNPAP4.js +878 -0
  66. package/dist/three-d.mjs +925 -910
  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-D6TKZdNb.js +97 -0
  82. package/dist/workbook-model-source-BIGrfZy6.js +94 -0
  83. package/dist/worker-source-DrwhR9fw.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-ClvPO_Jf.js +579 -0
  87. package/dist/xlsx-CsmREBaZ.js +5819 -0
  88. package/dist/xlsx-DmHfeNNp.js +534 -0
  89. package/dist/xlsx-model-source-D1flORqy.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/line-distribute-D1WNHKz_.js +0 -1023
  109. package/dist/line-metrics-B60C86uh.js +0 -60
  110. package/dist/plot-area-frame-DLTYKHNP.js +0 -4354
  111. package/dist/pptx-DkyYBYoL.js +0 -3065
  112. package/dist/renderer-B4GZb5We.js +0 -6492
  113. package/dist/resource-measurement-SHQCbkh2.js +0 -150
  114. package/dist/session-BGq81gRQ.js +0 -743
  115. package/dist/slide-pull-client-DiPnm240.js +0 -6253
  116. package/dist/source-key-DIJG8BA0.js +0 -42
  117. package/dist/three-d-DJBl8g8M.js +0 -1162
  118. package/dist/transfer-p6iCC2R7.js +0 -6
  119. package/dist/units-BzZ0gAxs.js +0 -4
  120. package/dist/worksheet-pull-client-BM8ywvbu.js +0 -458
  121. package/dist/xlsx-C9NVjgaV.js +0 -8484
  122. /package/dist/{chunk-DmhlhrBa.js → chunk-Dy4uBu1J.js} +0 -0
  123. /package/dist/{mathjax-DoyWZbSp.js → mathjax-BhwN6ilc.js} +0 -0
  124. /package/dist/{read-only-comment-decoration-Dz7eTQ4d.js → read-only-comment-decoration-PidH0wnP.js} +0 -0
  125. /package/dist/{read-only-comment-margin-DkgzASAl.js → read-only-comment-margin-B52rDVKo.js} +0 -0
  126. /package/dist/{renderer-module-contract-D91rkYHH.js → renderer-module-contract-CWM7jv6d.js} +0 -0
  127. /package/dist/{visible-index-BgiHEc1z.js → visible-index-FeVA0mGE.js} +0 -0
@@ -0,0 +1,104 @@
1
+ import { vo as e } from "./plot-area-frame-Bs_j4uu7.js";
2
+ import { B as t, D as n, G as r, O as i, k as a, ln as o, q as s, un as c } from "./bounded-raw-part-cache-CsnNptAy.js";
3
+ import { S as l } from "./worksheet-pull-client-ClvPO_Jf.js";
4
+ //#region packages/docx/src/internal/parser-errors.ts
5
+ var u = "OOXML_DOCX_ILVL:";
6
+ function d(t) {
7
+ let n = t instanceof Error ? t.message : String(t);
8
+ if (!n.startsWith(u)) return;
9
+ let r = n.slice(16);
10
+ if (r === "repair-required:level-definition") return new e("invalid-numbering", "The DOCX defines a numbering level outside Word’s supported 0–8 range and requires repair.");
11
+ if (r === "cannot-open:whitespace" || r === "cannot-open:non-decimal") return new e("invalid-numbering", `Word cannot open this DOCX numbering level (${r.slice(12)}).`);
12
+ }
13
+ function f(e) {
14
+ try {
15
+ return d(e) ?? e;
16
+ } catch {
17
+ return e;
18
+ }
19
+ }
20
+ function p(e) {
21
+ try {
22
+ return e();
23
+ } catch (e) {
24
+ throw f(e);
25
+ }
26
+ }
27
+ //#endregion
28
+ //#region packages/docx/src/document-pull-worker.ts
29
+ function m(e) {
30
+ let n = e((e) => e.document_cursor_resource_usage?.());
31
+ return n ? t(n) : void 0;
32
+ }
33
+ var h = Math.max(o, c), g = class {
34
+ archive;
35
+ coordinator = new a();
36
+ host = null;
37
+ identity = null;
38
+ executeArchive;
39
+ constructor(e, t = (e) => e(this.requireArchive())) {
40
+ this.archive = e, this.executeArchive = (e) => p(() => t(e));
41
+ }
42
+ open(e) {
43
+ if (this.host) throw Error("a DOCX document pull session is already active");
44
+ this.executeArchive((t) => {
45
+ t.open_document_cursor(e.operationId, e.generation);
46
+ });
47
+ let t = 0;
48
+ this.identity = e, this.host = new i({
49
+ ...e,
50
+ maxByteCredit: h,
51
+ coordinator: this.coordinator,
52
+ driver: {
53
+ pull: (n) => {
54
+ let r;
55
+ try {
56
+ r = this.executeArchive((r) => r.pull_document_chunk(t, e.operationId, e.generation, n));
57
+ } catch (e) {
58
+ throw s(e, n, h) || e;
59
+ }
60
+ let i = l(r);
61
+ return {
62
+ payload: i,
63
+ byteLength: i.byteLength,
64
+ done: this.executeArchive((e) => e.document_chunk_done()),
65
+ transfer: [i]
66
+ };
67
+ },
68
+ measureChunk: ({ payload: e }) => e.byteLength,
69
+ acknowledge: (n) => {
70
+ if (n !== t) throw Error("DOCX document acknowledgement sequence mismatch");
71
+ this.executeArchive((n) => n.acknowledge_document_chunk(t, e.operationId, e.generation)), t += 1;
72
+ },
73
+ cancel: () => this.executeArchive((e) => e.cancel_document_cursor()),
74
+ close: () => this.executeArchive((e) => e.close_document_session()),
75
+ resourceUsage: () => m(this.executeArchive)
76
+ }
77
+ });
78
+ }
79
+ dispatch(e, t) {
80
+ return !this.host || !this.identity ? (t({
81
+ protocol: n,
82
+ kind: "error",
83
+ sessionId: e.sessionId,
84
+ operationId: e.operationId,
85
+ generation: e.generation,
86
+ requestId: e.requestId,
87
+ error: r(/* @__PURE__ */ Error("DOCX document pull session is not open"))
88
+ }), Promise.resolve()) : this.host.dispatch(e, t);
89
+ }
90
+ async reset() {
91
+ if (this.host) try {
92
+ this.archive() && this.executeArchive((e) => e.close_document_session());
93
+ } finally {
94
+ this.host = null, this.identity = null, this.coordinator = new a();
95
+ }
96
+ }
97
+ requireArchive() {
98
+ let e = this.archive();
99
+ if (!e) throw Error("No docx loaded");
100
+ return e;
101
+ }
102
+ };
103
+ //#endregion
104
+ export { m as n, f as r, g as t };
@@ -0,0 +1,495 @@
1
+ import { t as e } from "./chunk-Dy4uBu1J.js";
2
+ import { yo as t } from "./plot-area-frame-Bs_j4uu7.js";
3
+ import { B as n, F as r, H as i, N as a, U as o, j as s, qt as c, st as l, ut as u } from "./bounded-raw-part-cache-CsnNptAy.js";
4
+ import { a as d, c as f, g as p, i as m, l as h, r as g } from "./document-pull-client-BoJeuURD.js";
5
+ import { n as _, t as ee } from "./abort-VrnK7mdP.js";
6
+ import { n as v, r as te, t as y } from "./wasm-loader-rlgHmcSv.js";
7
+ import { t as b } from "./wasm-runtime-generation-D6TKZdNb.js";
8
+ import { t as x } from "./in-process-pull-transport-DuXcPZng.js";
9
+ import { n as S, r as ne, t as re } from "./document-pull-worker-CaP8XESP.js";
10
+ import { a as ie } from "./render-CzbDzRKa.js";
11
+ //#region packages/docx/src/wasm/docx_parser.js
12
+ var C = /* @__PURE__ */ e({
13
+ DocxArchive: () => w,
14
+ default: () => q,
15
+ docx_to_markdown: () => T,
16
+ extract_image: () => ae,
17
+ initSync: () => se,
18
+ parse_docx: () => E,
19
+ reinit: () => ce
20
+ }), w = class {
21
+ __destroy_into_raw() {
22
+ let e = this.__wbg_ptr;
23
+ return this.__wbg_ptr = 0, O.unregister(this), e;
24
+ }
25
+ free() {
26
+ let e = this.__destroy_into_raw();
27
+ W.__wbg_docxarchive_free(e, 0);
28
+ }
29
+ acknowledge_document_chunk(e, t, n) {
30
+ let r = W.docxarchive_acknowledge_document_chunk(this.__wbg_ptr, e, t, n);
31
+ if (r[1]) throw R(r[0]);
32
+ }
33
+ assert_healthy() {
34
+ let e = W.docxarchive_assert_healthy(this.__wbg_ptr);
35
+ if (e[1]) throw R(e[0]);
36
+ }
37
+ cancel_document_cursor() {
38
+ W.docxarchive_cancel_document_cursor(this.__wbg_ptr);
39
+ }
40
+ close_document_session() {
41
+ W.docxarchive_close_document_session(this.__wbg_ptr);
42
+ }
43
+ document_chunk_done() {
44
+ let e = W.docxarchive_document_chunk_done(this.__wbg_ptr);
45
+ if (e[2]) throw R(e[1]);
46
+ return e[0] !== 0;
47
+ }
48
+ document_cursor_resource_usage() {
49
+ let e = W.docxarchive_document_cursor_resource_usage(this.__wbg_ptr);
50
+ if (e[3]) throw R(e[2]);
51
+ let t;
52
+ return e[0] !== 0 && (t = k(e[0], e[1]).slice(), W.__wbindgen_free(e[0], e[1] * 1, 1)), t;
53
+ }
54
+ extract_image(e) {
55
+ let t = L(e, W.__wbindgen_malloc, W.__wbindgen_realloc), n = U, r = W.docxarchive_extract_image(this.__wbg_ptr, t, n);
56
+ if (r[3]) throw R(r[2]);
57
+ var i = k(r[0], r[1]).slice();
58
+ return W.__wbindgen_free(r[0], r[1] * 1, 1), i;
59
+ }
60
+ constructor(e, t, n, r) {
61
+ let i = I(e, W.__wbindgen_malloc), a = U, o = W.docxarchive_new(i, a, !F(t), F(t) ? BigInt(0) : t, !F(n), F(n) ? BigInt(0) : n, !F(r), F(r) ? BigInt(0) : r);
62
+ if (o[2]) throw R(o[1]);
63
+ return this.__wbg_ptr = o[0] >>> 0, O.register(this, this.__wbg_ptr, this), this;
64
+ }
65
+ open_document_cursor(e, t) {
66
+ let n = W.docxarchive_open_document_cursor(this.__wbg_ptr, e, t);
67
+ if (n[1]) throw R(n[0]);
68
+ }
69
+ parse() {
70
+ let e = W.docxarchive_parse(this.__wbg_ptr);
71
+ if (e[3]) throw R(e[2]);
72
+ var t = k(e[0], e[1]).slice();
73
+ return W.__wbindgen_free(e[0], e[1] * 1, 1), t;
74
+ }
75
+ pull_document_chunk(e, t, n, r) {
76
+ let i = W.docxarchive_pull_document_chunk(this.__wbg_ptr, e, t, n, r);
77
+ if (i[3]) throw R(i[2]);
78
+ var a = k(i[0], i[1]).slice();
79
+ return W.__wbindgen_free(i[0], i[1] * 1, 1), a;
80
+ }
81
+ resource_usage() {
82
+ let e = W.docxarchive_resource_usage(this.__wbg_ptr);
83
+ if (e[3]) throw R(e[2]);
84
+ var t = k(e[0], e[1]).slice();
85
+ return W.__wbindgen_free(e[0], e[1] * 1, 1), t;
86
+ }
87
+ to_markdown() {
88
+ let e, t;
89
+ try {
90
+ let i = W.docxarchive_to_markdown(this.__wbg_ptr);
91
+ var n = i[0], r = i[1];
92
+ if (i[3]) throw n = 0, r = 0, R(i[2]);
93
+ return e = n, t = r, M(n, r);
94
+ } finally {
95
+ W.__wbindgen_free(e, t, 1);
96
+ }
97
+ }
98
+ };
99
+ Symbol.dispose && (w.prototype[Symbol.dispose] = w.prototype.free);
100
+ function T(e, t, n) {
101
+ let r, i;
102
+ try {
103
+ let s = I(e, W.__wbindgen_malloc), c = U, l = W.docx_to_markdown(s, c, !F(t), F(t) ? BigInt(0) : t, !F(n), F(n) ? BigInt(0) : n);
104
+ var a = l[0], o = l[1];
105
+ if (l[3]) throw a = 0, o = 0, R(l[2]);
106
+ return r = a, i = o, M(a, o);
107
+ } finally {
108
+ W.__wbindgen_free(r, i, 1);
109
+ }
110
+ }
111
+ function ae(e, t, n, r) {
112
+ let i = I(e, W.__wbindgen_malloc), a = U, o = L(t, W.__wbindgen_malloc, W.__wbindgen_realloc), s = U, c = W.extract_image(i, a, o, s, !F(n), F(n) ? BigInt(0) : n, !F(r), F(r) ? BigInt(0) : r);
113
+ if (c[3]) throw R(c[2]);
114
+ var l = k(c[0], c[1]).slice();
115
+ return W.__wbindgen_free(c[0], c[1] * 1, 1), l;
116
+ }
117
+ function E(e, t, n) {
118
+ let r = I(e, W.__wbindgen_malloc), i = U, a = W.parse_docx(r, i, !F(t), F(t) ? BigInt(0) : t, !F(n), F(n) ? BigInt(0) : n);
119
+ if (a[3]) throw R(a[2]);
120
+ var o = k(a[0], a[1]).slice();
121
+ return W.__wbindgen_free(a[0], a[1] * 1, 1), o;
122
+ }
123
+ function D() {
124
+ return {
125
+ __proto__: null,
126
+ "./docx_parser_bg.js": {
127
+ __proto__: null,
128
+ __wbg___wbindgen_throw_6b64449b9b9ed33c: function(e, t) {
129
+ throw Error(M(e, t));
130
+ },
131
+ __wbg_error_a6fa202b58aa1cd3: function(e, t) {
132
+ let n, r;
133
+ try {
134
+ n = e, r = t, console.error(M(e, t));
135
+ } finally {
136
+ W.__wbindgen_free(n, r, 1);
137
+ }
138
+ },
139
+ __wbg_new_227d7c05414eb861: function() {
140
+ return /* @__PURE__ */ Error();
141
+ },
142
+ __wbg_stack_3b0d974bbf31e44f: function(e, t) {
143
+ let n = t.stack, r = L(n, W.__wbindgen_malloc, W.__wbindgen_realloc), i = U;
144
+ j().setInt32(e + 4, i, !0), j().setInt32(e + 0, r, !0);
145
+ },
146
+ __wbindgen_cast_0000000000000001: function(e, t) {
147
+ return M(e, t);
148
+ },
149
+ __wbindgen_init_externref_table: function() {
150
+ let e = W.__wbindgen_externrefs, t = e.grow(4);
151
+ e.set(0, void 0), e.set(t + 0, void 0), e.set(t + 1, null), e.set(t + 2, !0), e.set(t + 3, !1);
152
+ }
153
+ }
154
+ };
155
+ }
156
+ var O = typeof FinalizationRegistry > "u" ? {
157
+ register: () => {},
158
+ unregister: () => {}
159
+ } : new FinalizationRegistry((e) => W.__wbg_docxarchive_free(e >>> 0, 1));
160
+ function k(e, t) {
161
+ return e >>>= 0, P().subarray(e / 1, e / 1 + t);
162
+ }
163
+ var A = null;
164
+ function j() {
165
+ return (A === null || A.buffer.detached === !0 || A.buffer.detached === void 0 && A.buffer !== W.memory.buffer) && (A = new DataView(W.memory.buffer)), A;
166
+ }
167
+ function M(e, t) {
168
+ return e >>>= 0, V(e, t);
169
+ }
170
+ var N = null;
171
+ function P() {
172
+ return (N === null || N.byteLength === 0) && (N = new Uint8Array(W.memory.buffer)), N;
173
+ }
174
+ function F(e) {
175
+ return e == null;
176
+ }
177
+ function I(e, t) {
178
+ let n = t(e.length * 1, 1) >>> 0;
179
+ return P().set(e, n / 1), U = e.length, n;
180
+ }
181
+ function L(e, t, n) {
182
+ if (n === void 0) {
183
+ let n = H.encode(e), r = t(n.length, 1) >>> 0;
184
+ return P().subarray(r, r + n.length).set(n), U = n.length, r;
185
+ }
186
+ let r = e.length, i = t(r, 1) >>> 0, a = P(), o = 0;
187
+ for (; o < r; o++) {
188
+ let t = e.charCodeAt(o);
189
+ if (t > 127) break;
190
+ a[i + o] = t;
191
+ }
192
+ if (o !== r) {
193
+ o !== 0 && (e = e.slice(o)), i = n(i, r, r = o + e.length * 3, 1) >>> 0;
194
+ let t = P().subarray(i + o, i + r), a = H.encodeInto(e, t);
195
+ o += a.written, i = n(i, r, o, 1) >>> 0;
196
+ }
197
+ return U = o, i;
198
+ }
199
+ function R(e) {
200
+ let t = W.__wbindgen_externrefs.get(e);
201
+ return W.__externref_table_dealloc(e), t;
202
+ }
203
+ var z = new TextDecoder("utf-8", {
204
+ ignoreBOM: !0,
205
+ fatal: !0
206
+ });
207
+ z.decode();
208
+ var oe = 2146435072, B = 0;
209
+ function V(e, t) {
210
+ return B += t, B >= oe && (z = new TextDecoder("utf-8", {
211
+ ignoreBOM: !0,
212
+ fatal: !0
213
+ }), z.decode(), B = t), z.decode(P().subarray(e, e + t));
214
+ }
215
+ var H = new TextEncoder();
216
+ "encodeInto" in H || (H.encodeInto = function(e, t) {
217
+ let n = H.encode(e);
218
+ return t.set(n), {
219
+ read: e.length,
220
+ written: n.length
221
+ };
222
+ });
223
+ var U = 0, W;
224
+ function G(e, t) {
225
+ return W = e.exports, A = null, N = null, W.__wbindgen_start(), W;
226
+ }
227
+ async function K(e, t) {
228
+ if (typeof Response == "function" && e instanceof Response) {
229
+ if (typeof WebAssembly.instantiateStreaming == "function") try {
230
+ return await WebAssembly.instantiateStreaming(e, t);
231
+ } catch (t) {
232
+ if (e.ok && n(e.type) && e.headers.get("Content-Type") !== "application/wasm") console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", t);
233
+ else throw t;
234
+ }
235
+ let r = await e.arrayBuffer();
236
+ return await WebAssembly.instantiate(r, t);
237
+ } else {
238
+ let n = await WebAssembly.instantiate(e, t);
239
+ return n instanceof WebAssembly.Instance ? {
240
+ instance: n,
241
+ module: e
242
+ } : n;
243
+ }
244
+ function n(e) {
245
+ switch (e) {
246
+ case "basic":
247
+ case "cors":
248
+ case "default": return !0;
249
+ }
250
+ return !1;
251
+ }
252
+ }
253
+ function se(e) {
254
+ if (W !== void 0) return W;
255
+ e !== void 0 && (Object.getPrototypeOf(e) === Object.prototype ? {module: e} = e : console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));
256
+ let t = D();
257
+ return e instanceof WebAssembly.Module || (e = new WebAssembly.Module(e)), G(new WebAssembly.Instance(e, t), e);
258
+ }
259
+ async function q(e) {
260
+ if (W !== void 0) return W;
261
+ e !== void 0 && (Object.getPrototypeOf(e) === Object.prototype ? {module_or_path: e} = e : console.warn("using deprecated parameters for the initialization function; pass a single object instead"));
262
+ let t = D();
263
+ (typeof e == "string" || typeof Request == "function" && e instanceof Request || typeof URL == "function" && e instanceof URL) && (e = fetch(e));
264
+ let { instance: n, module: r } = await K(await e, t);
265
+ return G(n, r);
266
+ }
267
+ async function ce(e) {
268
+ return W = void 0, A = null, N = null, q(e);
269
+ }
270
+ //#endregion
271
+ //#region packages/docx/src/internal/node-acquisition.ts
272
+ var J = "DOCX document session was aborted", le = b(C, "DOCX");
273
+ async function Y(e, t, n, i) {
274
+ let c = a(n), l = new s({
275
+ enabled: c.debug || c.onResourceMetrics !== void 0,
276
+ format: "docx",
277
+ mode: "node",
278
+ scope: "session",
279
+ policy: c.policy,
280
+ onMetrics: c.onResourceMetrics,
281
+ emitToConsole: c.debug
282
+ });
283
+ l.setSourceBytes(e.byteLength);
284
+ let u, d, f;
285
+ try {
286
+ _(n.signal, J);
287
+ let [a, o, s] = r(c.policy), p = w;
288
+ u = await le(t).open(() => new p(e, a, o, s), {
289
+ signal: n.signal,
290
+ abortError: () => ee(J),
291
+ disposeOnAbort: (e) => e.free()
292
+ }), _(n.signal, J);
293
+ let m = u.proxy;
294
+ l.checkpoint("container ready"), d = new re(() => m);
295
+ let h = {
296
+ sessionId: 1,
297
+ operationId: 1,
298
+ generation: 1
299
+ };
300
+ d.open(h), f = new x((e, t) => d?.dispatch(e, t), () => void 0);
301
+ let g, v = await i(f, h, {
302
+ signal: n.signal,
303
+ onUsage: (e) => {
304
+ g = e, l.observeUsage(e);
305
+ }
306
+ });
307
+ return g ??= S((e) => e(m)), l.observeUsage(g), l.checkpoint("model streamed"), await d.reset(), f.terminate(), {
308
+ archive: m,
309
+ result: v,
310
+ usage: g,
311
+ metrics: l,
312
+ closeArchive: () => u?.close((e) => e.free())
313
+ };
314
+ } catch (e) {
315
+ await d?.reset().catch(() => void 0), f?.terminate();
316
+ try {
317
+ u?.close((e) => e.free());
318
+ } catch {}
319
+ let t = o(e) ?? ne(e);
320
+ throw l.fail(t), t;
321
+ }
322
+ }
323
+ //#endregion
324
+ //#region packages/node/src/docx.ts
325
+ var X = "DOCX document session was aborted", Z = y(() => v(import.meta.url, "docx_parser_bg.wasm", "@silurus/ooxml-docx/wasm-binary"));
326
+ async function ue(e, t) {
327
+ if (!t?.factory) throw TypeError("openDocxDocument requires a canvas factory");
328
+ if (t.legacyDoc !== void 0) {
329
+ let { openDocxSource: n } = await import("./docx-model-source-CTO9iw_W.js");
330
+ return n(e, t, Z);
331
+ }
332
+ let n = c(t.cjkFallback), r = await Y($(e), Z(), t, (e, t, n) => g(e, t, n));
333
+ try {
334
+ _(t.signal, X);
335
+ let e = t.factory.createCanvas(1, 1), i = h(r.result, {
336
+ cjkFallback: n,
337
+ measureContext: e.getContext("2d"),
338
+ allowFootnoteContinuation: t.allowFootnoteContinuation !== !1
339
+ }), a = fe(t.currentDate), o = d(r.result, i, a).layoutVariants.defaultLayout, s = new Q(r.closeArchive, r.archive, r.result, i, o, t.factory, a, r.usage, r.metrics, t.signal);
340
+ return r.metrics.observeUsage(s.resourceUsage), r.metrics.checkpoint("pagination ready"), s;
341
+ } catch (e) {
342
+ try {
343
+ r.closeArchive();
344
+ } catch {}
345
+ let t = i(e) ?? e;
346
+ throw r.metrics.fail(t), t;
347
+ }
348
+ }
349
+ async function de(e, t = {}) {
350
+ if (t.legacyDoc !== void 0) {
351
+ let { materializeDocxSource: n } = await import("./docx-model-source-CTO9iw_W.js");
352
+ return n(e, t, Z);
353
+ }
354
+ return te(async () => {
355
+ let n = await Y($(e), Z(), t, (e, t, n) => m(e, t, n)), r = !1;
356
+ return {
357
+ acquired: n,
358
+ markSucceeded: () => {
359
+ r = !0;
360
+ },
361
+ close: async () => {
362
+ try {
363
+ n.closeArchive(), r && n.metrics.succeed({ documents: 1 });
364
+ } catch (e) {
365
+ throw n.metrics.fail(e), e;
366
+ }
367
+ }
368
+ };
369
+ }, async ({ acquired: e, markSucceeded: t }) => {
370
+ try {
371
+ let n = p(e.result);
372
+ return e.metrics.checkpoint("document materialized", e.usage), t(), n;
373
+ } catch (t) {
374
+ throw e.metrics.fail(t), t;
375
+ }
376
+ });
377
+ }
378
+ var Q = class {
379
+ closeArchive;
380
+ archive;
381
+ factory;
382
+ defaultCurrentDateMs;
383
+ metrics;
384
+ signal;
385
+ pageCount;
386
+ sizes;
387
+ lastResourceUsage;
388
+ state;
389
+ renderTail = Promise.resolve();
390
+ pagesStarted = !1;
391
+ closed = !1;
392
+ closePromise;
393
+ resourceFailure = null;
394
+ fetchImage = async (e, t) => {
395
+ let n = this.archive.extract_image(e);
396
+ return new Blob([n], { type: t });
397
+ };
398
+ constructor(e, t, n, r, i, a, o, s, c, l) {
399
+ this.closeArchive = e, this.archive = t, this.factory = a, this.defaultCurrentDateMs = o, this.metrics = c, this.signal = l, this.state = {
400
+ source: n,
401
+ services: r
402
+ }, this.pageCount = i.pages.length, this.lastResourceUsage = s, this.sizes = Object.freeze(i.pages.map((e) => Object.freeze({
403
+ widthPt: e.geometry.widthPt,
404
+ heightPt: e.geometry.heightPt
405
+ })));
406
+ }
407
+ get resourceUsage() {
408
+ return this.closed ? this.lastResourceUsage : this.refreshResourceUsage();
409
+ }
410
+ refreshResourceUsage() {
411
+ try {
412
+ this.lastResourceUsage = n(this.archive.resource_usage()), this.metrics.observeUsage(this.lastResourceUsage);
413
+ } catch {}
414
+ return this.lastResourceUsage;
415
+ }
416
+ pageSize(e) {
417
+ let t = this.sizes[e];
418
+ if (!t) throw RangeError(`DOCX page index ${e} out of range`);
419
+ return t;
420
+ }
421
+ [Symbol.asyncIterator]() {
422
+ return this.pages();
423
+ }
424
+ renderPage(e, n = {}) {
425
+ return this.closed ? Promise.reject(/* @__PURE__ */ Error("DOCX document session is closed")) : this.resourceFailure ? Promise.reject(this.resourceFailure) : (this.pageSize(e), this.enqueueRender(async () => {
426
+ _(this.signal, X);
427
+ let t = this.requireState(), r = this.factory.createCanvas(1, 1);
428
+ return await ie(this.factory, () => f(t.source, r, e, {
429
+ ...n,
430
+ currentDate: this.defaultCurrentDateMs,
431
+ defaultCurrentDateMs: this.defaultCurrentDateMs,
432
+ layoutServices: t.services,
433
+ fetchImage: this.fetchImage
434
+ })), _(this.signal, X), r;
435
+ }).catch((e) => {
436
+ let n = i(e) ?? e;
437
+ throw n instanceof t && (this.resourceFailure ??= n), this.metrics.fail(n), n;
438
+ }));
439
+ }
440
+ async *pages(e = {}) {
441
+ if (this.closed) throw Error("DOCX document session is closed");
442
+ if (this.pagesStarted) throw Error("DOCX page stream is one-pass and was already consumed");
443
+ this.pagesStarted = !0;
444
+ let t;
445
+ try {
446
+ for (let t = 0; t < this.pageCount; t += 1) {
447
+ let n = await this.renderPage(t, e), r = this.pageSize(t);
448
+ yield {
449
+ pageIndex: t,
450
+ ...r,
451
+ canvas: n
452
+ };
453
+ }
454
+ } catch (e) {
455
+ throw t = i(e) ?? e, t;
456
+ } finally {
457
+ try {
458
+ await this.close();
459
+ } catch (e) {
460
+ if (t === void 0) throw e;
461
+ }
462
+ }
463
+ }
464
+ close() {
465
+ return this.closePromise ? this.closePromise : (this.refreshResourceUsage(), this.closed = !0, this.closePromise = this.release(), this.closePromise);
466
+ }
467
+ enqueueRender(e) {
468
+ let t = this.renderTail.then(e, e);
469
+ return this.renderTail = t.then(() => void 0, () => void 0), t;
470
+ }
471
+ async release() {
472
+ await this.renderTail, u(this.fetchImage), l(this.fetchImage), this.state = null;
473
+ try {
474
+ this.closeArchive();
475
+ } catch (e) {
476
+ let t = i(e) ?? e;
477
+ throw this.metrics.fail(t), t;
478
+ }
479
+ this.metrics.checkpoint("document session closed", this.lastResourceUsage), this.metrics.succeed({ pages: this.pageCount });
480
+ }
481
+ requireState() {
482
+ if (!this.state) throw Error("DOCX document session is closed");
483
+ return this.state;
484
+ }
485
+ };
486
+ function fe(e) {
487
+ let t = e instanceof Date ? e.getTime() : e ?? Date.now();
488
+ if (!Number.isFinite(t)) throw RangeError("currentDate must resolve to finite epoch milliseconds");
489
+ return t;
490
+ }
491
+ function $(e) {
492
+ return e instanceof Uint8Array ? e : new Uint8Array(e);
493
+ }
494
+ //#endregion
495
+ export { Y as i, de as n, ue as r, Q as t };