@betteroffice/docx 0.3.0 → 0.4.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 (82) hide show
  1. package/README.md +66 -1
  2. package/dist/chunk-2HLVVQIL.mjs +1 -0
  3. package/dist/chunk-2QHGQA3V.mjs +1 -0
  4. package/dist/{chunk-ACGKK7IB.mjs → chunk-3CYO46ML.mjs} +1 -1
  5. package/dist/chunk-3OWET2KZ.mjs +1 -0
  6. package/dist/chunk-4GEXNR7A.mjs +1 -0
  7. package/dist/chunk-4QHAMEAS.mjs +1 -0
  8. package/dist/chunk-6CHGYCFU.mjs +1 -0
  9. package/dist/chunk-7DDF4RHB.mjs +16 -0
  10. package/dist/chunk-AOWJ4WDE.mjs +1 -0
  11. package/dist/chunk-C5BX34CG.mjs +2 -0
  12. package/dist/chunk-DKWD4P4J.mjs +1 -0
  13. package/dist/chunk-DLXIZBB6.mjs +1 -0
  14. package/dist/chunk-EIPVFGIC.mjs +1 -0
  15. package/dist/{chunk-NT2OYIJ4.mjs → chunk-FMOSOX5V.mjs} +1 -1
  16. package/dist/chunk-HPZFJGGM.mjs +0 -0
  17. package/dist/chunk-LT2GCWZ3.mjs +0 -0
  18. package/dist/chunk-NVN26RHH.mjs +1 -0
  19. package/dist/{chunk-QE4ZDRKV.mjs → chunk-YLFKV2NT.mjs} +1 -1
  20. package/dist/collaboration/index.d.mts +6 -4
  21. package/dist/compareDocx-QX2YF3EF.mjs +1 -0
  22. package/dist/computeLayout-4MNWHE2T.mjs +1 -0
  23. package/dist/core.d.mts +4 -4
  24. package/dist/core.mjs +1 -1
  25. package/dist/{displayListQueries-BYFrBkw5.d.mts → displayListQueries-DnHmHUPY.d.mts} +23 -5
  26. package/dist/docx/index.d.mts +2 -2
  27. package/dist/docx/index.mjs +1 -1
  28. package/dist/editor/index.d.mts +16 -7
  29. package/dist/editor/index.mjs +1 -1
  30. package/dist/{fontLoader-CkXcPB1C.d.mts → fontLoader-BNSs0E8K.d.mts} +54 -1
  31. package/dist/{frameDelta-CVt5FAXT.d.mts → frameDelta-ByU7HBuB.d.mts} +21 -1
  32. package/dist/generated/edit/docx_edit_bg.wasm +0 -0
  33. package/dist/generated/layout/docx_layout_bg.wasm +0 -0
  34. package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
  35. package/dist/generated/parse/docx_parse_bg.wasm +0 -0
  36. package/dist/{index-BbZwdkPz.d.mts → index-yOtBET85.d.mts} +769 -16
  37. package/dist/layout/index.d.mts +2 -2
  38. package/dist/layout/index.mjs +1 -1
  39. package/dist/layout/pagination/index.d.mts +2 -2
  40. package/dist/layout/render/index.d.mts +140 -32
  41. package/dist/layout/render/index.mjs +1 -1
  42. package/dist/loadWasmAsset-Cr95TImt.d.mts +25 -0
  43. package/dist/{pagedExport-D3E4jZ-B.d.mts → pagedExport-BmSlEhoP.d.mts} +1 -1
  44. package/dist/parseWasm-NLAG22EU.mjs +1 -0
  45. package/dist/plugin-api/RenderedDomContext.d.mts +6 -4
  46. package/dist/plugin-api/RenderedDomContext.mjs +1 -1
  47. package/dist/{rustDisplayList-CwOoUn3t.d.mts → rustDisplayList-DcaA5iok.d.mts} +12 -4
  48. package/dist/{rustMeasureSource-CyBMcy1x.d.mts → rustMeasureSource-BkCx1FDx.d.mts} +2 -0
  49. package/dist/types/document.d.mts +3 -0
  50. package/dist/{types-B4jD0rrc.d.mts → types-Buyw6dFd.d.mts} +32 -3
  51. package/dist/utils/index.d.mts +14 -2
  52. package/dist/utils/index.mjs +1 -1
  53. package/dist/wasm-6WSIEYWC.mjs +1 -0
  54. package/dist/wasm-GSI2XMOH.mjs +1 -0
  55. package/dist/{wasm-G62X4WRW.mjs → wasm-IBCLSJQU.mjs} +1 -1
  56. package/dist/wasm-edit.d.mts +191 -18
  57. package/dist/wasm-edit.mjs +1 -1
  58. package/dist/wasm-layout.d.mts +1 -1
  59. package/dist/wasm-layout.mjs +1 -1
  60. package/dist/wasm-opc.d.mts +1 -1
  61. package/dist/wasm-opc.mjs +1 -1
  62. package/dist/wasm-parse.d.mts +1 -1
  63. package/dist/wasm-parse.mjs +1 -1
  64. package/dist/yrs/index.d.mts +5 -3
  65. package/dist/yrs/index.mjs +1 -1
  66. package/dist/yrs/residentEngineWorker.mjs +1 -1
  67. package/package.json +2 -2
  68. package/dist/chunk-5B4VMUXM.mjs +0 -16
  69. package/dist/chunk-5F6DLQZP.mjs +0 -1
  70. package/dist/chunk-5JEQC76K.mjs +0 -1
  71. package/dist/chunk-7GJG6LLU.mjs +0 -1
  72. package/dist/chunk-FE6FWGBJ.mjs +0 -1
  73. package/dist/chunk-H5YYCN42.mjs +0 -1
  74. package/dist/chunk-HLDJMU3R.mjs +0 -1
  75. package/dist/chunk-J7LNO6SM.mjs +0 -1
  76. package/dist/chunk-PGMXWI5X.mjs +0 -1
  77. package/dist/chunk-VQXNED2P.mjs +0 -2
  78. package/dist/chunk-Z4HZIPBS.mjs +0 -1
  79. package/dist/compareDocx-XXTZV4CG.mjs +0 -1
  80. package/dist/computeLayout-LWLAJWYA.mjs +0 -1
  81. package/dist/loadWasmAsset-CMvnVkfA.d.mts +0 -3
  82. package/dist/wasm-US6R7SWN.mjs +0 -1
@@ -1,5 +1,5 @@
1
- import { B as BundledFontProvider } from '../rustMeasureSource-CyBMcy1x.mjs';
2
- export { a as BundledFontProviderSource, E as EmbeddedFaceInput, F as FontScript, b as ResidentFontRequirement, R as ResidentMeasurementConfig, c as RustMeasureSource, d as RustTextEngine, e as createRustMeasureSource, g as getRustTextEngine } from '../rustMeasureSource-CyBMcy1x.mjs';
1
+ import { B as BundledFontProvider } from '../rustMeasureSource-BkCx1FDx.mjs';
2
+ export { a as BundledFontProviderSource, E as EmbeddedFaceInput, F as FontScript, b as ResidentFontRequirement, R as ResidentMeasurementConfig, c as RustMeasureSource, d as RustTextEngine, e as createRustMeasureSource, g as getRustTextEngine } from '../rustMeasureSource-BkCx1FDx.mjs';
3
3
  import { f as SectionProperties, H as HeaderFooter } from '../content-BzoC6bSz.mjs';
4
4
  export { D as DrawingScene, V as DrawingSceneNode, b as ShapeEffect, aX as ShapeFillPaint, aY as ShapeStrokePaint, c as ShapeTextBodyProperties } from '../content-BzoC6bSz.mjs';
5
5
  import { Document } from '../types/document.mjs';
@@ -1 +1 @@
1
- import {d,e,g as g$1,c,f,b as b$1}from'../chunk-TTRUPDAB.mjs';var I={},R;function q(a){if(a===void 0)return;let e=typeof a=="string"?a:a.href,t=typeof location>"u"?void 0:location.href;try{return new URL(e,t)}catch{throw new TypeError(`configureDefaultFonts baseUrl must be absolute when no browser location exists: ${e}`)}}function U(){return I.fonts!==void 0||I.load!==void 0}function H(a){I={...a,baseUrl:q(a.baseUrl)},R=void 0,I.baseUrl!==void 0&&!U()&&console.warn("[configureDefaultFonts] a baseUrl on its own loads nothing \u2014 the face manifest lives in @betteroffice/fonts. Pass the module too: configureDefaultFonts({ fonts, baseUrl }).");}async function K(){let{baseUrl:a,fonts:e,load:t}=I;try{return (e??await t()).createFontProvider(a===void 0?void 0:{baseUrl:a})}catch(i){console.warn("[configureDefaultFonts] the configured font source failed to load",i);return}}function M(){if(!U())return Promise.resolve(void 0);if(R===void 0){let a=K();a.then(e=>{e===void 0&&R===a&&(R=void 0);}),R=a;}return R}function A(a){return a.trim().toLowerCase()}function C(a,e,t){return `${A(a)}|${e?1:0}|${t?1:0}`}function k(a,e,t,i){t.then(n=>{i(n)&&a.get(e)===t&&a.delete(e);},()=>{a.get(e)===t&&a.delete(e);});}var x=class{constructor(e,t){b$1(this,"sink");b$1(this,"bundledSource");b$1(this,"bundledPromise");b$1(this,"warnedFallback",false);b$1(this,"facesByFamily",new Map);b$1(this,"faceIds",new WeakMap);b$1(this,"bundledIds",new Map);b$1(this,"lastResortIds",new Map);b$1(this,"bufferIds",new WeakMap);b$1(this,"scriptIds",new Map);b$1(this,"scriptResults",new Map);b$1(this,"chains",new Map);b$1(this,"chainResults",new Map);b$1(this,"generation",0);this.sink=e,this.bundledSource=t?.bundled;}bundled(){if(this.bundledPromise===void 0){let e=this.bundledSource,t=Promise.resolve().then(()=>typeof e=="function"?e():e).catch(()=>{});t.then(i=>{i===void 0&&this.bundledPromise===t&&(this.bundledPromise=void 0);}),this.bundledPromise=t;}return this.bundledPromise}setEmbeddedFaces(e){this.generation++,this.facesByFamily=new Map;for(let t of e){let i=A(t.family),n=this.facesByFamily.get(i);n?n.push(t):this.facesByFamily.set(i,[t]);}this.chains=new Map,this.chainResults=new Map;}getFontIdChain(e,t,i){let n=C(e,t,i),o=this.chains.get(n);if(!o){let r=this.chains,s=this.chainResults,u=this.generation,f=this.resolveChain(e,t,i);f.then(l=>{u===this.generation&&(s.set(n,l),l.retryable&&r.get(n)===f&&r.delete(n));},()=>{r.get(n)===f&&r.delete(n);}),r.set(n,f),o=f;}return o.then(r=>r.ids)}getCachedFontIdChain(e,t,i,n=true){let o=C(e,t,i),r=this.chainResults.get(o);if(n&&r?.retryable){let s=this.chainResults;queueMicrotask(()=>{s.get(o)===r&&s.delete(o);});}return r?.ids}getScriptFallbackIds(e){let t=[...new Set(e)];return Promise.all(t.map(i=>this.resolveScript(i))).then(i=>{let n=[];for(let{id:o}of i)o!==null&&!n.includes(o)&&n.push(o);return n})}getCachedScriptFallbackIds(e,t=true){let i=this.scriptResults,n=[];for(let r of e){let s=i.get(r);if(!s)return;n.push([r,s]);}let o=[];for(let[r,s]of n){let{id:u}=s;u!==null&&!o.includes(u)&&o.push(u),t&&s.retryable&&queueMicrotask(()=>{i.get(r)===s&&i.delete(r);});}return o}clear(){this.generation++,this.bundledPromise=void 0,this.faceIds=new WeakMap,this.bundledIds=new Map,this.lastResortIds=new Map,this.bufferIds=new WeakMap,this.scriptIds=new Map,this.scriptResults=new Map,this.chains=new Map,this.chainResults=new Map;}async resolveChain(e,t,i){let n=C(e,t,i),o=[],r=false,s=this.pickEmbeddedFace(e,t,i);if(s){let d=await this.registerFace(s);d!==null?o.push(d):r=true;}let u=await this.bundled();u===void 0&&typeof this.bundledSource=="function"&&(r=true);let f;try{f=u?.resolve(e,t,i);}catch(d){r=true,console.warn(`[fontRegistry] bundled face resolver for "${e}" failed; falling back: ${d instanceof Error?d.message:String(d)}`);}if(f){let d=await this.registerBundled(n,f,e);d!==null&&!o.includes(d)&&o.push(d),d===null&&(r=true);}let l;try{l=u?.resolveLastResort?.(e,t,i,"word");}catch(d){r=true,console.warn(`[fontRegistry] last-resort resolver for "${e}" failed; falling back: ${d instanceof Error?d.message:String(d)}`);}if(l){let d=await this.registerLastResort(n,l,e);d!==null&&!o.includes(d)&&o.push(d),d===null&&(r=true);}return o.length===0&&this.warnFallback(e,u!==void 0,f!==void 0||l!==void 0),{ids:o,retryable:r}}warnFallback(e,t,i){if(this.warnedFallback)return;this.warnedFallback=true;let n="Native measurement is unsupported; browser hosts fall back to measureText and may use different OS fonts, so pagination can vary. Reported once per registry.";console.warn(i?`[fontRegistry] no font bytes for "${e}" \u2014 the font provider resolved but every matching face failed to load. ${n} If a bundler inlined @betteroffice/fonts, mark it external so its asset URLs resolve.`:t?`[fontRegistry] no font bytes for "${e}" \u2014 the configured font provider has no matching face. Add coverage for this family. ${n}`:`[fontRegistry] no font bytes for "${e}" \u2014 no font provider is configured. Install @betteroffice/fonts and pass it with configureDefaultFonts({ fonts }). `+n);}pickEmbeddedFace(e,t,i){let n=this.facesByFamily.get(A(e));if(!n)return;let o=t?"bold":"normal",r=i?"italic":"normal";return n.find(s=>s.weight===o&&s.style===r)??n.find(s=>s.weight==="normal"&&s.style==="normal")}measuredAs(e,t){let i=this.sink.registerSubstituteFont;if(!i)return e;try{return i.call(this.sink,e,t)}catch(n){return console.warn(`[fontRegistry] measurement view of the substitute for "${t}" failed; measuring with the substitute's own metrics: ${n instanceof Error?n.message:String(n)}`),e}}registerBuffer(e){let t=this.bufferIds.get(e);if(!t){let i=this.bufferIds;t=Promise.resolve().then(()=>this.sink.registerFont(new Uint8Array(e))),k(i,e,t,()=>false),i.set(e,t);}return t}registerFace(e){let t=this.faceIds.get(e);if(!t){let i=this.faceIds;t=(async()=>{try{return await this.registerBuffer(e.data)}catch{return console.warn(`[fontRegistry] embedded face "${e.family}" (${e.weight} ${e.style}) was rejected by the text engine; falling back`),null}})(),k(i,e,t,n=>n===null),i.set(e,t);}return t}registerBundled(e,t,i){let n=this.bundledIds.get(e);if(!n){let o=this.bundledIds;n=(async()=>{try{let r=await t();return this.measuredAs(await this.registerBuffer(r),i)}catch(r){return console.warn(`[fontRegistry] bundled face for "${i}" failed to load or register; falling back: ${r instanceof Error?r.message:String(r)}`),null}})(),k(o,e,n,r=>r===null),o.set(e,n);}return n}registerLastResort(e,t,i){let n=this.lastResortIds.get(e);if(!n){let o=this.lastResortIds;n=(async()=>{try{let r=await t();return this.measuredAs(await this.registerBuffer(r),i)}catch{return console.warn(`[fontRegistry] last-resort base face for "${i}" failed to load or register; falling back`),null}})(),k(o,e,n,r=>r===null),o.set(e,n);}return n}resolveScript(e){let t=this.scriptIds.get(e);if(!t){let i=this.scriptIds,n=this.scriptResults;t=(async()=>{let o=null,r=false,s=await this.bundled();s===void 0&&typeof this.bundledSource=="function"&&(r=true);let u;try{u=s?.resolveScriptFallback?.(e,!1,!1);}catch(l){r=true,console.warn(`[fontRegistry] script-fallback resolver for "${e}" failed; falling back: ${l instanceof Error?l.message:String(l)}`);}if(u)try{let l=await u();o=await this.registerBuffer(l);}catch(l){r=true,console.warn(`[fontRegistry] script-fallback face for "${e}" failed to load or register; falling back: ${l instanceof Error?l.message:String(l)}`);}let f={id:o,retryable:r};return n.set(e,f),f})(),k(i,e,t,o=>o.retryable),i.set(e,t);}return t}};var L=null;function j(){return L??(L=import('../wasm-G62X4WRW.mjs').then(async a=>(await a.preloadLayoutWasm(),{registerFont:a.registerMeasureFont,registerSubstituteFont:a.registerSubstituteMeasureFont,clearFonts:a.clearMeasureFonts}))),L}function V(a){let e=a.engine,t=new x({registerFont:n=>e.registerFont(n),...e.registerSubstituteFont&&{registerSubstituteFont:(n,o)=>e.registerSubstituteFont(n,o)}},{bundled:a.bundled??M}),i;return {setEmbeddedFaces(n){t.setEmbeddedFaces(n);},setCompat(n){i=n;},async prepareFontRequirements(n){return (await Promise.all(n.flatMap(r=>[(async()=>{try{return t.getCachedFontIdChain(r.family,r.bold,r.italic,!1)!==void 0?!1:(await t.getFontIdChain(r.family,r.bold,r.italic),!0)}catch{return false}})(),...Array.from(new Set(r.scripts??[]),async s=>{try{return t.getCachedScriptFallbackIds([s],!1)!==void 0?!1:(await t.getScriptFallbackIds([s]),!0)}catch{return false}})]))).some(Boolean)},measurementConfigForRequirements(n){let o=n.map(s=>({requirement:s,familyIds:t.getCachedFontIdChain(s.family,s.bold,s.italic,false),scriptIds:t.getCachedScriptFallbackIds(s.scripts??[],false)}));if(o.some(({familyIds:s,scriptIds:u})=>s===void 0||u===void 0))return;let r={};for(let{requirement:s}of o){let u=t.getCachedFontIdChain(s.family,s.bold,s.italic),f=t.getCachedScriptFallbackIds(s.scripts??[]);if(u===void 0||f===void 0)return;let l=Array.from(u);for(let d of f)l.includes(d)||l.push(d);l.length>0&&(r[s.key]=l);}return {fontChains:r,defaults:{fontSize:11,fontFamily:"Calibri"},compat:{noLeading:i?.noLeading??false,doNotExpandShiftReturn:i?.doNotExpandShiftReturn??false},authoritativeShaping:true}},clear(){t.clear();}}}var _=1056;function G(a,e){let t=a?.package.headers,i=a?.package.footers,n=e?.headerReferences?.find(F=>F.type==="default"),o=e?.headerReferences?.find(F=>F.type==="first"),r=e?.footerReferences?.find(F=>F.type==="default"),s=e?.footerReferences?.find(F=>F.type==="first"),u=n?t?.get(n.rId)??null:null,f=r?i?.get(r.rId)??null:null,l=o?t?.get(o.rId)??null:null,d=s?i?.get(s.rId)??null:null;return e?.titlePg||(u??(u=l),f??(f=d)),{header:u,footer:f,firstHeader:l,firstFooter:d}}var g,b,m,y,w,B,T,$=class{constructor(){d(this,B);d(this,g,0);d(this,b,0);d(this,m,false);d(this,y,false);d(this,w,new Set);}setStateSeq(e$1){e(this,g,e$1);}incrementStateSeq(){return ++g$1(this,g)._}getStateSeq(){return c(this,g)}getRenderSeq(){return c(this,b)}onLayoutStart(){e(this,m,true);}onLayoutComplete(e$1){e(this,b,e$1),e(this,m,false),c(this,y)&&this.isSafeToRender()&&(e(this,y,false),f(this,B,T).call(this));}isSafeToRender(){return !c(this,m)&&c(this,b)>=c(this,g)}requestRender(){this.isSafeToRender()?f(this,B,T).call(this):e(this,y,true);}onRender(e){return c(this,w).add(e),()=>c(this,w).delete(e)}reset(){e(this,g,0),e(this,b,0),e(this,m,false),e(this,y,false);}getDebugInfo(){return {stateSeq:c(this,g),renderSeq:c(this,b),layoutUpdating:c(this,m),hasPendingRender:c(this,y),isSafe:this.isSafeToRender()}}};g=new WeakMap,b=new WeakMap,m=new WeakMap,y=new WeakMap,w=new WeakMap,B=new WeakSet,T=function(){for(let e of c(this,w))try{e();}catch(t){console.error("LayoutSelectionGate: render callback error",t);}};export{_ as DEFAULT_PAGE_HEIGHT_PX,$ as LayoutSelectionGate,H as configureDefaultFonts,V as createRustMeasureSource,j as getRustTextEngine,M as resolveDefaultFontProvider,G as resolveHeaderFooter};
1
+ import {c}from'../chunk-DLXIZBB6.mjs';export{b as configureDefaultFonts,c as resolveDefaultFontProvider}from'../chunk-DLXIZBB6.mjs';import {d,e,g as g$1,c as c$1,f,b as b$1}from'../chunk-TTRUPDAB.mjs';function C(u){return u.trim().toLowerCase()}function B(u,e,t){return `${C(u)}|${e?1:0}|${t?1:0}`}function v(u,e,t,i){t.then(r=>{i(r)&&u.get(e)===t&&u.delete(e);},()=>{u.get(e)===t&&u.delete(e);});}var k=class{constructor(e,t){b$1(this,"sink");b$1(this,"bundledSource");b$1(this,"bundledPromise");b$1(this,"warnedFallback",false);b$1(this,"facesByFamily",new Map);b$1(this,"faceIds",new WeakMap);b$1(this,"bundledIds",new Map);b$1(this,"lastResortIds",new Map);b$1(this,"bufferIds",new WeakMap);b$1(this,"scriptIds",new Map);b$1(this,"scriptResults",new Map);b$1(this,"chains",new Map);b$1(this,"chainResults",new Map);b$1(this,"generation",0);this.sink=e,this.bundledSource=t?.bundled;}bundled(){if(this.bundledPromise===void 0){let e=this.bundledSource,t=Promise.resolve().then(()=>typeof e=="function"?e():e).catch(()=>{});t.then(i=>{i===void 0&&this.bundledPromise===t&&(this.bundledPromise=void 0);}),this.bundledPromise=t;}return this.bundledPromise}setEmbeddedFaces(e){this.generation++,this.facesByFamily=new Map;for(let t of e){let i=C(t.family),r=this.facesByFamily.get(i);r?r.push(t):this.facesByFamily.set(i,[t]);}this.chains=new Map,this.chainResults=new Map;}getFontIdChain(e,t,i){let r=B(e,t,i),s=this.chains.get(r);if(!s){let n=this.chains,o=this.chainResults,l=this.generation,f=this.resolveChain(e,t,i);f.then(d=>{l===this.generation&&(o.set(r,d),d.retryable&&n.get(r)===f&&n.delete(r));},()=>{n.get(r)===f&&n.delete(r);}),n.set(r,f),s=f;}return s.then(n=>n.ids)}getCachedFontIdChain(e,t,i,r=true){let s=B(e,t,i),n=this.chainResults.get(s);if(r&&n?.retryable){let o=this.chainResults;queueMicrotask(()=>{o.get(s)===n&&o.delete(s);});}return n?.ids}getScriptFallbackIds(e){let t=[...new Set(e)];return Promise.all(t.map(i=>this.resolveScript(i))).then(i=>{let r=[];for(let{id:s}of i)s!==null&&!r.includes(s)&&r.push(s);return r})}getCachedScriptFallbackIds(e,t=true){let i=this.scriptResults,r=[];for(let n of e){let o=i.get(n);if(!o)return;r.push([n,o]);}let s=[];for(let[n,o]of r){let{id:l}=o;l!==null&&!s.includes(l)&&s.push(l),t&&o.retryable&&queueMicrotask(()=>{i.get(n)===o&&i.delete(n);});}return s}clear(){this.generation++,this.bundledPromise=void 0,this.faceIds=new WeakMap,this.bundledIds=new Map,this.lastResortIds=new Map,this.bufferIds=new WeakMap,this.scriptIds=new Map,this.scriptResults=new Map,this.chains=new Map,this.chainResults=new Map;}async resolveChain(e,t,i){let r=B(e,t,i),s=[],n=false,o=this.pickEmbeddedFace(e,t,i);if(o){let a=await this.registerFace(o);a!==null?s.push(a):n=true;}let l=await this.bundled();l===void 0&&typeof this.bundledSource=="function"&&(n=true);let f;try{f=l?.resolve(e,t,i);}catch(a){n=true,console.warn(`[fontRegistry] bundled face resolver for "${e}" failed; falling back: ${a instanceof Error?a.message:String(a)}`);}if(f){let a=await this.registerBundled(r,f,e);a!==null&&!s.includes(a)&&s.push(a),a===null&&(n=true);}let d;try{d=l?.resolveLastResort?.(e,t,i,"word");}catch(a){n=true,console.warn(`[fontRegistry] last-resort resolver for "${e}" failed; falling back: ${a instanceof Error?a.message:String(a)}`);}if(d){let a=await this.registerLastResort(r,d,e);a!==null&&!s.includes(a)&&s.push(a),a===null&&(n=true);}return s.length===0&&this.warnFallback(e,l!==void 0,f!==void 0||d!==void 0),{ids:s,retryable:n}}warnFallback(e,t,i){if(this.warnedFallback)return;this.warnedFallback=true;let r="Native measurement is unsupported; browser hosts fall back to measureText and may use different OS fonts, so pagination can vary. Reported once per registry.";console.warn(i?`[fontRegistry] no font bytes for "${e}" \u2014 the font provider resolved but every matching face failed to load. ${r} If a bundler inlined @betteroffice/fonts, mark it external so its asset URLs resolve.`:t?`[fontRegistry] no font bytes for "${e}" \u2014 the configured font provider has no matching face. Add coverage for this family. ${r}`:`[fontRegistry] no font bytes for "${e}" \u2014 no font provider is configured. Install @betteroffice/fonts and pass it with configureDefaultFonts({ fonts }). `+r);}pickEmbeddedFace(e,t,i){let r=this.facesByFamily.get(C(e));if(!r)return;let s=t?"bold":"normal",n=i?"italic":"normal";return r.find(o=>o.weight===s&&o.style===n)??r.find(o=>o.weight==="normal"&&o.style==="normal")}measuredAs(e,t){let i=this.sink.registerSubstituteFont;if(!i)return e;try{return i.call(this.sink,e,t)}catch(r){return console.warn(`[fontRegistry] measurement view of the substitute for "${t}" failed; measuring with the substitute's own metrics: ${r instanceof Error?r.message:String(r)}`),e}}registerBuffer(e){let t=this.bufferIds.get(e);if(!t){let i=this.bufferIds;t=Promise.resolve().then(()=>this.sink.registerFont(new Uint8Array(e))),v(i,e,t,()=>false),i.set(e,t);}return t}registerFace(e){let t=this.faceIds.get(e);if(!t){let i=this.faceIds;t=(async()=>{try{return await this.registerBuffer(e.data)}catch{return console.warn(`[fontRegistry] embedded face "${e.family}" (${e.weight} ${e.style}) was rejected by the text engine; falling back`),null}})(),v(i,e,t,r=>r===null),i.set(e,t);}return t}registerBundled(e,t,i){let r=this.bundledIds.get(e);if(!r){let s=this.bundledIds;r=(async()=>{try{let n=await t();return this.measuredAs(await this.registerBuffer(n),i)}catch(n){return console.warn(`[fontRegistry] bundled face for "${i}" failed to load or register; falling back: ${n instanceof Error?n.message:String(n)}`),null}})(),v(s,e,r,n=>n===null),s.set(e,r);}return r}registerLastResort(e,t,i){let r=this.lastResortIds.get(e);if(!r){let s=this.lastResortIds;r=(async()=>{try{let n=await t();return this.measuredAs(await this.registerBuffer(n),i)}catch{return console.warn(`[fontRegistry] last-resort base face for "${i}" failed to load or register; falling back`),null}})(),v(s,e,r,n=>n===null),s.set(e,r);}return r}resolveScript(e){let t=this.scriptIds.get(e);if(!t){let i=this.scriptIds,r=this.scriptResults;t=(async()=>{let s=null,n=false,o=await this.bundled();o===void 0&&typeof this.bundledSource=="function"&&(n=true);let l;try{l=o?.resolveScriptFallback?.(e,!1,!1);}catch(d){n=true,console.warn(`[fontRegistry] script-fallback resolver for "${e}" failed; falling back: ${d instanceof Error?d.message:String(d)}`);}if(l)try{let d=await l();s=await this.registerBuffer(d);}catch(d){n=true,console.warn(`[fontRegistry] script-fallback face for "${e}" failed to load or register; falling back: ${d instanceof Error?d.message:String(d)}`);}let f={id:s,retryable:n};return r.set(e,f),f})(),v(i,e,t,s=>s.retryable),i.set(e,t);}return t}};var T=null;function L(){return T??(T=import('../wasm-IBCLSJQU.mjs').then(async u=>(await u.preloadLayoutWasm(),{registerFont:u.registerMeasureFont,registerSubstituteFont:u.registerSubstituteMeasureFont,clearFonts:u.clearMeasureFonts}))),T}function H(u){let e=u.engine,t=new k({registerFont:r=>e.registerFont(r),...e.registerSubstituteFont&&{registerSubstituteFont:(r,s)=>e.registerSubstituteFont(r,s)}},{bundled:u.bundled??c}),i;return {setEmbeddedFaces(r){t.setEmbeddedFaces(r);},setCompat(r){i=r;},async prepareFontRequirements(r){return (await Promise.all(r.flatMap(n=>[(async()=>{try{return t.getCachedFontIdChain(n.family,n.bold,n.italic,!1)!==void 0?!1:(await t.getFontIdChain(n.family,n.bold,n.italic),!0)}catch{return false}})(),...Array.from(new Set(n.scripts??[]),async o=>{try{return t.getCachedScriptFallbackIds([o],!1)!==void 0?!1:(await t.getScriptFallbackIds([o]),!0)}catch{return false}})]))).some(Boolean)},measurementConfigForRequirements(r){let s=r.map(o=>({requirement:o,familyIds:t.getCachedFontIdChain(o.family,o.bold,o.italic,false),scriptIds:t.getCachedScriptFallbackIds(o.scripts??[],false)}));if(s.some(({familyIds:o,scriptIds:l})=>o===void 0||l===void 0))return;let n={};for(let{requirement:o}of s){let l=t.getCachedFontIdChain(o.family,o.bold,o.italic),f=t.getCachedScriptFallbackIds(o.scripts??[]);if(l===void 0||f===void 0)return;let d=Array.from(l);for(let a of f)d.includes(a)||d.push(a);d.length>0&&(n[o.key]=d);}return {fontChains:n,defaults:{fontSize:11,fontFamily:"Calibri"},compat:{noLeading:i?.noLeading??false,doNotExpandShiftReturn:i?.doNotExpandShiftReturn??false},authoritativeShaping:true}},clear(){t.clear();}}}var D=1056;function U(u,e){let t=u?.package.headers,i=u?.package.footers,r=e?.headerReferences?.find(F=>F.type==="default"),s=e?.headerReferences?.find(F=>F.type==="first"),n=e?.footerReferences?.find(F=>F.type==="default"),o=e?.footerReferences?.find(F=>F.type==="first"),l=r?t?.get(r.rId)??null:null,f=n?i?.get(n.rId)??null:null,d=s?t?.get(s.rId)??null:null,a=o?i?.get(o.rId)??null:null;return e?.titlePg||(l??(l=d),f??(f=a)),{header:l,footer:f,firstHeader:d,firstFooter:a}}var g,b,m,y,R,I,A,M=class{constructor(){d(this,I);d(this,g,0);d(this,b,0);d(this,m,false);d(this,y,false);d(this,R,new Set);}setStateSeq(e$1){e(this,g,e$1);}incrementStateSeq(){return ++g$1(this,g)._}getStateSeq(){return c$1(this,g)}getRenderSeq(){return c$1(this,b)}onLayoutStart(){e(this,m,true);}onLayoutComplete(e$1){e(this,b,e$1),e(this,m,false),c$1(this,y)&&this.isSafeToRender()&&(e(this,y,false),f(this,I,A).call(this));}isSafeToRender(){return !c$1(this,m)&&c$1(this,b)>=c$1(this,g)}requestRender(){this.isSafeToRender()?f(this,I,A).call(this):e(this,y,true);}onRender(e){return c$1(this,R).add(e),()=>c$1(this,R).delete(e)}reset(){e(this,g,0),e(this,b,0),e(this,m,false),e(this,y,false);}getDebugInfo(){return {stateSeq:c$1(this,g),renderSeq:c$1(this,b),layoutUpdating:c$1(this,m),hasPendingRender:c$1(this,y),isSafe:this.isSafeToRender()}}};g=new WeakMap,b=new WeakMap,m=new WeakMap,y=new WeakMap,R=new WeakMap,I=new WeakSet,A=function(){for(let e of c$1(this,R))try{e();}catch(t){console.error("LayoutSelectionGate: render callback error",t);}};export{D as DEFAULT_PAGE_HEIGHT_PX,M as LayoutSelectionGate,H as createRustMeasureSource,L as getRustTextEngine,U as resolveHeaderFooter};
@@ -1,5 +1,5 @@
1
- import { b as LayoutBlock, B as BlockExtent } from '../../types-B4jD0rrc.mjs';
2
- export { A as AnchoredObjectPositionInput, d as BlockId, e as BorderStyle, C as CellBorderSpec, f as CellBorders, g as ChartBlock, h as ChartExtent, i as ChartFragment, j as ColumnBreakBlock, k as ColumnBreakExtent, l as ColumnLayout, D as DEFAULT_TEXTBOX_MARGINS, m as DEFAULT_TEXTBOX_WIDTH, n as DocumentPosition, o as FieldRun, p as FloatingTablePosition, F as FootnoteContent, q as FootnoteRenderItem, r as Fragment, s as FragmentBase, H as HeaderFooterContent, t as HeaderFooterContentHeights, u as HeaderFooterLayout, v as HitTestResult, w as HyperlinkInfo, I as ImageBlock, x as ImageExtent, y as ImageFragment, z as ImageRun, E as ImageRunPosition, G as InlineSdtWidget, L as Layout, a as LayoutOptions, J as LineBreakRun, K as ListNumPr, N as NoteAreaContract, M as NoteLayoutItem, O as NoteSettingsContract, P as Page, Q as PageBorderContract, S as PageBreakBlock, T as PageBreakExtent, U as PageGeometry, V as PageHeaderFooterRefs, W as PageMargins, X as PageNumberingContract, Y as ParagraphAttrs, Z as ParagraphBlock, _ as ParagraphBorders, $ as ParagraphExtent, a0 as ParagraphFragment, a1 as ParagraphIndent, a2 as ParagraphSpacing, R as ResolvedLine, c as ResolvedSegment, a3 as Run, a4 as RunFontSlots, a5 as RunFormatting, a6 as RunLanguageSlots, a7 as SdtGroup, a8 as SectionBreakBlock, a9 as SectionBreakExtent, aa as ShapeBlock, ab as ShapeBlockFill, ac as ShapeBlockStroke, ad as ShapeBlockTransform, ae as ShapeExtent, af as ShapeFragment, ag as TabAlignment, ah as TabRun, ai as TabStop, aj as TableBlock, ak as TableCell, al as TableCellExtent, am as TableExtent, an as TableFragment, ao as TableRow, ap as TableRowExtent, aq as TextBoxBlock, ar as TextBoxExtent, as as TextBoxFragment, at as TextRun, au as TypesetBidiSlice, av as TypesetClusterAdvance, aw as TypesetRow, ax as TypesetRowSegment, ay as TypesetRunAdvance, az as WrapTextDirection, aA as assertExhaustiveLayoutBlock, aB as isTextWrappingFloatingImageRun, aC as pageGeometryFromPage, aD as resolveAnchoredObjectVerticalTop } from '../../types-B4jD0rrc.mjs';
1
+ import { b as LayoutBlock, B as BlockExtent } from '../../types-Buyw6dFd.mjs';
2
+ export { A as AnchoredObjectPositionInput, d as BlockId, e as BorderStyle, C as CellBorderSpec, f as CellBorders, g as ChartBlock, h as ChartExtent, i as ChartFragment, j as ColumnBreakBlock, k as ColumnBreakExtent, l as ColumnLayout, D as DEFAULT_TEXTBOX_MARGINS, m as DEFAULT_TEXTBOX_WIDTH, n as DocumentPosition, o as FieldRun, p as FloatingTablePosition, F as FootnoteContent, q as FootnoteRenderItem, r as Fragment, s as FragmentBase, H as HeaderFooterContent, t as HeaderFooterContentHeights, u as HeaderFooterLayout, v as HitTestResult, w as HyperlinkInfo, I as ImageBlock, x as ImageExtent, y as ImageFragment, z as ImageRun, E as ImageRunPosition, G as InlineSdtWidget, L as Layout, a as LayoutOptions, J as LineBreakRun, K as ListNumPr, N as NoteAreaContract, M as NoteLayoutItem, O as NoteSettingsContract, P as Page, Q as PageBorderContract, S as PageBreakBlock, T as PageBreakExtent, U as PageGeometry, V as PageHeaderFooterRefs, W as PageMargins, X as PageNumberingContract, Y as ParagraphAttrs, Z as ParagraphBlock, _ as ParagraphBorders, $ as ParagraphExtent, a0 as ParagraphFragment, a1 as ParagraphIndent, a2 as ParagraphSpacing, R as ResolvedLine, c as ResolvedSegment, a3 as Run, a4 as RunFontSlots, a5 as RunFormatting, a6 as RunLanguageSlots, a7 as SdtGroup, a8 as SectionBreakBlock, a9 as SectionBreakExtent, aa as ShapeBlock, ab as ShapeBlockFill, ac as ShapeBlockStroke, ad as ShapeBlockTransform, ae as ShapeExtent, af as ShapeFragment, ag as TabAlignment, ah as TabRun, ai as TabStop, aj as TableBlock, ak as TableCell, al as TableCellExtent, am as TableExtent, an as TableFragment, ao as TableRow, ap as TableRowExtent, aq as TextBoxBlock, ar as TextBoxExtent, as as TextBoxFragment, at as TextRun, au as TypesetBidiSlice, av as TypesetClusterAdvance, aw as TypesetRow, ax as TypesetRowSegment, ay as TypesetRunAdvance, az as WrapTextDirection, aA as assertExhaustiveLayoutBlock, aB as isTextWrappingFloatingImageRun, aC as pageGeometryFromPage, aD as resolveAnchoredObjectVerticalTop } from '../../types-Buyw6dFd.mjs';
3
3
  import '../../content-BzoC6bSz.mjs';
4
4
  import '../../formatting-gqLFeJ9X.mjs';
5
5
  import '../../docx/wrapTypes.mjs';
@@ -1,19 +1,21 @@
1
- import { a as DisplayPage, b as DisplayPrimitive, D as DisplayList, G as GlyphRunPrimitive, L as LinePrimitive, T as TextRunPrimitive } from '../../frameDelta-CVt5FAXT.mjs';
2
- export { c as DecodedFrameDelta, d as DecorationPrimitive, e as DisplayBounds, f as DocAttrs, F as FRAME_DELTA_HEADER_BYTES, g as FRAME_DELTA_PAGE_OP_BYTES, h as FRAME_DELTA_VERSION, i as FrameDeltaError, j as FrameDeltaErrorCode, k as FramePageOperation, H as HfRegion, I as ImagePrimitive, P as PositionedGlyph, l as RectPrimitive, R as RetainedFrame, m as RetainedFramePage, n as TableCellRef, o as applyFrameDelta, p as applyFrameDeltaOwned, q as decodeFrameDelta, r as displayPageRevision } from '../../frameDelta-CVt5FAXT.mjs';
3
- export { a as DisplayListBuildInputs, D as DisplayListHeadersFooters, b as DisplayListHfVariant, c as DisplayListPictureWatermark, d as DisplayListTextWatermark, e as DisplayListWatermark, f as RustDisplayFrameResult, g as RustDisplayListEngine, R as RustDisplayListQueryEngine, h as RustDisplayListSourceError, i as RustDisplayListSourceErrorStage, j as buildRustDisplayFrame, k as buildRustDisplayList, l as encodeDisplayListFrameExtras, m as loadRustDisplayListQueryEngine } from '../../rustDisplayList-CwOoUn3t.mjs';
4
- import { a as DisplayListQueries, b as DisplayListRegionHit, D as DisplayListRect } from '../../displayListQueries-BYFrBkw5.mjs';
5
- export { c as DisplayListHitRegion, d as DisplayListHoverTarget, e as DisplayListImageGeometry, f as DisplayListImageRegion, g as DisplayListParagraphGeometry, h as DisplayListQuerySourceState, i as DisplayListVerticalMove, j as DisplayListVisualLine, L as LocatedImagePrimitive, R as ResidentDisplayListQueryEngine, k as captureInlinePositionEmuFromDisplayList, l as createDisplayListQueries, m as findImagePrimitiveAtPoint, n as findImagePrimitiveByDocPos, o as isDisplayListQuerySourceDead, p as onDisplayListQuerySourceFailure } from '../../displayListQueries-BYFrBkw5.mjs';
6
- import { u as YrsLoc, Y as YrsSession, v as YrsRevisionInfo } from '../../index-BbZwdkPz.mjs';
1
+ import { a as DisplayPage, G as GlyphRunPrimitive, L as LinePrimitive, T as TextRunPrimitive, b as DisplayPrimitive, D as DisplayList } from '../../frameDelta-ByU7HBuB.mjs';
2
+ export { c as DecodedFrameDelta, d as DecorationPrimitive, e as DisplayBounds, f as DocAttrs, F as FRAME_DELTA_HEADER_BYTES, g as FRAME_DELTA_PAGE_OP_BYTES, h as FRAME_DELTA_VERSION, i as FrameDeltaError, j as FrameDeltaErrorCode, k as FramePageOperation, H as HfRegion, I as ImagePrimitive, P as PositionedGlyph, l as RectPrimitive, R as RetainedFrame, m as RetainedFramePage, n as TableCellRef, o as applyFrameDelta, p as applyFrameDeltaOwned, q as decodeFrameDelta, r as displayPageNoteAnchorRevision, s as displayPageRevision } from '../../frameDelta-ByU7HBuB.mjs';
3
+ export { a as DisplayListBuildInputs, D as DisplayListHeadersFooters, b as DisplayListHfVariant, c as DisplayListPictureWatermark, d as DisplayListTextWatermark, e as DisplayListWatermark, f as RustDisplayFrameResult, g as RustDisplayListEngine, R as RustDisplayListQueryEngine, h as RustDisplayListSourceError, i as RustDisplayListSourceErrorStage, j as buildRustDisplayFrame, k as buildRustDisplayList, l as encodeDisplayListFrameExtras, m as loadRustDisplayListQueryEngine } from '../../rustDisplayList-DcaA5iok.mjs';
4
+ import { a as DisplayListQueries, b as DisplayListRegionHit, D as DisplayListRect } from '../../displayListQueries-DnHmHUPY.mjs';
5
+ export { c as DisplayListHitRegion, d as DisplayListHoverTarget, e as DisplayListImageGeometry, f as DisplayListImageRegion, g as DisplayListParagraphGeometry, h as DisplayListQuerySourceState, i as DisplayListVerticalMove, j as DisplayListVisualLine, L as LocatedImagePrimitive, R as ResidentDisplayListQueryEngine, V as VisualLineExtent, k as captureInlinePositionEmuFromDisplayList, l as createDisplayListQueries, m as endDisplayListQueriesLine, n as findImagePrimitiveAtPoint, o as findImagePrimitiveByDocPos, p as isDisplayListQuerySourceDead, q as onDisplayListQuerySourceFailure } from '../../displayListQueries-DnHmHUPY.mjs';
6
+ import { u as YrsLoc, v as YrsStorySegment, Y as YrsSession, w as YrsRevisionInfo } from '../../index-yOtBET85.mjs';
7
7
  import { TrackedChangeEntry } from '../../utils/comments.mjs';
8
8
  import '../../formatting-gqLFeJ9X.mjs';
9
9
  import '../../content-BzoC6bSz.mjs';
10
10
  import '../../docx/wrapTypes.mjs';
11
- import '../../types-B4jD0rrc.mjs';
11
+ import '../../types-Buyw6dFd.mjs';
12
12
  import '../pagination/index.mjs';
13
13
  import '../../types/document.mjs';
14
14
  import '../../styles-AryxLAhx.mjs';
15
- import '../../pagedExport-D3E4jZ-B.mjs';
15
+ import '../../pagedExport-BmSlEhoP.mjs';
16
+ import '../../loadWasmAsset-Cr95TImt.mjs';
16
17
  import '../../rezip-Bxiq4Z_R.mjs';
18
+ import '../../plugin-api/index.mjs';
17
19
 
18
20
  /** a cached glyph: its outline path (font units) plus the font's units-per-em. */
19
21
  interface GlyphOutline {
@@ -148,6 +150,34 @@ interface BuildMirrorPageOptions {
148
150
  /** localized aria-labels for page/header/footer wrappers */
149
151
  labels?: MirrorLabels;
150
152
  }
153
+ /** Whether `buildMirrorPage(page)` holds a table header cell, which cells on other pages may name. */
154
+ declare function mirrorPageHasHeaderCells(page: DisplayPage): boolean;
155
+ /** Whether `buildMirrorPage(page)` holds a link Tab stops at. */
156
+ declare function mirrorPageHasTabStops(page: DisplayPage): boolean;
157
+ /**
158
+ * Reduces a `buildMirrorPage` tree, in place, to its links, its notes (the
159
+ * targets of note references), its header cells (which cells on any page may
160
+ * name) and the elements that label what stays. What stays inside a table
161
+ * cell keeps the whole outermost cell, so the cell keeps its accessible name.
162
+ * Every other element and text goes; the ancestors of what stays keep their
163
+ * attributes, so the ids, order, positions and table semantics that remain
164
+ * are the full mirror's.
165
+ */
166
+ declare function reduceMirrorToLinks(mirror: HTMLElement): HTMLElement;
167
+ /** `buildMirrorPage(page)` reduced to its links: see `reduceMirrorToLinks`. */
168
+ declare function buildMirrorPageLinks(page: DisplayPage, options?: BuildMirrorPageOptions): HTMLElement;
169
+ /**
170
+ * Reduces a `buildMirrorPage` tree, in place, to what a screen reader reads:
171
+ * everything `reduceMirrorToLinks` keeps, unchanged, plus the text of every
172
+ * other run as plain text inside its paragraph, table and region wrappers,
173
+ * and images with an accessible name. Wrappers that hold no kept element lose
174
+ * their ids and data attributes, so painter-contract queries never match them.
175
+ */
176
+ declare function reduceMirrorToText(mirror: HTMLElement): HTMLElement;
177
+ /** `buildMirrorPage(page)` reduced to readable text: see `reduceMirrorToText`. */
178
+ declare function buildMirrorPageText(page: DisplayPage, options?: BuildMirrorPageOptions): HTMLElement;
179
+ /** Whether `page`'s mirror holds the note or note reference with element id `id`. */
180
+ declare function displayPageHoldsMirrorId(page: DisplayPage, id: string): boolean;
151
181
  /**
152
182
  * build the mirror DOM for one display page: an invisible (opacity 0,
153
183
  * pointer-events none) absolutely-positioned tree whose elements sit at the
@@ -173,6 +203,23 @@ interface BuildMirrorPageOptions {
173
203
  */
174
204
  declare function buildMirrorPage(page: DisplayPage, options?: BuildMirrorPageOptions): HTMLElement;
175
205
 
206
+ /** Renderer-neutral page-local geometry for display-list primitives. */
207
+
208
+ interface GeoRect {
209
+ x: number;
210
+ y: number;
211
+ w: number;
212
+ h: number;
213
+ }
214
+ /** Parse the px size from a CSS font shorthand, with Word's 11pt default. */
215
+ declare function fontSizePxFromShorthand(font: string): number;
216
+ /** Canonical page-local box for a text-run primitive. */
217
+ declare function textRunRect(p: Pick<TextRunPrimitive, 'x' | 'baselineY' | 'width' | 'font'>): GeoRect;
218
+ /** Canonical page-local box for a shaped glyph-run primitive. */
219
+ declare function glyphRunRect(p: Pick<GlyphRunPrimitive, 'glyphs' | 'size'>): GeoRect;
220
+ /** Canonical stroke-expanded page-local box for a line primitive. */
221
+ declare function lineRect(p: Pick<LinePrimitive, 'x1' | 'y1' | 'x2' | 'y2' | 'strokeWidth'>): GeoRect;
222
+
176
223
  /**
177
224
  * Framework-neutral interactive overlay for canvas-rendered content controls.
178
225
  *
@@ -209,6 +256,8 @@ declare function applyInteractiveSdtFocus(root: ParentNode, focusedGroupIds: Rea
209
256
  * pointer events; only real buttons are interactive/focusable.
210
257
  */
211
258
  declare function buildInteractiveOverlayPage(page: DisplayPage, options?: BuildInteractiveOverlayOptions): HTMLElement;
259
+ /** Whether `buildInteractiveOverlayPage(page)` holds a control Tab stops at. */
260
+ declare function interactiveOverlayHasTabStops(page: DisplayPage): boolean;
212
261
 
213
262
  /**
214
263
  * Resolves an image relationship id to a drawable source. Media decode stays
@@ -221,6 +270,8 @@ interface DrawPageOptions {
221
270
  resolveImage?: ImageResolver;
222
271
  /** Glyph cache; unresolved outlines fall back to `fillText`. */
223
272
  glyphCache?: GlyphCache;
273
+ /** The CSS family each document font family paints browser text with, where they differ. */
274
+ fontFamilies?: ReadonlyMap<string, string>;
224
275
  }
225
276
  /**
226
277
  * Minimal structural view of a canvas element for DPR sizing. Matches
@@ -264,28 +315,11 @@ declare function presentOffscreenPageBackBuffer(canvas: OffscreenCanvas, buffer:
264
315
  declare function sizeCanvasForPage(canvas: PageCanvasLike, ctx: CanvasRenderingContext2D, page: Pick<DisplayPage, 'width' | 'height'>, devicePixelRatio: number, zoom?: number): void;
265
316
  /** Raster every display page without requiring a mounted renderer surface. */
266
317
  declare function rasterizeDisplayListPages(list: DisplayList, options?: DrawPageOptions, devicePixelRatio?: number): Promise<HTMLCanvasElement[]>;
267
- /** Replays a page in primitive order, including body and header/footer bands. */
318
+ /** Replays watermark, header/footer, body and note layers. */
268
319
  declare function drawDisplayPage(ctx: CanvasRenderingContext2D, page: DisplayPage, options?: DrawPageOptions): Promise<void>;
269
320
  /** Replays a single primitive; exported for hosts that paint incrementally. */
270
321
  declare function drawPrimitive(ctx: CanvasRenderingContext2D, primitive: DisplayPrimitive, options?: DrawPageOptions): Promise<void>;
271
322
 
272
- /** Renderer-neutral page-local geometry for display-list primitives. */
273
-
274
- interface GeoRect {
275
- x: number;
276
- y: number;
277
- w: number;
278
- h: number;
279
- }
280
- /** Parse the px size from a CSS font shorthand, with Word's 11pt default. */
281
- declare function fontSizePxFromShorthand(font: string): number;
282
- /** Canonical page-local box for a text-run primitive. */
283
- declare function textRunRect(p: Pick<TextRunPrimitive, 'x' | 'baselineY' | 'width' | 'font'>): GeoRect;
284
- /** Canonical page-local box for a shaped glyph-run primitive. */
285
- declare function glyphRunRect(p: Pick<GlyphRunPrimitive, 'glyphs' | 'size'>): GeoRect;
286
- /** Canonical stroke-expanded page-local box for a line primitive. */
287
- declare function lineRect(p: Pick<LinePrimitive, 'x1' | 'y1' | 'x2' | 'y2' | 'strokeWidth'>): GeoRect;
288
-
289
323
  /** Shared vertical geometry for canvas page hosts. */
290
324
 
291
325
  /** vertical gap between canvas pages (flex `gap`) */
@@ -333,6 +367,51 @@ interface DisplayPageClientRect {
333
367
  width: number;
334
368
  height: number;
335
369
  }
370
+ /**
371
+ * The CSS `zoom` `element` renders at, its ancestors' included. Client rects
372
+ * carry it; layout sizes and an element's scroll offsets do not. Where
373
+ * `currentCSSZoom` is unavailable, zoom set inside a closed shadow tree the
374
+ * element is slotted through cannot be read and is left out.
375
+ */
376
+ declare function effectiveZoom(element: Element): number;
377
+ /**
378
+ * The page canvases a renderer mounts under its pages host, so page lookups
379
+ * read them instead of searching a subtree that also holds every page's
380
+ * accessibility mirror. A renderer adds each `<canvas data-page-index>` it
381
+ * mounts, deletes it on unmount, invalidates the registry whenever it may have
382
+ * moved or renumbered them, and binds the registry to the host with
383
+ * {@link bindDisplayPageRegistry}.
384
+ */
385
+ declare class DisplayPageRegistry {
386
+ private readonly canvases;
387
+ private ordered;
388
+ private byIndex;
389
+ private materializer;
390
+ /**
391
+ * Lets a renderer that keeps page DOM only near the viewport build the
392
+ * DOM of other pages when something needs it; see {@link materializeDisplayPages}.
393
+ */
394
+ setMaterializer(materializer: ((pageIndices: readonly number[]) => void) | null): void;
395
+ /** Builds the DOM of `pageIndices` now, where the renderer keeps it only for some pages. */
396
+ materialize(pageIndices: readonly number[]): void;
397
+ add(canvas: HTMLCanvasElement): void;
398
+ delete(canvas: HTMLCanvasElement): void;
399
+ /** Forgets the order and indices read so far, after the renderer moved or renumbered canvases. */
400
+ invalidate(): void;
401
+ /** The registered canvases in document order. */
402
+ all(): HTMLCanvasElement[];
403
+ /** The first canvas in document order that shows `pageIndex`. */
404
+ canvas(pageIndex: number): HTMLCanvasElement | null;
405
+ private indexPages;
406
+ }
407
+ /** Binds `registry` to the pages `host` it renders into, or unbinds it with null. */
408
+ declare function bindDisplayPageRegistry(host: HTMLElement, registry: DisplayPageRegistry | null): void;
409
+ /** Builds the accessibility DOM of `pageIndices` under `host` before a DOM query reads it. */
410
+ declare function materializeDisplayPages(host: HTMLElement, pageIndices: readonly number[]): void;
411
+ /** The first `<canvas data-page-index>` under `host` for `pageIndex`. */
412
+ declare function displayPageCanvas(host: HTMLElement, pageIndex: number): HTMLCanvasElement | null;
413
+ /** The canvas page elements inside a pages host, in document order. */
414
+ declare function displayPageCanvases(host: HTMLElement): HTMLCanvasElement[];
336
415
  /** Resolves a display-list page rectangle from canvas or DOM page hosts. */
337
416
  declare function resolveDisplayPageClientRect(host: HTMLElement, queries: DisplayListQueries, pageIndex: number, options?: DisplayPageHostOptions): DisplayPageClientRect | null;
338
417
  /**
@@ -355,17 +434,28 @@ declare function resolveCanvasPoint(host: HTMLElement, queries: DisplayListQueri
355
434
  * Image resolver for the canvas replay backend, shared by both adapters.
356
435
  *
357
436
  * v0 display lists carry the flow-block image `src` as the primitive's
358
- * relId — for embedded media that is a blob:/data: URL minted by the parser.
437
+ * relId — for embedded media that is a blob:/data: URL minted by the parser,
438
+ * or a `media:{n}` token naming the package part, whose bytes `media` reads.
359
439
  * Shape picture fills resolve through the same gate via
360
- * `fillPaint.pictureSrc`. Only those schemes are decoded; anything else
440
+ * `fillPaint.pictureSrc`. Only those sources are decoded; anything else
361
441
  * (notably remote http urls from external-mode relationships, or a raw
362
442
  * unresolved `rId`) resolves to null so opening a document never triggers a
363
- * network fetch (the no-zero-click-external-fetch security contract). Decode
443
+ * network fetch (the no-zero-click-external-fetch security contract). A token
444
+ * whose part this session cannot read paints a grey box. Decode
364
445
  * results are cached per source so repaints reuse the same HTMLImageElement.
365
446
  *
366
447
  */
367
448
 
368
- declare function createCanvasImageResolver(): ImageResolver;
449
+ interface CanvasImageResolverOptions {
450
+ /** The bytes and media type of a `media:{n}` source, or null. */
451
+ media?: (token: string) => {
452
+ bytes: Uint8Array;
453
+ mimeType: string;
454
+ } | null;
455
+ /** Identifies the package `media` reads; a new value decodes tokens anew. */
456
+ mediaScope?: () => number;
457
+ }
458
+ declare function createCanvasImageResolver(options?: CanvasImageResolverOptions): ImageResolver;
369
459
 
370
460
  /**
371
461
  * Selection → live-region announcement derivation for the canvas renderer's
@@ -426,6 +516,7 @@ interface A11yAnnouncement {
426
516
  */
427
517
  declare function computeA11yAnnouncements(prev: A11ySelectionSnapshot | null, next: A11ySelectionSnapshot): A11yAnnouncement[];
428
518
 
519
+ type SidebarReader = Pick<YrsSession, 'storyIds' | 'storySegments' | 'version' | 'paragraphs' | 'locateParagraph'>;
429
520
  /** A yrs location projected into the position space used by the display list. */
430
521
  interface YrsSidebarDisplayPoint {
431
522
  story: string;
@@ -438,6 +529,15 @@ interface YrsSidebarProjection {
438
529
  locToDisplayPoint(loc: YrsLoc): YrsSidebarDisplayPoint | null;
439
530
  storyOffsetToDisplayPoint(story: string, offset: number): YrsSidebarDisplayPoint | null;
440
531
  }
532
+ /**
533
+ * Where a sidebar projection reads story segments. `segments` must answer for the session's
534
+ * current state on every call, as `YrsSession.storySegments` does; the arrays it returns are shared
535
+ * and never mutated. A projection remembers the last source given for a session and reads
536
+ * through it for the session's lifetime.
537
+ */
538
+ interface YrsStorySegmentSource {
539
+ segments(story: string): YrsStorySegment[];
540
+ }
441
541
  /**
442
542
  * Convert a string yrs identity into the numeric id used by the existing
443
543
  * layout/sidebar contract. This is the same UTF-8 FNV-1a projection used by
@@ -448,8 +548,9 @@ declare function yrsIdToNumericId(value: string): number;
448
548
  * Build a lazy projection from live yrs stories to display positions.
449
549
  * The canonical yrs segment stream supplies paragraph/atom units; table-cell
450
550
  * and block-SDT stories are recursively sized so container tokens are included.
551
+ * A session gets the same projection back until its document changes.
451
552
  */
452
- declare function createYrsSidebarProjection(session: YrsSession): YrsSidebarProjection;
553
+ declare function createYrsSidebarProjection(session: SidebarReader, source?: YrsStorySegmentSource): YrsSidebarProjection;
453
554
 
454
555
  /**
455
556
  * Comment / tracked-change anchor derivation over the display list, shared
@@ -632,6 +733,8 @@ interface DisplayListTableInsertHoverInput {
632
733
  cellPmPosOf: (tableKey: string, row: number, col: number) => number | null;
633
734
  region?: DisplayListTableRegion;
634
735
  edgeProximity?: number;
736
+ /** Client px per CSS px of the button, which scales its offsets from the table. Default 1. */
737
+ buttonZoom?: number;
635
738
  }
636
739
  interface DisplayListTableInsertHoverHit {
637
740
  type: 'row' | 'column';
@@ -646,6 +749,11 @@ declare const DISPLAY_LIST_TABLE_INSERT_HIDE_DELAY_MS = 200;
646
749
  * in-cell doc position to its enclosing table's stable key (see module docs).
647
750
  */
648
751
  declare function deriveDisplayListTableFragments(list: DisplayList, tableKeyOf: TableKeyResolver): DisplayListTableFragment[];
752
+ /**
753
+ * [`deriveDisplayListTableFragments`] for the pages `start..=end` only. Each of
754
+ * their tables still takes its identity from every page it covers.
755
+ */
756
+ declare function deriveDisplayListTableFragmentsOnPages(list: DisplayList, tableKeyOf: TableKeyResolver, start: number, end: number): DisplayListTableFragment[];
649
757
  /**
650
758
  * Full selected-cell boxes for canvas overlays.
651
759
  *
@@ -688,4 +796,4 @@ declare function findDisplayListHyperlinkAtPoint(list: DisplayList, pageIndex: n
688
796
  */
689
797
  declare const demoDisplayList: DisplayList;
690
798
 
691
- export { type A11yAnnouncement, type A11yCommentThreadDetails, type A11ySelectionSnapshot, type AnchorEditorView, type BuildInteractiveOverlayOptions, type BuildMirrorPageOptions, CANVAS_PAGES_PADDING_PX, CANVAS_PAGE_GAP_PX, type CanvasPointHit, DISPLAY_LIST_TABLE_INSERT_HIDE_DELAY_MS, DisplayList, type DisplayListHfAnchorSource, type DisplayListHyperlinkHit, DisplayListQueries, DisplayListRect, DisplayListRegionHit, type DisplayListSelectedCellRect, type DisplayListSelectedCellSpec, type DisplayListTableFragment, type DisplayListTableInsertHoverHit, type DisplayListTableInsertHoverInput, type DisplayListTableRegion, DisplayPage, type DisplayPageClientRect, type DisplayPageHostOptions, DisplayPrimitive, type DrawPageOptions, type GeoRect, GlyphCache, type GlyphCacheOptions, type GlyphOutline, type GlyphOutlineProvider, GlyphRunPrimitive, type ImageResolver, type InteractiveOverlayLabels, LinePrimitive, MIRROR_CLASS_NAMES, type MirrorLabels, type PageCanvasBuffer, type PageCanvasLike, type TableKeyResolver, type TableRowBand, TextRunPrimitive, type TrackedChangesResult, type YrsHeaderFooterRegions, type YrsSidebarDisplayPoint, type YrsSidebarProjection, applyInteractiveSdtFocus, buildInteractiveOverlayPage, buildMirrorPage, canvasPageTops, computeA11yAnnouncements, computeAnchorPositionsFromDisplayList, computeAnchorPositionsFromYrs, createCanvasImageResolver, createYrsSidebarProjection, demoDisplayList, deriveDisplayListSelectedCellRects, deriveDisplayListTableFragments, detectDisplayListTableInsertHover, drawDisplayPage, drawPrimitive, extractTrackedChangesFromYrs, findDisplayListHyperlinkAtPoint, fontSizePxFromShorthand, glyphRunRect, lineRect, loadGlyphOutlineProvider, mergeHfAnchorPositionsFromDisplayList, presentDisplayPageBackBuffer, presentOffscreenPageBackBuffer, rasterizeDisplayListPages, rasterizeDisplayPageToBackBuffer, resolveCanvasPoint, resolveDisplayPageClientRect, sizeCanvasForPage, snapshotFromSelectionContext, textRunRect, visitAnchorKeys, yrsIdToNumericId };
799
+ export { type A11yAnnouncement, type A11yCommentThreadDetails, type A11ySelectionSnapshot, type AnchorEditorView, type BuildInteractiveOverlayOptions, type BuildMirrorPageOptions, CANVAS_PAGES_PADDING_PX, CANVAS_PAGE_GAP_PX, type CanvasImageResolverOptions, type CanvasPointHit, DISPLAY_LIST_TABLE_INSERT_HIDE_DELAY_MS, DisplayList, type DisplayListHfAnchorSource, type DisplayListHyperlinkHit, DisplayListQueries, DisplayListRect, DisplayListRegionHit, type DisplayListSelectedCellRect, type DisplayListSelectedCellSpec, type DisplayListTableFragment, type DisplayListTableInsertHoverHit, type DisplayListTableInsertHoverInput, type DisplayListTableRegion, DisplayPage, type DisplayPageClientRect, type DisplayPageHostOptions, DisplayPageRegistry, DisplayPrimitive, type DrawPageOptions, type GeoRect, GlyphCache, type GlyphCacheOptions, type GlyphOutline, type GlyphOutlineProvider, GlyphRunPrimitive, type ImageResolver, type InteractiveOverlayLabels, LinePrimitive, MIRROR_CLASS_NAMES, type MirrorLabels, type PageCanvasBuffer, type PageCanvasLike, type TableKeyResolver, type TableRowBand, TextRunPrimitive, type TrackedChangesResult, type YrsHeaderFooterRegions, type YrsSidebarDisplayPoint, type YrsSidebarProjection, type YrsStorySegmentSource, applyInteractiveSdtFocus, bindDisplayPageRegistry, buildInteractiveOverlayPage, buildMirrorPage, buildMirrorPageLinks, buildMirrorPageText, canvasPageTops, computeA11yAnnouncements, computeAnchorPositionsFromDisplayList, computeAnchorPositionsFromYrs, createCanvasImageResolver, createYrsSidebarProjection, demoDisplayList, deriveDisplayListSelectedCellRects, deriveDisplayListTableFragments, deriveDisplayListTableFragmentsOnPages, detectDisplayListTableInsertHover, displayPageCanvas, displayPageCanvases, displayPageHoldsMirrorId, drawDisplayPage, drawPrimitive, effectiveZoom, extractTrackedChangesFromYrs, findDisplayListHyperlinkAtPoint, fontSizePxFromShorthand, glyphRunRect, interactiveOverlayHasTabStops, lineRect, loadGlyphOutlineProvider, materializeDisplayPages, mergeHfAnchorPositionsFromDisplayList, mirrorPageHasHeaderCells, mirrorPageHasTabStops, presentDisplayPageBackBuffer, presentOffscreenPageBackBuffer, rasterizeDisplayListPages, rasterizeDisplayPageToBackBuffer, reduceMirrorToLinks, reduceMirrorToText, resolveCanvasPoint, resolveDisplayPageClientRect, sizeCanvasForPage, snapshotFromSelectionContext, textRunRect, visitAnchorKeys, yrsIdToNumericId };