@docx-editor.dev/core 2.9.2 → 2.10.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/dist/automation.cjs +1 -1
- package/dist/automation.js +1 -1
- package/dist/binding.cjs +1 -1
- package/dist/binding.d.cts +74 -10
- package/dist/binding.d.ts +74 -10
- package/dist/binding.js +1 -1
- package/dist/chunk-27APDXY2.js +2 -0
- package/dist/chunk-35MI6K7M.cjs +10 -0
- package/dist/chunk-4XL7SOWQ.cjs +2 -0
- package/dist/chunk-6K6QQVAZ.cjs +18 -0
- package/dist/chunk-7ZJL5AEY.cjs +1 -0
- package/dist/chunk-C6LK2BYA.cjs +2 -0
- package/dist/chunk-HBEBUCRM.cjs +5 -0
- package/dist/chunk-LG5K46OM.js +2 -0
- package/dist/chunk-LWADHMVV.js +5 -0
- package/dist/chunk-N725IUO7.js +18 -0
- package/dist/chunk-N7DBENH4.js +10 -0
- package/dist/chunk-NVGFWMCO.js +1 -0
- package/dist/chunk-SYTWKJPJ.cjs +18 -0
- package/dist/chunk-YI6JXF7U.js +18 -0
- package/dist/contracts/document.d.cts +6 -1
- package/dist/contracts/document.d.ts +6 -1
- package/dist/contracts/editor.d.cts +6 -6
- package/dist/contracts/editor.d.ts +6 -6
- package/dist/contracts/interaction.d.cts +6 -6
- package/dist/contracts/interaction.d.ts +6 -6
- package/dist/contracts/modules.d.cts +3 -4
- package/dist/contracts/modules.d.ts +3 -4
- package/dist/{custom-node-writes-D6SGwebL.d.ts → custom-node-writes-BvpWCnW8.d.ts} +35 -4
- package/dist/{custom-node-writes-Dy3b20PS.d.cts → custom-node-writes-Db8H6Z3n.d.cts} +35 -4
- package/dist/{editor-Cvd7Geoc.d.ts → editor-C0my6Uta.d.ts} +35 -14
- package/dist/{editor-cAEf1uXW.d.cts → editor-CwzY2Hcg.d.cts} +35 -14
- package/dist/editor.cjs +1 -1
- package/dist/editor.css +57 -456
- package/dist/editor.d.cts +20 -20
- package/dist/editor.d.ts +20 -20
- package/dist/editor.js +1 -1
- package/dist/{index-DRqY5JVF.d.ts → index-kID8Ymkp.d.ts} +79 -19
- package/dist/{index-wb-iOxfh.d.cts → index-nLFwo_17.d.cts} +79 -19
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +13 -13
- package/dist/index.d.ts +13 -13
- package/dist/index.js +1 -1
- package/dist/layout.cjs +1 -1
- package/dist/layout.d.cts +38 -19
- package/dist/layout.d.ts +38 -19
- package/dist/layout.js +1 -1
- package/dist/output.cjs +1 -1
- package/dist/output.d.cts +6 -6
- package/dist/output.d.ts +6 -6
- package/dist/output.js +1 -1
- package/dist/{review-items-B8tffIXj.d.cts → review-items-CwixiHNe.d.cts} +1 -1
- package/dist/{review-items-bdGxFWNA.d.ts → review-items-Dw-8a6Ie.d.ts} +1 -1
- package/dist/{review-reads-Bxz03tHG.d.cts → review-reads-BqkiJTeR.d.cts} +1 -1
- package/dist/{review-reads-CHODU0LI.d.ts → review-reads-C0u-IKEA.d.ts} +1 -1
- package/dist/{semantic-cell-selection-BPzx6DdT.d.cts → semantic-cell-selection-DT9x9WLf.d.cts} +2 -2
- package/dist/{semantic-cell-selection-CsHcr-yk.d.ts → semantic-cell-selection-Utrf0lz7.d.ts} +2 -2
- package/dist/{semantic-interaction-BfWDD_0V.d.cts → semantic-interaction-B6hFRQLy.d.ts} +21 -2
- package/dist/{semantic-interaction-D-RZ9Ust.d.ts → semantic-interaction-Z0xKQcB4.d.cts} +21 -2
- package/dist/{semantic-paint-WhVtSDJK.d.ts → semantic-paint-CQEOC0Od.d.cts} +2 -2
- package/dist/{semantic-paint-Bd7EqzXV.d.cts → semantic-paint-quke354p.d.ts} +2 -2
- package/dist/{semantic-records-DadVT_E1.d.cts → semantic-records-CMakzQ1X.d.cts} +16 -2
- package/dist/{semantic-records-DCt-ZwKU.d.ts → semantic-records-Do3-i5oB.d.ts} +16 -2
- package/dist/{shaped-measurer-B9f4A7QA.d.ts → shaped-measurer-BxwTUluj.d.ts} +1 -1
- package/dist/{shaped-measurer-CninrHr_.d.cts → shaped-measurer-DzRwWrL5.d.cts} +1 -1
- package/dist/store.cjs +1 -1
- package/dist/store.d.cts +128 -12
- package/dist/store.d.ts +128 -12
- package/dist/store.js +1 -1
- package/dist/tree-op-revision-attribution-CN06Xshv.d.cts +24 -0
- package/dist/tree-op-revision-attribution-CN06Xshv.d.ts +24 -0
- package/dist/{tree-op-types-CnRb7AYo.d.ts → tree-op-types-BuOfCrkp.d.ts} +259 -32
- package/dist/{tree-op-types-D1vNJ7XC.d.cts → tree-op-types-DSJYmf5b.d.cts} +259 -32
- package/dist/{tree-session-Df02ajqc.d.cts → tree-session-contract-ByWx8eew.d.cts} +44 -104
- package/dist/{tree-session-ZuBFOhIh.d.ts → tree-session-contract-C1dfE9hy.d.ts} +44 -104
- package/dist/{tree-store-DgETo6Mf.d.ts → tree-store-ASBtz7UB.d.ts} +1 -1
- package/dist/{tree-store-B_sJBMIS.d.cts → tree-store-CWOUMGN8.d.cts} +1 -1
- package/package.json +2 -2
- package/dist/chunk-6JWP2H7K.js +0 -2
- package/dist/chunk-6KNLLEUW.cjs +0 -18
- package/dist/chunk-7ADTI533.cjs +0 -10
- package/dist/chunk-7ETDCPF6.cjs +0 -2
- package/dist/chunk-7I3BSGGS.js +0 -1
- package/dist/chunk-7UU5YFCD.cjs +0 -2
- package/dist/chunk-CKDAK3MV.js +0 -10
- package/dist/chunk-DIMEYVNS.js +0 -2
- package/dist/chunk-H2656QDI.cjs +0 -1
- package/dist/chunk-KQGENNL5.cjs +0 -15
- package/dist/chunk-LIXPSV4T.js +0 -18
- package/dist/chunk-O4UULRAQ.cjs +0 -5
- package/dist/chunk-SIIFNE6U.js +0 -15
- package/dist/chunk-VXYECPKA.js +0 -5
- package/dist/image-resources-BgA9EQxY.d.ts +0 -203
- package/dist/image-resources-BiA-IXgo.d.cts +0 -203
package/dist/chunk-VXYECPKA.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import {M,L,O,R,S,G as G$1}from'./chunk-DIMEYVNS.js';import {Pe as Pe$1,b,Ke as Ke$1,va,ob,Wc,Rf,dg,We as We$1,Xe as Xe$1,Xf,Wf,sf,Zf,_f,Jg,Yc,zc,Zc,Tb,pb,Of,_c,je as je$1,Rb,Qb,E,eg,_d,cg,bg,Oe as Oe$1,Ob,Ub,Pg,Qg,ca,wg,zg,Ig,Wb,Qc,Pc,Hb,Jb}from'./chunk-CKDAK3MV.js';import {Schema}from'prosemirror-model';import {EditorState,TextSelection}from'prosemirror-state';import {EditorView}from'prosemirror-view';import {keymap}from'prosemirror-keymap';import {joinBackward,deleteSelection,joinForward,splitBlock,selectTextblockEnd,selectTextblockStart,baseKeymap}from'prosemirror-commands';function B(t){return t.attributes?.val}function j(t){let e=B(t);return e===void 0||!(e==="0"||e==="false"||e==="off")}var Un=/^[0-9A-Fa-f]{6}$/,ye=/^\d{1,6}$/,Yn=/^-?\d{1,6}$/;function _e(t){return t===void 0||t==="auto"?null:Un.test(t)?`#${t}`:null}var Gn={single:"solid",words:"solid",thick:"solid",double:"double",dotted:"dotted",dottedHeavy:"dotted",dash:"dashed",dashedHeavy:"dashed",dashLong:"dashed",dashLongHeavy:"dashed",dotDash:"dashed",dashDotHeavy:"dashed",dotDotDash:"dashed",dashDotDotHeavy:"dashed",wave:"wavy",wavyHeavy:"wavy",wavyDouble:"wavy"},Xn={black:"#000000",blue:"#0000ff",cyan:"#00ffff",darkBlue:"#000080",darkCyan:"#008080",darkGray:"#808080",darkGreen:"#008000",darkMagenta:"#800080",darkRed:"#800000",darkYellow:"#808000",green:"#00ff00",lightGray:"#c0c0c0",magenta:"#ff00ff",red:"#ff0000",yellow:"#ffff00",white:"#ffffff"};function Kn(t){return !t||!/^[\w \-.+]{1,64}$/.test(t)?null:`"${t}"`}function W(t,e=false){return t===void 0||!(e?Yn:ye).test(t)?null:`${Number(t)/20}pt`}function Vt(t){let e=[],n=[],o=null,s=null;for(let l of t)switch(l.localName){case "b":e.push(`font-weight:${j(l)?"bold":"normal"}`);break;case "i":e.push(`font-style:${j(l)?"italic":"normal"}`);break;case "u":{let r=B(l)??"single";if(r==="none"||!j(l))break;n.push("underline"),o=Gn[r]??"solid",s=_e(l.attributes?.color);break}case "strike":j(l)&&n.push("line-through");break;case "dstrike":j(l)&&n.push("line-through");break;case "caps":j(l)&&e.push("text-transform:uppercase");break;case "smallCaps":j(l)&&e.push("font-variant:small-caps");break;case "vertAlign":{let r=B(l);r==="superscript"?e.push("vertical-align:super","font-size:0.75em"):r==="subscript"&&e.push("vertical-align:sub","font-size:0.75em");break}case "color":{let r=_e(B(l));r&&e.push(`color:${r}`);break}case "highlight":{let r=Xn[B(l)??""];r&&e.push(`background-color:${r}`);break}case "sz":{let r=B(l);r!==void 0&&ye.test(r)&&e.push(`font-size:${Number(r)/2}pt`);break}case "rFonts":{let r=Kn(l.attributes?.ascii??l.attributes?.hAnsi);r&&e.push(`font-family:${r}`);break}case "spacing":{let r=W(B(l),true);r&&e.push(`letter-spacing:${r}`);break}}return n.length>0&&(e.push(`text-decoration-line:${[...new Set(n)].join(" ")}`),o&&e.push(`text-decoration-style:${o}`),s&&e.push(`text-decoration-color:${s}`)),e.join(";")}var Jn={left:"left",start:"left",right:"right",end:"right",center:"center",both:"justify",distribute:"justify"};function Qt(t){let e=[];for(let n of t)switch(n.localName){case "jc":{let o=Jn[B(n)??""];o&&e.push(`text-align:${o}`);break}case "ind":{let o=W(n.attributes?.left??n.attributes?.start,true),s=W(n.attributes?.right??n.attributes?.end,true),l=W(n.attributes?.firstLine),r=W(n.attributes?.hanging);o&&e.push(`margin-left:${o}`),s&&e.push(`margin-right:${s}`),l?e.push(`text-indent:${l}`):r&&e.push(`text-indent:-${r}`);break}case "spacing":{let o=W(n.attributes?.before),s=W(n.attributes?.after);o&&e.push(`margin-top:${o}`),s&&e.push(`margin-bottom:${s}`);let l=n.attributes?.line,r=n.attributes?.lineRule;l!==void 0&&ye.test(l)&&r!=="exact"&&r!=="atLeast"?e.push(`line-height:${(Number(l)/240).toFixed(3)}`):l!==void 0&&ye.test(l)&&e.push(`line-height:${Number(l)/20}pt`);break}case "shd":{let o=_e(n.attributes?.fill);o&&e.push(`background-color:${o}`);break}case "pageBreakBefore":j(n)&&e.push("break-before:page");break;}return e.join(";")}var C=new Schema({nodes:{doc:{content:"paragraph+"},paragraph:{content:"inline*",group:"block",attrs:{nodeId:{default:null},props:{default:[]}},toDOM:t=>{let e=Qt(t.attrs.props??[]);return ["p",{"data-node-id":String(t.attrs.nodeId??""),...e?{style:e}:{}},0]},parseDOM:[{tag:"p",getAttrs:t=>typeof t=="string"?null:{nodeId:t.getAttribute("data-node-id")||null,props:[]}}]},text:{group:"inline"},tab:{inline:true,group:"inline",atom:true,selectable:false,toDOM:()=>["span",{"data-token":"tab",class:"docx-tab"},"\u2192"],parseDOM:[{tag:'span[data-token="tab"]'}]},hardBreak:{inline:true,group:"inline",atom:true,selectable:false,toDOM:()=>["br"],parseDOM:[{tag:"br"}]},pageBreak:{inline:true,group:"inline",atom:true,selectable:false,toDOM:()=>["span",{"data-token":"page-break",class:"docx-page-break"}],parseDOM:[{tag:'span[data-token="page-break"]'}]},unknownInline:{inline:true,group:"inline",atom:true,selectable:false,draggable:false,attrs:{nodeId:{default:null},label:{default:""}},toDOM:t=>["span",{"data-token":"unknown","data-node-id":String(t.attrs.nodeId??""),contenteditable:"false",class:"docx-unknown-inline",title:String(t.attrs.label||"Content this editor cannot edit yet. It is preserved.")}],parseDOM:[{tag:'span[data-token="unknown"]',getAttrs:t=>typeof t=="string"?false:{nodeId:t.getAttribute("data-node-id")||null,label:""}}]}},marks:{runProps:{attrs:{props:{default:[]}},excludes:"runProps",toDOM:t=>{let e=t.attrs.props??[],n=Vt(e);return ["span",{"data-run-props":Vn(e),...n?{style:n}:{}},0]},parseDOM:[{tag:"span[data-run-props]",getAttrs:t=>{if(typeof t=="string")return false;let e=Qn(t.getAttribute("data-run-props"));return e?{props:e}:false}}]}}});function Vn(t){return JSON.stringify(Array.isArray(t)?t:[])}function Qn(t){if(!t)return null;try{let e=JSON.parse(t);if(!Array.isArray(e))return null;let n=[];for(let o of e){if(typeof o!="object"||o===null)return null;let s=o;if(typeof s.localName!="string"||s.attributes!==void 0&&(typeof s.attributes!="object"||s.attributes===null))return null;n.push(s.attributes===void 0?{localName:s.localName}:{localName:s.localName,attributes:s.attributes});}return n}catch{return null}}function Le(t){for(let e of t.marks)if(e.type.name==="runProps")return e.attrs.props??[];return []}function he(t,e){return JSON.stringify(xe(t))===JSON.stringify(xe(e))}function xe(t){return [...t].map(e=>({localName:e.localName,attributes:Object.fromEntries(Object.entries(e.attributes??{}).sort(([n],[o])=>n<o?-1:1))})).sort((e,n)=>e.localName<n.localName?-1:1)}function je(t){if(!t||t.kind==="textValue")return [];let e=[];for(let n of t.children){if(n.kind==="textValue")continue;let o={};for(let s of n.attributes)o[s.localName]=s.value;e.push(Object.keys(o).length>0?{localName:n.localName,attributes:o}:{localName:n.localName});}return e}function qt(t){return t.kind==="textValue"?"":`${{drawing:"Picture",pict:"Picture",object:"Embedded object",fldSimple:"Field",hyperlink:"Hyperlink",sdt:"Content control",tbl:"Table"}[t.localName]??t.localName} \u2014 preserved, not editable yet`}function Y(t){if(t.kind==="textValue")return [];let e=[],n=o=>{if(o.kind!=="run")return;let s=o.children.find(r=>r.kind==="runProperties"),l=je(s);for(let r of o.children)if(r.kind!=="runProperties"){if(r.kind==="tab"){e.push({kind:"tab"});continue}if(r.kind==="hardBreak"){e.push(Wb(r)?{kind:"pageBreak"}:{kind:"hardBreak"});continue}if(r.kind==="text"){let g="";for(let m of r.children)m.kind==="textValue"&&(g+=m.value);g.length>0&&e.push({kind:"text",text:g,props:l});continue}e.push({kind:"unknown",nodeId:r.id,label:qt(r)});}};return Ob(t.children,0,o=>{if(o.kind==="run"){n(o);return}e.push({kind:"unknown",nodeId:o.id,label:qt(o)});}),e}function H(t){let e=[],n=o=>{if(o.kind!=="textValue"){if(o.kind==="body"){for(let s of o.children)s.kind==="paragraph"&&e.push(s);return}for(let s of o.children)n(s);}};return n(t.root),e}var en=Pe$1(16),tn=new WeakMap;function qn(t,e){let n=tn.get(t);if(!n){let o=[];Oe$1([t],o,0),n=Object.freeze(o),tn.set(t,n);}for(let o of n)e.push(o);}function w(t){let e=en.get(t);if(e)return e;let n=[];for(let o of Ke$1(t))if(o.root.kind!=="textValue")for(let s of o.root.children)qn(s,n);return en.set(t,n),n}function U(t){let e=H(t).map(n=>{let o=n.kind==="textValue"?void 0:n.children.find(l=>l.kind==="paragraphProperties"),s=Y(n).map(l=>{switch(l.kind){case "text":return C.text(l.text,l.props.length>0?[C.marks.runProps.create({props:l.props})]:[]);case "tab":return C.node("tab");case "hardBreak":return C.node("hardBreak");case "pageBreak":return C.node("pageBreak");default:return C.node("unknownInline",{nodeId:l.nodeId,label:l.label})}});return C.node("paragraph",{nodeId:n.id,props:je(o)},s)});return C.node("doc",null,e.length>0?e:[C.node("paragraph")])}function Q(t){let e=[];return t.forEach(n=>{if(n.isText&&n.text){e.push({kind:"text",text:n.text,props:Le(n)});return}n.type.name==="tab"?e.push({kind:"tab"}):n.type.name==="hardBreak"?e.push({kind:"hardBreak"}):n.type.name==="pageBreak"?e.push({kind:"pageBreak"}):n.type.name==="unknownInline"&&e.push({kind:"unknown",nodeId:String(n.attrs.nodeId??""),label:String(n.attrs.label??"")});}),e}function D(t){let e="";for(let n of t)n.kind==="text"?e+=n.text:n.kind==="tab"?e+=" ":n.kind==="hardBreak"?e+=`
|
|
2
|
-
`:n.kind==="pageBreak"&&(e+=Ub);return e}function nn(t){let e=[],n=0;for(let o of t)o.kind==="text"?n+=o.text.length:o.kind==="tab"||o.kind==="hardBreak"||o.kind==="pageBreak"?n+=1:e.push(`${o.nodeId}@${n}`);return e}function eo(t,e){if(t===e)return null;let n=0,o=Math.min(t.length,e.length);for(;n<o&&t[n]===e[n];)n+=1;let s=t.length,l=e.length;for(;s>n&&l>n&&t[s-1]===e[l-1];)s-=1,l-=1;return {start:n,endBefore:s,endAfter:l}}function on(t){let e=[];for(let n of t)if(n.kind==="text")for(let o=0;o<n.text.length;o+=1)e.push(n.props);else (n.kind==="tab"||n.kind==="hardBreak"||n.kind==="pageBreak")&&e.push(e[e.length-1]??[]);return e}function to(t,e,n,o,s){let l=[],r=nn(e),g=nn(n);if(JSON.stringify(r)!==JSON.stringify(g))return {ok:false,reason:"unknown-content-moved",detail:t};he(o,s)||l.push({op:"setParagraphProperties",paragraphId:t,properties:xe(s)});let m=D(e),p=D(n),f=eo(m,p);if(f&&(f.endBefore>f.start&&l.push({op:"deleteText",paragraphId:t,start:f.start,end:f.endBefore}),f.endAfter>f.start)){let h=p.slice(f.start,f.endAfter),x=f.start,d="",k=()=>{d.length!==0&&(l.push({op:"insertText",paragraphId:t,offset:x,text:d}),x+=d.length,d="");};for(let P of h)P===" "?(k(),l.push({op:"insertTab",paragraphId:t,offset:x}),x+=1):P===`
|
|
3
|
-
`?(k(),l.push({op:"insertHardBreak",paragraphId:t,offset:x}),x+=1):P===Ub?(k(),l.push({op:"insertPageBreak",paragraphId:t,offset:x}),x+=1):d+=P;k();}if(!f){let h=on(e),x=on(n),d=0;for(;d<x.length;){if(he(h[d]??[],x[d])){d+=1;continue}let k=d,P=x[d];for(;d<x.length&&he(x[d],P)&&!he(h[d]??[],x[d]);)d+=1;l.push({op:"setRunProperties",paragraphId:t,start:k,end:d,properties:xe(P)});}}return {ok:true,ops:l}}function Be(t,e){let n=H(t),o=[];if(e.forEach(l=>{l.type.name==="paragraph"&&o.push(l);}),o.length!==e.childCount)return {ok:false,reason:"unsupported-node"};let s=o.length-n.length;if(s===0){let l=[];for(let[r,g]of o.entries()){let m=n[r];if(g.attrs.nodeId!==m.id)return {ok:false,reason:"paragraph-reordered",detail:String(g.attrs.nodeId)};let p=to(m.id,Y(m),Q(g),je(m.kind==="textValue"?void 0:m.children.find(f=>f.kind==="paragraphProperties")),g.attrs.props??[]);if(!p.ok)return p;l.push(...p.ops);}return {ok:true,ops:l}}return s===1?no(n,o):s===-1?oo(n,o):{ok:false,reason:"paragraph-count-unexplained",detail:String(s)}}function no(t,e){for(let n=0;n<t.length;n+=1){let o=t[n],s=e[n],l=e[n+1];if(!s||!l||s.attrs.nodeId!==o.id)continue;let r=l.attrs.nodeId;if(r!==null&&r!==o.id)continue;let g=D(Q(s));if(g+D(Q(l))===D(Y(o))&&rn(t,e,n)&&an(t,e,n+1,n+2))return {ok:true,ops:[{op:"splitParagraph",paragraphId:o.id,offset:g.length}]}}return {ok:false,reason:"split-not-clean"}}function oo(t,e){for(let n=0;n+1<t.length;n+=1){let o=t[n],s=t[n+1],l=e[n];if(!l||l.attrs.nodeId!==o.id)continue;let r=D(Y(o))+D(Y(s));if(D(Q(l))===r&&rn(t,e,n)&&an(t,e,n+2,n+1))return {ok:true,ops:[{op:"joinParagraphs",firstId:o.id,secondId:s.id}]}}return {ok:false,reason:"join-not-clean"}}function rn(t,e,n){for(let o=0;o<n;o+=1){let s=e[o],l=t[o];if(!s||s.attrs.nodeId!==l.id||D(Q(s))!==D(Y(l)))return false}return true}function an(t,e,n,o){for(let s=0;n+s<t.length;s+=1){let l=t[n+s],r=e[o+s];if(!r||r.attrs.nodeId!==l.id||D(Q(r))!==D(Y(l)))return false}return true}function ro(t,e){return va(t,e)!==null}function He(t,e,n){if(!n||n.created.length>0||n.deleted.length>0||n.splitJoin.length>0)return U(e);let o=new Map;t.forEach(m=>{let p=m.attrs.nodeId;typeof p=="string"&&o.set(p,m);});let s=new Set(n.dirty),l=H(e);if(l.length!==t.childCount)return U(e);let r=U(e),g=[];for(let[m,p]of l.entries()){let f=o.get(p.id);g.push(f&&!s.has(p.id)?f:r.child(m));}return C.node("doc",null,g)}function sn(t){return w(t).map(e=>Of(t,e.id)??"").join(`
|
|
4
|
-
`)}var ao=64,ln=new WeakMap;function $e(t,e=0){if(e>ao)return false;let n=ln.get(t);if(n!==void 0)return n;let o=false;for(let s of t.children)if(s.kind!=="textValue"&&(s.kind==="commentRangeStart"||s.kind==="commentReference"||$e(s,e+1))){o=true;break}return ln.set(t,o),o}function lo(t,e){let n=t.kind==="revision"?t.ranges[0]??null:t.range;if(!n)return null;let o=e.get(n.start.paragraphId);return o===void 0?null:o}function dn(t,e,n){for(let s of e)if(s.ranges.length===0)return false;let o=new Set;for(let s of t)s.kind!=="revision"||s.ranges.length>0||un(s,n)||o.add(wg(s));for(let s of e)if(o.has(wg(s)))return false;return true}function cn(t,e,n,o){let s=e.get(n);if(s===void 0)return [...t];let l=[],r=null;for(let g of t){if(g.kind==="revision"&&un(g,n)){r===null&&(r=l.length);continue}if(r===null){let m=lo(g,e);m!==null&&m>s&&(r=l.length);}l.push(g);}if(r===null&&(r=l.length),o.length>0){let g=o.length<2?[...o]:[...o].sort((m,p)=>zg(m,e)-zg(p,e));l.splice(r,0,...g);}return Ig(l)}function un(t,e){return t.ranges.length>0&&t.ranges.every(n=>n.start.paragraphId===e&&n.end.paragraphId===e)}function so(t,e){return t.range?t.range.start.paragraphId===e||t.range.end.paragraphId===e:false}function io(t,e){return t.revisionKind==="structural"&&t.ranges.some(n=>n.start.paragraphId===e||n.end.paragraphId===e)}function co(t,e){return t.ranges.length===0||!t.ranges.some(o=>o.start.paragraphId===e||o.end.paragraphId===e)?false:!t.ranges.every(o=>o.start.paragraphId===e&&o.end.paragraphId===e)}function pn(t,e,n,o,s,l,r){if(t.fromRevision!==e.bodyRevision||r!==e.packageRevision+1||t.story!==void 0&&t.story.kind!=="body"||t.impact!=="text-local"||t.dirty.length!==1||t.created.length>0||t.deleted.length>0||t.splitJoin.length>0||e.commentsPart!==s||e.commentsExtendedPart!==l)return null;let g=t.dirty[0],m=va(o,g);if(!m||m.kind!=="paragraph")return null;for(let p of n){if(p.kind==="comment"){if(so(p,g))return null;continue}if(p.kind==="custom"){if(p.range?.start.paragraphId===g)return null;continue}if(io(p,g)||co(p,g))return null}return g}var fn=/^[\p{L}\p{N}\p{M} \-.+_]{1,64}$/u,uo=["ascii","hAnsi","cs","eastAsia"],po=["asciiTheme","hAnsiTheme","cstheme","eastAsiaTheme"],mo=128,fo=/[\u0000-\u001F\u007F-\u009F]/;function $(t){return t.kind!=="textValue"}function G(t,e){return t.attributes.find(n=>n.localName===e)?.value}function gn(t,e){let n=new Map;for(let s of t)for(let l of s.children)if($(l))for(let[r,g]of yn(l,e))n.has(r)||n.set(r,g);let o=[...n.values()];return o.sort((s,l)=>s<l?-1:s>l?1:0),o}var ze=new WeakMap,go=16,yo=32;function yn(t,e,n=0){let o=e?.major??null,s=e?.minor??null,l=ze.get(t);if(l&&l.major===o&&l.minor===s)return l.byFold;if(t.children.length>=go&&n<yo&&t.localName!=="rFonts"){let p=new Map;for(let f of t.children)if($(f))for(let[h,x]of yn(f,e,n+1))p.has(h)||p.set(h,x);return ze.set(t,{major:o,minor:s,byFold:p}),p}let r=new Map,g=p=>{if(!p||!fn.test(p))return;let f=p.toLowerCase();r.has(f)||r.set(f,p);},m=[t];for(;m.length>0;){let p=m.pop();if($(p)){if(p.localName==="rFonts"){for(let f of uo)g(G(p,f));if(e)for(let f of po){let h=G(p,f);h!==void 0&&(h.startsWith("major")?g(e.major):h.startsWith("minor")&&g(e.minor));}}for(let f=p.children.length-1;f>=0;f-=1)m.push(p.children[f]);}}return ze.set(t,{major:o,minor:s,byFold:r}),r}function hn(t){let e=[...t];for(;e.length>0;){let n=e.pop();if($(n)){if(n.localName==="t"&&n.namespaceUri===ca){for(let o of n.children)if(!$(o)&&o.value.length>0)return true;continue}for(let o of n.children)e.push(o);}}return false}var ho=new Set(["paragraph","character","table","numbering"]),xo=/^[0-9A-Fa-f]{6}$/,ko=16,mn=new Map([["normal",0],["title",1],["subtitle",2],["heading 1",11],["heading 2",12],["heading 3",13],["heading 4",14],["heading 5",15],["heading 6",16],["heading 7",17],["heading 8",18],["heading 9",19]]);function xn(t){return t.children}function We(t,e){for(let n of xn(t))if($(n)&&n.localName===e)return n}function Po(t){return mn.get(t.name.toLowerCase())??mn.get(t.styleId.toLowerCase())??Number.MAX_SAFE_INTEGER}function Ue(t){return t===void 0||t.length===0||t.length>mo||fo.test(t)?null:t}function kn(t,e){if(!t)return [];let n=new Map;for(let l of t.children){if(!$(l)||l.localName!=="style")continue;let r=Ue(G(l,"styleId"));r!==null&&!n.has(r)&&n.set(r,l);}let o=l=>{let r=false,g=false,m=null,p=false,f=false,h=new Set,x=l;for(let P=0;P<ko&&x!==null&&!h.has(x);P+=1){h.add(x);let I=n.get(x);if(!I)break;let S=We(I,"rPr");for(let R of S?xn(S):[]){if(!$(R))continue;let T=G(R,"val"),A=T!=="0"&&T!=="false"&&T!=="off";R.localName==="b"&&!p?(r=A,p=true):R.localName==="i"&&!f?(g=A,f=true):R.localName==="color"&&m===null&&T&&xo.test(T)&&(m=T);}let v=We(I,"basedOn");x=v?Ue(G(v,"val")):null;}let d=e?.(l),k=d?.fontFamily??null;return {fontFamily:k!==null&&fn.test(k)?k:null,fontSizePt:d?.fontSizeHalfPoints!=null&&d.fontSizeHalfPoints>0?d.fontSizeHalfPoints/2:null,bold:r,italic:g,color:m}},s=[];for(let[l,r]of n){let g=G(r,"type");if(g===void 0||!ho.has(g))continue;let m=We(r,"name"),p=Ue(m?G(m,"val"):void 0);s.push({styleId:l,name:p??l,type:g,preview:o(l)});}return s.map((l,r)=>({entry:l,index:r,rank:Po(l)})).sort((l,r)=>l.rank-r.rank||l.index-r.index).map(l=>l.entry)}var bo=128,Oo=/[\u0000-\u001F\u007F-\u009F]/,So=/[\u0000-\u001F\u007F-\u009F]/g,vo=200,Ro=/^heading ([1-9])$/i;function Ye(t){return t.kind!=="textValue"}function ie(t,e){for(let n of t.children)if(Ye(n)&&n.localName===e)return n}function se(t,e){return t.attributes.find(n=>n.localName===e)?.value}function Io(t){let e=new Map;if(!t)return e;for(let n of t.children){if(!Ye(n)||n.localName!=="style"||se(n,"type")!=="paragraph")continue;let o=se(n,"styleId");if(o===void 0||o.length===0||o.length>bo||Oo.test(o))continue;let s=ie(n,"name"),l=s?se(s,"val"):void 0,r=l!==void 0?Ro.exec(l):null;if(r){e.set(o,Number(r[1])-1);continue}let g=ie(n,"pPr"),m=g?ie(g,"outlineLvl"):void 0,p=m?se(m,"val"):void 0;p!==void 0&&/^[0-8]$/.test(p)&&e.set(o,Number(p));}return e}function Ge(t){let e=ie(t,"pPr"),n=e?ie(e,"pStyle"):void 0;return n?se(n,"val"):void 0}function Pn(t,e){let n=Io(e);if(n.size===0)return [];let o=[];for(let s of H(t)){if(!Ye(s))continue;let l=Ge(s);if(l===void 0)continue;let r=n.get(l);if(r===void 0)continue;let m=(Of(t,s.id)??"").replace(So," ").trim().slice(0,vo);m.length!==0&&o.push({text:m,level:r,blockId:s.id});}return o}var ke=48,To=/[\u0000-\u001F\u007F-\u009F]/g;function bn(t){return t.kind!=="textValue"}function Pe(t){if(t.kind==="textValue")return t.value.length;if(t.kind==="tab"||t.kind==="hardBreak")return 1;if(t.kind==="runProperties"||t.kind==="generic")return 0;if(t.kind==="hyperlink"||Hb(t)){let n=0,o=t.kind==="hyperlink"?t.children:Jb(t)??[];for(let s of o)n+=Pe(s);return n}let e=0;for(let n of t.children)e+=Pe(n);return e}function No(t){let e=[],n=0;return bn(t)&&Ob(t.children,0,o=>{if(o.kind==="run"){e.push(n),n+=Pe(o);return}n+=Pe(o);}),e}function Eo(t,e){if(t.length===0)return {index:0,offset:e};for(let n=t.length-1;n>=0;n-=1){let o=t[n];if(e>=o)return {index:n,offset:e-o}}return {index:0,offset:e}}function Xe(t,e){return t.replace(To," ").slice(0,e)}function On(t,e,n={}){let o={matches:[],truncated:false};if(!Pg(e))return o;let s=n.limit!==void 0&&Number.isInteger(n.limit)&&n.limit>0?Math.min(n.limit,2e3):2e3,l={...n.matchCase===void 0?{}:{matchCase:n.matchCase},...n.wholeWord===void 0?{}:{wholeWord:n.wholeWord}},r=[],g=0;for(let m of H(t)){if(!bn(m))continue;let p=g;g+=1;let f=Of(t,m.id)??"";if(f.length===0)continue;let h=Qg(f,e,s-r.length,l),x=null;for(let d of h.matches){let k=d.start+d.length;x??=No(m);let P=Eo(x,d.start);r.push({blockId:m.id,start:d.start,length:d.length,paragraphIndex:p,runIndex:P.index,runOffset:P.offset,text:Xe(f.slice(d.start,k),256),contextBefore:Xe(f.slice(Math.max(0,d.start-ke),d.start),ke),contextAfter:Xe(f.slice(k,k+ke),ke)});}if(h.truncated)return {matches:r,truncated:true}}return {matches:r,truncated:false}}var Co=["lt1","dk1","lt2","dk2","accent1","accent2","accent3","accent4","accent5","accent6"],Do=/^[0-9A-Fa-f]{6}$/,Sn={windowText:"000000",window:"FFFFFF"};function Rn(t){return t.kind!=="textValue"}function be(t,e){return t.attributes.find(n=>n.localName===e)?.value}function In(t,e){let n=[t];for(;n.length>0;){let o=n.pop();if(Rn(o)){if(o.localName===e)return o;for(let s=o.children.length-1;s>=0;s-=1)n.push(o.children[s]);}}return null}function Oe(t,e){for(let n of t.children)if(Rn(n)&&(e===void 0||n.localName===e))return n;return null}function Mo(t){let e=Oe(t);if(!e)return null;let n;if(e.localName==="srgbClr")n=be(e,"val");else if(e.localName==="sysClr"){let o=be(e,"val")??"";n=be(e,"lastClr")??(Object.prototype.hasOwnProperty.call(Sn,o)?Sn[o]:void 0);}return n===void 0||!Do.test(n)?null:n.toUpperCase()}var wo=/^[\p{L}\p{N}\p{M} \-.+_]{1,64}$/u;function vn(t,e){let n=Oe(t,e),o=n?Oe(n,"latin"):null,s=o?be(o,"typeface"):void 0;return s!==void 0&&wo.test(s)?s:null}function de(t){if(!t)return {major:null,minor:null};let e=In(t,"fontScheme");return e?{major:vn(e,"majorFont"),minor:vn(e,"minorFont")}:{major:null,minor:null}}function Tn(t){if(!t)return [];let e=In(t,"clrScheme");if(!e)return [];let n=[];for(let o of Co){let s=Oe(e,o),l=s?Mo(s):null;if(l===null)return [];n.push({slot:o,hex:l});}return n}var Ao=/^[\p{L}\p{N}\p{M} \-.+_]{1,64}$/u;var Fo=/[\u0000-\u001F\u007F-\u009F]/;function Cn(t){return t.kind!=="textValue"}function X(t,e){for(let n of t.children)if(Cn(n)&&n.localName===e)return n}function K(t,e){return t.attributes.find(n=>n.localName===e)?.value}function Nn(t){return t===void 0||t.length===0||t.length>128||Fo.test(t)?null:t}function Se(t,e){return t==="minorAscii"||t==="minorHAnsi"?e.minor:t==="majorAscii"||t==="majorHAnsi"?e.major:null}function _o(t,e){let n=Se(K(t,"asciiTheme"),e)??Se(K(t,"hAnsiTheme"),e);if(n!==null)return n;let o=K(t,"ascii")??K(t,"hAnsi");return o===void 0?null:Ao.test(o)?o:null}function En(t,e){if(!t)return {fontFamily:null,fontSizeHalfPoints:null};let n=X(t,"rFonts"),o=X(t,"sz"),s=o?K(o,"val"):void 0,l=s!==void 0&&/^\d{1,4}$/.test(s)?Number(s):null;return {fontFamily:n?_o(n,e):null,fontSizeHalfPoints:l!==null&&l>=2&&l<=3276?l:null}}function Ke(t,e){let n=new Map,o={fontFamily:null,fontSizeHalfPoints:null};if(t){let r=X(t,"docDefaults"),g=r?X(r,"rPrDefault"):void 0;o=En(g?X(g,"rPr"):void 0,e);for(let m of t.children){if(!Cn(m)||m.localName!=="style")continue;let p=Nn(K(m,"styleId"));if(p===null||n.has(p))continue;let f=X(m,"basedOn");n.set(p,{basedOn:Nn(f?K(f,"val"):void 0),own:En(X(m,"rPr"),e)});}}let s=new Map,l=r=>{let g=r??"",m=s.get(g);if(m)return m;let p=null,f=null,h=new Set,x=r;for(let k=0;x!==null&&k<16&&!h.has(x);k+=1){h.add(x);let P=n.get(x);if(!P)break;p??=P.own.fontFamily,f??=P.own.fontSizeHalfPoints,x=P.basedOn;}let d={fontFamily:p??o.fontFamily,fontSizeHalfPoints:f??o.fontSizeHalfPoints};return s.set(g,d),d};return (r,g)=>{let m=l(r),p=g?.find(h=>h.localName==="rFonts"),f=p?Se(p.attributes?.asciiTheme,e)??Se(p.attributes?.hAnsiTheme,e):null;return f===null?m:{...m,fontFamily:f}}}var Dn=new WeakMap;function Ze(t){let e=Dn.get(t);if(e!==void 0)return e;let n=Qc(t),o=n===null||!Pc(n)?null:n;return Dn.set(t,o),o}var Je=class{#e;#t;constructor(e,n){this.#e=e,this.#t=n;}get size(){return this.#e.size}get(e){if(this.#e.has(e))return this.#t.find(n=>e.startsWith(`${n.name}#`))}has(e){return this.get(e)!==void 0}*entries(){for(let e of this.#e.keys()){let n=this.get(e);n&&(yield [e,n]);}}keys(){return this.#e.keys()}*values(){for(let[,e]of this.entries())yield e;}[Symbol.iterator](){return this.entries()}forEach(e,n){for(let[o,s]of this.entries())e.call(n,s,o,this);}};function Mn(t,e){return Object.freeze({...t,partByNode:new Je(t.ordinalByNode,e)})}function wn(t){let e=new Map,n=new Map,o=new Map,s=new Set,l=new Map,r=new Map,g=0;for(let m of t)for(let p of w(m)){o.set(p.id,g),l.set(p.id,m),g+=1;let f=Ze(p);if(f===null)continue;e.set(p.id,f);let h=f.toUpperCase(),x=r.get(h);x?(x.push(p.id),s.add(h)):(r.set(h,[p.id]),n.set(h,p.id));}return Object.freeze({paraIdByNode:e,nodeByParaId:n,ordinalByNode:o,ambiguousParaIds:s,partByNode:l,claimantsByParaId:r})}function An(t,e){let n=t.indexOf("#");if(n<=0)return null;let o=t.slice(0,n),s=e.body.name===o?e.body:void 0;s??=e.openStories.find(g=>g.name===o);let l=s?void 0:e.otherStories.find(g=>g.name===o);if(s??=l?e.normalize(l):void 0,!s)return null;let r=va(s,t);return r?.kind==="paragraph"?Ze(r):null}var Lo=Object.freeze([]);function jo(t,e={}){let n=ob(t);if(!n.ok)return {ok:false,reason:n.reason,...n.detail?{detail:n.detail}:{}};let o=n.package,s=o.parts.get(o.mainDocumentPart);if(!s)return {ok:false,reason:"no-main-document-tree",detail:o.mainDocumentPart};let l=Wc(s),r=new Rf(o,l),g=null,m=null,p=null,f=null;r.subscribe(a=>{f=a;});let h=()=>r.bodyStore(),x=()=>r.currentPackage(),d=Object.freeze({kind:"body"}),k=(a,i)=>{let c=r.currentPackage(),u=a.checkpoint();a.graftPackage(()=>r.currentPackage());let y=i();return y.ok&&(a.restoreHistoryStacks(u),r.replacePackageShell(a.package),r.adoptPackageUnit(c),r.publishStoryWrite(y.change)),y},P=()=>{if(g&&f&&g.packageRevision===f.fromRevision&&r.packageRevision===f.toRevision&&f.story?.kind==="body"&&f.impact==="text-local"&&f.created.length===0&&f.deleted.length===0&&f.splitJoin.length===0&&(g={...g,packageRevision:r.packageRevision}),!g||g.packageRevision!==r.packageRevision){let a=Rb(x());g={packageRevision:r.packageRevision,resolution:a,parts:Qb(a)};}return g},I="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",S$1="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",v=null,R$1=()=>{let a=x(),i=(a.relationships.get(a.mainDocumentPart)??[]).find(y=>y.type===I),c;if(i){let y=E(i);y.mode==="Internal"&&y.target.ok&&(c=a.parts.get(y.target.partName));}c??=a.parts.get("/word/styles.xml");let u=c?.root??null;return u!==v&&(v=u,Te=null,oe=null),v},T=false,A=null,ve=()=>{if(T)return A;T=true;let a=x(),i=(a.relationships.get(a.mainDocumentPart)??[]).find(u=>u.type===S$1),c;if(i){let u=E(i);u.mode==="Internal"&&u.target.ok&&(c=a.parts.get(u.target.partName));}return c??=a.parts.get("/word/numbering.xml"),A=c?.root??null,A},ce="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",J=-1,q=null,Ve=()=>{if(J===r.packageRevision)return q;J=r.packageRevision;let a=x(),i=(a.relationships.get(a.mainDocumentPart)??[]).find(u=>u.type===ce),c;if(i){let u=E(i);u.mode==="Internal"&&u.target.ok&&(c=a.parts.get(u.target.partName));}return c??=a.parts.get("/word/settings.xml"),q=c?.root??null,q},_n="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",Ln="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",Qe=(a,i)=>{let c=x(),u=(c.relationships.get("/")??[]).find(b=>b.type===a),y;if(u){let b=E(u);b.mode==="Internal"&&b.target.ok&&(y=c.parts.get(b.target.partName));}return y??c.parts.get(i)},qe=-1,Re=R,jn=()=>{if(qe===r.packageRevision)return Re;qe=r.packageRevision;let a=Qe(_n,"/docProps/core.xml"),i=Qe(Ln,"/docProps/app.xml");return Re=S(a?.root??null,i?.root??null),Re},Bn="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",et=false,Ie=null,ee=()=>{if(et)return Ie;et=true;let a=x(),i=(a.relationships.get(a.mainDocumentPart)??[]).find(u=>u.type===Bn),c;if(i){let u=E(i);u.mode==="Internal"&&u.target.ok&&(c=a.parts.get(u.target.partName));}return c??=a.parts.get("/word/theme/theme1.xml"),Ie=c?.root??null,Ie},Hn="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable",ue=null,$n=()=>{if(ue)return ue;let a=x(),i=(a.relationships.get(a.mainDocumentPart)??[]).find(u=>u.type===Hn),c;if(i){let u=E(i);u.mode==="Internal"&&u.target.ok&&(c=a.parts.get(u.target.partName));}return c??=a.parts.get("/word/fontTable.xml"),ue=Object.freeze(G$1(a,c)),ue},te=null,ne=null,Te=null,tt=null,nt=null,ot=()=>{let a=[h().part.root],i=R$1();i&&a.push(i);let c=new Set;for(let u of _())c.has(u)||(c.add(u),a.push(u.root));return a},oe=null,pe=null,re=null,ae=null,Z=null,rt=new WeakMap,me=null,at=a=>{let i=rt.get(a);if(i)return i;let c=Wc(a);return rt.set(a,c),c},lt=()=>{let a=r.packageRevision,i=r.openStoryToken();if(!Z||Z.revision!==a||Z.openStories!==i){let c=r.openStoryParts(),u=new Set(c.map(E=>E.name)),y=_().filter(E=>!u.has(E.name)).map(at),b=[h().part,...c,...y],O=Z,N=O!==null&&f!==null&&O.openStories===i&&O.revision===f.fromRevision&&a===f.toRevision&&f.impact==="text-local"&&f.created.length===0&&f.deleted.length===0&&f.splitJoin.length===0&&O.parts.length===b.length&&O.parts.every((E,M)=>E.name===b[M]?.name);Z={revision:a,openStories:i,parts:b,index:N&&O?Mn(O.index,b):wn(b)};}return Z.index},st=()=>{let a=h().part.name,i=new Map;for(let c of [h().part,..._()])for(let[u,y]of eg(x(),c.name,a))i.set(u,y);return i},zn=()=>[h().part,..._()],_=()=>{let a=[],i=new Set;for(let u of P().parts)for(let y of [u.headers,u.footers])for(let b of y.values())i.has(b)||(i.add(b),a.push(b));let c=x();for(let u of ["footnote","endnote"]){let y=_d(c,u);!y||i.has(y)||(i.add(y),a.push(y));}return a};return {ok:true,session:{editable:w(h().part).length>0,paragraphIds:()=>w(h().part).map(a=>a.id),paragraphIdsIn(a=d){let i=r.partFor(a);return i?w(i).map(c=>c.id):[]},part:()=>h().part,partFor:a=>r.partFor(a),currentPackage:x,applyTreeOps(a,i,c,u=d){if(a.length===0)return {committed:false,rejected:false,opCount:0};let y=a.filter(O=>_c(O)||je$1(O)).length;if(y>0){if(y!==a.length||a.length!==1)return {committed:false,rejected:true,opCount:a.length,reason:"invalidArgs"};let O=r.applyLifecycleOp(a[0]);return O.ok?{committed:true,rejected:false,opCount:1}:{committed:false,rejected:true,opCount:1,reason:O.detail??O.reason}}let b=r.transact(u,O=>{i!==void 0&&O.selectionBefore(i),c!==void 0&&O.selectionAfter(c);for(let N of a)O.apply(N);});return b.ok?{committed:true,rejected:false,opCount:a.length}:{committed:false,rejected:true,opCount:a.length,reason:b.reason}},projectDoc:()=>U(h().part),reconcile:a=>He(a,h().part,f),lastCommitWasStructural:()=>f!==null&&(f.created.length>0||f.deleted.length>0||f.splitJoin.length>0||f.impact==="global"),applyPmDoc(a){let i=h(),c=Be(i.part,a);if(!c.ok)return {committed:false,rejected:true,opCount:0,reason:c.reason};if(c.ops.length===0)return {committed:false,rejected:false,opCount:0};let u=r.transact(d,y=>{for(let b of c.ops)y.apply(b);});return u.ok?{committed:true,rejected:false,opCount:c.ops.length}:{committed:false,rejected:true,opCount:c.ops.length,reason:u.reason}},storyParts:zn,bodyText:()=>sn(h().part),storyText(a){let i=r.partFor(a);return i?w(i).map(c=>Of(i,c.id)??"").join(`
|
|
5
|
-
`):null},revision:()=>h().revision,revisionFor:a=>r.revisionFor(a),packageRevision:()=>r.packageRevision,canUndo:()=>r.canUndo,canRedo:()=>r.canRedo,undo:()=>{let a=r.selectionForUndo();return r.undo()===null?null:a},redo:()=>{let a=r.selectionForRedo();return r.redo()===null?null:a},beginComposition:(a=d)=>{r.beginComposition(a);},endComposition:()=>r.endComposition(),subscribe(a){return r.subscribe(a)},save(){return pb(x())},headerFooterParts:()=>{let a=P().parts;return a[a.length-1]??Tb(x())},headerFooterPartsBySection:()=>P().parts,headerFooterResolutionBySection:()=>P().resolution,documentFonts(){return te&&te.revision===r.packageRevision||(te={revision:r.packageRevision,fonts:gn(ot(),de(ee()))}),te.fonts},rendersText(){return ne&&ne.revision===r.packageRevision||(ne={revision:r.packageRevision,rendersText:hn(ot())}),ne.rendersText},documentStyles(){oe??=Ke(R$1(),de(ee()));let a=oe;return Te??=kn(R$1(),i=>a(i)),Te},stylesRoot:()=>R$1(),documentThemeFonts(){return nt??=de(ee()),nt},numberingRoot:()=>ve(),settingsRoot:()=>Ve(),documentProperties:()=>jn(),trackingSettings:()=>O(Ve()),documentThemeColors(){return tt??=Tn(ee()),tt},effectiveRunDefaults(a,i){oe??=Ke(R$1(),de(ee()));let c=h();if(!pe||pe.revision!==c.revision){let u=new Map;for(let y of w(c.part))y.kind!=="textValue"&&u.set(y.id,Ge(y)??null);pe={revision:c.revision,byId:u};}return oe(pe.byId.get(a)??null,i)},documentOutline(){let a=h();return re&&re.revision===a.revision||(re={revision:a.revision,outline:Pn(a.part,R$1())}),re.outline},findText(a,i){let c=h(),u=`${i?.matchCase===true?"c":""}${i?.wholeWord===true?"w":""}${i?.limit??""}\0${a}`;if(ae&&ae.revision===c.revision&&ae.key===u)return ae.result;let y=On(c.part,a,i??{});return ae={revision:c.revision,key:u,result:y},y},embeddedFonts:$n,paragraphAnchors:lt,paraIdOf:a=>An(a,{body:h().part,openStories:r.openStoryParts(),otherStories:_(),normalize:at}),nodeIdOf:a=>lt().nodeByParaId.get(a.toUpperCase())??null,relationshipTarget:(a,i=d)=>{let c=x(),u=r.partFor(i);return u?Zc(c,u.name,a):null},bookmarks:()=>{let a=r.packageRevision;if(!me||me.revision!==a){let i=new Map(zc(h().part));for(let c of _())for(let[u,y]of zc(c))i.has(u)||i.set(u,y);me={revision:a,index:i};}return me.index},ensureHyperlinkRelationship(a,i=d){let c=r.partFor(i);if(!c)return null;let u=x(),y=Yc(u,a,c.name);return y?(y.pkg!==u&&r.replacePackageShell(y.pkg),y.relationshipId):null},reviewItems(){let a=e.reviewModel;if(!a)return Lo;let i=h(),c=`${r.packageRevision}:${i.revision}`;if(m&&m.revisionKey===c)return m.items;let u=x(),y=u.parts.get(Zf(u,i.part.name)),b=u.parts.get(_f(u,i.part.name)),O=_(),N=m&&f?pn(f,m,m.items,i.part,y,b,r.packageRevision):null,E,M;if(N&&m){let F=a.revisionItemsOfParagraph(i.part,N);dn(m.items,F,N)?(E=cn(m.items,m.paragraphOrder,N,F),M=m.paragraphOrder):(M=Jg(i.part),E=a.collectReviewItems({storyPart:i.part,furnitureParts:O,commentsPart:y,commentsExtendedPart:b,customNodePayloads:st()}));}else M=Jg(i.part),E=a.collectReviewItems({storyPart:i.part,furnitureParts:O,commentsPart:y,commentsExtendedPart:b,customNodePayloads:st()});return m={revisionKey:c,bodyRevision:i.revision,packageRevision:r.packageRevision,items:E,paragraphOrder:M,commentsPart:y,commentsExtendedPart:b},m.items},hasReviewContent(){let a=r.packageRevision;if(!p||p.revision!==a){let i=[h().part,..._()];p={revision:a,present:i.some(c=>sf(c).length>0||$e(c.root))};}return p.present},replyToComment(a,i,c,u,y,b=d){let O=b.kind==="body"?null:r.resolveStory(b),N=O?.ok?O.store:h(),E=r.currentPackage(),M=N.checkpoint();N.graftPackage(()=>r.currentPackage());let F=Wf(N,{anchor:{paragraphId:i.paragraphId,start:i.start,end:i.end,...i.endParagraphId===void 0?{}:{endParagraphId:i.endParagraphId}},author:u,text:c,...y===void 0?{}:{date:y},...a===null?{}:{replyToCommentId:a}});return F.ok?(N.restoreHistoryStacks(M),r.replacePackageShell(N.package),r.adoptPackageUnit(E),r.publishStoryWrite(F.change),F.commentId):null},setCommentResolved(a,i){let c=h(),u=r.currentPackage(),y=c.checkpoint();c.graftPackage(()=>r.currentPackage());let b=Xf(c,a,i);return b.ok?(b.changed&&(c.restoreHistoryStacks(y),r.replacePackageShell(c.package),r.adoptPackageUnit(u),r.publishStoryWrite(b.change)),true):false},deleteComment(a,i=d,c){return this.deleteComments([{commentId:a}],i,c)},deleteComments(a,i=d,c){if(a.length===0)return false;let u=i.kind==="body"?h().part:r.partFor(i);if(!u)return false;let y={storyPartName:u.name,...c===void 0?{}:{noteId:c}},b=h(),O=r.currentPackage(),N=b.checkpoint();b.graftPackage(()=>r.currentPackage());let E=false,M=false,F=b.transact(Wn=>{Wn.applyPackage(it=>{let le=it;for(let fe of a){let Ne=fe.parentCommentId===void 0?We$1(le,fe.commentId,y):Xe$1(le,fe.commentId,fe.parentCommentId,y);if(Ne===null)return E=true,it;M||=Ne!==le,le=Ne;}return le});});return E||!F.ok||!M?false:(b.restoreHistoryStacks(N),r.installPackageSnapshot(b.package),r.adoptPackageUnit(O),r.publishStoryWrite(F.change),true)},insertCustomNode(a,i=d){let c=i.kind==="body"?null:r.resolveStory(i),u=c?.ok?c.store:h();return k(u,()=>bg(u,a,h().part.name))},removeCustomNode(a,i=d){let c=i.kind==="body"?null:r.resolveStory(i),u=c?.ok?c.store:h();return k(u,()=>cg(u,a))},sweepCustomNodePayloads(a){let i=h(),c=dg(r.currentPackage(),i.part.name,a);return c.ok?c.removed.length===0?{ok:true,removed:[]}:(r.replacePackageShell(c.pkg),{ok:true,removed:c.removed}):{ok:false,reason:c.reason}},ensureListDefinition(a){let i=L(x(),a);return i?(r.replacePackageShell(i.pkg),T=false,A=null,i.numId):null},ensureNumberingLevel(a,i,c){let u=x(),y=M(u,a,i,c);return y?(y!==u&&(r.replacePackageShell(y),T=false,A=null),true):false},insertImage(a,i){return r.insertImage(a,i)},replaceImage(a,i,c,u,y,b){return r.replaceImage(a,i,c,u,y,b)},deleteImage(a,i){return r.deleteImage(a,i)},applyImageProperties(a,i){return r.applyImageProperties(a,i)}}}}var Bo=b.projection;function Zo(t,e,n){let o=t.filter(s=>s.localName!==e);return o.length!==t.length?o:[...o,n?{localName:e,attributes:n}:{localName:e}]}function Vo(t,e,n={}){let o=null,s=false,l=()=>n.onChange?.(r()),r=()=>({revision:e.revision(),canUndo:e.canUndo(),canRedo:e.canRedo(),lastRejection:o}),g=d=>{s=true;let k=p.state.tr.replaceWith(0,p.state.doc.content.size,d.content);k.setMeta("addToHistory",false),p.dispatch(k),s=false;},m=d=>()=>(d()&&(g(e.projectDoc()),l()),true),p=new EditorView(t,{state:EditorState.create({doc:e.projectDoc(),plugins:[keymap({...baseKeymap,Home:selectTextblockStart,End:selectTextblockEnd,"Mod-z":m(()=>e.undo()!==null),"Mod-y":m(()=>e.redo()!==null),"Shift-Mod-z":m(()=>e.redo()!==null),"Mod-b":(d,k)=>x(d,k,"b"),"Mod-i":(d,k)=>x(d,k,"i"),"Mod-u":(d,k)=>x(d,k,"u",{val:"single"})})]}),editable:()=>e.editable,handleDOMEvents:{keydown:d=>(f(d),false),beforeinput:(d,k)=>{let P=k;if(d.composing)return false;f(d);let I=P.inputType;if(I==="insertText"&&P.data!=null){P.preventDefault();let{from:S,to:v}=d.state.selection;return d.dispatch(d.state.tr.insertText(P.data,S,v)),true}if(I==="deleteContentBackward"){P.preventDefault();let{from:S,empty:v}=d.state.selection;return v?S>0?d.dispatch(d.state.tr.delete(S-1,S)):joinBackward(d.state,d.dispatch):deleteSelection(d.state,d.dispatch),true}if(I==="deleteContentForward"){P.preventDefault();let{from:S,to:v,empty:R}=d.state.selection;return R?v<d.state.doc.content.size?d.dispatch(d.state.tr.delete(S,S+1)):joinForward(d.state,d.dispatch):deleteSelection(d.state,d.dispatch),true}return I==="insertParagraph"?(P.preventDefault(),splitBlock(d.state,d.dispatch),true):false},compositionstart:()=>(e.beginComposition(),false),compositionend:()=>(e.endComposition(),l(),false)},dispatchTransaction(d){let k=p.state.apply(d);if(s||!d.docChanged){p.updateState(k);return}let P=e.applyPmDoc(k.doc);if(P.rejected){o=String(P.reason??"rejected"),p.updateState(k),g(e.projectDoc()),l();return}o=null,p.updateState(P.committed&&e.lastCommitWasStructural()?h(k):k),l();}});function f(d){if(d.composing||s)return;let k=d.dom.ownerDocument.getSelection(),P=k?.anchorNode,I=k?.focusNode;if(!(!k||!P||!I)&&!(!d.dom.contains(P)||!d.dom.contains(I)))try{let S=d.posAtDOM(P,k.anchorOffset),v=d.posAtDOM(I,k.focusOffset),R=d.state.selection;if(R.anchor===S&&R.head===v)return;let T=TextSelection.create(d.state.doc,S,v);d.dispatch(d.state.tr.setSelection(T).setMeta("addToHistory",!1));}catch{}}function h(d){let k=e.paragraphIds(),P=d.tr,I=false,S=0;return d.doc.forEach((v,R)=>{let T=k[S];S+=1,!(v.type.name!=="paragraph"||T===void 0)&&v.attrs.nodeId!==T&&(P=P.setNodeMarkup(R,void 0,{...v.attrs,nodeId:T}),I=true);}),I?d.apply(P.setMeta("addToHistory",false)):d}function x(d,k,P,I){let S=C.marks.runProps;if(!k)return true;let{from:v,to:R,empty:T}=d.selection;if(T)return true;let ve=d.doc.resolve(v).marks().find(q=>q.type===S)?.attrs.props??[],ce=Zo(ve,P,I),J=d.tr;return J.removeMark(v,R,S),ce.length>0&&J.addMark(v,R,S.create({props:ce})),k(J),true}return {view:p,state:r,undo:()=>m(()=>e.undo()!==null)(),redo:()=>m(()=>e.redo()!==null)(),toggleRunProperty(d,k){x(p.state,p.dispatch.bind(p),d,k);},destroy:()=>p.destroy()}}export{C as a,Le as b,H as c,w as d,U as e,Be as f,ro as g,He as h,Ge as i,jo as j,Bo as k,Vo as l};
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { D as DrawingProjection } from './tree-op-types-CnRb7AYo.js';
|
|
2
|
-
import { c as OoxmlPackage } from './ooxml-package-CdEy9ufK.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* The engine's trust-boundary caps: recursion depth, element counts, and the rest.
|
|
6
|
-
*
|
|
7
|
-
* A caller may LOWER any of these but never raise or disable one — an override of `Infinity`,
|
|
8
|
-
* zero, a negative or `NaN` clamps into `(0, ceiling]` rather than turning the limit off. These
|
|
9
|
-
* are security ceilings, not performance budgets.
|
|
10
|
-
*/
|
|
11
|
-
interface ResourceLimits {
|
|
12
|
-
/** Max nested-structure recursion (tables/shapes/SDT/groups). */
|
|
13
|
-
readonly maxRecursionDepth: number;
|
|
14
|
-
/** Max total parsed element count. */
|
|
15
|
-
readonly maxElementCount: number;
|
|
16
|
-
/** Max package part count. */
|
|
17
|
-
readonly maxPartCount: number;
|
|
18
|
-
/** Max total decompressed bytes (zip-bomb guard). */
|
|
19
|
-
readonly maxDecompressedBytes: number;
|
|
20
|
-
/** Max total compressed input bytes. */
|
|
21
|
-
readonly maxCompressedBytes: number;
|
|
22
|
-
/** Max decompressed:compressed ratio per entry. */
|
|
23
|
-
readonly maxCompressionRatio: number;
|
|
24
|
-
/** In-memory chunk budget for streaming/spooling. */
|
|
25
|
-
readonly maxChunkBytes: number;
|
|
26
|
-
/** Max pagination passes before non-convergence is declared. */
|
|
27
|
-
readonly maxPaginationPasses: number;
|
|
28
|
-
/** Max queued items in any bounded work queue. */
|
|
29
|
-
readonly maxQueueDepth: number;
|
|
30
|
-
}
|
|
31
|
-
/** Non-disableable hard ceilings: no resolved limit may exceed these. */
|
|
32
|
-
declare const HARD_CEILINGS: ResourceLimits;
|
|
33
|
-
/** Finite defaults, all <= their hard ceiling. */
|
|
34
|
-
declare const DEFAULT_LIMITS: ResourceLimits;
|
|
35
|
-
/**
|
|
36
|
-
* Resolve caller overrides into a frozen, always-finite limit set. Each value is
|
|
37
|
-
* `min(override>0 ? override : default, ceiling)`. Infinity/0/negative/NaN can
|
|
38
|
-
* never disable a limit — the hard ceiling always wins.
|
|
39
|
-
*/
|
|
40
|
-
declare function resolveLimits(overrides?: Partial<ResourceLimits>): ResourceLimits;
|
|
41
|
-
/** Bounded image decode limits (typed-drawings-and-images task 4). */
|
|
42
|
-
/** Trust-boundary caps specific to image decoding and embedding. */
|
|
43
|
-
interface ImageResourceLimits {
|
|
44
|
-
readonly maxEncodedBytes: number;
|
|
45
|
-
readonly maxDecodedBytes: number;
|
|
46
|
-
readonly maxPixels: number;
|
|
47
|
-
readonly maxDimension: number;
|
|
48
|
-
readonly maxPolygonPoints: number;
|
|
49
|
-
readonly maxExternalRedirects: number;
|
|
50
|
-
}
|
|
51
|
-
/** Image caps nothing can raise past. A caller's override clamps into these. */
|
|
52
|
-
declare const IMAGE_RESOURCE_HARD_CEILINGS: ImageResourceLimits;
|
|
53
|
-
/** The image caps in force when a host configures none. Conservative and finite. */
|
|
54
|
-
declare const DEFAULT_IMAGE_RESOURCE_LIMITS: ImageResourceLimits;
|
|
55
|
-
/** Resolve caller overrides into frozen image limits; hard ceilings cannot be raised. */
|
|
56
|
-
declare function resolveImageResourceLimits(overrides?: Partial<ImageResourceLimits>): ImageResourceLimits;
|
|
57
|
-
|
|
58
|
-
/** Opaque handle — bytes are reachable only through {@link mintValidatedImageBytes}. */
|
|
59
|
-
interface ValidatedImageBytesHandle {
|
|
60
|
-
readonly registryId: number;
|
|
61
|
-
readonly resourceKey: string;
|
|
62
|
-
readonly contentId: string;
|
|
63
|
-
readonly generation: number;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Raster media the decode port measures and any authoring path may write.
|
|
68
|
-
*
|
|
69
|
-
* BMP and WebP are here for the same reason the other three are: an `<img>` decodes them
|
|
70
|
-
* natively, so they need a signature and a structural header and nothing else. BMP is what
|
|
71
|
-
* older documents carry; WebP is what current Word writes.
|
|
72
|
-
*/
|
|
73
|
-
type SupportedImageMime = 'image/png' | 'image/jpeg' | 'image/gif' | 'image/bmp' | 'image/webp';
|
|
74
|
-
/**
|
|
75
|
-
* Vector media painted straight from validated bytes. An `<img>` renders SVG in the
|
|
76
|
-
* browser's secure static mode — no script, no external subresource loads — so there is
|
|
77
|
-
* no decode step and no raster buffer sized by a file-supplied number.
|
|
78
|
-
*/
|
|
79
|
-
type VectorImageMime = 'image/svg+xml';
|
|
80
|
-
/** Every mime the painter can hand to an `<img>`. */
|
|
81
|
-
type RenderableImageMime = SupportedImageMime | VectorImageMime;
|
|
82
|
-
/**
|
|
83
|
-
* Media kept in the package byte-for-byte that the painter cannot hand to an `<img>`.
|
|
84
|
-
* A decode port may rasterize it; without one it paints as a labelled placeholder.
|
|
85
|
-
*/
|
|
86
|
-
type PreservedImageMime = 'image/tiff' | 'image/x-emf' | 'image/x-wmf';
|
|
87
|
-
/**
|
|
88
|
-
* What is known about one embedded image: validated, refused, or still decoding.
|
|
89
|
-
*
|
|
90
|
-
* Content type is a CLAIM. Signature sniffing, structural header validation and the decode port
|
|
91
|
-
* are authoritative, and bytes that fail them never enter public state.
|
|
92
|
-
*/
|
|
93
|
-
type ImageResourceState = {
|
|
94
|
-
readonly kind: 'ready';
|
|
95
|
-
readonly partName: string;
|
|
96
|
-
readonly contentId: string;
|
|
97
|
-
readonly resourceKey: string;
|
|
98
|
-
readonly validatedHandle: ValidatedImageBytesHandle;
|
|
99
|
-
readonly mime: RenderableImageMime;
|
|
100
|
-
readonly pixelWidth: number;
|
|
101
|
-
readonly pixelHeight: number;
|
|
102
|
-
readonly dpiX: number;
|
|
103
|
-
readonly dpiY: number;
|
|
104
|
-
} | {
|
|
105
|
-
readonly kind: 'unrenderable';
|
|
106
|
-
readonly partName: string | null;
|
|
107
|
-
readonly mime: RenderableImageMime | PreservedImageMime | 'unknown';
|
|
108
|
-
readonly reason: 'unsupported-format' | 'non-picture-graphic' | 'signature-mismatch' | 'decode-failed' | 'resource-limit';
|
|
109
|
-
} | {
|
|
110
|
-
readonly kind: 'external';
|
|
111
|
-
readonly relationshipId: string;
|
|
112
|
-
readonly sinkSafe: boolean;
|
|
113
|
-
} | {
|
|
114
|
-
readonly kind: 'missing';
|
|
115
|
-
readonly relationshipId: string;
|
|
116
|
-
} | {
|
|
117
|
-
readonly kind: 'pending';
|
|
118
|
-
readonly resourceKey: string;
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* The injected image decoder.
|
|
122
|
-
*
|
|
123
|
-
* A port rather than a direct `Image`/`createImageBitmap` call, so a worker or server runtime
|
|
124
|
-
* supplies its own and the engine never reaches for a browser global.
|
|
125
|
-
*/
|
|
126
|
-
interface ImageDecodePort {
|
|
127
|
-
decode(bytes: Uint8Array, mime: SupportedImageMime, limits: ImageResourceLimits): Promise<Readonly<{
|
|
128
|
-
pixelWidth: number;
|
|
129
|
-
pixelHeight: number;
|
|
130
|
-
dpiX: number;
|
|
131
|
-
dpiY: number;
|
|
132
|
-
}>>;
|
|
133
|
-
/**
|
|
134
|
-
* Optional conversion of media an `<img>` cannot render (EMF/WMF metafiles, TIFF) into a
|
|
135
|
-
* renderable raster. The returned bytes are untrusted and re-enter the full raster
|
|
136
|
-
* validation path (sniff, header, pixel caps, decode) before they can become a ready
|
|
137
|
-
* resource. A null return declines the format and keeps the labelled placeholder; so does
|
|
138
|
-
* a throw, as `decode-failed`.
|
|
139
|
-
*/
|
|
140
|
-
convertPreserved?(bytes: Uint8Array, mime: PreservedImageMime, limits: ImageResourceLimits): Promise<Readonly<{
|
|
141
|
-
bytes: Uint8Array;
|
|
142
|
-
mime: SupportedImageMime;
|
|
143
|
-
}> | null>;
|
|
144
|
-
}
|
|
145
|
-
/** Resolves a relationship id to a validated image resource, or reports why it could not. */
|
|
146
|
-
interface ImageResourceLookup {
|
|
147
|
-
readonly resolveEmbedded: (ownerPartName: string, relationshipId: string) => Promise<ImageResourceState>;
|
|
148
|
-
readonly resolveLinked: (ownerPartName: string, relationshipId: string) => ImageResourceState;
|
|
149
|
-
readonly resolveForProjection: (projection: DrawingProjection) => Promise<ImageResourceState>;
|
|
150
|
-
readonly liveReferenceCount: (partName: string) => number;
|
|
151
|
-
readonly dispose: () => void;
|
|
152
|
-
}
|
|
153
|
-
/** Maximum prefix inspected for SVG root detection (exported for bounded-scan tests). */
|
|
154
|
-
declare const MAX_SVG_SNIFF_BYTES = 512;
|
|
155
|
-
/** A raster header that passed structural validation: its real MIME type and pixel extent. */
|
|
156
|
-
interface ValidatedRasterHeader {
|
|
157
|
-
readonly pixelWidth: number;
|
|
158
|
-
readonly pixelHeight: number;
|
|
159
|
-
}
|
|
160
|
-
/** Bounded scan for an `<svg` document root (optional `<?xml` prolog only). */
|
|
161
|
-
declare function hasBoundedSvgRoot(bytes: Uint8Array): boolean;
|
|
162
|
-
/** Signature sniffing — authoritative over declared content type. */
|
|
163
|
-
declare function sniffImageMime(bytes: Uint8Array): RenderableImageMime | PreservedImageMime | 'unknown';
|
|
164
|
-
/** Structural PNG IHDR validation before decode. */
|
|
165
|
-
declare function validatePngHeader(bytes: Uint8Array): ValidatedRasterHeader | null;
|
|
166
|
-
/** Structural GIF logical screen descriptor validation before decode. */
|
|
167
|
-
declare function validateGifHeader(bytes: Uint8Array): ValidatedRasterHeader | null;
|
|
168
|
-
/** Bounded JPEG marker scan through the first supported SOF marker. */
|
|
169
|
-
declare function validateJpegHeader(bytes: Uint8Array): ValidatedRasterHeader | null;
|
|
170
|
-
/**
|
|
171
|
-
* Intrinsic size of an SVG, resolved the way a browser sizes one: absolute `width`/`height`
|
|
172
|
-
* first, then `viewBox` for the missing axis or ratio, then the CSS 300x150 default.
|
|
173
|
-
*
|
|
174
|
-
* This is metadata for insert and reset-to-natural-size only. Layout uses the authored
|
|
175
|
-
* `wp:extent` and the browser rasterizes into that box, so nothing here sizes an allocation
|
|
176
|
-
* and an out-of-range value is clamped rather than refused.
|
|
177
|
-
*/
|
|
178
|
-
declare function resolveSvgIntrinsicSize(bytes: Uint8Array, limits: ImageResourceLimits): ValidatedRasterHeader | null;
|
|
179
|
-
/**
|
|
180
|
-
* Validate a raster image's header structurally and report its real MIME type and extent.
|
|
181
|
-
*
|
|
182
|
-
* Content type is a CLAIM; this is what makes it a fact. A file declaring `image/png` over JPEG
|
|
183
|
-
* bytes is caught here rather than at decode.
|
|
184
|
-
*/
|
|
185
|
-
declare function validateRasterHeader(bytes: Uint8Array, mime: SupportedImageMime): ValidatedRasterHeader | null;
|
|
186
|
-
/** Package-wide live drawing references to a media part name. */
|
|
187
|
-
declare function liveDrawingReferenceCount(pkg: OoxmlPackage, partName: string): number;
|
|
188
|
-
/** How the image cache decodes, and what it will spend doing so. */
|
|
189
|
-
interface CreateImageResourceCacheOptions {
|
|
190
|
-
readonly limits?: Partial<ImageResourceLimits>;
|
|
191
|
-
readonly decodePort: ImageDecodePort;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Derived cache for one immutable package snapshot. Registry identity is
|
|
195
|
-
* `(package snapshot, decodePort object, normalized limits)` — the first caller
|
|
196
|
-
* never imposes its decoder or limits on later callers with different options.
|
|
197
|
-
*/
|
|
198
|
-
declare function imageResourceLookupFor(pkg: OoxmlPackage, options: CreateImageResourceCacheOptions): ImageResourceLookup;
|
|
199
|
-
/** @deprecated Prefer {@link imageResourceLookupFor} — registry binds cache to package identity. */
|
|
200
|
-
/** Build the per-document image cache. Validated bytes only; refusals are remembered too. */
|
|
201
|
-
declare function createImageResourceCache(initialPkg: OoxmlPackage, options: CreateImageResourceCacheOptions): ImageResourceLookup;
|
|
202
|
-
|
|
203
|
-
export { type CreateImageResourceCacheOptions as C, DEFAULT_IMAGE_RESOURCE_LIMITS as D, HARD_CEILINGS as H, type ImageResourceState as I, MAX_SVG_SNIFF_BYTES as M, type PreservedImageMime as P, type RenderableImageMime as R, type SupportedImageMime as S, type ValidatedImageBytesHandle as V, type VectorImageMime as a, type ImageDecodePort as b, type ImageResourceLimits as c, resolveSvgIntrinsicSize as d, type ResourceLimits as e, DEFAULT_LIMITS as f, IMAGE_RESOURCE_HARD_CEILINGS as g, type ImageResourceLookup as h, type ValidatedRasterHeader as i, createImageResourceCache as j, hasBoundedSvgRoot as k, imageResourceLookupFor as l, liveDrawingReferenceCount as m, resolveLimits as n, validateGifHeader as o, validateJpegHeader as p, validatePngHeader as q, resolveImageResourceLimits as r, sniffImageMime as s, validateRasterHeader as v };
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { D as DrawingProjection } from './tree-op-types-D1vNJ7XC.cjs';
|
|
2
|
-
import { c as OoxmlPackage } from './ooxml-package-CdEy9ufK.cjs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* The engine's trust-boundary caps: recursion depth, element counts, and the rest.
|
|
6
|
-
*
|
|
7
|
-
* A caller may LOWER any of these but never raise or disable one — an override of `Infinity`,
|
|
8
|
-
* zero, a negative or `NaN` clamps into `(0, ceiling]` rather than turning the limit off. These
|
|
9
|
-
* are security ceilings, not performance budgets.
|
|
10
|
-
*/
|
|
11
|
-
interface ResourceLimits {
|
|
12
|
-
/** Max nested-structure recursion (tables/shapes/SDT/groups). */
|
|
13
|
-
readonly maxRecursionDepth: number;
|
|
14
|
-
/** Max total parsed element count. */
|
|
15
|
-
readonly maxElementCount: number;
|
|
16
|
-
/** Max package part count. */
|
|
17
|
-
readonly maxPartCount: number;
|
|
18
|
-
/** Max total decompressed bytes (zip-bomb guard). */
|
|
19
|
-
readonly maxDecompressedBytes: number;
|
|
20
|
-
/** Max total compressed input bytes. */
|
|
21
|
-
readonly maxCompressedBytes: number;
|
|
22
|
-
/** Max decompressed:compressed ratio per entry. */
|
|
23
|
-
readonly maxCompressionRatio: number;
|
|
24
|
-
/** In-memory chunk budget for streaming/spooling. */
|
|
25
|
-
readonly maxChunkBytes: number;
|
|
26
|
-
/** Max pagination passes before non-convergence is declared. */
|
|
27
|
-
readonly maxPaginationPasses: number;
|
|
28
|
-
/** Max queued items in any bounded work queue. */
|
|
29
|
-
readonly maxQueueDepth: number;
|
|
30
|
-
}
|
|
31
|
-
/** Non-disableable hard ceilings: no resolved limit may exceed these. */
|
|
32
|
-
declare const HARD_CEILINGS: ResourceLimits;
|
|
33
|
-
/** Finite defaults, all <= their hard ceiling. */
|
|
34
|
-
declare const DEFAULT_LIMITS: ResourceLimits;
|
|
35
|
-
/**
|
|
36
|
-
* Resolve caller overrides into a frozen, always-finite limit set. Each value is
|
|
37
|
-
* `min(override>0 ? override : default, ceiling)`. Infinity/0/negative/NaN can
|
|
38
|
-
* never disable a limit — the hard ceiling always wins.
|
|
39
|
-
*/
|
|
40
|
-
declare function resolveLimits(overrides?: Partial<ResourceLimits>): ResourceLimits;
|
|
41
|
-
/** Bounded image decode limits (typed-drawings-and-images task 4). */
|
|
42
|
-
/** Trust-boundary caps specific to image decoding and embedding. */
|
|
43
|
-
interface ImageResourceLimits {
|
|
44
|
-
readonly maxEncodedBytes: number;
|
|
45
|
-
readonly maxDecodedBytes: number;
|
|
46
|
-
readonly maxPixels: number;
|
|
47
|
-
readonly maxDimension: number;
|
|
48
|
-
readonly maxPolygonPoints: number;
|
|
49
|
-
readonly maxExternalRedirects: number;
|
|
50
|
-
}
|
|
51
|
-
/** Image caps nothing can raise past. A caller's override clamps into these. */
|
|
52
|
-
declare const IMAGE_RESOURCE_HARD_CEILINGS: ImageResourceLimits;
|
|
53
|
-
/** The image caps in force when a host configures none. Conservative and finite. */
|
|
54
|
-
declare const DEFAULT_IMAGE_RESOURCE_LIMITS: ImageResourceLimits;
|
|
55
|
-
/** Resolve caller overrides into frozen image limits; hard ceilings cannot be raised. */
|
|
56
|
-
declare function resolveImageResourceLimits(overrides?: Partial<ImageResourceLimits>): ImageResourceLimits;
|
|
57
|
-
|
|
58
|
-
/** Opaque handle — bytes are reachable only through {@link mintValidatedImageBytes}. */
|
|
59
|
-
interface ValidatedImageBytesHandle {
|
|
60
|
-
readonly registryId: number;
|
|
61
|
-
readonly resourceKey: string;
|
|
62
|
-
readonly contentId: string;
|
|
63
|
-
readonly generation: number;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Raster media the decode port measures and any authoring path may write.
|
|
68
|
-
*
|
|
69
|
-
* BMP and WebP are here for the same reason the other three are: an `<img>` decodes them
|
|
70
|
-
* natively, so they need a signature and a structural header and nothing else. BMP is what
|
|
71
|
-
* older documents carry; WebP is what current Word writes.
|
|
72
|
-
*/
|
|
73
|
-
type SupportedImageMime = 'image/png' | 'image/jpeg' | 'image/gif' | 'image/bmp' | 'image/webp';
|
|
74
|
-
/**
|
|
75
|
-
* Vector media painted straight from validated bytes. An `<img>` renders SVG in the
|
|
76
|
-
* browser's secure static mode — no script, no external subresource loads — so there is
|
|
77
|
-
* no decode step and no raster buffer sized by a file-supplied number.
|
|
78
|
-
*/
|
|
79
|
-
type VectorImageMime = 'image/svg+xml';
|
|
80
|
-
/** Every mime the painter can hand to an `<img>`. */
|
|
81
|
-
type RenderableImageMime = SupportedImageMime | VectorImageMime;
|
|
82
|
-
/**
|
|
83
|
-
* Media kept in the package byte-for-byte that the painter cannot hand to an `<img>`.
|
|
84
|
-
* A decode port may rasterize it; without one it paints as a labelled placeholder.
|
|
85
|
-
*/
|
|
86
|
-
type PreservedImageMime = 'image/tiff' | 'image/x-emf' | 'image/x-wmf';
|
|
87
|
-
/**
|
|
88
|
-
* What is known about one embedded image: validated, refused, or still decoding.
|
|
89
|
-
*
|
|
90
|
-
* Content type is a CLAIM. Signature sniffing, structural header validation and the decode port
|
|
91
|
-
* are authoritative, and bytes that fail them never enter public state.
|
|
92
|
-
*/
|
|
93
|
-
type ImageResourceState = {
|
|
94
|
-
readonly kind: 'ready';
|
|
95
|
-
readonly partName: string;
|
|
96
|
-
readonly contentId: string;
|
|
97
|
-
readonly resourceKey: string;
|
|
98
|
-
readonly validatedHandle: ValidatedImageBytesHandle;
|
|
99
|
-
readonly mime: RenderableImageMime;
|
|
100
|
-
readonly pixelWidth: number;
|
|
101
|
-
readonly pixelHeight: number;
|
|
102
|
-
readonly dpiX: number;
|
|
103
|
-
readonly dpiY: number;
|
|
104
|
-
} | {
|
|
105
|
-
readonly kind: 'unrenderable';
|
|
106
|
-
readonly partName: string | null;
|
|
107
|
-
readonly mime: RenderableImageMime | PreservedImageMime | 'unknown';
|
|
108
|
-
readonly reason: 'unsupported-format' | 'non-picture-graphic' | 'signature-mismatch' | 'decode-failed' | 'resource-limit';
|
|
109
|
-
} | {
|
|
110
|
-
readonly kind: 'external';
|
|
111
|
-
readonly relationshipId: string;
|
|
112
|
-
readonly sinkSafe: boolean;
|
|
113
|
-
} | {
|
|
114
|
-
readonly kind: 'missing';
|
|
115
|
-
readonly relationshipId: string;
|
|
116
|
-
} | {
|
|
117
|
-
readonly kind: 'pending';
|
|
118
|
-
readonly resourceKey: string;
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* The injected image decoder.
|
|
122
|
-
*
|
|
123
|
-
* A port rather than a direct `Image`/`createImageBitmap` call, so a worker or server runtime
|
|
124
|
-
* supplies its own and the engine never reaches for a browser global.
|
|
125
|
-
*/
|
|
126
|
-
interface ImageDecodePort {
|
|
127
|
-
decode(bytes: Uint8Array, mime: SupportedImageMime, limits: ImageResourceLimits): Promise<Readonly<{
|
|
128
|
-
pixelWidth: number;
|
|
129
|
-
pixelHeight: number;
|
|
130
|
-
dpiX: number;
|
|
131
|
-
dpiY: number;
|
|
132
|
-
}>>;
|
|
133
|
-
/**
|
|
134
|
-
* Optional conversion of media an `<img>` cannot render (EMF/WMF metafiles, TIFF) into a
|
|
135
|
-
* renderable raster. The returned bytes are untrusted and re-enter the full raster
|
|
136
|
-
* validation path (sniff, header, pixel caps, decode) before they can become a ready
|
|
137
|
-
* resource. A null return declines the format and keeps the labelled placeholder; so does
|
|
138
|
-
* a throw, as `decode-failed`.
|
|
139
|
-
*/
|
|
140
|
-
convertPreserved?(bytes: Uint8Array, mime: PreservedImageMime, limits: ImageResourceLimits): Promise<Readonly<{
|
|
141
|
-
bytes: Uint8Array;
|
|
142
|
-
mime: SupportedImageMime;
|
|
143
|
-
}> | null>;
|
|
144
|
-
}
|
|
145
|
-
/** Resolves a relationship id to a validated image resource, or reports why it could not. */
|
|
146
|
-
interface ImageResourceLookup {
|
|
147
|
-
readonly resolveEmbedded: (ownerPartName: string, relationshipId: string) => Promise<ImageResourceState>;
|
|
148
|
-
readonly resolveLinked: (ownerPartName: string, relationshipId: string) => ImageResourceState;
|
|
149
|
-
readonly resolveForProjection: (projection: DrawingProjection) => Promise<ImageResourceState>;
|
|
150
|
-
readonly liveReferenceCount: (partName: string) => number;
|
|
151
|
-
readonly dispose: () => void;
|
|
152
|
-
}
|
|
153
|
-
/** Maximum prefix inspected for SVG root detection (exported for bounded-scan tests). */
|
|
154
|
-
declare const MAX_SVG_SNIFF_BYTES = 512;
|
|
155
|
-
/** A raster header that passed structural validation: its real MIME type and pixel extent. */
|
|
156
|
-
interface ValidatedRasterHeader {
|
|
157
|
-
readonly pixelWidth: number;
|
|
158
|
-
readonly pixelHeight: number;
|
|
159
|
-
}
|
|
160
|
-
/** Bounded scan for an `<svg` document root (optional `<?xml` prolog only). */
|
|
161
|
-
declare function hasBoundedSvgRoot(bytes: Uint8Array): boolean;
|
|
162
|
-
/** Signature sniffing — authoritative over declared content type. */
|
|
163
|
-
declare function sniffImageMime(bytes: Uint8Array): RenderableImageMime | PreservedImageMime | 'unknown';
|
|
164
|
-
/** Structural PNG IHDR validation before decode. */
|
|
165
|
-
declare function validatePngHeader(bytes: Uint8Array): ValidatedRasterHeader | null;
|
|
166
|
-
/** Structural GIF logical screen descriptor validation before decode. */
|
|
167
|
-
declare function validateGifHeader(bytes: Uint8Array): ValidatedRasterHeader | null;
|
|
168
|
-
/** Bounded JPEG marker scan through the first supported SOF marker. */
|
|
169
|
-
declare function validateJpegHeader(bytes: Uint8Array): ValidatedRasterHeader | null;
|
|
170
|
-
/**
|
|
171
|
-
* Intrinsic size of an SVG, resolved the way a browser sizes one: absolute `width`/`height`
|
|
172
|
-
* first, then `viewBox` for the missing axis or ratio, then the CSS 300x150 default.
|
|
173
|
-
*
|
|
174
|
-
* This is metadata for insert and reset-to-natural-size only. Layout uses the authored
|
|
175
|
-
* `wp:extent` and the browser rasterizes into that box, so nothing here sizes an allocation
|
|
176
|
-
* and an out-of-range value is clamped rather than refused.
|
|
177
|
-
*/
|
|
178
|
-
declare function resolveSvgIntrinsicSize(bytes: Uint8Array, limits: ImageResourceLimits): ValidatedRasterHeader | null;
|
|
179
|
-
/**
|
|
180
|
-
* Validate a raster image's header structurally and report its real MIME type and extent.
|
|
181
|
-
*
|
|
182
|
-
* Content type is a CLAIM; this is what makes it a fact. A file declaring `image/png` over JPEG
|
|
183
|
-
* bytes is caught here rather than at decode.
|
|
184
|
-
*/
|
|
185
|
-
declare function validateRasterHeader(bytes: Uint8Array, mime: SupportedImageMime): ValidatedRasterHeader | null;
|
|
186
|
-
/** Package-wide live drawing references to a media part name. */
|
|
187
|
-
declare function liveDrawingReferenceCount(pkg: OoxmlPackage, partName: string): number;
|
|
188
|
-
/** How the image cache decodes, and what it will spend doing so. */
|
|
189
|
-
interface CreateImageResourceCacheOptions {
|
|
190
|
-
readonly limits?: Partial<ImageResourceLimits>;
|
|
191
|
-
readonly decodePort: ImageDecodePort;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Derived cache for one immutable package snapshot. Registry identity is
|
|
195
|
-
* `(package snapshot, decodePort object, normalized limits)` — the first caller
|
|
196
|
-
* never imposes its decoder or limits on later callers with different options.
|
|
197
|
-
*/
|
|
198
|
-
declare function imageResourceLookupFor(pkg: OoxmlPackage, options: CreateImageResourceCacheOptions): ImageResourceLookup;
|
|
199
|
-
/** @deprecated Prefer {@link imageResourceLookupFor} — registry binds cache to package identity. */
|
|
200
|
-
/** Build the per-document image cache. Validated bytes only; refusals are remembered too. */
|
|
201
|
-
declare function createImageResourceCache(initialPkg: OoxmlPackage, options: CreateImageResourceCacheOptions): ImageResourceLookup;
|
|
202
|
-
|
|
203
|
-
export { type CreateImageResourceCacheOptions as C, DEFAULT_IMAGE_RESOURCE_LIMITS as D, HARD_CEILINGS as H, type ImageResourceState as I, MAX_SVG_SNIFF_BYTES as M, type PreservedImageMime as P, type RenderableImageMime as R, type SupportedImageMime as S, type ValidatedImageBytesHandle as V, type VectorImageMime as a, type ImageDecodePort as b, type ImageResourceLimits as c, resolveSvgIntrinsicSize as d, type ResourceLimits as e, DEFAULT_LIMITS as f, IMAGE_RESOURCE_HARD_CEILINGS as g, type ImageResourceLookup as h, type ValidatedRasterHeader as i, createImageResourceCache as j, hasBoundedSvgRoot as k, imageResourceLookupFor as l, liveDrawingReferenceCount as m, resolveLimits as n, validateGifHeader as o, validateJpegHeader as p, validatePngHeader as q, resolveImageResourceLimits as r, sniffImageMime as s, validateRasterHeader as v };
|