@betteroffice/docx 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/README.md +64 -0
  2. package/dist/chunk-24Z6ZVFZ.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-6CHGYCFU.mjs +1 -0
  6. package/dist/chunk-AOWJ4WDE.mjs +1 -0
  7. package/dist/chunk-DLXIZBB6.mjs +1 -0
  8. package/dist/chunk-F2VBW6RB.mjs +1 -0
  9. package/dist/chunk-HPZFJGGM.mjs +0 -0
  10. package/dist/chunk-L2ML3DDI.mjs +1 -0
  11. package/dist/chunk-LIGZ75FP.mjs +1 -0
  12. package/dist/chunk-LT2GCWZ3.mjs +0 -0
  13. package/dist/chunk-ND3FBCB3.mjs +16 -0
  14. package/dist/{chunk-NT2OYIJ4.mjs → chunk-NMDQHUQB.mjs} +1 -1
  15. package/dist/chunk-NVN26RHH.mjs +1 -0
  16. package/dist/{chunk-H5YYCN42.mjs → chunk-OK5UFGX3.mjs} +1 -1
  17. package/dist/{chunk-VQXNED2P.mjs → chunk-RZQ3OXZY.mjs} +1 -1
  18. package/dist/{chunk-QE4ZDRKV.mjs → chunk-YLFKV2NT.mjs} +1 -1
  19. package/dist/collaboration/index.d.mts +5 -4
  20. package/dist/compareDocx-IHFPGIGV.mjs +1 -0
  21. package/dist/computeLayout-4MNWHE2T.mjs +1 -0
  22. package/dist/core.d.mts +4 -4
  23. package/dist/core.mjs +1 -1
  24. package/dist/{displayListQueries-BYFrBkw5.d.mts → displayListQueries-H5YnU_hX.d.mts} +23 -5
  25. package/dist/docx/index.mjs +1 -1
  26. package/dist/editor/index.d.mts +15 -7
  27. package/dist/editor/index.mjs +1 -1
  28. package/dist/{fontLoader-CkXcPB1C.d.mts → fontLoader-BNSs0E8K.d.mts} +54 -1
  29. package/dist/{frameDelta-CVt5FAXT.d.mts → frameDelta-ByU7HBuB.d.mts} +21 -1
  30. package/dist/generated/edit/docx_edit_bg.wasm +0 -0
  31. package/dist/generated/layout/docx_layout_bg.wasm +0 -0
  32. package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
  33. package/dist/generated/parse/docx_parse_bg.wasm +0 -0
  34. package/dist/{index-BbZwdkPz.d.mts → index-CHy6_Yuo.d.mts} +470 -14
  35. package/dist/layout/index.d.mts +2 -2
  36. package/dist/layout/index.mjs +1 -1
  37. package/dist/layout/pagination/index.d.mts +2 -2
  38. package/dist/layout/render/index.d.mts +118 -31
  39. package/dist/layout/render/index.mjs +1 -1
  40. package/dist/loadWasmAsset-Cr95TImt.d.mts +25 -0
  41. package/dist/{pagedExport-D3E4jZ-B.d.mts → pagedExport---0Dlmzo.d.mts} +1 -1
  42. package/dist/parseWasm-NLAG22EU.mjs +1 -0
  43. package/dist/plugin-api/RenderedDomContext.d.mts +6 -4
  44. package/dist/plugin-api/RenderedDomContext.mjs +1 -1
  45. package/dist/{rustDisplayList-CwOoUn3t.d.mts → rustDisplayList-LcRZHCSL.d.mts} +12 -4
  46. package/dist/{rustMeasureSource-CyBMcy1x.d.mts → rustMeasureSource-BkCx1FDx.d.mts} +2 -0
  47. package/dist/types/document.d.mts +3 -0
  48. package/dist/{types-B4jD0rrc.d.mts → types-D6Pra38E.d.mts} +12 -3
  49. package/dist/utils/index.d.mts +14 -2
  50. package/dist/utils/index.mjs +1 -1
  51. package/dist/wasm-GSI2XMOH.mjs +1 -0
  52. package/dist/{wasm-G62X4WRW.mjs → wasm-K6DRABAA.mjs} +1 -1
  53. package/dist/wasm-NF6B3AH7.mjs +1 -0
  54. package/dist/wasm-edit.d.mts +177 -18
  55. package/dist/wasm-edit.mjs +1 -1
  56. package/dist/wasm-layout.d.mts +1 -1
  57. package/dist/wasm-layout.mjs +1 -1
  58. package/dist/wasm-opc.d.mts +1 -1
  59. package/dist/wasm-opc.mjs +1 -1
  60. package/dist/wasm-parse.d.mts +1 -1
  61. package/dist/wasm-parse.mjs +1 -1
  62. package/dist/yrs/index.d.mts +4 -3
  63. package/dist/yrs/index.mjs +1 -1
  64. package/dist/yrs/residentEngineWorker.mjs +1 -1
  65. package/package.json +2 -2
  66. package/dist/chunk-5B4VMUXM.mjs +0 -16
  67. package/dist/chunk-5F6DLQZP.mjs +0 -1
  68. package/dist/chunk-5JEQC76K.mjs +0 -1
  69. package/dist/chunk-7GJG6LLU.mjs +0 -1
  70. package/dist/chunk-FE6FWGBJ.mjs +0 -1
  71. package/dist/chunk-HLDJMU3R.mjs +0 -1
  72. package/dist/chunk-J7LNO6SM.mjs +0 -1
  73. package/dist/chunk-PGMXWI5X.mjs +0 -1
  74. package/dist/chunk-Z4HZIPBS.mjs +0 -1
  75. package/dist/compareDocx-XXTZV4CG.mjs +0 -1
  76. package/dist/computeLayout-LWLAJWYA.mjs +0 -1
  77. package/dist/loadWasmAsset-CMvnVkfA.d.mts +0 -3
  78. 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-K6DRABAA.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-D6Pra38E.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-D6Pra38E.mjs';
3
3
  import '../../content-BzoC6bSz.mjs';
4
4
  import '../../formatting-gqLFeJ9X.mjs';
5
5
  import '../../docx/wrapTypes.mjs';
@@ -1,18 +1,19 @@
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-LcRZHCSL.mjs';
4
+ import { a as DisplayListQueries, b as DisplayListRegionHit, D as DisplayListRect } from '../../displayListQueries-H5YnU_hX.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-H5YnU_hX.mjs';
6
+ import { u as YrsLoc, Y as YrsSession, v as YrsRevisionInfo } from '../../index-CHy6_Yuo.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-D6Pra38E.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---0Dlmzo.mjs';
16
+ import '../../loadWasmAsset-Cr95TImt.mjs';
16
17
  import '../../rezip-Bxiq4Z_R.mjs';
17
18
 
18
19
  /** a cached glyph: its outline path (font units) plus the font's units-per-em. */
@@ -148,6 +149,24 @@ interface BuildMirrorPageOptions {
148
149
  /** localized aria-labels for page/header/footer wrappers */
149
150
  labels?: MirrorLabels;
150
151
  }
152
+ /** Whether `buildMirrorPage(page)` holds a table header cell, which cells on other pages may name. */
153
+ declare function mirrorPageHasHeaderCells(page: DisplayPage): boolean;
154
+ /** Whether `buildMirrorPage(page)` holds a link Tab stops at. */
155
+ declare function mirrorPageHasTabStops(page: DisplayPage): boolean;
156
+ /**
157
+ * Reduces a `buildMirrorPage` tree, in place, to its links, its notes (the
158
+ * targets of note references), its header cells (which cells on any page may
159
+ * name) and the elements that label what stays. What stays inside a table
160
+ * cell keeps the whole outermost cell, so the cell keeps its accessible name.
161
+ * Every other element and text goes; the ancestors of what stays keep their
162
+ * attributes, so the ids, order, positions and table semantics that remain
163
+ * are the full mirror's.
164
+ */
165
+ declare function reduceMirrorToLinks(mirror: HTMLElement): HTMLElement;
166
+ /** `buildMirrorPage(page)` reduced to its links: see `reduceMirrorToLinks`. */
167
+ declare function buildMirrorPageLinks(page: DisplayPage, options?: BuildMirrorPageOptions): HTMLElement;
168
+ /** Whether `page`'s mirror holds the note or note reference with element id `id`. */
169
+ declare function displayPageHoldsMirrorId(page: DisplayPage, id: string): boolean;
151
170
  /**
152
171
  * build the mirror DOM for one display page: an invisible (opacity 0,
153
172
  * pointer-events none) absolutely-positioned tree whose elements sit at the
@@ -173,6 +192,23 @@ interface BuildMirrorPageOptions {
173
192
  */
174
193
  declare function buildMirrorPage(page: DisplayPage, options?: BuildMirrorPageOptions): HTMLElement;
175
194
 
195
+ /** Renderer-neutral page-local geometry for display-list primitives. */
196
+
197
+ interface GeoRect {
198
+ x: number;
199
+ y: number;
200
+ w: number;
201
+ h: number;
202
+ }
203
+ /** Parse the px size from a CSS font shorthand, with Word's 11pt default. */
204
+ declare function fontSizePxFromShorthand(font: string): number;
205
+ /** Canonical page-local box for a text-run primitive. */
206
+ declare function textRunRect(p: Pick<TextRunPrimitive, 'x' | 'baselineY' | 'width' | 'font'>): GeoRect;
207
+ /** Canonical page-local box for a shaped glyph-run primitive. */
208
+ declare function glyphRunRect(p: Pick<GlyphRunPrimitive, 'glyphs' | 'size'>): GeoRect;
209
+ /** Canonical stroke-expanded page-local box for a line primitive. */
210
+ declare function lineRect(p: Pick<LinePrimitive, 'x1' | 'y1' | 'x2' | 'y2' | 'strokeWidth'>): GeoRect;
211
+
176
212
  /**
177
213
  * Framework-neutral interactive overlay for canvas-rendered content controls.
178
214
  *
@@ -209,6 +245,8 @@ declare function applyInteractiveSdtFocus(root: ParentNode, focusedGroupIds: Rea
209
245
  * pointer events; only real buttons are interactive/focusable.
210
246
  */
211
247
  declare function buildInteractiveOverlayPage(page: DisplayPage, options?: BuildInteractiveOverlayOptions): HTMLElement;
248
+ /** Whether `buildInteractiveOverlayPage(page)` holds a control Tab stops at. */
249
+ declare function interactiveOverlayHasTabStops(page: DisplayPage): boolean;
212
250
 
213
251
  /**
214
252
  * Resolves an image relationship id to a drawable source. Media decode stays
@@ -221,6 +259,8 @@ interface DrawPageOptions {
221
259
  resolveImage?: ImageResolver;
222
260
  /** Glyph cache; unresolved outlines fall back to `fillText`. */
223
261
  glyphCache?: GlyphCache;
262
+ /** The CSS family each document font family paints browser text with, where they differ. */
263
+ fontFamilies?: ReadonlyMap<string, string>;
224
264
  }
225
265
  /**
226
266
  * Minimal structural view of a canvas element for DPR sizing. Matches
@@ -264,28 +304,11 @@ declare function presentOffscreenPageBackBuffer(canvas: OffscreenCanvas, buffer:
264
304
  declare function sizeCanvasForPage(canvas: PageCanvasLike, ctx: CanvasRenderingContext2D, page: Pick<DisplayPage, 'width' | 'height'>, devicePixelRatio: number, zoom?: number): void;
265
305
  /** Raster every display page without requiring a mounted renderer surface. */
266
306
  declare function rasterizeDisplayListPages(list: DisplayList, options?: DrawPageOptions, devicePixelRatio?: number): Promise<HTMLCanvasElement[]>;
267
- /** Replays a page in primitive order, including body and header/footer bands. */
307
+ /** Replays watermark, header/footer, body and note layers. */
268
308
  declare function drawDisplayPage(ctx: CanvasRenderingContext2D, page: DisplayPage, options?: DrawPageOptions): Promise<void>;
269
309
  /** Replays a single primitive; exported for hosts that paint incrementally. */
270
310
  declare function drawPrimitive(ctx: CanvasRenderingContext2D, primitive: DisplayPrimitive, options?: DrawPageOptions): Promise<void>;
271
311
 
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
312
  /** Shared vertical geometry for canvas page hosts. */
290
313
 
291
314
  /** vertical gap between canvas pages (flex `gap`) */
@@ -333,6 +356,51 @@ interface DisplayPageClientRect {
333
356
  width: number;
334
357
  height: number;
335
358
  }
359
+ /**
360
+ * The CSS `zoom` `element` renders at, its ancestors' included. Client rects
361
+ * carry it; layout sizes and an element's scroll offsets do not. Where
362
+ * `currentCSSZoom` is unavailable, zoom set inside a closed shadow tree the
363
+ * element is slotted through cannot be read and is left out.
364
+ */
365
+ declare function effectiveZoom(element: Element): number;
366
+ /**
367
+ * The page canvases a renderer mounts under its pages host, so page lookups
368
+ * read them instead of searching a subtree that also holds every page's
369
+ * accessibility mirror. A renderer adds each `<canvas data-page-index>` it
370
+ * mounts, deletes it on unmount, invalidates the registry whenever it may have
371
+ * moved or renumbered them, and binds the registry to the host with
372
+ * {@link bindDisplayPageRegistry}.
373
+ */
374
+ declare class DisplayPageRegistry {
375
+ private readonly canvases;
376
+ private ordered;
377
+ private byIndex;
378
+ private materializer;
379
+ /**
380
+ * Lets a renderer that keeps page DOM only near the viewport build the
381
+ * DOM of other pages when something needs it; see {@link materializeDisplayPages}.
382
+ */
383
+ setMaterializer(materializer: ((pageIndices: readonly number[]) => void) | null): void;
384
+ /** Builds the DOM of `pageIndices` now, where the renderer keeps it only for some pages. */
385
+ materialize(pageIndices: readonly number[]): void;
386
+ add(canvas: HTMLCanvasElement): void;
387
+ delete(canvas: HTMLCanvasElement): void;
388
+ /** Forgets the order and indices read so far, after the renderer moved or renumbered canvases. */
389
+ invalidate(): void;
390
+ /** The registered canvases in document order. */
391
+ all(): HTMLCanvasElement[];
392
+ /** The first canvas in document order that shows `pageIndex`. */
393
+ canvas(pageIndex: number): HTMLCanvasElement | null;
394
+ private indexPages;
395
+ }
396
+ /** Binds `registry` to the pages `host` it renders into, or unbinds it with null. */
397
+ declare function bindDisplayPageRegistry(host: HTMLElement, registry: DisplayPageRegistry | null): void;
398
+ /** Builds the accessibility DOM of `pageIndices` under `host` before a DOM query reads it. */
399
+ declare function materializeDisplayPages(host: HTMLElement, pageIndices: readonly number[]): void;
400
+ /** The first `<canvas data-page-index>` under `host` for `pageIndex`. */
401
+ declare function displayPageCanvas(host: HTMLElement, pageIndex: number): HTMLCanvasElement | null;
402
+ /** The canvas page elements inside a pages host, in document order. */
403
+ declare function displayPageCanvases(host: HTMLElement): HTMLCanvasElement[];
336
404
  /** Resolves a display-list page rectangle from canvas or DOM page hosts. */
337
405
  declare function resolveDisplayPageClientRect(host: HTMLElement, queries: DisplayListQueries, pageIndex: number, options?: DisplayPageHostOptions): DisplayPageClientRect | null;
338
406
  /**
@@ -355,17 +423,28 @@ declare function resolveCanvasPoint(host: HTMLElement, queries: DisplayListQueri
355
423
  * Image resolver for the canvas replay backend, shared by both adapters.
356
424
  *
357
425
  * 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.
426
+ * relId — for embedded media that is a blob:/data: URL minted by the parser,
427
+ * or a `media:{n}` token naming the package part, whose bytes `media` reads.
359
428
  * Shape picture fills resolve through the same gate via
360
- * `fillPaint.pictureSrc`. Only those schemes are decoded; anything else
429
+ * `fillPaint.pictureSrc`. Only those sources are decoded; anything else
361
430
  * (notably remote http urls from external-mode relationships, or a raw
362
431
  * unresolved `rId`) resolves to null so opening a document never triggers a
363
- * network fetch (the no-zero-click-external-fetch security contract). Decode
432
+ * network fetch (the no-zero-click-external-fetch security contract). A token
433
+ * whose part this session cannot read paints a grey box. Decode
364
434
  * results are cached per source so repaints reuse the same HTMLImageElement.
365
435
  *
366
436
  */
367
437
 
368
- declare function createCanvasImageResolver(): ImageResolver;
438
+ interface CanvasImageResolverOptions {
439
+ /** The bytes and media type of a `media:{n}` source, or null. */
440
+ media?: (token: string) => {
441
+ bytes: Uint8Array;
442
+ mimeType: string;
443
+ } | null;
444
+ /** Identifies the package `media` reads; a new value decodes tokens anew. */
445
+ mediaScope?: () => number;
446
+ }
447
+ declare function createCanvasImageResolver(options?: CanvasImageResolverOptions): ImageResolver;
369
448
 
370
449
  /**
371
450
  * Selection → live-region announcement derivation for the canvas renderer's
@@ -448,6 +527,7 @@ declare function yrsIdToNumericId(value: string): number;
448
527
  * Build a lazy projection from live yrs stories to display positions.
449
528
  * The canonical yrs segment stream supplies paragraph/atom units; table-cell
450
529
  * and block-SDT stories are recursively sized so container tokens are included.
530
+ * A session gets the same projection back until its document changes.
451
531
  */
452
532
  declare function createYrsSidebarProjection(session: YrsSession): YrsSidebarProjection;
453
533
 
@@ -632,6 +712,8 @@ interface DisplayListTableInsertHoverInput {
632
712
  cellPmPosOf: (tableKey: string, row: number, col: number) => number | null;
633
713
  region?: DisplayListTableRegion;
634
714
  edgeProximity?: number;
715
+ /** Client px per CSS px of the button, which scales its offsets from the table. Default 1. */
716
+ buttonZoom?: number;
635
717
  }
636
718
  interface DisplayListTableInsertHoverHit {
637
719
  type: 'row' | 'column';
@@ -646,6 +728,11 @@ declare const DISPLAY_LIST_TABLE_INSERT_HIDE_DELAY_MS = 200;
646
728
  * in-cell doc position to its enclosing table's stable key (see module docs).
647
729
  */
648
730
  declare function deriveDisplayListTableFragments(list: DisplayList, tableKeyOf: TableKeyResolver): DisplayListTableFragment[];
731
+ /**
732
+ * [`deriveDisplayListTableFragments`] for the pages `start..=end` only. Each of
733
+ * their tables still takes its identity from every page it covers.
734
+ */
735
+ declare function deriveDisplayListTableFragmentsOnPages(list: DisplayList, tableKeyOf: TableKeyResolver, start: number, end: number): DisplayListTableFragment[];
649
736
  /**
650
737
  * Full selected-cell boxes for canvas overlays.
651
738
  *
@@ -688,4 +775,4 @@ declare function findDisplayListHyperlinkAtPoint(list: DisplayList, pageIndex: n
688
775
  */
689
776
  declare const demoDisplayList: DisplayList;
690
777
 
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 };
778
+ 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, applyInteractiveSdtFocus, bindDisplayPageRegistry, buildInteractiveOverlayPage, buildMirrorPage, buildMirrorPageLinks, 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, resolveCanvasPoint, resolveDisplayPageClientRect, sizeCanvasForPage, snapshotFromSelectionContext, textRunRect, visitAnchorKeys, yrsIdToNumericId };