@silurus/ooxml 0.86.1 → 0.87.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 +42 -2
- package/dist/assets/render-worker-CeK_iqK3.js +10 -0
- package/dist/assets/render-worker-DusrDhPk.js +11 -0
- package/dist/assets/render-worker-n2ZG0lrQ.js +31 -0
- package/dist/{canvas-viewer-mechanics-DN5SqWGS.js → canvas-viewer-mechanics-Cpk0YFvM.js} +74 -65
- package/dist/chart-ex.mjs +1 -1
- package/dist/cjk-fallback-bLI3z70h.js +46 -0
- package/dist/{comment-ui-runtime-lXwVOgjW.js → comment-ui-runtime-BfE7MJZn.js} +4 -4
- package/dist/comment-ui-runtime-BsK8pmUT.js +2 -0
- package/dist/{comment-ui-runtime-DEtgcmj7.js → comment-ui-runtime-DcJOYlw-.js} +5 -5
- package/dist/{comments-CAn2A_Xh.js → comments-Diid5ujN.js} +1 -1
- package/dist/{document-pull-client-uopDjRde.js → document-pull-client-yKxI8aDH.js} +4588 -4545
- package/dist/{docx-wPzeF76A.js → docx-BkSRiy07.js} +318 -311
- package/dist/docx.mjs +5 -5
- package/dist/docx_parser_bg.wasm +0 -0
- package/dist/{dom-interaction-boundary-CswB9Tzi.js → dom-interaction-boundary-CBUQJsIM.js} +22 -19
- package/dist/{hyperlink-BR1NCO7S.js → hyperlink-ArrU3ArU.js} +771 -757
- package/dist/index.mjs +3 -3
- package/dist/{line-distribute-IsUGfHXm.js → line-distribute-Dtudnqhs.js} +1 -1
- package/dist/math.mjs +2 -2
- package/dist/node.mjs +356 -352
- package/dist/{pptx-BxJ_RBSY.js → pptx-62MmVbYB.js} +442 -435
- package/dist/pptx.mjs +7 -7
- package/dist/pptx_parser_bg.wasm +0 -0
- package/dist/region-map.mjs +1 -1
- package/dist/{render-DEiun_AH.js → render-8Zo7dnds.js} +31 -29
- package/dist/{render-worker-host-Ba6Fchqr.js → render-worker-host-BfbnEChF.js} +1 -1
- package/dist/{render-worker-host-BEfLZvSL.js → render-worker-host-DNL9dWRh.js} +1 -1
- package/dist/{render-worker-host-C3xwtHnv.js → render-worker-host-IkHrYOci.js} +1 -1
- package/dist/{resource-measurement-CclArDRs.js → resource-measurement-CJsgolre.js} +1 -1
- package/dist/{session-BuJL_xcp.js → session-CrU8f8DI.js} +98 -98
- package/dist/{slide-pull-client-Ck8wfRT_.js → slide-pull-client-B9KA8bU6.js} +773 -744
- package/dist/three-d.mjs +1 -1
- package/dist/tiff.mjs +1 -1
- package/dist/types/chart-ex.d.ts +2 -2
- package/dist/types/docx.d.ts +15 -11
- package/dist/types/index.d.ts +23 -17
- package/dist/types/math.d.ts +1 -1
- package/dist/types/node.d.ts +12 -6
- package/dist/types/pptx.d.ts +15 -11
- package/dist/types/region-map.d.ts +2 -2
- package/dist/types/three-d.d.ts +2 -2
- package/dist/types/tiff.d.ts +1 -1
- package/dist/types/xlsx.d.ts +15 -11
- package/dist/{worksheet-pull-client-CAvuf22q.js → worksheet-pull-client-eIcQ-xlD.js} +51 -51
- package/dist/{xlsx-Bblm5r1h.js → xlsx-CRcSzZNq.js} +1589 -1563
- package/dist/xlsx.mjs +5 -5
- package/dist/xlsx_parser_bg.wasm +0 -0
- package/package.json +1 -1
- package/dist/assets/render-worker-D21h5TGR.js +0 -10
- package/dist/assets/render-worker-Dsfekaht.js +0 -11
- package/dist/assets/render-worker-DxU7IrKo.js +0 -31
- package/dist/comment-ui-runtime-TLHustXJ.js +0 -2
- /package/dist/{bounded-raw-part-cache-BfbSxRIL.js → bounded-raw-part-cache-Cg1BsSZQ.js} +0 -0
- /package/dist/{comment-occurrence-CqejEuts.js → comment-occurrence-C8Y2uoVr.js} +0 -0
- /package/dist/{delimited-text-worker-host-DcHj_JZt.js → delimited-text-worker-host-BVY-Ecni.js} +0 -0
- /package/dist/{highlight-rect-FuUSmL3a.js → highlight-rect-C5hkRqUr.js} +0 -0
- /package/dist/{line-metrics-CBbw80Ko.js → line-metrics-B60C86uh.js} +0 -0
- /package/dist/{mathjax-DS69BmJd.js → mathjax-DoyWZbSp.js} +0 -0
- /package/dist/{read-only-comment-decoration-BTnWEeo5.js → read-only-comment-decoration-Dz7eTQ4d.js} +0 -0
- /package/dist/{read-only-comment-margin-plStyGfE.js → read-only-comment-margin-DkgzASAl.js} +0 -0
- /package/dist/{renderer-module-contract-Cu-GKuPd.js → renderer-module-contract-D91rkYHH.js} +0 -0
- /package/dist/{source-key-Ktb1GRE5.js → source-key-DIJG8BA0.js} +0 -0
- /package/dist/{transfer-mIj7E7NB.js → transfer-p6iCC2R7.js} +0 -0
- /package/dist/{visible-index-DPoQYSDt.js → visible-index-BgiHEc1z.js} +0 -0
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { t as e } from "./chunk-DmhlhrBa.js";
|
|
2
|
-
import { $ as t,
|
|
3
|
-
import { C as p, D as m, M as h, N as g, O as _, S as v, T as y, _ as b, a as x, b as ee, c as S, d as te, f as ne, g as re, h as ie, i as C, l as w, m as ae, n as oe, o as se, p as ce, r as le, s as ue, t as de, u as fe, v as pe, w as me, x as he, y as ge } from "./canvas-viewer-mechanics-
|
|
4
|
-
import { c as _e, d as ve,
|
|
5
|
-
import { A as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { n as
|
|
11
|
-
import { t as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
2
|
+
import { $ as t, $t as n, L as r, R as i, U as a, _t as o, ft as s, ln as c, lt as l, r as u, un as d, z as f } from "./hyperlink-ArrU3ArU.js";
|
|
3
|
+
import { C as p, D as m, M as h, N as g, O as _, S as v, T as y, _ as b, a as x, b as ee, c as S, d as te, f as ne, g as re, h as ie, i as C, l as w, m as ae, n as oe, o as se, p as ce, r as le, s as ue, t as de, u as fe, v as pe, w as me, x as he, y as ge } from "./canvas-viewer-mechanics-Cpk0YFvM.js";
|
|
4
|
+
import { c as _e, d as ve, f as ye, i as be, l as xe, n as Se, o as T, r as Ce, s as we, t as Te, u as Ee } from "./dom-interaction-boundary-CBUQJsIM.js";
|
|
5
|
+
import { A as De, C as E, D as Oe, E as ke, M as Ae, O as D, S as je, T as Me, _ as Ne, a as Pe, b as Fe, c as Ie, d as Le, f as Re, g as ze, h as Be, j as Ve, k as He, l as Ue, m as We, n as Ge, o as Ke, p as qe, s as Je, t as O, v as Ye, w as Xe, x as Ze, y as Qe } from "./document-pull-client-yKxI8aDH.js";
|
|
6
|
+
import { n as $e } from "./cjk-fallback-bLI3z70h.js";
|
|
7
|
+
import { l as et, s as tt } from "./pixel-budget-Dgjw269h.js";
|
|
8
|
+
import { a as k } from "./units-EJdC96r6.js";
|
|
9
|
+
import { i as nt, s as rt } from "./raster-target-ojDdQizC.js";
|
|
10
|
+
import { n as it } from "./renderer-module-contract-D91rkYHH.js";
|
|
11
|
+
import { n as at, t as A } from "./highlight-rect-C5hkRqUr.js";
|
|
12
|
+
import { t as ot } from "./bounded-raw-part-cache-Cg1BsSZQ.js";
|
|
13
|
+
import { o as j } from "./source-key-DIJG8BA0.js";
|
|
14
|
+
import { i as st, n as M, r as ct, t as lt } from "./comments-Diid5ujN.js";
|
|
14
15
|
//#region packages/core/src/fonts/open-type-metrics.ts
|
|
15
|
-
var
|
|
16
|
+
var N = (e) => (e.charCodeAt(0) << 24 >>> 0 | e.charCodeAt(1) << 16 | e.charCodeAt(2) << 8 | e.charCodeAt(3)) >>> 0, ut = N("ttcf"), dt = N("OTTO"), ft = N("true"), pt = N("typ1"), mt = N("head"), ht = N("hhea"), gt = N("OS/2"), _t = N("cmap"), P = [
|
|
16
17
|
[4352, 4607],
|
|
17
18
|
[11904, 12287],
|
|
18
19
|
[12352, 12543],
|
|
@@ -28,10 +29,10 @@ var P = (e) => (e.charCodeAt(0) << 24 >>> 0 | e.charCodeAt(1) << 16 | e.charCode
|
|
|
28
29
|
[63744, 64255],
|
|
29
30
|
[131072, 205743]
|
|
30
31
|
];
|
|
31
|
-
function
|
|
32
|
+
function F(e, t, n) {
|
|
32
33
|
return Number.isSafeInteger(t) && Number.isSafeInteger(n) && t >= 0 && n >= 0 && t <= e - n;
|
|
33
34
|
}
|
|
34
|
-
function
|
|
35
|
+
function vt(e, t, n) {
|
|
35
36
|
if (n < 16) return !1;
|
|
36
37
|
let r = e.getUint16(t + 2);
|
|
37
38
|
if (r < 16 || r > n) return !1;
|
|
@@ -47,7 +48,7 @@ function ht(e, t, n) {
|
|
|
47
48
|
}
|
|
48
49
|
for (let n = 0; n < a; n++) {
|
|
49
50
|
let i = e.getUint16(s + n * 2), a = e.getUint16(o + n * 2), u = e.getInt16(c + n * 2), d = l + n * 2, f = e.getUint16(d);
|
|
50
|
-
for (let [n, o] of
|
|
51
|
+
for (let [n, o] of P) {
|
|
51
52
|
let s = Math.max(i, n), c = Math.min(a, o);
|
|
52
53
|
if (!(s > c)) {
|
|
53
54
|
if (f === 0) {
|
|
@@ -65,7 +66,7 @@ function ht(e, t, n) {
|
|
|
65
66
|
}
|
|
66
67
|
return !1;
|
|
67
68
|
}
|
|
68
|
-
function
|
|
69
|
+
function yt(e, t, n, r) {
|
|
69
70
|
if (n < 16) return !1;
|
|
70
71
|
let i = e.getUint32(t + 4), a = e.getUint32(t + 12);
|
|
71
72
|
if (i < 16 || i > n || a > (i - 16) / 12) return !1;
|
|
@@ -73,8 +74,8 @@ function gt(e, t, n, r) {
|
|
|
73
74
|
for (let n = 0; n < a; n++) {
|
|
74
75
|
let i = t + 16 + n * 12, a = e.getUint32(i), s = e.getUint32(i + 4), c = e.getUint32(i + 8);
|
|
75
76
|
if (a > s || s > 1114111 || a <= o) return !1;
|
|
76
|
-
if (o = s, a >
|
|
77
|
-
for (let [e, t] of
|
|
77
|
+
if (o = s, a > P[P.length - 1][1]) break;
|
|
78
|
+
for (let [e, t] of P) {
|
|
78
79
|
let n = Math.max(a, e), i = Math.min(s, t);
|
|
79
80
|
if (!(n > i)) {
|
|
80
81
|
if (r) {
|
|
@@ -85,7 +86,7 @@ function gt(e, t, n, r) {
|
|
|
85
86
|
}
|
|
86
87
|
return !1;
|
|
87
88
|
}
|
|
88
|
-
function
|
|
89
|
+
function bt(e, t) {
|
|
89
90
|
if (!t || t.length < 4) return !1;
|
|
90
91
|
let n = e.getUint16(t.offset + 2);
|
|
91
92
|
if (4 + n * 8 > t.length) return !1;
|
|
@@ -95,44 +96,44 @@ function _t(e, t) {
|
|
|
95
96
|
let o = e.getUint32(n + 4);
|
|
96
97
|
if (o > t.length - 2) continue;
|
|
97
98
|
let s = t.offset + o, c = t.length - o, l = e.getUint16(s);
|
|
98
|
-
if (l === 4 &&
|
|
99
|
+
if (l === 4 && vt(e, s, c) || l === 12 && yt(e, s, c, !1) || l === 13 && yt(e, s, c, !0)) return !0;
|
|
99
100
|
}
|
|
100
101
|
return !1;
|
|
101
102
|
}
|
|
102
|
-
function
|
|
103
|
+
function xt(e, t) {
|
|
103
104
|
if (t !== void 0 && (!Number.isSafeInteger(t) || t < 0) || e.byteLength < 12) return null;
|
|
104
105
|
let n = new DataView(e.buffer, e.byteOffset, e.byteLength), r = 0;
|
|
105
|
-
if (n.getUint32(0) ===
|
|
106
|
+
if (n.getUint32(0) === ut) {
|
|
106
107
|
if (t === void 0 || e.byteLength < 12) return null;
|
|
107
108
|
let i = n.getUint32(8);
|
|
108
|
-
if (t >= i || !
|
|
109
|
+
if (t >= i || !F(e.byteLength, 12, i * 4)) return null;
|
|
109
110
|
r = n.getUint32(12 + t * 4);
|
|
110
111
|
} else if (t !== void 0 && t !== 0) return null;
|
|
111
|
-
if (!
|
|
112
|
+
if (!F(e.byteLength, r, 12)) return null;
|
|
112
113
|
let i = n.getUint32(r);
|
|
113
|
-
if (i !== 65536 && i !==
|
|
114
|
+
if (i !== 65536 && i !== dt && i !== ft && i !== pt) return null;
|
|
114
115
|
let a = n.getUint16(r + 4);
|
|
115
|
-
if (!
|
|
116
|
+
if (!F(e.byteLength, r + 12, a * 16)) return null;
|
|
116
117
|
let o = /* @__PURE__ */ new Map();
|
|
117
118
|
for (let t = 0; t < a; t++) {
|
|
118
119
|
let i = r + 12 + t * 16, a = n.getUint32(i), s = n.getUint32(i + 8), c = n.getUint32(i + 12);
|
|
119
|
-
if (o.has(a) || !
|
|
120
|
+
if (o.has(a) || !F(e.byteLength, s, c)) return null;
|
|
120
121
|
o.set(a, {
|
|
121
122
|
offset: s,
|
|
122
123
|
length: c
|
|
123
124
|
});
|
|
124
125
|
}
|
|
125
|
-
let s = o.get(
|
|
126
|
+
let s = o.get(mt), c = o.get(ht);
|
|
126
127
|
if (!s || s.length < 20 || !c || c.length < 10) return null;
|
|
127
128
|
let l = n.getUint16(s.offset + 18);
|
|
128
129
|
if (l < 16 || l > 16384) return null;
|
|
129
|
-
let u = o.get(
|
|
130
|
+
let u = o.get(gt), d = u !== void 0 && u.length >= 78;
|
|
130
131
|
return Object.freeze({
|
|
131
132
|
unitsPerEm: l,
|
|
132
133
|
hheaAscent: n.getInt16(c.offset + 4),
|
|
133
134
|
hheaDescent: n.getInt16(c.offset + 6),
|
|
134
135
|
hheaLineGap: n.getInt16(c.offset + 8),
|
|
135
|
-
hasEastAsianCmap:
|
|
136
|
+
hasEastAsianCmap: bt(n, o.get(_t)),
|
|
136
137
|
...d ? {
|
|
137
138
|
typoAscent: n.getInt16(u.offset + 68),
|
|
138
139
|
typoDescent: n.getInt16(u.offset + 70),
|
|
@@ -145,11 +146,11 @@ function vt(e, t) {
|
|
|
145
146
|
}
|
|
146
147
|
//#endregion
|
|
147
148
|
//#region packages/docx/src/worker.ts?worker&inline
|
|
148
|
-
var yt = "var e=(e,t)=>()=>(e&&(t=e(e=0)),t),t=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,r.unregister(this),e}free(){let e=this.__destroy_into_raw();v.__wbg_docxarchive_free(e,0)}acknowledge_document_chunk(e,t,n){let r=v.docxarchive_acknowledge_document_chunk(this.__wbg_ptr,e,t,n);if(r[1])throw p(r[0])}assert_healthy(){let e=v.docxarchive_assert_healthy(this.__wbg_ptr);if(e[1])throw p(e[0])}cancel_document_cursor(){v.docxarchive_cancel_document_cursor(this.__wbg_ptr)}close_document_session(){v.docxarchive_close_document_session(this.__wbg_ptr)}document_chunk_done(){let e=v.docxarchive_document_chunk_done(this.__wbg_ptr);if(e[2])throw p(e[1]);return e[0]!==0}document_cursor_resource_usage(){let e=v.docxarchive_document_cursor_resource_usage(this.__wbg_ptr);if(e[3])throw p(e[2]);var t=i(e[0],e[1]).slice();return v.__wbindgen_free(e[0],e[1]*1,1),t}extract_image(e){let t=f(e,v.__wbindgen_malloc,v.__wbindgen_realloc),n=_,r=v.docxarchive_extract_image(this.__wbg_ptr,t,n);if(r[3])throw p(r[2]);var a=i(r[0],r[1]).slice();return v.__wbindgen_free(r[0],r[1]*1,1),a}constructor(e,t,n,i){let a=d(e,v.__wbindgen_malloc),o=_,s=v.docxarchive_new(a,o,!u(t),u(t)?BigInt(0):t,!u(n),u(n)?BigInt(0):n,!u(i),u(i)?BigInt(0):i);if(s[2])throw p(s[1]);return this.__wbg_ptr=s[0]>>>0,r.register(this,this.__wbg_ptr,this),this}open_document_cursor(e,t){let n=v.docxarchive_open_document_cursor(this.__wbg_ptr,e,t);if(n[1])throw p(n[0])}parse(){let e=v.docxarchive_parse(this.__wbg_ptr);if(e[3])throw p(e[2]);var t=i(e[0],e[1]).slice();return v.__wbindgen_free(e[0],e[1]*1,1),t}pull_document_chunk(e,t,n,r){let a=v.docxarchive_pull_document_chunk(this.__wbg_ptr,e,t,n,r);if(a[3])throw p(a[2]);var o=i(a[0],a[1]).slice();return v.__wbindgen_free(a[0],a[1]*1,1),o}resource_usage(){let e=v.docxarchive_resource_usage(this.__wbg_ptr);if(e[3])throw p(e[2]);var t=i(e[0],e[1]).slice();return v.__wbindgen_free(e[0],e[1]*1,1),t}to_markdown(){let e,t;try{let i=v.docxarchive_to_markdown(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,p(i[2]);return e=n,t=r,s(n,r)}finally{v.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(t.prototype[Symbol.dispose]=t.prototype.free);function n(){return{__proto__:null,\"./docx_parser_bg.js\":{__proto__:null,__wbg___wbindgen_throw_6b64449b9b9ed33c:function(e,t){throw Error(s(e,t))},__wbg_error_a6fa202b58aa1cd3:function(e,t){let n,r;try{n=e,r=t,console.error(s(e,t))}finally{v.__wbindgen_free(n,r,1)}},__wbg_new_227d7c05414eb861:function(){return Error()},__wbg_stack_3b0d974bbf31e44f:function(e,t){let n=t.stack,r=f(n,v.__wbindgen_malloc,v.__wbindgen_realloc),i=_;o().setInt32(e+4,i,!0),o().setInt32(e+0,r,!0)},__wbindgen_cast_0000000000000001:function(e,t){return s(e,t)},__wbindgen_init_externref_table:function(){let e=v.__wbindgen_externrefs,t=e.grow(4);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)}}}}const r=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>v.__wbg_docxarchive_free(e>>>0,1));function i(e,t){return e>>>=0,l().subarray(e/1,e/1+t)}let a=null;function o(){return(a===null||a.buffer.detached===!0||a.buffer.detached===void 0&&a.buffer!==v.memory.buffer)&&(a=new DataView(v.memory.buffer)),a}function s(e,t){return e>>>=0,ee(e,t)}let c=null;function l(){return(c===null||c.byteLength===0)&&(c=new Uint8Array(v.memory.buffer)),c}function u(e){return e==null}function d(e,t){let n=t(e.length*1,1)>>>0;return l().set(e,n/1),_=e.length,n}function f(e,t,n){if(n===void 0){let n=g.encode(e),r=t(n.length,1)>>>0;return l().subarray(r,r+n.length).set(n),_=n.length,r}let r=e.length,i=t(r,1)>>>0,a=l(),o=0;for(;o<r;o++){let t=e.charCodeAt(o);if(t>127)break;a[i+o]=t}if(o!==r){o!==0&&(e=e.slice(o)),i=n(i,r,r=o+e.length*3,1)>>>0;let t=l().subarray(i+o,i+r),a=g.encodeInto(e,t);o+=a.written,i=n(i,r,o,1)>>>0}return _=o,i}function p(e){let t=v.__wbindgen_externrefs.get(e);return v.__externref_table_dealloc(e),t}let m=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0});m.decode();let h=0;function ee(e,t){return h+=t,h>=2146435072&&(m=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}),m.decode(),h=t),m.decode(l().subarray(e,e+t))}const g=new TextEncoder;`encodeInto`in g||(g.encodeInto=function(e,t){let n=g.encode(e);return t.set(n),{read:e.length,written:n.length}});let _=0,v;function te(e,t){return v=e.exports,a=null,c=null,v.__wbindgen_start(),v}async function ne(e,t){if(typeof Response==`function`&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming==`function`)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if(e.ok&&n(e.type)&&e.headers.get(`Content-Type`)!==`application/wasm`)console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\",t);else throw t}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}function n(e){switch(e){case`basic`:case`cors`:case`default`:return!0}return!1}}async function y(e){if(v!==void 0)return v;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`));let t=n();(typeof e==`string`||typeof Request==`function`&&e instanceof Request||typeof URL==`function`&&e instanceof URL)&&(e=fetch(e));let{instance:r,module:i}=await ne(await e,t);return te(r,i)}async function b(e){return v=void 0,a=null,c=null,y(e)}var x=class e extends Error{code;constructor(t,n){super(n),this.name=`OoxmlError`,this.code=t,Object.setPrototypeOf(this,e.prototype)}},S=class e extends Error{code=`ooxml-resource-limit`;details;constructor(t,n){super(t),this.name=`OoxmlResourceLimitError`;let r=n.violation,i=Object.freeze({format:r.format,operation:r.operation,resource:r.resource,metric:r.metric,...r.part===void 0?{}:{part:r.part},limit:r.limit,observed:r.observed,configurable:r.configurable,usage:Object.freeze({archiveEntryCount:r.usage.archiveEntryCount,declaredInflatedBytes:r.usage.declaredInflatedBytes,...r.usage.largestInflatedEntryBytes===void 0?{}:{largestInflatedEntryBytes:r.usage.largestInflatedEntryBytes},distinctInflatedBytes:r.usage.distinctInflatedBytes,operationInflatedBytes:r.usage.operationInflatedBytes})});this.details=Object.freeze({stage:n.stage,violation:i}),Object.setPrototypeOf(this,e.prototype)}};function re(e){return e===`image-dimension`||e===`image-pixels`||e===`active-decoded-bytes`}function C(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function ie(e){if(!(!e||typeof e!=`object`))try{let t=e,n=t.code,r=t.metric,i=t.limit,a=t.observed;return n!==`ooxml-decoded-image-limit`||!re(r)||!C(i)||!C(a)||a<=i?void 0:{metric:r,limit:i,observed:a}}catch{return}}var w,T,E,D=e((()=>{w=1<<25,T=1<<27,w*4,T*4,E=class e extends RangeError{code=`ooxml-decoded-image-limit`;constructor(t,n,r){super(`OOXML decoded image limit exceeded: ${t} ${r} > ${n}`),this.metric=t,this.limit=n,this.observed=r,this.name=`OoxmlDecodedImageLimitError`,Object.setPrototypeOf(this,e.prototype)}}}));function O(e){if(!(typeof e!=`object`||!e))try{let t=e,n=t.code,r=t.message;return n===`ooxml-tiff-decode`&&typeof r==`string`?{message:r}:void 0}catch{return}}var ae=e((()=>{}));function oe(e){if(!e.startsWith(`data:`))return null;let t=e.indexOf(`,`);if(t===-1)return null;let n=atob(e.slice(t+1)),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r.buffer}var se=class{state=`uninitialized`;generationValue=0;readiness;poisonListeners=new Set;constructor(e,t,n){this.initialize=e,this.reinitialize=t,this.normalizeFailure=n}get generation(){return this.generationValue}get poisoned(){return this.state===`poisoned`}onPoison(e){return this.poisonListeners.add(e),()=>this.poisonListeners.delete(e)}async ensureReady(){if(this.state!==`ready`){if(!this.readiness){let e=this.state===`uninitialized`?this.initialize:this.reinitialize;this.readiness=Promise.resolve().then(e).then(()=>{this.generationValue+=1,this.state=`ready`,this.readiness=void 0},e=>{throw this.readiness=void 0,e})}await this.readiness}}run(e){try{return e()}catch(e){let t=this.normalizeFailure(e);throw t?(this.poison(t),t):e}}tryRunReady(e){if(this.state!==`ready`)return{current:!1};let t=this.generationValue,n=this.run(e);return this.state!==`ready`||t!==this.generationValue?{current:!1}:{current:!0,generation:t,value:n}}poison(e){this.state=`poisoned`,this.readiness=void 0;for(let t of this.poisonListeners)t(e)}assertCurrent(e){if(this.state!==`ready`||e!==this.generationValue)throw Error(`WASM archive session belongs to a discarded runtime generation`)}},k=class e extends Error{code=`parser-crashed`;constructor(t){super(t),this.name=`WasmTrapError`,Object.setPrototypeOf(this,e.prototype)}};function ce(e){let t=globalThis.WebAssembly?.RuntimeError;return t&&e instanceof t||e instanceof RangeError?!0:e instanceof Error?e.name===`RuntimeError`||e.name===`CompileError`||e.name===`LinkError`||e.name===`InternalError`||e.name===`OOMError`:!1}function le(e){try{if((typeof e!=`object`||!e)&&typeof e!=`function`)return;let t=Reflect.get(e,`__destroy_into_raw`);typeof t==`function`&&Reflect.apply(t,e,[])}catch{}}function ue(e,t){return e({module_or_path:t})}var de=class{runtime;wasmInput=null;currentArchive=null;constructor(e,t={}){this.init=e,this.options=t,this.runtime=new se(()=>this.invokeConfigured(this.init),()=>this.invokeConfigured(this.options.reinit??this.init),fe),this.runtime.onPoison(()=>this.dropPoisonedArchive())}setWasmInput(e){this.wasmInput=e,this.runtime.ensureReady().catch(()=>void 0)}setWasmUrl(e){this.setWasmInput(e)}get archive(){return this.currentArchive}setArchive(e){this.freeArchive(),this.currentArchive=e}disposeArchive(){this.freeArchive()}get poisoned(){return this.runtime.poisoned}async ensureReady(){await this.runtime.ensureReady()}run(e){return this.runtime.run(e)}poison(){this.runtime.poison(new k(`WASM parser was recycled`))}invokeConfigured(e){return this.wasmInput===null?Promise.reject(Error(`WasmParserHost: setWasmInput was never called`)):ue(e,this.wasmInput)}freeArchive(){this.currentArchive!==null&&this.options.freeArchive&&this.options.freeArchive(this.currentArchive),this.currentArchive=null}dropPoisonedArchive(){let e=this.currentArchive;this.currentArchive=null,le(e)}};function fe(e){return ce(e)?new k(`WASM parser trapped and was recycled: ${e instanceof Error?e.message:String(e)}`):null}function A(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>0}function pe(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return A(t.requiredBytes)&&A(t.offeredBytes)&&t.requiredBytes>t.offeredBytes}var j=class e extends RangeError{code=`ooxml-insufficient-credit`;requiredBytes;offeredBytes;constructor(t){super(`Pull unit requires ${t.requiredBytes} bytes but credit is ${t.offeredBytes}`),this.name=`PullSessionInsufficientCreditError`,this.requiredBytes=t.requiredBytes,this.offeredBytes=t.offeredBytes,Object.setPrototypeOf(this,e.prototype)}};function M(e){if(e instanceof j)return e;let t=e instanceof Error?e.message:String(e);if(!t.startsWith(`OOXML_INSUFFICIENT_CREDIT:`))return;let n;try{n=JSON.parse(t.slice(26))}catch{return}if(!n||typeof n!=`object`||Array.isArray(n))return;let r=n;if(!(r.code!==`ooxml-insufficient-credit`||!pe(r)))return new j(r)}function me(e,t,n){let r=M(e);if(!(!r||r.offeredBytes!==t||r.requiredBytes>n))return r}D(),ae();const N=`OOXML_RESOURCE_LIMIT:`;function P(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function F(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return P(t.archiveEntryCount)&&P(t.declaredInflatedBytes)&&(t.largestInflatedEntryBytes===void 0||P(t.largestInflatedEntryBytes))&&P(t.distinctInflatedBytes)&&P(t.operationInflatedBytes)}function I(e){let t;try{t=JSON.parse(new TextDecoder().decode(e))}catch{throw TypeError(`OOXML resource usage checkpoint is not valid JSON`)}if(!F(t))throw TypeError(`OOXML resource usage checkpoint is invalid`);return t}function L(e){return e===`docx`||e===`xlsx`||e===`pptx`}function R(e){return e===`container`||e===`decompression`||e===`parsing`||e===`serialization`||e===`layout`||e===`rendering`||e===`worker`}function z(e,t){return typeof e==`string`&&e.length>0&&e.length<=t&&!/[\\u0000-\\u001f\\u007f]/u.test(e)}function B(e){return z(e,128)&&/^[a-z0-9][a-z0-9-]*$/u.test(e)}function he(e){return!z(e,4096)||e.startsWith(`/`)||e.startsWith(`\\\\`)||e.includes(`\\\\`)||e.includes(`?`)||e.includes(`#`)||e.includes(`://`)||/^[a-z]:/iu.test(e)?!1:e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`)}const V=new Map([[`archive-entry:declared-inflated-bytes`,{stage:`container`,part:`required`}],[`archive-entry:actual-inflated-bytes`,{stage:`decompression`,part:`required`}],[`archive:entry-count`,{stage:`container`,part:`forbidden`}],[`archive:central-directory-bytes`,{stage:`container`,part:`forbidden`,configurable:!1}],[`archive:distinct-inflated-bytes`,{stage:`decompression`,part:`required`}],[`xml-event:bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`xml-context:bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`xml-tree:depth`,{stage:`parsing`,part:`optional`,configurable:!1}],[`worksheet-row:projected-bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`worksheet-shell:projected-bytes`,{stage:`parsing`,part:`optional`,configurable:!1}]]),ge=new Set([...V.keys()].map(e=>e.slice(0,e.indexOf(`:`)))),_e=new Set([...V.keys()].map(e=>e.slice(e.indexOf(`:`)+1)));function ve(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return!L(t.format)||!z(t.operation,256)||!B(t.resource)||!B(t.metric)||!P(t.limit)||!P(t.observed)||typeof t.configurable!=`boolean`||!F(t.usage)?!1:!(`part`in t)||he(t.part)}function H(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;if(!R(t.stage)||!ve(t.violation))return!1;let n=t.violation,r=V.get(`${n.resource}:${n.metric}`);return r?t.stage!==r.stage||r.configurable===!1&&n.configurable!==!1?!1:r.part===`required`?n.part!==void 0:r.part===`forbidden`?n.part===void 0:!0:!(ge.has(n.resource)&&_e.has(n.metric))}function ye(e){return{archiveEntryCount:e.archiveEntryCount,declaredInflatedBytes:e.declaredInflatedBytes,...e.largestInflatedEntryBytes===void 0?{}:{largestInflatedEntryBytes:e.largestInflatedEntryBytes},distinctInflatedBytes:e.distinctInflatedBytes,operationInflatedBytes:e.operationInflatedBytes}}function be(e){if(!H(e))return;let t=e.violation,n={stage:e.stage,violation:{format:t.format,operation:t.operation,resource:t.resource,metric:t.metric,...t.part===void 0?{}:{part:t.part},limit:t.limit,observed:t.observed,configurable:t.configurable,usage:ye(t.usage)}};return H(n)?n:void 0}function U(e){let t=e.violation;return`OOXML resource limit exceeded${t.part?` for ${t.part}`:``}: ${t.metric} ${t.observed} > ${t.limit}`}function xe(e){let t=e instanceof Error?e.message:String(e);if(!t.startsWith(N))return;let n;try{n=JSON.parse(t.slice(21))}catch{return}if(!n||typeof n!=`object`)return;let r=n;if(!(r.code!==`ooxml-resource-limit`||!H(r.details)))return new S(U(r.details),r.details)}function Se(e){let t=ie(e);if(t){let e=new E(t.metric,t.limit,t.observed);return{message:e.message,errorName:e.name,code:e.code,decodedImage:t}}let n=O(e);if(n)return{message:n.message,errorName:`TiffDecodeError`,code:`ooxml-tiff-decode`};let r=M(e);if(r)return{message:r.message,errorName:r.name,code:r.code,insufficientCredit:{requiredBytes:r.requiredBytes,offeredBytes:r.offeredBytes}};let i=e instanceof x||e instanceof S?e:xe(e);if(i instanceof S){let e=be(i.details);return e?{message:typeof i.message==`string`?i.message:U(e),errorName:`OoxmlResourceLimitError`,code:`ooxml-resource-limit`,resourceLimit:e}:{message:`Invalid OOXML resource-limit error payload`,errorName:`Error`}}if(i instanceof x)return{message:typeof i.message==`string`?i.message:String(i.message),errorName:z(i.name,128)?i.name:`OoxmlError`,...B(i.code)?{code:i.code}:{}};let a=e instanceof Error?e.message:String(e);if(typeof a==`string`&&a.startsWith(N))return{message:`Invalid OOXML resource-limit payload`,errorName:`Error`};let o=e instanceof Error?e:Error(a),s=o;return{message:typeof o.message==`string`?o.message:String(o.message),errorName:z(o.name,128)?o.name:`Error`,...typeof s.code==`string`?{code:s.code}:{}}}function W(e){try{return Se(e)}catch{return{message:`Worker operation failed with an unreadable error`,errorName:`Error`}}}function Ce(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength&&e.buffer instanceof ArrayBuffer?e.buffer:e.slice().buffer}Object.freeze({maxArchiveEntryBytes:134217728,maxTotalInflatedBytes:268435456,maxArchiveEntries:4096});function we(e){return[e.maxArchiveEntryBytes===null?0n:BigInt(e.maxArchiveEntryBytes),e.maxTotalInflatedBytes===null?0n:BigInt(e.maxTotalInflatedBytes),e.maxArchiveEntries===null?0n:BigInt(e.maxArchiveEntries)]}const G=`ooxml-pull-v1`;function K(e,t){if(!Number.isSafeInteger(e)||e<=0)throw RangeError(`${t} must be a positive safe integer`)}function Te(e){if(!(typeof e==`string`&&e.length>0||typeof e==`number`&&Number.isSafeInteger(e)&&e>0))throw RangeError(`session id must be a non-empty string or positive safe integer`)}var q=class{owner;queue=Promise.resolve();leases=new Map;retainedBytes=0;retainedCount=0;maxRetainedBytes;maxRetainedCount;cleanups=new Set;pendingFatalCleanups=[];poisonRunning=!1;fatal;constructor(e){this.maxRetainedBytes=e?.maxRetainedBytes??64*1024*1024,this.maxRetainedCount=e?.maxRetainedCount??256,K(this.maxRetainedBytes,`max retained lease bytes`),K(this.maxRetainedCount,`max retained lease count`)}enqueue(e){let t=this.queue.then(e,e);return this.queue=t.then(()=>void 0,()=>void 0),t}acquire(e){return this.owner===void 0?(this.owner=e,!0):this.owner===e}release(e){this.owner===e&&(this.owner=void 0)}retainLease(e,t,n){if(!Number.isSafeInteger(n)||n<0)throw RangeError(`retained lease bytes are invalid`);let r=this.leases.get(e)??new Map;if(r.has(t))throw Error(`driver returned a duplicate lease id`);if(this.retainedCount+1>this.maxRetainedCount)throw RangeError(`retained lease count exceeds limit`);if(this.retainedBytes+n>this.maxRetainedBytes)throw RangeError(`retained lease bytes exceed limit`);r.set(t,n),this.leases.set(e,r),this.retainedCount++,this.retainedBytes+=n}releaseLease(e,t){let n=this.leases.get(e),r=n?.get(t);r!==void 0&&(n?.delete(t),n?.size===0&&this.leases.delete(e),this.retainedCount--,this.retainedBytes-=r)}registerCleanup(e){return this.fatal?(this.poisonRunning?this.pendingFatalCleanups.push(e):this.enqueue(e).catch(()=>void 0),()=>void 0):(this.cleanups.add(e),()=>this.cleanups.delete(e))}get fatalError(){return this.fatal}get registeredHostCount(){return this.cleanups.size}async poison(e){if(this.fatal??=e,this.poisonRunning)return this.fatal;this.poisonRunning=!0,this.pendingFatalCleanups.push(...this.cleanups);try{let e;for(;(e=this.pendingFatalCleanups.shift())!==void 0;)await e().catch(()=>void 0)}finally{this.poisonRunning=!1}return this.fatal}},Ee=class{options;coordinator;coordinatorOwner=Symbol(`pull-session-host`);unregisterCleanup;sequence=0;unacked;leases=new Map;activeDriverLeases=new Set;nextWireLeaseId;cancelRequested=!1;cancelComplete=!1;closeRequested=!1;closeComplete=!1;driverCancelComplete=!1;driverCloseComplete=!1;completed=!1;constructor(e){Te(e.sessionId),K(e.operationId,`operation id`),K(e.generation,`generation`),K(e.maxByteCredit,`max byte credit`),e.wireLeaseIdStart!==void 0&&K(e.wireLeaseIdStart,`wire lease id start`),this.options=e,this.coordinator=e.coordinator,this.nextWireLeaseId=e.wireLeaseIdStart??1,this.unregisterCleanup=this.coordinator.registerCleanup(()=>this.forceFatalCleanup())}dispatch(e,t){return this.coordinator.enqueue(async()=>{let n=await this.execute(e);try{t(n.response,n.transfer)}catch(e){throw await this.rollbackFailedPost(n),e}})}async rollbackFailedPost(e){let t=e.response;if(t.kind===`chunk`){let n=t.leaseId===void 0?void 0:this.leases.get(t.leaseId);try{await this.options.driver.disposeInvalidChunk?.({payload:t.payload,byteLength:t.byteLength,done:t.done,leaseId:n?.driverLeaseId,retainedBytes:n?.retainedBytes,transfer:e.transfer})}catch{}}this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);for(let[e,t]of[...this.leases])try{await this.options.driver.releaseLease?.(t.driverLeaseId)}catch{}finally{this.leases.delete(e),this.activeDriverLeases.delete(t.driverLeaseId),this.coordinator.releaseLease(this.coordinatorOwner,e)}if(this.cancelRequested=!0,!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch{}this.unregisterCleanup()}async execute(e){try{if(this.isStaleLifecycle(e)){let t=e.kind===`cancel`?`cancel`:`close`;return this.sameOperationIdentity(e)?{response:this.accepted(e,t,!0)}:{response:this.errorResponse(e,{message:`stale lifecycle targets another session or operation`,errorName:`PullSessionProtocolError`,code:`ooxml-stale-lifecycle`})}}this.validateCommandIdentity(e);let t=this.coordinator.fatalError;if(t)return e.kind===`pull`?{response:this.errorResponse(e,t)}:(e.kind===`cancel`?await this.cancel():e.kind===`close`?await this.close():e.kind===`release`&&await this.release(e.leaseId),{response:this.accepted(e,e.kind)});switch(e.kind){case`pull`:return await this.pull(e);case`ack`:return await this.ack(e.sequence),{response:this.accepted(e,`ack`)};case`release`:return await this.release(e.leaseId),{response:this.accepted(e,`release`)};case`cancel`:return await this.cancel(),{response:this.accepted(e,`cancel`)};case`close`:return await this.close(),{response:this.accepted(e,`close`)}}}catch(t){let n=W(t);return n.code===`ooxml-resource-limit`&&(n=await this.coordinator.poison(n)),{response:this.errorResponse(e,n)}}}async pull(e){if(this.closeRequested||this.cancelRequested||this.completed)throw Error(`pull session is closed`);if(this.unacked)throw Error(`previous chunk is not acknowledged`);if(!Number.isSafeInteger(e.sequence)||e.sequence<0||e.sequence!==this.sequence)throw Error(`pull command sequence mismatch`);if(this.validateHostCredit(e.byteCredit),!this.coordinator.acquire(this.coordinatorOwner))throw Error(`another operation has an unacknowledged package chunk`);let t;try{t=await this.options.driver.pull(e.byteCredit)}catch(e){throw this.coordinator.release(this.coordinatorOwner),e}let n=!1,r=!1,i,a;try{let o=this.options.driver.measureChunk(t),s=this.arrayBufferTransferBytes(t.transfer);if(o<s)throw RangeError(`measured chunk bytes are below ArrayBuffer transfer bytes`);if(a=Math.max(o,s),t.leaseId!==void 0){if(K(t.leaseId,`lease id`),t.retainedBytes===void 0)throw Error(`retained lease bytes are required`);if(this.activeDriverLeases.has(t.leaseId))throw r=!0,Error(`driver returned an active duplicate lease id`);i=this.allocateWireLeaseId(),this.coordinator.retainLease(this.coordinatorOwner,i,t.retainedBytes),this.leases.set(i,{driverLeaseId:t.leaseId,retainedBytes:t.retainedBytes}),this.activeDriverLeases.add(t.leaseId),n=!0}else if(t.retainedBytes!==void 0)throw Error(`retained lease bytes require a lease id`);if(!Number.isSafeInteger(a)||a<0)throw RangeError(`host chunk byte length must be a non-negative safe integer`);if(a>e.byteCredit)throw RangeError(`host chunk exceeds byte credit`)}catch(e){let a;try{await this.options.driver.disposeInvalidChunk?.(t)}catch(e){a=e}if(n&&i!==void 0)try{await this.release(i)}catch(e){a??=e}else if(t.leaseId!==void 0&&!r)try{await this.options.driver.releaseLease?.(t.leaseId)}catch(e){a??=e}if(r)try{await this.cancel()}catch(e){a??=e}throw this.coordinator.release(this.coordinatorOwner),a||e}return this.unacked={sequence:this.sequence,done:t.done},{response:{kind:`chunk`,protocol:G,...this.identity(),requestId:e.requestId,sequence:this.sequence,byteLength:a,done:t.done,payload:t.payload,leaseId:i,usage:this.resourceUsage()},transfer:t.transfer}}async ack(e){if(!Number.isSafeInteger(e)||e<0)throw RangeError(`invalid ack sequence`);if(e<this.sequence)return;if(!this.unacked||e!==this.sequence)throw Error(`ack sequence mismatch`);let t=this.unacked.done;await this.options.driver.acknowledge?.(e),this.unacked=void 0,this.coordinator.release(this.coordinatorOwner),this.sequence++,t&&(this.completed=!0,this.maybeUnregisterCompleted())}async release(e){K(e,`wire lease id`);let t=this.leases.get(e);t&&(await this.options.driver.releaseLease?.(t.driverLeaseId),this.leases.delete(e),this.activeDriverLeases.delete(t.driverLeaseId),this.coordinator.releaseLease(this.coordinatorOwner,e),this.maybeUnregisterCompleted())}async cancel(){if(this.cancelComplete)return;this.cancelRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;try{await this.releaseAllLeases()}catch(t){e=t}if(!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch(t){e??=t}if(e)throw e;this.cancelComplete=!0,this.unregisterCleanup()}async close(){if(this.closeComplete)return;this.closeRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;try{await this.releaseAllLeases()}catch(t){e=t}if(!this.driverCloseComplete)try{await this.options.driver.close?.(),this.driverCloseComplete=!0}catch(t){e??=t}if(e)throw e;this.closeComplete=!0,this.unregisterCleanup()}async releaseAllLeases(){let e;for(let t of[...this.leases.keys()])try{await this.release(t)}catch(t){e??=t}if(e)throw e}validateCommandIdentity(e){if(e.protocol!==`ooxml-pull-v1`||e.sessionId!==this.options.sessionId||e.operationId!==this.options.operationId||e.generation!==this.options.generation||!Number.isSafeInteger(e.requestId)||e.requestId<=0)throw Error(`stale or mismatched pull session command`)}validateHostCredit(e){if(K(e,`byte credit`),e>this.options.maxByteCredit)throw RangeError(`byte credit exceeds host maximum`)}accepted(e,t,n=!1){return{kind:`accepted`,protocol:G,...n?{sessionId:e.sessionId,operationId:e.operationId,generation:e.generation}:this.identity(),requestId:e.requestId,command:t,usage:this.resourceUsage()}}identity(){return{sessionId:this.options.sessionId,operationId:this.options.operationId,generation:this.options.generation}}isStaleLifecycle(e){return(e.kind===`cancel`||e.kind===`close`)&&e.protocol===`ooxml-pull-v1`&&Number.isSafeInteger(e.requestId)&&e.requestId>0&&Number.isSafeInteger(e.generation)&&e.generation>0&&e.generation<this.options.generation}sameOperationIdentity(e){return e.sessionId===this.options.sessionId&&e.operationId===this.options.operationId}errorResponse(e,t){return{kind:`error`,protocol:G,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:t,usage:this.errorResourceUsage()}}async forceFatalCleanup(){this.cancelRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;for(let t of[...this.leases.keys()])try{await this.release(t)}catch(t){e??=t}if(!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch(t){e??=t}if(e)throw e;this.unregisterCleanup()}allocateWireLeaseId(){if(!Number.isSafeInteger(this.nextWireLeaseId)||this.nextWireLeaseId<=0)throw RangeError(`wire lease id space exhausted`);return this.nextWireLeaseId++}arrayBufferTransferBytes(e){let t=0;for(let n of e??[])if(n instanceof ArrayBuffer&&(t+=n.byteLength,!Number.isSafeInteger(t)))throw RangeError(`ArrayBuffer transfer bytes overflow`);return t}maybeUnregisterCompleted(){this.completed&&this.leases.size===0&&this.unregisterCleanup()}resourceUsage(){return this.options.driver.resourceUsage?.()}errorResourceUsage(){try{return this.resourceUsage()}catch{return}}};const J=67108864;var De=class{coordinator=new q;host=null;identity=null;constructor(e,t=e=>e(this.requireArchive())){this.archive=e,this.executeArchive=t}open(e){if(this.host)throw Error(`a DOCX document pull session is already active`);this.executeArchive(t=>{t.open_document_cursor(e.operationId,e.generation)});let t=0;this.identity=e,this.host=new Ee({...e,maxByteCredit:J,coordinator:this.coordinator,driver:{pull:n=>{let r;try{r=this.executeArchive(r=>r.pull_document_chunk(t,e.operationId,e.generation,n))}catch(e){throw me(e,n,J)||e}let i=Ce(r);return{payload:i,byteLength:i.byteLength,done:this.executeArchive(e=>e.document_chunk_done()),transfer:[i]}},measureChunk:({payload:e})=>e.byteLength,acknowledge:n=>{if(n!==t)throw Error(`DOCX document acknowledgement sequence mismatch`);this.executeArchive(n=>n.acknowledge_document_chunk(t,e.operationId,e.generation)),t+=1},cancel:()=>this.executeArchive(e=>e.cancel_document_cursor()),close:()=>this.executeArchive(e=>e.close_document_session()),resourceUsage:()=>{let e=this.executeArchive(e=>e.document_cursor_resource_usage?.());return e?I(e):void 0}}})}dispatch(e,t){return!this.host||!this.identity?(t({protocol:G,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:W(Error(`DOCX document pull session is not open`))}),Promise.resolve()):this.host.dispatch(e,t)}async reset(){if(this.host)try{this.archive()&&this.executeArchive(e=>e.close_document_session())}finally{this.host=null,this.identity=null,this.coordinator=new q}}requireArchive(){let e=this.archive();if(!e)throw Error(`No docx loaded`);return e}};function Y(e){return!!e&&typeof e==`object`&&e.protocol===`ooxml-pull-v1`}const X=new de(y,{freeArchive:e=>e.free(),reinit:b}),Z=new De(()=>X.archive,e=>X.run(()=>{let t=X.archive;if(!t)throw Error(`No docx loaded`);return e(t)}));let Q=0;const $=(e,t)=>self.postMessage(e,t);self.onmessage=async e=>{let n=e.data;if(Y(n)){try{await Z.dispatch(n,$)}catch(e){$({protocol:G,kind:`error`,sessionId:n.sessionId,operationId:n.operationId,generation:n.generation,requestId:n.requestId,error:W(e)})}return}if(n.type===`init`){X.setWasmInput(oe(n.wasmUrl)??n.wasmUrl);return}let r=n.id;try{if(await X.ensureReady(),n.type!==`parse`&&X.archive){let e=X.archive;X.run(()=>e.assert_healthy())}if(n.type===`parse`){await Z.reset();let[e,i,a]=we(n.resourcePolicy),o=new Uint8Array(n.data);X.run(()=>{let n=new t(o,e,i,a);X.setArchive(n)}),Q+=1;let s={sessionId:Q,operationId:Q,generation:Q};Z.open(s),$({type:`documentSessionOpened`,id:r,...s});return}let e=X.archive;if(n.type===`extractImage`){if(!e)throw Error(`No docx loaded`);let t=X.run(()=>e.extract_image(n.path).buffer),i={type:`imageExtracted`,id:r,bytes:t};self.postMessage(i,[t]);return}if(n.type===`resourceUsage`){if(!e)throw Error(`No docx loaded`);$({type:`resourceUsage`,id:r,usage:I(X.run(()=>e.resource_usage()))});return}if(n.type===`toMarkdown`){if(!e)throw Error(`No docx loaded`);$({type:`markdownRendered`,id:r,markdown:X.run(()=>e.to_markdown())});return}}catch(e){$({type:`error`,id:r,...W(e)})}};", bt = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", yt], { type: "text/javascript;charset=utf-8" });
|
|
149
|
-
function
|
|
149
|
+
var St = "var e=(e,t)=>()=>(e&&(t=e(e=0)),t),t=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,r.unregister(this),e}free(){let e=this.__destroy_into_raw();v.__wbg_docxarchive_free(e,0)}acknowledge_document_chunk(e,t,n){let r=v.docxarchive_acknowledge_document_chunk(this.__wbg_ptr,e,t,n);if(r[1])throw p(r[0])}assert_healthy(){let e=v.docxarchive_assert_healthy(this.__wbg_ptr);if(e[1])throw p(e[0])}cancel_document_cursor(){v.docxarchive_cancel_document_cursor(this.__wbg_ptr)}close_document_session(){v.docxarchive_close_document_session(this.__wbg_ptr)}document_chunk_done(){let e=v.docxarchive_document_chunk_done(this.__wbg_ptr);if(e[2])throw p(e[1]);return e[0]!==0}document_cursor_resource_usage(){let e=v.docxarchive_document_cursor_resource_usage(this.__wbg_ptr);if(e[3])throw p(e[2]);var t=i(e[0],e[1]).slice();return v.__wbindgen_free(e[0],e[1]*1,1),t}extract_image(e){let t=f(e,v.__wbindgen_malloc,v.__wbindgen_realloc),n=_,r=v.docxarchive_extract_image(this.__wbg_ptr,t,n);if(r[3])throw p(r[2]);var a=i(r[0],r[1]).slice();return v.__wbindgen_free(r[0],r[1]*1,1),a}constructor(e,t,n,i){let a=d(e,v.__wbindgen_malloc),o=_,s=v.docxarchive_new(a,o,!u(t),u(t)?BigInt(0):t,!u(n),u(n)?BigInt(0):n,!u(i),u(i)?BigInt(0):i);if(s[2])throw p(s[1]);return this.__wbg_ptr=s[0]>>>0,r.register(this,this.__wbg_ptr,this),this}open_document_cursor(e,t){let n=v.docxarchive_open_document_cursor(this.__wbg_ptr,e,t);if(n[1])throw p(n[0])}parse(){let e=v.docxarchive_parse(this.__wbg_ptr);if(e[3])throw p(e[2]);var t=i(e[0],e[1]).slice();return v.__wbindgen_free(e[0],e[1]*1,1),t}pull_document_chunk(e,t,n,r){let a=v.docxarchive_pull_document_chunk(this.__wbg_ptr,e,t,n,r);if(a[3])throw p(a[2]);var o=i(a[0],a[1]).slice();return v.__wbindgen_free(a[0],a[1]*1,1),o}resource_usage(){let e=v.docxarchive_resource_usage(this.__wbg_ptr);if(e[3])throw p(e[2]);var t=i(e[0],e[1]).slice();return v.__wbindgen_free(e[0],e[1]*1,1),t}to_markdown(){let e,t;try{let i=v.docxarchive_to_markdown(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,p(i[2]);return e=n,t=r,s(n,r)}finally{v.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(t.prototype[Symbol.dispose]=t.prototype.free);function n(){return{__proto__:null,\"./docx_parser_bg.js\":{__proto__:null,__wbg___wbindgen_throw_6b64449b9b9ed33c:function(e,t){throw Error(s(e,t))},__wbg_error_a6fa202b58aa1cd3:function(e,t){let n,r;try{n=e,r=t,console.error(s(e,t))}finally{v.__wbindgen_free(n,r,1)}},__wbg_new_227d7c05414eb861:function(){return Error()},__wbg_stack_3b0d974bbf31e44f:function(e,t){let n=t.stack,r=f(n,v.__wbindgen_malloc,v.__wbindgen_realloc),i=_;o().setInt32(e+4,i,!0),o().setInt32(e+0,r,!0)},__wbindgen_cast_0000000000000001:function(e,t){return s(e,t)},__wbindgen_init_externref_table:function(){let e=v.__wbindgen_externrefs,t=e.grow(4);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)}}}}const r=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>v.__wbg_docxarchive_free(e>>>0,1));function i(e,t){return e>>>=0,l().subarray(e/1,e/1+t)}let a=null;function o(){return(a===null||a.buffer.detached===!0||a.buffer.detached===void 0&&a.buffer!==v.memory.buffer)&&(a=new DataView(v.memory.buffer)),a}function s(e,t){return e>>>=0,ee(e,t)}let c=null;function l(){return(c===null||c.byteLength===0)&&(c=new Uint8Array(v.memory.buffer)),c}function u(e){return e==null}function d(e,t){let n=t(e.length*1,1)>>>0;return l().set(e,n/1),_=e.length,n}function f(e,t,n){if(n===void 0){let n=g.encode(e),r=t(n.length,1)>>>0;return l().subarray(r,r+n.length).set(n),_=n.length,r}let r=e.length,i=t(r,1)>>>0,a=l(),o=0;for(;o<r;o++){let t=e.charCodeAt(o);if(t>127)break;a[i+o]=t}if(o!==r){o!==0&&(e=e.slice(o)),i=n(i,r,r=o+e.length*3,1)>>>0;let t=l().subarray(i+o,i+r),a=g.encodeInto(e,t);o+=a.written,i=n(i,r,o,1)>>>0}return _=o,i}function p(e){let t=v.__wbindgen_externrefs.get(e);return v.__externref_table_dealloc(e),t}let m=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0});m.decode();let h=0;function ee(e,t){return h+=t,h>=2146435072&&(m=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}),m.decode(),h=t),m.decode(l().subarray(e,e+t))}const g=new TextEncoder;`encodeInto`in g||(g.encodeInto=function(e,t){let n=g.encode(e);return t.set(n),{read:e.length,written:n.length}});let _=0,v;function te(e,t){return v=e.exports,a=null,c=null,v.__wbindgen_start(),v}async function ne(e,t){if(typeof Response==`function`&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming==`function`)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if(e.ok&&n(e.type)&&e.headers.get(`Content-Type`)!==`application/wasm`)console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\",t);else throw t}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}function n(e){switch(e){case`basic`:case`cors`:case`default`:return!0}return!1}}async function y(e){if(v!==void 0)return v;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`));let t=n();(typeof e==`string`||typeof Request==`function`&&e instanceof Request||typeof URL==`function`&&e instanceof URL)&&(e=fetch(e));let{instance:r,module:i}=await ne(await e,t);return te(r,i)}async function b(e){return v=void 0,a=null,c=null,y(e)}var x=class e extends Error{code;constructor(t,n){super(n),this.name=`OoxmlError`,this.code=t,Object.setPrototypeOf(this,e.prototype)}},S=class e extends Error{code=`ooxml-resource-limit`;details;constructor(t,n){super(t),this.name=`OoxmlResourceLimitError`;let r=n.violation,i=Object.freeze({format:r.format,operation:r.operation,resource:r.resource,metric:r.metric,...r.part===void 0?{}:{part:r.part},limit:r.limit,observed:r.observed,configurable:r.configurable,usage:Object.freeze({archiveEntryCount:r.usage.archiveEntryCount,declaredInflatedBytes:r.usage.declaredInflatedBytes,...r.usage.largestInflatedEntryBytes===void 0?{}:{largestInflatedEntryBytes:r.usage.largestInflatedEntryBytes},distinctInflatedBytes:r.usage.distinctInflatedBytes,operationInflatedBytes:r.usage.operationInflatedBytes})});this.details=Object.freeze({stage:n.stage,violation:i}),Object.setPrototypeOf(this,e.prototype)}};function re(e){return e===`image-dimension`||e===`image-pixels`||e===`active-decoded-bytes`}function C(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function ie(e){if(!(!e||typeof e!=`object`))try{let t=e,n=t.code,r=t.metric,i=t.limit,a=t.observed;return n!==`ooxml-decoded-image-limit`||!re(r)||!C(i)||!C(a)||a<=i?void 0:{metric:r,limit:i,observed:a}}catch{return}}var w,T,E,D=e((()=>{w=1<<25,T=1<<27,w*4,T*4,E=class e extends RangeError{code=`ooxml-decoded-image-limit`;constructor(t,n,r){super(`OOXML decoded image limit exceeded: ${t} ${r} > ${n}`),this.metric=t,this.limit=n,this.observed=r,this.name=`OoxmlDecodedImageLimitError`,Object.setPrototypeOf(this,e.prototype)}}}));function O(e){if(!(typeof e!=`object`||!e))try{let t=e,n=t.code,r=t.message;return n===`ooxml-tiff-decode`&&typeof r==`string`?{message:r}:void 0}catch{return}}var ae=e((()=>{}));function oe(e){if(!e.startsWith(`data:`))return null;let t=e.indexOf(`,`);if(t===-1)return null;let n=atob(e.slice(t+1)),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r.buffer}var se=class{state=`uninitialized`;generationValue=0;readiness;poisonListeners=new Set;constructor(e,t,n){this.initialize=e,this.reinitialize=t,this.normalizeFailure=n}get generation(){return this.generationValue}get poisoned(){return this.state===`poisoned`}onPoison(e){return this.poisonListeners.add(e),()=>this.poisonListeners.delete(e)}async ensureReady(){if(this.state!==`ready`){if(!this.readiness){let e=this.state===`uninitialized`?this.initialize:this.reinitialize;this.readiness=Promise.resolve().then(e).then(()=>{this.generationValue+=1,this.state=`ready`,this.readiness=void 0},e=>{throw this.readiness=void 0,e})}await this.readiness}}run(e){try{return e()}catch(e){let t=this.normalizeFailure(e);throw t?(this.poison(t),t):e}}tryRunReady(e){if(this.state!==`ready`)return{current:!1};let t=this.generationValue,n=this.run(e);return this.state!==`ready`||t!==this.generationValue?{current:!1}:{current:!0,generation:t,value:n}}poison(e){this.state=`poisoned`,this.readiness=void 0;for(let t of this.poisonListeners)t(e)}assertCurrent(e){if(this.state!==`ready`||e!==this.generationValue)throw Error(`WASM archive session belongs to a discarded runtime generation`)}},k=class e extends Error{code=`parser-crashed`;constructor(t){super(t),this.name=`WasmTrapError`,Object.setPrototypeOf(this,e.prototype)}};function ce(e){let t=globalThis.WebAssembly?.RuntimeError;return t&&e instanceof t||e instanceof RangeError?!0:e instanceof Error?e.name===`RuntimeError`||e.name===`CompileError`||e.name===`LinkError`||e.name===`InternalError`||e.name===`OOMError`:!1}function le(e){try{if((typeof e!=`object`||!e)&&typeof e!=`function`)return;let t=Reflect.get(e,`__destroy_into_raw`);typeof t==`function`&&Reflect.apply(t,e,[])}catch{}}function ue(e,t){return e({module_or_path:t})}var de=class{runtime;wasmInput=null;currentArchive=null;constructor(e,t={}){this.init=e,this.options=t,this.runtime=new se(()=>this.invokeConfigured(this.init),()=>this.invokeConfigured(this.options.reinit??this.init),fe),this.runtime.onPoison(()=>this.dropPoisonedArchive())}setWasmInput(e){this.wasmInput=e,this.runtime.ensureReady().catch(()=>void 0)}setWasmUrl(e){this.setWasmInput(e)}get archive(){return this.currentArchive}setArchive(e){this.freeArchive(),this.currentArchive=e}disposeArchive(){this.freeArchive()}get poisoned(){return this.runtime.poisoned}async ensureReady(){await this.runtime.ensureReady()}run(e){return this.runtime.run(e)}poison(){this.runtime.poison(new k(`WASM parser was recycled`))}invokeConfigured(e){return this.wasmInput===null?Promise.reject(Error(`WasmParserHost: setWasmInput was never called`)):ue(e,this.wasmInput)}freeArchive(){this.currentArchive!==null&&this.options.freeArchive&&this.options.freeArchive(this.currentArchive),this.currentArchive=null}dropPoisonedArchive(){let e=this.currentArchive;this.currentArchive=null,le(e)}};function fe(e){return ce(e)?new k(`WASM parser trapped and was recycled: ${e instanceof Error?e.message:String(e)}`):null}function A(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>0}function pe(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return A(t.requiredBytes)&&A(t.offeredBytes)&&t.requiredBytes>t.offeredBytes}var j=class e extends RangeError{code=`ooxml-insufficient-credit`;requiredBytes;offeredBytes;constructor(t){super(`Pull unit requires ${t.requiredBytes} bytes but credit is ${t.offeredBytes}`),this.name=`PullSessionInsufficientCreditError`,this.requiredBytes=t.requiredBytes,this.offeredBytes=t.offeredBytes,Object.setPrototypeOf(this,e.prototype)}};function M(e){if(e instanceof j)return e;let t=e instanceof Error?e.message:String(e);if(!t.startsWith(`OOXML_INSUFFICIENT_CREDIT:`))return;let n;try{n=JSON.parse(t.slice(26))}catch{return}if(!n||typeof n!=`object`||Array.isArray(n))return;let r=n;if(!(r.code!==`ooxml-insufficient-credit`||!pe(r)))return new j(r)}function me(e,t,n){let r=M(e);if(!(!r||r.offeredBytes!==t||r.requiredBytes>n))return r}D(),ae();const N=`OOXML_RESOURCE_LIMIT:`;function P(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function F(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return P(t.archiveEntryCount)&&P(t.declaredInflatedBytes)&&(t.largestInflatedEntryBytes===void 0||P(t.largestInflatedEntryBytes))&&P(t.distinctInflatedBytes)&&P(t.operationInflatedBytes)}function I(e){let t;try{t=JSON.parse(new TextDecoder().decode(e))}catch{throw TypeError(`OOXML resource usage checkpoint is not valid JSON`)}if(!F(t))throw TypeError(`OOXML resource usage checkpoint is invalid`);return t}function L(e){return e===`docx`||e===`xlsx`||e===`pptx`}function R(e){return e===`container`||e===`decompression`||e===`parsing`||e===`serialization`||e===`layout`||e===`rendering`||e===`worker`}function z(e,t){return typeof e==`string`&&e.length>0&&e.length<=t&&!/[\\u0000-\\u001f\\u007f]/u.test(e)}function B(e){return z(e,128)&&/^[a-z0-9][a-z0-9-]*$/u.test(e)}function he(e){return!z(e,4096)||e.startsWith(`/`)||e.startsWith(`\\\\`)||e.includes(`\\\\`)||e.includes(`?`)||e.includes(`#`)||e.includes(`://`)||/^[a-z]:/iu.test(e)?!1:e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`)}const V=new Map([[`archive-entry:declared-inflated-bytes`,{stage:`container`,part:`required`}],[`archive-entry:actual-inflated-bytes`,{stage:`decompression`,part:`required`}],[`archive:entry-count`,{stage:`container`,part:`forbidden`}],[`archive:central-directory-bytes`,{stage:`container`,part:`forbidden`,configurable:!1}],[`archive:distinct-inflated-bytes`,{stage:`decompression`,part:`required`}],[`xml-event:bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`xml-context:bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`xml-tree:depth`,{stage:`parsing`,part:`optional`,configurable:!1}],[`worksheet-row:projected-bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`worksheet-shell:projected-bytes`,{stage:`parsing`,part:`optional`,configurable:!1}]]),ge=new Set([...V.keys()].map(e=>e.slice(0,e.indexOf(`:`)))),_e=new Set([...V.keys()].map(e=>e.slice(e.indexOf(`:`)+1)));function ve(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return!L(t.format)||!z(t.operation,256)||!B(t.resource)||!B(t.metric)||!P(t.limit)||!P(t.observed)||typeof t.configurable!=`boolean`||!F(t.usage)?!1:!(`part`in t)||he(t.part)}function H(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;if(!R(t.stage)||!ve(t.violation))return!1;let n=t.violation,r=V.get(`${n.resource}:${n.metric}`);return r?t.stage!==r.stage||r.configurable===!1&&n.configurable!==!1?!1:r.part===`required`?n.part!==void 0:r.part===`forbidden`?n.part===void 0:!0:!(ge.has(n.resource)&&_e.has(n.metric))}function ye(e){return{archiveEntryCount:e.archiveEntryCount,declaredInflatedBytes:e.declaredInflatedBytes,...e.largestInflatedEntryBytes===void 0?{}:{largestInflatedEntryBytes:e.largestInflatedEntryBytes},distinctInflatedBytes:e.distinctInflatedBytes,operationInflatedBytes:e.operationInflatedBytes}}function be(e){if(!H(e))return;let t=e.violation,n={stage:e.stage,violation:{format:t.format,operation:t.operation,resource:t.resource,metric:t.metric,...t.part===void 0?{}:{part:t.part},limit:t.limit,observed:t.observed,configurable:t.configurable,usage:ye(t.usage)}};return H(n)?n:void 0}function U(e){let t=e.violation;return`OOXML resource limit exceeded${t.part?` for ${t.part}`:``}: ${t.metric} ${t.observed} > ${t.limit}`}function xe(e){let t=e instanceof Error?e.message:String(e);if(!t.startsWith(N))return;let n;try{n=JSON.parse(t.slice(21))}catch{return}if(!n||typeof n!=`object`)return;let r=n;if(!(r.code!==`ooxml-resource-limit`||!H(r.details)))return new S(U(r.details),r.details)}function Se(e){let t=ie(e);if(t){let e=new E(t.metric,t.limit,t.observed);return{message:e.message,errorName:e.name,code:e.code,decodedImage:t}}let n=O(e);if(n)return{message:n.message,errorName:`TiffDecodeError`,code:`ooxml-tiff-decode`};let r=M(e);if(r)return{message:r.message,errorName:r.name,code:r.code,insufficientCredit:{requiredBytes:r.requiredBytes,offeredBytes:r.offeredBytes}};let i=e instanceof x||e instanceof S?e:xe(e);if(i instanceof S){let e=be(i.details);return e?{message:typeof i.message==`string`?i.message:U(e),errorName:`OoxmlResourceLimitError`,code:`ooxml-resource-limit`,resourceLimit:e}:{message:`Invalid OOXML resource-limit error payload`,errorName:`Error`}}if(i instanceof x)return{message:typeof i.message==`string`?i.message:String(i.message),errorName:z(i.name,128)?i.name:`OoxmlError`,...B(i.code)?{code:i.code}:{}};let a=e instanceof Error?e.message:String(e);if(typeof a==`string`&&a.startsWith(N))return{message:`Invalid OOXML resource-limit payload`,errorName:`Error`};let o=e instanceof Error?e:Error(a),s=o;return{message:typeof o.message==`string`?o.message:String(o.message),errorName:z(o.name,128)?o.name:`Error`,...typeof s.code==`string`?{code:s.code}:{}}}function W(e){try{return Se(e)}catch{return{message:`Worker operation failed with an unreadable error`,errorName:`Error`}}}function Ce(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength&&e.buffer instanceof ArrayBuffer?e.buffer:e.slice().buffer}Object.freeze({maxArchiveEntryBytes:134217728,maxTotalInflatedBytes:268435456,maxArchiveEntries:4096});function we(e){return[e.maxArchiveEntryBytes===null?0n:BigInt(e.maxArchiveEntryBytes),e.maxTotalInflatedBytes===null?0n:BigInt(e.maxTotalInflatedBytes),e.maxArchiveEntries===null?0n:BigInt(e.maxArchiveEntries)]}const G=`ooxml-pull-v1`;function K(e,t){if(!Number.isSafeInteger(e)||e<=0)throw RangeError(`${t} must be a positive safe integer`)}function Te(e){if(!(typeof e==`string`&&e.length>0||typeof e==`number`&&Number.isSafeInteger(e)&&e>0))throw RangeError(`session id must be a non-empty string or positive safe integer`)}var q=class{owner;queue=Promise.resolve();leases=new Map;retainedBytes=0;retainedCount=0;maxRetainedBytes;maxRetainedCount;cleanups=new Set;pendingFatalCleanups=[];poisonRunning=!1;fatal;constructor(e){this.maxRetainedBytes=e?.maxRetainedBytes??64*1024*1024,this.maxRetainedCount=e?.maxRetainedCount??256,K(this.maxRetainedBytes,`max retained lease bytes`),K(this.maxRetainedCount,`max retained lease count`)}enqueue(e){let t=this.queue.then(e,e);return this.queue=t.then(()=>void 0,()=>void 0),t}acquire(e){return this.owner===void 0?(this.owner=e,!0):this.owner===e}release(e){this.owner===e&&(this.owner=void 0)}retainLease(e,t,n){if(!Number.isSafeInteger(n)||n<0)throw RangeError(`retained lease bytes are invalid`);let r=this.leases.get(e)??new Map;if(r.has(t))throw Error(`driver returned a duplicate lease id`);if(this.retainedCount+1>this.maxRetainedCount)throw RangeError(`retained lease count exceeds limit`);if(this.retainedBytes+n>this.maxRetainedBytes)throw RangeError(`retained lease bytes exceed limit`);r.set(t,n),this.leases.set(e,r),this.retainedCount++,this.retainedBytes+=n}releaseLease(e,t){let n=this.leases.get(e),r=n?.get(t);r!==void 0&&(n?.delete(t),n?.size===0&&this.leases.delete(e),this.retainedCount--,this.retainedBytes-=r)}registerCleanup(e){return this.fatal?(this.poisonRunning?this.pendingFatalCleanups.push(e):this.enqueue(e).catch(()=>void 0),()=>void 0):(this.cleanups.add(e),()=>this.cleanups.delete(e))}get fatalError(){return this.fatal}get registeredHostCount(){return this.cleanups.size}async poison(e){if(this.fatal??=e,this.poisonRunning)return this.fatal;this.poisonRunning=!0,this.pendingFatalCleanups.push(...this.cleanups);try{let e;for(;(e=this.pendingFatalCleanups.shift())!==void 0;)await e().catch(()=>void 0)}finally{this.poisonRunning=!1}return this.fatal}},Ee=class{options;coordinator;coordinatorOwner=Symbol(`pull-session-host`);unregisterCleanup;sequence=0;unacked;leases=new Map;activeDriverLeases=new Set;nextWireLeaseId;cancelRequested=!1;cancelComplete=!1;closeRequested=!1;closeComplete=!1;driverCancelComplete=!1;driverCloseComplete=!1;completed=!1;constructor(e){Te(e.sessionId),K(e.operationId,`operation id`),K(e.generation,`generation`),K(e.maxByteCredit,`max byte credit`),e.wireLeaseIdStart!==void 0&&K(e.wireLeaseIdStart,`wire lease id start`),this.options=e,this.coordinator=e.coordinator,this.nextWireLeaseId=e.wireLeaseIdStart??1,this.unregisterCleanup=this.coordinator.registerCleanup(()=>this.forceFatalCleanup())}dispatch(e,t){return this.coordinator.enqueue(async()=>{let n=await this.execute(e);try{t(n.response,n.transfer)}catch(e){throw await this.rollbackFailedPost(n),e}})}async rollbackFailedPost(e){let t=e.response;if(t.kind===`chunk`){let n=t.leaseId===void 0?void 0:this.leases.get(t.leaseId);try{await this.options.driver.disposeInvalidChunk?.({payload:t.payload,byteLength:t.byteLength,done:t.done,leaseId:n?.driverLeaseId,retainedBytes:n?.retainedBytes,transfer:e.transfer})}catch{}}this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);for(let[e,t]of[...this.leases])try{await this.options.driver.releaseLease?.(t.driverLeaseId)}catch{}finally{this.leases.delete(e),this.activeDriverLeases.delete(t.driverLeaseId),this.coordinator.releaseLease(this.coordinatorOwner,e)}if(this.cancelRequested=!0,!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch{}this.unregisterCleanup()}async execute(e){try{if(this.isStaleLifecycle(e)){let t=e.kind===`cancel`?`cancel`:`close`;return this.sameOperationIdentity(e)?{response:this.accepted(e,t,!0)}:{response:this.errorResponse(e,{message:`stale lifecycle targets another session or operation`,errorName:`PullSessionProtocolError`,code:`ooxml-stale-lifecycle`})}}this.validateCommandIdentity(e);let t=this.coordinator.fatalError;if(t)return e.kind===`pull`?{response:this.errorResponse(e,t)}:(e.kind===`cancel`?await this.cancel():e.kind===`close`?await this.close():e.kind===`release`&&await this.release(e.leaseId),{response:this.accepted(e,e.kind)});switch(e.kind){case`pull`:return await this.pull(e);case`ack`:return await this.ack(e.sequence),{response:this.accepted(e,`ack`)};case`release`:return await this.release(e.leaseId),{response:this.accepted(e,`release`)};case`cancel`:return await this.cancel(),{response:this.accepted(e,`cancel`)};case`close`:return await this.close(),{response:this.accepted(e,`close`)}}}catch(t){let n=W(t);return n.code===`ooxml-resource-limit`&&(n=await this.coordinator.poison(n)),{response:this.errorResponse(e,n)}}}async pull(e){if(this.closeRequested||this.cancelRequested||this.completed)throw Error(`pull session is closed`);if(this.unacked)throw Error(`previous chunk is not acknowledged`);if(!Number.isSafeInteger(e.sequence)||e.sequence<0||e.sequence!==this.sequence)throw Error(`pull command sequence mismatch`);if(this.validateHostCredit(e.byteCredit),!this.coordinator.acquire(this.coordinatorOwner))throw Error(`another operation has an unacknowledged package chunk`);let t;try{t=await this.options.driver.pull(e.byteCredit)}catch(e){throw this.coordinator.release(this.coordinatorOwner),e}let n=!1,r=!1,i,a;try{let o=this.options.driver.measureChunk(t),s=this.arrayBufferTransferBytes(t.transfer);if(o<s)throw RangeError(`measured chunk bytes are below ArrayBuffer transfer bytes`);if(a=Math.max(o,s),t.leaseId!==void 0){if(K(t.leaseId,`lease id`),t.retainedBytes===void 0)throw Error(`retained lease bytes are required`);if(this.activeDriverLeases.has(t.leaseId))throw r=!0,Error(`driver returned an active duplicate lease id`);i=this.allocateWireLeaseId(),this.coordinator.retainLease(this.coordinatorOwner,i,t.retainedBytes),this.leases.set(i,{driverLeaseId:t.leaseId,retainedBytes:t.retainedBytes}),this.activeDriverLeases.add(t.leaseId),n=!0}else if(t.retainedBytes!==void 0)throw Error(`retained lease bytes require a lease id`);if(!Number.isSafeInteger(a)||a<0)throw RangeError(`host chunk byte length must be a non-negative safe integer`);if(a>e.byteCredit)throw RangeError(`host chunk exceeds byte credit`)}catch(e){let a;try{await this.options.driver.disposeInvalidChunk?.(t)}catch(e){a=e}if(n&&i!==void 0)try{await this.release(i)}catch(e){a??=e}else if(t.leaseId!==void 0&&!r)try{await this.options.driver.releaseLease?.(t.leaseId)}catch(e){a??=e}if(r)try{await this.cancel()}catch(e){a??=e}throw this.coordinator.release(this.coordinatorOwner),a||e}return this.unacked={sequence:this.sequence,done:t.done},{response:{kind:`chunk`,protocol:G,...this.identity(),requestId:e.requestId,sequence:this.sequence,byteLength:a,done:t.done,payload:t.payload,leaseId:i,usage:this.resourceUsage()},transfer:t.transfer}}async ack(e){if(!Number.isSafeInteger(e)||e<0)throw RangeError(`invalid ack sequence`);if(e<this.sequence)return;if(!this.unacked||e!==this.sequence)throw Error(`ack sequence mismatch`);let t=this.unacked.done;await this.options.driver.acknowledge?.(e),this.unacked=void 0,this.coordinator.release(this.coordinatorOwner),this.sequence++,t&&(this.completed=!0,this.maybeUnregisterCompleted())}async release(e){K(e,`wire lease id`);let t=this.leases.get(e);t&&(await this.options.driver.releaseLease?.(t.driverLeaseId),this.leases.delete(e),this.activeDriverLeases.delete(t.driverLeaseId),this.coordinator.releaseLease(this.coordinatorOwner,e),this.maybeUnregisterCompleted())}async cancel(){if(this.cancelComplete)return;this.cancelRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;try{await this.releaseAllLeases()}catch(t){e=t}if(!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch(t){e??=t}if(e)throw e;this.cancelComplete=!0,this.unregisterCleanup()}async close(){if(this.closeComplete)return;this.closeRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;try{await this.releaseAllLeases()}catch(t){e=t}if(!this.driverCloseComplete)try{await this.options.driver.close?.(),this.driverCloseComplete=!0}catch(t){e??=t}if(e)throw e;this.closeComplete=!0,this.unregisterCleanup()}async releaseAllLeases(){let e;for(let t of[...this.leases.keys()])try{await this.release(t)}catch(t){e??=t}if(e)throw e}validateCommandIdentity(e){if(e.protocol!==`ooxml-pull-v1`||e.sessionId!==this.options.sessionId||e.operationId!==this.options.operationId||e.generation!==this.options.generation||!Number.isSafeInteger(e.requestId)||e.requestId<=0)throw Error(`stale or mismatched pull session command`)}validateHostCredit(e){if(K(e,`byte credit`),e>this.options.maxByteCredit)throw RangeError(`byte credit exceeds host maximum`)}accepted(e,t,n=!1){return{kind:`accepted`,protocol:G,...n?{sessionId:e.sessionId,operationId:e.operationId,generation:e.generation}:this.identity(),requestId:e.requestId,command:t,usage:this.resourceUsage()}}identity(){return{sessionId:this.options.sessionId,operationId:this.options.operationId,generation:this.options.generation}}isStaleLifecycle(e){return(e.kind===`cancel`||e.kind===`close`)&&e.protocol===`ooxml-pull-v1`&&Number.isSafeInteger(e.requestId)&&e.requestId>0&&Number.isSafeInteger(e.generation)&&e.generation>0&&e.generation<this.options.generation}sameOperationIdentity(e){return e.sessionId===this.options.sessionId&&e.operationId===this.options.operationId}errorResponse(e,t){return{kind:`error`,protocol:G,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:t,usage:this.errorResourceUsage()}}async forceFatalCleanup(){this.cancelRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;for(let t of[...this.leases.keys()])try{await this.release(t)}catch(t){e??=t}if(!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch(t){e??=t}if(e)throw e;this.unregisterCleanup()}allocateWireLeaseId(){if(!Number.isSafeInteger(this.nextWireLeaseId)||this.nextWireLeaseId<=0)throw RangeError(`wire lease id space exhausted`);return this.nextWireLeaseId++}arrayBufferTransferBytes(e){let t=0;for(let n of e??[])if(n instanceof ArrayBuffer&&(t+=n.byteLength,!Number.isSafeInteger(t)))throw RangeError(`ArrayBuffer transfer bytes overflow`);return t}maybeUnregisterCompleted(){this.completed&&this.leases.size===0&&this.unregisterCleanup()}resourceUsage(){return this.options.driver.resourceUsage?.()}errorResourceUsage(){try{return this.resourceUsage()}catch{return}}};function De(e){try{let t=e(e=>e.document_cursor_resource_usage?.());return t?I(t):void 0}catch(e){if(String(e).includes(`document cursor usage is unavailable`))return;throw e}}const J=67108864;var Y=class{coordinator=new q;host=null;identity=null;constructor(e,t=e=>e(this.requireArchive())){this.archive=e,this.executeArchive=t}open(e){if(this.host)throw Error(`a DOCX document pull session is already active`);this.executeArchive(t=>{t.open_document_cursor(e.operationId,e.generation)});let t=0;this.identity=e,this.host=new Ee({...e,maxByteCredit:J,coordinator:this.coordinator,driver:{pull:n=>{let r;try{r=this.executeArchive(r=>r.pull_document_chunk(t,e.operationId,e.generation,n))}catch(e){throw me(e,n,J)||e}let i=Ce(r);return{payload:i,byteLength:i.byteLength,done:this.executeArchive(e=>e.document_chunk_done()),transfer:[i]}},measureChunk:({payload:e})=>e.byteLength,acknowledge:n=>{if(n!==t)throw Error(`DOCX document acknowledgement sequence mismatch`);this.executeArchive(n=>n.acknowledge_document_chunk(t,e.operationId,e.generation)),t+=1},cancel:()=>this.executeArchive(e=>e.cancel_document_cursor()),close:()=>this.executeArchive(e=>e.close_document_session()),resourceUsage:()=>De(this.executeArchive)}})}dispatch(e,t){return!this.host||!this.identity?(t({protocol:G,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:W(Error(`DOCX document pull session is not open`))}),Promise.resolve()):this.host.dispatch(e,t)}async reset(){if(this.host)try{this.archive()&&this.executeArchive(e=>e.close_document_session())}finally{this.host=null,this.identity=null,this.coordinator=new q}}requireArchive(){let e=this.archive();if(!e)throw Error(`No docx loaded`);return e}};function Oe(e){return!!e&&typeof e==`object`&&e.protocol===`ooxml-pull-v1`}const X=new de(y,{freeArchive:e=>e.free(),reinit:b}),Z=new Y(()=>X.archive,e=>X.run(()=>{let t=X.archive;if(!t)throw Error(`No docx loaded`);return e(t)}));let Q=0;const $=(e,t)=>self.postMessage(e,t);self.onmessage=async e=>{let n=e.data;if(Oe(n)){try{await Z.dispatch(n,$)}catch(e){$({protocol:G,kind:`error`,sessionId:n.sessionId,operationId:n.operationId,generation:n.generation,requestId:n.requestId,error:W(e)})}return}if(n.type===`init`){X.setWasmInput(oe(n.wasmUrl)??n.wasmUrl);return}let r=n.id;try{if(await X.ensureReady(),n.type!==`parse`&&X.archive){let e=X.archive;X.run(()=>e.assert_healthy())}if(n.type===`parse`){await Z.reset();let[e,i,a]=we(n.resourcePolicy),o=new Uint8Array(n.data);X.run(()=>{let n=new t(o,e,i,a);X.setArchive(n)}),Q+=1;let s={sessionId:Q,operationId:Q,generation:Q};Z.open(s),$({type:`documentSessionOpened`,id:r,...s});return}let e=X.archive;if(n.type===`extractImage`){if(!e)throw Error(`No docx loaded`);let t=X.run(()=>e.extract_image(n.path).buffer),i={type:`imageExtracted`,id:r,bytes:t};self.postMessage(i,[t]);return}if(n.type===`resourceUsage`){if(!e)throw Error(`No docx loaded`);$({type:`resourceUsage`,id:r,usage:I(X.run(()=>e.resource_usage()))});return}if(n.type===`toMarkdown`){if(!e)throw Error(`No docx loaded`);$({type:`markdownRendered`,id:r,markdown:X.run(()=>e.to_markdown())});return}}catch(e){$({type:`error`,id:r,...W(e)})}};", Ct = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", St], { type: "text/javascript;charset=utf-8" });
|
|
150
|
+
function wt(e) {
|
|
150
151
|
let t;
|
|
151
152
|
try {
|
|
152
|
-
if (t =
|
|
153
|
+
if (t = Ct && (self.URL || self.webkitURL).createObjectURL(Ct), !t) throw "";
|
|
153
154
|
let n = new Worker(t, {
|
|
154
155
|
type: "module",
|
|
155
156
|
name: e?.name
|
|
@@ -158,7 +159,7 @@ function xt(e) {
|
|
|
158
159
|
(self.URL || self.webkitURL).revokeObjectURL(t);
|
|
159
160
|
}), n;
|
|
160
161
|
} catch {
|
|
161
|
-
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(
|
|
162
|
+
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(St), {
|
|
162
163
|
type: "module",
|
|
163
164
|
name: e?.name
|
|
164
165
|
});
|
|
@@ -166,17 +167,17 @@ function xt(e) {
|
|
|
166
167
|
}
|
|
167
168
|
//#endregion
|
|
168
169
|
//#region packages/docx/src/wasm/docx_parser_bg.wasm?url
|
|
169
|
-
var
|
|
170
|
+
var Tt = new URL("docx_parser_bg.wasm", import.meta.url).href;
|
|
170
171
|
//#endregion
|
|
171
172
|
//#region packages/docx/src/bookmark-nav.ts
|
|
172
|
-
function
|
|
173
|
+
function Et(e) {
|
|
173
174
|
let t = /* @__PURE__ */ new Map();
|
|
174
175
|
for (let n of e.pages) for (let e of n.bookmarkStarts) e.name !== "" && !t.has(e.name) && t.set(e.name, n.pageIndex);
|
|
175
176
|
return t;
|
|
176
177
|
}
|
|
177
178
|
//#endregion
|
|
178
179
|
//#region packages/docx/src/embedded-fonts.ts
|
|
179
|
-
async function
|
|
180
|
+
async function Dt(e, t) {
|
|
180
181
|
let n = e.embeddedFonts;
|
|
181
182
|
if (!n || n.length === 0) return {
|
|
182
183
|
faces: [],
|
|
@@ -184,7 +185,7 @@ async function wt(e, t) {
|
|
|
184
185
|
};
|
|
185
186
|
let r = [], i = /* @__PURE__ */ new Set();
|
|
186
187
|
for (let e of n) {
|
|
187
|
-
let t =
|
|
188
|
+
let t = Ot(e.style) === "bold" ? 700 : 400, n = kt(e.style), a = `${Ae(e.fontName)}:${t}:${n}`;
|
|
188
189
|
i.has(a) || (i.add(a), r.push(e));
|
|
189
190
|
}
|
|
190
191
|
let a = (await Promise.all(r.map(async (e) => {
|
|
@@ -194,23 +195,23 @@ async function wt(e, t) {
|
|
|
194
195
|
bytes: n,
|
|
195
196
|
odttf: r,
|
|
196
197
|
fontKey: e.fontKey,
|
|
197
|
-
weight:
|
|
198
|
-
style:
|
|
198
|
+
weight: Ot(e.style),
|
|
199
|
+
style: kt(e.style)
|
|
199
200
|
};
|
|
200
|
-
if (!
|
|
201
|
+
if (!Ee(n)) return {
|
|
201
202
|
face: i,
|
|
202
203
|
metric: null
|
|
203
204
|
};
|
|
204
205
|
let a = i, o = null;
|
|
205
206
|
try {
|
|
206
|
-
let t = r ?
|
|
207
|
+
let t = r ? xe(n, e.fontKey ?? "") : n;
|
|
207
208
|
a = {
|
|
208
209
|
...i,
|
|
209
210
|
bytes: t,
|
|
210
211
|
odttf: !1,
|
|
211
212
|
fontKey: ""
|
|
212
213
|
};
|
|
213
|
-
let s =
|
|
214
|
+
let s = xt(t), c = s?.hasEastAsianCmap ? Me(s) : 0;
|
|
214
215
|
c > 0 && (o = Object.freeze({
|
|
215
216
|
family: e.fontName,
|
|
216
217
|
requestedFamily: e.fontName,
|
|
@@ -233,13 +234,13 @@ async function wt(e, t) {
|
|
|
233
234
|
faces: [],
|
|
234
235
|
metrics: {}
|
|
235
236
|
};
|
|
236
|
-
let o = await
|
|
237
|
+
let o = await ve(a.map((e) => e.face)), s = new Set(o.map((e) => {
|
|
237
238
|
let t = e.family.trim().replace(/^(['"])(.*)\1$/, "$2"), n = e.weight === "bold" ? 700 : Number(e.weight) || 400, r = e.style === "italic" ? "italic" : "normal";
|
|
238
|
-
return `${
|
|
239
|
+
return `${Ae(t)}:${n}:${r}`;
|
|
239
240
|
})), c = {};
|
|
240
241
|
for (let e of a) {
|
|
241
242
|
if (!e.metric) continue;
|
|
242
|
-
let t =
|
|
243
|
+
let t = Ae(e.face.family), n = e.face.weight === "bold" ? 700 : 400, r = e.face.style, i = `${t}:${n}:${r}`;
|
|
243
244
|
s.has(i) && (c[n === 400 && r === "normal" ? t : i] = e.metric);
|
|
244
245
|
}
|
|
245
246
|
return {
|
|
@@ -247,16 +248,16 @@ async function wt(e, t) {
|
|
|
247
248
|
metrics: Object.freeze(c)
|
|
248
249
|
};
|
|
249
250
|
}
|
|
250
|
-
function
|
|
251
|
+
function Ot(e) {
|
|
251
252
|
return e === "bold" || e === "boldItalic" ? "bold" : "normal";
|
|
252
253
|
}
|
|
253
|
-
function
|
|
254
|
+
function kt(e) {
|
|
254
255
|
return e === "italic" || e === "boldItalic" ? "italic" : "normal";
|
|
255
256
|
}
|
|
256
257
|
//#endregion
|
|
257
258
|
//#region packages/docx/src/element-context.ts
|
|
258
|
-
var
|
|
259
|
-
function
|
|
259
|
+
var I = fe, At = 16384;
|
|
260
|
+
function jt(e, t) {
|
|
260
261
|
let n = Math.min(e.length, t);
|
|
261
262
|
if (n > 0 && n < e.length) {
|
|
262
263
|
let t = e.charCodeAt(n - 1), r = e.charCodeAt(n);
|
|
@@ -264,7 +265,7 @@ function Ot(e, t) {
|
|
|
264
265
|
}
|
|
265
266
|
return e.slice(0, n);
|
|
266
267
|
}
|
|
267
|
-
function
|
|
268
|
+
function Mt(e, t) {
|
|
268
269
|
let n = [], r = 0, i = !1;
|
|
269
270
|
for (let a of e) {
|
|
270
271
|
if (a.length === 0) continue;
|
|
@@ -275,7 +276,7 @@ function kt(e, t) {
|
|
|
275
276
|
}
|
|
276
277
|
n.push("\n"), r++;
|
|
277
278
|
}
|
|
278
|
-
let e =
|
|
279
|
+
let e = jt(a, Math.max(0, t - r));
|
|
279
280
|
if (n.push(e), r += e.length, e.length < a.length) {
|
|
280
281
|
i = !0;
|
|
281
282
|
break;
|
|
@@ -287,7 +288,7 @@ function kt(e, t) {
|
|
|
287
288
|
truncated: i
|
|
288
289
|
};
|
|
289
290
|
}
|
|
290
|
-
function*
|
|
291
|
+
function* L(e) {
|
|
291
292
|
if (e.kind === "paragraph") {
|
|
292
293
|
for (let t of e.lines) {
|
|
293
294
|
let e = t.placements.flatMap((e) => e.kind === "text" ? [e.text] : []).join("");
|
|
@@ -296,32 +297,32 @@ function* R(e) {
|
|
|
296
297
|
return;
|
|
297
298
|
}
|
|
298
299
|
if (e.kind === "table") {
|
|
299
|
-
for (let t of e.rows) for (let e of t.cells) for (let t of e.blocks) yield*
|
|
300
|
+
for (let t of e.rows) for (let e of t.cells) for (let t of e.blocks) yield* L(t.layout);
|
|
300
301
|
return;
|
|
301
302
|
}
|
|
302
|
-
if (e.kind === "note" || e.kind === "textbox") for (let t of e.story.blocks) yield*
|
|
303
|
+
if (e.kind === "note" || e.kind === "textbox") for (let t of e.story.blocks) yield* L(t);
|
|
303
304
|
}
|
|
304
|
-
function*
|
|
305
|
+
function* Nt(e) {
|
|
305
306
|
for (let t of e.drawing.commands) (t.kind === "text" || t.kind === "watermark-text") && (yield t.text);
|
|
306
|
-
for (let t of e.textBoxes) yield*
|
|
307
|
+
for (let t of e.textBoxes) yield* L(t);
|
|
307
308
|
}
|
|
308
|
-
function
|
|
309
|
-
let t = e ??
|
|
309
|
+
function Pt(e) {
|
|
310
|
+
let t = e ?? At;
|
|
310
311
|
if (!Number.isFinite(t) || t < 0) throw RangeError("maxTextCharacters must be a finite non-negative number.");
|
|
311
|
-
return Math.min(
|
|
312
|
+
return Math.min(I, Math.floor(t));
|
|
312
313
|
}
|
|
313
|
-
function
|
|
314
|
+
function Ft(e) {
|
|
314
315
|
return {
|
|
315
316
|
story: e.story,
|
|
316
317
|
storyInstance: e.storyInstance,
|
|
317
318
|
path: [...e.path]
|
|
318
319
|
};
|
|
319
320
|
}
|
|
320
|
-
function
|
|
321
|
+
function It(e) {
|
|
321
322
|
return "drawing" in e ? e.drawing.inkBounds : e.placement.bounds;
|
|
322
323
|
}
|
|
323
|
-
function
|
|
324
|
-
let t =
|
|
324
|
+
function Lt(e) {
|
|
325
|
+
let t = It(e), n = [
|
|
325
326
|
E(e.pointToPage, t),
|
|
326
327
|
E(e.pointToPage, {
|
|
327
328
|
xPt: t.xPt + t.widthPt,
|
|
@@ -343,10 +344,10 @@ function Pt(e) {
|
|
|
343
344
|
heightPt: o - i
|
|
344
345
|
};
|
|
345
346
|
}
|
|
346
|
-
function
|
|
347
|
+
function R(e, t) {
|
|
347
348
|
return t.xPt >= e.xPt && t.xPt <= e.xPt + e.widthPt && t.yPt >= e.yPt && t.yPt <= e.yPt + e.heightPt;
|
|
348
349
|
}
|
|
349
|
-
function
|
|
350
|
+
function Rt(e, t) {
|
|
350
351
|
let n = !1;
|
|
351
352
|
for (let r = 0, i = t.length - 1; r < t.length; i = r++) {
|
|
352
353
|
let a = t[r], o = t[i];
|
|
@@ -354,35 +355,35 @@ function Ft(e, t) {
|
|
|
354
355
|
}
|
|
355
356
|
return n;
|
|
356
357
|
}
|
|
357
|
-
function
|
|
358
|
-
return
|
|
358
|
+
function zt(e, t) {
|
|
359
|
+
return R(e.inkBounds, t) ? e.clip ? e.clip.kind === "rect" ? R(e.clip.rect, t) : Rt(t, e.clip.points) : !0 : !1;
|
|
359
360
|
}
|
|
360
|
-
function
|
|
361
|
+
function Bt(e, t, n) {
|
|
361
362
|
for (let n of e.clips) {
|
|
362
|
-
let e =
|
|
363
|
-
if (!e || !
|
|
363
|
+
let e = je(n.pointToPage, t);
|
|
364
|
+
if (!e || !R(n.bounds, e)) return !1;
|
|
364
365
|
}
|
|
365
|
-
return "drawing" in e ?
|
|
366
|
+
return "drawing" in e ? zt(e.drawing, n) : R(e.placement.bounds, n);
|
|
366
367
|
}
|
|
367
|
-
function
|
|
368
|
+
function z(e, t) {
|
|
368
369
|
return e.commands.find((e) => e.kind === "resource" && e.resourceKind === t);
|
|
369
370
|
}
|
|
370
|
-
function
|
|
371
|
-
return
|
|
371
|
+
function Vt(e) {
|
|
372
|
+
return z(e, "chart") ? "chart" : e.commands.some((e) => e.kind === "drawingml-shape" || e.kind === "drawingml-image-fill" || e.kind === "fill-rect" || e.kind === "stroke-rect" || e.kind === "text" || e.kind === "watermark-text") ? "shape" : z(e, "image") ? "image" : null;
|
|
372
373
|
}
|
|
373
|
-
function
|
|
374
|
-
let o = "drawing" in e ?
|
|
374
|
+
function Ht(e, t, n, r, i, a) {
|
|
375
|
+
let o = "drawing" in e ? Vt(e.drawing) : e.placement.resourceKind;
|
|
375
376
|
if (!o) return null;
|
|
376
377
|
let s, c = !1, l, u;
|
|
377
378
|
if (o === "chart") {
|
|
378
|
-
let t = "drawing" in e ?
|
|
379
|
+
let t = "drawing" in e ? z(e.drawing, "chart").resourceKey : e.placement.resourceKey, n = i.resolve(t, "chart"), r = te(n.model, a);
|
|
379
380
|
s = r.text, c = r.truncated, u = n.model.series.length;
|
|
380
381
|
} else if (o === "image") {
|
|
381
|
-
let t = "drawing" in e ?
|
|
382
|
+
let t = "drawing" in e ? z(e.drawing, "image").resourceKey : e.placement.resourceKey, n = i.descriptors.find((e) => e.resourceKey === t && e.kind === "image" && "mimeType" in e);
|
|
382
383
|
if (!n) throw Error(`Unknown image paint resource: ${t}`);
|
|
383
384
|
l = n.mimeType;
|
|
384
385
|
} else {
|
|
385
|
-
let t =
|
|
386
|
+
let t = Mt(Nt(e), a);
|
|
386
387
|
s = t.text, c = t.truncated;
|
|
387
388
|
}
|
|
388
389
|
return {
|
|
@@ -392,8 +393,8 @@ function zt(e, t, n, r, i, a) {
|
|
|
392
393
|
elementIndex: n,
|
|
393
394
|
elementType: o,
|
|
394
395
|
point: { ...r },
|
|
395
|
-
bounds:
|
|
396
|
-
source:
|
|
396
|
+
bounds: Lt(e),
|
|
397
|
+
source: Ft("drawing" in e ? e.drawing.source : e.source),
|
|
397
398
|
...s === void 0 ? {} : { text: s },
|
|
398
399
|
...l === void 0 ? {} : { mimeType: l },
|
|
399
400
|
...u === void 0 ? {} : { seriesCount: u },
|
|
@@ -403,26 +404,26 @@ function zt(e, t, n, r, i, a) {
|
|
|
403
404
|
maxTextCharacters: a
|
|
404
405
|
};
|
|
405
406
|
}
|
|
406
|
-
function
|
|
407
|
+
function Ut(e, t, n, r, i = {}) {
|
|
407
408
|
if (!Number.isFinite(n.xPt) || !Number.isFinite(n.yPt)) throw RangeError("DOCX hit-test point must contain finite page coordinates.");
|
|
408
|
-
let a =
|
|
409
|
+
let a = Pt(i.maxTextCharacters), o = Fe(e, t);
|
|
409
410
|
for (let e = o.length - 1; e >= 0; e--) {
|
|
410
|
-
let i = o[e], s =
|
|
411
|
-
if (!s || !
|
|
412
|
-
let c =
|
|
411
|
+
let i = o[e], s = je(i.pointToPage, n);
|
|
412
|
+
if (!s || !Bt(i, n, s)) continue;
|
|
413
|
+
let c = Ht(i, t, e, n, r, a);
|
|
413
414
|
if (c) return c;
|
|
414
415
|
}
|
|
415
416
|
return null;
|
|
416
417
|
}
|
|
417
|
-
function
|
|
418
|
-
return
|
|
418
|
+
function Wt(e, t, n, r) {
|
|
419
|
+
return Ut(Xe(e, {
|
|
419
420
|
currentDate: r.currentDate,
|
|
420
421
|
defaultCurrentDateMs: r.defaultCurrentDateMs,
|
|
421
422
|
showTrackedChanges: r.showTrackedChanges
|
|
422
|
-
}, t).layout, t, n,
|
|
423
|
+
}, t).layout, t, n, De(e), r);
|
|
423
424
|
}
|
|
424
|
-
function
|
|
425
|
-
let n =
|
|
425
|
+
function Gt(e, t) {
|
|
426
|
+
let n = Pt(t), r = e.text === void 0 ? void 0 : jt(e.text, n), i = e.truncated || e.text !== void 0 && r.length < e.text.length;
|
|
426
427
|
return {
|
|
427
428
|
...structuredClone(e),
|
|
428
429
|
...r === void 0 ? {} : { text: r },
|
|
@@ -434,8 +435,8 @@ function Ht(e, t) {
|
|
|
434
435
|
}
|
|
435
436
|
//#endregion
|
|
436
437
|
//#region packages/docx/src/revisions.ts
|
|
437
|
-
function
|
|
438
|
-
let t =
|
|
438
|
+
function B(e) {
|
|
439
|
+
let t = st(e.id);
|
|
439
440
|
return t === void 0 ? void 0 : `${e.kind}\u0000${t}`;
|
|
440
441
|
}
|
|
441
442
|
function V(e) {
|
|
@@ -444,10 +445,10 @@ function V(e) {
|
|
|
444
445
|
path: Object.freeze([...e.path])
|
|
445
446
|
});
|
|
446
447
|
}
|
|
447
|
-
function
|
|
448
|
+
function Kt(e, t) {
|
|
448
449
|
return e !== void 0 && e.story === t.story && e.storyInstance === t.storyInstance && e.path.length === t.path.length && e.path.every((e, n) => e === t.path[n]);
|
|
449
450
|
}
|
|
450
|
-
function
|
|
451
|
+
function qt(e, t) {
|
|
451
452
|
let n = 0, r = e.length;
|
|
452
453
|
for (; n < r;) {
|
|
453
454
|
let i = n + Math.floor((r - n) / 2);
|
|
@@ -455,11 +456,11 @@ function Gt(e, t) {
|
|
|
455
456
|
}
|
|
456
457
|
return n;
|
|
457
458
|
}
|
|
458
|
-
function
|
|
459
|
+
function Jt(e, t) {
|
|
459
460
|
let n = Array(e.length), r;
|
|
460
461
|
for (let i = e.length - 1; i >= 0; --i) {
|
|
461
462
|
n[i] = r;
|
|
462
|
-
let a = e[i], o = t.get(
|
|
463
|
+
let a = e[i], o = t.get(j(a.source))?.[0];
|
|
463
464
|
o !== void 0 && (r = Object.freeze({
|
|
464
465
|
source: V(a.source),
|
|
465
466
|
sourceRunIndex: o
|
|
@@ -468,7 +469,7 @@ function Kt(e, t) {
|
|
|
468
469
|
let i = Array(e.length), a;
|
|
469
470
|
for (let n = 0; n < e.length; n += 1) {
|
|
470
471
|
i[n] = a;
|
|
471
|
-
let r = e[n], o = t.get(
|
|
472
|
+
let r = e[n], o = t.get(j(r.source))?.at(-1);
|
|
472
473
|
o !== void 0 && (a = Object.freeze({
|
|
473
474
|
source: V(r.source),
|
|
474
475
|
sourceRunIndex: o
|
|
@@ -479,17 +480,17 @@ function Kt(e, t) {
|
|
|
479
480
|
preceding: i
|
|
480
481
|
};
|
|
481
482
|
}
|
|
482
|
-
function
|
|
483
|
-
let o = r[e], s = i.get(
|
|
483
|
+
function Yt(e, t, n, r, i, a) {
|
|
484
|
+
let o = r[e], s = i.get(j(o.source)) ?? [], c = s[qt(s, n)], l = s[qt(s, t) - 1], u = c ?? l;
|
|
484
485
|
return u === void 0 ? a.following[e] ?? a.preceding[e] : Object.freeze({
|
|
485
486
|
source: V(o.source),
|
|
486
487
|
sourceRunIndex: u
|
|
487
488
|
});
|
|
488
489
|
}
|
|
489
|
-
function
|
|
490
|
+
function Xt(e, t, n = /* @__PURE__ */ new Map()) {
|
|
490
491
|
let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
|
|
491
492
|
e.forEach((e, t) => {
|
|
492
|
-
let n =
|
|
493
|
+
let n = B(e);
|
|
493
494
|
n === void 0 || i.has(n) || (r.has(n) ? (r.delete(n), i.add(n)) : r.set(n, t));
|
|
494
495
|
});
|
|
495
496
|
let a = t.blocks.sources.flatMap((e) => {
|
|
@@ -499,11 +500,11 @@ function Jt(e, t, n = /* @__PURE__ */ new Map()) {
|
|
|
499
500
|
source: e,
|
|
500
501
|
runs: n.runs
|
|
501
502
|
}] : [];
|
|
502
|
-
}), o = new Map([...n].map(([e, t]) => [e, Object.freeze([...t].sort((e, t) => e - t))])), s =
|
|
503
|
+
}), o = new Map([...n].map(([e, t]) => [e, Object.freeze([...t].sort((e, t) => e - t))])), s = Jt(a, o), c = [];
|
|
503
504
|
for (let [e, t] of a.entries()) {
|
|
504
505
|
let n = 0;
|
|
505
506
|
for (; n < t.runs.length;) {
|
|
506
|
-
let i = t.runs[n], l = i.revision?.kind ?
|
|
507
|
+
let i = t.runs[n], l = i.revision?.kind ? B({
|
|
507
508
|
kind: i.revision.kind,
|
|
508
509
|
id: i.revision.id
|
|
509
510
|
}) : void 0, u = l === void 0 ? void 0 : r.get(l);
|
|
@@ -514,13 +515,13 @@ function Jt(e, t, n = /* @__PURE__ */ new Map()) {
|
|
|
514
515
|
let d = n;
|
|
515
516
|
for (n += 1; n < t.runs.length;) {
|
|
516
517
|
let e = t.runs[n].revision;
|
|
517
|
-
if (!e?.kind ||
|
|
518
|
+
if (!e?.kind || B({
|
|
518
519
|
kind: e.kind,
|
|
519
520
|
id: e.id
|
|
520
521
|
}) !== l) break;
|
|
521
522
|
n += 1;
|
|
522
523
|
}
|
|
523
|
-
let f = n, p = o.get(
|
|
524
|
+
let f = n, p = o.get(j(t.source)) ?? [], m = (p[qt(p, d)] ?? f) < f ? void 0 : Yt(e, d, f, a, o, s);
|
|
524
525
|
c.push(Object.freeze({
|
|
525
526
|
revisionIndex: u,
|
|
526
527
|
source: V(t.source),
|
|
@@ -532,26 +533,26 @@ function Jt(e, t, n = /* @__PURE__ */ new Map()) {
|
|
|
532
533
|
}
|
|
533
534
|
return c;
|
|
534
535
|
}
|
|
535
|
-
function
|
|
536
|
+
function Zt(e, t, n = /* @__PURE__ */ new Map(), r = {}) {
|
|
536
537
|
if ((e?.length ?? 0) === 0) return [];
|
|
537
|
-
let i =
|
|
538
|
+
let i = Xt(e ?? [], t, n), a = r.completedSourceKeys;
|
|
538
539
|
return a === void 0 ? i : i.filter((e) => {
|
|
539
|
-
let t = n.get(
|
|
540
|
-
return t !== void 0 && [...t].some((t) => t >= e.startRunIndex && t < e.endRunIndex) || a.has(
|
|
540
|
+
let t = n.get(j(e.source));
|
|
541
|
+
return t !== void 0 && [...t].some((t) => t >= e.startRunIndex && t < e.endRunIndex) || a.has(j(e.source));
|
|
541
542
|
});
|
|
542
543
|
}
|
|
543
|
-
function
|
|
544
|
-
let n = t.filter((t) => t.sourceRunIndex !== void 0 &&
|
|
544
|
+
function Qt(e, t) {
|
|
545
|
+
let n = t.filter((t) => t.sourceRunIndex !== void 0 && Kt(t.source, e.source) && t.sourceRunIndex >= e.startRunIndex && t.sourceRunIndex < e.endRunIndex);
|
|
545
546
|
if (n.length > 0) return n;
|
|
546
547
|
let r = e.geometryFallback;
|
|
547
|
-
return r === void 0 ? [] : t.filter((e) => e.sourceRunIndex === r.sourceRunIndex &&
|
|
548
|
+
return r === void 0 ? [] : t.filter((e) => e.sourceRunIndex === r.sourceRunIndex && Kt(e.source, r.source));
|
|
548
549
|
}
|
|
549
550
|
//#endregion
|
|
550
551
|
//#region packages/docx/src/layout/progressive.ts
|
|
551
|
-
var
|
|
552
|
-
async function
|
|
552
|
+
var $t = 12;
|
|
553
|
+
async function en(e, t, n, r = {}) {
|
|
553
554
|
let { onPreview: i, scheduler: a } = r;
|
|
554
|
-
return
|
|
555
|
+
return ze(Ne(e, t, n, i && e.sequence.length > $t ? { onPages: (e, t) => {
|
|
555
556
|
i(Object.freeze({
|
|
556
557
|
layout: e,
|
|
557
558
|
exact: !1,
|
|
@@ -572,7 +573,7 @@ function U(e, t) {
|
|
|
572
573
|
} catch {}
|
|
573
574
|
}
|
|
574
575
|
}
|
|
575
|
-
function
|
|
576
|
+
function tn(e, t, n, r) {
|
|
576
577
|
let i = H.get(e);
|
|
577
578
|
i || (i = /* @__PURE__ */ new Set(), H.set(e, i));
|
|
578
579
|
let a = Object.freeze({
|
|
@@ -593,7 +594,7 @@ function $t(e, t, n, r) {
|
|
|
593
594
|
}
|
|
594
595
|
//#endregion
|
|
595
596
|
//#region packages/docx/src/document-layout-view.ts
|
|
596
|
-
var W = /* @__PURE__ */ new WeakMap(),
|
|
597
|
+
var W = /* @__PURE__ */ new WeakMap(), nn = /* @__PURE__ */ new WeakMap(), rn = Symbol("docxLayoutViewRequester");
|
|
597
598
|
function G(e) {
|
|
598
599
|
let t = D(e), n = t.activeLayoutOptions;
|
|
599
600
|
return {
|
|
@@ -602,21 +603,21 @@ function G(e) {
|
|
|
602
603
|
};
|
|
603
604
|
}
|
|
604
605
|
async function K(e, t, n) {
|
|
605
|
-
let r = D(e), i =
|
|
606
|
+
let r = D(e), i = ke(t.currentDate, r.defaultCurrentDateMs, t.showTrackedChanges === !0), a = Object.freeze({
|
|
606
607
|
showTrackedChanges: i.showTrackedChanges === !0,
|
|
607
608
|
currentDate: i.currentDateMs
|
|
608
609
|
}), o = {
|
|
609
610
|
showTrackedChanges: a.showTrackedChanges,
|
|
610
611
|
currentDate: a.currentDate,
|
|
611
|
-
[
|
|
612
|
+
[rn]: n
|
|
612
613
|
};
|
|
613
614
|
await e.setLayoutView(o);
|
|
614
615
|
let s = G(e);
|
|
615
616
|
return s.currentDate === a.currentDate && s.showTrackedChanges === a.showTrackedChanges;
|
|
616
617
|
}
|
|
617
|
-
function
|
|
618
|
-
let n = Object.freeze({ ...G(e) }), r = (
|
|
619
|
-
|
|
618
|
+
function an(e, t) {
|
|
619
|
+
let n = Object.freeze({ ...G(e) }), r = (nn.get(e) ?? 0) + 1;
|
|
620
|
+
nn.set(e, r);
|
|
620
621
|
let i = Object.freeze({
|
|
621
622
|
view: n,
|
|
622
623
|
generation: r,
|
|
@@ -630,7 +631,7 @@ function nn(e, t) {
|
|
|
630
631
|
} catch {}
|
|
631
632
|
}
|
|
632
633
|
}
|
|
633
|
-
function
|
|
634
|
+
function on(e, t, n) {
|
|
634
635
|
let r = W.get(e);
|
|
635
636
|
r || (r = /* @__PURE__ */ new Set(), W.set(e, r));
|
|
636
637
|
let i = Object.freeze({
|
|
@@ -643,10 +644,10 @@ function rn(e, t, n) {
|
|
|
643
644
|
}
|
|
644
645
|
//#endregion
|
|
645
646
|
//#region packages/docx/src/document.ts
|
|
646
|
-
function
|
|
647
|
+
function sn(e, t) {
|
|
647
648
|
return e !== null && e.currentDateMs === t.currentDateMs && e.showTrackedChanges === !0 == (t.showTrackedChanges === !0);
|
|
648
649
|
}
|
|
649
|
-
function
|
|
650
|
+
function cn() {
|
|
650
651
|
let e, t;
|
|
651
652
|
return {
|
|
652
653
|
promise: new Promise((n, r) => {
|
|
@@ -656,24 +657,25 @@ function on() {
|
|
|
656
657
|
reject: t
|
|
657
658
|
};
|
|
658
659
|
}
|
|
659
|
-
var
|
|
660
|
+
var ln = Object.freeze([]), un = Object.freeze([]), dn = Object.freeze({
|
|
660
661
|
comments: Object.freeze([]),
|
|
661
662
|
revisions: Object.freeze([])
|
|
662
663
|
});
|
|
663
664
|
function q(e, t) {
|
|
664
|
-
return
|
|
665
|
+
return Ve({
|
|
665
666
|
comments: e,
|
|
666
667
|
revisions: t
|
|
667
668
|
}, "DOCX review metadata");
|
|
668
669
|
}
|
|
669
670
|
var J = class e {
|
|
670
671
|
_metrics = null;
|
|
672
|
+
_cjkFallback = "jp";
|
|
671
673
|
_document = null;
|
|
672
674
|
_source = null;
|
|
673
675
|
_meta = null;
|
|
674
|
-
_review =
|
|
675
|
-
_layoutLifecycle = new
|
|
676
|
-
_layoutObservers = new
|
|
676
|
+
_review = dn;
|
|
677
|
+
_layoutLifecycle = new be();
|
|
678
|
+
_layoutObservers = new Ce();
|
|
677
679
|
_layoutCompletion = null;
|
|
678
680
|
_layoutAbort = null;
|
|
679
681
|
_bookmarkPages = null;
|
|
@@ -692,19 +694,19 @@ var J = class e {
|
|
|
692
694
|
_tiff;
|
|
693
695
|
_worker;
|
|
694
696
|
_bridge;
|
|
695
|
-
_rawParts = new
|
|
697
|
+
_rawParts = new ot({
|
|
696
698
|
maxEntries: 64,
|
|
697
|
-
maxBytes:
|
|
699
|
+
maxBytes: n
|
|
698
700
|
});
|
|
699
701
|
_embeddedFontFaces = [];
|
|
700
702
|
_googleFontFaces = [];
|
|
701
703
|
_fetchImage = (e, t) => this.getImage(e, t);
|
|
702
704
|
constructor(e, t, n, r) {
|
|
703
|
-
this._worker = e, this._mode = t,
|
|
705
|
+
this._worker = e, this._mode = t, Oe(this, n), this._bridge = new me(this._worker, {
|
|
704
706
|
correlate: (e) => "protocol" in e && e.protocol === "ooxml-pull-v1" ? e.requestId : "id" in e ? e.id : void 0,
|
|
705
707
|
onUnsolicited: (e) => this._onWorkerLayoutPush(e),
|
|
706
708
|
toError: (e) => {
|
|
707
|
-
if (!("protocol" in e || e.type !== "error")) return Object.assign(
|
|
709
|
+
if (!("protocol" in e || e.type !== "error")) return Object.assign(a(e), {
|
|
708
710
|
...e.reason === void 0 ? {} : { reason: e.reason },
|
|
709
711
|
...e.outgoingColumnIndex === void 0 ? {} : { outgoingColumnIndex: e.outgoingColumnIndex },
|
|
710
712
|
...e.outgoingColumnCount === void 0 ? {} : { outgoingColumnCount: e.outgoingColumnCount },
|
|
@@ -712,133 +714,134 @@ var J = class e {
|
|
|
712
714
|
});
|
|
713
715
|
}
|
|
714
716
|
});
|
|
715
|
-
let
|
|
717
|
+
let i = new URL(r ?? Tt, location.href).href;
|
|
716
718
|
this._bridge.post({
|
|
717
719
|
type: "init",
|
|
718
|
-
wasmUrl:
|
|
720
|
+
wasmUrl: i
|
|
719
721
|
});
|
|
720
722
|
}
|
|
721
|
-
static async load(t,
|
|
722
|
-
let i =
|
|
723
|
+
static async load(t, n = {}) {
|
|
724
|
+
let i = $e(n.cjkFallback), a = f(n), o = Date.now(), s = n.mode ?? "main", c = new r({
|
|
723
725
|
enabled: !0,
|
|
724
726
|
format: "docx",
|
|
725
|
-
mode:
|
|
726
|
-
policy:
|
|
727
|
-
onMetrics:
|
|
728
|
-
emitToConsole:
|
|
727
|
+
mode: s,
|
|
728
|
+
policy: a.policy,
|
|
729
|
+
onMetrics: a.onResourceMetrics,
|
|
730
|
+
emitToConsole: a.debug
|
|
729
731
|
});
|
|
730
732
|
try {
|
|
731
|
-
if (
|
|
732
|
-
let
|
|
733
|
+
if (s === "worker" && (typeof Worker > "u" || typeof OffscreenCanvas > "u")) throw Error("mode: 'worker' requires Worker and OffscreenCanvas support");
|
|
734
|
+
let r;
|
|
733
735
|
if (typeof t == "string") {
|
|
734
736
|
let e = await fetch(t);
|
|
735
737
|
if (!e.ok) throw Error(`Failed to fetch: ${e.status} ${e.statusText}`);
|
|
736
|
-
|
|
737
|
-
} else
|
|
738
|
-
|
|
739
|
-
let
|
|
738
|
+
r = await e.arrayBuffer();
|
|
739
|
+
} else r = t;
|
|
740
|
+
r = g(await h(r, n.password)), c.setSourceBytes(r.byteLength), c.checkpoint("container ready");
|
|
741
|
+
let l = s === "worker" ? (await import("./render-worker-host-IkHrYOci.js")).createRenderWorker() : new wt(), u = s === "worker" ? it(n) : void 0, d = s === "worker" && !!n.progressiveLayout, f;
|
|
740
742
|
try {
|
|
741
|
-
|
|
742
|
-
let t = D(
|
|
743
|
-
t.activeLayoutOptions =
|
|
744
|
-
onPartial:
|
|
745
|
-
onComplete:
|
|
746
|
-
onProgress:
|
|
747
|
-
layoutOptions:
|
|
743
|
+
f = new e(l, s, o, n.wasmUrl), f._metrics = c, f._cjkFallback = i;
|
|
744
|
+
let t = D(f), p = ke(n.currentDate, t.defaultCurrentDateMs, n.showTrackedChanges === !0);
|
|
745
|
+
t.activeLayoutOptions = p, await f._parse(r, a.policy, s === "worker" ? !!n.useGoogleFonts : !1, n.workerTimeoutMs, (e) => c.observeUsage(e), u, d ? {
|
|
746
|
+
onPartial: n.onLayoutPartial,
|
|
747
|
+
onComplete: n.onLayoutComplete,
|
|
748
|
+
onProgress: n.onLayoutProgress,
|
|
749
|
+
layoutOptions: p,
|
|
748
750
|
abort: new AbortController(),
|
|
749
|
-
firstPublication:
|
|
751
|
+
firstPublication: cn(),
|
|
750
752
|
published: !1,
|
|
751
753
|
settled: !1
|
|
752
|
-
} : void 0),
|
|
753
|
-
let p;
|
|
754
|
-
if (d._mode === "main" && d._document?.embeddedFonts?.length) {
|
|
755
|
-
let e = d, t = await wt(d._document, (t) => e.getFontBytes(t));
|
|
756
|
-
d._embeddedFontFaces = t.faces, p = t.metrics;
|
|
757
|
-
}
|
|
754
|
+
} : void 0), s === "worker" && f._mode === "main" && (c.setMode("main"), console.warn("[ooxml] mode: 'worker' fell back to main-thread rendering because this document requires DOM OpenType vertical glyph selection.")), n.math && f._mode === "worker" && !u?.math && console.warn("[ooxml] a custom math renderer cannot cross the worker boundary; equations will be skipped in mode: 'worker'. Use the math renderer from @silurus/ooxml/math."), n.threeD && f._mode === "worker" && !u?.threeD && console.warn("[ooxml] a custom 3-D chart renderer cannot cross the worker boundary; charts use their 2-D family fallback in mode: 'worker'. Use the renderer from @silurus/ooxml/three-d."), f._threeD = f._mode === "worker" ? void 0 : n.threeD, n.regionMap && f._mode === "worker" && !u?.regionMap && console.warn("[ooxml] a custom Region Map renderer cannot cross the worker boundary; geospatial charts use the unsupported-chart placeholder in mode: 'worker'. Use the renderer from @silurus/ooxml/region-map."), f._regionMap = f._mode === "worker" ? void 0 : n.regionMap, n.chartEx && f._mode === "worker" && !u?.chartEx && console.warn("[ooxml] a custom ChartEx renderer cannot cross the worker boundary; ChartEx charts use the unsupported-chart placeholder in mode: 'worker'. Use the renderer from @silurus/ooxml/chart-ex."), f._chartEx = f._mode === "worker" ? void 0 : n.chartEx, n.tiff && f._mode === "worker" && !u?.tiff && console.warn("[ooxml] a custom TIFF codec cannot cross the worker boundary; recognized TIFF images will use an unavailable-image placeholder in mode: 'worker'. Use the codec from @silurus/ooxml/tiff to display them."), f._tiff = f._mode === "worker" ? void 0 : n.tiff, f._mode === "main" && n.useGoogleFonts && f._document && (f._googleFontFaces = await m(Re(f._document, i), Le));
|
|
758
755
|
let h;
|
|
759
|
-
if (
|
|
760
|
-
let e =
|
|
761
|
-
|
|
762
|
-
|
|
756
|
+
if (f._mode === "main" && f._document?.embeddedFonts?.length) {
|
|
757
|
+
let e = f, t = await Dt(f._document, (t) => e.getFontBytes(t));
|
|
758
|
+
f._embeddedFontFaces = t.faces, h = t.metrics;
|
|
759
|
+
}
|
|
760
|
+
let g;
|
|
761
|
+
if (f._mode === "main" && n.math && f._document && Ke(f._document) && (g = await Je(f._document, n.math)), f._mode === "main" && f._document && f._source) {
|
|
762
|
+
let e = f, t = D(f);
|
|
763
|
+
t.services = Ue(f._source, {
|
|
764
|
+
fontMetrics: h,
|
|
763
765
|
measureResolvedFontMetrics: !0,
|
|
764
|
-
resolvedFontMetricCandidates:
|
|
765
|
-
useGoogleFonts: !!
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
766
|
+
resolvedFontMetricCandidates: qe(f._document, f._source.fontFamilyCharsets),
|
|
767
|
+
useGoogleFonts: !!n.useGoogleFonts,
|
|
768
|
+
cjkFallback: i,
|
|
769
|
+
embeddedFaces: f._embeddedFontFaces,
|
|
770
|
+
googleFaces: f._googleFontFaces,
|
|
771
|
+
mathResources: g?.records,
|
|
772
|
+
mathDrawables: g?.drawables
|
|
770
773
|
});
|
|
771
|
-
let
|
|
772
|
-
if (!
|
|
773
|
-
let
|
|
774
|
-
if (
|
|
775
|
-
let e =
|
|
776
|
-
t._layoutAbort =
|
|
777
|
-
let
|
|
778
|
-
t._layoutCompletion =
|
|
774
|
+
let r = t.services, a = Pe(f._source, r, t.defaultCurrentDateMs), o = f._source.fatalParse === null, s = t.activeLayoutOptions;
|
|
775
|
+
if (!s) throw Error("Active layout view was not recorded at load");
|
|
776
|
+
let c = { onProgress: n.onLayoutProgress ? (t) => e._layoutObservers.notify("onLayoutProgress", n.onLayoutProgress, { committedUnits: t }) : void 0 };
|
|
777
|
+
if (o && n.progressiveLayout) {
|
|
778
|
+
let e = a.layoutVariants, t = f, i = new AbortController();
|
|
779
|
+
t._layoutAbort = i;
|
|
780
|
+
let o = cn(), l = null, u = !0;
|
|
781
|
+
t._layoutCompletion = en(f._source.bodyLayoutInput, r, s, {
|
|
779
782
|
scheduler: {
|
|
780
|
-
...
|
|
781
|
-
signal:
|
|
783
|
+
...c,
|
|
784
|
+
signal: i.signal
|
|
782
785
|
},
|
|
783
|
-
onPreview: (
|
|
786
|
+
onPreview: (r) => {
|
|
784
787
|
if (!u) return;
|
|
785
|
-
let i = l === null, a = t._replaceMainLayoutPublication(e,
|
|
788
|
+
let i = l === null, a = t._replaceMainLayoutPublication(e, s, l, r.layout);
|
|
786
789
|
if (a === null) {
|
|
787
790
|
u = !1;
|
|
788
791
|
return;
|
|
789
792
|
}
|
|
790
793
|
if (l = a, i) t._layoutLifecycle.begin(), U(t, {
|
|
791
|
-
pageCount:
|
|
792
|
-
exact:
|
|
794
|
+
pageCount: r.layout.pages.length,
|
|
795
|
+
exact: r.exact,
|
|
793
796
|
complete: !1
|
|
794
|
-
}),
|
|
797
|
+
}), o.resolve();
|
|
795
798
|
else {
|
|
796
|
-
if (!t._isLayoutViewActive(
|
|
799
|
+
if (!t._isLayoutViewActive(s)) return;
|
|
797
800
|
U(t, {
|
|
798
|
-
pageCount:
|
|
799
|
-
exact:
|
|
801
|
+
pageCount: r.layout.pages.length,
|
|
802
|
+
exact: r.exact,
|
|
800
803
|
complete: !1
|
|
801
|
-
}), t._layoutObservers.notify("onLayoutPartial",
|
|
802
|
-
availableUnits:
|
|
803
|
-
exact:
|
|
804
|
+
}), t._layoutObservers.notify("onLayoutPartial", n.onLayoutPartial, {
|
|
805
|
+
availableUnits: r.layout.pages.length,
|
|
806
|
+
exact: r.exact
|
|
804
807
|
});
|
|
805
808
|
}
|
|
806
809
|
}
|
|
807
|
-
}).then((
|
|
808
|
-
u && t._replaceMainLayoutPublication(e,
|
|
810
|
+
}).then((r) => {
|
|
811
|
+
u && t._replaceMainLayoutPublication(e, s, l, r) === null && (u = !1), t._layoutLifecycle.succeed(), U(t, {
|
|
809
812
|
pageCount: t.pageCount,
|
|
810
813
|
exact: !0,
|
|
811
814
|
complete: !0
|
|
812
|
-
}),
|
|
815
|
+
}), t._layoutObservers.notify("onLayoutComplete", n.onLayoutComplete), o.resolve();
|
|
813
816
|
}).catch((e) => {
|
|
814
817
|
if (l === null) {
|
|
815
|
-
|
|
818
|
+
o.reject(e);
|
|
816
819
|
return;
|
|
817
820
|
}
|
|
818
|
-
if (e instanceof
|
|
821
|
+
if (e instanceof Be) {
|
|
819
822
|
t._layoutLifecycle.succeed();
|
|
820
823
|
return;
|
|
821
824
|
}
|
|
822
|
-
let
|
|
825
|
+
let r = t._layoutLifecycle.fail(e);
|
|
823
826
|
U(t, {
|
|
824
827
|
pageCount: t.pageCount,
|
|
825
828
|
exact: !1,
|
|
826
829
|
complete: !1,
|
|
827
|
-
error:
|
|
828
|
-
}), t._layoutObservers.notify("onLayoutComplete",
|
|
829
|
-
}), await
|
|
830
|
-
} else if (
|
|
831
|
-
let e = await
|
|
832
|
-
|
|
833
|
-
} else
|
|
830
|
+
error: r
|
|
831
|
+
}), t._layoutObservers.notify("onLayoutComplete", n.onLayoutComplete, r);
|
|
832
|
+
}), await o.promise;
|
|
833
|
+
} else if (o && (n.sliceLayout || n.onLayoutProgress)) {
|
|
834
|
+
let e = await We(f._source.bodyLayoutInput, r, s, c);
|
|
835
|
+
a.layoutVariants.prime(s, e);
|
|
836
|
+
} else a.layoutVariants.layoutFor(s);
|
|
834
837
|
}
|
|
835
|
-
return await
|
|
838
|
+
return await f._resourceUsage(n.workerTimeoutMs ?? 1e3).then((e) => c.observeUsage(e), () => void 0), c.checkpoint("model and layout ready"), c.succeed({ pages: f.pageCount }), f;
|
|
836
839
|
} catch (e) {
|
|
837
|
-
let t =
|
|
838
|
-
throw p(
|
|
840
|
+
let t = f;
|
|
841
|
+
throw p(l, t ? () => t.destroy() : void 0), e;
|
|
839
842
|
}
|
|
840
843
|
} catch (e) {
|
|
841
|
-
throw
|
|
844
|
+
throw c.fail(e), e;
|
|
842
845
|
}
|
|
843
846
|
}
|
|
844
847
|
async _parse(e, t, n = !1, r, i, a, o) {
|
|
@@ -852,6 +855,7 @@ var J = class e {
|
|
|
852
855
|
data: e,
|
|
853
856
|
resourcePolicy: t,
|
|
854
857
|
useGoogleFonts: n,
|
|
858
|
+
cjkFallback: this._cjkFallback,
|
|
855
859
|
defaultCurrentDateMs: D(this).defaultCurrentDateMs,
|
|
856
860
|
...this._parseViewFields(),
|
|
857
861
|
renderers: a
|
|
@@ -863,14 +867,14 @@ var J = class e {
|
|
|
863
867
|
}, [e], { timeoutMs: r });
|
|
864
868
|
if ("protocol" in s) throw Error("DOCX parse open returned a pull-protocol response");
|
|
865
869
|
if (this._mode === "worker") if ("usage" in s && s.usage && i?.(s.usage), s.type === "mainThreadVerticalFallback") {
|
|
866
|
-
let e = await
|
|
870
|
+
let e = await Ge(this._bridge.transport(O), s, {
|
|
867
871
|
timeoutMs: r,
|
|
868
872
|
onUsage: i
|
|
869
873
|
});
|
|
870
874
|
this._source = e.source, this._document = e.document, this._meta = null, this._mode = "main";
|
|
871
875
|
} else this._meta = s.meta;
|
|
872
876
|
else {
|
|
873
|
-
let e = s, t = await
|
|
877
|
+
let e = s, t = await Ge(this._bridge.transport(O), e, {
|
|
874
878
|
timeoutMs: r,
|
|
875
879
|
onUsage: i
|
|
876
880
|
});
|
|
@@ -941,7 +945,7 @@ var J = class e {
|
|
|
941
945
|
pageCount: this.pageCount,
|
|
942
946
|
exact: !0,
|
|
943
947
|
complete: !0
|
|
944
|
-
}), t.firstPublication.resolve(),
|
|
948
|
+
}), t.firstPublication.resolve(), this._layoutObservers.notify("onLayoutComplete", t.onComplete));
|
|
945
949
|
}
|
|
946
950
|
}
|
|
947
951
|
_invalidateLayoutDerivedCaches() {
|
|
@@ -952,7 +956,7 @@ var J = class e {
|
|
|
952
956
|
return i !== null && this._isLayoutViewActive(t) && this._invalidateLayoutDerivedCaches(), i;
|
|
953
957
|
}
|
|
954
958
|
_isLayoutViewActive(e) {
|
|
955
|
-
return
|
|
959
|
+
return sn(D(this).activeLayoutOptions, e);
|
|
956
960
|
}
|
|
957
961
|
_rearmParseWatchdog() {
|
|
958
962
|
this._parseWatchdogMs !== void 0 && (clearTimeout(this._parseWatchdog), this._parseWatchdog = setTimeout(() => this._onParseWentSilent(), this._parseWatchdogMs));
|
|
@@ -994,6 +998,7 @@ var J = class e {
|
|
|
994
998
|
data: e,
|
|
995
999
|
resourcePolicy: t,
|
|
996
1000
|
useGoogleFonts: n,
|
|
1001
|
+
cjkFallback: this._cjkFallback,
|
|
997
1002
|
defaultCurrentDateMs: D(this).defaultCurrentDateMs,
|
|
998
1003
|
...this._parseViewFields(),
|
|
999
1004
|
renderers: a,
|
|
@@ -1002,7 +1007,7 @@ var J = class e {
|
|
|
1002
1007
|
if (this._parseRequestId = null, "protocol" in e) throw Error("DOCX parse open returned a pull-protocol response");
|
|
1003
1008
|
if ("usage" in e && e.usage && i?.(e.usage), e.type === "mainThreadVerticalFallback") {
|
|
1004
1009
|
this._clearParseWatchdog(), o.settled = !0, this._progressive = null, this._layoutAbort = null;
|
|
1005
|
-
let t = await
|
|
1010
|
+
let t = await Ge(this._bridge.transport(O), e, {
|
|
1006
1011
|
timeoutMs: r,
|
|
1007
1012
|
onUsage: i
|
|
1008
1013
|
});
|
|
@@ -1021,7 +1026,7 @@ var J = class e {
|
|
|
1021
1026
|
}), this._rearmParseWatchdog(), await o.firstPublication.promise;
|
|
1022
1027
|
}
|
|
1023
1028
|
destroy() {
|
|
1024
|
-
this._layoutAbort?.abort(), this._layoutAbort = null, this._clearParseWatchdog(), this._parseRequestId = null, this._progressive = null, this._layoutViewGeneration++, this._bridge.terminate(), this._document = null, this._source = null, this._meta = null, this._review =
|
|
1029
|
+
this._layoutAbort?.abort(), this._layoutAbort = null, this._clearParseWatchdog(), this._parseRequestId = null, this._progressive = null, this._layoutViewGeneration++, this._bridge.terminate(), this._document = null, this._source = null, this._meta = null, this._review = dn, D(this).services = null, this._bookmarkPages = null, this._commentAnchorRanges = null, this._revisionAnchorRanges = null, this._reviewProjectionIndex = null, this._rawParts.clear(), this._embeddedFontFaces.length > 0 && (ye(this._embeddedFontFaces), this._embeddedFontFaces = []), this._googleFontFaces.length > 0 && (_(this._googleFontFaces), this._googleFontFaces = []), s(this._fetchImage), l(this._fetchImage);
|
|
1025
1030
|
}
|
|
1026
1031
|
async getImage(e, t) {
|
|
1027
1032
|
return this._rawParts.get(e, t, () => this._bridge.request((t) => ({
|
|
@@ -1050,7 +1055,7 @@ var J = class e {
|
|
|
1050
1055
|
async getResourceMetrics() {
|
|
1051
1056
|
let e = this._metrics;
|
|
1052
1057
|
if (!e) throw Error("Document not loaded");
|
|
1053
|
-
return
|
|
1058
|
+
return i(e, (e) => this._resourceUsage(e));
|
|
1054
1059
|
}
|
|
1055
1060
|
async toMarkdown() {
|
|
1056
1061
|
return (await this._bridge.request((e) => ({
|
|
@@ -1082,32 +1087,32 @@ var J = class e {
|
|
|
1082
1087
|
return this._reviewSnapshot().revisions;
|
|
1083
1088
|
}
|
|
1084
1089
|
commentAnchorRanges() {
|
|
1085
|
-
if (this._meta) return this._meta.commentAnchorRanges ??
|
|
1090
|
+
if (this._meta) return this._meta.commentAnchorRanges ?? ln;
|
|
1086
1091
|
if (!this._document || !this._source) return [];
|
|
1087
1092
|
let e = this._reviewSnapshot().comments;
|
|
1088
|
-
if (e.length === 0) return
|
|
1093
|
+
if (e.length === 0) return ln;
|
|
1089
1094
|
let t = D(this), n = t.services;
|
|
1090
1095
|
if (!n) throw Error("Document layout services are not initialized");
|
|
1091
|
-
let r =
|
|
1096
|
+
let r = He(n);
|
|
1092
1097
|
if (!r) throw Error("Document layout variant store is not initialized");
|
|
1093
1098
|
let i = t.activeLayoutOptions, a = i ? r.layoutFor(i) : r.defaultLayout;
|
|
1094
|
-
this._reviewProjectionIndex ??=
|
|
1099
|
+
this._reviewProjectionIndex ??= Ze(a);
|
|
1095
1100
|
let o = this._layoutLifecycle?.complete ?? !0 ? void 0 : { completedSourceKeys: this._reviewProjectionIndex.completedSourceKeys };
|
|
1096
|
-
return this._commentAnchorRanges ??=
|
|
1101
|
+
return this._commentAnchorRanges ??= lt(e, this._source, this._reviewProjectionIndex.renderedRunIndex, o), this._commentAnchorRanges;
|
|
1097
1102
|
}
|
|
1098
1103
|
revisionAnchorRanges() {
|
|
1099
|
-
if (this._meta) return this._meta.revisionAnchorRanges ??
|
|
1104
|
+
if (this._meta) return this._meta.revisionAnchorRanges ?? un;
|
|
1100
1105
|
if (!this._document || !this._source) return [];
|
|
1101
1106
|
let e = this._reviewSnapshot().revisions;
|
|
1102
|
-
if (e.length === 0) return
|
|
1107
|
+
if (e.length === 0) return un;
|
|
1103
1108
|
let t = D(this), n = t.services;
|
|
1104
1109
|
if (!n) throw Error("Document layout services are not initialized");
|
|
1105
|
-
let r =
|
|
1110
|
+
let r = He(n);
|
|
1106
1111
|
if (!r) throw Error("Document layout variant store is not initialized");
|
|
1107
1112
|
let i = t.activeLayoutOptions, a = i ? r.layoutFor(i) : r.defaultLayout;
|
|
1108
|
-
this._reviewProjectionIndex ??=
|
|
1113
|
+
this._reviewProjectionIndex ??= Ze(a);
|
|
1109
1114
|
let o = this._layoutLifecycle?.complete ?? !0 ? void 0 : { completedSourceKeys: this._reviewProjectionIndex.completedSourceKeys };
|
|
1110
|
-
return this._revisionAnchorRanges ??=
|
|
1115
|
+
return this._revisionAnchorRanges ??= Zt(e, this._source, this._reviewProjectionIndex.renderedRunIndex, o), this._revisionAnchorRanges;
|
|
1111
1116
|
}
|
|
1112
1117
|
_reviewSnapshot() {
|
|
1113
1118
|
return this._review ||= q(this._meta?.comments ?? this._document?.comments ?? [], this._meta?.revisions ?? this._document?.revisions ?? []), this._review;
|
|
@@ -1122,14 +1127,14 @@ var J = class e {
|
|
|
1122
1127
|
if (!this._document) return null;
|
|
1123
1128
|
let e = D(this), t = e.services;
|
|
1124
1129
|
if (!t) throw Error("Document layout services are not initialized");
|
|
1125
|
-
let n =
|
|
1130
|
+
let n = He(t);
|
|
1126
1131
|
if (!n) throw Error("Document layout variant store is not initialized");
|
|
1127
1132
|
let r = e.activeLayoutOptions;
|
|
1128
1133
|
return r ? n.layoutFor(r) : n.defaultLayout;
|
|
1129
1134
|
}
|
|
1130
1135
|
async setLayoutView(e = {}) {
|
|
1131
|
-
let t = e[
|
|
1132
|
-
if (!
|
|
1136
|
+
let t = e[rn], n = D(this), r = ke(e.currentDate, n.defaultCurrentDateMs, e.showTrackedChanges === !0), i = ++this._layoutViewGeneration, a = n.activeLayoutOptions;
|
|
1137
|
+
if (!sn(a, r)) {
|
|
1133
1138
|
if (this._mode === "worker" && this._meta) {
|
|
1134
1139
|
let e = await this._bridge.request((e) => ({
|
|
1135
1140
|
type: "selectLayoutView",
|
|
@@ -1142,17 +1147,17 @@ var J = class e {
|
|
|
1142
1147
|
n.activeLayoutOptions = r, this._meta = {
|
|
1143
1148
|
...this._meta,
|
|
1144
1149
|
...a.meta
|
|
1145
|
-
}, this._invalidateLayoutDerivedCaches(),
|
|
1150
|
+
}, this._invalidateLayoutDerivedCaches(), an(this, t);
|
|
1146
1151
|
return;
|
|
1147
1152
|
}
|
|
1148
|
-
n.activeLayoutOptions = r, this._invalidateLayoutDerivedCaches(),
|
|
1153
|
+
n.activeLayoutOptions = r, this._invalidateLayoutDerivedCaches(), an(this, t);
|
|
1149
1154
|
}
|
|
1150
1155
|
}
|
|
1151
1156
|
_getBookmarkPages() {
|
|
1152
1157
|
if (this._bookmarkPages) return this._bookmarkPages;
|
|
1153
1158
|
if (this._meta) return this._bookmarkPages = new Map(this._meta.bookmarkPages), this._bookmarkPages;
|
|
1154
1159
|
let e = this._getLayout();
|
|
1155
|
-
return e ? (this._bookmarkPages =
|
|
1160
|
+
return e ? (this._bookmarkPages = Et(e), this._bookmarkPages) : null;
|
|
1156
1161
|
}
|
|
1157
1162
|
getBookmarkPage(e) {
|
|
1158
1163
|
return this._getBookmarkPages()?.get(e);
|
|
@@ -1192,7 +1197,7 @@ var J = class e {
|
|
|
1192
1197
|
renderPage(e, t, n = {}) {
|
|
1193
1198
|
if (this._mode === "worker") throw Error("renderPage(canvas) is unavailable in mode: 'worker'; use renderPageToBitmap() and paint it via an ImageBitmapRenderingContext");
|
|
1194
1199
|
if (!this._source) throw Error("Document not loaded");
|
|
1195
|
-
return
|
|
1200
|
+
return Ie(this._source, e, t, {
|
|
1196
1201
|
...this._withActiveView(n),
|
|
1197
1202
|
fetchImage: this._fetchImage,
|
|
1198
1203
|
layoutServices: D(this).services ?? void 0,
|
|
@@ -1238,7 +1243,7 @@ var J = class e {
|
|
|
1238
1243
|
}))).runs;
|
|
1239
1244
|
let r = D(this), i = r.services;
|
|
1240
1245
|
if (!i) throw Error("Document layout services are not initialized");
|
|
1241
|
-
return
|
|
1246
|
+
return Qe(i, e, {
|
|
1242
1247
|
currentDate: n.currentDate,
|
|
1243
1248
|
defaultCurrentDateMs: r.defaultCurrentDateMs,
|
|
1244
1249
|
width: n.width,
|
|
@@ -1247,7 +1252,7 @@ var J = class e {
|
|
|
1247
1252
|
}
|
|
1248
1253
|
async getCommentThreads(e, t = {}) {
|
|
1249
1254
|
let { includeResolved: n, ...r } = t, i = await this.collectPageRuns(e, r);
|
|
1250
|
-
return
|
|
1255
|
+
return ct(this.comments, this.commentAnchorRanges(), i, { includeResolved: n });
|
|
1251
1256
|
}
|
|
1252
1257
|
async getElementContextAt(e, t, n = {}) {
|
|
1253
1258
|
let r = this._withActiveView(n);
|
|
@@ -1260,7 +1265,7 @@ var J = class e {
|
|
|
1260
1265
|
}))).context;
|
|
1261
1266
|
let i = D(this), a = i.services;
|
|
1262
1267
|
if (!a) throw Error("Document layout services are not initialized");
|
|
1263
|
-
return
|
|
1268
|
+
return Wt(a, e, t, {
|
|
1264
1269
|
...r,
|
|
1265
1270
|
defaultCurrentDateMs: i.defaultCurrentDateMs
|
|
1266
1271
|
});
|
|
@@ -1268,7 +1273,7 @@ var J = class e {
|
|
|
1268
1273
|
};
|
|
1269
1274
|
//#endregion
|
|
1270
1275
|
//#region packages/docx/src/tate-chu-yoko-overlay.ts
|
|
1271
|
-
function
|
|
1276
|
+
function fn(e, t) {
|
|
1272
1277
|
if (!e.eastAsianVert) return 1;
|
|
1273
1278
|
let n = t(e.text);
|
|
1274
1279
|
return !(n > 0) || e.w >= n ? 1 : e.w / n;
|
|
@@ -1286,11 +1291,11 @@ function X(e, t, n, r, i, a, o) {
|
|
|
1286
1291
|
Y(t, "ooxmlSelectionRun", "docx"), Y(t, "runIndex", String(o)), c.paragraphId !== void 0 && Y(t, "paragraphId", c.paragraphId), c.source !== void 0 && (Y(t, "sourceStory", c.source.story), Y(t, "sourceStoryInstance", c.source.storyInstance), Y(t, "sourcePath", JSON.stringify(c.source.path))), t.textContent = c.text;
|
|
1287
1292
|
let l = c.transform ?? "";
|
|
1288
1293
|
if (a && c.eastAsianVert) {
|
|
1289
|
-
let e =
|
|
1294
|
+
let e = fn(c, a(c.font));
|
|
1290
1295
|
e !== 1 && (l = `${l ? `${l} ` : ""}scaleX(${e})`);
|
|
1291
1296
|
}
|
|
1292
1297
|
let u = l ? `transform:${l};transform-origin:top left;` : "", d = i ? c.hyperlink : void 0, f = d ? "pointer" : "text", p = c.letterSpacingPx === void 0 ? "0" : `${c.letterSpacingPx}px`;
|
|
1293
|
-
t.style.cssText = `position:absolute;left:${
|
|
1298
|
+
t.style.cssText = `position:absolute;left:${A(c.x, n)};top:${A(c.y, r)};font:${c.font};line-height:${c.h}px;letter-spacing:${p};` + u + `white-space:pre;color:transparent;cursor:${f};pointer-events:all;`, d && i && (t.title = d.kind === "external" ? d.url : d.ref, t.addEventListener("click", (e) => {
|
|
1294
1299
|
e.preventDefault(), i(d);
|
|
1295
1300
|
})), e.appendChild(t);
|
|
1296
1301
|
}
|
|
@@ -1303,16 +1308,16 @@ function Z(e, t, n, r, i, a, o = {}) {
|
|
|
1303
1308
|
for (let s of o.slices) {
|
|
1304
1309
|
let o = t[s.runIndex];
|
|
1305
1310
|
if (!o) continue;
|
|
1306
|
-
let c = a(o.font), l =
|
|
1311
|
+
let c = a(o.font), l = at(o.text, s.start, s.end, c), u = o.letterSpacingPx ?? 0, d = Math.max(0, Math.min(s.start, o.text.length)), f = Math.max(d, Math.min(s.end, o.text.length)), p = [...o.text.slice(0, d)].length, m = [...o.text.slice(d, f)].length, h = l.x + p * u, g = l.width + Math.max(0, m - 1) * u, _ = fn(o, c), v = h * _, y = g * _;
|
|
1307
1312
|
if (y <= 0) continue;
|
|
1308
1313
|
let b = document.createElement("div"), x = o.transform ? `transform:${o.transform};transform-origin:top left;` : "";
|
|
1309
|
-
b.style.cssText = `position:absolute;left:${
|
|
1314
|
+
b.style.cssText = `position:absolute;left:${A(o.x + v, r)};top:${A(o.y, i)};width:${A(y, r)};height:${A(o.h, i)};` + x + `background:${n};pointer-events:none;`, e.appendChild(b);
|
|
1310
1315
|
}
|
|
1311
1316
|
}
|
|
1312
1317
|
}
|
|
1313
1318
|
//#endregion
|
|
1314
1319
|
//#region packages/docx/src/find.ts
|
|
1315
|
-
var
|
|
1320
|
+
var pn = class {
|
|
1316
1321
|
_pageRuns = /* @__PURE__ */ new Map();
|
|
1317
1322
|
_matches = [];
|
|
1318
1323
|
_active = -1;
|
|
@@ -1404,7 +1409,7 @@ var dn = class {
|
|
|
1404
1409
|
};
|
|
1405
1410
|
//#endregion
|
|
1406
1411
|
//#region packages/docx/src/selection-context.ts
|
|
1407
|
-
function
|
|
1412
|
+
function mn(e, t, n, r, i = {}) {
|
|
1408
1413
|
let a = e.find((e) => e.id === n && e.parentId === void 0);
|
|
1409
1414
|
if (!a) return null;
|
|
1410
1415
|
let o = new Map(e.map((e) => [e.id, e])), s = e.filter((e) => {
|
|
@@ -1418,7 +1423,7 @@ function fn(e, t, n, r, i = {}) {
|
|
|
1418
1423
|
t = e;
|
|
1419
1424
|
}
|
|
1420
1425
|
return !1;
|
|
1421
|
-
}), c =
|
|
1426
|
+
}), c = Se({
|
|
1422
1427
|
id: a.id,
|
|
1423
1428
|
author: a.author,
|
|
1424
1429
|
date: a.date,
|
|
@@ -1447,19 +1452,19 @@ function fn(e, t, n, r, i = {}) {
|
|
|
1447
1452
|
maxTextCharacters: c.maxTextCharacters
|
|
1448
1453
|
});
|
|
1449
1454
|
}
|
|
1450
|
-
function
|
|
1455
|
+
function hn(e) {
|
|
1451
1456
|
if (e === void 0 || !/^\d+$/.test(e)) return null;
|
|
1452
1457
|
let t = Number(e);
|
|
1453
1458
|
return Number.isSafeInteger(t) ? t : null;
|
|
1454
1459
|
}
|
|
1455
|
-
function
|
|
1460
|
+
function gn(e) {
|
|
1456
1461
|
for (let t = e; t; t = t.parentElement) {
|
|
1457
|
-
let e =
|
|
1462
|
+
let e = hn(t.dataset.pageIndex);
|
|
1458
1463
|
if (e !== null) return e;
|
|
1459
1464
|
}
|
|
1460
1465
|
return null;
|
|
1461
1466
|
}
|
|
1462
|
-
var
|
|
1467
|
+
var _n = new Set([
|
|
1463
1468
|
"body",
|
|
1464
1469
|
"header",
|
|
1465
1470
|
"footer",
|
|
@@ -1467,9 +1472,9 @@ var hn = new Set([
|
|
|
1467
1472
|
"endnote",
|
|
1468
1473
|
"textbox"
|
|
1469
1474
|
]);
|
|
1470
|
-
function
|
|
1475
|
+
function vn(e) {
|
|
1471
1476
|
let t = e.dataset.sourceStory, n = e.dataset.sourceStoryInstance, r = e.dataset.sourcePath;
|
|
1472
|
-
if (!t || !
|
|
1477
|
+
if (!t || !_n.has(t) || !n || !r) return null;
|
|
1473
1478
|
try {
|
|
1474
1479
|
let e = JSON.parse(r);
|
|
1475
1480
|
return !Array.isArray(e) || e.length === 0 || e.length > 32 || !e.every((e) => Number.isSafeInteger(e) && e >= 0) ? null : {
|
|
@@ -1483,12 +1488,12 @@ function gn(e) {
|
|
|
1483
1488
|
}
|
|
1484
1489
|
function Q(e, t, n = {}) {
|
|
1485
1490
|
let r = ue(e, t, (e) => {
|
|
1486
|
-
let t =
|
|
1491
|
+
let t = gn(e), n = hn(e.dataset.runIndex);
|
|
1487
1492
|
return t === null || n === null ? null : {
|
|
1488
1493
|
pageIndex: t,
|
|
1489
1494
|
runIndex: n,
|
|
1490
1495
|
...e.dataset.paragraphId === void 0 ? {} : { paragraphId: e.dataset.paragraphId },
|
|
1491
|
-
...
|
|
1496
|
+
...vn(e) === null ? {} : { source: vn(e) }
|
|
1492
1497
|
};
|
|
1493
1498
|
}, {
|
|
1494
1499
|
maxChars: n.maxTextCharacters,
|
|
@@ -1517,7 +1522,7 @@ function $(e, t, n, r, i) {
|
|
|
1517
1522
|
}
|
|
1518
1523
|
//#endregion
|
|
1519
1524
|
//#region packages/docx/src/viewer.ts
|
|
1520
|
-
var
|
|
1525
|
+
var yn = Symbol("DocxViewer.borrowedDocument"), bn = class e {
|
|
1521
1526
|
_documentOwner;
|
|
1522
1527
|
get _doc() {
|
|
1523
1528
|
return this._documentOwner.current;
|
|
@@ -1560,12 +1565,12 @@ var _n = Symbol("DocxViewer.borrowedDocument"), vn = class e {
|
|
|
1560
1565
|
...r,
|
|
1561
1566
|
currentDate: i.currentDate,
|
|
1562
1567
|
showTrackedChanges: i.showTrackedChanges,
|
|
1563
|
-
[
|
|
1568
|
+
[yn]: n
|
|
1564
1569
|
});
|
|
1565
1570
|
}
|
|
1566
1571
|
constructor(e, t = {}) {
|
|
1567
1572
|
this._canvas = e, this._opts = t;
|
|
1568
|
-
let n = t[
|
|
1573
|
+
let n = t[yn];
|
|
1569
1574
|
this._borrowed = n !== void 0, this._mode = w("DocxViewer", t.mode, n), this._documentOwner = new x("DocxViewer", n ?? null, !1);
|
|
1570
1575
|
let r = e.ownerDocument?.defaultView ?? (typeof window < "u" ? window : null);
|
|
1571
1576
|
if (!r) throw Error("DocxViewer requires a canvas with an active Window");
|
|
@@ -1587,7 +1592,7 @@ var _n = Symbol("DocxViewer.borrowedDocument"), vn = class e {
|
|
|
1587
1592
|
let a = this._wrapper.ownerDocument.createElement("progress");
|
|
1588
1593
|
a.setAttribute("aria-hidden", "true"), this._loadingLayer.appendChild(a), this._wrapper.insertBefore(this._loadingLayer, this._elementLayer), this._textLayer && (t.onSelectionContextChange || t.enableElementSelection) && (this._selectionChangeListener = () => this._emitSelectionContextChange(), this._wrapper.ownerDocument.addEventListener("selectionchange", this._selectionChangeListener)), t.enableElementSelection && (this._elementClickListener = (e) => {
|
|
1589
1594
|
this._onElementClick(e).catch((e) => this._reportRenderError(e));
|
|
1590
|
-
}, this._wrapper.addEventListener("click", this._elementClickListener)), t.onContextMenu && (this._contextMenuListener = (e) => this._onContextMenu(e), this._wrapper.addEventListener("contextmenu", this._contextMenuListener)), this._find = new
|
|
1595
|
+
}, this._wrapper.addEventListener("click", this._elementClickListener)), t.onContextMenu && (this._contextMenuListener = (e) => this._onContextMenu(e), this._wrapper.addEventListener("contextmenu", this._contextMenuListener)), this._find = new pn(() => this.pageCount, (e) => this._collectPageRuns(e)), n && this._bindLayoutDocument(n);
|
|
1591
1596
|
}
|
|
1592
1597
|
async load(e) {
|
|
1593
1598
|
if (this._destroyed) throw Error("DocxViewer is destroyed");
|
|
@@ -1597,6 +1602,7 @@ var _n = Symbol("DocxViewer.borrowedDocument"), vn = class e {
|
|
|
1597
1602
|
let n = await this._documentOwner.replace(() => J.load(e, {
|
|
1598
1603
|
password: this._opts.password,
|
|
1599
1604
|
useGoogleFonts: this._opts.useGoogleFonts,
|
|
1605
|
+
cjkFallback: this._opts.cjkFallback,
|
|
1600
1606
|
maxZipEntryBytes: this._opts.maxZipEntryBytes,
|
|
1601
1607
|
resourceLimits: this._opts.resourceLimits,
|
|
1602
1608
|
debug: this._opts.debug,
|
|
@@ -1667,7 +1673,7 @@ var _n = Symbol("DocxViewer.borrowedDocument"), vn = class e {
|
|
|
1667
1673
|
await this.goToPage(this._currentPage - 1);
|
|
1668
1674
|
}
|
|
1669
1675
|
_naturalWidthPx() {
|
|
1670
|
-
return !this._doc || this._doc.pageCount === 0 ? 0 : this._doc.pageSize(this._currentPage).widthPt *
|
|
1676
|
+
return !this._doc || this._doc.pageCount === 0 ? 0 : this._doc.pageSize(this._currentPage).widthPt * k;
|
|
1671
1677
|
}
|
|
1672
1678
|
_renderWidth() {
|
|
1673
1679
|
if (this._scale === null) return this._opts.width;
|
|
@@ -1706,8 +1712,8 @@ var _n = Symbol("DocxViewer.borrowedDocument"), vn = class e {
|
|
|
1706
1712
|
let t = this._doc.pageSize(this._currentPage), n = this._fitContainer();
|
|
1707
1713
|
if (!n) return;
|
|
1708
1714
|
let r = b({
|
|
1709
|
-
contentWidth: t.widthPt *
|
|
1710
|
-
contentHeight: t.heightPt *
|
|
1715
|
+
contentWidth: t.widthPt * k,
|
|
1716
|
+
contentHeight: t.heightPt * k,
|
|
1711
1717
|
containerWidth: n.clientWidth,
|
|
1712
1718
|
containerHeight: n.clientHeight
|
|
1713
1719
|
}, e);
|
|
@@ -1746,7 +1752,7 @@ var _n = Symbol("DocxViewer.borrowedDocument"), vn = class e {
|
|
|
1746
1752
|
}
|
|
1747
1753
|
getSelectionContext(e = {}) {
|
|
1748
1754
|
if (this._destroyed) throw Error("DocxViewer is destroyed");
|
|
1749
|
-
return (this._textLayer ? Q(this._wrapper, this._wrapper.ownerDocument?.getSelection?.() ?? null, e) : null) ?? (this._elementContext ?
|
|
1755
|
+
return (this._textLayer ? Q(this._wrapper, this._wrapper.ownerDocument?.getSelection?.() ?? null, e) : null) ?? (this._elementContext ? Gt(this._elementContext, e.maxTextCharacters) : null);
|
|
1750
1756
|
}
|
|
1751
1757
|
_emitSelectionContextChange() {
|
|
1752
1758
|
let e = this.getSelectionContext();
|
|
@@ -1801,7 +1807,7 @@ var _n = Symbol("DocxViewer.borrowedDocument"), vn = class e {
|
|
|
1801
1807
|
}, {
|
|
1802
1808
|
currentDate: this._opts.currentDate,
|
|
1803
1809
|
showTrackedChanges: this._opts.showTrackedChanges,
|
|
1804
|
-
maxTextCharacters:
|
|
1810
|
+
maxTextCharacters: I
|
|
1805
1811
|
});
|
|
1806
1812
|
} catch (e) {
|
|
1807
1813
|
if (this._destroyed || a !== this._elementHitGeneration || o !== this._currentPage || t !== this._doc) return null;
|
|
@@ -1810,7 +1816,7 @@ var _n = Symbol("DocxViewer.borrowedDocument"), vn = class e {
|
|
|
1810
1816
|
return this._destroyed || a !== this._elementHitGeneration || o !== this._currentPage || t !== this._doc ? null : (this._setElementContext(c), this._destroyed ? null : this.getSelectionContext());
|
|
1811
1817
|
}
|
|
1812
1818
|
destroy() {
|
|
1813
|
-
this._destroyed || (this._destroyed = !0, this._findRequestGeneration++, this._layoutViewGeneration++, this._unbindLayoutDocument(), this._errorRouter.close(), this._renderDispatcher.destroy(),
|
|
1819
|
+
this._destroyed || (this._destroyed = !0, this._findRequestGeneration++, this._layoutViewGeneration++, this._unbindLayoutDocument(), this._errorRouter.close(), this._renderDispatcher.destroy(), Ye(this._canvas), this._documentOwner.close(), this._find.invalidate(), this._selectionChangeListener &&= (this._wrapper.ownerDocument.removeEventListener("selectionchange", this._selectionChangeListener), null), this._elementHitGeneration++, this._elementClickListener &&= (this._wrapper.removeEventListener("click", this._elementClickListener), null), this._contextMenuListener &&= (this._wrapper.removeEventListener("contextmenu", this._contextMenuListener), null), this._elementContext = null, this._canvasMount.restore());
|
|
1814
1820
|
}
|
|
1815
1821
|
async _render() {
|
|
1816
1822
|
let e = this._renderDispatcher.begin();
|
|
@@ -1846,7 +1852,7 @@ var _n = Symbol("DocxViewer.borrowedDocument"), vn = class e {
|
|
|
1846
1852
|
}
|
|
1847
1853
|
_bindLayoutDocument(e) {
|
|
1848
1854
|
this._unbindLayoutDocument(), this._layoutFailed = !1, this._layoutViewPublicationGeneration = 0;
|
|
1849
|
-
let t =
|
|
1855
|
+
let t = on(e, (t) => this._onLayoutViewPublication(e, t), (e) => this._reportRenderError(e)), n = !0, r = tn(e, () => ({
|
|
1850
1856
|
pageCount: e.pageCount,
|
|
1851
1857
|
exact: e.layoutComplete,
|
|
1852
1858
|
complete: e.layoutComplete
|
|
@@ -1962,11 +1968,11 @@ var _n = Symbol("DocxViewer.borrowedDocument"), vn = class e {
|
|
|
1962
1968
|
let r = e.getBookmarkPage(t);
|
|
1963
1969
|
r !== void 0 && await this.goToPage(r);
|
|
1964
1970
|
}
|
|
1965
|
-
},
|
|
1966
|
-
function
|
|
1967
|
-
return
|
|
1971
|
+
}, xn = 150, Sn = "0 1px 3px rgba(0,0,0,0.2)", Cn = 12, wn = 13, Tn = Symbol("DocxScrollViewer.borrowedDocument"), En;
|
|
1972
|
+
function Dn() {
|
|
1973
|
+
return En ??= import("./comment-ui-runtime-DcJOYlw-.js");
|
|
1968
1974
|
}
|
|
1969
|
-
var
|
|
1975
|
+
var On = class e {
|
|
1970
1976
|
_documentOwner;
|
|
1971
1977
|
get _doc() {
|
|
1972
1978
|
return this._documentOwner.current;
|
|
@@ -2029,7 +2035,7 @@ var En = class e {
|
|
|
2029
2035
|
_prevBase = 0;
|
|
2030
2036
|
_lastFitWidth = 0;
|
|
2031
2037
|
_pageShadow;
|
|
2032
|
-
_find = new
|
|
2038
|
+
_find = new pn(() => this.pageCount, (e) => this._collectPageRuns(e));
|
|
2033
2039
|
_findActive = !1;
|
|
2034
2040
|
_findRequestGeneration = 0;
|
|
2035
2041
|
_showTrackedChanges;
|
|
@@ -2042,14 +2048,14 @@ var En = class e {
|
|
|
2042
2048
|
...r,
|
|
2043
2049
|
currentDate: i.currentDate,
|
|
2044
2050
|
showTrackedChanges: i.showTrackedChanges,
|
|
2045
|
-
[
|
|
2051
|
+
[Tn]: n
|
|
2046
2052
|
});
|
|
2047
2053
|
}
|
|
2048
2054
|
constructor(e, t = {}) {
|
|
2049
2055
|
if (e.tagName === "CANVAS") throw Error("DocxScrollViewer takes a container element (e.g. a <div>), not a <canvas> — the viewer creates and manages its own canvases. Pass a block container; for the single-page canvas API use DocxViewer.");
|
|
2050
|
-
this._container = e, this._opts = t, this._errorRouter = new le("DocxScrollViewer", t.onError), this._showTrackedChanges = t.showTrackedChanges === !0, this._currentDate = t.currentDate, this._pageShadow = t.pageShadow ??
|
|
2051
|
-
let n = t[
|
|
2052
|
-
this._borrowed = n !== void 0, n ? (this._documentOwner = new x("DocxScrollViewer", n, !1), this._mode = w("DocxScrollViewer", t.mode, n)) : (this._documentOwner = new x("DocxScrollViewer"), this._mode = w("DocxScrollViewer", t.mode, void 0)), this._wrapper = document.createElement("div"), this._wrapper.style.cssText = "position:relative;width:100%;height:100%;overflow:hidden;", this._scrollHost = document.createElement("div"), this._scrollHost.style.cssText = "position:absolute;inset:0;overflow:auto;", this._scrollHost.style.scrollbarGutter = "stable", t.background && (this._scrollHost.style.background = t.background), this._spacer = document.createElement("div"), this._spacer.style.cssText = "position:absolute;top:0;left:0;width:1px;height:0;pointer-events:none;", this._scrollHost.appendChild(this._spacer), this._wrapper.appendChild(this._scrollHost), this._container.appendChild(this._wrapper), this._commentsEnabled() &&
|
|
2056
|
+
this._container = e, this._opts = t, this._errorRouter = new le("DocxScrollViewer", t.onError), this._showTrackedChanges = t.showTrackedChanges === !0, this._currentDate = t.currentDate, this._pageShadow = t.pageShadow ?? Sn;
|
|
2057
|
+
let n = t[Tn];
|
|
2058
|
+
this._borrowed = n !== void 0, n ? (this._documentOwner = new x("DocxScrollViewer", n, !1), this._mode = w("DocxScrollViewer", t.mode, n)) : (this._documentOwner = new x("DocxScrollViewer"), this._mode = w("DocxScrollViewer", t.mode, void 0)), this._wrapper = document.createElement("div"), this._wrapper.style.cssText = "position:relative;width:100%;height:100%;overflow:hidden;", this._scrollHost = document.createElement("div"), this._scrollHost.style.cssText = "position:absolute;inset:0;overflow:auto;", this._scrollHost.style.scrollbarGutter = "stable", t.background && (this._scrollHost.style.background = t.background), this._spacer = document.createElement("div"), this._spacer.style.cssText = "position:absolute;top:0;left:0;width:1px;height:0;pointer-events:none;", this._scrollHost.appendChild(this._spacer), this._wrapper.appendChild(this._scrollHost), this._container.appendChild(this._wrapper), this._commentsEnabled() && Dn().then((e) => {
|
|
2053
2059
|
if (!this._destroyed) {
|
|
2054
2060
|
this._commentUi = e;
|
|
2055
2061
|
for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
|
|
@@ -2057,7 +2063,7 @@ var En = class e {
|
|
|
2057
2063
|
}).catch((e) => this._reportRenderError(e)), t.enableTextSelection && (t.onSelectionContextChange || t.enableElementSelection) && (this._selectionChangeListener = () => this._emitSelectionContextChange(), this._wrapper.ownerDocument.addEventListener("selectionchange", this._selectionChangeListener)), t.enableElementSelection && (this._elementClickListener = (e) => {
|
|
2058
2064
|
this._onElementClick(e).catch((e) => this._reportRenderError(e));
|
|
2059
2065
|
}, this._scrollHost.addEventListener("click", this._elementClickListener)), t.onContextMenu && (this._contextMenuListener = (e) => this._onContextMenu(e), this._scrollHost.addEventListener("contextmenu", this._contextMenuListener)), this._scrollListener = () => this._onScroll(), this._scrollHost.addEventListener("scroll", this._scrollListener), t.comments && (this._commentOutsidePointerListener = (e) => {
|
|
2060
|
-
if (!
|
|
2066
|
+
if (!Te(e, this._wrapper, "ooxmlCommentId") && this._activeCommentId !== null) {
|
|
2061
2067
|
this._activeCommentId = null, this._activeCommentPage = null;
|
|
2062
2068
|
for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
|
|
2063
2069
|
this._emitSelectionContextChange();
|
|
@@ -2079,6 +2085,7 @@ var En = class e {
|
|
|
2079
2085
|
let n = await this._documentOwner.replace(() => J.load(e, {
|
|
2080
2086
|
password: this._opts.password,
|
|
2081
2087
|
useGoogleFonts: this._opts.useGoogleFonts,
|
|
2088
|
+
cjkFallback: this._opts.cjkFallback,
|
|
2082
2089
|
maxZipEntryBytes: this._opts.maxZipEntryBytes,
|
|
2083
2090
|
resourceLimits: this._opts.resourceLimits,
|
|
2084
2091
|
debug: this._opts.debug,
|
|
@@ -2127,7 +2134,7 @@ var En = class e {
|
|
|
2127
2134
|
}
|
|
2128
2135
|
_bindLayoutDocument(e) {
|
|
2129
2136
|
this._unbindLayoutDocument(), this._layoutViewPublicationGeneration = 0, this._presentedPageCount = e.pageCount;
|
|
2130
|
-
let t =
|
|
2137
|
+
let t = on(e, (t) => this._onLayoutViewPublication(e, t), (e) => this._reportRenderError(e)), n = !0, r = tn(e, () => ({
|
|
2131
2138
|
pageCount: e.pageCount,
|
|
2132
2139
|
exact: e.layoutComplete,
|
|
2133
2140
|
complete: e.layoutComplete
|
|
@@ -2173,10 +2180,10 @@ var En = class e {
|
|
|
2173
2180
|
for (let [e, n] of t) e >= this._presentedPageCount || this._slots.get(e) !== n || this._refreshSlotAtomically(e, n);
|
|
2174
2181
|
}
|
|
2175
2182
|
_pageWidthPx(e) {
|
|
2176
|
-
return this._doc.pageSize(e).widthPt *
|
|
2183
|
+
return this._doc.pageSize(e).widthPt * k * this._scale;
|
|
2177
2184
|
}
|
|
2178
2185
|
_pageHeightPx(e) {
|
|
2179
|
-
return this._doc.pageSize(e).heightPt *
|
|
2186
|
+
return this._doc.pageSize(e).heightPt * k * this._scale;
|
|
2180
2187
|
}
|
|
2181
2188
|
_fitWidthPx() {
|
|
2182
2189
|
if (this._opts.width && this._opts.width > 0) return this._opts.width;
|
|
@@ -2198,7 +2205,7 @@ var En = class e {
|
|
|
2198
2205
|
return e.comments.some((e) => this._commentAnchorIds.has(e.id) && e.parentId === void 0 && (n || e.resolved !== !0));
|
|
2199
2206
|
}
|
|
2200
2207
|
_commentMarginExtent() {
|
|
2201
|
-
return this._hasCommentMargin() ? (
|
|
2208
|
+
return this._hasCommentMargin() ? (Cn + 280) * this._commentZoom() : 0;
|
|
2202
2209
|
}
|
|
2203
2210
|
_commentZoom() {
|
|
2204
2211
|
return this._scaleEstablished ? this._scale : 1;
|
|
@@ -2216,8 +2223,8 @@ var En = class e {
|
|
|
2216
2223
|
_syncCommentMarginGeometry(e) {
|
|
2217
2224
|
if (!e) return;
|
|
2218
2225
|
e.style.display = this._hasCommentMargin() ? "" : "none";
|
|
2219
|
-
let t = this._commentZoom(), n = `calc(100% + ${
|
|
2220
|
-
e.style.left = this._commentSide() === "right" ? n : "", e.style.right = this._commentSide() === "left" ? n : "", e.style.width = `${280 * t}px`, e.style.fontSize = `${
|
|
2226
|
+
let t = this._commentZoom(), n = `calc(100% + ${Cn * t}px)`;
|
|
2227
|
+
e.style.left = this._commentSide() === "right" ? n : "", e.style.right = this._commentSide() === "left" ? n : "", e.style.width = `${280 * t}px`, e.style.fontSize = `${wn}px`, e.dataset.ooxmlCommentZoom = String(t);
|
|
2221
2228
|
}
|
|
2222
2229
|
_widestPageWidthPt() {
|
|
2223
2230
|
if (!this._doc) return 0;
|
|
@@ -2233,7 +2240,7 @@ var En = class e {
|
|
|
2233
2240
|
let e = this._fitWidthPx();
|
|
2234
2241
|
if (e <= 0) return 0;
|
|
2235
2242
|
let t = this._widestPageWidthPt();
|
|
2236
|
-
return t <= 0 ? 0 : e / (t *
|
|
2243
|
+
return t <= 0 ? 0 : e / (t * k);
|
|
2237
2244
|
}
|
|
2238
2245
|
relayout() {
|
|
2239
2246
|
this._relayout();
|
|
@@ -2262,7 +2269,7 @@ var En = class e {
|
|
|
2262
2269
|
_recomputeHeights() {
|
|
2263
2270
|
let e = Math.min(this._presentedPageCount, this._doc.pageCount), t = Array(e);
|
|
2264
2271
|
for (let n = 0; n < e; n++) t[n] = this._pageHeightPx(n);
|
|
2265
|
-
this._heights = t, this._scrollGeometry =
|
|
2272
|
+
this._heights = t, this._scrollGeometry = we(t, this._gap(), this._pad());
|
|
2266
2273
|
}
|
|
2267
2274
|
_gap() {
|
|
2268
2275
|
return this._opts.gap ?? 16;
|
|
@@ -2529,8 +2536,8 @@ var En = class e {
|
|
|
2529
2536
|
_fit(e) {
|
|
2530
2537
|
if (!this._doc || this._doc.pageCount === 0) return;
|
|
2531
2538
|
let t = this._doc.pageSize(0), n = b({
|
|
2532
|
-
contentWidth: (e === "width" ? this._widestPageWidthPt() : t.widthPt) *
|
|
2533
|
-
contentHeight: t.heightPt *
|
|
2539
|
+
contentWidth: (e === "width" ? this._widestPageWidthPt() : t.widthPt) * k,
|
|
2540
|
+
contentHeight: t.heightPt * k,
|
|
2534
2541
|
containerWidth: this._fitWidthPx(),
|
|
2535
2542
|
containerHeight: this._scrollHost.clientHeight
|
|
2536
2543
|
}, e);
|
|
@@ -2567,7 +2574,7 @@ var En = class e {
|
|
|
2567
2574
|
_scheduleSettle() {
|
|
2568
2575
|
this._settleTimer !== null && clearTimeout(this._settleTimer), this._settleTimer = setTimeout(() => {
|
|
2569
2576
|
this._settleTimer = null, this._settleRender();
|
|
2570
|
-
},
|
|
2577
|
+
}, xn);
|
|
2571
2578
|
}
|
|
2572
2579
|
_settleRender() {
|
|
2573
2580
|
if (!(this._destroyed || !this._doc || this._doc.pageCount === 0)) for (let [e, t] of [...this._slots]) t.renderedScale !== this._scale && this._refreshSlotAtomically(e, t);
|
|
@@ -2625,11 +2632,11 @@ var En = class e {
|
|
|
2625
2632
|
}
|
|
2626
2633
|
scrollToPage(e, t) {
|
|
2627
2634
|
if (!this._doc || this._doc.pageCount === 0 || !this._scaleEstablished) return;
|
|
2628
|
-
let n = Math.max(0, Math.min(e, this._doc.pageCount - 1)), r = T(this._scrollGeometry, 0, this._scrollHost.clientHeight, this._overscan()), i = r.offsets[n] ?? 0,
|
|
2629
|
-
typeof
|
|
2630
|
-
top:
|
|
2635
|
+
let n = Math.max(0, Math.min(e, this._doc.pageCount - 1)), r = T(this._scrollGeometry, 0, this._scrollHost.clientHeight, this._overscan()), i = _e(r.offsets[n] ?? 0, Math.max(0, r.totalHeight - this._scrollHost.clientHeight)), a = this._scrollHost;
|
|
2636
|
+
typeof a.scrollTo == "function" ? a.scrollTo({
|
|
2637
|
+
top: i,
|
|
2631
2638
|
behavior: t?.behavior ?? "auto"
|
|
2632
|
-
}) : this._scrollHost.scrollTop =
|
|
2639
|
+
}) : this._scrollHost.scrollTop = i, this._mountVisible();
|
|
2633
2640
|
}
|
|
2634
2641
|
_scrollToPageTarget(e, t, n) {
|
|
2635
2642
|
let r = T(this._scrollGeometry, 0, this._scrollHost.clientHeight, this._overscan()), i = this._pageWidthPx(e), { left: a } = this._padH(), o = Math.max(a, (this._scrollHost.clientWidth - i) / 2) + this._reviewOriginPx, s = Math.max(0, r.totalHeight - this._scrollHost.clientHeight), c = this._spacer.offsetWidth || Number.parseFloat(this._spacer.style.width) || 0, l = Math.max(0, c - this._scrollHost.clientWidth), u = Math.min(s, Math.max(0, (r.offsets[e] ?? 0) + t.y + t.h / 2 - this._scrollHost.clientHeight / 2)), d = Math.min(l, Math.max(0, o + t.x + t.w / 2 - this._scrollHost.clientWidth / 2)), f = this._scrollHost;
|
|
@@ -2647,7 +2654,7 @@ var En = class e {
|
|
|
2647
2654
|
}
|
|
2648
2655
|
_indexCommentPages(e, t, n) {
|
|
2649
2656
|
if (!this._commentIndexedPages.has(e)) {
|
|
2650
|
-
for (let r of n) this._commentPageById.has(r.commentId) ||
|
|
2657
|
+
for (let r of n) this._commentPageById.has(r.commentId) || M(r, t).length > 0 && this._commentPageById.set(r.commentId, e);
|
|
2651
2658
|
this._commentIndexedPages.add(e), this._advanceCommentScanFrontier();
|
|
2652
2659
|
}
|
|
2653
2660
|
}
|
|
@@ -2697,7 +2704,7 @@ var En = class e {
|
|
|
2697
2704
|
if (a.length === 0 || o !== void 0 && o >= n.pageCount || s === void 0) return !1;
|
|
2698
2705
|
let u = await this._commentRunsForPage(s, n);
|
|
2699
2706
|
if (this._destroyed) throw Error("DocxScrollViewer is destroyed");
|
|
2700
|
-
if (this._doc !== n || r !== this._commentNavigationGeneration || !u || (c = a.flatMap((e) =>
|
|
2707
|
+
if (this._doc !== n || r !== this._commentNavigationGeneration || !u || (c = a.flatMap((e) => M(e, u))[0], !c)) return !1;
|
|
2701
2708
|
this._activeCommentId = e, this._activeCommentPage = s, this._elementContext = null, this._scrollToPageTarget(s, c, t);
|
|
2702
2709
|
for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
|
|
2703
2710
|
return this._emitSelectionContextChange(), !0;
|
|
@@ -2874,7 +2881,7 @@ var En = class e {
|
|
|
2874
2881
|
}
|
|
2875
2882
|
getSelectionContext(e = {}) {
|
|
2876
2883
|
if (this._destroyed) throw Error("DocxScrollViewer is destroyed");
|
|
2877
|
-
return (this._doc && this._activeCommentId !== null && this._activeCommentPage !== null ?
|
|
2884
|
+
return (this._doc && this._activeCommentId !== null && this._activeCommentPage !== null ? mn(this._doc.comments, this._doc.commentAnchorRanges(), this._activeCommentId, this._activeCommentPage, e) : null) || ((this._opts.enableTextSelection ? Q(this._wrapper, this._wrapper.ownerDocument?.getSelection?.() ?? null, e) : null) ?? (this._elementContext ? Gt(this._elementContext, e.maxTextCharacters) : null));
|
|
2878
2885
|
}
|
|
2879
2886
|
_emitSelectionContextChange() {
|
|
2880
2887
|
let e = this.getSelectionContext();
|
|
@@ -2934,7 +2941,7 @@ var En = class e {
|
|
|
2934
2941
|
}, {
|
|
2935
2942
|
currentDate: this._currentDate,
|
|
2936
2943
|
...this._showTrackedChanges ? { showTrackedChanges: !0 } : {},
|
|
2937
|
-
maxTextCharacters:
|
|
2944
|
+
maxTextCharacters: I
|
|
2938
2945
|
});
|
|
2939
2946
|
} catch (e) {
|
|
2940
2947
|
if (this._destroyed || l !== this._elementHitGeneration || t !== this._doc) return null;
|
|
@@ -2952,7 +2959,7 @@ var En = class e {
|
|
|
2952
2959
|
};
|
|
2953
2960
|
//#endregion
|
|
2954
2961
|
//#region packages/docx/src/types.ts
|
|
2955
|
-
function
|
|
2962
|
+
function kn(e) {
|
|
2956
2963
|
let t = [];
|
|
2957
2964
|
for (let n of e.content) {
|
|
2958
2965
|
if (n.type !== "paragraph") continue;
|
|
@@ -2964,25 +2971,25 @@ function Dn(e) {
|
|
|
2964
2971
|
}
|
|
2965
2972
|
//#endregion
|
|
2966
2973
|
//#region src/docx.ts
|
|
2967
|
-
var
|
|
2974
|
+
var An = /* @__PURE__ */ e({
|
|
2968
2975
|
DocxDocument: () => J,
|
|
2969
|
-
DocxScrollViewer: () =>
|
|
2970
|
-
DocxViewer: () =>
|
|
2971
|
-
OoxmlDecodedImageLimitError: () =>
|
|
2972
|
-
OoxmlError: () =>
|
|
2973
|
-
OoxmlResourceLimitError: () =>
|
|
2974
|
-
TiffDecodeError: () =>
|
|
2976
|
+
DocxScrollViewer: () => On,
|
|
2977
|
+
DocxViewer: () => bn,
|
|
2978
|
+
OoxmlDecodedImageLimitError: () => tt,
|
|
2979
|
+
OoxmlError: () => c,
|
|
2980
|
+
OoxmlResourceLimitError: () => d,
|
|
2981
|
+
TiffDecodeError: () => nt,
|
|
2975
2982
|
autoResize: () => y,
|
|
2976
2983
|
buildDocxHighlightLayer: () => Z,
|
|
2977
2984
|
buildDocxTextLayer: () => X,
|
|
2978
|
-
isOoxmlDecodedImageLimitError: () =>
|
|
2979
|
-
isTiffDecodeError: () =>
|
|
2980
|
-
noteText: () =>
|
|
2985
|
+
isOoxmlDecodedImageLimitError: () => et,
|
|
2986
|
+
isTiffDecodeError: () => rt,
|
|
2987
|
+
noteText: () => kn,
|
|
2981
2988
|
openExternalHyperlink: () => u,
|
|
2982
2989
|
readDocxTextSelectionContext: () => Q,
|
|
2983
|
-
resolveCommentAnchorRuns: () =>
|
|
2984
|
-
resolveDocxCommentThreads: () =>
|
|
2985
|
-
resolveRevisionAnchorRuns: () =>
|
|
2990
|
+
resolveCommentAnchorRuns: () => M,
|
|
2991
|
+
resolveDocxCommentThreads: () => ct,
|
|
2992
|
+
resolveRevisionAnchorRuns: () => Qt
|
|
2986
2993
|
});
|
|
2987
2994
|
//#endregion
|
|
2988
|
-
export { Q as a, J as c,
|
|
2995
|
+
export { Q as a, J as c, bn as i, Qt as l, kn as n, Z as o, On as r, X as s, An as t };
|