@betteroffice/docx 0.2.1 → 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 (91) hide show
  1. package/README.md +586 -3
  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-NMDQHUQB.mjs +57 -0
  15. package/dist/chunk-NVN26RHH.mjs +1 -0
  16. package/dist/chunk-OK5UFGX3.mjs +1 -0
  17. package/dist/chunk-RZQ3OXZY.mjs +2 -0
  18. package/dist/chunk-YLFKV2NT.mjs +1 -0
  19. package/dist/collaboration/index.d.mts +9 -6
  20. package/dist/compareDocx-IHFPGIGV.mjs +1 -0
  21. package/dist/computeLayout-4MNWHE2T.mjs +1 -0
  22. package/dist/{content-CvEtPl0c.d.mts → content-BzoC6bSz.d.mts} +48 -8
  23. package/dist/core.d.mts +172 -9
  24. package/dist/core.mjs +1 -1
  25. package/dist/{displayListQueries-DF8F6fMl.d.mts → displayListQueries-H5YnU_hX.d.mts} +23 -5
  26. package/dist/docx/index.d.mts +5 -4
  27. package/dist/docx/index.mjs +1 -1
  28. package/dist/editor/index.d.mts +19 -9
  29. package/dist/editor/index.mjs +1 -1
  30. package/dist/{fontLoader-b8eicJKV.d.mts → fontLoader-BNSs0E8K.d.mts} +55 -2
  31. package/dist/{formatting-7zKCTu5a.d.mts → formatting-gqLFeJ9X.d.mts} +8 -0
  32. package/dist/{frameDelta-pA4jrQ1G.d.mts → frameDelta-ByU7HBuB.d.mts} +34 -3
  33. package/dist/generated/edit/docx_edit_bg.wasm +0 -0
  34. package/dist/generated/layout/docx_layout_bg.wasm +0 -0
  35. package/dist/generated/opc/ooxml_opc_bg.wasm +0 -0
  36. package/dist/generated/parse/docx_parse_bg.wasm +0 -0
  37. package/dist/index-CHy6_Yuo.d.mts +2026 -0
  38. package/dist/layout/index.d.mts +6 -6
  39. package/dist/layout/index.mjs +1 -1
  40. package/dist/layout/pagination/index.d.mts +4 -4
  41. package/dist/layout/render/index.d.mts +122 -33
  42. package/dist/layout/render/index.mjs +1 -1
  43. package/dist/loadWasmAsset-Cr95TImt.d.mts +25 -0
  44. package/dist/pagedExport---0Dlmzo.d.mts +907 -0
  45. package/dist/parseWasm-NLAG22EU.mjs +1 -0
  46. package/dist/plugin-api/RenderedDomContext.d.mts +12 -9
  47. package/dist/plugin-api/RenderedDomContext.mjs +1 -1
  48. package/dist/plugin-api/index.d.mts +21 -4
  49. package/dist/plugin-api/resolveItemPositions.d.mts +3 -3
  50. package/dist/rezip-Bxiq4Z_R.d.mts +24 -0
  51. package/dist/{rustDisplayList-BJqaN9tt.d.mts → rustDisplayList-LcRZHCSL.d.mts} +12 -4
  52. package/dist/{rustMeasureSource-C0EZB055.d.mts → rustMeasureSource-BkCx1FDx.d.mts} +14 -4
  53. package/dist/{selectiveSave-CRh-_Y_C.d.mts → selectiveSave-r-NMK6aI.d.mts} +1 -22
  54. package/dist/styles/index.d.mts +2 -2
  55. package/dist/{styles-7e-mq3c-.d.mts → styles-AryxLAhx.d.mts} +1 -1
  56. package/dist/types/content.d.mts +2 -2
  57. package/dist/types/document.d.mts +9 -6
  58. package/dist/{types-C4A8mWjU.d.mts → types-D6Pra38E.d.mts} +31 -5
  59. package/dist/utils/comments.d.mts +2 -2
  60. package/dist/utils/index.d.mts +20 -5
  61. package/dist/utils/index.mjs +1 -1
  62. package/dist/utils/stylePreview.d.mts +2 -2
  63. package/dist/wasm-GSI2XMOH.mjs +1 -0
  64. package/dist/wasm-K6DRABAA.mjs +1 -0
  65. package/dist/wasm-NF6B3AH7.mjs +1 -0
  66. package/dist/wasm-edit.d.mts +420 -28
  67. package/dist/wasm-edit.mjs +1 -1
  68. package/dist/wasm-layout.d.mts +9 -2
  69. package/dist/wasm-layout.mjs +1 -1
  70. package/dist/wasm-opc.d.mts +1 -1
  71. package/dist/wasm-opc.mjs +1 -1
  72. package/dist/wasm-parse.d.mts +1 -1
  73. package/dist/wasm-parse.mjs +1 -1
  74. package/dist/yrs/index.d.mts +8 -5
  75. package/dist/yrs/index.mjs +1 -1
  76. package/dist/yrs/residentEngineWorker.mjs +1 -1
  77. package/package.json +2 -2
  78. package/dist/chunk-5F6DLQZP.mjs +0 -1
  79. package/dist/chunk-6LQJAKOC.mjs +0 -1
  80. package/dist/chunk-AFMVSI4Z.mjs +0 -57
  81. package/dist/chunk-GD4VNJ64.mjs +0 -1
  82. package/dist/chunk-HLDJMU3R.mjs +0 -1
  83. package/dist/chunk-J7LNO6SM.mjs +0 -1
  84. package/dist/chunk-JHJLG4I6.mjs +0 -16
  85. package/dist/chunk-PGMXWI5X.mjs +0 -1
  86. package/dist/chunk-WRWRCBLK.mjs +0 -1
  87. package/dist/chunk-WTFRNX5K.mjs +0 -1
  88. package/dist/index-CHl2zLJ7.d.mts +0 -1142
  89. package/dist/loadWasmAsset-CMvnVkfA.d.mts +0 -3
  90. package/dist/wasm-7SOSHNGP.mjs +0 -1
  91. package/dist/wasm-ZQAVP7P2.mjs +0 -1
@@ -1,11 +1,11 @@
1
- import { B as BundledFontProvider } from '../rustMeasureSource-C0EZB055.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-C0EZB055.mjs';
3
- import { f as SectionProperties, H as HeaderFooter } from '../content-CvEtPl0c.mjs';
4
- export { D as DrawingScene, V as DrawingSceneNode, b as ShapeEffect, aX as ShapeFillPaint, aY as ShapeStrokePaint, c as ShapeTextBodyProperties } from '../content-CvEtPl0c.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
+ import { f as SectionProperties, H as HeaderFooter } from '../content-BzoC6bSz.mjs';
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';
6
- import '../formatting-7zKCTu5a.mjs';
6
+ import '../formatting-gqLFeJ9X.mjs';
7
7
  import '../docx/wrapTypes.mjs';
8
- import '../styles-7e-mq3c-.mjs';
8
+ import '../styles-AryxLAhx.mjs';
9
9
 
10
10
  /** Opt-in bundled-font provider resolution. @packageDocumentation */
11
11
 
@@ -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(s){if(s===void 0)return;let e=typeof s=="string"?s:s.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(s){I={...s,baseUrl:q(s.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:s,fonts:e,load:t}=I;try{return (e??await t()).createFontProvider(s===void 0?void 0:{baseUrl:s})}catch(r){console.warn("[configureDefaultFonts] the configured font source failed to load",r);return}}function M(){if(!U())return Promise.resolve(void 0);if(R===void 0){let s=K();s.then(e=>{e===void 0&&R===s&&(R=void 0);}),R=s;}return R}function $(s){return s.trim().toLowerCase()}function C(s,e,t){return `${$(s)}|${e?1:0}|${t?1:0}`}function k(s,e,t,r){t.then(o=>{r(o)&&s.get(e)===t&&s.delete(e);},()=>{s.get(e)===t&&s.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(r=>{r===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 r=$(t.family),o=this.facesByFamily.get(r);o?o.push(t):this.facesByFamily.set(r,[t]);}this.chains=new Map,this.chainResults=new Map;}getFontIdChain(e,t,r){let o=C(e,t,r),i=this.chains.get(o);if(!i){let n=this.chains,a=this.chainResults,f=this.generation,u=this.resolveChain(e,t,r);u.then(d=>{f===this.generation&&(a.set(o,d),d.retryable&&n.get(o)===u&&n.delete(o));},()=>{n.get(o)===u&&n.delete(o);}),n.set(o,u),i=u;}return i.then(n=>n.ids)}getCachedFontIdChain(e,t,r,o=true){let i=C(e,t,r),n=this.chainResults.get(i);if(o&&n?.retryable){let a=this.chainResults;queueMicrotask(()=>{a.get(i)===n&&a.delete(i);});}return n?.ids}getScriptFallbackIds(e){let t=[...new Set(e)];return Promise.all(t.map(r=>this.resolveScript(r))).then(r=>{let o=[];for(let{id:i}of r)i!==null&&!o.includes(i)&&o.push(i);return o})}getCachedScriptFallbackIds(e,t=true){let r=this.scriptResults,o=[];for(let n of e){let a=r.get(n);if(!a)return;o.push([n,a]);}let i=[];for(let[n,a]of o){let{id:f}=a;f!==null&&!i.includes(f)&&i.push(f),t&&a.retryable&&queueMicrotask(()=>{r.get(n)===a&&r.delete(n);});}return i}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,r){let o=C(e,t,r),i=[],n=false,a=this.pickEmbeddedFace(e,t,r);if(a){let l=await this.registerFace(a);l!==null?i.push(l):n=true;}let f=await this.bundled();f===void 0&&typeof this.bundledSource=="function"&&(n=true);let u;try{u=f?.resolve(e,t,r);}catch(l){n=true,console.warn(`[fontRegistry] bundled face resolver for "${e}" failed; falling back: ${l instanceof Error?l.message:String(l)}`);}if(u){let l=await this.registerBundled(o,u,e);l!==null&&!i.includes(l)&&i.push(l),l===null&&(n=true);}let d;try{d=f?.resolveLastResort?.(e,t,r);}catch(l){n=true,console.warn(`[fontRegistry] last-resort resolver for "${e}" failed; falling back: ${l instanceof Error?l.message:String(l)}`);}if(d){let l=await this.registerLastResort(o,d,e);l!==null&&!i.includes(l)&&i.push(l),l===null&&(n=true);}return i.length===0&&this.warnFallback(e,f!==void 0,u!==void 0||d!==void 0),{ids:i,retryable:n}}warnFallback(e,t,r){if(this.warnedFallback)return;this.warnedFallback=true;let o="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(r?`[fontRegistry] no font bytes for "${e}" \u2014 the font provider resolved but every matching face failed to load. ${o} 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. ${o}`:`[fontRegistry] no font bytes for "${e}" \u2014 no font provider is configured. Install @betteroffice/fonts and pass it with configureDefaultFonts({ fonts }). `+o);}pickEmbeddedFace(e,t,r){let o=this.facesByFamily.get($(e));if(!o)return;let i=t?"bold":"normal",n=r?"italic":"normal";return o.find(a=>a.weight===i&&a.style===n)??o.find(a=>a.weight==="normal"&&a.style==="normal")}registerBuffer(e){let t=this.bufferIds.get(e);if(!t){let r=this.bufferIds;t=Promise.resolve().then(()=>this.sink.registerFont(new Uint8Array(e))),k(r,e,t,()=>false),r.set(e,t);}return t}registerFace(e){let t=this.faceIds.get(e);if(!t){let r=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(r,e,t,o=>o===null),r.set(e,t);}return t}registerBundled(e,t,r){let o=this.bundledIds.get(e);if(!o){let i=this.bundledIds;o=(async()=>{try{let n=await t();return await this.registerBuffer(n)}catch(n){return console.warn(`[fontRegistry] bundled face for "${r}" failed to load or register; falling back: ${n instanceof Error?n.message:String(n)}`),null}})(),k(i,e,o,n=>n===null),i.set(e,o);}return o}registerLastResort(e,t,r){let o=this.lastResortIds.get(e);if(!o){let i=this.lastResortIds;o=(async()=>{try{let n=await t();return await this.registerBuffer(n)}catch{return console.warn(`[fontRegistry] last-resort base face for "${r}" failed to load or register; falling back`),null}})(),k(i,e,o,n=>n===null),i.set(e,o);}return o}resolveScript(e){let t=this.scriptIds.get(e);if(!t){let r=this.scriptIds,o=this.scriptResults;t=(async()=>{let i=null,n=false,a=await this.bundled();a===void 0&&typeof this.bundledSource=="function"&&(n=true);let f;try{f=a?.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(f)try{let d=await f();i=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 u={id:i,retryable:n};return o.set(e,u),u})(),k(r,e,t,i=>i.retryable),r.set(e,t);}return t}};var L=null;function j(){return L??(L=import('../wasm-ZQAVP7P2.mjs').then(async s=>(await s.preloadLayoutWasm(),{registerFont:s.registerMeasureFont,clearFonts:s.clearMeasureFonts}))),L}function V(s){let e=new x({registerFont:r=>s.engine.registerFont(r)},{bundled:s.bundled??M}),t;return {setEmbeddedFaces(r){e.setEmbeddedFaces(r);},setCompat(r){t=r;},async prepareFontRequirements(r){return (await Promise.all(r.flatMap(i=>[(async()=>{try{return e.getCachedFontIdChain(i.family,i.bold,i.italic,!1)!==void 0?!1:(await e.getFontIdChain(i.family,i.bold,i.italic),!0)}catch{return false}})(),...Array.from(new Set(i.scripts??[]),async n=>{try{return e.getCachedScriptFallbackIds([n],!1)!==void 0?!1:(await e.getScriptFallbackIds([n]),!0)}catch{return false}})]))).some(Boolean)},measurementConfigForRequirements(r){let o=r.map(n=>({requirement:n,familyIds:e.getCachedFontIdChain(n.family,n.bold,n.italic,false),scriptIds:e.getCachedScriptFallbackIds(n.scripts??[],false)}));if(o.some(({familyIds:n,scriptIds:a})=>n===void 0||a===void 0))return;let i={};for(let{requirement:n}of o){let a=e.getCachedFontIdChain(n.family,n.bold,n.italic),f=e.getCachedScriptFallbackIds(n.scripts??[]);if(a===void 0||f===void 0)return;let u=Array.from(a);for(let d of f)u.includes(d)||u.push(d);u.length>0&&(i[n.key]=u);}return {fontChains:i,defaults:{fontSize:11,fontFamily:"Calibri"},compat:{noLeading:t?.noLeading??false,doNotExpandShiftReturn:t?.doNotExpandShiftReturn??false},authoritativeShaping:true}},clear(){e.clear();}}}var _=1056;function G(s,e){let t=s?.package.headers,r=s?.package.footers,o=e?.headerReferences?.find(F=>F.type==="default"),i=e?.headerReferences?.find(F=>F.type==="first"),n=e?.footerReferences?.find(F=>F.type==="default"),a=e?.footerReferences?.find(F=>F.type==="first"),f=o?t?.get(o.rId)??null:null,u=n?r?.get(n.rId)??null:null,d=i?t?.get(i.rId)??null:null,l=a?r?.get(a.rId)??null:null;return e?.titlePg||(f??(f=d),u??(u=l)),{header:f,footer:u,firstHeader:d,firstFooter:l}}var g,b,m,y,w,B,T,A=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,A 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,7 +1,7 @@
1
- import { b as LayoutBlock, B as BlockExtent } from '../../types-C4A8mWjU.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-C4A8mWjU.mjs';
3
- import '../../content-CvEtPl0c.mjs';
4
- import '../../formatting-7zKCTu5a.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
+ import '../../content-BzoC6bSz.mjs';
4
+ import '../../formatting-gqLFeJ9X.mjs';
5
5
  import '../../docx/wrapTypes.mjs';
6
6
 
7
7
  interface MeasuredBlock {
@@ -1,17 +1,20 @@
1
- import { a as DisplayPage, b as DisplayPrimitive, D as DisplayList, G as GlyphRunPrimitive, L as LinePrimitive, T as TextRunPrimitive } from '../../frameDelta-pA4jrQ1G.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 } from '../../frameDelta-pA4jrQ1G.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-BJqaN9tt.mjs';
4
- import { a as DisplayListQueries, b as DisplayListRegionHit, D as DisplayListRect } from '../../displayListQueries-DF8F6fMl.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-DF8F6fMl.mjs';
6
- import { u as YrsLoc, Y as YrsSession, v as YrsRevisionInfo } from '../../index-CHl2zLJ7.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
- import '../../formatting-7zKCTu5a.mjs';
9
- import '../../content-CvEtPl0c.mjs';
8
+ import '../../formatting-gqLFeJ9X.mjs';
9
+ import '../../content-BzoC6bSz.mjs';
10
10
  import '../../docx/wrapTypes.mjs';
11
- import '../../types-C4A8mWjU.mjs';
11
+ import '../../types-D6Pra38E.mjs';
12
12
  import '../pagination/index.mjs';
13
13
  import '../../types/document.mjs';
14
- import '../../styles-7e-mq3c-.mjs';
14
+ import '../../styles-AryxLAhx.mjs';
15
+ import '../../pagedExport---0Dlmzo.mjs';
16
+ import '../../loadWasmAsset-Cr95TImt.mjs';
17
+ import '../../rezip-Bxiq4Z_R.mjs';
15
18
 
16
19
  /** a cached glyph: its outline path (font units) plus the font's units-per-em. */
17
20
  interface GlyphOutline {
@@ -146,6 +149,24 @@ interface BuildMirrorPageOptions {
146
149
  /** localized aria-labels for page/header/footer wrappers */
147
150
  labels?: MirrorLabels;
148
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;
149
170
  /**
150
171
  * build the mirror DOM for one display page: an invisible (opacity 0,
151
172
  * pointer-events none) absolutely-positioned tree whose elements sit at the
@@ -171,6 +192,23 @@ interface BuildMirrorPageOptions {
171
192
  */
172
193
  declare function buildMirrorPage(page: DisplayPage, options?: BuildMirrorPageOptions): HTMLElement;
173
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
+
174
212
  /**
175
213
  * Framework-neutral interactive overlay for canvas-rendered content controls.
176
214
  *
@@ -207,6 +245,8 @@ declare function applyInteractiveSdtFocus(root: ParentNode, focusedGroupIds: Rea
207
245
  * pointer events; only real buttons are interactive/focusable.
208
246
  */
209
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;
210
250
 
211
251
  /**
212
252
  * Resolves an image relationship id to a drawable source. Media decode stays
@@ -219,6 +259,8 @@ interface DrawPageOptions {
219
259
  resolveImage?: ImageResolver;
220
260
  /** Glyph cache; unresolved outlines fall back to `fillText`. */
221
261
  glyphCache?: GlyphCache;
262
+ /** The CSS family each document font family paints browser text with, where they differ. */
263
+ fontFamilies?: ReadonlyMap<string, string>;
222
264
  }
223
265
  /**
224
266
  * Minimal structural view of a canvas element for DPR sizing. Matches
@@ -262,28 +304,11 @@ declare function presentOffscreenPageBackBuffer(canvas: OffscreenCanvas, buffer:
262
304
  declare function sizeCanvasForPage(canvas: PageCanvasLike, ctx: CanvasRenderingContext2D, page: Pick<DisplayPage, 'width' | 'height'>, devicePixelRatio: number, zoom?: number): void;
263
305
  /** Raster every display page without requiring a mounted renderer surface. */
264
306
  declare function rasterizeDisplayListPages(list: DisplayList, options?: DrawPageOptions, devicePixelRatio?: number): Promise<HTMLCanvasElement[]>;
265
- /** Replays a page in primitive order, including body and header/footer bands. */
307
+ /** Replays watermark, header/footer, body and note layers. */
266
308
  declare function drawDisplayPage(ctx: CanvasRenderingContext2D, page: DisplayPage, options?: DrawPageOptions): Promise<void>;
267
309
  /** Replays a single primitive; exported for hosts that paint incrementally. */
268
310
  declare function drawPrimitive(ctx: CanvasRenderingContext2D, primitive: DisplayPrimitive, options?: DrawPageOptions): Promise<void>;
269
311
 
270
- /** Renderer-neutral page-local geometry for display-list primitives. */
271
-
272
- interface GeoRect {
273
- x: number;
274
- y: number;
275
- w: number;
276
- h: number;
277
- }
278
- /** Parse the px size from a CSS font shorthand, with Word's 11pt default. */
279
- declare function fontSizePxFromShorthand(font: string): number;
280
- /** Canonical page-local box for a text-run primitive. */
281
- declare function textRunRect(p: Pick<TextRunPrimitive, 'x' | 'baselineY' | 'width' | 'font'>): GeoRect;
282
- /** Canonical page-local box for a shaped glyph-run primitive. */
283
- declare function glyphRunRect(p: Pick<GlyphRunPrimitive, 'glyphs' | 'size'>): GeoRect;
284
- /** Canonical stroke-expanded page-local box for a line primitive. */
285
- declare function lineRect(p: Pick<LinePrimitive, 'x1' | 'y1' | 'x2' | 'y2' | 'strokeWidth'>): GeoRect;
286
-
287
312
  /** Shared vertical geometry for canvas page hosts. */
288
313
 
289
314
  /** vertical gap between canvas pages (flex `gap`) */
@@ -331,6 +356,51 @@ interface DisplayPageClientRect {
331
356
  width: number;
332
357
  height: number;
333
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[];
334
404
  /** Resolves a display-list page rectangle from canvas or DOM page hosts. */
335
405
  declare function resolveDisplayPageClientRect(host: HTMLElement, queries: DisplayListQueries, pageIndex: number, options?: DisplayPageHostOptions): DisplayPageClientRect | null;
336
406
  /**
@@ -353,17 +423,28 @@ declare function resolveCanvasPoint(host: HTMLElement, queries: DisplayListQueri
353
423
  * Image resolver for the canvas replay backend, shared by both adapters.
354
424
  *
355
425
  * v0 display lists carry the flow-block image `src` as the primitive's
356
- * 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.
357
428
  * Shape picture fills resolve through the same gate via
358
- * `fillPaint.pictureSrc`. Only those schemes are decoded; anything else
429
+ * `fillPaint.pictureSrc`. Only those sources are decoded; anything else
359
430
  * (notably remote http urls from external-mode relationships, or a raw
360
431
  * unresolved `rId`) resolves to null so opening a document never triggers a
361
- * 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
362
434
  * results are cached per source so repaints reuse the same HTMLImageElement.
363
435
  *
364
436
  */
365
437
 
366
- 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;
367
448
 
368
449
  /**
369
450
  * Selection → live-region announcement derivation for the canvas renderer's
@@ -446,6 +527,7 @@ declare function yrsIdToNumericId(value: string): number;
446
527
  * Build a lazy projection from live yrs stories to display positions.
447
528
  * The canonical yrs segment stream supplies paragraph/atom units; table-cell
448
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.
449
531
  */
450
532
  declare function createYrsSidebarProjection(session: YrsSession): YrsSidebarProjection;
451
533
 
@@ -630,6 +712,8 @@ interface DisplayListTableInsertHoverInput {
630
712
  cellPmPosOf: (tableKey: string, row: number, col: number) => number | null;
631
713
  region?: DisplayListTableRegion;
632
714
  edgeProximity?: number;
715
+ /** Client px per CSS px of the button, which scales its offsets from the table. Default 1. */
716
+ buttonZoom?: number;
633
717
  }
634
718
  interface DisplayListTableInsertHoverHit {
635
719
  type: 'row' | 'column';
@@ -644,6 +728,11 @@ declare const DISPLAY_LIST_TABLE_INSERT_HIDE_DELAY_MS = 200;
644
728
  * in-cell doc position to its enclosing table's stable key (see module docs).
645
729
  */
646
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[];
647
736
  /**
648
737
  * Full selected-cell boxes for canvas overlays.
649
738
  *
@@ -686,4 +775,4 @@ declare function findDisplayListHyperlinkAtPoint(list: DisplayList, pageIndex: n
686
775
  */
687
776
  declare const demoDisplayList: DisplayList;
688
777
 
689
- 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 };