@silurus/ooxml 0.88.0 → 0.89.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/README.md +118 -23
  2. package/THIRD_PARTY_NOTICES.md +8 -7
  3. package/dist/abort-VrnK7mdP.js +10 -0
  4. package/dist/assets/render-worker-C5G_Nr_A.js +35 -0
  5. package/dist/assets/render-worker-DQfWdNsm.js +16 -0
  6. package/dist/assets/render-worker-Ds7LjwU-.js +15 -0
  7. package/dist/{hyperlink-Cxzhet30.js → bounded-raw-part-cache-CsnNptAy.js} +4937 -7458
  8. package/dist/bundled-asset-url-E2nXURF9.js +15 -0
  9. package/dist/canvas-viewer-mechanics-BZ8QCrRi.js +675 -0
  10. package/dist/cfb-guard-dNeUiANF.js +528 -0
  11. package/dist/chart-ex.mjs +667 -663
  12. package/dist/comment-overlay-controller-CBvQx-En.js +994 -0
  13. package/dist/comment-ui-runtime-B7ZvovcS.js +2 -0
  14. package/dist/{comment-ui-runtime-DcJOYlw-.js → comment-ui-runtime-BKidRH36.js} +5 -5
  15. package/dist/{comment-ui-runtime-CWGqn5Vr.js → comment-ui-runtime-C47QoDUy.js} +5 -5
  16. package/dist/delimited-text-worker-host-CikWU6_m.js +27 -0
  17. package/dist/document-model-source-MzFPrxt0.js +249 -0
  18. package/dist/document-pull-client-BoJeuURD.js +35941 -0
  19. package/dist/document-pull-worker-CaP8XESP.js +104 -0
  20. package/dist/docx-BN70UhvX.js +495 -0
  21. package/dist/docx-BRRtSvk3.js +3563 -0
  22. package/dist/docx-model-source-CTO9iw_W.js +98 -0
  23. package/dist/docx-source-worker.mjs +455 -0
  24. package/dist/docx.mjs +7 -7
  25. package/dist/docx_parser_bg.wasm +0 -0
  26. package/dist/drawingml-shape-CHmq8kpM.js +310 -0
  27. package/dist/duotone-DN8P4aXe.js +126 -0
  28. package/dist/emf-CGFQIz6c.js +1790 -0
  29. package/dist/font-preload-demand-Dmy31xt-.js +2058 -0
  30. package/dist/grid-geometry-C3IG20ut.js +384 -0
  31. package/dist/host-layout-DVMw8hDY.js +56 -0
  32. package/dist/host-layout-measure-DsuQ2UJs.js +7 -0
  33. package/dist/in-process-pull-transport-DuXcPZng.js +29 -0
  34. package/dist/index.mjs +4 -4
  35. package/dist/internal-companion.mjs +12 -0
  36. package/dist/line-distribute-Bu8psjGd.js +2799 -0
  37. package/dist/math.mjs +2 -2
  38. package/dist/mathjax-stix2.js +10 -10
  39. package/dist/model-source-kz_NkZqT.js +179 -0
  40. package/dist/model-source-s5hRpk4w.js +61 -0
  41. package/dist/model-source-session-6fuaqbGs.js +71 -0
  42. package/dist/model-source-session-DqrR4XHR.js +85 -0
  43. package/dist/model-source-session-cPJSF_Ak.js +58 -0
  44. package/dist/node.mjs +7 -1327
  45. package/dist/{pixel-budget-9P63Bsk5.js → pixel-budget-BpTYrepD.js} +13 -10
  46. package/dist/plot-area-frame-Bs_j4uu7.js +41811 -0
  47. package/dist/pptx-CaJ6ILnw.js +183 -0
  48. package/dist/pptx-_BOGcBym.js +2936 -0
  49. package/dist/pptx-model-source-B_9afw9R.js +37 -0
  50. package/dist/pptx-source-worker.mjs +446 -0
  51. package/dist/pptx.mjs +8 -7
  52. package/dist/pptx_parser_bg.wasm +0 -0
  53. package/dist/presentation-model-source-CGHLyX32.js +77 -0
  54. package/dist/raster-target-YQ4G6rxo.js +42 -0
  55. package/dist/region-map.mjs +117 -153
  56. package/dist/{render-D3iqVKCo.js → render-CzbDzRKa.js} +3 -3
  57. package/dist/{render-worker-host-B5wQfB7U.js → render-worker-host-B1u6BOUd.js} +1 -1
  58. package/dist/{render-worker-host-D4123J27.js → render-worker-host-C-EECo68.js} +1 -1
  59. package/dist/{render-worker-host-Di3LxLc0.js → render-worker-host-DDqZTCVf.js} +1 -1
  60. package/dist/renderer-CD2cvVAF.js +5823 -0
  61. package/dist/renderer-DRoeb14O.js +5170 -0
  62. package/dist/resource-measurement-Dhhm7P_l.js +772 -0
  63. package/dist/session-XPmC0CUd.js +656 -0
  64. package/dist/slide-pull-client-tq7U_fYg.js +6485 -0
  65. package/dist/three-d-BKwNPAP4.js +878 -0
  66. package/dist/three-d.mjs +925 -910
  67. package/dist/{raster-target-ojDdQizC.js → tiff-contract-C6M3QcPp.js} +1 -42
  68. package/dist/tiff.mjs +401 -248
  69. package/dist/types/chart-ex.d.ts +149 -2
  70. package/dist/types/docx.d.ts +333 -96
  71. package/dist/types/index.d.ts +566 -301
  72. package/dist/types/internal-companion.d.ts +11 -0
  73. package/dist/types/math.d.ts +1 -1
  74. package/dist/types/node.d.ts +422 -9
  75. package/dist/types/pptx.d.ts +302 -95
  76. package/dist/types/region-map.d.ts +149 -2
  77. package/dist/types/three-d.d.ts +149 -2
  78. package/dist/types/tiff.d.ts +1 -1
  79. package/dist/types/xlsx.d.ts +343 -132
  80. package/dist/wasm-loader-rlgHmcSv.js +35 -0
  81. package/dist/wasm-runtime-generation-D6TKZdNb.js +97 -0
  82. package/dist/workbook-model-source-BIGrfZy6.js +94 -0
  83. package/dist/worker-source-DrwhR9fw.js +22 -0
  84. package/dist/worker-source-SbudzjYL.js +22 -0
  85. package/dist/worker-source-UAi3GNcM.js +22 -0
  86. package/dist/worksheet-pull-client-ClvPO_Jf.js +579 -0
  87. package/dist/xlsx-CsmREBaZ.js +5819 -0
  88. package/dist/xlsx-DmHfeNNp.js +534 -0
  89. package/dist/xlsx-model-source-D1flORqy.js +309 -0
  90. package/dist/xlsx-source-worker.mjs +525 -0
  91. package/dist/xlsx.mjs +8 -7
  92. package/dist/xlsx_parser_bg.wasm +0 -0
  93. package/package.json +42 -16
  94. package/dist/assets/render-worker-1uPAxMZr.js +0 -31
  95. package/dist/assets/render-worker-BlvJybji.js +0 -10
  96. package/dist/assets/render-worker-CzmiJfFL.js +0 -11
  97. package/dist/bounded-raw-part-cache-Cg1BsSZQ.js +0 -119
  98. package/dist/canvas-viewer-mechanics-DbLz0rYW.js +0 -1384
  99. package/dist/cjk-fallback-bLI3z70h.js +0 -46
  100. package/dist/comment-occurrence-C8Y2uoVr.js +0 -6
  101. package/dist/comment-ui-runtime-BsK8pmUT.js +0 -2
  102. package/dist/comments-Diid5ujN.js +0 -246
  103. package/dist/delimited-text-worker-host-BVY-Ecni.js +0 -27
  104. package/dist/document-pull-client-B9PTM-pL.js +0 -27280
  105. package/dist/docx-BF9WXrYH.js +0 -3103
  106. package/dist/dom-interaction-boundary-Cnm8DSBN.js +0 -223
  107. package/dist/highlight-rect-C5hkRqUr.js +0 -13
  108. package/dist/line-distribute-D1WNHKz_.js +0 -1023
  109. package/dist/line-metrics-B60C86uh.js +0 -60
  110. package/dist/plot-area-frame-DLTYKHNP.js +0 -4354
  111. package/dist/pptx-DkyYBYoL.js +0 -3065
  112. package/dist/renderer-B4GZb5We.js +0 -6492
  113. package/dist/resource-measurement-SHQCbkh2.js +0 -150
  114. package/dist/session-BGq81gRQ.js +0 -743
  115. package/dist/slide-pull-client-DiPnm240.js +0 -6253
  116. package/dist/source-key-DIJG8BA0.js +0 -42
  117. package/dist/three-d-DJBl8g8M.js +0 -1162
  118. package/dist/transfer-p6iCC2R7.js +0 -6
  119. package/dist/units-BzZ0gAxs.js +0 -4
  120. package/dist/worksheet-pull-client-BM8ywvbu.js +0 -458
  121. package/dist/xlsx-C9NVjgaV.js +0 -8484
  122. /package/dist/{chunk-DmhlhrBa.js → chunk-Dy4uBu1J.js} +0 -0
  123. /package/dist/{mathjax-DoyWZbSp.js → mathjax-BhwN6ilc.js} +0 -0
  124. /package/dist/{read-only-comment-decoration-Dz7eTQ4d.js → read-only-comment-decoration-PidH0wnP.js} +0 -0
  125. /package/dist/{read-only-comment-margin-DkgzASAl.js → read-only-comment-margin-B52rDVKo.js} +0 -0
  126. /package/dist/{renderer-module-contract-D91rkYHH.js → renderer-module-contract-CWM7jv6d.js} +0 -0
  127. /package/dist/{visible-index-BgiHEc1z.js → visible-index-FeVA0mGE.js} +0 -0
@@ -0,0 +1,579 @@
1
+ import { yo as e } from "./plot-area-frame-Bs_j4uu7.js";
2
+ import { B as t, Cn as n, D as r, E as i, G as a, O as o, Sn as s, W as c, _n as l, bn as u, gn as d, k as f, vn as p, wn as m, xn as h, yn as g } from "./bounded-raw-part-cache-CsnNptAy.js";
3
+ import { n as _ } from "./abort-VrnK7mdP.js";
4
+ import { n as v, r as y, t as b } from "./resource-measurement-Dhhm7P_l.js";
5
+ //#region packages/core/src/worker/transfer.ts
6
+ function x(e) {
7
+ return e.byteOffset === 0 && e.byteLength === e.buffer.byteLength && e.buffer instanceof ArrayBuffer ? e.buffer : e.slice().buffer;
8
+ }
9
+ //#endregion
10
+ //#region packages/xlsx/src/internal/worksheet-policy.ts
11
+ var S = 2 ** 53 - 1 - 1;
12
+ function C(e) {
13
+ return Object.freeze({
14
+ maxRows: e.maxRows,
15
+ maxCells: e.maxCells,
16
+ maxOwnedUtf8Bytes: e.maxOwnedUtf8Bytes,
17
+ maxJsonBytes: e.maxJsonBytes
18
+ });
19
+ }
20
+ var w = Object.freeze({
21
+ worksheet: C({
22
+ maxRows: m,
23
+ maxCells: h,
24
+ maxOwnedUtf8Bytes: s,
25
+ maxJsonBytes: n
26
+ }),
27
+ cache: C({
28
+ maxRows: u,
29
+ maxCells: l,
30
+ maxOwnedUtf8Bytes: p,
31
+ maxJsonBytes: g
32
+ }),
33
+ maxCoordinateIndexEntries: d
34
+ });
35
+ function T(e, t) {
36
+ let n = e[t];
37
+ if (n === void 0) return w.worksheet[t];
38
+ if (typeof n != "number") throw TypeError(`xlsxWorksheetLimits.${t} must be a number`);
39
+ if (!Number.isSafeInteger(n) || n <= 0 || n > S) throw RangeError(`xlsxWorksheetLimits.${t} must be a positive safe integer no greater than ${S}`);
40
+ return n;
41
+ }
42
+ function E(e = {}) {
43
+ let t = e.xlsxWorksheetLimits, n = {};
44
+ if (t !== void 0) {
45
+ if (typeof t != "object" || !t || Array.isArray(t)) throw TypeError("xlsxWorksheetLimits must be a non-null, non-array object");
46
+ n = t;
47
+ }
48
+ let r = C({
49
+ maxRows: T(n, "maxRows"),
50
+ maxCells: T(n, "maxCells"),
51
+ maxOwnedUtf8Bytes: T(n, "maxOwnedUtf8Bytes"),
52
+ maxJsonBytes: T(n, "maxJsonBytes")
53
+ }), i = w, a = C({
54
+ maxRows: Math.max(i.cache.maxRows, r.maxRows),
55
+ maxCells: Math.max(i.cache.maxCells, r.maxCells),
56
+ maxOwnedUtf8Bytes: Math.max(i.cache.maxOwnedUtf8Bytes, r.maxOwnedUtf8Bytes),
57
+ maxJsonBytes: Math.max(i.cache.maxJsonBytes, r.maxJsonBytes)
58
+ });
59
+ return Object.freeze({
60
+ worksheet: r,
61
+ cache: a,
62
+ maxCoordinateIndexEntries: Math.max(i.maxCoordinateIndexEntries, r.maxCells)
63
+ });
64
+ }
65
+ function D(e) {
66
+ let { worksheet: t } = e;
67
+ return [
68
+ BigInt(t.maxRows),
69
+ BigInt(t.maxCells),
70
+ BigInt(t.maxOwnedUtf8Bytes),
71
+ BigInt(t.maxJsonBytes)
72
+ ];
73
+ }
74
+ //#endregion
75
+ //#region packages/xlsx/src/worksheet-policy-context.ts
76
+ var O = /* @__PURE__ */ new WeakMap();
77
+ function k(e, t) {
78
+ O.set(e, t);
79
+ }
80
+ function A(e) {
81
+ return O.get(e) ?? w;
82
+ }
83
+ function j(e, t) {
84
+ let n = O.get(e);
85
+ n === void 0 ? O.delete(t) : O.set(t, n);
86
+ }
87
+ //#endregion
88
+ //#region packages/xlsx/src/worksheet-resource-limits.ts
89
+ var M = n, N = Object.freeze({
90
+ archiveEntryCount: 0,
91
+ declaredInflatedBytes: 0,
92
+ distinctInflatedBytes: 0,
93
+ operationInflatedBytes: 0
94
+ });
95
+ function P(e, t = w) {
96
+ let { maxCells: n, maxOwnedUtf8Bytes: r } = t.worksheet, i = e.reduce((e, t) => b(e, t.cells.length, n), 0);
97
+ return {
98
+ rows: e.length,
99
+ cells: i,
100
+ ownedUtf8Bytes: e.reduce((e, t) => t.cells.reduce((e, t) => {
101
+ let n = v(t.value, r).stringValueUtf8Bytes;
102
+ return b(e, b(n, t.formula === void 0 ? 0 : y(t.formula, r), r), r);
103
+ }, e), 0)
104
+ };
105
+ }
106
+ function F(e, t = w) {
107
+ return I(e, P(e.rows, t), t);
108
+ }
109
+ function I(e, t, n = w) {
110
+ let r = v(e, n.worksheet.maxJsonBytes);
111
+ return {
112
+ ...t,
113
+ jsonBytes: r.jsonBytes
114
+ };
115
+ }
116
+ function L(e, t, n = w) {
117
+ let r = n.worksheet;
118
+ return {
119
+ rows: b(e.rows, t.rows, r.maxRows),
120
+ cells: b(e.cells, t.cells, r.maxCells),
121
+ ownedUtf8Bytes: b(e.ownedUtf8Bytes, t.ownedUtf8Bytes, r.maxOwnedUtf8Bytes)
122
+ };
123
+ }
124
+ function R(e, t, n = {}, r = w) {
125
+ let i = r.cache, a = e.rows - (n.rows ?? 0), o = e.cells - (n.cells ?? 0), s = e.ownedUtf8Bytes - (n.ownedUtf8Bytes ?? 0), c = e.jsonBytes - (n.jsonBytes ?? 0);
126
+ if (a < 0 || o < 0 || s < 0 || c < 0) throw Error("worksheet cache accounting underflow");
127
+ return {
128
+ rows: b(a, t.rows, i.maxRows),
129
+ cells: b(o, t.cells, i.maxCells),
130
+ ownedUtf8Bytes: b(s, t.ownedUtf8Bytes, i.maxOwnedUtf8Bytes),
131
+ jsonBytes: b(c, t.jsonBytes, i.maxJsonBytes)
132
+ };
133
+ }
134
+ function z(t, n, r, i, a, o, s, l = r !== "delimited-text-source") {
135
+ let u = r === "worksheet-json" ? "serialization" : "parsing";
136
+ return new e(c({
137
+ stage: u,
138
+ violation: {
139
+ part: n,
140
+ resource: r,
141
+ metric: i,
142
+ observed: o,
143
+ limit: a
144
+ }
145
+ }), {
146
+ stage: u,
147
+ violation: {
148
+ format: "xlsx",
149
+ operation: t,
150
+ resource: r,
151
+ metric: i,
152
+ ...n === void 0 ? {} : { part: n },
153
+ limit: a,
154
+ observed: Math.min(o, a + 1),
155
+ configurable: l,
156
+ usage: s ?? N
157
+ }
158
+ });
159
+ }
160
+ function B(e, t, n, r, i = w) {
161
+ let a = i.worksheet, o = [
162
+ [
163
+ "rows",
164
+ e.rows,
165
+ a.maxRows
166
+ ],
167
+ [
168
+ "cells",
169
+ e.cells,
170
+ a.maxCells
171
+ ],
172
+ [
173
+ "owned-utf8-bytes",
174
+ e.ownedUtf8Bytes,
175
+ a.maxOwnedUtf8Bytes
176
+ ]
177
+ ];
178
+ for (let [e, i, a] of o) if (i > a) throw z(t, n, e === "owned-utf8-bytes" ? "worksheet-cell-content" : "worksheet-model", e, a, i, r);
179
+ }
180
+ function V(e, t, n, r, i = w) {
181
+ let a = i.worksheet.maxJsonBytes;
182
+ if (e > a) throw z(t, n, "worksheet-json", "bytes", a, e, r);
183
+ }
184
+ function H(e, t, n, r, i = w) {
185
+ let a = i.cache;
186
+ if (e.rows > a.maxRows) throw z(t, n, "worksheet-cache", "rows", a.maxRows, e.rows, r);
187
+ if (e.cells > a.maxCells) throw z(t, n, "worksheet-cache", "cells", a.maxCells, e.cells, r);
188
+ if (e.ownedUtf8Bytes > a.maxOwnedUtf8Bytes) throw z(t, n, "worksheet-cache", "owned-utf8-bytes", a.maxOwnedUtf8Bytes, e.ownedUtf8Bytes, r);
189
+ if (e.jsonBytes > a.maxJsonBytes) throw z(t, n, "worksheet-cache", "bytes", a.maxJsonBytes, e.jsonBytes, r);
190
+ }
191
+ //#endregion
192
+ //#region packages/xlsx/src/shared-strings.ts
193
+ function U(e, t) {
194
+ return W(e.rows, t), e;
195
+ }
196
+ function W(e, t) {
197
+ for (let n of e) for (let e of n.cells) {
198
+ let n = e.value;
199
+ if (n.type === "shared") {
200
+ let r = t[n.si];
201
+ if (r) {
202
+ let t = {
203
+ type: "text",
204
+ text: r.text
205
+ };
206
+ 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;
207
+ } else e.value = {
208
+ type: "text",
209
+ text: ""
210
+ };
211
+ }
212
+ }
213
+ return e;
214
+ }
215
+ //#endregion
216
+ //#region packages/xlsx/src/worksheet-pull-codec.ts
217
+ var G = new Set([
218
+ "outline",
219
+ "merge",
220
+ "conditional-format",
221
+ "ancillary-content",
222
+ "metadata-unavailable",
223
+ "unordered-rows"
224
+ ]);
225
+ function K(e, t, n, r) {
226
+ let i = e instanceof ArrayBuffer ? new Uint8Array(e) : new Uint8Array(e.buffer, e.byteOffset, e.byteLength), a = JSON.parse(new TextDecoder().decode(i));
227
+ if (!a || typeof a != "object" || !("kind" in a)) throw Error("worksheet cursor returned an invalid unit");
228
+ let o = a;
229
+ if (t !== (o.kind === "finished")) throw Error("worksheet cursor terminal marker mismatch");
230
+ if (o.kind === "rows") {
231
+ if (!Array.isArray(o.rows)) throw Error("worksheet row unit is missing rows");
232
+ return n && W(o.rows, n), r?.(o.rows), {
233
+ kind: "rows",
234
+ rows: o.rows
235
+ };
236
+ }
237
+ if (o.kind === "preview") {
238
+ if (!Number.isSafeInteger(o.maxRow) || !Number.isSafeInteger(o.maxCol) || o.maxRow < 0 || o.maxCol < 0 || o.worksheet === null == (o.reason === null) || o.worksheet !== null && (typeof o.worksheet != "object" || Array.isArray(o.worksheet)) || o.reason !== null && !G.has(o.reason)) throw Error("worksheet preview unit is invalid");
239
+ return o.worksheet && (o.worksheet.rows = []), o;
240
+ }
241
+ if (o.kind === "finished") {
242
+ if (!o.worksheet || typeof o.worksheet != "object") throw Error("worksheet terminal unit is missing its worksheet");
243
+ return o.worksheet.rows = [], {
244
+ kind: "finished",
245
+ worksheet: o.worksheet
246
+ };
247
+ }
248
+ throw Error("worksheet cursor returned an unknown unit kind");
249
+ }
250
+ //#endregion
251
+ //#region packages/xlsx/src/worksheet-pull-worker.ts
252
+ var q = 64 * 1024 * 1024, J = class {
253
+ archive;
254
+ acceptWorksheet;
255
+ executeArchive;
256
+ prepareRows;
257
+ provisional;
258
+ worksheetPolicy;
259
+ coordinator = new f();
260
+ sessions = /* @__PURE__ */ new Map();
261
+ operationTail = Promise.resolve();
262
+ pendingOpens = /* @__PURE__ */ new Map();
263
+ resourceFailure;
264
+ constructor(e, t, n = (e) => e(this.requireArchive()), r, i, a = () => w) {
265
+ this.archive = e, this.acceptWorksheet = t, this.executeArchive = n, this.prepareRows = r, this.provisional = i, this.worksheetPolicy = a;
266
+ }
267
+ reserveOpen(e) {
268
+ this.pendingOpens.set(e.sessionId, {
269
+ identity: e,
270
+ canceled: !1
271
+ });
272
+ }
273
+ abandonOpen(e) {
274
+ this.pendingOpens.delete(e);
275
+ }
276
+ get pendingOpenCount() {
277
+ return this.pendingOpens.size;
278
+ }
279
+ runDuringPull(t) {
280
+ return this.sessions.size === 0 ? this.run(t) : this.coordinator.enqueue(async () => {
281
+ if (this.resourceFailure) throw this.resourceFailure;
282
+ try {
283
+ return t();
284
+ } catch (t) {
285
+ throw t instanceof e && (this.resourceFailure ??= t), t;
286
+ }
287
+ });
288
+ }
289
+ async open(t, n, r) {
290
+ if (this.resourceFailure) throw this.resourceFailure;
291
+ let i = this.pendingOpens.get(r.sessionId);
292
+ if (!i || i.identity.operationId !== r.operationId || i.identity.generation !== r.generation) throw Error("worksheet pull session open reservation is stale or missing");
293
+ let a = this.worksheetPolicy(), s, c = new Promise((e) => {
294
+ s = e;
295
+ }), l = this.operationTail.then(() => this.coordinator.enqueue(async () => {
296
+ if (i.canceled) throw Error("worksheet pull session open was canceled");
297
+ this.executeArchive((e) => e.open_sheet_cursor(t, n));
298
+ let c = [], l = {
299
+ rows: 0,
300
+ cells: 0,
301
+ ownedUtf8Bytes: 0
302
+ }, u, d = !1, f = new o({
303
+ ...r,
304
+ maxByteCredit: q,
305
+ coordinator: this.coordinator,
306
+ driver: {
307
+ pull: () => {
308
+ let n = this.executeArchive((e) => e.pull_sheet_cursor(128)), r = this.executeArchive((e) => e.sheet_cursor_pull_finished());
309
+ if (this.acceptWorksheet) {
310
+ let i = K(n, r, void 0, this.prepareRows);
311
+ try {
312
+ if (i.kind === "preview") i.worksheet && (i.worksheet.rows = c, k(i.worksheet, a), this.provisional?.preview(t, i.worksheet));
313
+ else if (i.kind === "rows") {
314
+ let e = L(l, P(i.rows, a), a);
315
+ B(e, "get-worksheet-worker", void 0, this.readResourceUsage(), a), c.push(...i.rows), l = e;
316
+ } else i.kind === "finished" && (u = i.worksheet);
317
+ } catch (t) {
318
+ throw t instanceof e && (this.resourceFailure ??= t), t;
319
+ }
320
+ }
321
+ d = r;
322
+ let i = x(n);
323
+ return {
324
+ payload: i,
325
+ byteLength: i.byteLength,
326
+ done: r,
327
+ transfer: [i]
328
+ };
329
+ },
330
+ measureChunk: ({ payload: e }) => e.byteLength,
331
+ acknowledge: () => {
332
+ if (!d) return;
333
+ let n, i;
334
+ try {
335
+ if (this.acceptWorksheet) {
336
+ if (!u) throw Error("worksheet terminal payload is missing");
337
+ u.rows = u.parseError ? [] : c;
338
+ let e = u.parseError ? {
339
+ rows: 0,
340
+ cells: 0,
341
+ ownedUtf8Bytes: 0
342
+ } : l, r = I(u, e, a), o = this.readResourceUsage();
343
+ B(r, "get-worksheet-worker", void 0, o, a), V(r.jsonBytes, "get-worksheet-worker", void 0, o, a), k(u, a);
344
+ let s = this.acceptWorksheet(t, u, r, o);
345
+ typeof s == "function" ? n = s : s && ({rollback: n, commit: i} = s);
346
+ }
347
+ this.executeArchive((e) => e.acknowledge_sheet_cursor_terminal()), i?.();
348
+ } catch (t) {
349
+ throw n?.(), t instanceof e && (this.resourceFailure ??= t), t;
350
+ }
351
+ d = !1, this.sessions.delete(r.sessionId), this.provisional?.stop(t), s();
352
+ },
353
+ cancel: () => {
354
+ try {
355
+ this.archive() && this.executeArchive((e) => e.cancel_sheet_cursor());
356
+ } finally {
357
+ this.sessions.delete(r.sessionId), this.provisional?.stop(t), s();
358
+ }
359
+ },
360
+ close: () => {
361
+ try {
362
+ this.archive() && this.executeArchive((e) => e.close_sheet_cursor());
363
+ } finally {
364
+ this.sessions.delete(r.sessionId), this.provisional?.stop(t), s();
365
+ }
366
+ },
367
+ resourceUsage: () => this.readResourceUsage()
368
+ }
369
+ });
370
+ this.sessions.set(r.sessionId, {
371
+ host: f,
372
+ identity: r
373
+ }), this.pendingOpens.delete(r.sessionId);
374
+ }));
375
+ this.operationTail = l.then(() => c, () => void 0);
376
+ try {
377
+ await l;
378
+ } catch (e) {
379
+ throw this.pendingOpens.delete(r.sessionId), s(), e;
380
+ }
381
+ }
382
+ async postOpenedSafely(e, t, n) {
383
+ try {
384
+ t();
385
+ } catch (t) {
386
+ await this.closeIdentity(e);
387
+ try {
388
+ n(t);
389
+ } catch {}
390
+ }
391
+ }
392
+ dispatch(e, t) {
393
+ let n = this.sessions.get(e.sessionId);
394
+ if (n) return n.host.dispatch(e, t);
395
+ let i = this.pendingOpens.get(e.sessionId);
396
+ if (i && (e.kind === "cancel" || e.kind === "close")) {
397
+ let n = i.identity.operationId === e.operationId && i.identity.generation === e.generation;
398
+ return n && (i.canceled = !0), t(n ? {
399
+ protocol: r,
400
+ kind: "accepted",
401
+ sessionId: e.sessionId,
402
+ operationId: e.operationId,
403
+ generation: e.generation,
404
+ requestId: e.requestId,
405
+ command: e.kind
406
+ } : {
407
+ protocol: r,
408
+ kind: "error",
409
+ sessionId: e.sessionId,
410
+ operationId: e.operationId,
411
+ generation: e.generation,
412
+ requestId: e.requestId,
413
+ error: {
414
+ message: "stale lifecycle targets another pending worksheet operation",
415
+ errorName: "PullSessionProtocolError",
416
+ code: "ooxml-stale-lifecycle"
417
+ }
418
+ }), Promise.resolve();
419
+ }
420
+ return e.kind === "cancel" || e.kind === "close" ? (t({
421
+ protocol: r,
422
+ kind: "accepted",
423
+ sessionId: e.sessionId,
424
+ operationId: e.operationId,
425
+ generation: e.generation,
426
+ requestId: e.requestId,
427
+ command: e.kind
428
+ }), Promise.resolve()) : (t({
429
+ protocol: r,
430
+ kind: "error",
431
+ sessionId: e.sessionId,
432
+ operationId: e.operationId,
433
+ generation: e.generation,
434
+ requestId: e.requestId,
435
+ error: a(/* @__PURE__ */ Error("worksheet pull session is not open"))
436
+ }), Promise.resolve());
437
+ }
438
+ async dispatchSafely(e, t) {
439
+ try {
440
+ await this.dispatch(e, t);
441
+ } catch (n) {
442
+ try {
443
+ t({
444
+ protocol: r,
445
+ kind: "error",
446
+ sessionId: e.sessionId,
447
+ operationId: e.operationId,
448
+ generation: e.generation,
449
+ requestId: e.requestId,
450
+ error: a(n)
451
+ });
452
+ } catch {}
453
+ }
454
+ }
455
+ run(t) {
456
+ let n = this.operationTail.then(() => this.coordinator.enqueue(async () => {
457
+ if (this.resourceFailure) throw this.resourceFailure;
458
+ return t();
459
+ })).catch((t) => {
460
+ throw t instanceof e && (this.resourceFailure ??= t), t;
461
+ });
462
+ return this.operationTail = n.then(() => void 0, () => void 0), n;
463
+ }
464
+ async reset() {
465
+ for (let e of this.pendingOpens.values()) e.canceled = !0;
466
+ let e = 1;
467
+ for (let { host: t, identity: n } of [...this.sessions.values()]) await t.dispatch({
468
+ protocol: r,
469
+ kind: "close",
470
+ ...n,
471
+ requestId: e++
472
+ }, () => void 0);
473
+ this.sessions.clear(), await this.operationTail, this.pendingOpens.clear(), this.resourceFailure = void 0;
474
+ }
475
+ requireArchive() {
476
+ let e = this.archive();
477
+ if (!e) throw Error("Workbook not loaded");
478
+ return e;
479
+ }
480
+ async closeIdentity(e) {
481
+ let t = this.sessions.get(e.sessionId);
482
+ if (t) {
483
+ await t.host.dispatch({
484
+ protocol: r,
485
+ kind: "close",
486
+ ...e,
487
+ requestId: 1
488
+ }, () => void 0);
489
+ return;
490
+ }
491
+ let n = this.pendingOpens.get(e.sessionId);
492
+ n && n.identity.operationId === e.operationId && n.identity.generation === e.generation && (n.canceled = !0);
493
+ }
494
+ readResourceUsage() {
495
+ return t(this.executeArchive((e) => e.sheet_cursor_resource_usage()));
496
+ }
497
+ }, Y = "XLSX workbook session was aborted", X = class {
498
+ options;
499
+ active = /* @__PURE__ */ new Set();
500
+ nextSessionId = 1;
501
+ constructor(e) {
502
+ if (this.options = e, e.generation !== void 0 && (!Number.isSafeInteger(e.generation) || e.generation <= 0)) throw TypeError("generation must be a positive safe integer");
503
+ }
504
+ async *stream(e, t, n) {
505
+ if (!Number.isSafeInteger(e) || e < 0) throw RangeError("sheetIndex must be a non-negative safe integer");
506
+ if (!t) throw TypeError("sheetName must be non-empty");
507
+ _(n, Y);
508
+ let r = this.nextSessionId++, a = {
509
+ sessionId: r,
510
+ operationId: r,
511
+ generation: this.options.generation ?? 1
512
+ }, o = new i(this.options.transport, {
513
+ ...a,
514
+ maxByteCredit: q,
515
+ timeoutMs: this.options.timeoutMs,
516
+ disposeTransferred: this.options.disposeTransferred
517
+ });
518
+ this.active.add(o);
519
+ let s = !1, c;
520
+ try {
521
+ for (await this.options.open(e, t, a, this.options.timeoutMs);;) {
522
+ _(n, Y);
523
+ let e = await o.pull(q, { signal: n });
524
+ try {
525
+ let t = e.usage ?? o.usageCheckpoint;
526
+ t && this.options.onUsage?.(t);
527
+ let r = K(e.payload, e.done, this.options.sharedStrings);
528
+ if (yield r.kind === "preview" ? {
529
+ ...r,
530
+ sequence: e.sequence,
531
+ wireBytes: e.byteLength,
532
+ usage: t
533
+ } : r.kind === "rows" ? {
534
+ kind: "rows",
535
+ rows: r.rows,
536
+ sequence: e.sequence,
537
+ wireBytes: e.byteLength,
538
+ usage: t
539
+ } : {
540
+ kind: "finished",
541
+ worksheet: r.worksheet,
542
+ sequence: e.sequence,
543
+ wireBytes: e.byteLength,
544
+ usage: t
545
+ }, await e.ack({ signal: n }), r.kind === "finished") {
546
+ s = !0;
547
+ return;
548
+ }
549
+ } finally {
550
+ e.disposeTransferred();
551
+ }
552
+ }
553
+ } catch (e) {
554
+ throw c = e, e;
555
+ } finally {
556
+ let e;
557
+ try {
558
+ s || await o.cancel(Q(c));
559
+ } catch (t) {
560
+ e = t;
561
+ } finally {
562
+ this.active.delete(o);
563
+ }
564
+ if (c === void 0 && e !== void 0) throw e;
565
+ }
566
+ }
567
+ async cancelAll(e = "closed") {
568
+ let t = (await Promise.allSettled([...this.active].map((t) => t.cancel(e)))).find((e) => e.status === "rejected");
569
+ if (t) throw t.reason;
570
+ }
571
+ };
572
+ function Z(e) {
573
+ return !!e && typeof e == "object" && e.protocol === "ooxml-pull-v1";
574
+ }
575
+ function Q(e) {
576
+ return e && typeof e == "object" && "name" in e && e.name === "AbortError" ? "abort" : e === void 0 ? "closed" : "request-error";
577
+ }
578
+ //#endregion
579
+ export { x as S, A as _, U as a, E as b, L as c, B as d, I as f, k as g, z as h, K as i, H as l, F as m, Z as n, M as o, P as p, J as r, R as s, X as t, V as u, j as v, D as x, w as y };