@silurus/ooxml 0.74.5 → 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-BxU0Lb3J.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
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import { C as e, N as t, O as n, S as r, T as i, a, b as o, i as s, o as c, w as l, x as u, y as d } from "./bounded-raw-part-cache-BTfZD_Sz.js";
|
|
2
|
+
import { t as f } from "./transfer-3QEJrsJa.js";
|
|
3
|
+
import { n as p, r as m, t as h } from "./resource-measurement-6aReN3K0.js";
|
|
4
|
+
//#region packages/xlsx/src/shared-strings.ts
|
|
5
|
+
function g(e, t) {
|
|
6
|
+
return _(e.rows, t), e;
|
|
7
|
+
}
|
|
8
|
+
function _(e, t) {
|
|
9
|
+
for (let n of e) for (let e of n.cells) {
|
|
10
|
+
let n = e.value;
|
|
11
|
+
if (n.type === "shared") {
|
|
12
|
+
let r = t[n.si];
|
|
13
|
+
if (r) {
|
|
14
|
+
let t = {
|
|
15
|
+
type: "text",
|
|
16
|
+
text: r.text
|
|
17
|
+
};
|
|
18
|
+
r.runs !== void 0 && (t.runs = r.runs), r.phoneticRuns !== void 0 && (t.phoneticRuns = r.phoneticRuns), r.phoneticPr !== void 0 && (t.phoneticPr = r.phoneticPr), e.value = t;
|
|
19
|
+
} else e.value = {
|
|
20
|
+
type: "text",
|
|
21
|
+
text: ""
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return e;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region packages/xlsx/src/worksheet-resource-limits.ts
|
|
29
|
+
var v = l, y = u, b = r, x = e, S = o, C = d, w = Object.freeze({
|
|
30
|
+
archiveEntryCount: 0,
|
|
31
|
+
declaredInflatedBytes: 0,
|
|
32
|
+
distinctInflatedBytes: 0,
|
|
33
|
+
operationInflatedBytes: 0
|
|
34
|
+
});
|
|
35
|
+
function T(e) {
|
|
36
|
+
let t = e.reduce((e, t) => h(e, t.cells.length, y), 0);
|
|
37
|
+
return {
|
|
38
|
+
rows: e.length,
|
|
39
|
+
cells: t,
|
|
40
|
+
ownedUtf8Bytes: e.reduce((e, t) => t.cells.reduce((e, t) => {
|
|
41
|
+
let n = p(t.value, b).stringValueUtf8Bytes;
|
|
42
|
+
return h(e, h(n, t.formula === void 0 ? 0 : m(t.formula, b), b), b);
|
|
43
|
+
}, e), 0)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function E(e) {
|
|
47
|
+
let t = T(e.rows), n = p(e, Math.max(b, x));
|
|
48
|
+
return {
|
|
49
|
+
...t,
|
|
50
|
+
jsonBytes: n.jsonBytes
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function D(e, t) {
|
|
54
|
+
return {
|
|
55
|
+
rows: h(e.rows, t.rows, v),
|
|
56
|
+
cells: h(e.cells, t.cells, y),
|
|
57
|
+
ownedUtf8Bytes: h(e.ownedUtf8Bytes, t.ownedUtf8Bytes, b)
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function O(e, t, n = {}) {
|
|
61
|
+
let r = e.rows - (n.rows ?? 0), i = e.cells - (n.cells ?? 0);
|
|
62
|
+
if (r < 0 || i < 0) throw Error("worksheet cache accounting underflow");
|
|
63
|
+
return {
|
|
64
|
+
rows: h(r, t.rows, S),
|
|
65
|
+
cells: h(i, t.cells, C)
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function k(e, n, r, i, a, o, s) {
|
|
69
|
+
let c = r === "worksheet-json" ? "serialization" : "parsing";
|
|
70
|
+
return new t(`OOXML resource limit exceeded${n ? ` for ${n}` : ""}: ${i} ${o} > ${a}`, {
|
|
71
|
+
stage: c,
|
|
72
|
+
violation: {
|
|
73
|
+
format: "xlsx",
|
|
74
|
+
operation: e,
|
|
75
|
+
resource: r,
|
|
76
|
+
metric: i,
|
|
77
|
+
...n === void 0 ? {} : { part: n },
|
|
78
|
+
limit: a,
|
|
79
|
+
observed: Math.min(o, a + 1),
|
|
80
|
+
configurable: !1,
|
|
81
|
+
usage: s ?? w
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function A(e, t, n, r) {
|
|
86
|
+
let i = [
|
|
87
|
+
[
|
|
88
|
+
"rows",
|
|
89
|
+
e.rows,
|
|
90
|
+
v
|
|
91
|
+
],
|
|
92
|
+
[
|
|
93
|
+
"cells",
|
|
94
|
+
e.cells,
|
|
95
|
+
y
|
|
96
|
+
],
|
|
97
|
+
[
|
|
98
|
+
"owned-utf8-bytes",
|
|
99
|
+
e.ownedUtf8Bytes,
|
|
100
|
+
b
|
|
101
|
+
]
|
|
102
|
+
];
|
|
103
|
+
for (let [e, a, o] of i) if (a > o) throw k(t, n, e === "owned-utf8-bytes" ? "worksheet-cell-content" : "worksheet-model", e, o, a, r);
|
|
104
|
+
}
|
|
105
|
+
function j(e, t, n, r) {
|
|
106
|
+
if (e > x) throw k(t, n, "worksheet-json", "bytes", x, e, r);
|
|
107
|
+
}
|
|
108
|
+
function M(e, t, n, r) {
|
|
109
|
+
if (e.rows > S) throw k(t, n, "worksheet-cache", "rows", S, e.rows, r);
|
|
110
|
+
if (e.cells > C) throw k(t, n, "worksheet-cache", "cells", C, e.cells, r);
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region packages/xlsx/src/worksheet-pull-worker.ts
|
|
114
|
+
var N = 64 * 1024 * 1024, P = class {
|
|
115
|
+
coordinator = new c();
|
|
116
|
+
sessions = /* @__PURE__ */ new Map();
|
|
117
|
+
operationTail = Promise.resolve();
|
|
118
|
+
pendingOpens = /* @__PURE__ */ new Map();
|
|
119
|
+
resourceFailure;
|
|
120
|
+
constructor(e, t, n = (e) => e(this.requireArchive()), r) {
|
|
121
|
+
this.archive = e, this.acceptWorksheet = t, this.executeArchive = n, this.prepareRows = r;
|
|
122
|
+
}
|
|
123
|
+
reserveOpen(e) {
|
|
124
|
+
this.pendingOpens.set(e.sessionId, {
|
|
125
|
+
identity: e,
|
|
126
|
+
canceled: !1
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
abandonOpen(e) {
|
|
130
|
+
this.pendingOpens.delete(e);
|
|
131
|
+
}
|
|
132
|
+
get pendingOpenCount() {
|
|
133
|
+
return this.pendingOpens.size;
|
|
134
|
+
}
|
|
135
|
+
async open(e, n, r) {
|
|
136
|
+
if (this.resourceFailure) throw this.resourceFailure;
|
|
137
|
+
let i = this.pendingOpens.get(r.sessionId);
|
|
138
|
+
if (!i || i.identity.operationId !== r.operationId || i.identity.generation !== r.generation) throw Error("worksheet pull session open reservation is stale or missing");
|
|
139
|
+
let o, s = new Promise((e) => {
|
|
140
|
+
o = e;
|
|
141
|
+
}), c = this.operationTail.then(() => this.coordinator.enqueue(async () => {
|
|
142
|
+
if (i.canceled) throw Error("worksheet pull session open was canceled");
|
|
143
|
+
this.executeArchive((t) => t.open_sheet_cursor(e, n));
|
|
144
|
+
let s = [], c = {
|
|
145
|
+
rows: 0,
|
|
146
|
+
cells: 0,
|
|
147
|
+
ownedUtf8Bytes: 0
|
|
148
|
+
}, l, u = !1, d = new a({
|
|
149
|
+
...r,
|
|
150
|
+
maxByteCredit: N,
|
|
151
|
+
coordinator: this.coordinator,
|
|
152
|
+
driver: {
|
|
153
|
+
pull: () => {
|
|
154
|
+
let e = this.executeArchive((e) => e.pull_sheet_cursor(128)), n = this.executeArchive((e) => e.sheet_cursor_pull_finished());
|
|
155
|
+
if (this.acceptWorksheet) {
|
|
156
|
+
let r = JSON.parse(new TextDecoder().decode(e));
|
|
157
|
+
if (n !== (r.kind === "finished")) throw Error("worksheet cursor terminal marker mismatch");
|
|
158
|
+
try {
|
|
159
|
+
if (r.kind === "rows") {
|
|
160
|
+
this.prepareRows?.(r.rows);
|
|
161
|
+
let e = D(c, T(r.rows));
|
|
162
|
+
A(e, "get-worksheet-worker", void 0, this.readResourceUsage()), s.push(...r.rows), c = e;
|
|
163
|
+
} else l = r.worksheet;
|
|
164
|
+
} catch (e) {
|
|
165
|
+
throw e instanceof t && (this.resourceFailure ??= e), e;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
u = n;
|
|
169
|
+
let r = f(e);
|
|
170
|
+
return {
|
|
171
|
+
payload: r,
|
|
172
|
+
byteLength: r.byteLength,
|
|
173
|
+
done: n,
|
|
174
|
+
transfer: [r]
|
|
175
|
+
};
|
|
176
|
+
},
|
|
177
|
+
measureChunk: ({ payload: e }) => e.byteLength,
|
|
178
|
+
acknowledge: () => {
|
|
179
|
+
if (!u) return;
|
|
180
|
+
let n, i;
|
|
181
|
+
try {
|
|
182
|
+
if (this.acceptWorksheet) {
|
|
183
|
+
if (!l) throw Error("worksheet terminal payload is missing");
|
|
184
|
+
l.rows = s;
|
|
185
|
+
let t = E(l), r = this.readResourceUsage();
|
|
186
|
+
A(t, "get-worksheet-worker", void 0, r), j(t.jsonBytes, "get-worksheet-worker", void 0, r);
|
|
187
|
+
let a = this.acceptWorksheet(e, l, r);
|
|
188
|
+
typeof a == "function" ? n = a : a && ({rollback: n, commit: i} = a);
|
|
189
|
+
}
|
|
190
|
+
this.executeArchive((e) => e.acknowledge_sheet_cursor_terminal()), i?.();
|
|
191
|
+
} catch (e) {
|
|
192
|
+
throw n?.(), e instanceof t && (this.resourceFailure ??= e), e;
|
|
193
|
+
}
|
|
194
|
+
u = !1, this.sessions.delete(r.sessionId), o();
|
|
195
|
+
},
|
|
196
|
+
cancel: () => {
|
|
197
|
+
try {
|
|
198
|
+
this.archive() && this.executeArchive((e) => e.cancel_sheet_cursor());
|
|
199
|
+
} finally {
|
|
200
|
+
this.sessions.delete(r.sessionId), o();
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
close: () => {
|
|
204
|
+
try {
|
|
205
|
+
this.archive() && this.executeArchive((e) => e.close_sheet_cursor());
|
|
206
|
+
} finally {
|
|
207
|
+
this.sessions.delete(r.sessionId), o();
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
resourceUsage: () => this.readResourceUsage()
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
this.sessions.set(r.sessionId, {
|
|
214
|
+
host: d,
|
|
215
|
+
identity: r
|
|
216
|
+
}), this.pendingOpens.delete(r.sessionId);
|
|
217
|
+
}));
|
|
218
|
+
this.operationTail = c.then(() => s, () => void 0);
|
|
219
|
+
try {
|
|
220
|
+
await c;
|
|
221
|
+
} catch (e) {
|
|
222
|
+
throw this.pendingOpens.delete(r.sessionId), o(), e;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
async postOpenedSafely(e, t, n) {
|
|
226
|
+
try {
|
|
227
|
+
t();
|
|
228
|
+
} catch (t) {
|
|
229
|
+
await this.closeIdentity(e);
|
|
230
|
+
try {
|
|
231
|
+
n(t);
|
|
232
|
+
} catch {}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
dispatch(e, t) {
|
|
236
|
+
let r = this.sessions.get(e.sessionId);
|
|
237
|
+
if (r) return r.host.dispatch(e, t);
|
|
238
|
+
let i = this.pendingOpens.get(e.sessionId);
|
|
239
|
+
if (i && (e.kind === "cancel" || e.kind === "close")) {
|
|
240
|
+
let n = i.identity.operationId === e.operationId && i.identity.generation === e.generation;
|
|
241
|
+
return n && (i.canceled = !0), t(n ? {
|
|
242
|
+
protocol: s,
|
|
243
|
+
kind: "accepted",
|
|
244
|
+
sessionId: e.sessionId,
|
|
245
|
+
operationId: e.operationId,
|
|
246
|
+
generation: e.generation,
|
|
247
|
+
requestId: e.requestId,
|
|
248
|
+
command: e.kind
|
|
249
|
+
} : {
|
|
250
|
+
protocol: s,
|
|
251
|
+
kind: "error",
|
|
252
|
+
sessionId: e.sessionId,
|
|
253
|
+
operationId: e.operationId,
|
|
254
|
+
generation: e.generation,
|
|
255
|
+
requestId: e.requestId,
|
|
256
|
+
error: {
|
|
257
|
+
message: "stale lifecycle targets another pending worksheet operation",
|
|
258
|
+
errorName: "PullSessionProtocolError",
|
|
259
|
+
code: "ooxml-stale-lifecycle"
|
|
260
|
+
}
|
|
261
|
+
}), Promise.resolve();
|
|
262
|
+
}
|
|
263
|
+
return e.kind === "cancel" || e.kind === "close" ? (t({
|
|
264
|
+
protocol: s,
|
|
265
|
+
kind: "accepted",
|
|
266
|
+
sessionId: e.sessionId,
|
|
267
|
+
operationId: e.operationId,
|
|
268
|
+
generation: e.generation,
|
|
269
|
+
requestId: e.requestId,
|
|
270
|
+
command: e.kind
|
|
271
|
+
}), Promise.resolve()) : (t({
|
|
272
|
+
protocol: s,
|
|
273
|
+
kind: "error",
|
|
274
|
+
sessionId: e.sessionId,
|
|
275
|
+
operationId: e.operationId,
|
|
276
|
+
generation: e.generation,
|
|
277
|
+
requestId: e.requestId,
|
|
278
|
+
error: n(/* @__PURE__ */ Error("worksheet pull session is not open"))
|
|
279
|
+
}), Promise.resolve());
|
|
280
|
+
}
|
|
281
|
+
async dispatchSafely(e, t) {
|
|
282
|
+
try {
|
|
283
|
+
await this.dispatch(e, t);
|
|
284
|
+
} catch (r) {
|
|
285
|
+
try {
|
|
286
|
+
t({
|
|
287
|
+
protocol: s,
|
|
288
|
+
kind: "error",
|
|
289
|
+
sessionId: e.sessionId,
|
|
290
|
+
operationId: e.operationId,
|
|
291
|
+
generation: e.generation,
|
|
292
|
+
requestId: e.requestId,
|
|
293
|
+
error: n(r)
|
|
294
|
+
});
|
|
295
|
+
} catch {}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
run(e) {
|
|
299
|
+
let n = this.operationTail.then(() => this.coordinator.enqueue(async () => {
|
|
300
|
+
if (this.resourceFailure) throw this.resourceFailure;
|
|
301
|
+
return e();
|
|
302
|
+
})).catch((e) => {
|
|
303
|
+
throw e instanceof t && (this.resourceFailure ??= e), e;
|
|
304
|
+
});
|
|
305
|
+
return this.operationTail = n.then(() => void 0, () => void 0), n;
|
|
306
|
+
}
|
|
307
|
+
async reset() {
|
|
308
|
+
for (let e of this.pendingOpens.values()) e.canceled = !0;
|
|
309
|
+
let e = 1;
|
|
310
|
+
for (let { host: t, identity: n } of [...this.sessions.values()]) await t.dispatch({
|
|
311
|
+
protocol: s,
|
|
312
|
+
kind: "close",
|
|
313
|
+
...n,
|
|
314
|
+
requestId: e++
|
|
315
|
+
}, () => void 0);
|
|
316
|
+
this.sessions.clear(), await this.operationTail, this.pendingOpens.clear(), this.resourceFailure = void 0;
|
|
317
|
+
}
|
|
318
|
+
requireArchive() {
|
|
319
|
+
let e = this.archive();
|
|
320
|
+
if (!e) throw Error("Workbook not loaded");
|
|
321
|
+
return e;
|
|
322
|
+
}
|
|
323
|
+
async closeIdentity(e) {
|
|
324
|
+
let t = this.sessions.get(e.sessionId);
|
|
325
|
+
if (t) {
|
|
326
|
+
await t.host.dispatch({
|
|
327
|
+
protocol: s,
|
|
328
|
+
kind: "close",
|
|
329
|
+
...e,
|
|
330
|
+
requestId: 1
|
|
331
|
+
}, () => void 0);
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
let n = this.pendingOpens.get(e.sessionId);
|
|
335
|
+
n && n.identity.operationId === e.operationId && n.identity.generation === e.generation && (n.canceled = !0);
|
|
336
|
+
}
|
|
337
|
+
readResourceUsage() {
|
|
338
|
+
try {
|
|
339
|
+
return i(this.executeArchive((e) => e.sheet_cursor_resource_usage()));
|
|
340
|
+
} catch (e) {
|
|
341
|
+
if (String(e).includes("worksheet cursor usage is unavailable")) return;
|
|
342
|
+
throw e;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
//#endregion
|
|
347
|
+
export { M as a, T as c, g as d, D as i, E as l, N as n, j as o, O as r, A as s, P as t, _ as u };
|