@silurus/ooxml 0.75.5 → 0.76.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 +66 -28
- package/dist/bounded-raw-part-cache-C6ro6Ezf.js +254 -0
- package/dist/{find-cursor-Dc5iM6s7.js → canvas-viewer-mechanics-CwVSOYke.js} +192 -64
- package/dist/{document-pull-client-BcNYhoAG.js → document-pull-client-DQNen8c4.js} +3620 -3597
- package/dist/docx-DYRguRRi.js +1301 -0
- package/dist/docx.mjs +4 -6
- package/dist/docx_parser_bg.wasm +0 -0
- package/dist/index.mjs +3 -3
- package/dist/{line-distribute-B8sqT8kC.js → line-distribute-C1r2zvji.js} +141 -141
- package/dist/{line-metrics-D9gqQWHl.js → line-metrics-BdCACYlq.js} +4026 -1170
- package/dist/math.mjs +1 -1
- package/dist/node.mjs +779 -465
- package/dist/pptx-B-EJp83T.js +1735 -0
- package/dist/pptx.mjs +5 -7
- package/dist/pptx_parser_bg.wasm +0 -0
- package/dist/{render-CalC7GX4.js → render-CLcpSi0m.js} +11 -18
- package/dist/render-worker-host-Bkf1jUcW.js +27 -0
- package/dist/render-worker-host-CKOmXdyr.js +27 -0
- package/dist/render-worker-host-DWLyqwI3.js +27 -0
- package/dist/resource-measurement-E_S_iau4.js +119 -0
- package/dist/session-B4Y54cbT.js +730 -0
- package/dist/{renderer-B9R6F_QY.js → slide-pull-client-WCuYCjio.js} +973 -820
- package/dist/types/docx.d.ts +1181 -3994
- package/dist/types/index.d.ts +2733 -8171
- package/dist/types/math.d.ts +8 -33
- package/dist/types/node.d.ts +1852 -4433
- package/dist/types/pptx.d.ts +1030 -3678
- package/dist/types/xlsx.d.ts +1291 -3262
- package/dist/worksheet-pull-client-YzjJMOns.js +455 -0
- package/dist/xlsx-BBmmZNQn.js +6362 -0
- package/dist/xlsx.mjs +5 -7
- package/dist/xlsx_parser_bg.wasm +0 -0
- package/package.json +14 -7
- package/dist/bounded-raw-part-cache-BTfZD_Sz.js +0 -1248
- package/dist/docx-DjF8FgoP.js +0 -1274
- package/dist/duotone-bitmap-by-path-CWsSJkJu.js +0 -28
- package/dist/hyperlink-D85FexTa.js +0 -27
- package/dist/pptx-C17xP8AV.js +0 -1705
- package/dist/pptx-Dl8tOSmP.js +0 -822
- package/dist/preload-BEouWnlI.js +0 -132
- package/dist/render-worker-host-BG3a7brz.js +0 -27
- package/dist/render-worker-host-CsB-dPJv.js +0 -27
- package/dist/render-worker-host-Cyv5Hkbh.js +0 -27
- package/dist/resource-measurement-6aReN3K0.js +0 -93
- package/dist/slide-pull-client-D_T0AIoX.js +0 -175
- package/dist/svg-image-by-path-C1M3N2pT.js +0 -1623
- package/dist/worksheet-pull-worker-DCei8u-4.js +0 -347
- package/dist/xlsx-BaH9irS0.js +0 -5515
- /package/dist/{highlight-rect-cCvVU-MW.js → highlight-rect-CAkCWJ37.js} +0 -0
- /package/dist/{mathjax-Dqo857oC.js → mathjax-CMjda8Ip.js} +0 -0
- /package/dist/{transfer-3QEJrsJa.js → transfer-DCu4c2BL.js} +0 -0
- /package/dist/{visible-index-CKvgpUrf.js → visible-index-CgyJLAS_.js} +0 -0
package/dist/node.mjs
CHANGED
|
@@ -1,14 +1,245 @@
|
|
|
1
1
|
import { t as e } from "./chunk-DmhlhrBa.js";
|
|
2
|
-
import {
|
|
3
|
-
import { c as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
2
|
+
import { t } from "./slide-pull-client-WCuYCjio.js";
|
|
3
|
+
import { B as n, Et as r, F as i, H as a, I as o, It as s, Lt as c, P as l, R as u, U as d, W as ee, at as f, hn as p, kt as m, ot as h, q as te, rt as g, st as ne } from "./line-metrics-BdCACYlq.js";
|
|
4
|
+
import { t as re } from "./bounded-raw-part-cache-C6ro6Ezf.js";
|
|
5
|
+
import { a as ie, c as ae, i as oe, l as se, r as ce, u as le } from "./document-pull-client-DQNen8c4.js";
|
|
6
|
+
import { t as ue } from "./transfer-DCu4c2BL.js";
|
|
7
|
+
import { a as de, c as fe, d as pe, l as me, o as he, r as ge, s as _e, t as ve, u as ye } from "./worksheet-pull-client-YzjJMOns.js";
|
|
8
|
+
import { a as be, i as xe, n as Se, r as Ce } from "./session-B4Y54cbT.js";
|
|
9
|
+
import { a as we, n as Te, r as Ee, t as De } from "./render-CLcpSi0m.js";
|
|
10
|
+
import { existsSync as Oe, readFileSync as ke } from "node:fs";
|
|
11
|
+
import { fileURLToPath as Ae } from "node:url";
|
|
12
|
+
import { basename as je, dirname as Me, resolve as Ne } from "node:path";
|
|
13
|
+
import { createRequire as Pe } from "node:module";
|
|
14
|
+
//#region packages/core/src/internal/owned-session.ts
|
|
15
|
+
async function _(e, t) {
|
|
16
|
+
let n = await e(), r;
|
|
17
|
+
try {
|
|
18
|
+
return await t(n);
|
|
19
|
+
} catch (e) {
|
|
20
|
+
throw r = e, e;
|
|
21
|
+
} finally {
|
|
22
|
+
try {
|
|
23
|
+
await n.close();
|
|
24
|
+
} catch (e) {
|
|
25
|
+
if (r === void 0) throw e;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region packages/core/src/internal/in-process-pull-transport.ts
|
|
31
|
+
var v = class {
|
|
32
|
+
nextRequestId = 1;
|
|
33
|
+
terminated = !1;
|
|
34
|
+
constructor(e, t) {
|
|
35
|
+
this.dispatch = e, this.terminateHost = t;
|
|
36
|
+
}
|
|
37
|
+
async request(e, t, n) {
|
|
38
|
+
if (this.terminated) throw Error("pull transport terminated");
|
|
39
|
+
if (n?.signal?.aborted) {
|
|
40
|
+
n.onCancel?.(this.nextRequestId, "abort");
|
|
41
|
+
let e = /* @__PURE__ */ Error("worker request aborted");
|
|
42
|
+
throw e.name = "AbortError", e;
|
|
43
|
+
}
|
|
44
|
+
let r = e(this.nextRequestId++), i;
|
|
45
|
+
if (await this.dispatch(r, (e) => {
|
|
46
|
+
i = e;
|
|
47
|
+
}), i === void 0) throw Error("in-process pull host did not respond");
|
|
48
|
+
return i;
|
|
49
|
+
}
|
|
50
|
+
forgetOrphaned(e) {}
|
|
51
|
+
terminate() {
|
|
52
|
+
this.terminated || (this.terminated = !0, this.terminateHost());
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region packages/node/src/wasm-loader.ts
|
|
57
|
+
function Fe(e) {
|
|
58
|
+
return new WebAssembly.Module(ke(e));
|
|
59
|
+
}
|
|
60
|
+
function y(e, t = Fe) {
|
|
61
|
+
let n = {};
|
|
62
|
+
return () => n.value ??= t(e());
|
|
63
|
+
}
|
|
64
|
+
function Ie(e, t, n) {
|
|
65
|
+
let r = Me(Ae(e)), i = Ne(r, t);
|
|
66
|
+
if (Oe(i)) return i;
|
|
67
|
+
let a = Ne(r, je(t));
|
|
68
|
+
return Oe(a) || !n ? a : Pe(e).resolve(n);
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region packages/node/src/pptx.ts
|
|
72
|
+
var Le = y(() => Ie(import.meta.url, "pptx_parser_bg.wasm", "@silurus/ooxml-pptx/wasm-binary"));
|
|
73
|
+
async function Re(e, t = {}) {
|
|
74
|
+
return ze(e, t);
|
|
75
|
+
}
|
|
76
|
+
async function ze(e, t = {}) {
|
|
77
|
+
let n = await Se(He(e), Le(), t);
|
|
78
|
+
return new Be(n.closeArchive, n.archive, n.bootstrap, n.metrics, t.signal);
|
|
79
|
+
}
|
|
80
|
+
var Be = class {
|
|
81
|
+
slideCount;
|
|
82
|
+
slideWidth;
|
|
83
|
+
slideHeight;
|
|
84
|
+
slidePull;
|
|
85
|
+
slideClient;
|
|
86
|
+
transport;
|
|
87
|
+
started = !1;
|
|
88
|
+
closed = !1;
|
|
89
|
+
closePromise;
|
|
90
|
+
usage;
|
|
91
|
+
consumedSlides = 0;
|
|
92
|
+
resourceFailure;
|
|
93
|
+
renderTail = Promise.resolve();
|
|
94
|
+
fetchImage = (e, t) => this.getPartInternal(e, t, (t) => t.extract_image(e));
|
|
95
|
+
fetchMedia = (e) => this.getPartInternal(e, "application/octet-stream", (t) => t.extract_media(e));
|
|
96
|
+
rawParts = new re({
|
|
97
|
+
maxEntries: 64,
|
|
98
|
+
maxBytes: te
|
|
99
|
+
});
|
|
100
|
+
constructor(e, n, r, i, a) {
|
|
101
|
+
this.closeArchive = e, this.archive = n, this.bootstrap = r, this.metrics = i, this.signal = a, this.slideCount = r.slideCount, this.slideWidth = r.slideWidth, this.slideHeight = r.slideHeight, this.slidePull = new xe(() => this.archive), this.transport = new v((e, t) => this.slidePull.dispatchSafely(e, t), () => void 0), this.slideClient = new t({
|
|
102
|
+
slideCount: this.slideCount,
|
|
103
|
+
transport: this.transport,
|
|
104
|
+
open: async (e, t) => {
|
|
105
|
+
this.slidePull.reserveOpen(t), await this.slidePull.open(e, t);
|
|
106
|
+
},
|
|
107
|
+
onUsage: (e) => {
|
|
108
|
+
this.usage = e, this.metrics.observeUsage(e);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
materialize(e) {
|
|
113
|
+
return {
|
|
114
|
+
slideWidth: this.slideWidth,
|
|
115
|
+
slideHeight: this.slideHeight,
|
|
116
|
+
slides: e,
|
|
117
|
+
defaultTextColor: this.bootstrap.defaultTextColor,
|
|
118
|
+
majorFont: this.bootstrap.majorFont,
|
|
119
|
+
minorFont: this.bootstrap.minorFont,
|
|
120
|
+
...this.bootstrap.hlinkColor ? { hlinkColor: this.bootstrap.hlinkColor } : {},
|
|
121
|
+
...this.bootstrap.folHlinkColor ? { folHlinkColor: this.bootstrap.folHlinkColor } : {}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
get resourceUsage() {
|
|
125
|
+
return this.closed ? this.usage : this.refreshResourceUsage();
|
|
126
|
+
}
|
|
127
|
+
async getImage(e, t) {
|
|
128
|
+
return this.assertOpen(), this.getPartInternal(e, t, (t) => t.extract_image(e)).catch((e) => this.failOperation(e));
|
|
129
|
+
}
|
|
130
|
+
async getMedia(e, t = "application/octet-stream") {
|
|
131
|
+
return this.assertOpen(), this.getPartInternal(e, t, (t) => t.extract_media(e)).catch((e) => this.failOperation(e));
|
|
132
|
+
}
|
|
133
|
+
async renderSlide(e, t, n) {
|
|
134
|
+
return this.assertOpen(), this.enqueueRender(async () => {
|
|
135
|
+
b(this.signal);
|
|
136
|
+
let { renderSlideNode: r } = await import("./render-CLcpSi0m.js").then((e) => e.i);
|
|
137
|
+
await r(e, {
|
|
138
|
+
slideWidth: this.slideWidth,
|
|
139
|
+
slideHeight: this.slideHeight,
|
|
140
|
+
slides: [t],
|
|
141
|
+
defaultTextColor: this.bootstrap.defaultTextColor,
|
|
142
|
+
majorFont: this.bootstrap.majorFont,
|
|
143
|
+
minorFont: this.bootstrap.minorFont,
|
|
144
|
+
...this.bootstrap.hlinkColor ? { hlinkColor: this.bootstrap.hlinkColor } : {},
|
|
145
|
+
...this.bootstrap.folHlinkColor ? { folHlinkColor: this.bootstrap.folHlinkColor } : {}
|
|
146
|
+
}, 0, {
|
|
147
|
+
...n,
|
|
148
|
+
fetchImage: this.fetchImage,
|
|
149
|
+
fetchMedia: this.fetchMedia
|
|
150
|
+
}), b(this.signal);
|
|
151
|
+
}).catch((e) => this.failOperation(e));
|
|
152
|
+
}
|
|
153
|
+
[Symbol.asyncIterator]() {
|
|
154
|
+
return this.slides();
|
|
155
|
+
}
|
|
156
|
+
async *slides() {
|
|
157
|
+
if (this.closed) throw Error("PPTX presentation session is closed");
|
|
158
|
+
if (this.started) throw Error("PPTX presentation session is one-pass and was already consumed");
|
|
159
|
+
this.started = !0;
|
|
160
|
+
let e;
|
|
161
|
+
try {
|
|
162
|
+
for (let e = 0; e < this.slideCount; e += 1) {
|
|
163
|
+
b(this.signal);
|
|
164
|
+
let t = await this.slideClient.load(e);
|
|
165
|
+
if (!t) throw Error(`PPTX slide ${e} was not decoded`);
|
|
166
|
+
this.usage ??= await this.slidePull.run(() => be((e) => e(this.archive))), this.metrics.observeUsage(this.usage), this.consumedSlides = e + 1, yield t;
|
|
167
|
+
}
|
|
168
|
+
} catch (t) {
|
|
169
|
+
throw e = f(t) ?? t, this.metrics.fail(e), e;
|
|
170
|
+
} finally {
|
|
171
|
+
try {
|
|
172
|
+
await this.close();
|
|
173
|
+
} catch (t) {
|
|
174
|
+
if (e === void 0) throw t;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
close() {
|
|
179
|
+
return this.closePromise ? this.closePromise : (this.closed = !0, this.slideClient.cancelAll(), this.closePromise = this.release(), this.closePromise);
|
|
180
|
+
}
|
|
181
|
+
async release() {
|
|
182
|
+
let e;
|
|
183
|
+
await this.renderTail, m(this.fetchImage), r(this.fetchImage);
|
|
184
|
+
try {
|
|
185
|
+
await this.slidePull.reset();
|
|
186
|
+
} catch (t) {
|
|
187
|
+
e = f(t) ?? t;
|
|
188
|
+
}
|
|
189
|
+
this.transport.terminate(), this.rawParts.clear();
|
|
190
|
+
try {
|
|
191
|
+
this.closeArchive();
|
|
192
|
+
} catch (t) {
|
|
193
|
+
e ??= f(t) ?? t;
|
|
194
|
+
}
|
|
195
|
+
if (e !== void 0) throw this.metrics.fail(e), e;
|
|
196
|
+
this.metrics.checkpoint("presentation session closed"), this.metrics.succeed({ slides: this.consumedSlides });
|
|
197
|
+
}
|
|
198
|
+
enqueueRender(e) {
|
|
199
|
+
let t = this.renderTail.then(e, e);
|
|
200
|
+
return this.renderTail = t.then(() => void 0, () => void 0), t;
|
|
201
|
+
}
|
|
202
|
+
getPartInternal(e, t, n) {
|
|
203
|
+
return this.rawParts.get(e, t, () => {
|
|
204
|
+
b(this.signal);
|
|
205
|
+
let e = n(this.archive);
|
|
206
|
+
return this.refreshResourceUsage(), new Blob([e], { type: t });
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
refreshResourceUsage() {
|
|
210
|
+
try {
|
|
211
|
+
this.usage = g(this.archive.resource_usage()), this.metrics.observeUsage(this.usage);
|
|
212
|
+
} catch {}
|
|
213
|
+
return this.usage;
|
|
214
|
+
}
|
|
215
|
+
assertOpen() {
|
|
216
|
+
if (this.closed) throw Error("PPTX presentation session is closed");
|
|
217
|
+
if (this.resourceFailure) throw this.resourceFailure;
|
|
218
|
+
}
|
|
219
|
+
failOperation(e) {
|
|
220
|
+
let t = f(e) ?? e;
|
|
221
|
+
throw t instanceof p && (this.resourceFailure ??= t), this.metrics.fail(t), t;
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
async function Ve(e, t = {}) {
|
|
225
|
+
return _(() => ze(e, t), async (e) => {
|
|
226
|
+
let t = [];
|
|
227
|
+
for await (let n of e.slides()) t.push(n);
|
|
228
|
+
return e.materialize(t);
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
function He(e) {
|
|
232
|
+
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
233
|
+
}
|
|
234
|
+
function b(e) {
|
|
235
|
+
if (!e?.aborted) return;
|
|
236
|
+
let t = /* @__PURE__ */ Error("PPTX presentation session was aborted");
|
|
237
|
+
throw t.name = "AbortError", t;
|
|
238
|
+
}
|
|
239
|
+
//#endregion
|
|
9
240
|
//#region packages/docx/src/document-pull-worker.ts
|
|
10
|
-
var
|
|
11
|
-
coordinator = new
|
|
241
|
+
var Ue = Math.max(d, ee), We = class {
|
|
242
|
+
coordinator = new o();
|
|
12
243
|
host = null;
|
|
13
244
|
identity = null;
|
|
14
245
|
constructor(e, t = (e) => e(this.requireArchive())) {
|
|
@@ -20,9 +251,9 @@ var Ce = Math.max(f, u), we = class {
|
|
|
20
251
|
t.open_document_cursor(e.operationId, e.generation);
|
|
21
252
|
});
|
|
22
253
|
let t = 0;
|
|
23
|
-
this.identity = e, this.host = new
|
|
254
|
+
this.identity = e, this.host = new i({
|
|
24
255
|
...e,
|
|
25
|
-
maxByteCredit:
|
|
256
|
+
maxByteCredit: Ue,
|
|
26
257
|
coordinator: this.coordinator,
|
|
27
258
|
driver: {
|
|
28
259
|
pull: (n) => {
|
|
@@ -30,9 +261,9 @@ var Ce = Math.max(f, u), we = class {
|
|
|
30
261
|
try {
|
|
31
262
|
r = this.executeArchive((r) => r.pull_document_chunk(t, e.operationId, e.generation, n));
|
|
32
263
|
} catch (e) {
|
|
33
|
-
throw
|
|
264
|
+
throw ne(e, n, Ue) || e;
|
|
34
265
|
}
|
|
35
|
-
let i =
|
|
266
|
+
let i = ue(r);
|
|
36
267
|
return {
|
|
37
268
|
payload: i,
|
|
38
269
|
byteLength: i.byteLength,
|
|
@@ -49,27 +280,27 @@ var Ce = Math.max(f, u), we = class {
|
|
|
49
280
|
close: () => this.executeArchive((e) => e.close_document_session()),
|
|
50
281
|
resourceUsage: () => {
|
|
51
282
|
let e = this.executeArchive((e) => e.document_cursor_resource_usage?.());
|
|
52
|
-
return e ?
|
|
283
|
+
return e ? g(e) : void 0;
|
|
53
284
|
}
|
|
54
285
|
}
|
|
55
286
|
});
|
|
56
287
|
}
|
|
57
288
|
dispatch(e, t) {
|
|
58
289
|
return !this.host || !this.identity ? (t({
|
|
59
|
-
protocol:
|
|
290
|
+
protocol: l,
|
|
60
291
|
kind: "error",
|
|
61
292
|
sessionId: e.sessionId,
|
|
62
293
|
operationId: e.operationId,
|
|
63
294
|
generation: e.generation,
|
|
64
295
|
requestId: e.requestId,
|
|
65
|
-
error:
|
|
296
|
+
error: h(/* @__PURE__ */ Error("DOCX document pull session is not open"))
|
|
66
297
|
}), Promise.resolve()) : this.host.dispatch(e, t);
|
|
67
298
|
}
|
|
68
299
|
async reset() {
|
|
69
300
|
if (this.host) try {
|
|
70
301
|
this.archive() && this.executeArchive((e) => e.close_document_session());
|
|
71
302
|
} finally {
|
|
72
|
-
this.host = null, this.identity = null, this.coordinator = new
|
|
303
|
+
this.host = null, this.identity = null, this.coordinator = new o();
|
|
73
304
|
}
|
|
74
305
|
}
|
|
75
306
|
requireArchive() {
|
|
@@ -77,181 +308,181 @@ var Ce = Math.max(f, u), we = class {
|
|
|
77
308
|
if (!e) throw Error("No docx loaded");
|
|
78
309
|
return e;
|
|
79
310
|
}
|
|
80
|
-
},
|
|
81
|
-
DocxArchive: () =>
|
|
82
|
-
default: () =>
|
|
83
|
-
docx_to_markdown: () =>
|
|
84
|
-
extract_image: () =>
|
|
85
|
-
initSync: () =>
|
|
86
|
-
parse_docx: () =>
|
|
87
|
-
reinit: () =>
|
|
88
|
-
}),
|
|
311
|
+
}, Ge = /* @__PURE__ */ e({
|
|
312
|
+
DocxArchive: () => x,
|
|
313
|
+
default: () => rt,
|
|
314
|
+
docx_to_markdown: () => Ke,
|
|
315
|
+
extract_image: () => qe,
|
|
316
|
+
initSync: () => nt,
|
|
317
|
+
parse_docx: () => Je,
|
|
318
|
+
reinit: () => it
|
|
319
|
+
}), x = class {
|
|
89
320
|
__destroy_into_raw() {
|
|
90
321
|
let e = this.__wbg_ptr;
|
|
91
|
-
return this.__wbg_ptr = 0,
|
|
322
|
+
return this.__wbg_ptr = 0, Xe.unregister(this), e;
|
|
92
323
|
}
|
|
93
324
|
free() {
|
|
94
325
|
let e = this.__destroy_into_raw();
|
|
95
|
-
|
|
326
|
+
F.__wbg_docxarchive_free(e, 0);
|
|
96
327
|
}
|
|
97
328
|
acknowledge_document_chunk(e, t, n) {
|
|
98
|
-
let r =
|
|
99
|
-
if (r[1]) throw
|
|
329
|
+
let r = F.docxarchive_acknowledge_document_chunk(this.__wbg_ptr, e, t, n);
|
|
330
|
+
if (r[1]) throw A(r[0]);
|
|
100
331
|
}
|
|
101
332
|
assert_healthy() {
|
|
102
|
-
let e =
|
|
103
|
-
if (e[1]) throw
|
|
333
|
+
let e = F.docxarchive_assert_healthy(this.__wbg_ptr);
|
|
334
|
+
if (e[1]) throw A(e[0]);
|
|
104
335
|
}
|
|
105
336
|
cancel_document_cursor() {
|
|
106
|
-
|
|
337
|
+
F.docxarchive_cancel_document_cursor(this.__wbg_ptr);
|
|
107
338
|
}
|
|
108
339
|
close_document_session() {
|
|
109
|
-
|
|
340
|
+
F.docxarchive_close_document_session(this.__wbg_ptr);
|
|
110
341
|
}
|
|
111
342
|
document_chunk_done() {
|
|
112
|
-
let e =
|
|
113
|
-
if (e[2]) throw
|
|
343
|
+
let e = F.docxarchive_document_chunk_done(this.__wbg_ptr);
|
|
344
|
+
if (e[2]) throw A(e[1]);
|
|
114
345
|
return e[0] !== 0;
|
|
115
346
|
}
|
|
116
347
|
document_cursor_resource_usage() {
|
|
117
|
-
let e =
|
|
118
|
-
if (e[3]) throw
|
|
119
|
-
var t =
|
|
120
|
-
return
|
|
348
|
+
let e = F.docxarchive_document_cursor_resource_usage(this.__wbg_ptr);
|
|
349
|
+
if (e[3]) throw A(e[2]);
|
|
350
|
+
var t = S(e[0], e[1]).slice();
|
|
351
|
+
return F.__wbindgen_free(e[0], e[1] * 1, 1), t;
|
|
121
352
|
}
|
|
122
353
|
extract_image(e) {
|
|
123
|
-
let t =
|
|
124
|
-
if (r[3]) throw
|
|
125
|
-
var i =
|
|
126
|
-
return
|
|
354
|
+
let t = k(e, F.__wbindgen_malloc, F.__wbindgen_realloc), n = P, r = F.docxarchive_extract_image(this.__wbg_ptr, t, n);
|
|
355
|
+
if (r[3]) throw A(r[2]);
|
|
356
|
+
var i = S(r[0], r[1]).slice();
|
|
357
|
+
return F.__wbindgen_free(r[0], r[1] * 1, 1), i;
|
|
127
358
|
}
|
|
128
|
-
constructor(e, t, n) {
|
|
129
|
-
let
|
|
130
|
-
if (
|
|
131
|
-
return this.__wbg_ptr =
|
|
359
|
+
constructor(e, t, n, r) {
|
|
360
|
+
let i = O(e, F.__wbindgen_malloc), a = P, o = F.docxarchive_new(i, a, !D(t), D(t) ? BigInt(0) : t, !D(n), D(n) ? BigInt(0) : n, !D(r), D(r) ? BigInt(0) : r);
|
|
361
|
+
if (o[2]) throw A(o[1]);
|
|
362
|
+
return this.__wbg_ptr = o[0] >>> 0, Xe.register(this, this.__wbg_ptr, this), this;
|
|
132
363
|
}
|
|
133
364
|
open_document_cursor(e, t) {
|
|
134
|
-
let n =
|
|
135
|
-
if (n[1]) throw
|
|
365
|
+
let n = F.docxarchive_open_document_cursor(this.__wbg_ptr, e, t);
|
|
366
|
+
if (n[1]) throw A(n[0]);
|
|
136
367
|
}
|
|
137
368
|
parse() {
|
|
138
|
-
let e =
|
|
139
|
-
if (e[3]) throw
|
|
140
|
-
var t =
|
|
141
|
-
return
|
|
369
|
+
let e = F.docxarchive_parse(this.__wbg_ptr);
|
|
370
|
+
if (e[3]) throw A(e[2]);
|
|
371
|
+
var t = S(e[0], e[1]).slice();
|
|
372
|
+
return F.__wbindgen_free(e[0], e[1] * 1, 1), t;
|
|
142
373
|
}
|
|
143
374
|
pull_document_chunk(e, t, n, r) {
|
|
144
|
-
let i =
|
|
145
|
-
if (i[3]) throw
|
|
146
|
-
var a =
|
|
147
|
-
return
|
|
375
|
+
let i = F.docxarchive_pull_document_chunk(this.__wbg_ptr, e, t, n, r);
|
|
376
|
+
if (i[3]) throw A(i[2]);
|
|
377
|
+
var a = S(i[0], i[1]).slice();
|
|
378
|
+
return F.__wbindgen_free(i[0], i[1] * 1, 1), a;
|
|
148
379
|
}
|
|
149
380
|
resource_usage() {
|
|
150
|
-
let e =
|
|
151
|
-
if (e[3]) throw
|
|
152
|
-
var t =
|
|
153
|
-
return
|
|
381
|
+
let e = F.docxarchive_resource_usage(this.__wbg_ptr);
|
|
382
|
+
if (e[3]) throw A(e[2]);
|
|
383
|
+
var t = S(e[0], e[1]).slice();
|
|
384
|
+
return F.__wbindgen_free(e[0], e[1] * 1, 1), t;
|
|
154
385
|
}
|
|
155
386
|
to_markdown() {
|
|
156
387
|
let e, t;
|
|
157
388
|
try {
|
|
158
|
-
let i =
|
|
389
|
+
let i = F.docxarchive_to_markdown(this.__wbg_ptr);
|
|
159
390
|
var n = i[0], r = i[1];
|
|
160
|
-
if (i[3]) throw n = 0, r = 0,
|
|
161
|
-
return e = n, t = r,
|
|
391
|
+
if (i[3]) throw n = 0, r = 0, A(i[2]);
|
|
392
|
+
return e = n, t = r, w(n, r);
|
|
162
393
|
} finally {
|
|
163
|
-
|
|
394
|
+
F.__wbindgen_free(e, t, 1);
|
|
164
395
|
}
|
|
165
396
|
}
|
|
166
397
|
};
|
|
167
|
-
Symbol.dispose && (
|
|
168
|
-
function
|
|
398
|
+
Symbol.dispose && (x.prototype[Symbol.dispose] = x.prototype.free);
|
|
399
|
+
function Ke(e, t, n) {
|
|
169
400
|
let r, i;
|
|
170
401
|
try {
|
|
171
|
-
let s =
|
|
402
|
+
let s = O(e, F.__wbindgen_malloc), c = P, l = F.docx_to_markdown(s, c, !D(t), D(t) ? BigInt(0) : t, !D(n), D(n) ? BigInt(0) : n);
|
|
172
403
|
var a = l[0], o = l[1];
|
|
173
|
-
if (l[3]) throw a = 0, o = 0,
|
|
174
|
-
return r = a, i = o,
|
|
404
|
+
if (l[3]) throw a = 0, o = 0, A(l[2]);
|
|
405
|
+
return r = a, i = o, w(a, o);
|
|
175
406
|
} finally {
|
|
176
|
-
|
|
407
|
+
F.__wbindgen_free(r, i, 1);
|
|
177
408
|
}
|
|
178
409
|
}
|
|
179
|
-
function
|
|
180
|
-
let i =
|
|
181
|
-
if (c[3]) throw
|
|
182
|
-
var l =
|
|
183
|
-
return
|
|
410
|
+
function qe(e, t, n, r) {
|
|
411
|
+
let i = O(e, F.__wbindgen_malloc), a = P, o = k(t, F.__wbindgen_malloc, F.__wbindgen_realloc), s = P, c = F.extract_image(i, a, o, s, !D(n), D(n) ? BigInt(0) : n, !D(r), D(r) ? BigInt(0) : r);
|
|
412
|
+
if (c[3]) throw A(c[2]);
|
|
413
|
+
var l = S(c[0], c[1]).slice();
|
|
414
|
+
return F.__wbindgen_free(c[0], c[1] * 1, 1), l;
|
|
184
415
|
}
|
|
185
|
-
function
|
|
186
|
-
let r =
|
|
187
|
-
if (a[3]) throw
|
|
188
|
-
var o =
|
|
189
|
-
return
|
|
416
|
+
function Je(e, t, n) {
|
|
417
|
+
let r = O(e, F.__wbindgen_malloc), i = P, a = F.parse_docx(r, i, !D(t), D(t) ? BigInt(0) : t, !D(n), D(n) ? BigInt(0) : n);
|
|
418
|
+
if (a[3]) throw A(a[2]);
|
|
419
|
+
var o = S(a[0], a[1]).slice();
|
|
420
|
+
return F.__wbindgen_free(a[0], a[1] * 1, 1), o;
|
|
190
421
|
}
|
|
191
|
-
function
|
|
422
|
+
function Ye() {
|
|
192
423
|
return {
|
|
193
424
|
__proto__: null,
|
|
194
425
|
"./docx_parser_bg.js": {
|
|
195
426
|
__proto__: null,
|
|
196
427
|
__wbg___wbindgen_throw_6b64449b9b9ed33c: function(e, t) {
|
|
197
|
-
throw Error(
|
|
428
|
+
throw Error(w(e, t));
|
|
198
429
|
},
|
|
199
430
|
__wbg_error_a6fa202b58aa1cd3: function(e, t) {
|
|
200
431
|
let n, r;
|
|
201
432
|
try {
|
|
202
|
-
n = e, r = t, console.error(
|
|
433
|
+
n = e, r = t, console.error(w(e, t));
|
|
203
434
|
} finally {
|
|
204
|
-
|
|
435
|
+
F.__wbindgen_free(n, r, 1);
|
|
205
436
|
}
|
|
206
437
|
},
|
|
207
438
|
__wbg_new_227d7c05414eb861: function() {
|
|
208
439
|
return /* @__PURE__ */ Error();
|
|
209
440
|
},
|
|
210
441
|
__wbg_stack_3b0d974bbf31e44f: function(e, t) {
|
|
211
|
-
let n = t.stack, r =
|
|
212
|
-
|
|
442
|
+
let n = t.stack, r = k(n, F.__wbindgen_malloc, F.__wbindgen_realloc), i = P;
|
|
443
|
+
Ze().setInt32(e + 4, i, !0), Ze().setInt32(e + 0, r, !0);
|
|
213
444
|
},
|
|
214
445
|
__wbindgen_cast_0000000000000001: function(e, t) {
|
|
215
|
-
return
|
|
446
|
+
return w(e, t);
|
|
216
447
|
},
|
|
217
448
|
__wbindgen_init_externref_table: function() {
|
|
218
|
-
let e =
|
|
449
|
+
let e = F.__wbindgen_externrefs, t = e.grow(4);
|
|
219
450
|
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
451
|
}
|
|
221
452
|
}
|
|
222
453
|
};
|
|
223
454
|
}
|
|
224
|
-
var
|
|
455
|
+
var Xe = typeof FinalizationRegistry > "u" ? {
|
|
225
456
|
register: () => {},
|
|
226
457
|
unregister: () => {}
|
|
227
|
-
} : new FinalizationRegistry((e) =>
|
|
228
|
-
function
|
|
229
|
-
return e >>>= 0,
|
|
458
|
+
} : new FinalizationRegistry((e) => F.__wbg_docxarchive_free(e >>> 0, 1));
|
|
459
|
+
function S(e, t) {
|
|
460
|
+
return e >>>= 0, E().subarray(e / 1, e / 1 + t);
|
|
230
461
|
}
|
|
231
|
-
var
|
|
232
|
-
function
|
|
233
|
-
return (
|
|
462
|
+
var C = null;
|
|
463
|
+
function Ze() {
|
|
464
|
+
return (C === null || C.buffer.detached === !0 || C.buffer.detached === void 0 && C.buffer !== F.memory.buffer) && (C = new DataView(F.memory.buffer)), C;
|
|
234
465
|
}
|
|
235
|
-
function
|
|
236
|
-
return e >>>= 0,
|
|
466
|
+
function w(e, t) {
|
|
467
|
+
return e >>>= 0, $e(e, t);
|
|
237
468
|
}
|
|
238
|
-
var
|
|
239
|
-
function
|
|
240
|
-
return (
|
|
469
|
+
var T = null;
|
|
470
|
+
function E() {
|
|
471
|
+
return (T === null || T.byteLength === 0) && (T = new Uint8Array(F.memory.buffer)), T;
|
|
241
472
|
}
|
|
242
|
-
function
|
|
473
|
+
function D(e) {
|
|
243
474
|
return e == null;
|
|
244
475
|
}
|
|
245
|
-
function
|
|
476
|
+
function O(e, t) {
|
|
246
477
|
let n = t(e.length * 1, 1) >>> 0;
|
|
247
|
-
return
|
|
478
|
+
return E().set(e, n / 1), P = e.length, n;
|
|
248
479
|
}
|
|
249
|
-
function
|
|
480
|
+
function k(e, t, n) {
|
|
250
481
|
if (n === void 0) {
|
|
251
|
-
let n =
|
|
252
|
-
return
|
|
482
|
+
let n = N.encode(e), r = t(n.length, 1) >>> 0;
|
|
483
|
+
return E().subarray(r, r + n.length).set(n), P = n.length, r;
|
|
253
484
|
}
|
|
254
|
-
let r = e.length, i = t(r, 1) >>> 0, a =
|
|
485
|
+
let r = e.length, i = t(r, 1) >>> 0, a = E(), o = 0;
|
|
255
486
|
for (; o < r; o++) {
|
|
256
487
|
let t = e.charCodeAt(o);
|
|
257
488
|
if (t > 127) break;
|
|
@@ -259,40 +490,40 @@ function E(e, t, n) {
|
|
|
259
490
|
}
|
|
260
491
|
if (o !== r) {
|
|
261
492
|
o !== 0 && (e = e.slice(o)), i = n(i, r, r = o + e.length * 3, 1) >>> 0;
|
|
262
|
-
let t =
|
|
493
|
+
let t = E().subarray(i + o, i + r), a = N.encodeInto(e, t);
|
|
263
494
|
o += a.written, i = n(i, r, o, 1) >>> 0;
|
|
264
495
|
}
|
|
265
|
-
return
|
|
496
|
+
return P = o, i;
|
|
266
497
|
}
|
|
267
|
-
function
|
|
268
|
-
let t =
|
|
269
|
-
return
|
|
498
|
+
function A(e) {
|
|
499
|
+
let t = F.__wbindgen_externrefs.get(e);
|
|
500
|
+
return F.__externref_table_dealloc(e), t;
|
|
270
501
|
}
|
|
271
|
-
var
|
|
502
|
+
var j = new TextDecoder("utf-8", {
|
|
272
503
|
ignoreBOM: !0,
|
|
273
504
|
fatal: !0
|
|
274
505
|
});
|
|
275
|
-
|
|
276
|
-
var
|
|
277
|
-
function
|
|
278
|
-
return
|
|
506
|
+
j.decode();
|
|
507
|
+
var Qe = 2146435072, M = 0;
|
|
508
|
+
function $e(e, t) {
|
|
509
|
+
return M += t, M >= Qe && (j = new TextDecoder("utf-8", {
|
|
279
510
|
ignoreBOM: !0,
|
|
280
511
|
fatal: !0
|
|
281
|
-
}),
|
|
512
|
+
}), j.decode(), M = t), j.decode(E().subarray(e, e + t));
|
|
282
513
|
}
|
|
283
|
-
var
|
|
284
|
-
"encodeInto" in
|
|
285
|
-
let n =
|
|
514
|
+
var N = new TextEncoder();
|
|
515
|
+
"encodeInto" in N || (N.encodeInto = function(e, t) {
|
|
516
|
+
let n = N.encode(e);
|
|
286
517
|
return t.set(n), {
|
|
287
518
|
read: e.length,
|
|
288
519
|
written: n.length
|
|
289
520
|
};
|
|
290
521
|
});
|
|
291
|
-
var
|
|
292
|
-
function
|
|
293
|
-
return
|
|
522
|
+
var P = 0, F;
|
|
523
|
+
function et(e, t) {
|
|
524
|
+
return F = e.exports, C = null, T = null, F.__wbindgen_start(), F;
|
|
294
525
|
}
|
|
295
|
-
async function
|
|
526
|
+
async function tt(e, t) {
|
|
296
527
|
if (typeof Response == "function" && e instanceof Response) {
|
|
297
528
|
if (typeof WebAssembly.instantiateStreaming == "function") try {
|
|
298
529
|
return await WebAssembly.instantiateStreaming(e, t);
|
|
@@ -318,76 +549,139 @@ async function Fe(e, t) {
|
|
|
318
549
|
return !1;
|
|
319
550
|
}
|
|
320
551
|
}
|
|
321
|
-
function
|
|
322
|
-
if (
|
|
552
|
+
function nt(e) {
|
|
553
|
+
if (F !== void 0) return F;
|
|
323
554
|
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 =
|
|
325
|
-
return e instanceof WebAssembly.Module || (e = new WebAssembly.Module(e)),
|
|
555
|
+
let t = Ye();
|
|
556
|
+
return e instanceof WebAssembly.Module || (e = new WebAssembly.Module(e)), et(new WebAssembly.Instance(e, t), e);
|
|
326
557
|
}
|
|
327
|
-
async function
|
|
328
|
-
if (
|
|
558
|
+
async function rt(e) {
|
|
559
|
+
if (F !== void 0) return F;
|
|
329
560
|
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 =
|
|
561
|
+
let t = Ye();
|
|
331
562
|
(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
|
|
333
|
-
return
|
|
563
|
+
let { instance: n, module: r } = await tt(await e, t);
|
|
564
|
+
return et(n, r);
|
|
334
565
|
}
|
|
335
|
-
async function
|
|
336
|
-
return
|
|
566
|
+
async function it(e) {
|
|
567
|
+
return F = void 0, C = null, T = null, rt(e);
|
|
337
568
|
}
|
|
338
569
|
//#endregion
|
|
339
|
-
//#region packages/
|
|
340
|
-
var
|
|
341
|
-
function
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
async function He(e, n) {
|
|
350
|
-
let r = m(n ?? {}), i = new o({
|
|
351
|
-
enabled: r.debug || r.onResourceMetrics !== void 0,
|
|
570
|
+
//#region packages/docx/src/internal/node-acquisition.ts
|
|
571
|
+
var at, I;
|
|
572
|
+
function ot(e) {
|
|
573
|
+
if (!I) at = e, I = new Ce(Ge, e);
|
|
574
|
+
else if (at !== e) throw Error("DOCX runtime was already initialized with another WebAssembly.Module");
|
|
575
|
+
return I;
|
|
576
|
+
}
|
|
577
|
+
async function st(e, t, r, i) {
|
|
578
|
+
let o = n(r), s = new u({
|
|
579
|
+
enabled: o.debug || o.onResourceMetrics !== void 0,
|
|
352
580
|
format: "docx",
|
|
353
581
|
mode: "node",
|
|
354
582
|
scope: "session",
|
|
355
|
-
policy:
|
|
356
|
-
onMetrics:
|
|
357
|
-
emitToConsole:
|
|
583
|
+
policy: o.policy,
|
|
584
|
+
onMetrics: o.onResourceMetrics,
|
|
585
|
+
emitToConsole: o.debug
|
|
358
586
|
});
|
|
359
|
-
|
|
360
|
-
let
|
|
587
|
+
s.setSourceBytes(e.byteLength);
|
|
588
|
+
let c, l, d;
|
|
361
589
|
try {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
590
|
+
lt(r.signal);
|
|
591
|
+
let [n, u, ee] = a(o.policy), f = x;
|
|
592
|
+
c = await ot(t).open(() => new f(e, n, u, ee), {
|
|
593
|
+
signal: r.signal,
|
|
594
|
+
abortError: ut,
|
|
595
|
+
disposeOnAbort: (e) => e.free()
|
|
596
|
+
}), lt(r.signal);
|
|
597
|
+
let p = c.proxy;
|
|
598
|
+
s.checkpoint("container ready"), l = new We(() => p);
|
|
599
|
+
let m = {
|
|
367
600
|
sessionId: 1,
|
|
368
601
|
operationId: 1,
|
|
369
602
|
generation: 1
|
|
370
603
|
};
|
|
371
|
-
l.open(
|
|
372
|
-
let
|
|
373
|
-
signal:
|
|
604
|
+
l.open(m), d = new v((e, t) => l?.dispatch(e, t), () => void 0);
|
|
605
|
+
let h, te = await i(d, m, {
|
|
606
|
+
signal: r.signal,
|
|
374
607
|
onUsage: (e) => {
|
|
375
|
-
|
|
608
|
+
h = e, s.observeUsage(e);
|
|
376
609
|
}
|
|
377
610
|
});
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
611
|
+
return h ??= ct(p.document_cursor_resource_usage()), s.observeUsage(h), s.checkpoint("model streamed"), await l.reset(), d.terminate(), {
|
|
612
|
+
archive: p,
|
|
613
|
+
result: te,
|
|
614
|
+
usage: h,
|
|
615
|
+
metrics: s,
|
|
616
|
+
closeArchive: () => c?.close((e) => e.free())
|
|
617
|
+
};
|
|
381
618
|
} catch (e) {
|
|
382
|
-
await l?.reset().catch(() => void 0),
|
|
619
|
+
await l?.reset().catch(() => void 0), d?.terminate();
|
|
383
620
|
try {
|
|
384
|
-
c?.free();
|
|
621
|
+
c?.close((e) => e.free());
|
|
385
622
|
} catch {}
|
|
386
|
-
let
|
|
387
|
-
throw
|
|
623
|
+
let t = f(e) ?? e;
|
|
624
|
+
throw s.fail(t), t;
|
|
388
625
|
}
|
|
389
626
|
}
|
|
390
|
-
|
|
627
|
+
function ct(e) {
|
|
628
|
+
try {
|
|
629
|
+
return g(e);
|
|
630
|
+
} catch {
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
function lt(e) {
|
|
635
|
+
if (e?.aborted) throw ut();
|
|
636
|
+
}
|
|
637
|
+
function ut() {
|
|
638
|
+
let e = /* @__PURE__ */ Error("DOCX document session was aborted");
|
|
639
|
+
return e.name = "AbortError", e;
|
|
640
|
+
}
|
|
641
|
+
//#endregion
|
|
642
|
+
//#region packages/node/src/docx.ts
|
|
643
|
+
var dt = y(() => Ie(import.meta.url, "docx_parser_bg.wasm", "@silurus/ooxml-docx/wasm-binary"));
|
|
644
|
+
async function ft(e, t) {
|
|
645
|
+
if (!t?.factory) throw TypeError("openDocxDocument requires a canvas factory");
|
|
646
|
+
let n = await st(gt(e), dt(), t, (e, t, n) => ce(e, t, n));
|
|
647
|
+
try {
|
|
648
|
+
L(t.signal);
|
|
649
|
+
let e = t.factory.createCanvas(1, 1), r = se(n.result, { measureContext: e.getContext("2d") }), i = ht(t.currentDate), a = ie(n.result, r, i).layoutVariants.defaultLayout, o = new mt(n.closeArchive, n.archive, n.result, r, a, t.factory, i, n.usage, n.metrics, t.signal);
|
|
650
|
+
return n.metrics.observeUsage(o.resourceUsage), n.metrics.checkpoint("pagination ready"), o;
|
|
651
|
+
} catch (e) {
|
|
652
|
+
try {
|
|
653
|
+
n.closeArchive();
|
|
654
|
+
} catch {}
|
|
655
|
+
let t = f(e) ?? e;
|
|
656
|
+
throw n.metrics.fail(t), t;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
async function pt(e, t = {}) {
|
|
660
|
+
return _(async () => {
|
|
661
|
+
let n = await st(gt(e), dt(), t, (e, t, n) => oe(e, t, n)), r = !1;
|
|
662
|
+
return {
|
|
663
|
+
acquired: n,
|
|
664
|
+
markSucceeded: () => {
|
|
665
|
+
r = !0;
|
|
666
|
+
},
|
|
667
|
+
close: async () => {
|
|
668
|
+
try {
|
|
669
|
+
n.closeArchive(), r && n.metrics.succeed({ documents: 1 });
|
|
670
|
+
} catch (e) {
|
|
671
|
+
throw n.metrics.fail(e), e;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
};
|
|
675
|
+
}, async ({ acquired: e, markSucceeded: t }) => {
|
|
676
|
+
try {
|
|
677
|
+
let n = le(e.result);
|
|
678
|
+
return e.metrics.checkpoint("document materialized", e.usage), t(), n;
|
|
679
|
+
} catch (t) {
|
|
680
|
+
throw e.metrics.fail(t), t;
|
|
681
|
+
}
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
var mt = class {
|
|
391
685
|
pageCount;
|
|
392
686
|
sizes;
|
|
393
687
|
lastResourceUsage;
|
|
@@ -399,13 +693,13 @@ var Ue = class {
|
|
|
399
693
|
resourceFailure = null;
|
|
400
694
|
fetchImage = async (e, t) => {
|
|
401
695
|
let n = this.archive.extract_image(e);
|
|
402
|
-
return new Blob([
|
|
696
|
+
return new Blob([n], { type: t });
|
|
403
697
|
};
|
|
404
|
-
constructor(e, t, n, r, i, a, o, s, c) {
|
|
405
|
-
this.
|
|
406
|
-
source:
|
|
407
|
-
services:
|
|
408
|
-
}, this.pageCount =
|
|
698
|
+
constructor(e, t, n, r, i, a, o, s, c, l) {
|
|
699
|
+
this.closeArchive = e, this.archive = t, this.factory = a, this.defaultCurrentDateMs = o, this.metrics = c, this.signal = l, this.state = {
|
|
700
|
+
source: n,
|
|
701
|
+
services: r
|
|
702
|
+
}, this.pageCount = i.pages.length, this.lastResourceUsage = s, this.sizes = Object.freeze(i.pages.map((e) => Object.freeze({
|
|
409
703
|
widthPt: e.geometry.widthPt,
|
|
410
704
|
heightPt: e.geometry.heightPt
|
|
411
705
|
})));
|
|
@@ -415,7 +709,7 @@ var Ue = class {
|
|
|
415
709
|
}
|
|
416
710
|
refreshResourceUsage() {
|
|
417
711
|
try {
|
|
418
|
-
this.lastResourceUsage =
|
|
712
|
+
this.lastResourceUsage = g(this.archive.resource_usage()), this.metrics.observeUsage(this.lastResourceUsage);
|
|
419
713
|
} catch {}
|
|
420
714
|
return this.lastResourceUsage;
|
|
421
715
|
}
|
|
@@ -427,27 +721,27 @@ var Ue = class {
|
|
|
427
721
|
[Symbol.asyncIterator]() {
|
|
428
722
|
return this.pages();
|
|
429
723
|
}
|
|
430
|
-
renderPage(e,
|
|
724
|
+
renderPage(e, t = {}) {
|
|
431
725
|
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
|
-
|
|
433
|
-
let
|
|
434
|
-
return await
|
|
435
|
-
...
|
|
726
|
+
L(this.signal);
|
|
727
|
+
let n = this.requireState(), r = this.factory.createCanvas(1, 1);
|
|
728
|
+
return await we(this.factory, () => ae(n.source, r, e, {
|
|
729
|
+
...t,
|
|
436
730
|
currentDate: this.defaultCurrentDateMs,
|
|
437
731
|
defaultCurrentDateMs: this.defaultCurrentDateMs,
|
|
438
|
-
layoutServices:
|
|
732
|
+
layoutServices: n.services,
|
|
439
733
|
fetchImage: this.fetchImage
|
|
440
|
-
})),
|
|
734
|
+
})), L(this.signal), r;
|
|
441
735
|
}).catch((e) => {
|
|
442
|
-
let
|
|
443
|
-
throw
|
|
736
|
+
let t = f(e) ?? e;
|
|
737
|
+
throw t instanceof p && (this.resourceFailure ??= t), this.metrics.fail(t), t;
|
|
444
738
|
}));
|
|
445
739
|
}
|
|
446
740
|
async *pages(e = {}) {
|
|
447
741
|
if (this.closed) throw Error("DOCX document session is closed");
|
|
448
742
|
if (this.pagesStarted) throw Error("DOCX page stream is one-pass and was already consumed");
|
|
449
743
|
this.pagesStarted = !0;
|
|
450
|
-
let
|
|
744
|
+
let t;
|
|
451
745
|
try {
|
|
452
746
|
for (let t = 0; t < this.pageCount; t += 1) {
|
|
453
747
|
let n = await this.renderPage(t, e), r = this.pageSize(t);
|
|
@@ -458,12 +752,12 @@ var Ue = class {
|
|
|
458
752
|
};
|
|
459
753
|
}
|
|
460
754
|
} catch (e) {
|
|
461
|
-
throw
|
|
755
|
+
throw t = f(e) ?? e, t;
|
|
462
756
|
} finally {
|
|
463
757
|
try {
|
|
464
758
|
await this.close();
|
|
465
759
|
} catch (e) {
|
|
466
|
-
if (
|
|
760
|
+
if (t === void 0) throw e;
|
|
467
761
|
}
|
|
468
762
|
}
|
|
469
763
|
}
|
|
@@ -475,12 +769,12 @@ var Ue = class {
|
|
|
475
769
|
return this.renderTail = t.then(() => void 0, () => void 0), t;
|
|
476
770
|
}
|
|
477
771
|
async release() {
|
|
478
|
-
await this.renderTail,
|
|
772
|
+
await this.renderTail, m(this.fetchImage), r(this.fetchImage), this.state = null;
|
|
479
773
|
try {
|
|
480
|
-
this.
|
|
774
|
+
this.closeArchive();
|
|
481
775
|
} catch (e) {
|
|
482
|
-
let
|
|
483
|
-
throw this.metrics.fail(
|
|
776
|
+
let t = f(e) ?? e;
|
|
777
|
+
throw this.metrics.fail(t), t;
|
|
484
778
|
}
|
|
485
779
|
this.metrics.checkpoint("document session closed", this.lastResourceUsage), this.metrics.succeed({ pages: this.pageCount });
|
|
486
780
|
}
|
|
@@ -489,215 +783,194 @@ var Ue = class {
|
|
|
489
783
|
return this.state;
|
|
490
784
|
}
|
|
491
785
|
};
|
|
492
|
-
function
|
|
786
|
+
function ht(e) {
|
|
493
787
|
let t = e instanceof Date ? e.getTime() : e ?? Date.now();
|
|
494
788
|
if (!Number.isFinite(t)) throw RangeError("currentDate must resolve to finite epoch milliseconds");
|
|
495
789
|
return t;
|
|
496
790
|
}
|
|
497
|
-
function
|
|
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) {
|
|
791
|
+
function gt(e) {
|
|
506
792
|
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
507
793
|
}
|
|
508
|
-
function
|
|
794
|
+
function L(e) {
|
|
509
795
|
if (!e?.aborted) return;
|
|
510
796
|
let t = /* @__PURE__ */ Error("DOCX document session was aborted");
|
|
511
797
|
throw t.name = "AbortError", t;
|
|
512
798
|
}
|
|
513
799
|
//#endregion
|
|
514
800
|
//#region packages/xlsx/src/wasm/xlsx_parser.js
|
|
515
|
-
var
|
|
516
|
-
XlsxArchive: () =>
|
|
517
|
-
default: () =>
|
|
518
|
-
extract_image: () =>
|
|
519
|
-
initSync: () =>
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
}), P = class {
|
|
801
|
+
var _t = /* @__PURE__ */ e({
|
|
802
|
+
XlsxArchive: () => R,
|
|
803
|
+
default: () => kt,
|
|
804
|
+
extract_image: () => vt,
|
|
805
|
+
initSync: () => Ot,
|
|
806
|
+
parse_xlsx: () => yt,
|
|
807
|
+
reinit: () => At,
|
|
808
|
+
xlsx_to_markdown: () => bt
|
|
809
|
+
}), R = class {
|
|
525
810
|
__destroy_into_raw() {
|
|
526
811
|
let e = this.__wbg_ptr;
|
|
527
|
-
return this.__wbg_ptr = 0,
|
|
812
|
+
return this.__wbg_ptr = 0, St.unregister(this), e;
|
|
528
813
|
}
|
|
529
814
|
free() {
|
|
530
815
|
let e = this.__destroy_into_raw();
|
|
531
|
-
|
|
816
|
+
Q.__wbg_xlsxarchive_free(e, 0);
|
|
532
817
|
}
|
|
533
818
|
acknowledge_sheet_cursor_terminal() {
|
|
534
|
-
let e =
|
|
535
|
-
if (e[1]) throw
|
|
819
|
+
let e = Q.xlsxarchive_acknowledge_sheet_cursor_terminal(this.__wbg_ptr);
|
|
820
|
+
if (e[1]) throw q(e[0]);
|
|
536
821
|
}
|
|
537
822
|
assert_healthy() {
|
|
538
|
-
let e =
|
|
539
|
-
if (e[1]) throw
|
|
823
|
+
let e = Q.xlsxarchive_assert_healthy(this.__wbg_ptr);
|
|
824
|
+
if (e[1]) throw q(e[0]);
|
|
540
825
|
}
|
|
541
826
|
cancel_sheet_cursor() {
|
|
542
|
-
|
|
827
|
+
Q.xlsxarchive_cancel_sheet_cursor(this.__wbg_ptr);
|
|
543
828
|
}
|
|
544
829
|
close_sheet_cursor() {
|
|
545
|
-
|
|
830
|
+
Q.xlsxarchive_close_sheet_cursor(this.__wbg_ptr);
|
|
546
831
|
}
|
|
547
832
|
extract_image(e) {
|
|
548
|
-
let t =
|
|
549
|
-
if (r[3]) throw
|
|
550
|
-
var i =
|
|
551
|
-
return
|
|
833
|
+
let t = K(e, Q.__wbindgen_malloc, Q.__wbindgen_realloc), n = Z, r = Q.xlsxarchive_extract_image(this.__wbg_ptr, t, n);
|
|
834
|
+
if (r[3]) throw q(r[2]);
|
|
835
|
+
var i = z(r[0], r[1]).slice();
|
|
836
|
+
return Q.__wbindgen_free(r[0], r[1] * 1, 1), i;
|
|
552
837
|
}
|
|
553
|
-
constructor(e, t, n) {
|
|
554
|
-
let
|
|
555
|
-
if (
|
|
556
|
-
return this.__wbg_ptr =
|
|
838
|
+
constructor(e, t, n, r) {
|
|
839
|
+
let i = G(e, Q.__wbindgen_malloc), a = Z, o = Q.xlsxarchive_new(i, a, !W(t), W(t) ? BigInt(0) : t, !W(n), W(n) ? BigInt(0) : n, !W(r), W(r) ? BigInt(0) : r);
|
|
840
|
+
if (o[2]) throw q(o[1]);
|
|
841
|
+
return this.__wbg_ptr = o[0] >>> 0, St.register(this, this.__wbg_ptr, this), this;
|
|
557
842
|
}
|
|
558
843
|
open_sheet_cursor(e, t) {
|
|
559
|
-
let n =
|
|
560
|
-
if (i[1]) throw
|
|
844
|
+
let n = K(t, Q.__wbindgen_malloc, Q.__wbindgen_realloc), r = Z, i = Q.xlsxarchive_open_sheet_cursor(this.__wbg_ptr, e, n, r);
|
|
845
|
+
if (i[1]) throw q(i[0]);
|
|
561
846
|
}
|
|
562
847
|
parse() {
|
|
563
|
-
let e =
|
|
564
|
-
if (e[3]) throw
|
|
565
|
-
var t =
|
|
566
|
-
return
|
|
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;
|
|
848
|
+
let e = Q.xlsxarchive_parse(this.__wbg_ptr);
|
|
849
|
+
if (e[3]) throw q(e[2]);
|
|
850
|
+
var t = z(e[0], e[1]).slice();
|
|
851
|
+
return Q.__wbindgen_free(e[0], e[1] * 1, 1), t;
|
|
573
852
|
}
|
|
574
853
|
pull_sheet_cursor(e) {
|
|
575
|
-
let t =
|
|
576
|
-
if (t[3]) throw
|
|
577
|
-
var n =
|
|
578
|
-
return
|
|
854
|
+
let t = Q.xlsxarchive_pull_sheet_cursor(this.__wbg_ptr, e);
|
|
855
|
+
if (t[3]) throw q(t[2]);
|
|
856
|
+
var n = z(t[0], t[1]).slice();
|
|
857
|
+
return Q.__wbindgen_free(t[0], t[1] * 1, 1), n;
|
|
579
858
|
}
|
|
580
859
|
resource_usage() {
|
|
581
|
-
let e =
|
|
582
|
-
if (e[3]) throw
|
|
583
|
-
var t =
|
|
584
|
-
return
|
|
860
|
+
let e = Q.xlsxarchive_resource_usage(this.__wbg_ptr);
|
|
861
|
+
if (e[3]) throw q(e[2]);
|
|
862
|
+
var t = z(e[0], e[1]).slice();
|
|
863
|
+
return Q.__wbindgen_free(e[0], e[1] * 1, 1), t;
|
|
585
864
|
}
|
|
586
865
|
sheet_cursor_pull_finished() {
|
|
587
|
-
return
|
|
866
|
+
return Q.xlsxarchive_sheet_cursor_pull_finished(this.__wbg_ptr) !== 0;
|
|
588
867
|
}
|
|
589
868
|
sheet_cursor_resource_usage() {
|
|
590
|
-
let e =
|
|
591
|
-
if (e[3]) throw
|
|
592
|
-
var t =
|
|
593
|
-
return
|
|
869
|
+
let e = Q.xlsxarchive_sheet_cursor_resource_usage(this.__wbg_ptr);
|
|
870
|
+
if (e[3]) throw q(e[2]);
|
|
871
|
+
var t = z(e[0], e[1]).slice();
|
|
872
|
+
return Q.__wbindgen_free(e[0], e[1] * 1, 1), t;
|
|
594
873
|
}
|
|
595
874
|
to_markdown() {
|
|
596
875
|
let e, t;
|
|
597
876
|
try {
|
|
598
|
-
let i =
|
|
877
|
+
let i = Q.xlsxarchive_to_markdown(this.__wbg_ptr);
|
|
599
878
|
var n = i[0], r = i[1];
|
|
600
|
-
if (i[3]) throw n = 0, r = 0,
|
|
601
|
-
return e = n, t = r,
|
|
879
|
+
if (i[3]) throw n = 0, r = 0, q(i[2]);
|
|
880
|
+
return e = n, t = r, V(n, r);
|
|
602
881
|
} finally {
|
|
603
|
-
|
|
882
|
+
Q.__wbindgen_free(e, t, 1);
|
|
604
883
|
}
|
|
605
884
|
}
|
|
606
885
|
};
|
|
607
|
-
Symbol.dispose && (
|
|
608
|
-
function
|
|
609
|
-
let i =
|
|
610
|
-
if (c[3]) throw
|
|
611
|
-
var l =
|
|
612
|
-
return
|
|
613
|
-
}
|
|
614
|
-
function
|
|
615
|
-
let
|
|
616
|
-
if (
|
|
617
|
-
var
|
|
618
|
-
return
|
|
619
|
-
}
|
|
620
|
-
function
|
|
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) {
|
|
886
|
+
Symbol.dispose && (R.prototype[Symbol.dispose] = R.prototype.free);
|
|
887
|
+
function vt(e, t, n, r) {
|
|
888
|
+
let i = G(e, Q.__wbindgen_malloc), a = Z, o = K(t, Q.__wbindgen_malloc, Q.__wbindgen_realloc), s = Z, c = Q.extract_image(i, a, o, s, !W(n), W(n) ? BigInt(0) : n, !W(r), W(r) ? BigInt(0) : r);
|
|
889
|
+
if (c[3]) throw q(c[2]);
|
|
890
|
+
var l = z(c[0], c[1]).slice();
|
|
891
|
+
return Q.__wbindgen_free(c[0], c[1] * 1, 1), l;
|
|
892
|
+
}
|
|
893
|
+
function yt(e, t, n) {
|
|
894
|
+
let r = G(e, Q.__wbindgen_malloc), i = Z, a = Q.parse_xlsx(r, i, !W(t), W(t) ? BigInt(0) : t, !W(n), W(n) ? BigInt(0) : n);
|
|
895
|
+
if (a[3]) throw q(a[2]);
|
|
896
|
+
var o = z(a[0], a[1]).slice();
|
|
897
|
+
return Q.__wbindgen_free(a[0], a[1] * 1, 1), o;
|
|
898
|
+
}
|
|
899
|
+
function bt(e, t, n) {
|
|
627
900
|
let r, i;
|
|
628
901
|
try {
|
|
629
|
-
let s =
|
|
902
|
+
let s = G(e, Q.__wbindgen_malloc), c = Z, l = Q.xlsx_to_markdown(s, c, !W(t), W(t) ? BigInt(0) : t, !W(n), W(n) ? BigInt(0) : n);
|
|
630
903
|
var a = l[0], o = l[1];
|
|
631
|
-
if (l[3]) throw a = 0, o = 0,
|
|
632
|
-
return r = a, i = o,
|
|
904
|
+
if (l[3]) throw a = 0, o = 0, q(l[2]);
|
|
905
|
+
return r = a, i = o, V(a, o);
|
|
633
906
|
} finally {
|
|
634
|
-
|
|
907
|
+
Q.__wbindgen_free(r, i, 1);
|
|
635
908
|
}
|
|
636
909
|
}
|
|
637
|
-
function
|
|
910
|
+
function xt() {
|
|
638
911
|
return {
|
|
639
912
|
__proto__: null,
|
|
640
913
|
"./xlsx_parser_bg.js": {
|
|
641
914
|
__proto__: null,
|
|
642
915
|
__wbg___wbindgen_throw_6b64449b9b9ed33c: function(e, t) {
|
|
643
|
-
throw Error(
|
|
916
|
+
throw Error(V(e, t));
|
|
644
917
|
},
|
|
645
918
|
__wbg_error_a6fa202b58aa1cd3: function(e, t) {
|
|
646
919
|
let n, r;
|
|
647
920
|
try {
|
|
648
|
-
n = e, r = t, console.error(
|
|
921
|
+
n = e, r = t, console.error(V(e, t));
|
|
649
922
|
} finally {
|
|
650
|
-
|
|
923
|
+
Q.__wbindgen_free(n, r, 1);
|
|
651
924
|
}
|
|
652
925
|
},
|
|
653
926
|
__wbg_new_227d7c05414eb861: function() {
|
|
654
927
|
return /* @__PURE__ */ Error();
|
|
655
928
|
},
|
|
656
929
|
__wbg_stack_3b0d974bbf31e44f: function(e, t) {
|
|
657
|
-
let n = t.stack, r =
|
|
658
|
-
|
|
930
|
+
let n = t.stack, r = K(n, Q.__wbindgen_malloc, Q.__wbindgen_realloc), i = Z;
|
|
931
|
+
Ct().setInt32(e + 4, i, !0), Ct().setInt32(e + 0, r, !0);
|
|
659
932
|
},
|
|
660
933
|
__wbindgen_cast_0000000000000001: function(e, t) {
|
|
661
|
-
return
|
|
934
|
+
return V(e, t);
|
|
662
935
|
},
|
|
663
936
|
__wbindgen_init_externref_table: function() {
|
|
664
|
-
let e =
|
|
937
|
+
let e = Q.__wbindgen_externrefs, t = e.grow(4);
|
|
665
938
|
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
939
|
}
|
|
667
940
|
}
|
|
668
941
|
};
|
|
669
942
|
}
|
|
670
|
-
var
|
|
943
|
+
var St = typeof FinalizationRegistry > "u" ? {
|
|
671
944
|
register: () => {},
|
|
672
945
|
unregister: () => {}
|
|
673
|
-
} : new FinalizationRegistry((e) =>
|
|
674
|
-
function
|
|
675
|
-
return e >>>= 0,
|
|
946
|
+
} : new FinalizationRegistry((e) => Q.__wbg_xlsxarchive_free(e >>> 0, 1));
|
|
947
|
+
function z(e, t) {
|
|
948
|
+
return e >>>= 0, U().subarray(e / 1, e / 1 + t);
|
|
676
949
|
}
|
|
677
|
-
var
|
|
678
|
-
function
|
|
679
|
-
return (
|
|
950
|
+
var B = null;
|
|
951
|
+
function Ct() {
|
|
952
|
+
return (B === null || B.buffer.detached === !0 || B.buffer.detached === void 0 && B.buffer !== Q.memory.buffer) && (B = new DataView(Q.memory.buffer)), B;
|
|
680
953
|
}
|
|
681
|
-
function
|
|
682
|
-
return e >>>= 0,
|
|
954
|
+
function V(e, t) {
|
|
955
|
+
return e >>>= 0, Tt(e, t);
|
|
683
956
|
}
|
|
684
|
-
var
|
|
685
|
-
function
|
|
686
|
-
return (
|
|
957
|
+
var H = null;
|
|
958
|
+
function U() {
|
|
959
|
+
return (H === null || H.byteLength === 0) && (H = new Uint8Array(Q.memory.buffer)), H;
|
|
687
960
|
}
|
|
688
|
-
function
|
|
961
|
+
function W(e) {
|
|
689
962
|
return e == null;
|
|
690
963
|
}
|
|
691
|
-
function
|
|
964
|
+
function G(e, t) {
|
|
692
965
|
let n = t(e.length * 1, 1) >>> 0;
|
|
693
|
-
return
|
|
966
|
+
return U().set(e, n / 1), Z = e.length, n;
|
|
694
967
|
}
|
|
695
|
-
function
|
|
968
|
+
function K(e, t, n) {
|
|
696
969
|
if (n === void 0) {
|
|
697
|
-
let n =
|
|
698
|
-
return
|
|
970
|
+
let n = X.encode(e), r = t(n.length, 1) >>> 0;
|
|
971
|
+
return U().subarray(r, r + n.length).set(n), Z = n.length, r;
|
|
699
972
|
}
|
|
700
|
-
let r = e.length, i = t(r, 1) >>> 0, a =
|
|
973
|
+
let r = e.length, i = t(r, 1) >>> 0, a = U(), o = 0;
|
|
701
974
|
for (; o < r; o++) {
|
|
702
975
|
let t = e.charCodeAt(o);
|
|
703
976
|
if (t > 127) break;
|
|
@@ -705,40 +978,40 @@ function H(e, t, n) {
|
|
|
705
978
|
}
|
|
706
979
|
if (o !== r) {
|
|
707
980
|
o !== 0 && (e = e.slice(o)), i = n(i, r, r = o + e.length * 3, 1) >>> 0;
|
|
708
|
-
let t =
|
|
981
|
+
let t = U().subarray(i + o, i + r), a = X.encodeInto(e, t);
|
|
709
982
|
o += a.written, i = n(i, r, o, 1) >>> 0;
|
|
710
983
|
}
|
|
711
|
-
return
|
|
984
|
+
return Z = o, i;
|
|
712
985
|
}
|
|
713
|
-
function
|
|
714
|
-
let t =
|
|
715
|
-
return
|
|
986
|
+
function q(e) {
|
|
987
|
+
let t = Q.__wbindgen_externrefs.get(e);
|
|
988
|
+
return Q.__externref_table_dealloc(e), t;
|
|
716
989
|
}
|
|
717
|
-
var
|
|
990
|
+
var J = new TextDecoder("utf-8", {
|
|
718
991
|
ignoreBOM: !0,
|
|
719
992
|
fatal: !0
|
|
720
993
|
});
|
|
721
|
-
|
|
722
|
-
var
|
|
723
|
-
function
|
|
724
|
-
return
|
|
994
|
+
J.decode();
|
|
995
|
+
var wt = 2146435072, Y = 0;
|
|
996
|
+
function Tt(e, t) {
|
|
997
|
+
return Y += t, Y >= wt && (J = new TextDecoder("utf-8", {
|
|
725
998
|
ignoreBOM: !0,
|
|
726
999
|
fatal: !0
|
|
727
|
-
}),
|
|
1000
|
+
}), J.decode(), Y = t), J.decode(U().subarray(e, e + t));
|
|
728
1001
|
}
|
|
729
|
-
var
|
|
730
|
-
"encodeInto" in
|
|
731
|
-
let n =
|
|
1002
|
+
var X = new TextEncoder();
|
|
1003
|
+
"encodeInto" in X || (X.encodeInto = function(e, t) {
|
|
1004
|
+
let n = X.encode(e);
|
|
732
1005
|
return t.set(n), {
|
|
733
1006
|
read: e.length,
|
|
734
1007
|
written: n.length
|
|
735
1008
|
};
|
|
736
1009
|
});
|
|
737
|
-
var
|
|
738
|
-
function
|
|
739
|
-
return
|
|
1010
|
+
var Z = 0, Q;
|
|
1011
|
+
function Et(e, t) {
|
|
1012
|
+
return Q = e.exports, B = null, H = null, Q.__wbindgen_start(), Q;
|
|
740
1013
|
}
|
|
741
|
-
async function
|
|
1014
|
+
async function Dt(e, t) {
|
|
742
1015
|
if (typeof Response == "function" && e instanceof Response) {
|
|
743
1016
|
if (typeof WebAssembly.instantiateStreaming == "function") try {
|
|
744
1017
|
return await WebAssembly.instantiateStreaming(e, t);
|
|
@@ -764,86 +1037,96 @@ async function rt(e, t) {
|
|
|
764
1037
|
return !1;
|
|
765
1038
|
}
|
|
766
1039
|
}
|
|
767
|
-
function
|
|
768
|
-
if (
|
|
1040
|
+
function Ot(e) {
|
|
1041
|
+
if (Q !== void 0) return Q;
|
|
769
1042
|
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 =
|
|
771
|
-
return e instanceof WebAssembly.Module || (e = new WebAssembly.Module(e)),
|
|
1043
|
+
let t = xt();
|
|
1044
|
+
return e instanceof WebAssembly.Module || (e = new WebAssembly.Module(e)), Et(new WebAssembly.Instance(e, t), e);
|
|
772
1045
|
}
|
|
773
|
-
async function
|
|
774
|
-
if (
|
|
1046
|
+
async function kt(e) {
|
|
1047
|
+
if (Q !== void 0) return Q;
|
|
775
1048
|
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 =
|
|
1049
|
+
let t = xt();
|
|
777
1050
|
(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
|
|
779
|
-
return
|
|
1051
|
+
let { instance: n, module: r } = await Dt(await e, t);
|
|
1052
|
+
return Et(n, r);
|
|
780
1053
|
}
|
|
781
|
-
async function
|
|
782
|
-
return
|
|
1054
|
+
async function At(e) {
|
|
1055
|
+
return Q = void 0, B = null, H = null, kt(e);
|
|
783
1056
|
}
|
|
784
1057
|
//#endregion
|
|
785
|
-
//#region packages/
|
|
786
|
-
var
|
|
787
|
-
function
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
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);
|
|
1058
|
+
//#region packages/xlsx/src/internal/node-acquisition.ts
|
|
1059
|
+
var jt, Mt;
|
|
1060
|
+
function Nt(e) {
|
|
1061
|
+
if (!Mt) jt = e, Mt = new Ce(_t, e);
|
|
1062
|
+
else if (jt !== e) throw Error("XLSX runtime was already initialized with another WebAssembly.Module");
|
|
1063
|
+
return Mt;
|
|
802
1064
|
}
|
|
803
|
-
function
|
|
804
|
-
let
|
|
805
|
-
|
|
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,
|
|
1065
|
+
async function Pt(e, t, r = {}) {
|
|
1066
|
+
let i = n(r), o = new u({
|
|
1067
|
+
enabled: i.debug || i.onResourceMetrics !== void 0,
|
|
817
1068
|
format: "xlsx",
|
|
818
1069
|
mode: "node",
|
|
819
1070
|
scope: "session",
|
|
820
|
-
policy:
|
|
821
|
-
onMetrics:
|
|
822
|
-
emitToConsole:
|
|
823
|
-
})
|
|
824
|
-
|
|
825
|
-
let
|
|
1071
|
+
policy: i.policy,
|
|
1072
|
+
onMetrics: i.onResourceMetrics,
|
|
1073
|
+
emitToConsole: i.debug
|
|
1074
|
+
});
|
|
1075
|
+
o.setSourceBytes(e.byteLength);
|
|
1076
|
+
let s;
|
|
826
1077
|
try {
|
|
827
|
-
|
|
828
|
-
let [
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
1078
|
+
It(r.signal);
|
|
1079
|
+
let [n, c, l] = a(i.policy), u = R;
|
|
1080
|
+
s = await Nt(t).open(() => new u(e, n, c, l), {
|
|
1081
|
+
signal: r.signal,
|
|
1082
|
+
abortError: Lt,
|
|
1083
|
+
disposeOnAbort: (e) => e.free()
|
|
1084
|
+
}), It(r.signal);
|
|
1085
|
+
let d = s.proxy, ee = JSON.parse(new TextDecoder().decode(d.parse())), f = Ft(d.resource_usage());
|
|
1086
|
+
return o.observeUsage(f), o.checkpoint("workbook index ready"), {
|
|
1087
|
+
archive: d,
|
|
1088
|
+
workbookIndex: ee,
|
|
1089
|
+
usage: f,
|
|
1090
|
+
metrics: o,
|
|
1091
|
+
closeArchive: () => s?.close((e) => e.free())
|
|
1092
|
+
};
|
|
832
1093
|
} catch (e) {
|
|
833
1094
|
try {
|
|
834
|
-
|
|
1095
|
+
s?.close((e) => e.free());
|
|
835
1096
|
} catch {}
|
|
836
|
-
let
|
|
837
|
-
throw
|
|
1097
|
+
let t = f(e) ?? e;
|
|
1098
|
+
throw o.fail(t), t;
|
|
838
1099
|
}
|
|
839
1100
|
}
|
|
840
|
-
|
|
1101
|
+
function Ft(e) {
|
|
1102
|
+
try {
|
|
1103
|
+
return g(e);
|
|
1104
|
+
} catch (e) {
|
|
1105
|
+
if (String(e).includes("worksheet cursor usage is unavailable")) return;
|
|
1106
|
+
throw e;
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
function It(e) {
|
|
1110
|
+
if (e?.aborted) throw Lt();
|
|
1111
|
+
}
|
|
1112
|
+
function Lt() {
|
|
1113
|
+
let e = /* @__PURE__ */ Error("XLSX workbook session was aborted");
|
|
1114
|
+
return e.name = "AbortError", e;
|
|
1115
|
+
}
|
|
1116
|
+
//#endregion
|
|
1117
|
+
//#region packages/node/src/xlsx.ts
|
|
1118
|
+
var Rt = y(() => Ie(import.meta.url, "xlsx_parser_bg.wasm", "@silurus/ooxml-xlsx/wasm-binary"));
|
|
1119
|
+
async function $(e, t = {}) {
|
|
1120
|
+
let n = await Pt(Kt(e), Rt(), t);
|
|
1121
|
+
return new zt(n.closeArchive, n.archive, n.workbookIndex, n.metrics, n.usage, t.signal);
|
|
1122
|
+
}
|
|
1123
|
+
var zt = class {
|
|
1124
|
+
workbookIndex;
|
|
841
1125
|
sheetCount;
|
|
842
1126
|
sheetNames;
|
|
843
1127
|
pull;
|
|
844
1128
|
transport;
|
|
845
|
-
|
|
846
|
-
nextOperationId = 1;
|
|
1129
|
+
worksheetPullClient;
|
|
847
1130
|
active;
|
|
848
1131
|
closed = !1;
|
|
849
1132
|
closePromise;
|
|
@@ -851,13 +1134,22 @@ var ft = class {
|
|
|
851
1134
|
completedWorksheets = 0;
|
|
852
1135
|
rowBatches = 0;
|
|
853
1136
|
emittedRows = 0;
|
|
854
|
-
constructor(e, t, n, r, i) {
|
|
855
|
-
this.
|
|
1137
|
+
constructor(e, t, n, r, i, a) {
|
|
1138
|
+
this.closeArchive = e, this.archive = t, this.metrics = r, this.signal = a, this.workbookIndex = Wt(n), this.sheetNames = Object.freeze(this.workbookIndex.workbook.sheets.map((e) => e.name)), this.sheetCount = this.sheetNames.length, this.lastUsage = i, this.pull = new ge(() => this.archive), this.transport = new v((e, t) => this.pull.dispatchSafely(e, t), () => void 0), this.worksheetPullClient = new ve({
|
|
1139
|
+
transport: this.transport,
|
|
1140
|
+
sharedStrings: n.sharedStrings,
|
|
1141
|
+
open: async (e, t, n) => {
|
|
1142
|
+
this.pull.reserveOpen(n), await this.pull.open(e, t, n);
|
|
1143
|
+
},
|
|
1144
|
+
onUsage: (e) => {
|
|
1145
|
+
this.lastUsage = e, this.metrics.observeUsage(e);
|
|
1146
|
+
}
|
|
1147
|
+
});
|
|
856
1148
|
}
|
|
857
1149
|
get resourceUsage() {
|
|
858
1150
|
if (this.closed) return this.lastUsage;
|
|
859
1151
|
try {
|
|
860
|
-
this.lastUsage =
|
|
1152
|
+
this.lastUsage = Gt(this.archive.resource_usage());
|
|
861
1153
|
} catch {}
|
|
862
1154
|
return this.lastUsage;
|
|
863
1155
|
}
|
|
@@ -865,59 +1157,40 @@ var ft = class {
|
|
|
865
1157
|
if (this.closed) throw Error("XLSX workbook session is closed");
|
|
866
1158
|
if (this.active) throw Error("another XLSX worksheet row stream is already active");
|
|
867
1159
|
if (!Number.isSafeInteger(e) || e < 0) throw RangeError("sheetIndex must be a non-negative safe integer");
|
|
868
|
-
let
|
|
869
|
-
|
|
870
|
-
let r
|
|
871
|
-
identity: {
|
|
872
|
-
sessionId: r,
|
|
873
|
-
operationId: r,
|
|
874
|
-
generation: 1
|
|
875
|
-
},
|
|
876
|
-
terminalAcknowledged: !1
|
|
877
|
-
};
|
|
878
|
-
this.active = i;
|
|
879
|
-
let a;
|
|
1160
|
+
let t = this.requireSheetName(e), n = {};
|
|
1161
|
+
this.active = n;
|
|
1162
|
+
let r;
|
|
880
1163
|
try {
|
|
881
|
-
|
|
882
|
-
let t = new p(this.transport, {
|
|
883
|
-
...i.identity,
|
|
884
|
-
maxByteCredit: ce
|
|
885
|
-
});
|
|
886
|
-
for (i.client = t;;) {
|
|
1164
|
+
for await (let n of this.worksheetPullClient.stream(e, t, this.signal)) {
|
|
887
1165
|
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
1166
|
if (n.kind === "rows") {
|
|
894
|
-
|
|
1167
|
+
this.rowBatches += 1, this.emittedRows += n.rows.length, yield {
|
|
895
1168
|
kind: "rows",
|
|
896
1169
|
rows: n.rows,
|
|
897
|
-
sequence:
|
|
898
|
-
wireBytes:
|
|
899
|
-
usage:
|
|
900
|
-
}
|
|
1170
|
+
sequence: n.sequence,
|
|
1171
|
+
wireBytes: n.wireBytes,
|
|
1172
|
+
usage: n.usage
|
|
1173
|
+
};
|
|
901
1174
|
continue;
|
|
902
1175
|
}
|
|
903
|
-
|
|
1176
|
+
yield {
|
|
904
1177
|
kind: "finished",
|
|
905
1178
|
worksheet: n.worksheet,
|
|
906
|
-
sequence:
|
|
907
|
-
wireBytes:
|
|
908
|
-
usage:
|
|
909
|
-
}
|
|
910
|
-
return;
|
|
1179
|
+
sequence: n.sequence,
|
|
1180
|
+
wireBytes: n.wireBytes,
|
|
1181
|
+
usage: n.usage
|
|
1182
|
+
};
|
|
911
1183
|
}
|
|
1184
|
+
this.completedWorksheets += 1, this.metrics.checkpoint("worksheet stream complete", this.lastUsage);
|
|
912
1185
|
} catch (e) {
|
|
913
|
-
throw
|
|
1186
|
+
throw r = f(e) ?? e, this.metrics.fail(r), await this.close().catch(() => void 0), r;
|
|
914
1187
|
} finally {
|
|
915
1188
|
try {
|
|
916
|
-
await this.cleanupOperation(
|
|
1189
|
+
await this.cleanupOperation(n, r === void 0 ? "closed" : "request-error");
|
|
917
1190
|
} catch (e) {
|
|
918
|
-
if (
|
|
919
|
-
let
|
|
920
|
-
throw this.metrics.fail(
|
|
1191
|
+
if (r === void 0) {
|
|
1192
|
+
let t = f(e) ?? e;
|
|
1193
|
+
throw this.metrics.fail(t), await this.close().catch(() => void 0), t;
|
|
921
1194
|
}
|
|
922
1195
|
}
|
|
923
1196
|
}
|
|
@@ -925,34 +1198,34 @@ var ft = class {
|
|
|
925
1198
|
close() {
|
|
926
1199
|
return this.closePromise ? this.closePromise : (this.closed = !0, this.closePromise = this.release(), this.closePromise);
|
|
927
1200
|
}
|
|
928
|
-
cleanupOperation(e,
|
|
1201
|
+
cleanupOperation(e, t) {
|
|
929
1202
|
return e.cleanupPromise ||= (async () => {
|
|
930
|
-
let
|
|
931
|
-
|
|
932
|
-
await
|
|
1203
|
+
let n;
|
|
1204
|
+
try {
|
|
1205
|
+
await this.worksheetPullClient.cancelAll(t);
|
|
933
1206
|
} catch (e) {
|
|
934
|
-
|
|
1207
|
+
n = f(e) ?? e;
|
|
935
1208
|
}
|
|
936
1209
|
try {
|
|
937
1210
|
await this.pull.reset();
|
|
938
1211
|
} catch (e) {
|
|
939
|
-
|
|
1212
|
+
n ??= f(e) ?? e;
|
|
940
1213
|
}
|
|
941
|
-
if (this.active === e && (this.active = void 0),
|
|
1214
|
+
if (this.active === e && (this.active = void 0), n !== void 0) throw n;
|
|
942
1215
|
})(), e.cleanupPromise;
|
|
943
1216
|
}
|
|
944
1217
|
async release() {
|
|
945
1218
|
let e;
|
|
946
1219
|
if (this.active) try {
|
|
947
1220
|
await this.cleanupOperation(this.active, "closed");
|
|
948
|
-
} catch (
|
|
949
|
-
e = t
|
|
1221
|
+
} catch (t) {
|
|
1222
|
+
e = f(t) ?? t;
|
|
950
1223
|
}
|
|
951
|
-
this.transport.terminate()
|
|
1224
|
+
this.transport.terminate();
|
|
952
1225
|
try {
|
|
953
|
-
this.
|
|
954
|
-
} catch (
|
|
955
|
-
e ??= t
|
|
1226
|
+
this.closeArchive();
|
|
1227
|
+
} catch (t) {
|
|
1228
|
+
e ??= f(t) ?? t;
|
|
956
1229
|
}
|
|
957
1230
|
if (e !== void 0) throw this.metrics.fail(e), e;
|
|
958
1231
|
this.metrics.checkpoint("workbook session closed", this.lastUsage), this.metrics.succeed({
|
|
@@ -961,38 +1234,79 @@ var ft = class {
|
|
|
961
1234
|
rows: this.emittedRows
|
|
962
1235
|
});
|
|
963
1236
|
}
|
|
964
|
-
requireWorkbook() {
|
|
965
|
-
if (!this.workbook) throw Error("XLSX workbook session is closed");
|
|
966
|
-
return this.workbook;
|
|
967
|
-
}
|
|
968
1237
|
requireSheetName(e) {
|
|
969
|
-
let t = this.
|
|
1238
|
+
let t = this.workbookIndex.workbook.sheets[e];
|
|
970
1239
|
if (!t) throw RangeError(`Sheet index ${e} out of range`);
|
|
971
1240
|
return t.name;
|
|
972
1241
|
}
|
|
973
1242
|
};
|
|
974
|
-
function
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
}
|
|
1243
|
+
async function Bt(e, t = {}) {
|
|
1244
|
+
return _(() => $(e, t), async (e) => structuredClone(e.workbookIndex));
|
|
1245
|
+
}
|
|
1246
|
+
async function Vt(e, t, n = {}) {
|
|
1247
|
+
return _(() => $(e, n), async (e) => (await Ut(e, t)).worksheet);
|
|
980
1248
|
}
|
|
981
|
-
function
|
|
1249
|
+
async function Ht(e, t = {}) {
|
|
1250
|
+
return _(() => $(e, t), async (e) => {
|
|
1251
|
+
let t = [], n = {
|
|
1252
|
+
rows: 0,
|
|
1253
|
+
cells: 0,
|
|
1254
|
+
ownedUtf8Bytes: 0,
|
|
1255
|
+
jsonBytes: 0
|
|
1256
|
+
};
|
|
1257
|
+
for (let r = 0; r < e.sheetCount; r += 1) {
|
|
1258
|
+
let i = await Ut(e, r), a = de(n, i.usage);
|
|
1259
|
+
_e(a, "materialize-workbook", void 0, i.resourceUsage), n = a, t.push(i.worksheet);
|
|
1260
|
+
}
|
|
1261
|
+
return {
|
|
1262
|
+
workbookIndex: structuredClone(e.workbookIndex),
|
|
1263
|
+
worksheets: Object.freeze(t)
|
|
1264
|
+
};
|
|
1265
|
+
});
|
|
1266
|
+
}
|
|
1267
|
+
async function Ut(e, t) {
|
|
1268
|
+
let n = [], r = {
|
|
1269
|
+
rows: 0,
|
|
1270
|
+
cells: 0,
|
|
1271
|
+
ownedUtf8Bytes: 0
|
|
1272
|
+
}, i, a, o;
|
|
1273
|
+
for await (let s of e.worksheetRows(t)) if (o = s.usage ?? o, s.kind === "rows") {
|
|
1274
|
+
let e = he(r, pe(s.rows));
|
|
1275
|
+
me(e, "materialize-worksheet", void 0, o), n.push(...s.rows), r = e;
|
|
1276
|
+
} else {
|
|
1277
|
+
a = s.worksheet, a.rows = a.parseError ? [] : n;
|
|
1278
|
+
let e = ye(a, a.parseError ? {
|
|
1279
|
+
rows: 0,
|
|
1280
|
+
cells: 0,
|
|
1281
|
+
ownedUtf8Bytes: 0
|
|
1282
|
+
} : r);
|
|
1283
|
+
me(e, "materialize-worksheet", void 0, o), fe(e.jsonBytes, "materialize-worksheet", void 0, o), r = e, i = e;
|
|
1284
|
+
}
|
|
1285
|
+
if (!a || !i) throw Error(`XLSX worksheet ${t} did not produce a terminal model`);
|
|
1286
|
+
return {
|
|
1287
|
+
worksheet: a,
|
|
1288
|
+
usage: i,
|
|
1289
|
+
resourceUsage: o
|
|
1290
|
+
};
|
|
1291
|
+
}
|
|
1292
|
+
function Wt(e, t = /* @__PURE__ */ new WeakSet()) {
|
|
1293
|
+
if (typeof e != "object" || !e) return e;
|
|
1294
|
+
let n = e;
|
|
1295
|
+
if (t.has(n)) return e;
|
|
1296
|
+
t.add(n);
|
|
1297
|
+
for (let e of Object.values(n)) Wt(e, t);
|
|
1298
|
+
return Object.freeze(e);
|
|
1299
|
+
}
|
|
1300
|
+
function Gt(e) {
|
|
982
1301
|
try {
|
|
983
|
-
return
|
|
1302
|
+
return g(e);
|
|
984
1303
|
} catch (e) {
|
|
985
1304
|
if (String(e).includes("worksheet cursor usage is unavailable")) return;
|
|
986
1305
|
throw e;
|
|
987
1306
|
}
|
|
988
1307
|
}
|
|
989
|
-
function
|
|
1308
|
+
function Kt(e) {
|
|
990
1309
|
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
991
1310
|
}
|
|
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
1311
|
//#endregion
|
|
998
|
-
export {
|
|
1312
|
+
export { s as OoxmlDecodedImageLimitError, p as OoxmlResourceLimitError, De as installImageBitmapShim, Te as installOffscreenCanvasShim, c as isOoxmlDecodedImageLimitError, pt as materializeDocxDocument, Ve as materializePptxPresentation, Ht as materializeXlsxWorkbook, Bt as materializeXlsxWorkbookIndex, Vt as materializeXlsxWorksheet, ft as openDocxDocument, Re as openPptxPresentation, $ as openXlsxWorkbook, Ee as renderSlideNode };
|