@betteroffice/docx 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +41 -0
  3. package/dist/Subscribable-DOz6Ohoo.d.mts +33 -0
  4. package/dist/agent/index.d.mts +531 -0
  5. package/dist/agent/index.mjs +1 -0
  6. package/dist/chunk-34K66SY4.mjs +1 -0
  7. package/dist/chunk-3UBMCDME.mjs +1 -0
  8. package/dist/chunk-4RCISPPE.mjs +1 -0
  9. package/dist/chunk-4UD54UM5.mjs +1 -0
  10. package/dist/chunk-52GB3Y42.mjs +1 -0
  11. package/dist/chunk-6NEKRDXF.mjs +1 -0
  12. package/dist/chunk-6PW4CWUG.mjs +1 -0
  13. package/dist/chunk-7DEIW7FL.mjs +1 -0
  14. package/dist/chunk-7PCO5I2O.mjs +1 -0
  15. package/dist/chunk-BI3B33LI.mjs +1 -0
  16. package/dist/chunk-BIQWVK5P.mjs +2 -0
  17. package/dist/chunk-CIRN3LZA.mjs +1 -0
  18. package/dist/chunk-DXKG3HQ5.mjs +16 -0
  19. package/dist/chunk-EUUIJVM6.mjs +0 -0
  20. package/dist/chunk-FPZBTOD6.mjs +1 -0
  21. package/dist/chunk-FZIA7OFY.mjs +1 -0
  22. package/dist/chunk-GWKJ2Y4Y.mjs +1 -0
  23. package/dist/chunk-H3JCIGWK.mjs +1 -0
  24. package/dist/chunk-HJGAQIU7.mjs +2 -0
  25. package/dist/chunk-I6KKMUUC.mjs +1 -0
  26. package/dist/chunk-IL5JZJT7.mjs +1 -0
  27. package/dist/chunk-JY6ILTNS.mjs +1 -0
  28. package/dist/chunk-KEE52TT5.mjs +1 -0
  29. package/dist/chunk-KVKLLTDP.mjs +58 -0
  30. package/dist/chunk-KXNZFTTK.mjs +1 -0
  31. package/dist/chunk-L5ISVQ3W.mjs +1 -0
  32. package/dist/chunk-LDUWIM7M.mjs +1 -0
  33. package/dist/chunk-N5Q3YN64.mjs +1 -0
  34. package/dist/chunk-NEWOMDTX.mjs +1 -0
  35. package/dist/chunk-O2QSE2I7.mjs +1 -0
  36. package/dist/chunk-OBQGPMPQ.mjs +1 -0
  37. package/dist/chunk-OJOHXQNQ.mjs +1 -0
  38. package/dist/chunk-OMR3TWCD.mjs +2 -0
  39. package/dist/chunk-P3KDV4M2.mjs +1 -0
  40. package/dist/chunk-Q7PO7V73.mjs +1 -0
  41. package/dist/chunk-QOUFE3VX.mjs +1 -0
  42. package/dist/chunk-SINEY6ZF.mjs +1 -0
  43. package/dist/chunk-T4EZMUXM.mjs +1 -0
  44. package/dist/chunk-TTRUPDAB.mjs +1 -0
  45. package/dist/chunk-TYHI7RAD.mjs +1 -0
  46. package/dist/chunk-UIEJWORW.mjs +1 -0
  47. package/dist/chunk-VAOUFAUH.mjs +1 -0
  48. package/dist/chunk-VBOTMRXV.mjs +1 -0
  49. package/dist/chunk-VCER63GQ.mjs +1 -0
  50. package/dist/chunk-WAUF2UC7.mjs +2 -0
  51. package/dist/chunk-WRWRCBLK.mjs +1 -0
  52. package/dist/chunk-X4XDO3LZ.mjs +1 -0
  53. package/dist/chunk-XQBCCJBO.mjs +9 -0
  54. package/dist/chunk-XWUOLYRQ.mjs +2 -0
  55. package/dist/chunk-XYH6XWP3.mjs +10 -0
  56. package/dist/chunk-YBIM6UJV.mjs +8 -0
  57. package/dist/chunk-YCIH2Q3E.mjs +1 -0
  58. package/dist/chunk-YUOKI2HB.mjs +1 -0
  59. package/dist/chunk-ZOV5KL7C.mjs +1 -0
  60. package/dist/colorResolver-n0o7H7ep.d.mts +290 -0
  61. package/dist/content-sSHuWw49.d.mts +2202 -0
  62. package/dist/core-plugins.d.mts +37 -0
  63. package/dist/core-plugins.mjs +1 -0
  64. package/dist/core.d.mts +451 -0
  65. package/dist/core.mjs +1 -0
  66. package/dist/displayListQueries-p-ijSzdh.d.mts +222 -0
  67. package/dist/docx/index.d.mts +618 -0
  68. package/dist/docx/index.mjs +2 -0
  69. package/dist/docx/parser.d.mts +41 -0
  70. package/dist/docx/parser.mjs +1 -0
  71. package/dist/docx/rezip.d.mts +148 -0
  72. package/dist/docx/rezip.mjs +1 -0
  73. package/dist/docx/serializer/index.d.mts +42 -0
  74. package/dist/docx/serializer/index.mjs +1 -0
  75. package/dist/docx/wrapTypes.d.mts +19 -0
  76. package/dist/docx/wrapTypes.mjs +1 -0
  77. package/dist/docxInput-DTbCa48g.d.mts +21 -0
  78. package/dist/editor/index.d.mts +170 -0
  79. package/dist/editor/index.mjs +1 -0
  80. package/dist/editorTree-DO5PyDK8.d.mts +37 -0
  81. package/dist/executor-7O2RBJ2B.mjs +1 -0
  82. package/dist/fontLoader-Bx6DK6-2.d.mts +327 -0
  83. package/dist/formatting-DoL7KBSL.d.mts +823 -0
  84. package/dist/generated/edit/docx_edit_bg.wasm +0 -0
  85. package/dist/generated/layout/docx_layout_bg.wasm +0 -0
  86. package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
  87. package/dist/generated/parse/docx_parse_bg.wasm +0 -0
  88. package/dist/headerFooterLayout-0zPT64Qc.d.mts +316 -0
  89. package/dist/headless.d.mts +69 -0
  90. package/dist/headless.mjs +1 -0
  91. package/dist/layout/flow/index.d.mts +149 -0
  92. package/dist/layout/flow/index.mjs +1 -0
  93. package/dist/layout/index.d.mts +307 -0
  94. package/dist/layout/index.mjs +1 -0
  95. package/dist/layout/measure/index.d.mts +324 -0
  96. package/dist/layout/measure/index.mjs +1 -0
  97. package/dist/layout/pagination/index.d.mts +60 -0
  98. package/dist/layout/pagination/index.mjs +1 -0
  99. package/dist/layout/pagination/types.d.mts +4 -0
  100. package/dist/layout/pagination/types.mjs +1 -0
  101. package/dist/layout/render/index.d.mts +733 -0
  102. package/dist/layout/render/index.mjs +1 -0
  103. package/dist/loadWasmAsset-CMvnVkfA.d.mts +3 -0
  104. package/dist/managers/AutoSaveManager.d.mts +81 -0
  105. package/dist/managers/AutoSaveManager.mjs +1 -0
  106. package/dist/managers/TableSelectionManager.d.mts +74 -0
  107. package/dist/managers/TableSelectionManager.mjs +1 -0
  108. package/dist/managers/types.d.mts +113 -0
  109. package/dist/managers/types.mjs +0 -0
  110. package/dist/mcp-cli.mjs +142 -0
  111. package/dist/mcp.d.mts +162 -0
  112. package/dist/mcp.mjs +16 -0
  113. package/dist/measureBlocksPipeline-Df0Bbrwy.d.mts +109 -0
  114. package/dist/measuredBlock-DZwz8zhD.d.mts +26 -0
  115. package/dist/plugin-api/RenderedDomContext.d.mts +114 -0
  116. package/dist/plugin-api/RenderedDomContext.mjs +1 -0
  117. package/dist/plugin-api/index.d.mts +7 -0
  118. package/dist/plugin-api/index.mjs +0 -0
  119. package/dist/plugin-api/resolveItemPositions.d.mts +39 -0
  120. package/dist/plugin-api/resolveItemPositions.mjs +1 -0
  121. package/dist/plugin-api/types.d.mts +193 -0
  122. package/dist/plugin-api/types.mjs +0 -0
  123. package/dist/processTemplate-HDUIZFJ5.mjs +1 -0
  124. package/dist/registry-DMM5VTdT.d.mts +165 -0
  125. package/dist/rustDisplayList-dqunvwxH.d.mts +1036 -0
  126. package/dist/rustPagination-Bj2hq013.d.mts +106 -0
  127. package/dist/sectionConfigs-DW3J8q0X.d.mts +55 -0
  128. package/dist/selectionContext-Buc9BCU1.d.mts +570 -0
  129. package/dist/selectiveSave-oFBJ1n71.d.mts +16 -0
  130. package/dist/selectiveXmlPatch-ypkxlTD_.d.mts +23 -0
  131. package/dist/settingsParser-CcGvtmCK.d.mts +33 -0
  132. package/dist/styles/index.d.mts +162 -0
  133. package/dist/styles/index.mjs +1 -0
  134. package/dist/styles-VxNcXLdi.d.mts +189 -0
  135. package/dist/types/agentApi.d.mts +456 -0
  136. package/dist/types/agentApi.mjs +1 -0
  137. package/dist/types/content.d.mts +3 -0
  138. package/dist/types/content.mjs +1 -0
  139. package/dist/types/document.d.mts +117 -0
  140. package/dist/types/document.mjs +1 -0
  141. package/dist/types-DNrYr6yQ.d.mts +1754 -0
  142. package/dist/types-dYdjUZMo.d.mts +311 -0
  143. package/dist/units-O5Y02RKQ.d.mts +34 -0
  144. package/dist/utils/autoScroll.d.mts +24 -0
  145. package/dist/utils/autoScroll.mjs +1 -0
  146. package/dist/utils/cardStyles.d.mts +22 -0
  147. package/dist/utils/cardStyles.mjs +1 -0
  148. package/dist/utils/comments.d.mts +120 -0
  149. package/dist/utils/comments.mjs +4 -0
  150. package/dist/utils/findReplace.d.mts +114 -0
  151. package/dist/utils/findReplace.mjs +2 -0
  152. package/dist/utils/findVerticalScrollParent.d.mts +25 -0
  153. package/dist/utils/findVerticalScrollParent.mjs +1 -0
  154. package/dist/utils/fontOptions.d.mts +21 -0
  155. package/dist/utils/fontOptions.mjs +1 -0
  156. package/dist/utils/headingCollector.d.mts +28 -0
  157. package/dist/utils/headingCollector.mjs +1 -0
  158. package/dist/utils/highlightColors.d.mts +14 -0
  159. package/dist/utils/highlightColors.mjs +1 -0
  160. package/dist/utils/index.d.mts +956 -0
  161. package/dist/utils/index.mjs +84 -0
  162. package/dist/utils/listState.d.mts +27 -0
  163. package/dist/utils/listState.mjs +1 -0
  164. package/dist/utils/reportIssue.d.mts +23 -0
  165. package/dist/utils/reportIssue.mjs +2 -0
  166. package/dist/utils/sidebarConstants.d.mts +10 -0
  167. package/dist/utils/sidebarConstants.mjs +1 -0
  168. package/dist/utils/stylePreview.d.mts +70 -0
  169. package/dist/utils/stylePreview.mjs +1 -0
  170. package/dist/utils/textSelection.d.mts +92 -0
  171. package/dist/utils/textSelection.mjs +1 -0
  172. package/dist/utils/units.d.mts +78 -0
  173. package/dist/utils/units.mjs +1 -0
  174. package/dist/variableDetector-Borj29SF.d.mts +115 -0
  175. package/dist/wasm-FZQ5XB2Y.mjs +1 -0
  176. package/dist/wasm-SA237OSP.mjs +1 -0
  177. package/dist/wasm-edit.d.mts +473 -0
  178. package/dist/wasm-edit.mjs +1 -0
  179. package/dist/wasm-layout.d.mts +112 -0
  180. package/dist/wasm-layout.mjs +1 -0
  181. package/dist/wasm-opc.d.mts +16 -0
  182. package/dist/wasm-opc.mjs +1 -0
  183. package/dist/wasm-parse.d.mts +18 -0
  184. package/dist/wasm-parse.mjs +1 -0
  185. package/dist/watermarkApi-DCxjutkg.d.mts +38 -0
  186. package/dist/yrs/index.d.mts +882 -0
  187. package/dist/yrs/index.mjs +1 -0
  188. package/dist/yrs/residentEngineWorker.d.mts +2 -0
  189. package/dist/yrs/residentEngineWorker.mjs +1 -0
  190. package/package.json +365 -0
@@ -0,0 +1,2 @@
1
+ export{h as getImageHeightPx,g as getImageWidthPx,j as getWrapDistancesPx,e as isBehindText,i as isDecorativeImage,d as isFloatingImage,f as isInFrontOfText,c as isInlineImage,a as parseDrawing,b as parseImage}from'../chunk-I6KKMUUC.mjs';import {a}from'../chunk-ZOV5KL7C.mjs';export{f as getEndnoteText,e as getFootnoteText,h as isSeparatorEndnote,g as isSeparatorFootnote,d as parseEndnoteProperties,b as parseEndnotes,c as parseFootnoteProperties,a as parseFootnotes}from'../chunk-OMR3TWCD.mjs';export{d as computeListRendering,c as createNumberingMap,e as formatNumber,h as getBulletCharacter,b as getCachedNumberingMap,i as isBulletLevel,a as parseNumbering,g as renderListMarker}from'../chunk-XWUOLYRQ.mjs';import {h,k,o,p,n,f,m,g,a as a$1,b,i,s,t,c,q as q$1,j as j$1,r,l,e}from'../chunk-HJGAQIU7.mjs';export{a as getDocumentWatermark,b as setDocumentWatermark}from'../chunk-WAUF2UC7.mjs';export{b as buildPatchedDocumentXml,a as validatePatchSafety}from'../chunk-KEE52TT5.mjs';import'../chunk-FZIA7OFY.mjs';export{a as attemptSelectiveSave}from'../chunk-OJOHXQNQ.mjs';export{s as createDocx,h as repackDocx,l as updateMultipleFiles}from'../chunk-KVKLLTDP.mjs';import'../chunk-BIQWVK5P.mjs';import {b as b$1}from'../chunk-3UBMCDME.mjs';export{b as emuToPixels,c as pixelsToEmu}from'../chunk-3UBMCDME.mjs';export{a as parseDocx}from'../chunk-LDUWIM7M.mjs';import'../chunk-DXKG3HQ5.mjs';import'../chunk-FPZBTOD6.mjs';import'../chunk-H3JCIGWK.mjs';import'../chunk-N5Q3YN64.mjs';import'../chunk-SINEY6ZF.mjs';import'../chunk-T4EZMUXM.mjs';import'../chunk-TTRUPDAB.mjs';var it=new Set(["decorative","modern","roman","script","swiss","auto"]),at=new Set(["default","fixed","variable"]);function V(e,t){let n=j$1(e,"w",t);if(!n)return;let r=o(n,"r","id");if(!r)return;let o$1={relId:r},l=o(n,"w","fontKey");l&&(o$1.fontKey=l);let i=o(n,"w","subsetted");return (i==="true"||i==="1")&&(o$1.subsetted=true),o$1}function lt(e){let t=o(e,"w","name");if(!t)return null;let n={name:t},r=j$1(e,"w","altName");if(r){let c=o(r,"w","val");c&&(n.altName=c);}let o$1=j$1(e,"w","family");if(o$1){let c=o(o$1,"w","val");c&&it.has(c)&&(n.family=c);}let l=j$1(e,"w","pitch");if(l){let c=o(l,"w","val");c&&at.has(c)&&(n.pitch=c);}let i=j$1(e,"w","charset");if(i){let c=o(i,"w","val");c&&(n.charset=c);}let a=j$1(e,"w","panose1");if(a){let c=o(a,"w","val");c&&(n.panose1=c);}let u=V(e,"embedRegular");u&&(n.embedRegular=u);let p=V(e,"embedBold");p&&(n.embedBold=p);let f=V(e,"embedItalic");f&&(n.embedItalic=f);let m=V(e,"embedBoldItalic");return m&&(n.embedBoldItalic=m),n}function st(e){if(!e||e.trim().length===0)return {fonts:[]};let t=h(e);if(!t)return console.warn("Failed to parse fontTable.xml"),{fonts:[]};let n=[];for(let r of k(t,"w","font")){let o=lt(r);o&&n.push(o);}return {fonts:n}}function ut(e,t,n,r,o,l){let i=e.includes("w")||e.includes("e"),a=e.includes("n")||e.includes("s"),u=e.includes("w")?-1:1,p=e.includes("n")?-1:1,f=i?r+t*u:r,m=a?o+n*p:o;if(i&&a&&l){let T=Math.max(f/r,m/o);f=r*T,m=o*T;}let c=T=>Math.max(20,Math.min(2e3,T));return {width:i?c(f):r,height:a?c(m):o}}function pt(e,t,n){let r=()=>t.position?.horizontal&&t.position.vertical?t.position:n?.initialPositionEmu?{horizontal:{relativeTo:"column",posOffset:n.initialPositionEmu.horizontalEmu},vertical:{relativeTo:"paragraph",posOffset:n.initialPositionEmu.verticalEmu}}:{horizontal:{relativeTo:"column",posOffset:0},vertical:{relativeTo:"paragraph",posOffset:0}};switch(e){case "inline":return {wrapType:"inline",displayMode:"inline",cssFloat:"none",wrapText:void 0,position:void 0,distTop:void 0,distBottom:void 0,distLeft:void 0,distRight:void 0};case "squareLeft":case "squareRight":{let o=e==="squareLeft"?"left":"right";return {wrapType:t.wrapType==="tight"||t.wrapType==="through"?t.wrapType:"square",displayMode:"float",cssFloat:o,wrapText:o==="left"?"right":"left",position:r()}}case "square":case "tight":case "through":{let o=t.cssFloat==="left"||t.cssFloat==="right"?t.cssFloat:"left";return {wrapType:e,displayMode:"float",cssFloat:o,wrapText:o==="left"?"right":"left",position:r()}}case "topAndBottom":return {wrapType:"topAndBottom",displayMode:"block",cssFloat:"none",wrapText:"bothSides",position:r()};case "behind":case "inFront":return {wrapType:e,displayMode:"float",cssFloat:"none",wrapText:"bothSides",position:r()}}}function ct(e,t){return e==="inline"?"inline":e==="behind"?"behind":e==="inFront"?"inFront":e==="square"||e==="tight"||e==="through"?t==="right"?"squareRight":"squareLeft":null}var ft=[{choice:"inline",i18nLabelKey:"inLineWithText",i18nDescKey:"inLineWithText",iconHint:"inline"},{choice:"squareLeft",i18nLabelKey:"squareLeft",i18nDescKey:"squareLeft",iconHint:"squareLeft"},{choice:"squareRight",i18nLabelKey:"squareRight",i18nDescKey:"squareRight",iconHint:"squareRight"},{choice:"behind",i18nLabelKey:"behindText",i18nDescKey:"behindText",iconHint:"behind"},{choice:"inFront",i18nLabelKey:"inFrontOfText",i18nDescKey:"inFrontOfText",iconHint:"inFront"}];function dt(e,t){return true}function mt(e){switch(e){case "inline":return "inline";case "square":case "tight":case "through":return "squareLeft";case "topAndBottom":return "topAndBottom";case "behind":return "behind";case "inFront":return "inFront";case "wrapRight":return "squareLeft";case "wrapLeft":return "squareRight";default:return}}var Z=["PAGE","NUMPAGES","NUMWORDS","NUMCHARS","DATE","TIME","CREATEDATE","SAVEDATE","PRINTDATE","EDITTIME","AUTHOR","TITLE","SUBJECT","KEYWORDS","COMMENTS","FILENAME","FILESIZE","TEMPLATE","REVNUM","DOCPROPERTY","DOCVARIABLE","REF","PAGEREF","NOTEREF","HYPERLINK","TOC","TOA","INDEX","SEQ","STYLEREF","AUTONUM","AUTONUMLGL","AUTONUMOUT","SECTION","SECTIONPAGES","USERADDRESS","USERNAME","USERINITIALS","FORMTEXT","FORMCHECKBOX","FORMDROPDOWN","CITATION","BIBLIOGRAPHY","IF","MERGEFIELD","NEXT","NEXTIF","ASK","SET","QUOTE","INCLUDETEXT","INCLUDEPICTURE","SYMBOL","ADVANCE"];function $(e){let n=e.trim().match(/^\\?([A-Z][A-Z0-9]*)/i)?.[1]?.toUpperCase();return n&&Z.includes(n)?n:"UNKNOWN"}function ht(e){return Z.includes(e)}function gt(e){let t=e.trim(),n=t.match(/^\\?([A-Z][A-Z0-9]*)/i)?.[0]??"",r=t.slice(n.length).trim(),o=[],l=[],i=/\\(\*|@|#|!|[a-z])\s*(?:"([^"]*)"|([^\s]*))?/gi,a;for(;a=i.exec(r);)o.push({switch:a[1],...a[2]||a[3]?{value:a[2]||a[3]}:{}}),l.push(a.index);let u=r.slice(0,l[0]??r.length).trim(),p=u.startsWith('"')&&u.endsWith('"')?u.slice(1,-1):u||void 0;return {type:$(e),raw:e,...p?{argument:p}:{},switches:o}}function xt(e){return e.switches.find(t=>t.switch==="*"||t.switch==="@")?.value}function Tt(e){return e.switches.find(t=>t.switch==="*")?.value?.toUpperCase()==="MERGEFORMAT"}function bt(e,t,n){let r=o(e,"w","instr")??"",o$1=k(e,"w","r").map(i=>{let a=p(i);return {type:"run",content:a?[{type:"text",text:a}]:[]}}),l={type:"simpleField",instruction:r,fieldType:$(r),content:o$1};return /^(1|true)$/i.test(o(e,"w","fldLock")??"")&&(l.fldLock=true),/^(1|true)$/i.test(o(e,"w","dirty")??"")&&(l.dirty=true),o$1.length&&(l.structuredResult={inline:o$1},l.fieldTree={version:1,result:l.structuredResult,displayMode:"result"}),l}function yt(){return {state:"outside",instruction:"",codeRuns:[],resultRuns:[],fldLock:false,dirty:false,nestingLevel:0}}function wt(e){return (e.type==="simpleField"?e.content:e.fieldResult).map(St).join("")}function St(e){return e.type==="run"?le(e):e.children.filter(t=>t.type==="run").map(le).join("")}function le(e){return e.content.filter(t=>t.type==="text").map(t=>t.text).join("")}function Ft(e){return e.fieldType==="PAGE"}function Et(e){return e.fieldType==="NUMPAGES"}function Ct(e){return ["DATE","TIME","CREATEDATE","SAVEDATE","PRINTDATE","EDITTIME"].includes(e.fieldType)}function It(e){return ["AUTHOR","TITLE","SUBJECT","KEYWORDS","COMMENTS","FILENAME","FILESIZE","TEMPLATE","REVNUM","DOCPROPERTY","DOCVARIABLE"].includes(e.fieldType)}function At(e){return ["REF","PAGEREF","NOTEREF"].includes(e.fieldType)}function Mt(e){return ["MERGEFIELD","IF","NEXT","NEXTIF","ASK","SET"].includes(e.fieldType)}function Bt(e){return ["TOC","TOA","INDEX"].includes(e.fieldType)}function Pt(e,t,n$1=null,r=null,o$1=null,l,i=null){let a$1={type:"hyperlink",children:[]},u=o(e,"r","id");if(u){a$1.rId=u;let g=t?.get(u);g&&(a$1.href=a(g.target));}let p$1=o(e,"w","anchor");p$1&&(a$1.anchor=p$1.slice(0,1024),a$1.href||(a$1.href=`#${a$1.anchor}`));let f=o(e,"w","tooltip");f&&(a$1.tooltip=f.slice(0,2048));let m=o(e,"w","tgtFrame");m&&(a$1.target=m.slice(0,255));let c=o(e,"w","history");(c==="1"||c==="true")&&(a$1.history=true);let T=o(e,"w","docLocation");T&&(a$1.docLocation=T.slice(0,2048));for(let g of n(e).slice(0,1e4)){if(g.name?.replace(/^.*:/,"")!=="r")continue;let A=p(g);a$1.children.push({type:"run",content:A?[{type:"text",text:A}]:[]});}return a$1.children.length&&(a$1.structuredChildren=[...a$1.children]),a$1}function Lt(e){return e.children.filter(t=>t.type==="run").flatMap(t=>t.content).map(t=>t.type==="text"?t.text:t.type==="tab"?" ":"").join("")}function Rt(e){return e.href?/^https?:\/\/|^mailto:|^tel:|^ftp:/i.test(e.href):!!e.rId&&!e.anchor}function vt(e){return !!e.anchor}function Nt(e){return e.href}function Dt(e){return e.children.some(t=>t.type==="run")}function Ot(e){return e.children.filter(t=>t.type==="run")}function Xt(e,t){return e.rId&&(e.href=a(t.get(e.rId)?.target)),e.anchor&&!e.href&&(e.href=`#${e.anchor}`),e.href}function L(e,t){return n(e).find(n=>i(n.name??"")===t)??null}function P(e,t,n$1=0){if(!e||n$1>32)return null;for(let r of n(e)){if(i(r.name??"")===t)return r;let o=P(r,t,n$1+1);if(o)return o}return null}function N(e,t){let n=o(e,null,t);if(n==="1"||n==="true"||n==="on")return true;if(n==="0"||n==="false"||n==="off")return false}function E(e,t){let n=q$1(e,null,t);return n!==void 0&&Number.isFinite(n)?n:void 0}function kt(e){return e?l(e,"p").map(()=>({type:"paragraph",formatting:{},content:[]})):[]}function Ht(e$1,t){let n={t:"top",ctr:"middle",b:"bottom",dist:"distributed",just:"justified"},r=o(e$1,null,"anchor"),o$1=o(e$1,null,"vert"),l={left:E(e$1,"lIns"),right:E(e$1,"rIns"),top:E(e$1,"tIns"),bottom:E(e$1,"bIns")},i={content:kt(t)};o$1&&o$1!=="horz"&&(i.vertical=true);let a=e(o(e$1,null,"rot"));a!==void 0&&(i.rotation=a),r&&n[r]&&(i.anchor=n[r]);let u=N(e$1,"anchorCtr");return u!==void 0&&(i.anchorCenter=u),L(e$1,"noAutofit")?i.autoFit="none":L(e$1,"normAutofit")?i.autoFit="normal":L(e$1,"spAutoFit")&&(i.autoFit="shape"),Object.values(l).some(p=>p!==void 0)&&(i.margins=l),i}function se(e){let t=L(e,"spPr")??P(e,"spPr"),n=P(e,"cNvPr"),r=L(e,"bodyPr")??P(L(e,"txBody"),"bodyPr"),o$1=P(e,"txbxContent"),l=f(t?m(t,"a:xfrm"):null),i={type:"shape",shapeType:g(t),size:l.size};l.offset&&(i.offset=l.offset),l.transform&&(i.transform=l.transform);let a=a$1(t);a&&(i.fill=a);let u=b(t);return u&&(i.outline=u),n&&(i.id=o(n,null,"id")??void 0,i.name=o(n,null,"name")??void 0,i.title=o(n,null,"title")??void 0,i.description=o(n,null,"descr")??void 0,i.hidden=N(n,"hidden"),i.decorative=N(n,"decorative")),(o$1||r)&&(i.textBody=Ht(r,o$1)),i}function ue(e){return n(e).find(t=>{let n=i(t.name??"");return n==="inline"||n==="anchor"})??null}function Wt(e){let t$1=ue(e);if(!t$1)return null;let n$1=m(t$1,"a:graphicData");if(!n$1)return null;let r=n(n$1).find(u=>["wsp","sp","cxnSp"].includes(i(u.name??"")))??P(n$1,"wsp");if(!r)return null;let o$1=se(r),l=m(t$1,"wp:extent");l&&(o$1.size={width:E(l,"cx")??0,height:E(l,"cy")??0}),i(t$1.name??"")==="anchor"&&(o$1.position=s(t$1),o$1.wrap=t(t$1));let i$1=m(t$1,"wp:docPr");i$1&&(o$1.id=o(i$1,null,"id")??o$1.id,o$1.name=o(i$1,null,"name")??o$1.name,o$1.title=o(i$1,null,"title")??o$1.title,o$1.description=o(i$1,null,"descr")??o$1.description,o$1.hidden=N(i$1,"hidden")??o$1.hidden,o$1.decorative=N(i$1,"decorative")??o$1.decorative);let a=m(t$1,"wp:effectExtent");return a&&(o$1.effectExtent={left:E(a,"l"),top:E(a,"t"),right:E(a,"r"),bottom:E(a,"b")}),o$1.relativeHeight=o$1.position?.relativeHeight,o$1}function _t(e){let t=ue(e),n$1=t?m(t,"a:graphicData"):null;return n$1?n(n$1).some(r=>["wsp","wgp","wpc","spTree","grpSp","sp","cxnSp"].includes(i(r.name??""))):false}function Vt(e){return ["line","straightConnector1","bentConnector2","bentConnector3","bentConnector4","bentConnector5","curvedConnector2","curvedConnector3","curvedConnector4","curvedConnector5"].includes(e.shapeType)}function Ut(e){return e.shapeType==="textBox"||!!e.textBody?.content.length}function zt(e){return !!e.textBody?.content.length}function pe(e){return b$1(e.size.width)}function ce(e){return b$1(e.size.height)}function jt(e){return {width:pe(e),height:ce(e)}}function Kt(e){return e.position!==void 0||e.wrap!==void 0}function qt(e){return e.fill!==void 0&&e.fill.type!=="none"}function Gt(e){return e.outline!==void 0}function Yt(e){return e.outline?.width?b$1(e.outline.width):0}function Zt(e){return e.fill?.type==="solid"?c(e.fill.color):void 0}function $t(e){return e.outline?.color?c(e.outline.color):void 0}var J=720,Q="left",Jt="none";function fe(e){let t=q$1(e,"w","pos"),n=o(e,"w","val");if(t===void 0||!n)return null;let r={position:t,alignment:n},o$1=o(e,"w","leader");return o$1&&(r.leader=o$1),r}function de(e){if(!e)return [];let t=k(e,"w","tab");if(t.length===0)return [];let n=[];for(let r of t){let o=fe(r);o&&n.push(o);}return n.sort((r,o)=>r.position-o.position),n}function Qt(e){if(!e)return;let t=j$1(e,"w","tabs"),n=de(t);return n.length>0?n:void 0}function en(e,t){if(!e&&!t)return [];if(!e)return t??[];if(!t)return [...e];let n=new Map;for(let o of e)n.set(o.position,o);for(let o of t)o.alignment==="clear"?n.delete(o.position):n.set(o.position,o);let r=Array.from(n.values());return r.sort((o,l)=>o.position-l.position),r}function ee(e,t,n){for(let o of t)if(o.position>e&&o.alignment!=="clear")return o;let r=Math.ceil((e+1)/J)*J;return r>n?{position:n,alignment:Q}:{position:r,alignment:Q}}function tn(e,t,n){let r=ee(e,t,n);return Math.max(0,r.position-e)}function nn(e,t,n,r=0){let o=ee(e,t,n),l;switch(o.alignment){case "right":l=Math.max(0,o.position-e-r);break;case "center":l=Math.max(0,o.position-e-r/2);break;case "decimal":l=Math.max(0,o.position-e-r);break;case "bar":l=Math.max(0,o.position-e);break;default:l=Math.max(0,o.position-e);break}return {width:l,alignment:o.alignment}}function on(e){switch(e){case "dot":return ".";case "hyphen":return "-";case "underscore":return "_";case "heavy":return "_";case "middleDot":return "\xB7";default:return " "}}function rn(e){return e!==void 0&&e!=="none"}function an(e,t,n,r){return {...e&&e!=="auto"?{rgb:e}:{},...e==="auto"?{auto:true}:{},...t?{themeColor:t}:{},...n?{themeTint:n}:{},...r?{themeShade:r}:{}}}function D(e){if(!e)return;let n={style:o(e,"w","val")??"none"},r=q$1(e,"w","sz");r!==void 0&&(n.size=r);let o$1=q$1(e,"w","space");o$1!==void 0&&(n.space=o$1);let l=o(e,"w","color"),i=o(e,"w","themeColor"),a=o(e,"w","themeTint"),u=o(e,"w","themeShade");(l||i||a||u)&&(n.color=an(l,i,a,u));let p=o(e,"w","shadow");(p==="1"||p==="true")&&(n.shadow=true);let f=o(e,"w","frame");return (f==="1"||f==="true")&&(n.frame=true),n}function te(e){if(!e)return;let t=q$1(e,"w","w")??0,n=o(e,"w","type")??"dxa",r="dxa";return (n==="auto"||n==="dxa"||n==="nil"||n==="pct")&&(r=n),{value:t,type:r}}function C(e){return te(e)}function U(e){if(!e)return;let t={};for(let n of ["top","bottom","left","right","insideH","insideV","start","end","tl2br","tr2bl"]){let r=D(j$1(e,"w",n));r&&(t[n]=r);}return Object.keys(t).length>0?t:void 0}function z(e){if(!e)return;let t={},n=C(j$1(e,"w","top"));n&&(t.top=n);let r=C(j$1(e,"w","bottom"));r&&(t.bottom=r);let o=C(j$1(e,"w","left"));o&&(t.left=o);let l=C(j$1(e,"w","right"));l&&(t.right=l);let i=C(j$1(e,"w","start"));i&&(t.start=i);let a=C(j$1(e,"w","end"));if(a&&(t.end=a),Object.keys(t).length!==0)return t}function j(e){if(!e)return;let t={},n=o(e,"w","fill");n&&n!=="auto"&&(t.fill={rgb:n});let r=o(e,"w","themeFill");if(r){t.fill={themeColor:r};let a=o(e,"w","themeFillTint");a&&t.fill&&(t.fill.themeTint=a);let u=o(e,"w","themeFillShade");u&&t.fill&&(t.fill.themeShade=u);}let o$1=o(e,"w","color");o$1&&o$1!=="auto"&&(t.color={rgb:o$1});let l=o(e,"w","themeColor");l&&(t.color={...t.color??{},themeColor:l,themeTint:o(e,"w","themeTint")??void 0,themeShade:o(e,"w","themeShade")??void 0});let i=o(e,"w","val");if(i&&(t.pattern=i),Object.keys(t).length!==0)return t}function K(e){if(!e)return;let t={},n=o(e,"w","val");n&&(t.value=n.slice(0,8));let r=n?parseInt(n,16):NaN;Number.isNaN(r)||(t.firstRow=(r&32)!==0,t.lastRow=(r&64)!==0,t.firstColumn=(r&128)!==0,t.lastColumn=(r&256)!==0,t.noHBand=(r&512)!==0,t.noVBand=(r&1024)!==0);for(let[o$1,l]of [["firstRow","firstRow"],["lastRow","lastRow"],["firstColumn","firstColumn"],["lastColumn","lastColumn"],["noHBand","noHBand"],["noVBand","noVBand"]]){let i=o(e,"w",o$1);i!=null&&(t[l]=!/^(0|false|off)$/i.test(i));}if(Object.keys(t).length!==0)return t}function q(e){if(!e)return;let t={},n=o(e,"w","horzAnchor");(n==="margin"||n==="page"||n==="text")&&(t.horzAnchor=n);let r=o(e,"w","vertAnchor");(r==="margin"||r==="page"||r==="text")&&(t.vertAnchor=r);let o$1=q$1(e,"w","tblpX");o$1!==void 0&&(t.tblpX=o$1);let l=o(e,"w","tblpXSpec");l&&(t.tblpXSpec=l);let i=q$1(e,"w","tblpY");i!==void 0&&(t.tblpY=i);let a=o(e,"w","tblpYSpec");a&&(t.tblpYSpec=a);let u=q$1(e,"w","topFromText");u!==void 0&&(t.topFromText=u);let p=q$1(e,"w","bottomFromText");p!==void 0&&(t.bottomFromText=p);let f=q$1(e,"w","leftFromText");f!==void 0&&(t.leftFromText=f);let m=q$1(e,"w","rightFromText");if(m!==void 0&&(t.rightFromText=m),Object.keys(t).length!==0)return t}function me(e){return e.columnWidths&&e.columnWidths.length>0?e.columnWidths.length:e.rows.length===0?0:e.rows[0].cells.reduce((t,n)=>t+(n.formatting?.gridSpan??1),0)}function he(e){return e.rows.length}function ge(e){return e.formatting?.vMerge==="continue"}function xe(e){return e.formatting?.vMerge==="restart"}function Te(e){return e.rows.length===0?false:e.rows[0].formatting?.header===true}function ln(e){if(!e)return;let t={},n=C(j$1(e,"w","tblW"));n&&(t.width=n);let r$1=o(j$1(e,"w","jc"),"w","val");(r$1==="left"||r$1==="center"||r$1==="right"||r$1==="start")&&(t.justification=r$1==="start"?"left":r$1);let o$1=C(j$1(e,"w","tblCellSpacing"));o$1&&(t.cellSpacing=o$1);let l=C(j$1(e,"w","tblInd"));l&&(t.indent=l);let i=U(j$1(e,"w","tblBorders"));i&&(t.borders=i);let a=z(j$1(e,"w","tblCellMar"));a&&(t.cellMargins=a);let u=o(j$1(e,"w","tblLayout"),"w","type");(u==="fixed"||u==="autofit")&&(t.layout=u);let p=o(j$1(e,"w","tblStyle"),"w","val");p&&(t.styleId=p);let f=q$1(j$1(e,"w","tblStyleRowBandSize"),"w","val");f!==void 0&&f>0&&f<=1024&&(t.styleRowBandSize=f);let m=q$1(j$1(e,"w","tblStyleColBandSize"),"w","val");m!==void 0&&m>0&&m<=1024&&(t.styleColBandSize=m);let c=K(j$1(e,"w","tblLook"));c&&(t.look=c);let T=j(j$1(e,"w","shd"));T&&(t.shading=T);let g=o(j$1(e,"w","tblOverlap"),"w","val");(g==="never"||g==="overlap")&&(t.overlap=g);let A=q(j$1(e,"w","tblpPr"));return A&&(t.floating=A),r(j$1(e,"w","bidiVisual"))&&(t.bidi=true),Object.keys(t).length?t:void 0}var G=91440;function R(e,t){return n(e).find(n=>i(n.name??"")===t)??null}function I(e,t){let n=q$1(e,null,t);return n!==void 0&&Number.isFinite(n)?n:void 0}function sn(e$1){if(!e$1)return {};let t={left:I(e$1,"lIns"),right:I(e$1,"rIns"),top:I(e$1,"tIns"),bottom:I(e$1,"bIns")},n=Object.values(t).some(p=>p!==void 0),r={horz:"horizontal",vert:"vertical",vert270:"vertical270",wordArtVert:"wordArtVertical",wordArtVertRtl:"wordArtVertical",eaVert:"eastAsianVertical",mongolianVert:"mongolianVertical"},o$1={t:"top",ctr:"middle",b:"bottom",dist:"distributed",just:"justified"},l=o(e$1,null,"vert"),i=o(e$1,null,"anchor"),a=R(e$1,"normAutofit"),u={vertical:l?r[l]:void 0,rotation:e(o(e$1,null,"rot")),upright:o(e$1,null,"upright")==="1"||void 0,anchor:i?o$1[i]:void 0,anchorCenter:o(e$1,null,"anchorCtr")==="1"||void 0,columns:I(e$1,"numCol"),columnSpacing:I(e$1,"spcCol"),margins:n?t:void 0,autoFit:R(e$1,"noAutofit")?"none":a?"normal":R(e$1,"spAutoFit")?"shape":void 0,fontScale:I(a,"fontScale"),lineSpacingReduction:I(a,"lnSpcReduction")};return {...n?{margins:t}:{},...Object.values(u).some(p=>p!==void 0)?{bodyProperties:u}:{}}}function un(e){return {paragraphElements:l(e,"p"),tableElements:l(e,"tbl")}}function pn(e,t,n$1,r,o,l,i$1,a){if(!e)return [];let u=[];for(let p of n(e)){let f=i(p.name??"");f==="p"?u.push(t(p,r,o,l,i$1)):f==="tbl"&&n$1&&n$1(p,r,o,l,i$1,a);}return u}function be(e){let t=n(e).find(o=>["inline","anchor"].includes(i(o.name??"")))??null,n$1=t?m(t,"a:graphic"):null,r=n$1?m(n$1,"a:graphicData"):null;return {container:t,shape:r?m(r,"wps:wsp"):null}}function cn(e){let{shape:t}=be(e);return t?ne(t):false}function ne(e){return m(e,"wps:txbx")!==null}function ye(e,t,n,r){if(!ne(e))return null;let o$1=R(e,"spPr"),l=R(e,"bodyPr"),i=R(e,"cNvPr"),a=sn(l),u={type:"textBox",size:t,content:[]};u.id=o(i,null,"id")??void 0;let p=a$1(o$1);p&&(u.fill=p);let f=b(o$1);return f&&(u.outline=f),a.margins&&(u.margins=a.margins),a.bodyProperties&&(u.bodyProperties=a.bodyProperties),n&&(u.position=n),r&&(u.wrap=r),u}function fn(e){let{container:t$1,shape:n}=be(e);if(!t$1||!n)return null;let r=m(t$1,"wp:extent"),o$1={width:I(r,"cx")??0,height:I(r,"cy")??0},l=i(t$1.name??"")==="anchor",i$1=ye(n,o$1,l?s(t$1):void 0,l?t(t$1):void 0);return i$1&&(i$1.id=o(m(t$1,"wp:docPr"),null,"id")??i$1.id),i$1}function dn(e){return m(m(e,"wps:txbx"),"w:txbxContent")}function mn(e,t,n,r){return ye(e,t,n,r)}function we(e){return b$1(e.size.width)}function Se(e){return b$1(e.size.height)}function hn(e){return {width:we(e),height:Se(e)}}function gn(e){return {top:b$1(e.margins?.top??G),bottom:b$1(e.margins?.bottom??G),left:b$1(e.margins?.left??G),right:b$1(e.margins?.right??G)}}function xn(e){return e.position!==void 0||e.wrap!==void 0}function Tn(e){return e.fill!==void 0&&e.fill.type!=="none"}function bn(e){return e.outline!==void 0}function yn(e){return e.content.length>0}function wn(e){return e.content.map(t=>t.content.filter(n=>n.type==="run").flatMap(n=>n.content).filter(n=>n.type==="text").map(n=>n.text).join("")).join(`
2
+ `)}function Sn(e){return e.fill?.type==="solid"?c(e.fill.color):void 0}function Fn(e){return e.outline?.color?c(e.outline.color):void 0}function En(e){return e.outline?.width?b$1(e.outline.width):0}function Cn(e,t){let n=t.filter(l=>l.parentId!=null);if(n.length===0)return;let r=new Map;for(let l of n){let i=r.get(l.parentId);i?i.push(l.id):r.set(l.parentId,[l.id]);}function o(l){for(let i of l)if(i.type==="paragraph"){if(!i.content.some(u=>u.type==="commentRangeStart"||u.type==="commentRangeEnd"))continue;let a=[];for(let u of i.content)if(u.type==="commentRangeStart"){a.push(u);let p=r.get(u.id);if(p)for(let f of p)a.push({type:"commentRangeStart",id:f});}else if(u.type==="commentRangeEnd"){a.push(u);let p=r.get(u.id);if(p)for(let f of p)a.push({type:"commentRangeEnd",id:f});}else a.push(u);i.content=a;}else if(i.type==="table")for(let a of i.rows)for(let u of a.cells)o(u.content);}o(e);}function In(e,t){let n=new Set(t.map(i=>i.id)),r=t.filter(i=>i.parentId!=null&&!n.has(i.parentId));if(r.length===0)return;let o=new Map;for(let i of r){let a=o.get(i.parentId);a?a.push(i.id):o.set(i.parentId,[i.id]);}function l(i){for(let a of i)if(a.type==="paragraph"){if(!a.content.some(m=>(m.type==="insertion"||m.type==="deletion")&&o.has(m.info.id)))continue;let p=[],f=a.content;for(let m=0;m<f.length;m++){let c=f[m];if((c.type==="insertion"||c.type==="deletion")&&o.has(c.info.id)){let T=o.get(c.info.id);for(let A of T)p.push({type:"commentRangeStart",id:A});p.push(c);let g=f[m+1];g&&(g.type==="insertion"||g.type==="deletion")&&g.type!==c.type&&g.info.author===c.info.author&&g.info.date===c.info.date&&(p.push(g),m++);for(let A of T)p.push({type:"commentRangeEnd",id:A});}else p.push(c);}a.content=p;}else if(a.type==="table")for(let u of a.rows)for(let p of u.cells)l(p.content);}l(e);}export{Q as DEFAULT_TAB_ALIGNMENT,J as DEFAULT_TAB_INTERVAL_TWIPS,Jt as DEFAULT_TAB_LEADER,ft as IMAGE_LAYOUT_OPTIONS,Z as KNOWN_FIELD_TYPES,ut as calculateResizedImageDimensions,tn as calculateTabWidth,nn as calculateTabWidthWithAlignment,yt as createComplexFieldContext,ct as deriveLayoutChoice,un as extractTextBoxContentElements,wt as getFieldDisplayValue,xt as getFormatSwitch,Ot as getHyperlinkRuns,Lt as getHyperlinkText,Nt as getHyperlinkUrl,on as getLeaderCharacter,ee as getNextTabStop,Yt as getOutlineWidthPx,jt as getShapeDimensionsPx,ce as getShapeHeightPx,pe as getShapeWidthPx,me as getTableColumnCount,he as getTableRowCount,dn as getTextBoxContentElement,hn as getTextBoxDimensionsPx,Se as getTextBoxHeightPx,gn as getTextBoxMarginsPx,En as getTextBoxOutlineWidthPx,wn as getTextBoxText,we as getTextBoxWidthPx,Dt as hasContent,qt as hasFill,Te as hasHeaderRow,Tt as hasMergeFormat,Gt as hasOutline,yn as hasTextBoxContent,Tn as hasTextBoxFill,bn as hasTextBoxOutline,zt as hasTextContent,rn as hasVisibleLeader,Cn as injectReplyRangeMarkers,In as injectTCReplyRangeMarkers,ge as isCellMergeContinuation,xe as isCellMergeStart,Ct as isDateTimeField,It as isDocPropertyField,Rt as isExternalLink,Kt as isFloatingShape,xn as isFloatingTextBox,dt as isImageLayoutOptionEnabled,vt as isInternalLink,ht as isKnownFieldType,Vt as isLineShape,Mt as isMergeField,Ft as isPageNumberField,At as isReferenceField,_t as isShapeDrawing,ne as isShapeTextBox,cn as isTextBoxDrawing,Ut as isTextBoxShape,Bt as isTocField,Et as isTotalPagesField,en as mergeTabStops,D as parseBorderSpec,z as parseCellMargins,gt as parseFieldInstruction,$ as parseFieldType,q as parseFloatingTableProperties,st as parseFontTable,Pt as parseHyperlink,j as parseShading,se as parseShape,Wt as parseShapeFromDrawing,bt as parseSimpleField,fe as parseTabStop,de as parseTabStops,Qt as parseTabStopsFromParagraphProperties,U as parseTableBorders,K as parseTableLook,te as parseTableMeasurement,ln as parseTableProperties,fn as parseTextBox,pn as parseTextBoxContent,mn as parseTextBoxFromShape,Zt as resolveFillColor,Xt as resolveHyperlinkUrl,pt as resolveImageLayoutAttrs,$t as resolveOutlineColor,Sn as resolveTextBoxFillColor,Fn as resolveTextBoxOutlineColor,mt as toolbarValueToLayoutTarget};
@@ -0,0 +1,41 @@
1
+ import { Document } from '../types/document.mjs';
2
+ import { D as DocxInput } from '../docxInput-DTbCa48g.mjs';
3
+ import '../content-sSHuWw49.mjs';
4
+ import '../formatting-DoL7KBSL.mjs';
5
+ import './wrapTypes.mjs';
6
+ import '../styles-VxNcXLdi.mjs';
7
+ import '../settingsParser-CcGvtmCK.mjs';
8
+
9
+ /**
10
+ * Public DOCX parser facade.
11
+ *
12
+ * Rust S9 owns ZIP/XML parsing. TypeScript only normalizes host inputs,
13
+ * rehydrates the public `Document`, reports progress, and registers fonts.
14
+ * @packageDocumentation
15
+ * @public
16
+ */
17
+
18
+ type ProgressCallback = (stage: string, percent: number) => void;
19
+ interface ParseOptions {
20
+ onProgress?: ProgressCallback;
21
+ preloadFonts?: boolean;
22
+ parseHeadersFooters?: boolean;
23
+ parseNotes?: boolean;
24
+ detectVariables?: boolean;
25
+ }
26
+ declare function parseDocx(input: DocxInput, options?: ParseOptions): Promise<Document>;
27
+ declare function quickParseDocx(buffer: ArrayBuffer): Promise<Document>;
28
+ declare function fullParseDocx(buffer: ArrayBuffer, onProgress?: ProgressCallback): Promise<Document>;
29
+ declare function getDocxVariables(buffer: ArrayBuffer): Promise<string[]>;
30
+ declare function getDocxSummary(buffer: ArrayBuffer): Promise<{
31
+ hasDocument: boolean;
32
+ hasStyles: boolean;
33
+ hasTheme: boolean;
34
+ hasNumbering: boolean;
35
+ headerCount: number;
36
+ footerCount: number;
37
+ mediaCount: number;
38
+ variableCount: number;
39
+ }>;
40
+
41
+ export { type ParseOptions, type ProgressCallback, fullParseDocx, getDocxSummary, getDocxVariables, parseDocx, quickParseDocx };
@@ -0,0 +1 @@
1
+ export{c as fullParseDocx,e as getDocxSummary,d as getDocxVariables,a as parseDocx,b as quickParseDocx}from'../chunk-LDUWIM7M.mjs';import'../chunk-DXKG3HQ5.mjs';import'../chunk-FPZBTOD6.mjs';import'../chunk-H3JCIGWK.mjs';import'../chunk-SINEY6ZF.mjs';import'../chunk-T4EZMUXM.mjs';import'../chunk-TTRUPDAB.mjs';
@@ -0,0 +1,148 @@
1
+ import { Document } from '../types/document.mjs';
2
+ import '../content-sSHuWw49.mjs';
3
+ import '../formatting-DoL7KBSL.mjs';
4
+ import './wrapTypes.mjs';
5
+ import '../styles-VxNcXLdi.mjs';
6
+ import '../settingsParser-CcGvtmCK.mjs';
7
+
8
+ /**
9
+ * Zip-container READ facade for the DOCX open path.
10
+ *
11
+ * Backed by the inlined docx-container wasm (see ./wasm): every non-directory
12
+ * entry is inflated in Rust — with the decompression-bomb and path-traversal
13
+ * guards enforced there by construction — and exposed as a normalized, eager
14
+ * read view. Consumers pull parts by path.
15
+ *
16
+ * Read path only. The write/rezip builder assembles a parts map and hands it
17
+ * to the same wasm container via `rezipContainer` (see ./rezip).
18
+ */
19
+ /**
20
+ * Eager, normalized read view of an OPC (DOCX) container. All entries are
21
+ * already materialized; lookups are synchronous.
22
+ */
23
+ interface ZipContainerReader {
24
+ paths(): string[];
25
+ file(path: string): Uint8Array | null;
26
+ text(path: string): string | null;
27
+ }
28
+
29
+ /**
30
+ * Legacy raw-package shape retained for the public rezip compatibility
31
+ * signature. Live parsing no longer constructs it; Rust S9 owns extraction.
32
+ */
33
+ interface RawDocxContent {
34
+ documentXml: string | null;
35
+ stylesXml: string | null;
36
+ themeXml: string | null;
37
+ numberingXml: string | null;
38
+ fontTableXml: string | null;
39
+ settingsXml: string | null;
40
+ webSettingsXml: string | null;
41
+ headers: Map<string, string>;
42
+ footers: Map<string, string>;
43
+ footnotesXml: string | null;
44
+ endnotesXml: string | null;
45
+ commentsXml: string | null;
46
+ commentsExtensibleXml: string | null;
47
+ commentsExtendedXml: string | null;
48
+ documentRels: string | null;
49
+ packageRels: string | null;
50
+ contentTypesXml: string | null;
51
+ corePropsXml: string | null;
52
+ appPropsXml: string | null;
53
+ customPropsXml: string | null;
54
+ media: Map<string, ArrayBuffer>;
55
+ fonts: Map<string, ArrayBuffer>;
56
+ allXml: Map<string, string>;
57
+ container: ZipContainerReader;
58
+ originalBuffer: ArrayBuffer;
59
+ }
60
+
61
+ /**
62
+ * Part Enumeration
63
+ *
64
+ * Shared helpers for walking the parts of a DOCX package (body, headers,
65
+ * footers, footnotes, endnotes) when registering newly inserted images and
66
+ * hyperlinks against each part's rels file.
67
+ */
68
+
69
+ /**
70
+ * The assembled DOCX package as a `path -> bytes` map. Both the full-repack and
71
+ * selective-save flows build one of these and hand it to the wasm container.
72
+ */
73
+ type PartsMap = Map<string, Uint8Array>;
74
+ /**
75
+ * Find the highest rId number in a relationships XML string.
76
+ */
77
+ declare function findMaxRId(relsXml: string): number;
78
+
79
+ /**
80
+ * Empty DOCX Template
81
+ *
82
+ * Produces a minimal valid DOCX package — Content Types, package + document
83
+ * rels, an empty body with the standard letter-size section, default
84
+ * Calibri 11 styles, and core/app properties. Used as the base for
85
+ * `createDocx()` when the caller has no existing buffer.
86
+ */
87
+ /**
88
+ * Create a new empty DOCX file.
89
+ *
90
+ * @returns Promise resolving to minimal DOCX as ArrayBuffer
91
+ */
92
+ declare function createEmptyDocx(): Promise<ArrayBuffer>;
93
+
94
+ /**
95
+ * Public DOCX package I/O wrappers.
96
+ *
97
+ * Model serialization and selective package writing are Rust-owned. The
98
+ * TypeScript kept here is compatibility glue for public ZIP utilities and host
99
+ * values; package inflation/deflation continues through `docx-container` wasm.
100
+ * @packageDocumentation
101
+ * @public
102
+ */
103
+
104
+ declare const COMMENTS_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml";
105
+ declare const COMMENTS_EXTENDED_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml";
106
+ declare const COMMENTS_IDS_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.commentsIds+xml";
107
+ declare const COMMENTS_EXTENSIBLE_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtensible+xml";
108
+ interface RepackOptions {
109
+ /** Retained for signature compatibility; `docx-container` chooses compression. */
110
+ compressionLevel?: number;
111
+ updateModifiedDate?: boolean;
112
+ modifiedBy?: string;
113
+ }
114
+ /** Repack a public Document through the live Rust S13 writer. */
115
+ declare function repackDocx(doc: Document, options?: RepackOptions): Promise<ArrayBuffer>;
116
+ declare function repackDocxFromRaw(doc: Document, rawContent: RawDocxContent, options?: RepackOptions): Promise<ArrayBuffer>;
117
+ declare function updateDocumentXml(originalBuffer: ArrayBuffer, newDocumentXml: string, options?: RepackOptions): Promise<ArrayBuffer>;
118
+ declare function updateXmlFile(originalBuffer: ArrayBuffer, path: string, content: string, options?: RepackOptions): Promise<ArrayBuffer>;
119
+ declare function updateMultipleFiles(originalBuffer: ArrayBuffer, updates: Map<string, string | ArrayBuffer>, options?: RepackOptions): Promise<ArrayBuffer>;
120
+ declare function applyUpdatesToZip(pkg: PartsMap, updates: Map<string, string | ArrayBuffer>, _options?: RepackOptions): Promise<ArrayBuffer>;
121
+ declare function addRelationship(originalBuffer: ArrayBuffer, relationship: {
122
+ type: string;
123
+ target: string;
124
+ targetMode?: 'External' | 'Internal';
125
+ }): Promise<{
126
+ buffer: ArrayBuffer;
127
+ rId: string;
128
+ }>;
129
+ declare function addMedia(originalBuffer: ArrayBuffer, filename: string, data: ArrayBuffer, mimeType: string): Promise<{
130
+ buffer: ArrayBuffer;
131
+ rId: string;
132
+ path: string;
133
+ }>;
134
+ declare function updateCoreProperties(corePropsXml: string, options: {
135
+ updateModifiedDate?: boolean;
136
+ modifiedBy?: string;
137
+ }): string;
138
+ declare function validateDocx(buffer: ArrayBuffer): Promise<{
139
+ valid: boolean;
140
+ errors: string[];
141
+ warnings: string[];
142
+ }>;
143
+ declare function isDocxBuffer(buffer: ArrayBuffer): boolean;
144
+ declare function createDocx(doc: Document): Promise<ArrayBuffer>;
145
+ /** Compatibility helper for callers that update header/footer parts directly. */
146
+ declare function collectHeaderFooterUpdates(doc: Document): Map<string, string>;
147
+
148
+ export { COMMENTS_CONTENT_TYPE, COMMENTS_EXTENDED_CONTENT_TYPE, COMMENTS_EXTENSIBLE_CONTENT_TYPE, COMMENTS_IDS_CONTENT_TYPE, type PartsMap, type RepackOptions, addMedia, addRelationship, applyUpdatesToZip, collectHeaderFooterUpdates, createDocx, createEmptyDocx, repackDocx as default, findMaxRId, isDocxBuffer, repackDocx, repackDocxFromRaw, updateCoreProperties, updateDocumentXml, updateMultipleFiles, updateXmlFile, validateDocx };
@@ -0,0 +1 @@
1
+ export{d as COMMENTS_CONTENT_TYPE,e as COMMENTS_EXTENDED_CONTENT_TYPE,g as COMMENTS_EXTENSIBLE_CONTENT_TYPE,f as COMMENTS_IDS_CONTENT_TYPE,o as addMedia,n as addRelationship,m as applyUpdatesToZip,t as collectHeaderFooterUpdates,s as createDocx,c as createEmptyDocx,u as default,a as findMaxRId,r as isDocxBuffer,h as repackDocx,i as repackDocxFromRaw,p as updateCoreProperties,j as updateDocumentXml,l as updateMultipleFiles,k as updateXmlFile,q as validateDocx}from'../chunk-KVKLLTDP.mjs';import'../chunk-BIQWVK5P.mjs';import'../chunk-H3JCIGWK.mjs';import'../chunk-N5Q3YN64.mjs';import'../chunk-SINEY6ZF.mjs';import'../chunk-T4EZMUXM.mjs';import'../chunk-TTRUPDAB.mjs';
@@ -0,0 +1,42 @@
1
+ import { Document } from '../../types/document.mjs';
2
+ import { c as DocumentBody, S as SectionProperties, B as BlockContent, C as Comment, E as Endnote, F as Footnote, m as HeaderFooter, P as Paragraph, R as Run, T as Table } from '../../content-sSHuWw49.mjs';
3
+ import '../../formatting-DoL7KBSL.mjs';
4
+ import '../../styles-VxNcXLdi.mjs';
5
+ import '../../settingsParser-CcGvtmCK.mjs';
6
+ import '../wrapTypes.mjs';
7
+
8
+ /**
9
+ * DOCX XML serializers.
10
+ *
11
+ * The public synchronous serializer surface is retained for compatibility, but
12
+ * all OOXML emission is owned by the Rust writer. The fixed context only
13
+ * supplies deterministic IDs to standalone XML calls; package saves use the
14
+ * source-package hash and clock through {@link ../rustSaveFacade}.
15
+ * @packageDocumentation
16
+ * @public
17
+ */
18
+
19
+ /** Serialize a single block content item. */
20
+ declare function serializeBlockContent(block: BlockContent): string;
21
+ /** Serialize a complete `word/document.xml` part. */
22
+ declare function serializeDocument(doc: Document): string;
23
+ /** Serialize the contents of `w:body`, without the body tags. */
24
+ declare function serializeDocumentBody(body: DocumentBody): string;
25
+ /** Serialize section properties. */
26
+ declare function serializeSectionProperties(props: SectionProperties | undefined): string;
27
+ /** Serialize one paragraph. */
28
+ declare function serializeParagraph(paragraph: Paragraph): string;
29
+ /** Serialize one run. */
30
+ declare function serializeRun(run: Run): string;
31
+ /** Serialize one table. */
32
+ declare function serializeTable(table: Table): string;
33
+ /** Serialize a header or footer part. */
34
+ declare function serializeHeaderFooter(hf: HeaderFooter): string;
35
+ /** Serialize the comments part. */
36
+ declare function serializeComments(comments: Comment[]): string;
37
+ /** Serialize the footnotes part. */
38
+ declare function serializeFootnotes(footnotes: Footnote[]): string;
39
+ /** Serialize the endnotes part. */
40
+ declare function serializeEndnotes(endnotes: Endnote[]): string;
41
+
42
+ export { serializeBlockContent, serializeComments, serializeDocument, serializeDocumentBody, serializeEndnotes, serializeFootnotes, serializeHeaderFooter, serializeParagraph, serializeRun, serializeSectionProperties, serializeTable };
@@ -0,0 +1 @@
1
+ export{a as serializeBlockContent,i as serializeComments,b as serializeDocument,c as serializeDocumentBody,k as serializeEndnotes,j as serializeFootnotes,h as serializeHeaderFooter,e as serializeParagraph,f as serializeRun,d as serializeSectionProperties,g as serializeTable}from'../../chunk-N5Q3YN64.mjs';import'../../chunk-SINEY6ZF.mjs';import'../../chunk-T4EZMUXM.mjs';import'../../chunk-TTRUPDAB.mjs';
@@ -0,0 +1,19 @@
1
+ /**
2
+ * OOXML image wrap-type taxonomy.
3
+ *
4
+ * `wp:inline` flows in the line. `wp:anchor` covers all positioned variants:
5
+ * - `square` / `tight` / `through` — text wraps around the image
6
+ * - `topAndBottom` — text breaks above and below
7
+ * - `behind` / `inFront` (`wp:wrapNone`) — image paints out of flow
8
+ * @packageDocumentation
9
+ * @public
10
+ */
11
+ type WrapType = 'inline' | 'square' | 'tight' | 'through' | 'topAndBottom' | 'behind' | 'inFront';
12
+ /** True for wrap types that anchor at a position (i.e. not `inline`, not `topAndBottom`). */
13
+ declare function isFloatingWrapType(wrapType: string | undefined): boolean;
14
+ /** True for `wp:wrapNone` variants (`behind` / `inFront`) — positioned but ignore text-flow. */
15
+ declare function isWrapNone(wrapType: string | undefined): boolean;
16
+ /** True for wrap types where text flows around the image (`square` / `tight` / `through`). */
17
+ declare function wrapsAroundText(wrapType: string | undefined): boolean;
18
+
19
+ export { type WrapType, isFloatingWrapType, isWrapNone, wrapsAroundText };
@@ -0,0 +1 @@
1
+ export{a as isFloatingWrapType,b as isWrapNone,c as wrapsAroundText}from'../chunk-OBQGPMPQ.mjs';import'../chunk-TTRUPDAB.mjs';
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Flexible input types for DOCX documents.
3
+ *
4
+ * Accepts any common binary format so consumers don't need to manually
5
+ * convert before passing data to the editor or parser.
6
+ */
7
+ /**
8
+ * Any binary representation of a DOCX file that the editor can consume.
9
+ *
10
+ * - `ArrayBuffer` — from `FileReader.readAsArrayBuffer()` or `fetch().arrayBuffer()`
11
+ * - `Uint8Array` — from Node.js `fs.readFile()` or streaming APIs
12
+ * - `Blob` — from drag-and-drop or `<input type="file">`
13
+ * - `File` — subclass of Blob, from `<input type="file">`
14
+ */
15
+ type DocxInput = ArrayBuffer | Uint8Array | Blob | File;
16
+ /**
17
+ * Normalize any {@link DocxInput} into an `ArrayBuffer` for internal use.
18
+ */
19
+ declare function toArrayBuffer(input: DocxInput): Promise<ArrayBuffer>;
20
+
21
+ export { type DocxInput as D, toArrayBuffer as t };
@@ -0,0 +1,170 @@
1
+ import { P as PageMargins, C as ColumnLayout, e as LayoutBlock, B as BlockExtent, a as Layout, H as HeaderFooterContent, h as FootnoteRenderItem } from '../types-DNrYr6yQ.mjs';
2
+ import { t as toMeasuredBlocks } from '../measuredBlock-DZwz8zhD.mjs';
3
+ import { L as LayoutPaginationSource } from '../rustPagination-Bj2hq013.mjs';
4
+ import { Document } from '../types/document.mjs';
5
+ import { a as Theme } from '../formatting-DoL7KBSL.mjs';
6
+ import { S as SectionProperties, m as HeaderFooter, W as Watermark } from '../content-sSHuWw49.mjs';
7
+ import { F as FloatPageGeometry } from '../measureBlocksPipeline-Df0Bbrwy.mjs';
8
+ import { a as DisplayListHeadersFooters } from '../rustDisplayList-dqunvwxH.mjs';
9
+ import { a as StyleDefinitions } from '../styles-VxNcXLdi.mjs';
10
+ import '../settingsParser-CcGvtmCK.mjs';
11
+ import '../docx/wrapTypes.mjs';
12
+
13
+ /**
14
+ * The pure layout COMPUTE pass shared by the React and Vue adapters — issue
15
+ * #696 Tier 2, the clean half of the engine spine.
16
+ *
17
+ * This is the 6-step pass from React's `useLayoutPipeline` minus the paint
18
+ * + scroll/event side-effects (which stay adapter-side, where the framework
19
+ * timing lives): PM doc → flow blocks → measure → header/footer resolve →
20
+ * margin extension → Rust pagination (+ two-pass footnote stabilization) →
21
+ * footnote render items. It is pure (no DOM, no refs, no rAF) and returns
22
+ * everything the adapter needs to render.
23
+ *
24
+ * Two injected seams: `measureBlocks` (each adapter passes the Rust
25
+ * measurement implementation) and `paginationSource` (the mandatory Rust
26
+ * pagination engine — every pagination pass, including each footnote
27
+ * stabilization iteration, runs through it). `getHfPmDoc` is the
28
+ * HF-unification seam (prefer the persistent PM doc over re-parsing
29
+ * `HeaderFooter.content`).
30
+ */
31
+
32
+ interface PageSizePx {
33
+ w: number;
34
+ h: number;
35
+ }
36
+ /** Adapter-supplied block measurer (React's is caching). */
37
+ type MeasureBlocksFn = (blocks: LayoutBlock[], contentWidth: number | number[], pageGeometry?: FloatPageGeometry) => BlockExtent[];
38
+ interface ComputeLayoutInputs {
39
+ /** Legacy tree state; null when an adapter supplies yrs body blocks. */
40
+ state: {
41
+ readonly doc: {
42
+ readonly attrs: Record<string, any>;
43
+ };
44
+ } | null;
45
+ document: Document | null;
46
+ pageSize: PageSizePx;
47
+ margins: PageMargins;
48
+ columns: ColumnLayout | undefined;
49
+ finalPageSize: PageSizePx;
50
+ finalMargins: PageMargins;
51
+ finalColumns: ColumnLayout | undefined;
52
+ pageGap: number;
53
+ contentWidth: number;
54
+ theme: Theme | null | undefined;
55
+ styles: StyleDefinitions | null | undefined;
56
+ sectionProperties: SectionProperties | null | undefined;
57
+ finalSectionProperties: SectionProperties | null | undefined;
58
+ /** Resolved HF objects for the section (default + first-page). */
59
+ headerContent: HeaderFooter | null | undefined;
60
+ footerContent: HeaderFooter | null | undefined;
61
+ firstPageHeaderContent: HeaderFooter | null | undefined;
62
+ firstPageFooterContent: HeaderFooter | null | undefined;
63
+ /** Optional adapter-owned body source; null falls back to ProseMirror lowering. */
64
+ yrsBodyBlocks?: (env: {
65
+ pageContentHeight: number;
66
+ }) => LayoutBlock[] | null;
67
+ /** Optional adapter-owned non-body story source; null preserves PM lowering. */
68
+ yrsStoryBlocks?: (storyId: string) => LayoutBlock[] | null;
69
+ measureBlocks: MeasureBlocksFn;
70
+ /**
71
+ * The mandatory Rust pagination engine
72
+ * (`layout/pagination/rustPagination.ts`). Every pagination pass — full,
73
+ * footnote pass 1, and each footnote-stabilization iteration — runs
74
+ * `paginationSource.paginate(measured, options)`. The caller must gate
75
+ * layout passes on the source's readiness (`isReady()` / `whenReady()`);
76
+ * `paginate` throws on an unloaded engine or an engine failure and the
77
+ * pipeline surfaces the error.
78
+ *
79
+ * The Rust engine keeps no resume checkpoints: every pass is a full
80
+ * relayout in native code — the measured wager that replaced the TS
81
+ * incremental/off-thread kernels.
82
+ */
83
+ paginationSource: LayoutPaginationSource;
84
+ }
85
+ interface LayoutComputation {
86
+ blocks: LayoutBlock[];
87
+ measures: BlockExtent[];
88
+ layout: Layout;
89
+ headerContentForRender: HeaderFooterContent | undefined;
90
+ footerContentForRender: HeaderFooterContent | undefined;
91
+ firstPageHeaderForRender: HeaderFooterContent | undefined;
92
+ firstPageFooterForRender: HeaderFooterContent | undefined;
93
+ hasTitlePg: boolean;
94
+ watermark: Watermark | undefined;
95
+ headerDistancePx: number | undefined;
96
+ footerDistancePx: number | undefined;
97
+ pageBorders: SectionProperties['pageBorders'] | undefined;
98
+ footnotesByPage: Map<number, FootnoteRenderItem[]> | undefined;
99
+ }
100
+ /**
101
+ * The `{ measured, options }` pair a Layout was paginated from, when that
102
+ * Layout came out of a compute call in this session, plus the `headersFooters`
103
+ * payload assembled from the same HF contents/page-level watermark the pages
104
+ * render with. The canvas renderer joins this with the Layout itself into the
105
+ * `{ measured, options, layout, headersFooters }` envelope the Rust
106
+ * display-list builder consumes. Every compute path (including footnote
107
+ * stabilization) records its final layout here; undefined means the Layout
108
+ * did not come from a compute call in this session.
109
+ */
110
+ declare function getLayoutKernelInputs(layout: Layout): {
111
+ measured: ReturnType<typeof toMeasuredBlocks>;
112
+ options: unknown;
113
+ headersFooters?: DisplayListHeadersFooters;
114
+ } | undefined;
115
+ /**
116
+ * Run the pure layout compute pass (the 6 steps in this file's header).
117
+ * Every pagination pass runs through the injected Rust pagination source —
118
+ * the sole layout kernel. The wasm engine is synchronous native code, so
119
+ * edits and opens alike take this one full-pass path (the Rust engine keeps
120
+ * no resume checkpoints; incremental resume and the off-thread worker died
121
+ * with the TS kernel).
122
+ */
123
+ declare function computeLayout(inputs: ComputeLayoutInputs): LayoutComputation;
124
+
125
+ /**
126
+ * rAF-coalescing layout scheduler shared by the React and Vue adapters
127
+ * (issue #696 Tier 2). Rapid doc-changing transactions (a burst of
128
+ * keystrokes) collapse to a single layout pass per animation frame: while a
129
+ * frame is pending, later `schedule` calls just replace the target state, so
130
+ * only the final state lays out.
131
+ *
132
+ * `scheduleFrame`/`cancelFrame` are injected so a headless/test host can pass
133
+ * a synchronous stub; they default to requestAnimationFrame.
134
+ */
135
+ interface LayoutScheduler<TState = unknown> {
136
+ /** Request a layout for `state`, coalesced into the pending frame. */
137
+ schedule(state: TState): void;
138
+ /** Cancel any pending frame (call on teardown). */
139
+ cancel(): void;
140
+ }
141
+ declare function createLayoutScheduler<TState>(run: (state: TState) => void, scheduleFrame?: (cb: () => void) => number, cancelFrame?: (handle: number) => void): LayoutScheduler<TState>;
142
+
143
+ /**
144
+ * Strip ProseMirror's internal `UPDATED_SCROLL` flag from a transaction so the
145
+ * hidden, off-screen editor's `updateState` does not force-scroll its ancestors
146
+ * to the selection — the paginated painter owns scroll, not the PM view.
147
+ *
148
+ * Shared by both adapters' `dispatchTransaction` (issue #696 Tier 2). React has
149
+ * always done this; Vue did not, so its hidden editor could yank an ancestor's
150
+ * scroll on edit. Centralizing the magic bit + the drift canary here keeps the
151
+ * two in lockstep.
152
+ *
153
+ * `Transaction.updated` is a private bitfield in `prosemirror-state` whose
154
+ * `UPDATED_SCROLL` bit is not exported. It is `4` in current PM
155
+ * (state/src/transaction.ts). If a future PM release renumbers the bits before
156
+ * SCROLL, `assertScrollFlagShape` logs once so the constant can be updated.
157
+ */
158
+ /** Minimal transaction shape used by the legacy scroll-flag compatibility seam. */
159
+ interface ScrollFlagTransaction {
160
+ scrollIntoView(): ScrollFlagTransaction;
161
+ }
162
+ /**
163
+ * Clear the scroll-into-view flag on `transaction` in place. Call inside
164
+ * `dispatchTransaction` before `state.apply(transaction)`. `probeTr` should be
165
+ * a fresh `view.state.tr` used only for the one-shot drift canary (so the real
166
+ * transaction is never mutated by the probe).
167
+ */
168
+ declare function stripScrollFlag(transaction: ScrollFlagTransaction, probeTr: ScrollFlagTransaction): void;
169
+
170
+ export { type ComputeLayoutInputs, type LayoutComputation, type LayoutScheduler, type MeasureBlocksFn, computeLayout, createLayoutScheduler, getLayoutKernelInputs, stripScrollFlag };
@@ -0,0 +1 @@
1
+ import {I,f as f$1,w,g,j,e,n,o,l,a as a$1,C,t,b}from'../chunk-P3KDV4M2.mjs';import {f,g as g$1}from'../chunk-7DEIW7FL.mjs';import {c}from'../chunk-IL5JZJT7.mjs';import'../chunk-GWKJ2Y4Y.mjs';import'../chunk-52GB3Y42.mjs';import {a}from'../chunk-7PCO5I2O.mjs';import {d}from'../chunk-X4XDO3LZ.mjs';import'../chunk-L5ISVQ3W.mjs';import'../chunk-OMR3TWCD.mjs';import {e as e$1}from'../chunk-XWUOLYRQ.mjs';import'../chunk-HJGAQIU7.mjs';import'../chunk-FZIA7OFY.mjs';import'../chunk-OBQGPMPQ.mjs';import'../chunk-3UBMCDME.mjs';import'../chunk-FPZBTOD6.mjs';import'../chunk-H3JCIGWK.mjs';import'../chunk-SINEY6ZF.mjs';import'../chunk-T4EZMUXM.mjs';import'../chunk-TTRUPDAB.mjs';function fe(t,a){let r=t?.package?.document;if(!r)return;let o=[...(r.sections??[]).map(n=>n.properties),r.finalSectionProperties];return a.sectionIndex!==void 0?o[a.sectionIndex]??r.finalSectionProperties:o.find(n=>(n?.footnoteColumns??1)>1)??o[0]}function le(t){let a=t?.package?.document;return a?[...(a.sections??[]).map(r=>r.properties),a.finalSectionProperties]:[]}function me(t,a){let r={},o=(n,c,e)=>{let i=`${n}${c==="default"?"Default":c==="first"?"First":"Even"}`;r[i]=e;};for(let n=0;n<=a;n++){let c=t[n];for(let e of c?.headerReferences??[])o("header",e.type,e.rId);for(let e of c?.footerReferences??[])o("footer",e.type,e.rId);}return Object.keys(r).length?r:void 0}function Me(t,a){let{document:r,sectionProperties:o}=t.inputs,n=le(r),c=new Map;for(let e of a.pages){let s=e.sectionIndex??(n.length===1?0:void 0);e.sectionIndex===void 0&&s!==void 0&&(e.sectionIndex=s);let i=s!==void 0?n[s]??o:o;if(!i){t.watermark!==void 0&&e.watermark===void 0&&(e.watermark=t.watermark);continue}if(s!==void 0){let f=e.sectionId??String(s),l=c.get(f)??0,m=e.sectionPageIndex??l;c.set(f,Math.max(l,m)+1),e.sectionPageIndex=m,e.headerFooterRefs??(e.headerFooterRefs=me(n,s));let d=e.pageNumbering??i.pageNumbering;if(d){e.pageNumbering=d;let u=e.sectionPageNumber??(d.start??1)+m;e.sectionPageNumber=u,e.pageLabel??(e.pageLabel=e$1(u,d.format??"decimal"));}}e.headerDistance===void 0&&i.headerDistance!=null&&(e.headerDistance=C(i.headerDistance)),e.footerDistance===void 0&&i.footerDistance!=null&&(e.footerDistance=C(i.footerDistance)),e.pageBorders??(e.pageBorders=i.pageBorders),e.watermark??(e.watermark=i.watermark??t.watermark),e.verticalAlign??(e.verticalAlign=i.verticalAlign);}}function xe(t,a,r){let o=fe(t,a);if(!o?.footnoteColumns)return {columns:1,columnWidth:r};let n=o.footnoteColumns,e=((o.pageWidth!=null?C(o.pageWidth-(o.marginLeft??1440)-(o.marginRight??1440)):r)-(n-1)*b)/n;return {columns:n,columnWidth:Math.max(1,e)}}var pe=new WeakMap;function Be(t,a){return Me(t,a),pe.set(a,{measured:t.measured,options:t.layoutOpts,headersFooters:Ie(t,a.pages)}),a}function De(t,a){let r=String(a.length),o=[],n=(c,e)=>{let s=g$1(c,e);return s.active?s.width:void 0};for(let c of t.blocks)if(c.kind==="paragraph")for(let e of c.runs){if(e.kind!=="field"||e.fieldType!=="PAGE"&&e.fieldType!=="NUMPAGES"||e.pmStart===void 0)continue;let s={fontFamily:e.fontFamily??"Calibri",fontSize:e.fontSize??11,bold:e.bold,italic:e.italic},i=n(e.fallback||"1",s);if(i===void 0)continue;let f=[],l=true;for(let m of a){let d=n(e.fieldType==="NUMPAGES"?r:m.pageLabel??String(m.number),s);if(d===void 0){l=false;break}f.push(d);}l&&o.push({pmStart:e.pmStart,fallbackWidth:i,perPage:f});}return o.length>0?o:void 0}function Ie(t,a$1){let{inputs:r,hasTitlePg:o}=t,n=r.document?.package,c=(l,m)=>{if(!(!l||!m)){for(let[d,u]of l)if(u===m)return d}},e=[],s=(l,m,d,u)=>{if(!u||u.blocks.length===0)return;let g=De(u,a$1);e.push({rId:c(l==="header"?n?.headers:n?.footers,d)??"",kind:l,type:m,measured:a(u.blocks,u.measures),height:u.height,...u.flowHeight!==void 0?{flowHeight:u.flowHeight}:{},...u.visualTop!==void 0?{visualTop:u.visualTop}:{},...u.visualBottom!==void 0?{visualBottom:u.visualBottom}:{},...g?{fieldWidths:g}:{}});};s("header","default",r.headerContent,t.headerContentForRender),s("footer","default",r.footerContent,t.footerContentForRender),s("header","first",r.firstPageHeaderContent,t.firstPageHeaderForRender),s("footer","first",r.firstPageFooterContent,t.firstPageFooterForRender),s("header","even",t.evenPageHeader,t.evenPageHeaderForRender),s("footer","even",t.evenPageFooter,t.evenPageFooterForRender);let i=t.watermark;if(e.length===0&&!i)return;let{sectionProperties:f}=r;return {titlePg:o,evenAndOddHeaders:t.evenAndOddHeaders,...f?.headerDistance!=null?{headerDistance:C(f.headerDistance)}:{},...f?.footerDistance!=null?{footerDistance:C(f.footerDistance)}:{},...i?{watermark:i}:{},variants:e}}function we(t){return pe.get(t)}function Ee(t){let a=Oe(t),{layout:r,footnotesByPage:o}=a.hasFootnotes?We(a):{layout:t.paginationSource.paginate(a.measured,a.layoutOpts),footnotesByPage:void 0};return Be(a,r),_e(a,r,o)}function Oe(t$1){f();let{state:a$1,document:r,pageSize:o,margins:n,columns:c$1,finalPageSize:e,finalMargins:s,finalColumns:i,pageGap:f$2,contentWidth:l,theme:m,styles:d$1,sectionProperties:u,finalSectionProperties:g,headerContent:b,footerContent:C,firstPageHeaderContent:R,firstPageFooterContent:L,measureBlocks:k}=t$1,p=o.h-n.top-n.bottom,y=t$1.yrsBodyBlocks?.({pageContentHeight:p})??(a$1?c(a$1.doc,{theme:m,pageContentHeight:p}):(()=>{throw new Error("computeLayout requires either yrsBodyBlocks or a ProseMirror state")})()),h=I(y,{pageSize:o,margins:n,columns:c$1},{pageSize:e,margins:s,columns:i});let F=k(y,h,d({size:o,margins:n})),T=f$1(y),D=T.some(P=>P.noteKind==="endnote"?!!r?.package?.endnotes?.length:!!r?.package?.footnotes?.length),I$1={section:"header",pageSize:o,margins:n},w$1={section:"footer",pageSize:o,margins:n},he=a$1?.doc.attrs?.defaultTabStopTwips??r?.package.settings?.defaultTabStop??null,Pe={styles:d$1,theme:m,measureBlocks:k,defaultTabStopTwips:he,yrsStoryBlocks:t$1.yrsStoryBlocks},Fe=P=>{let v=r?.package;if(v){for(let x of [v.headers,v.footers])if(x){for(let[ve,Te]of x)if(Te===P)return `hf:${ve}`}}},H=(P,v)=>{if(!P)return;let x=t$1.yrsStoryBlocks?Fe(P):void 0;return t(P,l,v,Pe,x)},K=H(b,I$1),G=H(C,w$1),E=u?.titlePg===true,U=E?H(R,I$1):void 0,$=E?H(L,w$1):void 0,V=le(r),be=Math.max(0,V.findIndex(P=>P===u)),M=me(V,be),q=M?.headerEven?r?.package?.headers?.get(M.headerEven):void 0,j=M?.footerEven?r?.package?.footers?.get(M.footerEven):void 0,X=H(q,I$1),J=H(j,w$1),Le=r?.package?.settings?.evenAndOddHeaders===true||u?.evenAndOddHeaders===true,ke=a$1?.doc.attrs?.watermark??g?.watermark??void 0,{margins:Se,finalMargins:Ce}=w({pageSize:o,margins:n,finalMargins:s,bodyBlocks:y,headers:[K,U,X],footers:[G,$,J],warn:P=>console.warn(`[computeLayout] ${P}`)}),He=g?.sectionStart,Re={pageSize:o,margins:Se,finalPageSize:e,finalMargins:Ce,columns:i,bodyBreakType:He,pageGap:f$2};return {measured:a(y,F),layoutOpts:Re,hasFootnotes:D,footnoteRefs:T,blocks:y,measures:F,headerContentForRender:K,footerContentForRender:G,firstPageHeaderForRender:U,firstPageFooterForRender:$,evenPageHeader:q,evenPageFooter:j,evenPageHeaderForRender:X,evenPageFooterForRender:J,evenAndOddHeaders:Le,hasTitlePg:E,watermark:ke,inputs:t$1}}function We(t){let{measured:a,layoutOpts:r,footnoteRefs:o$1,blocks:n$1,measures:c,inputs:e$1}=t,{document:s,contentWidth:i,styles:f,theme:l,measureBlocks:m,state:d}=e$1,u=d?.doc.attrs?.defaultTabStopTwips??s?.package.settings?.defaultTabStop??null,g$1=(h,F)=>e$1.paginationSource.paginate(h,F),b=g$1(a,r),C=g(b.pages,o$1),R=new Map,L=new Map;for(let h of b.pages){let{columns:F,columnWidth:T}=xe(s,h,i);R.set(h.number,F);for(let D of C.get(h.number)??[])L.set(D,T);}let k=Ae(o$1,b.pages,s,C),p=j(s.package.footnotes??[],s.package.endnotes??[],o$1,h=>L.get(e(h))??i,{styles:f??void 0,theme:l??null,measureBlocks:m,defaultTabStopTwips:u,yrsStoryBlocks:e$1.yrsStoryBlocks},k),y=n({blocks:n$1,measures:c,layoutOpts:r,paginate:g$1,footnoteRefs:o$1,footnoteContentMap:p,initialLayout:b,footnoteColumns:R,mapReferencesToPages:(h,F)=>Ne(h,F,s)});return ze(y.layout,y.pageFootnoteMap,p,s),{layout:y.layout,footnotesByPage:o(y.pageFootnoteMap,p,s)}}function _(t,a,r){let o=t?.package?.settings,n=fe(t,a);return r==="endnote"?{...o?.endnotePr??{},...n?.endnotePr??{}}:{...o?.footnotePr??{},...n?.footnotePr??{}}}function ge(t,a,r){let o=[...a].find(([,n])=>n.includes(r))?.[0];return t.find(n=>n.number===o)}function Ne(t,a,r){let o=g(t,a),n=new Map,c=(e,s)=>{let i=n.get(e)??[];i.includes(s)||i.push(s),n.set(e,i);};for(let e$1 of a){let s=e(e$1),i=ge(t,o,s);if(!i)continue;let f=e$1.noteKind??"footnote",m=_(r,i,f).position??(f==="endnote"?"docEnd":"pageBottom"),d=i;if(m==="docEnd")d=t[t.length-1]??i;else if(m==="sectEnd"){let u=t.filter(g=>i.sectionId!==void 0?g.sectionId===i.sectionId:i.sectionIndex!==void 0?g.sectionIndex===i.sectionIndex:true);d=u[u.length-1]??i;}c(d.number,s);}return n}function Ae(t,a,r,o){let n=new Map,c=new Map;for(let e$2 of t){let s=e(e$2);if(n.has(s))continue;let i=ge(a,o,s);if(!i)continue;let f=e$2.noteKind??"footnote",l=_(r,i,f),m=l.numRestart==="eachPage"?`${f}:page:${i.number}`:l.numRestart==="eachSect"?`${f}:section:${i.sectionId??i.sectionIndex??0}`:`${f}:continuous`,d=c.get(m)??l.numStart??1;c.set(m,d+1),n.set(s,{displayNumber:d,displayLabel:e$1(d,l.numFmt??"decimal"),anchor:{docStart:e$2.pmPos,docEnd:e$2.pmPos+1}});}return n}function ze(t,a,r,o){for(let n of t.pages){let c=a.get(n.number);if(!c?.length)continue;let e=c.map(d=>r.get(d)).filter(d=>d!==void 0);if(!e.length)continue;let s=n.size.h-n.margins.bottom,i=n.fragments.reduce((d,u)=>Math.max(d,u.y+u.height),n.margins.top),f=new Map;for(let d of e){let u=d.noteKind??"footnote",g=f.get(u)??[];g.push(d),f.set(u,g);}let l$1=s,m=i;n.noteAreas=[...f].map(([d,u])=>{let b=_(o,n,d).position??(d==="endnote"?"docEnd":"pageBottom"),C=d==="footnote"?n.footnoteColumns??1:1,L=l(u,C).reduce((p,y)=>Math.max(p,y.reduce((h,F)=>h+F.height,0)),0)+a$1,k;return b==="beneathText"?(k=Math.min(m,s-L),m=k+L):(l$1-=L,k=l$1),{kind:d,placement:b,y:k,height:L,columns:C,sectionId:n.sectionId,notes:u.map(p=>({kind:d,id:p.id,displayLabel:p.displayLabel??String(p.displayNumber),blocks:p.blocks,measures:p.measures,height:p.height,anchorDocStart:p.anchor?.docStart,anchorDocEnd:p.anchor?.docEnd,customMarkFollows:p.customMarkFollows}))}});}}function _e(t,a,r){let{sectionProperties:o}=t.inputs;return {blocks:t.blocks,measures:t.measures,layout:a,headerContentForRender:t.headerContentForRender,footerContentForRender:t.footerContentForRender,firstPageHeaderForRender:t.firstPageHeaderForRender,firstPageFooterForRender:t.firstPageFooterForRender,hasTitlePg:t.hasTitlePg,watermark:t.watermark,headerDistancePx:o?.headerDistance!=null?C(o.headerDistance):void 0,footerDistancePx:o?.footerDistance!=null?C(o.footerDistance):void 0,pageBorders:o?.pageBorders,footnotesByPage:r?.size?r:void 0}}function Ke(t,a=o=>requestAnimationFrame(o),r=o=>cancelAnimationFrame(o)){let o=null;return {schedule(n){if(o){o.state=n;return}o={handle:0,state:n};let c=a(()=>{let e=o;o=null,e&&t(e.state);});o&&(o.handle=c);},cancel(){o&&(r(o.handle),o=null);}}}var ye=false;function Ge(t){if(!ye){ye=true;try{let a=t.scrollIntoView();(typeof a.updated!="number"||(a.updated&4)===0)&&console.warn("[docx-editor] prosemirror-state UPDATED_SCROLL bit shape changed; paginated scroll suppression may be stale. Update PM_UPDATED_SCROLL.");}catch{}}}function Ue(t,a){Ge(a);let r=t;typeof r.updated=="number"&&(r.updated&=-5);}export{Ee as computeLayout,Ke as createLayoutScheduler,we as getLayoutKernelInputs,Ue as stripScrollFlag};
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Structural mark contract consumed by the legacy tree-to-layout adapter.
3
+ * @public
4
+ */
5
+ interface EditorTreeMark {
6
+ readonly type: {
7
+ readonly name: string;
8
+ };
9
+ readonly attrs: Record<string, any>;
10
+ }
11
+ /**
12
+ * Structural node contract consumed by renderer-side tree walkers.
13
+ *
14
+ * The contract deliberately describes only the immutable tree operations the
15
+ * renderer needs, so core does not depend on any editor implementation.
16
+ * @public
17
+ */
18
+ interface EditorTreeNode {
19
+ readonly type: {
20
+ readonly name: string;
21
+ create(...args: any[]): EditorTreeNode;
22
+ };
23
+ readonly attrs: Record<string, any>;
24
+ readonly marks: readonly EditorTreeMark[];
25
+ readonly nodeSize: number;
26
+ readonly content: {
27
+ readonly size: number;
28
+ };
29
+ readonly isText: boolean;
30
+ readonly isTextblock: boolean;
31
+ readonly isInline: boolean;
32
+ readonly text?: string | null;
33
+ forEach(callback: (node: EditorTreeNode, offset: number, index: number) => void): void;
34
+ descendants(callback: (node: EditorTreeNode, pos: number) => boolean | void): void;
35
+ }
36
+
37
+ export type { EditorTreeNode as E };
@@ -0,0 +1 @@
1
+ export{a as executeCommand,b as executeCommands}from'./chunk-6PW4CWUG.mjs';import'./chunk-KXNZFTTK.mjs';import'./chunk-VBOTMRXV.mjs';import'./chunk-3UBMCDME.mjs';import'./chunk-TTRUPDAB.mjs';