@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.
- package/README.md +105 -6
- package/dist/bounded-raw-part-cache-BTfZD_Sz.js +1248 -0
- package/dist/{docx-DftZMp7R.js → document-pull-client-H80_E10V.js} +11165 -11517
- package/dist/docx-BX0mJqS1.js +1274 -0
- package/dist/docx.mjs +6 -3
- package/dist/docx_parser_bg.wasm +0 -0
- package/dist/duotone-bitmap-by-path-Dv5Ikbzl.js +28 -0
- package/dist/find-cursor-Dc5iM6s7.js +815 -0
- package/dist/highlight-rect-cCvVU-MW.js +48 -0
- package/dist/hyperlink-D85FexTa.js +27 -0
- package/dist/index.mjs +4 -4
- package/dist/{highlight-rect-IjFkGg4X.js → line-distribute-DkLgIa7B.js} +37 -84
- package/dist/{find-cursor-DtgyGs5V.js → line-metrics-qwIyTk7Q.js} +1169 -3641
- package/dist/math.mjs +1 -1
- package/dist/node.mjs +998 -0
- package/dist/pptx-BEYjiTnZ.js +822 -0
- package/dist/pptx-CXgyi7wu.js +1705 -0
- package/dist/pptx.mjs +7 -3
- package/dist/pptx_parser_bg.wasm +0 -0
- package/dist/preload-BEouWnlI.js +132 -0
- package/dist/render-C0wMf5eT.js +71 -0
- package/dist/render-worker-host-CLdOlxFu.js +27 -0
- package/dist/render-worker-host-DZ4u0RFs.js +27 -0
- package/dist/render-worker-host-s3J-mWBP.js +27 -0
- package/dist/renderer-CwzTv9hH.js +5225 -0
- package/dist/resource-measurement-6aReN3K0.js +93 -0
- package/dist/slide-pull-client-D_T0AIoX.js +175 -0
- package/dist/svg-image-by-path-C1M3N2pT.js +1623 -0
- package/dist/transfer-3QEJrsJa.js +6 -0
- package/dist/types/docx.d.ts +290 -105
- package/dist/types/index.d.ts +399 -142
- package/dist/types/math.d.ts +1 -1
- package/dist/types/node.d.ts +4855 -0
- package/dist/types/pptx.d.ts +431 -245
- package/dist/types/xlsx.d.ts +320 -120
- package/dist/visible-index-CKvgpUrf.js +17 -0
- package/dist/worksheet-pull-worker-DCei8u-4.js +347 -0
- package/dist/{xlsx-BqMHvfsE.js → xlsx-DJyPlzjB.js} +1499 -1284
- package/dist/xlsx.mjs +7 -3
- package/dist/xlsx_parser_bg.wasm +0 -0
- package/package.json +12 -2
- package/dist/pptx-qbadwIv4.js +0 -6761
- package/dist/render-worker-host-Bcm9j4-H.js +0 -27
- package/dist/render-worker-host-BqSTDaYt.js +0 -27
- package/dist/render-worker-host-C523QxVw.js +0 -27
- package/dist/visible-index-C3_3gBg-.js +0 -50
- /package/dist/{mathjax-BPjQ2C_j.js → mathjax-Dqo857oC.js} +0 -0
package/dist/node.mjs
ADDED
|
@@ -0,0 +1,998 @@
|
|
|
1
|
+
import { t as e } from "./chunk-DmhlhrBa.js";
|
|
2
|
+
import { D as t, N as n, O as r, T as i, a, c as o, f as s, i as c, k as l, m as u, o as d, p as f, r as p, u as m } from "./bounded-raw-part-cache-BTfZD_Sz.js";
|
|
3
|
+
import { c as h, n as ee, o as g, r as te, s as ne } from "./document-pull-client-H80_E10V.js";
|
|
4
|
+
import { f as re, i as _, p as ie, t as ae } from "./svg-image-by-path-C1M3N2pT.js";
|
|
5
|
+
import { t as oe } from "./transfer-3QEJrsJa.js";
|
|
6
|
+
import { d as se, n as ce, t as le, u as ue } from "./worksheet-pull-worker-DCei8u-4.js";
|
|
7
|
+
import { c as de, i as fe, n as pe, o as me, r as he, s as ge, t as _e } from "./pptx-BEYjiTnZ.js";
|
|
8
|
+
import { i as ve, n as ye, o as be, r as xe, t as Se } from "./render-C0wMf5eT.js";
|
|
9
|
+
//#region packages/docx/src/document-pull-worker.ts
|
|
10
|
+
var Ce = Math.max(f, u), we = class {
|
|
11
|
+
coordinator = new d();
|
|
12
|
+
host = null;
|
|
13
|
+
identity = null;
|
|
14
|
+
constructor(e, t = (e) => e(this.requireArchive())) {
|
|
15
|
+
this.archive = e, this.executeArchive = t;
|
|
16
|
+
}
|
|
17
|
+
open(e) {
|
|
18
|
+
if (this.host) throw Error("a DOCX document pull session is already active");
|
|
19
|
+
this.executeArchive((t) => {
|
|
20
|
+
t.open_document_cursor(e.operationId, e.generation);
|
|
21
|
+
});
|
|
22
|
+
let t = 0;
|
|
23
|
+
this.identity = e, this.host = new a({
|
|
24
|
+
...e,
|
|
25
|
+
maxByteCredit: Ce,
|
|
26
|
+
coordinator: this.coordinator,
|
|
27
|
+
driver: {
|
|
28
|
+
pull: (n) => {
|
|
29
|
+
let r;
|
|
30
|
+
try {
|
|
31
|
+
r = this.executeArchive((r) => r.pull_document_chunk(t, e.operationId, e.generation, n));
|
|
32
|
+
} catch (e) {
|
|
33
|
+
throw l(e, n, Ce) || e;
|
|
34
|
+
}
|
|
35
|
+
let i = oe(r);
|
|
36
|
+
return {
|
|
37
|
+
payload: i,
|
|
38
|
+
byteLength: i.byteLength,
|
|
39
|
+
done: this.executeArchive((e) => e.document_chunk_done()),
|
|
40
|
+
transfer: [i]
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
measureChunk: ({ payload: e }) => e.byteLength,
|
|
44
|
+
acknowledge: (n) => {
|
|
45
|
+
if (n !== t) throw Error("DOCX document acknowledgement sequence mismatch");
|
|
46
|
+
this.executeArchive((n) => n.acknowledge_document_chunk(t, e.operationId, e.generation)), t += 1;
|
|
47
|
+
},
|
|
48
|
+
cancel: () => this.executeArchive((e) => e.cancel_document_cursor()),
|
|
49
|
+
close: () => this.executeArchive((e) => e.close_document_session()),
|
|
50
|
+
resourceUsage: () => {
|
|
51
|
+
let e = this.executeArchive((e) => e.document_cursor_resource_usage?.());
|
|
52
|
+
return e ? i(e) : void 0;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
dispatch(e, t) {
|
|
58
|
+
return !this.host || !this.identity ? (t({
|
|
59
|
+
protocol: c,
|
|
60
|
+
kind: "error",
|
|
61
|
+
sessionId: e.sessionId,
|
|
62
|
+
operationId: e.operationId,
|
|
63
|
+
generation: e.generation,
|
|
64
|
+
requestId: e.requestId,
|
|
65
|
+
error: r(/* @__PURE__ */ Error("DOCX document pull session is not open"))
|
|
66
|
+
}), Promise.resolve()) : this.host.dispatch(e, t);
|
|
67
|
+
}
|
|
68
|
+
async reset() {
|
|
69
|
+
if (this.host) try {
|
|
70
|
+
this.archive() && this.executeArchive((e) => e.close_document_session());
|
|
71
|
+
} finally {
|
|
72
|
+
this.host = null, this.identity = null, this.coordinator = new d();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
requireArchive() {
|
|
76
|
+
let e = this.archive();
|
|
77
|
+
if (!e) throw Error("No docx loaded");
|
|
78
|
+
return e;
|
|
79
|
+
}
|
|
80
|
+
}, Te = /* @__PURE__ */ e({
|
|
81
|
+
DocxArchive: () => v,
|
|
82
|
+
default: () => Le,
|
|
83
|
+
docx_to_markdown: () => Ee,
|
|
84
|
+
extract_image: () => De,
|
|
85
|
+
initSync: () => Ie,
|
|
86
|
+
parse_docx: () => Oe,
|
|
87
|
+
reinit: () => Re
|
|
88
|
+
}), v = class {
|
|
89
|
+
__destroy_into_raw() {
|
|
90
|
+
let e = this.__wbg_ptr;
|
|
91
|
+
return this.__wbg_ptr = 0, Ae.unregister(this), e;
|
|
92
|
+
}
|
|
93
|
+
free() {
|
|
94
|
+
let e = this.__destroy_into_raw();
|
|
95
|
+
M.__wbg_docxarchive_free(e, 0);
|
|
96
|
+
}
|
|
97
|
+
acknowledge_document_chunk(e, t, n) {
|
|
98
|
+
let r = M.docxarchive_acknowledge_document_chunk(this.__wbg_ptr, e, t, n);
|
|
99
|
+
if (r[1]) throw D(r[0]);
|
|
100
|
+
}
|
|
101
|
+
assert_healthy() {
|
|
102
|
+
let e = M.docxarchive_assert_healthy(this.__wbg_ptr);
|
|
103
|
+
if (e[1]) throw D(e[0]);
|
|
104
|
+
}
|
|
105
|
+
cancel_document_cursor() {
|
|
106
|
+
M.docxarchive_cancel_document_cursor(this.__wbg_ptr);
|
|
107
|
+
}
|
|
108
|
+
close_document_session() {
|
|
109
|
+
M.docxarchive_close_document_session(this.__wbg_ptr);
|
|
110
|
+
}
|
|
111
|
+
document_chunk_done() {
|
|
112
|
+
let e = M.docxarchive_document_chunk_done(this.__wbg_ptr);
|
|
113
|
+
if (e[2]) throw D(e[1]);
|
|
114
|
+
return e[0] !== 0;
|
|
115
|
+
}
|
|
116
|
+
document_cursor_resource_usage() {
|
|
117
|
+
let e = M.docxarchive_document_cursor_resource_usage(this.__wbg_ptr);
|
|
118
|
+
if (e[3]) throw D(e[2]);
|
|
119
|
+
var t = y(e[0], e[1]).slice();
|
|
120
|
+
return M.__wbindgen_free(e[0], e[1] * 1, 1), t;
|
|
121
|
+
}
|
|
122
|
+
extract_image(e) {
|
|
123
|
+
let t = E(e, M.__wbindgen_malloc, M.__wbindgen_realloc), n = j, r = M.docxarchive_extract_image(this.__wbg_ptr, t, n);
|
|
124
|
+
if (r[3]) throw D(r[2]);
|
|
125
|
+
var i = y(r[0], r[1]).slice();
|
|
126
|
+
return M.__wbindgen_free(r[0], r[1] * 1, 1), i;
|
|
127
|
+
}
|
|
128
|
+
constructor(e, t, n) {
|
|
129
|
+
let r = T(e, M.__wbindgen_malloc), i = j, a = M.docxarchive_new(r, i, !w(t), w(t) ? BigInt(0) : t, !w(n), w(n) ? BigInt(0) : n);
|
|
130
|
+
if (a[2]) throw D(a[1]);
|
|
131
|
+
return this.__wbg_ptr = a[0] >>> 0, Ae.register(this, this.__wbg_ptr, this), this;
|
|
132
|
+
}
|
|
133
|
+
open_document_cursor(e, t) {
|
|
134
|
+
let n = M.docxarchive_open_document_cursor(this.__wbg_ptr, e, t);
|
|
135
|
+
if (n[1]) throw D(n[0]);
|
|
136
|
+
}
|
|
137
|
+
parse() {
|
|
138
|
+
let e = M.docxarchive_parse(this.__wbg_ptr);
|
|
139
|
+
if (e[3]) throw D(e[2]);
|
|
140
|
+
var t = y(e[0], e[1]).slice();
|
|
141
|
+
return M.__wbindgen_free(e[0], e[1] * 1, 1), t;
|
|
142
|
+
}
|
|
143
|
+
pull_document_chunk(e, t, n, r) {
|
|
144
|
+
let i = M.docxarchive_pull_document_chunk(this.__wbg_ptr, e, t, n, r);
|
|
145
|
+
if (i[3]) throw D(i[2]);
|
|
146
|
+
var a = y(i[0], i[1]).slice();
|
|
147
|
+
return M.__wbindgen_free(i[0], i[1] * 1, 1), a;
|
|
148
|
+
}
|
|
149
|
+
resource_usage() {
|
|
150
|
+
let e = M.docxarchive_resource_usage(this.__wbg_ptr);
|
|
151
|
+
if (e[3]) throw D(e[2]);
|
|
152
|
+
var t = y(e[0], e[1]).slice();
|
|
153
|
+
return M.__wbindgen_free(e[0], e[1] * 1, 1), t;
|
|
154
|
+
}
|
|
155
|
+
to_markdown() {
|
|
156
|
+
let e, t;
|
|
157
|
+
try {
|
|
158
|
+
let i = M.docxarchive_to_markdown(this.__wbg_ptr);
|
|
159
|
+
var n = i[0], r = i[1];
|
|
160
|
+
if (i[3]) throw n = 0, r = 0, D(i[2]);
|
|
161
|
+
return e = n, t = r, x(n, r);
|
|
162
|
+
} finally {
|
|
163
|
+
M.__wbindgen_free(e, t, 1);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
Symbol.dispose && (v.prototype[Symbol.dispose] = v.prototype.free);
|
|
168
|
+
function Ee(e, t, n) {
|
|
169
|
+
let r, i;
|
|
170
|
+
try {
|
|
171
|
+
let s = T(e, M.__wbindgen_malloc), c = j, l = M.docx_to_markdown(s, c, !w(t), w(t) ? BigInt(0) : t, !w(n), w(n) ? BigInt(0) : n);
|
|
172
|
+
var a = l[0], o = l[1];
|
|
173
|
+
if (l[3]) throw a = 0, o = 0, D(l[2]);
|
|
174
|
+
return r = a, i = o, x(a, o);
|
|
175
|
+
} finally {
|
|
176
|
+
M.__wbindgen_free(r, i, 1);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function De(e, t, n, r) {
|
|
180
|
+
let i = T(e, M.__wbindgen_malloc), a = j, o = E(t, M.__wbindgen_malloc, M.__wbindgen_realloc), s = j, c = M.extract_image(i, a, o, s, !w(n), w(n) ? BigInt(0) : n, !w(r), w(r) ? BigInt(0) : r);
|
|
181
|
+
if (c[3]) throw D(c[2]);
|
|
182
|
+
var l = y(c[0], c[1]).slice();
|
|
183
|
+
return M.__wbindgen_free(c[0], c[1] * 1, 1), l;
|
|
184
|
+
}
|
|
185
|
+
function Oe(e, t, n) {
|
|
186
|
+
let r = T(e, M.__wbindgen_malloc), i = j, a = M.parse_docx(r, i, !w(t), w(t) ? BigInt(0) : t, !w(n), w(n) ? BigInt(0) : n);
|
|
187
|
+
if (a[3]) throw D(a[2]);
|
|
188
|
+
var o = y(a[0], a[1]).slice();
|
|
189
|
+
return M.__wbindgen_free(a[0], a[1] * 1, 1), o;
|
|
190
|
+
}
|
|
191
|
+
function ke() {
|
|
192
|
+
return {
|
|
193
|
+
__proto__: null,
|
|
194
|
+
"./docx_parser_bg.js": {
|
|
195
|
+
__proto__: null,
|
|
196
|
+
__wbg___wbindgen_throw_6b64449b9b9ed33c: function(e, t) {
|
|
197
|
+
throw Error(x(e, t));
|
|
198
|
+
},
|
|
199
|
+
__wbg_error_a6fa202b58aa1cd3: function(e, t) {
|
|
200
|
+
let n, r;
|
|
201
|
+
try {
|
|
202
|
+
n = e, r = t, console.error(x(e, t));
|
|
203
|
+
} finally {
|
|
204
|
+
M.__wbindgen_free(n, r, 1);
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
__wbg_new_227d7c05414eb861: function() {
|
|
208
|
+
return /* @__PURE__ */ Error();
|
|
209
|
+
},
|
|
210
|
+
__wbg_stack_3b0d974bbf31e44f: function(e, t) {
|
|
211
|
+
let n = t.stack, r = E(n, M.__wbindgen_malloc, M.__wbindgen_realloc), i = j;
|
|
212
|
+
je().setInt32(e + 4, i, !0), je().setInt32(e + 0, r, !0);
|
|
213
|
+
},
|
|
214
|
+
__wbindgen_cast_0000000000000001: function(e, t) {
|
|
215
|
+
return x(e, t);
|
|
216
|
+
},
|
|
217
|
+
__wbindgen_init_externref_table: function() {
|
|
218
|
+
let e = M.__wbindgen_externrefs, t = e.grow(4);
|
|
219
|
+
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);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
var Ae = typeof FinalizationRegistry > "u" ? {
|
|
225
|
+
register: () => {},
|
|
226
|
+
unregister: () => {}
|
|
227
|
+
} : new FinalizationRegistry((e) => M.__wbg_docxarchive_free(e >>> 0, 1));
|
|
228
|
+
function y(e, t) {
|
|
229
|
+
return e >>>= 0, C().subarray(e / 1, e / 1 + t);
|
|
230
|
+
}
|
|
231
|
+
var b = null;
|
|
232
|
+
function je() {
|
|
233
|
+
return (b === null || b.buffer.detached === !0 || b.buffer.detached === void 0 && b.buffer !== M.memory.buffer) && (b = new DataView(M.memory.buffer)), b;
|
|
234
|
+
}
|
|
235
|
+
function x(e, t) {
|
|
236
|
+
return e >>>= 0, Ne(e, t);
|
|
237
|
+
}
|
|
238
|
+
var S = null;
|
|
239
|
+
function C() {
|
|
240
|
+
return (S === null || S.byteLength === 0) && (S = new Uint8Array(M.memory.buffer)), S;
|
|
241
|
+
}
|
|
242
|
+
function w(e) {
|
|
243
|
+
return e == null;
|
|
244
|
+
}
|
|
245
|
+
function T(e, t) {
|
|
246
|
+
let n = t(e.length * 1, 1) >>> 0;
|
|
247
|
+
return C().set(e, n / 1), j = e.length, n;
|
|
248
|
+
}
|
|
249
|
+
function E(e, t, n) {
|
|
250
|
+
if (n === void 0) {
|
|
251
|
+
let n = A.encode(e), r = t(n.length, 1) >>> 0;
|
|
252
|
+
return C().subarray(r, r + n.length).set(n), j = n.length, r;
|
|
253
|
+
}
|
|
254
|
+
let r = e.length, i = t(r, 1) >>> 0, a = C(), o = 0;
|
|
255
|
+
for (; o < r; o++) {
|
|
256
|
+
let t = e.charCodeAt(o);
|
|
257
|
+
if (t > 127) break;
|
|
258
|
+
a[i + o] = t;
|
|
259
|
+
}
|
|
260
|
+
if (o !== r) {
|
|
261
|
+
o !== 0 && (e = e.slice(o)), i = n(i, r, r = o + e.length * 3, 1) >>> 0;
|
|
262
|
+
let t = C().subarray(i + o, i + r), a = A.encodeInto(e, t);
|
|
263
|
+
o += a.written, i = n(i, r, o, 1) >>> 0;
|
|
264
|
+
}
|
|
265
|
+
return j = o, i;
|
|
266
|
+
}
|
|
267
|
+
function D(e) {
|
|
268
|
+
let t = M.__wbindgen_externrefs.get(e);
|
|
269
|
+
return M.__externref_table_dealloc(e), t;
|
|
270
|
+
}
|
|
271
|
+
var O = new TextDecoder("utf-8", {
|
|
272
|
+
ignoreBOM: !0,
|
|
273
|
+
fatal: !0
|
|
274
|
+
});
|
|
275
|
+
O.decode();
|
|
276
|
+
var Me = 2146435072, k = 0;
|
|
277
|
+
function Ne(e, t) {
|
|
278
|
+
return k += t, k >= Me && (O = new TextDecoder("utf-8", {
|
|
279
|
+
ignoreBOM: !0,
|
|
280
|
+
fatal: !0
|
|
281
|
+
}), O.decode(), k = t), O.decode(C().subarray(e, e + t));
|
|
282
|
+
}
|
|
283
|
+
var A = new TextEncoder();
|
|
284
|
+
"encodeInto" in A || (A.encodeInto = function(e, t) {
|
|
285
|
+
let n = A.encode(e);
|
|
286
|
+
return t.set(n), {
|
|
287
|
+
read: e.length,
|
|
288
|
+
written: n.length
|
|
289
|
+
};
|
|
290
|
+
});
|
|
291
|
+
var j = 0, M;
|
|
292
|
+
function Pe(e, t) {
|
|
293
|
+
return M = e.exports, b = null, S = null, M.__wbindgen_start(), M;
|
|
294
|
+
}
|
|
295
|
+
async function Fe(e, t) {
|
|
296
|
+
if (typeof Response == "function" && e instanceof Response) {
|
|
297
|
+
if (typeof WebAssembly.instantiateStreaming == "function") try {
|
|
298
|
+
return await WebAssembly.instantiateStreaming(e, t);
|
|
299
|
+
} catch (t) {
|
|
300
|
+
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);
|
|
301
|
+
else throw t;
|
|
302
|
+
}
|
|
303
|
+
let r = await e.arrayBuffer();
|
|
304
|
+
return await WebAssembly.instantiate(r, t);
|
|
305
|
+
} else {
|
|
306
|
+
let n = await WebAssembly.instantiate(e, t);
|
|
307
|
+
return n instanceof WebAssembly.Instance ? {
|
|
308
|
+
instance: n,
|
|
309
|
+
module: e
|
|
310
|
+
} : n;
|
|
311
|
+
}
|
|
312
|
+
function n(e) {
|
|
313
|
+
switch (e) {
|
|
314
|
+
case "basic":
|
|
315
|
+
case "cors":
|
|
316
|
+
case "default": return !0;
|
|
317
|
+
}
|
|
318
|
+
return !1;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
function Ie(e) {
|
|
322
|
+
if (M !== void 0) return M;
|
|
323
|
+
e !== void 0 && (Object.getPrototypeOf(e) === Object.prototype ? {module: e} = e : console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));
|
|
324
|
+
let t = ke();
|
|
325
|
+
return e instanceof WebAssembly.Module || (e = new WebAssembly.Module(e)), Pe(new WebAssembly.Instance(e, t), e);
|
|
326
|
+
}
|
|
327
|
+
async function Le(e) {
|
|
328
|
+
if (M !== void 0) return M;
|
|
329
|
+
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"));
|
|
330
|
+
let t = ke();
|
|
331
|
+
(typeof e == "string" || typeof Request == "function" && e instanceof Request || typeof URL == "function" && e instanceof URL) && (e = fetch(e));
|
|
332
|
+
let { instance: n, module: r } = await Fe(await e, t);
|
|
333
|
+
return Pe(n, r);
|
|
334
|
+
}
|
|
335
|
+
async function Re(e) {
|
|
336
|
+
return M = void 0, b = null, S = null, Le(e);
|
|
337
|
+
}
|
|
338
|
+
//#endregion
|
|
339
|
+
//#region packages/node/src/docx.ts
|
|
340
|
+
var ze = !1;
|
|
341
|
+
function Be() {
|
|
342
|
+
ze ||= (me(Te, ge(import.meta.url, "../../docx/src/wasm/docx_parser_bg.wasm")), !0);
|
|
343
|
+
}
|
|
344
|
+
function Ve(e) {
|
|
345
|
+
Be();
|
|
346
|
+
let t = Oe(e instanceof Uint8Array ? e : new Uint8Array(e));
|
|
347
|
+
return h(JSON.parse(new TextDecoder().decode(t)));
|
|
348
|
+
}
|
|
349
|
+
async function He(e, n) {
|
|
350
|
+
let r = m(n ?? {}), i = new o({
|
|
351
|
+
enabled: r.debug || r.onResourceMetrics !== void 0,
|
|
352
|
+
format: "docx",
|
|
353
|
+
mode: "node",
|
|
354
|
+
scope: "session",
|
|
355
|
+
policy: r.policy,
|
|
356
|
+
onMetrics: r.onResourceMetrics,
|
|
357
|
+
emitToConsole: r.debug
|
|
358
|
+
});
|
|
359
|
+
i.setSourceBytes(Ke(e).byteLength);
|
|
360
|
+
let a = v, c, l, u;
|
|
361
|
+
try {
|
|
362
|
+
if (!n?.factory) throw TypeError("openDocxDocument requires a canvas factory");
|
|
363
|
+
N(n.signal), Be();
|
|
364
|
+
let [t, o] = s(r.policy);
|
|
365
|
+
c = new a(Ke(e), t, o), i.checkpoint("container ready"), l = new we(() => c);
|
|
366
|
+
let d = {
|
|
367
|
+
sessionId: 1,
|
|
368
|
+
operationId: 1,
|
|
369
|
+
generation: 1
|
|
370
|
+
};
|
|
371
|
+
l.open(d), u = new de((e, t) => l?.dispatch(e, t), () => void 0);
|
|
372
|
+
let f, p = await ee(u, d, {
|
|
373
|
+
signal: n.signal,
|
|
374
|
+
onUsage: (e) => {
|
|
375
|
+
f = e, i.observeUsage(e);
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
f ??= Ge(c.document_cursor_resource_usage()), i.observeUsage(f), i.checkpoint("model streamed"), await l.reset(), u.terminate(), N(n.signal);
|
|
379
|
+
let m = n.factory.createCanvas(1, 1), h = ne(p.source, { measureContext: m.getContext("2d") }), g = We(n.currentDate), re = te(p.source, h, g).layoutVariants.defaultLayout, _ = new Ue(c, p.source, h, re, n.factory, g, f, i, n.signal);
|
|
380
|
+
return i.observeUsage(_.resourceUsage), i.checkpoint("pagination ready"), _;
|
|
381
|
+
} catch (e) {
|
|
382
|
+
await l?.reset().catch(() => void 0), u?.terminate();
|
|
383
|
+
try {
|
|
384
|
+
c?.free();
|
|
385
|
+
} catch {}
|
|
386
|
+
let n = t(e) ?? e;
|
|
387
|
+
throw i.fail(n), n;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
var Ue = class {
|
|
391
|
+
pageCount;
|
|
392
|
+
sizes;
|
|
393
|
+
lastResourceUsage;
|
|
394
|
+
state;
|
|
395
|
+
renderTail = Promise.resolve();
|
|
396
|
+
pagesStarted = !1;
|
|
397
|
+
closed = !1;
|
|
398
|
+
closePromise;
|
|
399
|
+
resourceFailure = null;
|
|
400
|
+
fetchImage = async (e, t) => {
|
|
401
|
+
let n = this.archive.extract_image(e);
|
|
402
|
+
return new Blob([new Uint8Array(n).slice()], { type: t });
|
|
403
|
+
};
|
|
404
|
+
constructor(e, t, n, r, i, a, o, s, c) {
|
|
405
|
+
this.archive = e, this.factory = i, this.defaultCurrentDateMs = a, this.metrics = s, this.signal = c, this.state = {
|
|
406
|
+
source: t,
|
|
407
|
+
services: n
|
|
408
|
+
}, this.pageCount = r.pages.length, this.lastResourceUsage = o, this.sizes = Object.freeze(r.pages.map((e) => Object.freeze({
|
|
409
|
+
widthPt: e.geometry.widthPt,
|
|
410
|
+
heightPt: e.geometry.heightPt
|
|
411
|
+
})));
|
|
412
|
+
}
|
|
413
|
+
get resourceUsage() {
|
|
414
|
+
return this.closed ? this.lastResourceUsage : this.refreshResourceUsage();
|
|
415
|
+
}
|
|
416
|
+
refreshResourceUsage() {
|
|
417
|
+
try {
|
|
418
|
+
this.lastResourceUsage = i(this.archive.resource_usage()), this.metrics.observeUsage(this.lastResourceUsage);
|
|
419
|
+
} catch {}
|
|
420
|
+
return this.lastResourceUsage;
|
|
421
|
+
}
|
|
422
|
+
pageSize(e) {
|
|
423
|
+
let t = this.sizes[e];
|
|
424
|
+
if (!t) throw RangeError(`DOCX page index ${e} out of range`);
|
|
425
|
+
return t;
|
|
426
|
+
}
|
|
427
|
+
[Symbol.asyncIterator]() {
|
|
428
|
+
return this.pages();
|
|
429
|
+
}
|
|
430
|
+
renderPage(e, r = {}) {
|
|
431
|
+
return this.closed ? Promise.reject(/* @__PURE__ */ Error("DOCX document session is closed")) : this.resourceFailure ? Promise.reject(this.resourceFailure) : (this.pageSize(e), this.enqueueRender(async () => {
|
|
432
|
+
N(this.signal);
|
|
433
|
+
let t = this.requireState(), n = this.factory.createCanvas(1, 1);
|
|
434
|
+
return await be(this.factory, () => g(t.source, n, e, {
|
|
435
|
+
...r,
|
|
436
|
+
currentDate: this.defaultCurrentDateMs,
|
|
437
|
+
defaultCurrentDateMs: this.defaultCurrentDateMs,
|
|
438
|
+
layoutServices: t.services,
|
|
439
|
+
fetchImage: this.fetchImage
|
|
440
|
+
})), N(this.signal), n;
|
|
441
|
+
}).catch((e) => {
|
|
442
|
+
let r = t(e) ?? e;
|
|
443
|
+
throw r instanceof n && (this.resourceFailure ??= r), this.metrics.fail(r), r;
|
|
444
|
+
}));
|
|
445
|
+
}
|
|
446
|
+
async *pages(e = {}) {
|
|
447
|
+
if (this.closed) throw Error("DOCX document session is closed");
|
|
448
|
+
if (this.pagesStarted) throw Error("DOCX page stream is one-pass and was already consumed");
|
|
449
|
+
this.pagesStarted = !0;
|
|
450
|
+
let n;
|
|
451
|
+
try {
|
|
452
|
+
for (let t = 0; t < this.pageCount; t += 1) {
|
|
453
|
+
let n = await this.renderPage(t, e), r = this.pageSize(t);
|
|
454
|
+
yield {
|
|
455
|
+
pageIndex: t,
|
|
456
|
+
...r,
|
|
457
|
+
canvas: n
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
} catch (e) {
|
|
461
|
+
throw n = t(e) ?? e, n;
|
|
462
|
+
} finally {
|
|
463
|
+
try {
|
|
464
|
+
await this.close();
|
|
465
|
+
} catch (e) {
|
|
466
|
+
if (n === void 0) throw e;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
close() {
|
|
471
|
+
return this.closePromise ? this.closePromise : (this.refreshResourceUsage(), this.closed = !0, this.closePromise = this.release(), this.closePromise);
|
|
472
|
+
}
|
|
473
|
+
enqueueRender(e) {
|
|
474
|
+
let t = this.renderTail.then(e, e);
|
|
475
|
+
return this.renderTail = t.then(() => void 0, () => void 0), t;
|
|
476
|
+
}
|
|
477
|
+
async release() {
|
|
478
|
+
await this.renderTail, _(this.fetchImage), ae(this.fetchImage), this.state = null;
|
|
479
|
+
try {
|
|
480
|
+
this.archive.free();
|
|
481
|
+
} catch (e) {
|
|
482
|
+
let n = t(e) ?? e;
|
|
483
|
+
throw this.metrics.fail(n), n;
|
|
484
|
+
}
|
|
485
|
+
this.metrics.checkpoint("document session closed", this.lastResourceUsage), this.metrics.succeed({ pages: this.pageCount });
|
|
486
|
+
}
|
|
487
|
+
requireState() {
|
|
488
|
+
if (!this.state) throw Error("DOCX document session is closed");
|
|
489
|
+
return this.state;
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
function We(e) {
|
|
493
|
+
let t = e instanceof Date ? e.getTime() : e ?? Date.now();
|
|
494
|
+
if (!Number.isFinite(t)) throw RangeError("currentDate must resolve to finite epoch milliseconds");
|
|
495
|
+
return t;
|
|
496
|
+
}
|
|
497
|
+
function Ge(e) {
|
|
498
|
+
try {
|
|
499
|
+
return i(e);
|
|
500
|
+
} catch (e) {
|
|
501
|
+
if (String(e).includes("document cursor usage is unavailable")) return;
|
|
502
|
+
throw e;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
function Ke(e) {
|
|
506
|
+
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
507
|
+
}
|
|
508
|
+
function N(e) {
|
|
509
|
+
if (!e?.aborted) return;
|
|
510
|
+
let t = /* @__PURE__ */ Error("DOCX document session was aborted");
|
|
511
|
+
throw t.name = "AbortError", t;
|
|
512
|
+
}
|
|
513
|
+
//#endregion
|
|
514
|
+
//#region packages/xlsx/src/wasm/xlsx_parser.js
|
|
515
|
+
var qe = /* @__PURE__ */ e({
|
|
516
|
+
XlsxArchive: () => P,
|
|
517
|
+
default: () => at,
|
|
518
|
+
extract_image: () => Je,
|
|
519
|
+
initSync: () => it,
|
|
520
|
+
parse_sheet: () => Ye,
|
|
521
|
+
parse_xlsx: () => Xe,
|
|
522
|
+
reinit: () => ot,
|
|
523
|
+
xlsx_to_markdown: () => Ze
|
|
524
|
+
}), P = class {
|
|
525
|
+
__destroy_into_raw() {
|
|
526
|
+
let e = this.__wbg_ptr;
|
|
527
|
+
return this.__wbg_ptr = 0, $e.unregister(this), e;
|
|
528
|
+
}
|
|
529
|
+
free() {
|
|
530
|
+
let e = this.__destroy_into_raw();
|
|
531
|
+
J.__wbg_xlsxarchive_free(e, 0);
|
|
532
|
+
}
|
|
533
|
+
acknowledge_sheet_cursor_terminal() {
|
|
534
|
+
let e = J.xlsxarchive_acknowledge_sheet_cursor_terminal(this.__wbg_ptr);
|
|
535
|
+
if (e[1]) throw U(e[0]);
|
|
536
|
+
}
|
|
537
|
+
assert_healthy() {
|
|
538
|
+
let e = J.xlsxarchive_assert_healthy(this.__wbg_ptr);
|
|
539
|
+
if (e[1]) throw U(e[0]);
|
|
540
|
+
}
|
|
541
|
+
cancel_sheet_cursor() {
|
|
542
|
+
J.xlsxarchive_cancel_sheet_cursor(this.__wbg_ptr);
|
|
543
|
+
}
|
|
544
|
+
close_sheet_cursor() {
|
|
545
|
+
J.xlsxarchive_close_sheet_cursor(this.__wbg_ptr);
|
|
546
|
+
}
|
|
547
|
+
extract_image(e) {
|
|
548
|
+
let t = H(e, J.__wbindgen_malloc, J.__wbindgen_realloc), n = q, r = J.xlsxarchive_extract_image(this.__wbg_ptr, t, n);
|
|
549
|
+
if (r[3]) throw U(r[2]);
|
|
550
|
+
var i = F(r[0], r[1]).slice();
|
|
551
|
+
return J.__wbindgen_free(r[0], r[1] * 1, 1), i;
|
|
552
|
+
}
|
|
553
|
+
constructor(e, t, n) {
|
|
554
|
+
let r = V(e, J.__wbindgen_malloc), i = q, a = J.xlsxarchive_new(r, i, !B(t), B(t) ? BigInt(0) : t, !B(n), B(n) ? BigInt(0) : n);
|
|
555
|
+
if (a[2]) throw U(a[1]);
|
|
556
|
+
return this.__wbg_ptr = a[0] >>> 0, $e.register(this, this.__wbg_ptr, this), this;
|
|
557
|
+
}
|
|
558
|
+
open_sheet_cursor(e, t) {
|
|
559
|
+
let n = H(t, J.__wbindgen_malloc, J.__wbindgen_realloc), r = q, i = J.xlsxarchive_open_sheet_cursor(this.__wbg_ptr, e, n, r);
|
|
560
|
+
if (i[1]) throw U(i[0]);
|
|
561
|
+
}
|
|
562
|
+
parse() {
|
|
563
|
+
let e = J.xlsxarchive_parse(this.__wbg_ptr);
|
|
564
|
+
if (e[3]) throw U(e[2]);
|
|
565
|
+
var t = F(e[0], e[1]).slice();
|
|
566
|
+
return J.__wbindgen_free(e[0], e[1] * 1, 1), t;
|
|
567
|
+
}
|
|
568
|
+
parse_sheet(e, t) {
|
|
569
|
+
let n = H(t, J.__wbindgen_malloc, J.__wbindgen_realloc), r = q, i = J.xlsxarchive_parse_sheet(this.__wbg_ptr, e, n, r);
|
|
570
|
+
if (i[3]) throw U(i[2]);
|
|
571
|
+
var a = F(i[0], i[1]).slice();
|
|
572
|
+
return J.__wbindgen_free(i[0], i[1] * 1, 1), a;
|
|
573
|
+
}
|
|
574
|
+
pull_sheet_cursor(e) {
|
|
575
|
+
let t = J.xlsxarchive_pull_sheet_cursor(this.__wbg_ptr, e);
|
|
576
|
+
if (t[3]) throw U(t[2]);
|
|
577
|
+
var n = F(t[0], t[1]).slice();
|
|
578
|
+
return J.__wbindgen_free(t[0], t[1] * 1, 1), n;
|
|
579
|
+
}
|
|
580
|
+
resource_usage() {
|
|
581
|
+
let e = J.xlsxarchive_resource_usage(this.__wbg_ptr);
|
|
582
|
+
if (e[3]) throw U(e[2]);
|
|
583
|
+
var t = F(e[0], e[1]).slice();
|
|
584
|
+
return J.__wbindgen_free(e[0], e[1] * 1, 1), t;
|
|
585
|
+
}
|
|
586
|
+
sheet_cursor_pull_finished() {
|
|
587
|
+
return J.xlsxarchive_sheet_cursor_pull_finished(this.__wbg_ptr) !== 0;
|
|
588
|
+
}
|
|
589
|
+
sheet_cursor_resource_usage() {
|
|
590
|
+
let e = J.xlsxarchive_sheet_cursor_resource_usage(this.__wbg_ptr);
|
|
591
|
+
if (e[3]) throw U(e[2]);
|
|
592
|
+
var t = F(e[0], e[1]).slice();
|
|
593
|
+
return J.__wbindgen_free(e[0], e[1] * 1, 1), t;
|
|
594
|
+
}
|
|
595
|
+
to_markdown() {
|
|
596
|
+
let e, t;
|
|
597
|
+
try {
|
|
598
|
+
let i = J.xlsxarchive_to_markdown(this.__wbg_ptr);
|
|
599
|
+
var n = i[0], r = i[1];
|
|
600
|
+
if (i[3]) throw n = 0, r = 0, U(i[2]);
|
|
601
|
+
return e = n, t = r, L(n, r);
|
|
602
|
+
} finally {
|
|
603
|
+
J.__wbindgen_free(e, t, 1);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
Symbol.dispose && (P.prototype[Symbol.dispose] = P.prototype.free);
|
|
608
|
+
function Je(e, t, n, r) {
|
|
609
|
+
let i = V(e, J.__wbindgen_malloc), a = q, o = H(t, J.__wbindgen_malloc, J.__wbindgen_realloc), s = q, c = J.extract_image(i, a, o, s, !B(n), B(n) ? BigInt(0) : n, !B(r), B(r) ? BigInt(0) : r);
|
|
610
|
+
if (c[3]) throw U(c[2]);
|
|
611
|
+
var l = F(c[0], c[1]).slice();
|
|
612
|
+
return J.__wbindgen_free(c[0], c[1] * 1, 1), l;
|
|
613
|
+
}
|
|
614
|
+
function Ye(e, t, n, r, i) {
|
|
615
|
+
let a = V(e, J.__wbindgen_malloc), o = q, s = H(n, J.__wbindgen_malloc, J.__wbindgen_realloc), c = q, l = J.parse_sheet(a, o, t, s, c, !B(r), B(r) ? BigInt(0) : r, !B(i), B(i) ? BigInt(0) : i);
|
|
616
|
+
if (l[3]) throw U(l[2]);
|
|
617
|
+
var u = F(l[0], l[1]).slice();
|
|
618
|
+
return J.__wbindgen_free(l[0], l[1] * 1, 1), u;
|
|
619
|
+
}
|
|
620
|
+
function Xe(e, t, n) {
|
|
621
|
+
let r = V(e, J.__wbindgen_malloc), i = q, a = J.parse_xlsx(r, i, !B(t), B(t) ? BigInt(0) : t, !B(n), B(n) ? BigInt(0) : n);
|
|
622
|
+
if (a[3]) throw U(a[2]);
|
|
623
|
+
var o = F(a[0], a[1]).slice();
|
|
624
|
+
return J.__wbindgen_free(a[0], a[1] * 1, 1), o;
|
|
625
|
+
}
|
|
626
|
+
function Ze(e, t, n) {
|
|
627
|
+
let r, i;
|
|
628
|
+
try {
|
|
629
|
+
let s = V(e, J.__wbindgen_malloc), c = q, l = J.xlsx_to_markdown(s, c, !B(t), B(t) ? BigInt(0) : t, !B(n), B(n) ? BigInt(0) : n);
|
|
630
|
+
var a = l[0], o = l[1];
|
|
631
|
+
if (l[3]) throw a = 0, o = 0, U(l[2]);
|
|
632
|
+
return r = a, i = o, L(a, o);
|
|
633
|
+
} finally {
|
|
634
|
+
J.__wbindgen_free(r, i, 1);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
function Qe() {
|
|
638
|
+
return {
|
|
639
|
+
__proto__: null,
|
|
640
|
+
"./xlsx_parser_bg.js": {
|
|
641
|
+
__proto__: null,
|
|
642
|
+
__wbg___wbindgen_throw_6b64449b9b9ed33c: function(e, t) {
|
|
643
|
+
throw Error(L(e, t));
|
|
644
|
+
},
|
|
645
|
+
__wbg_error_a6fa202b58aa1cd3: function(e, t) {
|
|
646
|
+
let n, r;
|
|
647
|
+
try {
|
|
648
|
+
n = e, r = t, console.error(L(e, t));
|
|
649
|
+
} finally {
|
|
650
|
+
J.__wbindgen_free(n, r, 1);
|
|
651
|
+
}
|
|
652
|
+
},
|
|
653
|
+
__wbg_new_227d7c05414eb861: function() {
|
|
654
|
+
return /* @__PURE__ */ Error();
|
|
655
|
+
},
|
|
656
|
+
__wbg_stack_3b0d974bbf31e44f: function(e, t) {
|
|
657
|
+
let n = t.stack, r = H(n, J.__wbindgen_malloc, J.__wbindgen_realloc), i = q;
|
|
658
|
+
et().setInt32(e + 4, i, !0), et().setInt32(e + 0, r, !0);
|
|
659
|
+
},
|
|
660
|
+
__wbindgen_cast_0000000000000001: function(e, t) {
|
|
661
|
+
return L(e, t);
|
|
662
|
+
},
|
|
663
|
+
__wbindgen_init_externref_table: function() {
|
|
664
|
+
let e = J.__wbindgen_externrefs, t = e.grow(4);
|
|
665
|
+
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);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
var $e = typeof FinalizationRegistry > "u" ? {
|
|
671
|
+
register: () => {},
|
|
672
|
+
unregister: () => {}
|
|
673
|
+
} : new FinalizationRegistry((e) => J.__wbg_xlsxarchive_free(e >>> 0, 1));
|
|
674
|
+
function F(e, t) {
|
|
675
|
+
return e >>>= 0, z().subarray(e / 1, e / 1 + t);
|
|
676
|
+
}
|
|
677
|
+
var I = null;
|
|
678
|
+
function et() {
|
|
679
|
+
return (I === null || I.buffer.detached === !0 || I.buffer.detached === void 0 && I.buffer !== J.memory.buffer) && (I = new DataView(J.memory.buffer)), I;
|
|
680
|
+
}
|
|
681
|
+
function L(e, t) {
|
|
682
|
+
return e >>>= 0, nt(e, t);
|
|
683
|
+
}
|
|
684
|
+
var R = null;
|
|
685
|
+
function z() {
|
|
686
|
+
return (R === null || R.byteLength === 0) && (R = new Uint8Array(J.memory.buffer)), R;
|
|
687
|
+
}
|
|
688
|
+
function B(e) {
|
|
689
|
+
return e == null;
|
|
690
|
+
}
|
|
691
|
+
function V(e, t) {
|
|
692
|
+
let n = t(e.length * 1, 1) >>> 0;
|
|
693
|
+
return z().set(e, n / 1), q = e.length, n;
|
|
694
|
+
}
|
|
695
|
+
function H(e, t, n) {
|
|
696
|
+
if (n === void 0) {
|
|
697
|
+
let n = K.encode(e), r = t(n.length, 1) >>> 0;
|
|
698
|
+
return z().subarray(r, r + n.length).set(n), q = n.length, r;
|
|
699
|
+
}
|
|
700
|
+
let r = e.length, i = t(r, 1) >>> 0, a = z(), o = 0;
|
|
701
|
+
for (; o < r; o++) {
|
|
702
|
+
let t = e.charCodeAt(o);
|
|
703
|
+
if (t > 127) break;
|
|
704
|
+
a[i + o] = t;
|
|
705
|
+
}
|
|
706
|
+
if (o !== r) {
|
|
707
|
+
o !== 0 && (e = e.slice(o)), i = n(i, r, r = o + e.length * 3, 1) >>> 0;
|
|
708
|
+
let t = z().subarray(i + o, i + r), a = K.encodeInto(e, t);
|
|
709
|
+
o += a.written, i = n(i, r, o, 1) >>> 0;
|
|
710
|
+
}
|
|
711
|
+
return q = o, i;
|
|
712
|
+
}
|
|
713
|
+
function U(e) {
|
|
714
|
+
let t = J.__wbindgen_externrefs.get(e);
|
|
715
|
+
return J.__externref_table_dealloc(e), t;
|
|
716
|
+
}
|
|
717
|
+
var W = new TextDecoder("utf-8", {
|
|
718
|
+
ignoreBOM: !0,
|
|
719
|
+
fatal: !0
|
|
720
|
+
});
|
|
721
|
+
W.decode();
|
|
722
|
+
var tt = 2146435072, G = 0;
|
|
723
|
+
function nt(e, t) {
|
|
724
|
+
return G += t, G >= tt && (W = new TextDecoder("utf-8", {
|
|
725
|
+
ignoreBOM: !0,
|
|
726
|
+
fatal: !0
|
|
727
|
+
}), W.decode(), G = t), W.decode(z().subarray(e, e + t));
|
|
728
|
+
}
|
|
729
|
+
var K = new TextEncoder();
|
|
730
|
+
"encodeInto" in K || (K.encodeInto = function(e, t) {
|
|
731
|
+
let n = K.encode(e);
|
|
732
|
+
return t.set(n), {
|
|
733
|
+
read: e.length,
|
|
734
|
+
written: n.length
|
|
735
|
+
};
|
|
736
|
+
});
|
|
737
|
+
var q = 0, J;
|
|
738
|
+
function Y(e, t) {
|
|
739
|
+
return J = e.exports, I = null, R = null, J.__wbindgen_start(), J;
|
|
740
|
+
}
|
|
741
|
+
async function rt(e, t) {
|
|
742
|
+
if (typeof Response == "function" && e instanceof Response) {
|
|
743
|
+
if (typeof WebAssembly.instantiateStreaming == "function") try {
|
|
744
|
+
return await WebAssembly.instantiateStreaming(e, t);
|
|
745
|
+
} catch (t) {
|
|
746
|
+
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);
|
|
747
|
+
else throw t;
|
|
748
|
+
}
|
|
749
|
+
let r = await e.arrayBuffer();
|
|
750
|
+
return await WebAssembly.instantiate(r, t);
|
|
751
|
+
} else {
|
|
752
|
+
let n = await WebAssembly.instantiate(e, t);
|
|
753
|
+
return n instanceof WebAssembly.Instance ? {
|
|
754
|
+
instance: n,
|
|
755
|
+
module: e
|
|
756
|
+
} : n;
|
|
757
|
+
}
|
|
758
|
+
function n(e) {
|
|
759
|
+
switch (e) {
|
|
760
|
+
case "basic":
|
|
761
|
+
case "cors":
|
|
762
|
+
case "default": return !0;
|
|
763
|
+
}
|
|
764
|
+
return !1;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
function it(e) {
|
|
768
|
+
if (J !== void 0) return J;
|
|
769
|
+
e !== void 0 && (Object.getPrototypeOf(e) === Object.prototype ? {module: e} = e : console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));
|
|
770
|
+
let t = Qe();
|
|
771
|
+
return e instanceof WebAssembly.Module || (e = new WebAssembly.Module(e)), Y(new WebAssembly.Instance(e, t), e);
|
|
772
|
+
}
|
|
773
|
+
async function at(e) {
|
|
774
|
+
if (J !== void 0) return J;
|
|
775
|
+
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"));
|
|
776
|
+
let t = Qe();
|
|
777
|
+
(typeof e == "string" || typeof Request == "function" && e instanceof Request || typeof URL == "function" && e instanceof URL) && (e = fetch(e));
|
|
778
|
+
let { instance: n, module: r } = await rt(await e, t);
|
|
779
|
+
return Y(n, r);
|
|
780
|
+
}
|
|
781
|
+
async function ot(e) {
|
|
782
|
+
return J = void 0, I = null, R = null, at(e);
|
|
783
|
+
}
|
|
784
|
+
//#endregion
|
|
785
|
+
//#region packages/node/src/xlsx.ts
|
|
786
|
+
var st = !1;
|
|
787
|
+
function X() {
|
|
788
|
+
st ||= (me(qe, ge(import.meta.url, "../../xlsx/src/wasm/xlsx_parser_bg.wasm")), !0);
|
|
789
|
+
}
|
|
790
|
+
function Z(e) {
|
|
791
|
+
X();
|
|
792
|
+
let t = Xe(Q(e));
|
|
793
|
+
return JSON.parse(new TextDecoder().decode(t));
|
|
794
|
+
}
|
|
795
|
+
function ct(e, t, n) {
|
|
796
|
+
X();
|
|
797
|
+
let r = Ye(Q(e), t, n);
|
|
798
|
+
return JSON.parse(new TextDecoder().decode(r));
|
|
799
|
+
}
|
|
800
|
+
function lt(e, t, n) {
|
|
801
|
+
return se(ct(e, t, n), Z(e).sharedStrings);
|
|
802
|
+
}
|
|
803
|
+
function ut(e) {
|
|
804
|
+
let t = Z(e), n = {};
|
|
805
|
+
for (let r = 0; r < t.workbook.sheets.length; r++) {
|
|
806
|
+
let i = t.workbook.sheets[r];
|
|
807
|
+
n[i.name] = se(ct(e, r, i.name), t.sharedStrings);
|
|
808
|
+
}
|
|
809
|
+
return {
|
|
810
|
+
workbook: t.workbook,
|
|
811
|
+
worksheets: n
|
|
812
|
+
};
|
|
813
|
+
}
|
|
814
|
+
async function dt(e, n = {}) {
|
|
815
|
+
let r = m(n), i = new o({
|
|
816
|
+
enabled: r.debug || r.onResourceMetrics !== void 0,
|
|
817
|
+
format: "xlsx",
|
|
818
|
+
mode: "node",
|
|
819
|
+
scope: "session",
|
|
820
|
+
policy: r.policy,
|
|
821
|
+
onMetrics: r.onResourceMetrics,
|
|
822
|
+
emitToConsole: r.debug
|
|
823
|
+
}), a = Q(e);
|
|
824
|
+
i.setSourceBytes(a.byteLength);
|
|
825
|
+
let c;
|
|
826
|
+
try {
|
|
827
|
+
$(n.signal), X();
|
|
828
|
+
let [e, t] = s(r.policy);
|
|
829
|
+
c = pt(P, a, e, t);
|
|
830
|
+
let o = JSON.parse(new TextDecoder().decode(c.parse())), l = mt(c.resource_usage());
|
|
831
|
+
return i.observeUsage(l), i.checkpoint("workbook index ready"), new ft(c, o, i, l, n.signal);
|
|
832
|
+
} catch (e) {
|
|
833
|
+
try {
|
|
834
|
+
c?.free();
|
|
835
|
+
} catch {}
|
|
836
|
+
let n = t(e) ?? e;
|
|
837
|
+
throw i.fail(n), n;
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
var ft = class {
|
|
841
|
+
sheetCount;
|
|
842
|
+
sheetNames;
|
|
843
|
+
pull;
|
|
844
|
+
transport;
|
|
845
|
+
workbook;
|
|
846
|
+
nextOperationId = 1;
|
|
847
|
+
active;
|
|
848
|
+
closed = !1;
|
|
849
|
+
closePromise;
|
|
850
|
+
lastUsage;
|
|
851
|
+
completedWorksheets = 0;
|
|
852
|
+
rowBatches = 0;
|
|
853
|
+
emittedRows = 0;
|
|
854
|
+
constructor(e, t, n, r, i) {
|
|
855
|
+
this.archive = e, this.metrics = n, this.signal = i, this.workbook = t, this.sheetNames = Object.freeze(t.workbook.sheets.map((e) => e.name)), this.sheetCount = this.sheetNames.length, this.lastUsage = r, this.pull = new le(() => this.archive), this.transport = new de((e, t) => this.pull.dispatchSafely(e, t), () => void 0);
|
|
856
|
+
}
|
|
857
|
+
get resourceUsage() {
|
|
858
|
+
if (this.closed) return this.lastUsage;
|
|
859
|
+
try {
|
|
860
|
+
this.lastUsage = mt(this.archive.resource_usage());
|
|
861
|
+
} catch {}
|
|
862
|
+
return this.lastUsage;
|
|
863
|
+
}
|
|
864
|
+
async *worksheetRows(e) {
|
|
865
|
+
if (this.closed) throw Error("XLSX workbook session is closed");
|
|
866
|
+
if (this.active) throw Error("another XLSX worksheet row stream is already active");
|
|
867
|
+
if (!Number.isSafeInteger(e) || e < 0) throw RangeError("sheetIndex must be a non-negative safe integer");
|
|
868
|
+
let n = this.requireSheetName(e);
|
|
869
|
+
$(this.signal);
|
|
870
|
+
let r = this.nextOperationId++, i = {
|
|
871
|
+
identity: {
|
|
872
|
+
sessionId: r,
|
|
873
|
+
operationId: r,
|
|
874
|
+
generation: 1
|
|
875
|
+
},
|
|
876
|
+
terminalAcknowledged: !1
|
|
877
|
+
};
|
|
878
|
+
this.active = i;
|
|
879
|
+
let a;
|
|
880
|
+
try {
|
|
881
|
+
this.pull.reserveOpen(i.identity), await this.pull.open(e, n, i.identity);
|
|
882
|
+
let t = new p(this.transport, {
|
|
883
|
+
...i.identity,
|
|
884
|
+
maxByteCredit: ce
|
|
885
|
+
});
|
|
886
|
+
for (i.client = t;;) {
|
|
887
|
+
if (this.closed) throw Error("XLSX workbook session is closed");
|
|
888
|
+
$(this.signal);
|
|
889
|
+
let e = await t.pull(ce, { signal: this.signal });
|
|
890
|
+
this.lastUsage = e.usage ?? this.lastUsage, this.metrics.observeUsage(e.usage);
|
|
891
|
+
let n = JSON.parse(new TextDecoder().decode(new Uint8Array(e.payload)));
|
|
892
|
+
if (e.done !== (n.kind === "finished")) throw Error("worksheet cursor terminal marker mismatch");
|
|
893
|
+
if (n.kind === "rows") {
|
|
894
|
+
ue(n.rows, this.requireWorkbook().sharedStrings), this.rowBatches += 1, this.emittedRows += n.rows.length, yield {
|
|
895
|
+
kind: "rows",
|
|
896
|
+
rows: n.rows,
|
|
897
|
+
sequence: e.sequence,
|
|
898
|
+
wireBytes: e.byteLength,
|
|
899
|
+
usage: e.usage
|
|
900
|
+
}, await e.ack({ signal: this.signal });
|
|
901
|
+
continue;
|
|
902
|
+
}
|
|
903
|
+
n.worksheet.rows = [], yield {
|
|
904
|
+
kind: "finished",
|
|
905
|
+
worksheet: n.worksheet,
|
|
906
|
+
sequence: e.sequence,
|
|
907
|
+
wireBytes: e.byteLength,
|
|
908
|
+
usage: e.usage
|
|
909
|
+
}, await e.ack({ signal: this.signal }), i.terminalAcknowledged = !0, this.completedWorksheets += 1, this.metrics.checkpoint("worksheet stream complete", e.usage);
|
|
910
|
+
return;
|
|
911
|
+
}
|
|
912
|
+
} catch (e) {
|
|
913
|
+
throw a = t(e) ?? e, this.metrics.fail(a), await this.close().catch(() => void 0), a;
|
|
914
|
+
} finally {
|
|
915
|
+
try {
|
|
916
|
+
await this.cleanupOperation(i, a === void 0 ? "closed" : "request-error");
|
|
917
|
+
} catch (e) {
|
|
918
|
+
if (a === void 0) {
|
|
919
|
+
let n = t(e) ?? e;
|
|
920
|
+
throw this.metrics.fail(n), await this.close().catch(() => void 0), n;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
close() {
|
|
926
|
+
return this.closePromise ? this.closePromise : (this.closed = !0, this.closePromise = this.release(), this.closePromise);
|
|
927
|
+
}
|
|
928
|
+
cleanupOperation(e, n) {
|
|
929
|
+
return e.cleanupPromise ||= (async () => {
|
|
930
|
+
let r;
|
|
931
|
+
if (e.client && !e.terminalAcknowledged) try {
|
|
932
|
+
await e.client.cancel(n);
|
|
933
|
+
} catch (e) {
|
|
934
|
+
r = t(e) ?? e;
|
|
935
|
+
}
|
|
936
|
+
try {
|
|
937
|
+
await this.pull.reset();
|
|
938
|
+
} catch (e) {
|
|
939
|
+
r ??= t(e) ?? e;
|
|
940
|
+
}
|
|
941
|
+
if (this.active === e && (this.active = void 0), r !== void 0) throw r;
|
|
942
|
+
})(), e.cleanupPromise;
|
|
943
|
+
}
|
|
944
|
+
async release() {
|
|
945
|
+
let e;
|
|
946
|
+
if (this.active) try {
|
|
947
|
+
await this.cleanupOperation(this.active, "closed");
|
|
948
|
+
} catch (n) {
|
|
949
|
+
e = t(n) ?? n;
|
|
950
|
+
}
|
|
951
|
+
this.transport.terminate(), this.workbook = null;
|
|
952
|
+
try {
|
|
953
|
+
this.archive.free();
|
|
954
|
+
} catch (n) {
|
|
955
|
+
e ??= t(n) ?? n;
|
|
956
|
+
}
|
|
957
|
+
if (e !== void 0) throw this.metrics.fail(e), e;
|
|
958
|
+
this.metrics.checkpoint("workbook session closed", this.lastUsage), this.metrics.succeed({
|
|
959
|
+
worksheets: this.completedWorksheets,
|
|
960
|
+
"row-batches": this.rowBatches,
|
|
961
|
+
rows: this.emittedRows
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
requireWorkbook() {
|
|
965
|
+
if (!this.workbook) throw Error("XLSX workbook session is closed");
|
|
966
|
+
return this.workbook;
|
|
967
|
+
}
|
|
968
|
+
requireSheetName(e) {
|
|
969
|
+
let t = this.requireWorkbook().workbook.sheets[e];
|
|
970
|
+
if (!t) throw RangeError(`Sheet index ${e} out of range`);
|
|
971
|
+
return t.name;
|
|
972
|
+
}
|
|
973
|
+
};
|
|
974
|
+
function pt(e, n, r, i) {
|
|
975
|
+
try {
|
|
976
|
+
return new e(n, r, i);
|
|
977
|
+
} catch (e) {
|
|
978
|
+
throw t(e) ?? e;
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
function mt(e) {
|
|
982
|
+
try {
|
|
983
|
+
return i(e);
|
|
984
|
+
} catch (e) {
|
|
985
|
+
if (String(e).includes("worksheet cursor usage is unavailable")) return;
|
|
986
|
+
throw e;
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
function Q(e) {
|
|
990
|
+
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
991
|
+
}
|
|
992
|
+
function $(e) {
|
|
993
|
+
if (!e?.aborted) return;
|
|
994
|
+
let t = /* @__PURE__ */ Error("XLSX workbook session was aborted");
|
|
995
|
+
throw t.name = "AbortError", t;
|
|
996
|
+
}
|
|
997
|
+
//#endregion
|
|
998
|
+
export { re as OoxmlDecodedImageLimitError, n as OoxmlResourceLimitError, _e as extractPptxImage, pe as extractPptxMedia, Se as installImageBitmapShim, ye as installOffscreenCanvasShim, ie as isOoxmlDecodedImageLimitError, xe as makeSourceBufferFetchImage, He as openDocxDocument, he as openPptxPresentation, dt as openXlsxWorkbook, Ve as parseDocx, fe as parsePptx, Z as parseXlsx, ut as parseXlsxAllSheets, lt as parseXlsxSheet, ve as renderSlideNode };
|