@silurus/ooxml 0.79.0 → 0.80.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 +22 -15
- package/dist/assets/render-worker-BSx9_xRC.js +8 -0
- package/dist/assets/render-worker-BTp87EaD.js +21 -0
- package/dist/assets/render-worker-fdwAjSve.js +7 -0
- package/dist/{canvas-viewer-mechanics-D9tsuHnG.js → canvas-viewer-mechanics-D41tGY4d.js} +1 -1
- package/dist/{dash-Cyc-sevN.js → dash-CMzZIDz_.js} +87 -49
- package/dist/{document-pull-client-YiU8M4LO.js → document-pull-client-D-fnlVGf.js} +2247 -2254
- package/dist/{docx-a1UpmRf8.js → docx-CbIqgb1f.js} +108 -106
- package/dist/docx.mjs +4 -4
- package/dist/docx_parser_bg.wasm +0 -0
- package/dist/index.mjs +3 -3
- package/dist/line-distribute-DFdgzaLK.js +1002 -0
- package/dist/{line-metrics-DjKxiIUD.js → line-metrics-PpgpOvz4.js} +2774 -2524
- package/dist/math.mjs +34 -24
- package/dist/node.mjs +186 -186
- package/dist/{pptx-t5ABdzfd.js → pptx-DwF8olh2.js} +129 -127
- package/dist/pptx.mjs +5 -5
- package/dist/pptx_parser_bg.wasm +0 -0
- package/dist/region-map.mjs +75 -74
- package/dist/{render-BjIEuFIG.js → render-BMC4d1CO.js} +1 -1
- package/dist/render-worker-host-CcENRoDr.js +9 -0
- package/dist/render-worker-host-CzsHtsN_.js +9 -0
- package/dist/render-worker-host-DFgTN7hy.js +9 -0
- package/dist/renderer-module-contract-BNGz8HvO.js +30 -0
- package/dist/{resource-measurement-D8EiTm_E.js → resource-measurement-DvIKHd-9.js} +7 -7
- package/dist/{session-Bhe_eY-s.js → session-BzhcJOvj.js} +9 -9
- package/dist/{slide-pull-client-BQ8gJPTq.js → slide-pull-client-DLC3nJUt.js} +847 -861
- package/dist/three-d.mjs +828 -559
- package/dist/types/docx.d.ts +74 -8
- package/dist/types/index.d.ts +82 -12
- package/dist/types/math.d.ts +1 -1
- package/dist/types/node.d.ts +70 -2
- package/dist/types/pptx.d.ts +74 -8
- package/dist/types/region-map.d.ts +68 -2
- package/dist/types/three-d.d.ts +68 -2
- package/dist/types/xlsx.d.ts +78 -8
- package/dist/{worksheet-pull-client-T0EzdEEQ.js → worksheet-pull-client-DlVk_4Bt.js} +13 -13
- package/dist/{xlsx-CsDDMJIK.js → xlsx-C1BUns1R.js} +1387 -1252
- package/dist/xlsx.mjs +5 -5
- package/dist/xlsx_parser_bg.wasm +0 -0
- package/package.json +4 -1
- package/dist/line-distribute-pDqovJpT.js +0 -1002
- package/dist/render-worker-host-BB320snY.js +0 -27
- package/dist/render-worker-host-BjEPZBwf.js +0 -27
- package/dist/render-worker-host-hZ0o4OD7.js +0 -27
- /package/dist/{highlight-rect-cCvVU-MW.js → highlight-rect-BuX5rWP4.js} +0 -0
- /package/dist/{mathjax-Dqo857oC.js → mathjax-DgAl7Yi5.js} +0 -0
- /package/dist/{transfer-3QEJrsJa.js → transfer-CKZ79zFw.js} +0 -0
- /package/dist/{visible-index-CKvgpUrf.js → visible-index-BjesVGhg.js} +0 -0
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
import { t as e } from "./chunk-DmhlhrBa.js";
|
|
2
|
-
import { B as t,
|
|
3
|
-
import { C as m, E as h, S as g, T as _, _ as v, a as y, b, c as x, d as ee, f as te, g as ne, h as re, i as S, l as C, m as ie, n as ae, o as oe, p as se, r as ce, s as le, t as ue, u as de, v as w, w as fe, x as pe, y as T } from "./canvas-viewer-mechanics-
|
|
2
|
+
import { B as t, Ot as n, R as r, Rt as i, a, cn as o, it as s, jt as c, ln as l, mt as u, q as d, z as f, zt as p } from "./line-metrics-PpgpOvz4.js";
|
|
3
|
+
import { C as m, E as h, S as g, T as _, _ as v, a as y, b, c as x, d as ee, f as te, g as ne, h as re, i as S, l as C, m as ie, n as ae, o as oe, p as se, r as ce, s as le, t as ue, u as de, v as w, w as fe, x as pe, y as T } from "./canvas-viewer-mechanics-D41tGY4d.js";
|
|
4
4
|
import { a as me, c as he, i as ge, o as _e, r as ve, s as ye, t as be } from "./bounded-raw-part-cache-C6ro6Ezf.js";
|
|
5
|
-
import { C as xe, S as Se, _ as E, a as Ce, b as we, c as Te, d as Ee, f as De, g as Oe, h as ke, l as Ae, m as je, n as D, o as Me, p as Ne, s as Pe, t as O, v as k, w as Fe, x as A, y as Ie } from "./document-pull-client-
|
|
6
|
-
import {
|
|
7
|
-
import { n as Le
|
|
5
|
+
import { C as xe, S as Se, _ as E, a as Ce, b as we, c as Te, d as Ee, f as De, g as Oe, h as ke, l as Ae, m as je, n as D, o as Me, p as Ne, s as Pe, t as O, v as k, w as Fe, x as A, y as Ie } from "./document-pull-client-D-fnlVGf.js";
|
|
6
|
+
import { S as j } from "./dash-CMzZIDz_.js";
|
|
7
|
+
import { n as Le } from "./renderer-module-contract-BNGz8HvO.js";
|
|
8
|
+
import { n as Re, r as M, t as N } from "./highlight-rect-BuX5rWP4.js";
|
|
8
9
|
//#region packages/core/src/fonts/embedded.ts
|
|
9
|
-
function
|
|
10
|
-
let n =
|
|
10
|
+
function ze(e, t) {
|
|
11
|
+
let n = Be(t), r = e.slice(), i = Math.min(32, r.length);
|
|
11
12
|
for (let e = 0; e < i; e++) r[e] ^= n[e % 16];
|
|
12
13
|
return r;
|
|
13
14
|
}
|
|
14
|
-
function
|
|
15
|
+
function Be(e) {
|
|
15
16
|
let t = e.replace(/[{}\-\s]/g, "");
|
|
16
17
|
if (t.length !== 32 || /[^0-9a-fA-F]/.test(t)) throw Error(`invalid fontKey GUID: ${e}`);
|
|
17
18
|
let n = new Uint8Array(16);
|
|
18
19
|
for (let e = 0; e < 16; e++) n[e] = parseInt(t.slice(e * 2, e * 2 + 2), 16);
|
|
19
20
|
return n.reverse();
|
|
20
21
|
}
|
|
21
|
-
function
|
|
22
|
+
function Ve(e, t, n, r) {
|
|
22
23
|
let i = 2166136261;
|
|
23
24
|
for (let e = 0; e < r.length; e++) i ^= r[e], i = Math.imul(i, 16777619);
|
|
24
25
|
return `${e}|${t}|${n}|${r.length}|${(i >>> 0).toString(16)}`;
|
|
25
26
|
}
|
|
26
|
-
async function
|
|
27
|
+
async function He(e, t = 30 * 1024 * 1024) {
|
|
27
28
|
let n = ve();
|
|
28
29
|
if (!n || typeof FontFace > "u") return [];
|
|
29
30
|
let r = [], i = [], a = [];
|
|
@@ -32,7 +33,7 @@ async function Ve(e, t = 30 * 1024 * 1024) {
|
|
|
32
33
|
a.push(o.family);
|
|
33
34
|
continue;
|
|
34
35
|
}
|
|
35
|
-
let e = o.odttf ?
|
|
36
|
+
let e = o.odttf ? ze(o.bytes, o.fontKey ?? "") : o.bytes, { face: s, isNew: c } = he(`embedded:${Ve(o.family, o.weight, o.style, e)}`, n, () => {
|
|
36
37
|
let t = e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength), r = new FontFace(o.family, t, {
|
|
37
38
|
weight: o.weight,
|
|
38
39
|
style: o.style
|
|
@@ -47,13 +48,13 @@ async function Ve(e, t = 30 * 1024 * 1024) {
|
|
|
47
48
|
e.status === "rejected" && a.push(i[t].family);
|
|
48
49
|
}), n.ready))), a.length > 0 && console.warn(`[ooxml] failed to register embedded font(s): ${[...new Set(a)].join(", ")}; falling back to substitute fonts (text may shift or differ).`), r;
|
|
49
50
|
}
|
|
50
|
-
function
|
|
51
|
+
function Ue(e) {
|
|
51
52
|
ye(e);
|
|
52
53
|
}
|
|
53
54
|
//#endregion
|
|
54
55
|
//#region packages/docx/src/worker.ts?worker&inline
|
|
55
56
|
var P = "var e=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,n.unregister(this),e}free(){let e=this.__destroy_into_raw();g.__wbg_docxarchive_free(e,0)}acknowledge_document_chunk(e,t,n){let r=g.docxarchive_acknowledge_document_chunk(this.__wbg_ptr,e,t,n);if(r[1])throw d(r[0])}assert_healthy(){let e=g.docxarchive_assert_healthy(this.__wbg_ptr);if(e[1])throw d(e[0])}cancel_document_cursor(){g.docxarchive_cancel_document_cursor(this.__wbg_ptr)}close_document_session(){g.docxarchive_close_document_session(this.__wbg_ptr)}document_chunk_done(){let e=g.docxarchive_document_chunk_done(this.__wbg_ptr);if(e[2])throw d(e[1]);return e[0]!==0}document_cursor_resource_usage(){let e=g.docxarchive_document_cursor_resource_usage(this.__wbg_ptr);if(e[3])throw d(e[2]);var t=r(e[0],e[1]).slice();return g.__wbindgen_free(e[0],e[1]*1,1),t}extract_image(e){let t=u(e,g.__wbindgen_malloc,g.__wbindgen_realloc),n=h,i=g.docxarchive_extract_image(this.__wbg_ptr,t,n);if(i[3])throw d(i[2]);var a=r(i[0],i[1]).slice();return g.__wbindgen_free(i[0],i[1]*1,1),a}constructor(e,t,r,i){let a=ee(e,g.__wbindgen_malloc),o=h,s=g.docxarchive_new(a,o,!l(t),l(t)?BigInt(0):t,!l(r),l(r)?BigInt(0):r,!l(i),l(i)?BigInt(0):i);if(s[2])throw d(s[1]);return this.__wbg_ptr=s[0]>>>0,n.register(this,this.__wbg_ptr,this),this}open_document_cursor(e,t){let n=g.docxarchive_open_document_cursor(this.__wbg_ptr,e,t);if(n[1])throw d(n[0])}parse(){let e=g.docxarchive_parse(this.__wbg_ptr);if(e[3])throw d(e[2]);var t=r(e[0],e[1]).slice();return g.__wbindgen_free(e[0],e[1]*1,1),t}pull_document_chunk(e,t,n,i){let a=g.docxarchive_pull_document_chunk(this.__wbg_ptr,e,t,n,i);if(a[3])throw d(a[2]);var o=r(a[0],a[1]).slice();return g.__wbindgen_free(a[0],a[1]*1,1),o}resource_usage(){let e=g.docxarchive_resource_usage(this.__wbg_ptr);if(e[3])throw d(e[2]);var t=r(e[0],e[1]).slice();return g.__wbindgen_free(e[0],e[1]*1,1),t}to_markdown(){let e,t;try{let i=g.docxarchive_to_markdown(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,d(i[2]);return e=n,t=r,o(n,r)}finally{g.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(e.prototype[Symbol.dispose]=e.prototype.free);function t(){return{__proto__:null,\"./docx_parser_bg.js\":{__proto__:null,__wbg___wbindgen_throw_6b64449b9b9ed33c:function(e,t){throw Error(o(e,t))},__wbg_error_a6fa202b58aa1cd3:function(e,t){let n,r;try{n=e,r=t,console.error(o(e,t))}finally{g.__wbindgen_free(n,r,1)}},__wbg_new_227d7c05414eb861:function(){return Error()},__wbg_stack_3b0d974bbf31e44f:function(e,t){let n=t.stack,r=u(n,g.__wbindgen_malloc,g.__wbindgen_realloc),i=h;a().setInt32(e+4,i,!0),a().setInt32(e+0,r,!0)},__wbindgen_cast_0000000000000001:function(e,t){return o(e,t)},__wbindgen_init_externref_table:function(){let e=g.__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 n=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>g.__wbg_docxarchive_free(e>>>0,1));function r(e,t){return e>>>=0,c().subarray(e/1,e/1+t)}let i=null;function a(){return(i===null||i.buffer.detached===!0||i.buffer.detached===void 0&&i.buffer!==g.memory.buffer)&&(i=new DataView(g.memory.buffer)),i}function o(e,t){return e>>>=0,te(e,t)}let s=null;function c(){return(s===null||s.byteLength===0)&&(s=new Uint8Array(g.memory.buffer)),s}function l(e){return e==null}function ee(e,t){let n=t(e.length*1,1)>>>0;return c().set(e,n/1),h=e.length,n}function u(e,t,n){if(n===void 0){let n=m.encode(e),r=t(n.length,1)>>>0;return c().subarray(r,r+n.length).set(n),h=n.length,r}let r=e.length,i=t(r,1)>>>0,a=c(),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=c().subarray(i+o,i+r),a=m.encodeInto(e,t);o+=a.written,i=n(i,r,o,1)>>>0}return h=o,i}function d(e){let t=g.__wbindgen_externrefs.get(e);return g.__externref_table_dealloc(e),t}let f=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0});f.decode();let p=0;function te(e,t){return p+=t,p>=2146435072&&(f=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}),f.decode(),p=t),f.decode(c().subarray(e,e+t))}const m=new TextEncoder;`encodeInto`in m||(m.encodeInto=function(e,t){let n=m.encode(e);return t.set(n),{read:e.length,written:n.length}});let h=0,g;function _(e,t){return g=e.exports,i=null,s=null,g.__wbindgen_start(),g}async function v(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(g!==void 0)return g;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 n=t();(typeof e==`string`||typeof Request==`function`&&e instanceof Request||typeof URL==`function`&&e instanceof URL)&&(e=fetch(e));let{instance:r,module:i}=await v(await e,n);return _(r,i)}async function b(e){return g=void 0,i=null,s=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)}},ne=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 re(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 ie=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`)}},C=class e extends Error{code=`parser-crashed`;constructor(t){super(t),this.name=`WasmTrapError`,Object.setPrototypeOf(this,e.prototype)}};function ae(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 w(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 T(e,t){return e({module_or_path:t})}var oe=class{runtime;wasmInput=null;currentArchive=null;constructor(e,t={}){this.init=e,this.options=t,this.runtime=new ie(()=>this.invokeConfigured(this.init),()=>this.invokeConfigured(this.options.reinit??this.init),E),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 C(`WASM parser was recycled`))}invokeConfigured(e){return this.wasmInput===null?Promise.reject(Error(`WasmParserHost: setWasmInput was never called`)):T(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,w(e)}};function E(e){return ae(e)?new C(`WASM parser trapped and was recycled: ${e instanceof Error?e.message:String(e)}`):null}function D(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>0}function se(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return D(t.requiredBytes)&&D(t.offeredBytes)&&t.requiredBytes>t.offeredBytes}var O=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 k(e){if(e instanceof O)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`||!se(r)))return new O(r)}function ce(e,t,n){let r=k(e);if(!(!r||r.offeredBytes!==t||r.requiredBytes>n))return r}const A=`OOXML_RESOURCE_LIMIT:`;function j(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function M(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return j(t.archiveEntryCount)&&j(t.declaredInflatedBytes)&&(t.largestInflatedEntryBytes===void 0||j(t.largestInflatedEntryBytes))&&j(t.distinctInflatedBytes)&&j(t.operationInflatedBytes)}function N(e){let t;try{t=JSON.parse(new TextDecoder().decode(e))}catch{throw TypeError(`OOXML resource usage checkpoint is not valid JSON`)}if(!M(t))throw TypeError(`OOXML resource usage checkpoint is invalid`);return t}function le(e){return e===`docx`||e===`xlsx`||e===`pptx`}function P(e){return e===`container`||e===`decompression`||e===`parsing`||e===`serialization`||e===`layout`||e===`rendering`||e===`worker`}function F(e,t){return typeof e==`string`&&e.length>0&&e.length<=t&&!/[\\u0000-\\u001f\\u007f]/u.test(e)}function I(e){return F(e,128)&&/^[a-z0-9][a-z0-9-]*$/u.test(e)}function L(e){return!F(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 R=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}]]),z=new Set([...R.keys()].map(e=>e.slice(0,e.indexOf(`:`)))),B=new Set([...R.keys()].map(e=>e.slice(e.indexOf(`:`)+1)));function V(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return!le(t.format)||!F(t.operation,256)||!I(t.resource)||!I(t.metric)||!j(t.limit)||!j(t.observed)||typeof t.configurable!=`boolean`||!M(t.usage)?!1:!(`part`in t)||L(t.part)}function H(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;if(!P(t.stage)||!V(t.violation))return!1;let n=t.violation,r=R.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:!(z.has(n.resource)&&B.has(n.metric))}function U(e){return{archiveEntryCount:e.archiveEntryCount,declaredInflatedBytes:e.declaredInflatedBytes,...e.largestInflatedEntryBytes===void 0?{}:{largestInflatedEntryBytes:e.largestInflatedEntryBytes},distinctInflatedBytes:e.distinctInflatedBytes,operationInflatedBytes:e.operationInflatedBytes}}function ue(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:U(t.usage)}};return H(n)?n:void 0}function W(e){let t=e.violation;return`OOXML resource limit exceeded${t.part?` for ${t.part}`:``}: ${t.metric} ${t.observed} > ${t.limit}`}function de(e){let t=e instanceof Error?e.message:String(e);if(!t.startsWith(A))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(W(r.details),r.details)}function fe(e){if(e instanceof ne)return{message:e.message,errorName:e.name,code:e.code,decodedImage:{metric:e.metric,limit:e.limit,observed:e.observed}};let t=k(e);if(t)return{message:t.message,errorName:t.name,code:t.code,insufficientCredit:{requiredBytes:t.requiredBytes,offeredBytes:t.offeredBytes}};let n=e instanceof x||e instanceof S?e:de(e);if(n instanceof S){let e=ue(n.details);return e?{message:typeof n.message==`string`?n.message:W(e),errorName:`OoxmlResourceLimitError`,code:`ooxml-resource-limit`,resourceLimit:e}:{message:`Invalid OOXML resource-limit error payload`,errorName:`Error`}}if(n instanceof x)return{message:typeof n.message==`string`?n.message:String(n.message),errorName:F(n.name,128)?n.name:`OoxmlError`,...I(n.code)?{code:n.code}:{}};let r=e instanceof Error?e.message:String(e);if(typeof r==`string`&&r.startsWith(A))return{message:`Invalid OOXML resource-limit payload`,errorName:`Error`};let i=e instanceof Error?e:Error(r),a=i;return{message:typeof i.message==`string`?i.message:String(i.message),errorName:F(i.name,128)?i.name:`Error`,...typeof a.code==`string`?{code:a.code}:{}}}function G(e){try{return fe(e)}catch{return{message:`Worker operation failed with an unreadable error`,errorName:`Error`}}}function pe(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 me(e){return[e.maxArchiveEntryBytes===null?0n:BigInt(e.maxArchiveEntryBytes),e.maxTotalInflatedBytes===null?0n:BigInt(e.maxTotalInflatedBytes),e.maxArchiveEntries===null?0n:BigInt(e.maxArchiveEntries)]}const K=`ooxml-pull-v1`;function q(e,t){if(!Number.isSafeInteger(e)||e<=0)throw RangeError(`${t} must be a positive safe integer`)}function he(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 J=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,q(this.maxRetainedBytes,`max retained lease bytes`),q(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}},ge=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){he(e.sessionId),q(e.operationId,`operation id`),q(e.generation,`generation`),q(e.maxByteCredit,`max byte credit`),e.wireLeaseIdStart!==void 0&&q(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=G(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(q(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:K,...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){q(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(q(e,`byte credit`),e>this.options.maxByteCredit)throw RangeError(`byte credit exceeds host maximum`)}accepted(e,t,n=!1){return{kind:`accepted`,protocol:K,...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:K,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 Y=67108864;var _e=class{coordinator=new J;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 ge({...e,maxByteCredit:Y,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 ce(e,n,Y)||e}let i=pe(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?N(e):void 0}}})}dispatch(e,t){return!this.host||!this.identity?(t({protocol:K,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:G(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 J}}requireArchive(){let e=this.archive();if(!e)throw Error(`No docx loaded`);return e}};function ve(e){return!!e&&typeof e==`object`&&e.protocol===`ooxml-pull-v1`}const X=new oe(y,{freeArchive:e=>e.free(),reinit:b}),Z=new _e(()=>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 t=>{let n=t.data;if(ve(n)){try{await Z.dispatch(n,$)}catch(e){$({protocol:K,kind:`error`,sessionId:n.sessionId,operationId:n.operationId,generation:n.generation,requestId:n.requestId,error:G(e)})}return}if(n.type===`init`){X.setWasmInput(re(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[t,i,a]=me(n.resourcePolicy),o=new Uint8Array(n.data);X.run(()=>{let n=new e(o,t,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 t=X.archive;if(n.type===`extractImage`){if(!t)throw Error(`No docx loaded`);let e=X.run(()=>t.extract_image(n.path).buffer),i={type:`imageExtracted`,id:r,bytes:e};self.postMessage(i,[e]);return}if(n.type===`resourceUsage`){if(!t)throw Error(`No docx loaded`);$({type:`resourceUsage`,id:r,usage:N(X.run(()=>t.resource_usage()))});return}if(n.type===`toMarkdown`){if(!t)throw Error(`No docx loaded`);$({type:`markdownRendered`,id:r,markdown:X.run(()=>t.to_markdown())});return}}catch(e){$({type:`error`,id:r,...G(e)})}};", F = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", P], { type: "text/javascript;charset=utf-8" });
|
|
56
|
-
function
|
|
57
|
+
function We(e) {
|
|
57
58
|
let t;
|
|
58
59
|
try {
|
|
59
60
|
if (t = F && (self.URL || self.webkitURL).createObjectURL(F), !t) throw "";
|
|
@@ -73,17 +74,17 @@ function Ue(e) {
|
|
|
73
74
|
}
|
|
74
75
|
//#endregion
|
|
75
76
|
//#region packages/docx/src/wasm/docx_parser_bg.wasm?url
|
|
76
|
-
var
|
|
77
|
+
var Ge = new URL("docx_parser_bg.wasm", import.meta.url).href;
|
|
77
78
|
//#endregion
|
|
78
79
|
//#region packages/docx/src/bookmark-nav.ts
|
|
79
|
-
function
|
|
80
|
+
function Ke(e) {
|
|
80
81
|
let t = /* @__PURE__ */ new Map();
|
|
81
82
|
for (let n of e.pages) for (let e of n.bookmarkStarts) e.name !== "" && !t.has(e.name) && t.set(e.name, n.pageIndex);
|
|
82
83
|
return t;
|
|
83
84
|
}
|
|
84
85
|
//#endregion
|
|
85
86
|
//#region packages/docx/src/embedded-fonts.ts
|
|
86
|
-
async function
|
|
87
|
+
async function qe(e, t) {
|
|
87
88
|
let n = e.embeddedFonts;
|
|
88
89
|
if (!n || n.length === 0) return [];
|
|
89
90
|
let r = (await Promise.all(n.map(async (e) => {
|
|
@@ -94,24 +95,24 @@ async function Ke(e, t) {
|
|
|
94
95
|
bytes: n,
|
|
95
96
|
odttf: e.partPath.toLowerCase().endsWith(".odttf"),
|
|
96
97
|
fontKey: e.fontKey,
|
|
97
|
-
weight:
|
|
98
|
-
style:
|
|
98
|
+
weight: Je(e.style),
|
|
99
|
+
style: Ye(e.style)
|
|
99
100
|
};
|
|
100
101
|
} catch {
|
|
101
102
|
return null;
|
|
102
103
|
}
|
|
103
104
|
}))).filter((e) => e !== null);
|
|
104
|
-
return r.length === 0 ? [] :
|
|
105
|
+
return r.length === 0 ? [] : He(r);
|
|
105
106
|
}
|
|
106
|
-
function
|
|
107
|
+
function Je(e) {
|
|
107
108
|
return e === "bold" || e === "boldItalic" ? "bold" : "normal";
|
|
108
109
|
}
|
|
109
|
-
function
|
|
110
|
+
function Ye(e) {
|
|
110
111
|
return e === "italic" || e === "boldItalic" ? "italic" : "normal";
|
|
111
112
|
}
|
|
112
113
|
//#endregion
|
|
113
114
|
//#region packages/docx/src/element-context.ts
|
|
114
|
-
var I = de,
|
|
115
|
+
var I = de, Xe = 16384;
|
|
115
116
|
function L(e, t) {
|
|
116
117
|
let n = Math.min(e.length, t);
|
|
117
118
|
if (n > 0 && n < e.length) {
|
|
@@ -120,7 +121,7 @@ function L(e, t) {
|
|
|
120
121
|
}
|
|
121
122
|
return e.slice(0, n);
|
|
122
123
|
}
|
|
123
|
-
function
|
|
124
|
+
function Ze(e, t) {
|
|
124
125
|
let n = [], r = 0, i = !1;
|
|
125
126
|
for (let a of e) {
|
|
126
127
|
if (a.length === 0) continue;
|
|
@@ -157,27 +158,27 @@ function* R(e) {
|
|
|
157
158
|
}
|
|
158
159
|
if (e.kind === "note" || e.kind === "textbox") for (let t of e.story.blocks) yield* R(t);
|
|
159
160
|
}
|
|
160
|
-
function*
|
|
161
|
+
function* Qe(e) {
|
|
161
162
|
for (let t of e.drawing.commands) (t.kind === "text" || t.kind === "watermark-text") && (yield t.text);
|
|
162
163
|
for (let t of e.textBoxes) yield* R(t);
|
|
163
164
|
}
|
|
164
165
|
function z(e) {
|
|
165
|
-
let t = e ??
|
|
166
|
+
let t = e ?? Xe;
|
|
166
167
|
if (!Number.isFinite(t) || t < 0) throw RangeError("maxTextCharacters must be a finite non-negative number.");
|
|
167
168
|
return Math.min(I, Math.floor(t));
|
|
168
169
|
}
|
|
169
|
-
function
|
|
170
|
+
function $e(e) {
|
|
170
171
|
return {
|
|
171
172
|
story: e.story,
|
|
172
173
|
storyInstance: e.storyInstance,
|
|
173
174
|
path: [...e.path]
|
|
174
175
|
};
|
|
175
176
|
}
|
|
176
|
-
function
|
|
177
|
+
function et(e) {
|
|
177
178
|
return "drawing" in e ? e.drawing.inkBounds : e.placement.bounds;
|
|
178
179
|
}
|
|
179
|
-
function
|
|
180
|
-
let t =
|
|
180
|
+
function tt(e) {
|
|
181
|
+
let t = et(e), n = [
|
|
181
182
|
k(e.pointToPage, t),
|
|
182
183
|
k(e.pointToPage, {
|
|
183
184
|
xPt: t.xPt + t.widthPt,
|
|
@@ -202,7 +203,7 @@ function et(e) {
|
|
|
202
203
|
function B(e, t) {
|
|
203
204
|
return t.xPt >= e.xPt && t.xPt <= e.xPt + e.widthPt && t.yPt >= e.yPt && t.yPt <= e.yPt + e.heightPt;
|
|
204
205
|
}
|
|
205
|
-
function
|
|
206
|
+
function nt(e, t) {
|
|
206
207
|
let n = !1;
|
|
207
208
|
for (let r = 0, i = t.length - 1; r < t.length; i = r++) {
|
|
208
209
|
let a = t[r], o = t[i];
|
|
@@ -210,24 +211,24 @@ function tt(e, t) {
|
|
|
210
211
|
}
|
|
211
212
|
return n;
|
|
212
213
|
}
|
|
213
|
-
function
|
|
214
|
-
return B(e.inkBounds, t) ? e.clip ? e.clip.kind === "rect" ? B(e.clip.rect, t) :
|
|
214
|
+
function rt(e, t) {
|
|
215
|
+
return B(e.inkBounds, t) ? e.clip ? e.clip.kind === "rect" ? B(e.clip.rect, t) : nt(t, e.clip.points) : !0 : !1;
|
|
215
216
|
}
|
|
216
|
-
function
|
|
217
|
+
function it(e, t, n) {
|
|
217
218
|
for (let n of e.clips) {
|
|
218
219
|
let e = E(n.pointToPage, t);
|
|
219
220
|
if (!e || !B(n.bounds, e)) return !1;
|
|
220
221
|
}
|
|
221
|
-
return "drawing" in e ?
|
|
222
|
+
return "drawing" in e ? rt(e.drawing, n) : B(e.placement.bounds, n);
|
|
222
223
|
}
|
|
223
224
|
function V(e, t) {
|
|
224
225
|
return e.commands.find((e) => e.kind === "resource" && e.resourceKind === t);
|
|
225
226
|
}
|
|
226
|
-
function
|
|
227
|
+
function at(e) {
|
|
227
228
|
return V(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" : V(e, "image") ? "image" : null;
|
|
228
229
|
}
|
|
229
|
-
function
|
|
230
|
-
let o = "drawing" in e ?
|
|
230
|
+
function ot(e, t, n, r, i, a) {
|
|
231
|
+
let o = "drawing" in e ? at(e.drawing) : e.placement.resourceKind;
|
|
231
232
|
if (!o) return null;
|
|
232
233
|
let s, c = !1, l, u;
|
|
233
234
|
if (o === "chart") {
|
|
@@ -238,7 +239,7 @@ function at(e, t, n, r, i, a) {
|
|
|
238
239
|
if (!n) throw Error(`Unknown image paint resource: ${t}`);
|
|
239
240
|
l = n.mimeType;
|
|
240
241
|
} else {
|
|
241
|
-
let t =
|
|
242
|
+
let t = Ze(Qe(e), a);
|
|
242
243
|
s = t.text, c = t.truncated;
|
|
243
244
|
}
|
|
244
245
|
return {
|
|
@@ -248,8 +249,8 @@ function at(e, t, n, r, i, a) {
|
|
|
248
249
|
elementIndex: n,
|
|
249
250
|
elementType: o,
|
|
250
251
|
point: { ...r },
|
|
251
|
-
bounds:
|
|
252
|
-
source:
|
|
252
|
+
bounds: tt(e),
|
|
253
|
+
source: $e("drawing" in e ? e.drawing.source : e.source),
|
|
253
254
|
...s === void 0 ? {} : { text: s },
|
|
254
255
|
...l === void 0 ? {} : { mimeType: l },
|
|
255
256
|
...u === void 0 ? {} : { seriesCount: u },
|
|
@@ -259,19 +260,19 @@ function at(e, t, n, r, i, a) {
|
|
|
259
260
|
maxTextCharacters: a
|
|
260
261
|
};
|
|
261
262
|
}
|
|
262
|
-
function
|
|
263
|
+
function st(e, t, n, r, i = {}) {
|
|
263
264
|
if (!Number.isFinite(n.xPt) || !Number.isFinite(n.yPt)) throw RangeError("DOCX hit-test point must contain finite page coordinates.");
|
|
264
265
|
let a = z(i.maxTextCharacters), o = Oe(e, t);
|
|
265
266
|
for (let e = o.length - 1; e >= 0; e--) {
|
|
266
267
|
let i = o[e], s = E(i.pointToPage, n);
|
|
267
|
-
if (!s || !
|
|
268
|
-
let c =
|
|
268
|
+
if (!s || !it(i, n, s)) continue;
|
|
269
|
+
let c = ot(i, t, e, n, r, a);
|
|
269
270
|
if (c) return c;
|
|
270
271
|
}
|
|
271
272
|
return null;
|
|
272
273
|
}
|
|
273
|
-
function
|
|
274
|
-
return
|
|
274
|
+
function ct(e, t, n, r) {
|
|
275
|
+
return st(Ie(e, {
|
|
275
276
|
currentDate: r.currentDate,
|
|
276
277
|
defaultCurrentDateMs: r.defaultCurrentDateMs
|
|
277
278
|
}, t).layout, t, n, xe(e), r);
|
|
@@ -312,7 +313,7 @@ var U = class e {
|
|
|
312
313
|
this._worker = e, this._mode = t, we(this, n), this._bridge = new m(this._worker, {
|
|
313
314
|
correlate: (e) => "protocol" in e && e.protocol === "ooxml-pull-v1" ? e.requestId : "id" in e ? e.id : void 0,
|
|
314
315
|
toError: (e) => {
|
|
315
|
-
if (!("protocol" in e || e.type !== "error")) return Object.assign(
|
|
316
|
+
if (!("protocol" in e || e.type !== "error")) return Object.assign(s(e), {
|
|
316
317
|
...e.reason === void 0 ? {} : { reason: e.reason },
|
|
317
318
|
...e.outgoingColumnIndex === void 0 ? {} : { outgoingColumnIndex: e.outgoingColumnIndex },
|
|
318
319
|
...e.outgoingColumnCount === void 0 ? {} : { outgoingColumnCount: e.outgoingColumnCount },
|
|
@@ -320,20 +321,20 @@ var U = class e {
|
|
|
320
321
|
});
|
|
321
322
|
}
|
|
322
323
|
});
|
|
323
|
-
let i = new URL(r ??
|
|
324
|
+
let i = new URL(r ?? Ge, location.href).href;
|
|
324
325
|
this._bridge.post({
|
|
325
326
|
type: "init",
|
|
326
327
|
wasmUrl: i
|
|
327
328
|
});
|
|
328
329
|
}
|
|
329
|
-
static async load(n,
|
|
330
|
-
let
|
|
330
|
+
static async load(n, i = {}) {
|
|
331
|
+
let a = t(i), o = Date.now(), s = i.mode ?? "main", c = new r({
|
|
331
332
|
enabled: !0,
|
|
332
333
|
format: "docx",
|
|
333
334
|
mode: s,
|
|
334
|
-
policy:
|
|
335
|
-
onMetrics:
|
|
336
|
-
emitToConsole:
|
|
335
|
+
policy: a.policy,
|
|
336
|
+
onMetrics: a.onResourceMetrics,
|
|
337
|
+
emitToConsole: a.debug
|
|
337
338
|
});
|
|
338
339
|
try {
|
|
339
340
|
if (s === "worker" && (typeof Worker > "u" || typeof OffscreenCanvas > "u")) throw Error("mode: 'worker' requires Worker and OffscreenCanvas support");
|
|
@@ -343,62 +344,63 @@ var U = class e {
|
|
|
343
344
|
if (!e.ok) throw Error(`Failed to fetch: ${e.status} ${e.statusText}`);
|
|
344
345
|
t = await e.arrayBuffer();
|
|
345
346
|
} else t = n;
|
|
346
|
-
t = h(await _(t,
|
|
347
|
-
let
|
|
347
|
+
t = h(await _(t, i.password)), c.setSourceBytes(t.byteLength), c.checkpoint("container ready");
|
|
348
|
+
let r = s === "worker" ? (await import("./render-worker-host-CcENRoDr.js")).createRenderWorker() : new We(), l = s === "worker" ? Le(i) : void 0, u;
|
|
348
349
|
try {
|
|
349
|
-
if (
|
|
350
|
-
let e =
|
|
351
|
-
|
|
350
|
+
if (u = new e(r, s, o, i.wasmUrl), u._metrics = c, await u._parse(t, a.policy, s === "worker" ? !!i.useGoogleFonts : !1, i.workerTimeoutMs, (e) => c.observeUsage(e), l), s === "worker" && u._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.")), i.math && u._mode === "worker" && !l?.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."), i.threeD && u._mode === "worker" && !l?.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."), u._threeD = u._mode === "worker" ? void 0 : i.threeD, i.regionMap && u._mode === "worker" && !l?.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."), u._regionMap = u._mode === "worker" ? void 0 : i.regionMap, u._mode === "main" && i.useGoogleFonts && u._document && (u._googleFontFaces = await ge(Ne(u._document), De)), u._mode === "main" && u._document?.embeddedFonts?.length) {
|
|
351
|
+
let e = u;
|
|
352
|
+
u._embeddedFontFaces = await qe(u._document, (t) => e.getFontBytes(t));
|
|
352
353
|
}
|
|
353
354
|
let n;
|
|
354
|
-
|
|
355
|
-
let
|
|
356
|
-
if (
|
|
357
|
-
let e = A(
|
|
358
|
-
e.services = Ae(
|
|
355
|
+
u._mode === "main" && u._document && (n = await Ee(u._document), u._localMetricFontFaces = n.faces);
|
|
356
|
+
let d;
|
|
357
|
+
if (u._mode === "main" && i.math && u._document && Me(u._document) && (d = await Pe(u._document, i.math)), u._mode === "main" && u._document && u._source) {
|
|
358
|
+
let e = A(u);
|
|
359
|
+
e.services = Ae(u._source, {
|
|
359
360
|
localMetrics: n?.metrics,
|
|
360
|
-
useGoogleFonts: !!
|
|
361
|
-
embeddedFaces:
|
|
362
|
-
googleFaces:
|
|
363
|
-
mathResources:
|
|
364
|
-
mathDrawables:
|
|
361
|
+
useGoogleFonts: !!i.useGoogleFonts,
|
|
362
|
+
embeddedFaces: u._embeddedFontFaces,
|
|
363
|
+
googleFaces: u._googleFontFaces,
|
|
364
|
+
mathResources: d?.records,
|
|
365
|
+
mathDrawables: d?.drawables
|
|
365
366
|
});
|
|
366
367
|
let t = e.services;
|
|
367
|
-
Ce(
|
|
368
|
+
Ce(u._source, t, e.defaultCurrentDateMs).layoutVariants.defaultLayout;
|
|
368
369
|
}
|
|
369
|
-
return await
|
|
370
|
+
return await u._resourceUsage(i.workerTimeoutMs ?? 1e3).then((e) => c.observeUsage(e), () => void 0), c.checkpoint("model and layout ready"), c.succeed({ pages: u.pageCount }), u;
|
|
370
371
|
} catch (e) {
|
|
371
|
-
let t =
|
|
372
|
-
throw g(
|
|
372
|
+
let t = u;
|
|
373
|
+
throw g(r, t ? () => t.destroy() : void 0), e;
|
|
373
374
|
}
|
|
374
375
|
} catch (e) {
|
|
375
376
|
throw c.fail(e), e;
|
|
376
377
|
}
|
|
377
378
|
}
|
|
378
|
-
async _parse(e, t, n = !1, r, i) {
|
|
379
|
-
let
|
|
379
|
+
async _parse(e, t, n = !1, r, i, a) {
|
|
380
|
+
let o = await this._bridge.request((r) => this._mode === "worker" ? {
|
|
380
381
|
type: "parse",
|
|
381
382
|
id: r,
|
|
382
383
|
data: e,
|
|
383
384
|
resourcePolicy: t,
|
|
384
385
|
useGoogleFonts: n,
|
|
385
|
-
defaultCurrentDateMs: A(this).defaultCurrentDateMs
|
|
386
|
+
defaultCurrentDateMs: A(this).defaultCurrentDateMs,
|
|
387
|
+
renderers: a
|
|
386
388
|
} : {
|
|
387
389
|
type: "parse",
|
|
388
390
|
id: r,
|
|
389
391
|
data: e,
|
|
390
392
|
resourcePolicy: t
|
|
391
393
|
}, [e], { timeoutMs: r });
|
|
392
|
-
if ("protocol" in
|
|
393
|
-
if (this._mode === "worker") if ("usage" in
|
|
394
|
-
let e = await D(this._bridge.transport(O),
|
|
394
|
+
if ("protocol" in o) throw Error("DOCX parse open returned a pull-protocol response");
|
|
395
|
+
if (this._mode === "worker") if ("usage" in o && o.usage && i?.(o.usage), o.type === "mainThreadVerticalFallback") {
|
|
396
|
+
let e = await D(this._bridge.transport(O), o, {
|
|
395
397
|
timeoutMs: r,
|
|
396
398
|
onUsage: i
|
|
397
399
|
});
|
|
398
400
|
this._source = e.source, this._document = e.document, this._meta = null, this._mode = "main";
|
|
399
|
-
} else this._meta =
|
|
401
|
+
} else this._meta = o.meta;
|
|
400
402
|
else {
|
|
401
|
-
let e =
|
|
403
|
+
let e = o, t = await D(this._bridge.transport(O), e, {
|
|
402
404
|
timeoutMs: r,
|
|
403
405
|
onUsage: i
|
|
404
406
|
});
|
|
@@ -406,7 +408,7 @@ var U = class e {
|
|
|
406
408
|
}
|
|
407
409
|
}
|
|
408
410
|
destroy() {
|
|
409
|
-
this._bridge.terminate(), this._document = null, this._source = null, this._meta = null, A(this).services = null, this._bookmarkPages = null, this._rawParts.clear(), this._embeddedFontFaces.length > 0 && (
|
|
411
|
+
this._bridge.terminate(), this._document = null, this._source = null, this._meta = null, A(this).services = null, this._bookmarkPages = null, this._rawParts.clear(), this._embeddedFontFaces.length > 0 && (Ue(this._embeddedFontFaces), this._embeddedFontFaces = []), this._googleFontFaces.length > 0 && (me(this._googleFontFaces), this._googleFontFaces = []), this._localMetricFontFaces.length > 0 && (Fe(this._localMetricFontFaces), this._localMetricFontFaces = []), c(this._fetchImage), n(this._fetchImage);
|
|
410
412
|
}
|
|
411
413
|
async getImage(e, t) {
|
|
412
414
|
return this._rawParts.get(e, t, () => this._bridge.request((t) => ({
|
|
@@ -435,7 +437,7 @@ var U = class e {
|
|
|
435
437
|
async getResourceMetrics() {
|
|
436
438
|
let e = this._metrics;
|
|
437
439
|
if (!e) throw Error("Document not loaded");
|
|
438
|
-
return
|
|
440
|
+
return f(e, (e) => this._resourceUsage(e));
|
|
439
441
|
}
|
|
440
442
|
async toMarkdown() {
|
|
441
443
|
return (await this._bridge.request((e) => ({
|
|
@@ -475,7 +477,7 @@ var U = class e {
|
|
|
475
477
|
if (this._bookmarkPages) return this._bookmarkPages;
|
|
476
478
|
if (this._meta) return this._bookmarkPages = new Map(this._meta.bookmarkPages), this._bookmarkPages;
|
|
477
479
|
let e = this._getLayout();
|
|
478
|
-
return e ? (this._bookmarkPages =
|
|
480
|
+
return e ? (this._bookmarkPages = Ke(e), this._bookmarkPages) : null;
|
|
479
481
|
}
|
|
480
482
|
getBookmarkPage(e) {
|
|
481
483
|
return this._getBookmarkPages()?.get(e);
|
|
@@ -521,7 +523,7 @@ var U = class e {
|
|
|
521
523
|
async renderPageToBitmap(e, t = {}) {
|
|
522
524
|
let { onTextRun: n, ...r } = t, i = {
|
|
523
525
|
...r,
|
|
524
|
-
dpr: r.dpr ??
|
|
526
|
+
dpr: r.dpr ?? u()
|
|
525
527
|
};
|
|
526
528
|
if (this._mode === "worker") {
|
|
527
529
|
let t = await this._bridge.request((t) => ({
|
|
@@ -565,7 +567,7 @@ var U = class e {
|
|
|
565
567
|
}))).context;
|
|
566
568
|
let r = A(this), i = r.services;
|
|
567
569
|
if (!i) throw Error("Document layout services are not initialized");
|
|
568
|
-
return
|
|
570
|
+
return ct(i, e, t, {
|
|
569
571
|
...n,
|
|
570
572
|
defaultCurrentDateMs: r.defaultCurrentDateMs
|
|
571
573
|
});
|
|
@@ -608,7 +610,7 @@ function q(e, t, n, r, i, a, o = {}) {
|
|
|
608
610
|
for (let s of o.slices) {
|
|
609
611
|
let o = t[s.runIndex];
|
|
610
612
|
if (!o) continue;
|
|
611
|
-
let c = a(o.font), l =
|
|
613
|
+
let c = a(o.font), l = Re(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, _ = W(o, c), v = h * _, y = g * _;
|
|
612
614
|
if (y <= 0) continue;
|
|
613
615
|
let b = document.createElement("div"), x = o.transform ? `transform:${o.transform};transform-origin:top left;` : "";
|
|
614
616
|
b.style.cssText = `position:absolute;left:${N(o.x + v, r)};top:${N(o.y, i)};width:${N(y, r)};height:${N(o.h, i)};` + x + `background:${n};pointer-events:none;`, e.appendChild(b);
|
|
@@ -714,14 +716,14 @@ function Y(e) {
|
|
|
714
716
|
let t = Number(e);
|
|
715
717
|
return Number.isSafeInteger(t) ? t : null;
|
|
716
718
|
}
|
|
717
|
-
function
|
|
719
|
+
function lt(e) {
|
|
718
720
|
for (let t = e; t; t = t.parentElement) {
|
|
719
721
|
let e = Y(t.dataset.pageIndex);
|
|
720
722
|
if (e !== null) return e;
|
|
721
723
|
}
|
|
722
724
|
return null;
|
|
723
725
|
}
|
|
724
|
-
var
|
|
726
|
+
var ut = new Set([
|
|
725
727
|
"body",
|
|
726
728
|
"header",
|
|
727
729
|
"footer",
|
|
@@ -731,7 +733,7 @@ var lt = new Set([
|
|
|
731
733
|
]);
|
|
732
734
|
function X(e) {
|
|
733
735
|
let t = e.dataset.sourceStory, n = e.dataset.sourceStoryInstance, r = e.dataset.sourcePath;
|
|
734
|
-
if (!t || !
|
|
736
|
+
if (!t || !ut.has(t) || !n || !r) return null;
|
|
735
737
|
try {
|
|
736
738
|
let e = JSON.parse(r);
|
|
737
739
|
return !Array.isArray(e) || e.length === 0 || e.length > 32 || !e.every((e) => Number.isSafeInteger(e) && e >= 0) ? null : {
|
|
@@ -745,7 +747,7 @@ function X(e) {
|
|
|
745
747
|
}
|
|
746
748
|
function Z(e, t, n = {}) {
|
|
747
749
|
let r = le(e, t, (e) => {
|
|
748
|
-
let t =
|
|
750
|
+
let t = lt(e), n = Y(e.dataset.runIndex);
|
|
749
751
|
return t === null || n === null ? null : {
|
|
750
752
|
pageIndex: t,
|
|
751
753
|
runIndex: n,
|
|
@@ -774,7 +776,7 @@ function Z(e, t, n = {}) {
|
|
|
774
776
|
}
|
|
775
777
|
//#endregion
|
|
776
778
|
//#region packages/docx/src/viewer.ts
|
|
777
|
-
var Q = Symbol("DocxViewer.borrowedDocument"),
|
|
779
|
+
var Q = Symbol("DocxViewer.borrowedDocument"), dt = class e {
|
|
778
780
|
_documentOwner;
|
|
779
781
|
get _doc() {
|
|
780
782
|
return this._documentOwner.current;
|
|
@@ -1077,14 +1079,14 @@ var Q = Symbol("DocxViewer.borrowedDocument"), ut = class e {
|
|
|
1077
1079
|
_hyperlinkHandler() {
|
|
1078
1080
|
return this._opts.enableHyperlinks === !1 ? void 0 : this._opts.onHyperlinkClick || ((e) => {
|
|
1079
1081
|
if (e.kind === "external") {
|
|
1080
|
-
|
|
1082
|
+
a(e.url, void 0, this._hostWindow);
|
|
1081
1083
|
return;
|
|
1082
1084
|
}
|
|
1083
1085
|
let t = this._doc?.getBookmarkPage(e.ref);
|
|
1084
1086
|
t !== void 0 && this.goToPage(t).catch((e) => this._reportRenderError(e));
|
|
1085
1087
|
});
|
|
1086
1088
|
}
|
|
1087
|
-
},
|
|
1089
|
+
}, ft = 150, pt = "0 1px 3px rgba(0,0,0,0.2)", mt = Symbol("DocxScrollViewer.borrowedDocument"), ht = class e {
|
|
1088
1090
|
_documentOwner;
|
|
1089
1091
|
get _doc() {
|
|
1090
1092
|
return this._documentOwner.current;
|
|
@@ -1127,13 +1129,13 @@ var Q = Symbol("DocxViewer.borrowedDocument"), ut = class e {
|
|
|
1127
1129
|
static fromDocument(t, n, r = {}) {
|
|
1128
1130
|
return new e(t, {
|
|
1129
1131
|
...r,
|
|
1130
|
-
[
|
|
1132
|
+
[mt]: n
|
|
1131
1133
|
});
|
|
1132
1134
|
}
|
|
1133
1135
|
constructor(e, t = {}) {
|
|
1134
1136
|
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.");
|
|
1135
|
-
this._container = e, this._opts = t, this._pageShadow = t.pageShadow ??
|
|
1136
|
-
let n = t[
|
|
1137
|
+
this._container = e, this._opts = t, this._pageShadow = t.pageShadow ?? pt;
|
|
1138
|
+
let n = t[mt];
|
|
1137
1139
|
this._borrowed = n !== void 0, n ? (this._documentOwner = new y("DocxScrollViewer", n, !1), this._mode = C("DocxScrollViewer", t.mode, n)) : (this._documentOwner = new y("DocxScrollViewer"), this._mode = C("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), t.enableTextSelection && (t.onSelectionContextChange || t.enableElementSelection) && (this._selectionChangeListener = () => this._emitSelectionContextChange(), this._wrapper.ownerDocument.addEventListener("selectionchange", this._selectionChangeListener)), t.enableElementSelection && (this._elementClickListener = (e) => {
|
|
1138
1140
|
this._onElementClick(e).catch((e) => this._reportRenderError(e));
|
|
1139
1141
|
}, 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), this._opts.enableZoom !== !1 && (this._wheelListener = (e) => {
|
|
@@ -1355,7 +1357,7 @@ var Q = Symbol("DocxViewer.borrowedDocument"), ut = class e {
|
|
|
1355
1357
|
_hyperlinkHandler() {
|
|
1356
1358
|
return this._opts.enableHyperlinks === !1 ? void 0 : this._opts.onHyperlinkClick || ((e) => {
|
|
1357
1359
|
if (e.kind === "external") {
|
|
1358
|
-
|
|
1360
|
+
a(e.url);
|
|
1359
1361
|
return;
|
|
1360
1362
|
}
|
|
1361
1363
|
let t = this._doc?.getBookmarkPage(e.ref);
|
|
@@ -1482,7 +1484,7 @@ var Q = Symbol("DocxViewer.borrowedDocument"), ut = class e {
|
|
|
1482
1484
|
_scheduleSettle() {
|
|
1483
1485
|
this._settleTimer !== null && clearTimeout(this._settleTimer), this._settleTimer = setTimeout(() => {
|
|
1484
1486
|
this._settleTimer = null, this._settleRender();
|
|
1485
|
-
},
|
|
1487
|
+
}, ft);
|
|
1486
1488
|
}
|
|
1487
1489
|
_settleRender() {
|
|
1488
1490
|
if (!(this._destroyed || !this._doc || this._doc.pageCount === 0)) for (let [e, t] of [...this._slots]) t.renderedScale !== this._scale && this._settleSlot(e, t);
|
|
@@ -1712,20 +1714,20 @@ function $(e) {
|
|
|
1712
1714
|
}
|
|
1713
1715
|
//#endregion
|
|
1714
1716
|
//#region src/docx.ts
|
|
1715
|
-
var
|
|
1717
|
+
var gt = /* @__PURE__ */ e({
|
|
1716
1718
|
DocxDocument: () => U,
|
|
1717
|
-
DocxScrollViewer: () =>
|
|
1718
|
-
DocxViewer: () =>
|
|
1719
|
-
OoxmlDecodedImageLimitError: () =>
|
|
1720
|
-
OoxmlError: () =>
|
|
1721
|
-
OoxmlResourceLimitError: () =>
|
|
1719
|
+
DocxScrollViewer: () => ht,
|
|
1720
|
+
DocxViewer: () => dt,
|
|
1721
|
+
OoxmlDecodedImageLimitError: () => i,
|
|
1722
|
+
OoxmlError: () => o,
|
|
1723
|
+
OoxmlResourceLimitError: () => l,
|
|
1722
1724
|
autoResize: () => fe,
|
|
1723
1725
|
buildDocxHighlightLayer: () => q,
|
|
1724
1726
|
buildDocxTextLayer: () => K,
|
|
1725
|
-
isOoxmlDecodedImageLimitError: () =>
|
|
1727
|
+
isOoxmlDecodedImageLimitError: () => p,
|
|
1726
1728
|
noteText: () => $,
|
|
1727
|
-
openExternalHyperlink: () =>
|
|
1729
|
+
openExternalHyperlink: () => a,
|
|
1728
1730
|
readDocxTextSelectionContext: () => Z
|
|
1729
1731
|
});
|
|
1730
1732
|
//#endregion
|
|
1731
|
-
export { Z as a, U as c,
|
|
1733
|
+
export { Z as a, U as c, dt as i, $ as n, q as o, ht as r, K as s, gt as t };
|
package/dist/docx.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { w as a } from "./canvas-viewer-mechanics-
|
|
3
|
-
import { a as o, c as s, i as c, n as l, o as u, r as d, s as f } from "./docx-
|
|
4
|
-
export { s as DocxDocument, d as DocxScrollViewer, c as DocxViewer, e as OoxmlDecodedImageLimitError,
|
|
1
|
+
import { Rt as e, a as t, cn as n, ln as r, zt as i } from "./line-metrics-PpgpOvz4.js";
|
|
2
|
+
import { w as a } from "./canvas-viewer-mechanics-D41tGY4d.js";
|
|
3
|
+
import { a as o, c as s, i as c, n as l, o as u, r as d, s as f } from "./docx-CbIqgb1f.js";
|
|
4
|
+
export { s as DocxDocument, d as DocxScrollViewer, c as DocxViewer, e as OoxmlDecodedImageLimitError, n as OoxmlError, r as OoxmlResourceLimitError, a as autoResize, u as buildDocxHighlightLayer, f as buildDocxTextLayer, i as isOoxmlDecodedImageLimitError, l as noteText, t as openExternalHyperlink, o as readDocxTextSelectionContext };
|
package/dist/docx_parser_bg.wasm
CHANGED
|
Binary file
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "./docx-
|
|
2
|
-
import { t } from "./xlsx-
|
|
3
|
-
import { t as n } from "./pptx-
|
|
1
|
+
import { t as e } from "./docx-CbIqgb1f.js";
|
|
2
|
+
import { t } from "./xlsx-C1BUns1R.js";
|
|
3
|
+
import { t as n } from "./pptx-DwF8olh2.js";
|
|
4
4
|
export { e as docx, n as pptx, t as xlsx };
|