@betteroffice/docx 0.0.2 → 0.0.4

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 (65) hide show
  1. package/README.md +20 -7
  2. package/dist/chunk-4V6MDZIK.mjs +1 -0
  3. package/dist/chunk-6KDV6AIL.mjs +1 -0
  4. package/dist/chunk-CTBUQRYQ.mjs +1 -0
  5. package/dist/chunk-GGEGIQRK.mjs +1 -0
  6. package/dist/chunk-J7LNO6SM.mjs +1 -0
  7. package/dist/{chunk-IFT6DUJX.mjs → chunk-LTVVQMHB.mjs} +1 -1
  8. package/dist/chunk-NBSLB77E.mjs +1 -0
  9. package/dist/chunk-NTSSE5QK.mjs +57 -0
  10. package/dist/chunk-YTILOUAA.mjs +16 -0
  11. package/dist/collaboration/index.d.mts +31 -6
  12. package/dist/collaboration/index.mjs +1 -1
  13. package/dist/{content-DLFHRQav.d.mts → content-C3sTRz-u.d.mts} +115 -248
  14. package/dist/core.d.mts +6 -6
  15. package/dist/core.mjs +1 -1
  16. package/dist/{displayListQueries-UGc_XBUv.d.mts → displayListQueries-DLzpvJV6.d.mts} +36 -7
  17. package/dist/docx/index.d.mts +3 -3
  18. package/dist/docx/index.mjs +1 -1
  19. package/dist/editor/index.d.mts +7 -6
  20. package/dist/{fontLoader-aSewHMKF.d.mts → fontLoader-CMH3bZ2Z.d.mts} +127 -2
  21. package/dist/{formatting-D1EPSaJP.d.mts → formatting-BEkIBePP.d.mts} +77 -203
  22. package/dist/{rustDisplayList-CX78djsZ.d.mts → frameDelta-B2kC6XiP.d.mts} +5 -274
  23. package/dist/generated/edit/docx_edit_bg.wasm +0 -0
  24. package/dist/generated/layout/docx_layout_bg.wasm +0 -0
  25. package/dist/generated/parse/docx_parse_bg.wasm +0 -0
  26. package/dist/{index-Bwxm3oiC.d.mts → index-2piKi4gO.d.mts} +147 -8
  27. package/dist/layout/index.d.mts +8 -6
  28. package/dist/layout/index.mjs +1 -1
  29. package/dist/layout/pagination/index.d.mts +4 -4
  30. package/dist/layout/pagination/index.mjs +1 -1
  31. package/dist/layout/render/index.d.mts +10 -9
  32. package/dist/layout/render/index.mjs +1 -1
  33. package/dist/plugin-api/RenderedDomContext.d.mts +7 -6
  34. package/dist/plugin-api/index.d.mts +3 -3
  35. package/dist/plugin-api/resolveItemPositions.d.mts +3 -3
  36. package/dist/rustDisplayList-B0M2eBkU.d.mts +283 -0
  37. package/dist/styles/index.d.mts +2 -2
  38. package/dist/{styles-Dn_o3Vo5.d.mts → styles-BK3Jecxs.d.mts} +1 -1
  39. package/dist/types/content.d.mts +2 -2
  40. package/dist/types/document.d.mts +6 -6
  41. package/dist/{types-DMkDbvEu.d.mts → types-C1rv3KM-.d.mts} +2 -2
  42. package/dist/utils/comments.d.mts +2 -2
  43. package/dist/utils/index.d.mts +4 -4
  44. package/dist/utils/index.mjs +1 -1
  45. package/dist/utils/stylePreview.d.mts +2 -2
  46. package/dist/utils/units.d.mts +4 -34
  47. package/dist/utils/units.mjs +1 -1
  48. package/dist/wasm-F2ETFAYL.mjs +1 -0
  49. package/dist/wasm-JE7B3ROD.mjs +1 -0
  50. package/dist/wasm-edit.d.mts +25 -0
  51. package/dist/wasm-edit.mjs +1 -1
  52. package/dist/wasm-layout.d.mts +14 -1
  53. package/dist/wasm-layout.mjs +1 -1
  54. package/dist/yrs/index.d.mts +5 -4
  55. package/dist/yrs/index.mjs +1 -1
  56. package/dist/yrs/residentEngineWorker.mjs +1 -1
  57. package/package.json +1 -2
  58. package/dist/chunk-3UBMCDME.mjs +0 -1
  59. package/dist/chunk-6NEKRDXF.mjs +0 -1
  60. package/dist/chunk-AEQOEQJ7.mjs +0 -57
  61. package/dist/chunk-AZ52IWB6.mjs +0 -16
  62. package/dist/chunk-CIRN3LZA.mjs +0 -1
  63. package/dist/chunk-NTQM4EYN.mjs +0 -1
  64. package/dist/wasm-BGQBTR2J.mjs +0 -1
  65. package/dist/wasm-SA237OSP.mjs +0 -1
@@ -1 +1 @@
1
- import {b as b$1}from'../chunk-TTRUPDAB.mjs';var w=Number.MAX_SAFE_INTEGER,c=class extends Error{constructor(t){super(t),this.name="ProtocolError";}},b=class{constructor(t){b$1(this,"bytes",t);b$1(this,"offset",0);}get done(){return this.offset===this.bytes.byteLength}readVarUint(){let t=0,e=1,r=0;for(;;){if(this.offset>=this.bytes.byteLength)throw new c("Truncated varUint");let n=this.bytes[this.offset++],i=n&127;if(i>Math.floor((w-t)/e))throw new c("varUint exceeds Number.MAX_SAFE_INTEGER");if(t+=i*e,r+=1,(n&128)===0){if(r>1&&i===0)throw new c("Non-canonical varUint");return t}if(r>=8)throw new c("varUint exceeds Number.MAX_SAFE_INTEGER");e*=128;}}readVarUint8Array(){let t=this.readVarUint(),e=this.bytes.byteLength-this.offset;if(t>e)throw new c("Truncated varUint8Array");let r=this.bytes.slice(this.offset,this.offset+t);return this.offset+=t,r}readVarString(){let t=this.readVarUint8Array();try{return new TextDecoder("utf-8",{fatal:!0}).decode(t)}catch(e){throw new c(`Invalid UTF-8 string${e instanceof Error?`: ${e.message}`:""}`)}}};function u(o){if(!Number.isSafeInteger(o)||o<0)throw new c("varUint value must be a non-negative safe integer");let t=[],e=o;for(;e>=128;)t.push(e%128|128),e=Math.floor(e/128);return t.push(e),Uint8Array.from(t)}function C(o,t){let e=0;for(let i of o)if(e+=i.byteLength,e>t)throw new c(`Frame exceeds ${t} bytes`);let r=new Uint8Array(e),n=0;for(let i of o)r.set(i,n),n+=i.byteLength;return r}function f(o,t,e){return C([u(0),u(o),u(t.byteLength),t],e)}function A(o,t=16777216){return f(0,o,t)}function g(o,t=16777216){return f(1,o,t)}function U(o,t=16777216){return f(2,o,t)}function v(o=16777216){let t=Uint8Array.of(0);return C([u(1),u(t.byteLength),t],o)}function T(o,t=16777216,e=4096){if(!(o instanceof Uint8Array))throw new c("Frame must be a Uint8Array");if(o.byteLength===0)throw new c("Frame is empty");if(o.byteLength>t)throw new c(`Frame exceeds ${t} bytes`);if(!Number.isSafeInteger(e)||e<1)throw new c("Message limit must be a positive integer");let r=new b(o),n=[];for(;!r.done;){if(n.length>=e)throw new c(`Frame exceeds ${e} messages`);let i=r.readVarUint();switch(i){case 0:{let l=r.readVarUint(),y=r.readVarUint8Array();if(l===0)n.push({type:"sync-step-1",stateVector:y});else if(l===1)n.push({type:"sync-step-2",update:y});else if(l===2)n.push({type:"update",update:y});else throw new c(`Unknown sync message type ${l}`);break}case 1:n.push({type:"awareness",update:r.readVarUint8Array()});break;case 2:{let l=r.readVarUint();if(l!==0)throw new c(`Unknown auth message type ${l}`);n.push({type:"auth",reason:r.readVarString()});break}case 3:n.push({type:"query-awareness"});break;default:throw new c(`Unknown top-level message type ${i}`)}}return n}var p=class extends Error{constructor(e,r,n){super(r);b$1(this,"code");b$1(this,"cause");this.name="CollaborationError",this.code=e,this.cause=n;}};var L=16*1024*1024;function m(o,t,e){if(!Number.isSafeInteger(t)||t<(e?0:1))throw new RangeError(`${o} must be ${e?"a non-negative":"a positive"} integer`);return t}function x(o){return o instanceof Error&&o.message?o.message:typeof o=="string"&&o?o:"Unknown error"}function a(o,t,e){return e instanceof p?e:new p(o,`${t}: ${x(e)}`,e)}function E(o,t){if(!(o instanceof Uint8Array))throw new TypeError(`${t} must return a Uint8Array`);return o.slice()}var S=class{constructor(t,e,r={}){b$1(this,"replica");b$1(this,"transport");b$1(this,"maxFrameBytes");b$1(this,"maxMessagesPerFrame");b$1(this,"maxPendingBytes");b$1(this,"statusListeners",new Map);b$1(this,"errorListeners",new Map);b$1(this,"pendingFrames",[]);b$1(this,"unsubscribeReplica");b$1(this,"unsubscribeTransport",()=>{});b$1(this,"hasTransportSubscription",false);b$1(this,"connectionStatus","disconnected");b$1(this,"isSynced",false);b$1(this,"wantsConnection",false);b$1(this,"isOpen",false);b$1(this,"isDestroyed",false);b$1(this,"epoch",0);b$1(this,"connectAttempt",0);b$1(this,"nextListenerId",0);b$1(this,"queuedBytes",0);b$1(this,"isFlushing",false);this.replica=t,this.transport=e,this.maxFrameBytes=m("maxFrameBytes",r.maxFrameBytes??16777216,false),this.maxMessagesPerFrame=m("maxMessagesPerFrame",r.maxMessagesPerFrame??4096,false),this.maxPendingBytes=m("maxPendingBytes",r.maxPendingBytes??L,true);try{this.unsubscribeReplica=t.onUpdate((n,i)=>{i==="local"&&this.forwardLocalUpdate(n);});}catch(n){throw a("replica","Failed to observe replica updates",n)}}get status(){return this.connectionStatus}get synced(){return this.isSynced}get pendingBytes(){return this.queuedBytes}connect(){if(this.isDestroyed||this.isOpen||this.connectionStatus==="connecting")return;this.wantsConnection=true;let t=this.hasTransportSubscription?this.epoch:++this.epoch,e=++this.connectAttempt;if(this.setStatus("connecting",false),!!this.isCurrent(t)){if(!this.hasTransportSubscription){let r;try{if(r=this.transport.onEvent(n=>this.handleTransportEvent(t,n)),typeof r!="function")throw new TypeError("Transport event subscription must return a function")}catch(n){this.failConnection(t,a("transport","Failed to subscribe to transport events",n));return}if(!this.isCurrent(t)){try{r();}catch(n){this.isDestroyed||this.report(a("transport","Failed to unsubscribe from stale transport events",n));}return}this.unsubscribeTransport=r,this.hasTransportSubscription=true;}try{let r=this.transport.connect();r&&r.catch(n=>{this.isCurrent(t)&&this.connectAttempt===e&&this.failConnection(t,a("transport","Transport connect failed",n));});}catch(r){this.failConnection(t,a("transport","Transport connect failed",r));}}}disconnect(){if(this.isDestroyed||!(this.wantsConnection||this.isOpen||this.hasTransportSubscription||this.connectionStatus!=="disconnected"))return;this.wantsConnection=false,this.isOpen=false,this.epoch+=1,this.connectAttempt+=1;let e=this.takeTransportSubscription();this.clearPending();let r=this.cleanupTransport(e,true);this.setStatus("disconnected",false);for(let n of r)this.report(n);}destroy(){if(this.isDestroyed)return;let t=this.wantsConnection||this.isOpen||this.hasTransportSubscription||this.connectionStatus==="connecting"||this.connectionStatus==="connected";this.isDestroyed=true,this.wantsConnection=false,this.isOpen=false,this.epoch+=1,this.connectAttempt+=1;let e=this.takeTransportSubscription();this.clearPending();let r=this.cleanupTransport(e,t);this.setStatus("destroyed",false);for(let n of r)this.report(n);try{this.unsubscribeReplica();}catch(n){this.report(a("replica","Failed to unsubscribe from replica updates",n));}this.unsubscribeReplica=()=>{},this.statusListeners.clear(),this.errorListeners.clear();}onStatus(t){if(this.isDestroyed)return ()=>{};if(typeof t!="function")throw new TypeError("status listener must be a function");let e=this.nextListenerId++;return this.statusListeners.set(e,t),()=>this.statusListeners.delete(e)}onError(t){if(this.isDestroyed)return ()=>{};if(typeof t!="function")throw new TypeError("error listener must be a function");let e=this.nextListenerId++;return this.errorListeners.set(e,t),()=>this.errorListeners.delete(e)}isCurrent(t){return !this.isDestroyed&&this.wantsConnection&&t===this.epoch}failConnection(t,e){if(!this.isCurrent(t))return;this.wantsConnection=false,this.isOpen=false,this.epoch+=1,this.connectAttempt+=1;let r=this.takeTransportSubscription();this.clearPending();let n=this.cleanupTransport(r,true);this.setStatus("disconnected",false),this.report(e);for(let i of n)this.report(i);}takeTransportSubscription(){let t=this.unsubscribeTransport;return this.unsubscribeTransport=()=>{},this.hasTransportSubscription=false,t}cleanupTransport(t,e){let r=[];try{t();}catch(n){r.push(a("transport","Failed to unsubscribe from transport events",n));}if(!e)return r;try{let n=this.transport.disconnect();n&&n.catch(i=>{this.isDestroyed||this.report(a("transport","Transport disconnect failed",i));});}catch(n){r.push(a("transport","Transport disconnect failed",n));}return r}handleTransportEvent(t,e){if(this.isCurrent(t))switch(e.type){case "open":this.handleOpen(t);break;case "message":this.isOpen&&this.handleMessage(t,e.data);break;case "close":this.isOpen=false,this.connectAttempt+=1,this.clearPending(),this.setStatus("disconnected",false);break;case "error":this.failConnection(t,a("transport","Transport error",e.error));break;case "drain":this.isOpen&&this.flushPending();break;default:this.failConnection(t,new p("transport","Unknown transport event"));}}handleOpen(t){if(this.isOpen||(this.isOpen=true,this.clearPending(),this.setStatus("connected",false),!this.isCurrent(t)||!this.isOpen))return;let e;try{e=E(this.replica.encodeStateVector(),"encodeStateVector");}catch(r){this.failConnection(t,a("replica","Failed to encode replica state vector",r));return}try{this.sendFrame(A(e,this.maxFrameBytes));}catch(r){this.failConnection(t,a("protocol","Failed to encode SyncStep1",r));}}handleMessage(t,e){let r;try{r=T(e.slice(),this.maxFrameBytes,this.maxMessagesPerFrame);}catch(n){this.failConnection(t,a("protocol","Invalid collaboration frame",n));return}for(let n of r){if(!this.isCurrent(t)||!this.isOpen)return;switch(n.type){case "sync-step-1":this.respondToSyncStep1(t,n.stateVector);break;case "sync-step-2":this.applyRemoteUpdate(t,n.update)&&this.isCurrent(t)&&this.setStatus("connected",true);break;case "update":this.applyRemoteUpdate(t,n.update);break;case "awareness":break;case "auth":this.failConnection(t,new p("protocol",n.reason?`Authentication denied: ${n.reason}`:"Authentication denied"));return;case "query-awareness":try{this.sendFrame(v(this.maxFrameBytes));}catch(i){this.failConnection(t,a("protocol","Failed to encode awareness response",i));return}break}}}respondToSyncStep1(t,e){let r;try{r=E(this.replica.encodeStateAsUpdate(e.slice()),"encodeStateAsUpdate");}catch(n){this.failConnection(t,a("replica","Failed to encode replica update",n));return}try{this.sendFrame(g(r,this.maxFrameBytes));}catch(n){this.failConnection(t,a("protocol","Failed to encode SyncStep2",n));}}applyRemoteUpdate(t,e){try{return this.replica.applyUpdate(e.slice()),!0}catch(r){return this.failConnection(t,a("replica","Failed to apply remote update",r)),false}}forwardLocalUpdate(t){if(this.isDestroyed||!this.isOpen||!this.wantsConnection)return;let e=this.epoch,r;try{r=E(t,"Replica update");}catch(n){this.failConnection(e,a("replica","Invalid replica update",n));return}try{this.sendFrame(U(r,this.maxFrameBytes));}catch(n){this.failConnection(e,a("protocol","Failed to encode update",n));}}sendFrame(t){if(!this.isOpen||this.isDestroyed||!this.wantsConnection)return;let e=this.epoch;if(this.pendingFrames.length>0){this.queueFrame(e,t);return}let r;try{r=this.transport.send(t.slice());}catch(n){this.failConnection(e,a("transport","Transport send failed",n));return}if(typeof r!="boolean"){this.failConnection(e,new p("transport","Transport send must return a boolean"));return}!r&&this.isCurrent(e)&&this.isOpen&&this.queueFrame(e,t);}queueFrame(t,e){if(e.byteLength>this.maxPendingBytes-this.queuedBytes){this.failConnection(t,new p("backpressure",`Pending collaboration data exceeds ${this.maxPendingBytes} bytes`));return}let r=e.slice();this.pendingFrames.push(r),this.queuedBytes+=r.byteLength;}flushPending(){if(!this.isFlushing){this.isFlushing=true;try{for(;this.isOpen&&!this.isDestroyed&&this.pendingFrames.length>0;){let t=this.epoch,e=this.pendingFrames[0],r;try{r=this.transport.send(e.slice());}catch(n){this.failConnection(t,a("transport","Transport send failed",n));return}if(typeof r!="boolean"){this.failConnection(t,new p("transport","Transport send must return a boolean"));return}if(!r||!this.isOpen||this.pendingFrames[0]!==e)return;this.pendingFrames.shift(),this.queuedBytes-=e.byteLength;}}finally{this.isFlushing=false;}}}clearPending(){this.pendingFrames.length=0,this.queuedBytes=0;}setStatus(t,e){if(this.connectionStatus===t&&this.isSynced===e)return;this.connectionStatus=t,this.isSynced=e;let r={status:t,synced:e};for(let[n,i]of [...this.statusListeners])if(this.statusListeners.get(n)===i)try{i(r);}catch{}}report(t){for(let[e,r]of [...this.errorListeners])if(this.errorListeners.get(e)===r)try{r(t);}catch{}}};function P(o){return o}function M(o,t){return {clientId:o.clientId,encodeStateVector:()=>o.encodeStateVector(),encodeStateAsUpdate:e=>o.encodeStateAsUpdate(e?.slice()),applyUpdate:e=>{let r=e.slice();o.applyUpdate(r),t.invalidate(r,o.selection());},onUpdate:e=>o.onUpdate(e)}}export{p as CollaborationError,S as CollaborationProvider,P as createDirectCollaborationReplica,M as createWorkerCollaborationReplica};
1
+ import {b as b$1}from'../chunk-TTRUPDAB.mjs';var B=["#0B57D0","#B3261E","#137333","#7B1FA2","#A142F4","#A04B00","#006A6A","#455A64"],oe=/^#[0-9a-fA-F]{3}(?:[0-9a-fA-F]{3})?$/;function S(r,e){if(typeof e=="string"&&oe.test(e))return e;let t=Number.isSafeInteger(r)&&r>=0?r%B.length:0;return B[t]}function D(r,e){return r.byteLength===e.byteLength&&r.every((t,n)=>t===e[n])}function ae(r,e){return r===e||!!(r&&e&&r.story===e.story&&D(r.anchor,e.anchor)&&D(r.head,e.head))}function ie(r,e){return r?.clientId===e.clientId&&r.story===e.story&&r.paraId===e.paraId&&r.endOffset===e.endOffset}function V(r){return r?{story:r.story,anchor:r.anchor.slice(),head:r.head.slice()}:null}function ce(r){return r?{user:{...r.user},cursor:V(r.cursor)}:null}function X(r,e,t,n){let s=r,o=false;for(let a of e){if(a.clientId===t)continue;let u=s.get(a.clientId);if(!u&&s.size>=1024)continue;if(u&&a.clock<=u.clock){a.clock===u.clock&&n>u.lastSeenAt&&(s===r&&(s=new Map(r)),s.set(a.clientId,{...u,lastSeenAt:n}));continue}s===r&&(s=new Map(r));let h=a.state?.cursor!=null&&(u?.inferredCursor!=null||u?.state==null||!ae(u.state.cursor,a.state.cursor));s.set(a.clientId,{clientId:a.clientId,clock:a.clock,state:ce(a.state),lastSeenAt:n,cursorMovedAt:h?n:u?.cursorMovedAt??0,inferredCursor:null}),o=true;}return {records:s,peersChanged:o}}function $(r,e,t,n){if(e.clientId===t)return {records:r,peersChanged:false};let s=r.get(e.clientId);if(!s&&r.size>=1024)return {records:r,peersChanged:false};let o=new Map(r);return o.set(e.clientId,{clientId:e.clientId,clock:s?.clock??-1,state:s?.state??null,lastSeenAt:s?.lastSeenAt??n,cursorMovedAt:ie(s?.inferredCursor??null,e)?s?.cursorMovedAt??n:n,inferredCursor:{...e}}),{records:o,peersChanged:s?.state!=null}}function Y(r,e,t){let n=r,s=false;for(let[o,a]of r)e-a.lastSeenAt<t||(n===r&&(n=new Map(r)),n.delete(o),a.state&&(s=true));return {records:n,peersChanged:s}}function I(r){let e=[];for(let t of r.values()){if(!t.state)continue;let n={clientId:t.clientId,clock:t.clock,user:{...t.state.user},cursor:V(t.state.cursor)};e.push({...n,lastSeenAt:t.lastSeenAt,cursorMovedAt:t.cursorMovedAt,inferredCursor:t.inferredCursor?{...t.inferredCursor}:null});}return e.sort((t,n)=>t.clientId-n.clientId),e}var b=16777216,_=4096,q=0,j=1,ue=2,H=3,z=0,K=1,J=2,de=0,pe=Number.MAX_SAFE_INTEGER,c=class extends Error{constructor(e){super(e),this.name="ProtocolError";}},f=class extends c{},U=class{constructor(e){b$1(this,"bytes",e);b$1(this,"offset",0);}get done(){return this.offset===this.bytes.byteLength}readVarUint(){let e=0,t=1,n=0;for(;;){if(this.offset>=this.bytes.byteLength)throw new c("Truncated varUint");let s=this.bytes[this.offset++],o=s&127;if(o>Math.floor((pe-e)/t))throw new c("varUint exceeds Number.MAX_SAFE_INTEGER");if(e+=o*t,n+=1,(s&128)===0){if(n>1&&o===0)throw new c("Non-canonical varUint");return e}if(n>=8)throw new c("varUint exceeds Number.MAX_SAFE_INTEGER");t*=128;}}readVarUint8Array(){let e=this.readVarUint(),t=this.bytes.byteLength-this.offset;if(e>t)throw new c("Truncated varUint8Array");let n=this.bytes.slice(this.offset,this.offset+e);return this.offset+=e,n}skipVarUint8Array(){let e=this.readVarUint(),t=this.bytes.byteLength-this.offset;if(e>t)throw new c("Truncated varUint8Array");this.offset+=e;}readVarString(){let e=this.readVarUint8Array();try{return new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch(t){throw new c(`Invalid UTF-8 string${t instanceof Error?`: ${t.message}`:""}`)}}};function p(r){if(!Number.isSafeInteger(r)||r<0)throw new c("varUint value must be a non-negative safe integer");let e=[],t=r;for(;t>=128;)e.push(t%128|128),t=Math.floor(t/128);return e.push(t),Uint8Array.from(e)}function g(r,e){let t=0;for(let o of r)if(t+=o.byteLength,t>e)throw new c(`Frame exceeds ${e} bytes`);let n=new Uint8Array(t),s=0;for(let o of r)n.set(o,s),s+=o.byteLength;return n}function he(r){let e=new TextEncoder().encode(r);return g([p(e.byteLength),e],Number.MAX_SAFE_INTEGER)}function P(r,e,t){return g([p(q),p(r),p(e.byteLength),e],t)}function Q(r,e=b){return P(z,r,e)}function Z(r,e=b){return P(K,r,e)}function ee(r,e=b){return P(J,r,e)}function ye(r){return r.state===null?"null":JSON.stringify({user:r.state.user,cursor:r.state.cursor?{story:r.state.cursor.story,anchor:[...r.state.cursor.anchor],head:[...r.state.cursor.head]}:null})}function fe(r){let e=[p(r.length)];for(let t of r)e.push(p(t.clientId),p(t.clock),he(ye(t)));return g(e,Number.MAX_SAFE_INTEGER)}function R(r,e=b){let t=fe(r);return g([p(j),p(t.byteLength),t],e)}function L(r=b){return g([p(H)],r)}function G(r,e){if(!Array.isArray(r))throw new c(`${e} must be a byte array`);if(r.length>1024)throw new f(`${e} exceeds ${1024} bytes`);if(r.some(t=>!Number.isInteger(t)||t<0||t>255))throw new c(`${e} must be a byte array`);return Uint8Array.from(r)}function be(r,e){let t;try{t=JSON.parse(r);}catch{throw new c("Invalid awareness JSON")}if(t===null)return null;if(typeof t!="object"||Array.isArray(t))throw new c("Awareness state must be an object or null");let n=t,s=n.user;if(typeof s!="object"||s===null||Array.isArray(s))throw new c("Awareness user must be an object");let o=s;if(typeof o.name!="string")throw new c("Awareness user requires a string name");if(o.name.length>1024)throw new f(`Awareness user name exceeds ${1024} characters`);let a={name:o.name,color:S(e,o.color)},u=n.cursor;if(u==null)return {user:a,cursor:null};if(typeof u!="object"||Array.isArray(u))throw new c("Awareness cursor must be an object or null");let h=u;if(typeof h.story!="string")throw new c("Awareness cursor requires a string story");if(h.story.length>1024)throw new f(`Awareness cursor story exceeds ${1024} characters`);return {user:a,cursor:{story:h.story,anchor:G(h.anchor,"Awareness cursor anchor"),head:G(h.head,"Awareness cursor head")}}}function te(r,e={}){let t=new U(r),n=t.readVarUint();if(n>r.byteLength)throw new c("Invalid awareness entry count");let s=new Set(e.trackedClientIds);e.localClientId!==void 0&&s.delete(e.localClientId);let o=new Set,a=m=>{o.has(m.message)||(o.add(m.message),e.onDiscard?.(m));};n>1024&&a(new f(`Awareness update exceeds ${1024} entries`));let u=[],h=Math.min(n,1024);for(let m=0;m<h;m+=1){let A=t.readVarUint(),ne=t.readVarUint();if(!(A===e.localClientId||s.has(A))&&s.size>=1024){t.skipVarUint8Array(),a(new f(`Awareness peer limit of ${1024} reached`));continue}let se=t.readVarString(),O;try{O=be(se,A);}catch(x){if(!(x instanceof f))throw x;a(x);continue}u.push({clientId:A,clock:ne,state:O}),A!==e.localClientId&&s.add(A);}if(n<=1024&&!t.done)throw new c("Trailing awareness data");return u}function re(r,e=b,t=_){if(!(r instanceof Uint8Array))throw new c("Frame must be a Uint8Array");if(r.byteLength===0)throw new c("Frame is empty");if(r.byteLength>e)throw new c(`Frame exceeds ${e} bytes`);if(!Number.isSafeInteger(t)||t<1)throw new c("Message limit must be a positive integer");let n=new U(r),s=[];for(;!n.done;){if(s.length>=t)throw new c(`Frame exceeds ${t} messages`);let o=n.readVarUint();switch(o){case q:{let a=n.readVarUint(),u=n.readVarUint8Array();if(a===z)s.push({type:"sync-step-1",stateVector:u});else if(a===K)s.push({type:"sync-step-2",update:u});else if(a===J)s.push({type:"update",update:u});else throw new c(`Unknown sync message type ${a}`);break}case j:s.push({type:"awareness",update:n.readVarUint8Array()});break;case ue:{let a=n.readVarUint();if(a!==de)throw new c(`Unknown auth message type ${a}`);s.push({type:"auth",reason:n.readVarString()});break}case H:s.push({type:"query-awareness"});break;default:throw new c(`Unknown top-level message type ${o}`)}}return s}var d=class extends Error{constructor(t,n,s){super(n);b$1(this,"code");b$1(this,"cause");this.name="CollaborationError",this.code=t,this.cause=s;}};var me=16*1024*1024,Ae=80,Ce=2e4,we=45e3,Ee=5e3;function F(r,e,t){if(!Number.isSafeInteger(e)||e<(t?0:1))throw new RangeError(`${r} must be ${t?"a non-negative":"a positive"} integer`);return e}function Se(r){return r instanceof Error&&r.message?r.message:typeof r=="string"&&r?r:"Unknown error"}function l(r,e,t){return t instanceof d?t:new d(r,`${e}: ${Se(t)}`,t)}function M(r,e){if(!(r instanceof Uint8Array))throw new TypeError(`${e} must return a Uint8Array`);return r.slice()}function v(){return globalThis.performance?.now?.()??Date.now()}function k(r){r.unref?.();}function ge(r,e){if(!r)return null;if(!Number.isSafeInteger(e)||e<0)throw new RangeError("clientId must be a non-negative safe integer for awareness");if(typeof r.name!="string"||r.name.trim().length===0)throw new TypeError("user.name must be a non-empty string");return {name:r.name.trim().slice(0,1024),color:S(e,r.color)}}function ve(r){if(r===null)return null;if(typeof r.story!="string"||!r.story||!(r.anchor instanceof Uint8Array)||!(r.head instanceof Uint8Array))throw new TypeError("cursor requires a story and Uint8Array anchor/head");return {story:r.story,anchor:r.anchor.slice(),head:r.head.slice()}}function Te(r){return r.story.length<=1024&&r.anchor.byteLength<=1024&&r.head.byteLength<=1024}function Ue(r){if(typeof r!="object"||r===null)return null;let e=r;return !Number.isSafeInteger(e.clientId)||(e.clientId??-1)<0||typeof e.story!="string"||typeof e.paraId!="string"||!Number.isSafeInteger(e.endOffset)||(e.endOffset??-1)<0?null:{clientId:e.clientId,story:e.story,paraId:e.paraId,endOffset:e.endOffset}}var N=class{constructor(e,t,n={}){b$1(this,"replica");b$1(this,"transport");b$1(this,"maxFrameBytes");b$1(this,"maxMessagesPerFrame");b$1(this,"maxPendingBytes");b$1(this,"localUser");b$1(this,"statusListeners",new Map);b$1(this,"errorListeners",new Map);b$1(this,"peerListeners",new Map);b$1(this,"pendingFrames",[]);b$1(this,"awarenessRecords",new Map);b$1(this,"unsubscribeReplica");b$1(this,"unsubscribeTransport",()=>{});b$1(this,"hasTransportSubscription",false);b$1(this,"connectionStatus","disconnected");b$1(this,"isSynced",false);b$1(this,"wantsConnection",false);b$1(this,"isOpen",false);b$1(this,"isDestroyed",false);b$1(this,"epoch",0);b$1(this,"connectAttempt",0);b$1(this,"nextListenerId",0);b$1(this,"queuedBytes",0);b$1(this,"isFlushing",false);b$1(this,"localClock",0);b$1(this,"reportedClockExhaustion",false);b$1(this,"localCursor",null);b$1(this,"lastAwarenessSentAt",Number.NEGATIVE_INFINITY);b$1(this,"cursorBroadcastTimer",null);b$1(this,"heartbeatTimer",null);b$1(this,"expiryTimer",null);this.replica=e,this.transport=t,this.maxFrameBytes=F("maxFrameBytes",n.maxFrameBytes??b,false),this.maxMessagesPerFrame=F("maxMessagesPerFrame",n.maxMessagesPerFrame??_,false),this.maxPendingBytes=F("maxPendingBytes",n.maxPendingBytes??me,true),this.localUser=ge(n.user,e.clientId);try{this.unsubscribeReplica=e.onUpdate((s,o)=>{o==="local"&&this.forwardLocalUpdate(s);});}catch(s){throw l("replica","Failed to observe replica updates",s)}}get status(){return this.connectionStatus}get synced(){return this.isSynced}get pendingBytes(){return this.queuedBytes}get peers(){return I(this.awarenessRecords)}setCursor(e,t=true){if(this.isDestroyed||!this.localUser)return;let n=ve(e);if(this.localCursor=!n||Te(n)?n:null,n&&!this.localCursor&&this.report(new d("protocol",`Presence cursor exceeds ${1024} story characters or ${1024} position bytes; cursor dropped`)),!t){this.clearCursorBroadcastTimer();return}this.scheduleCursorBroadcast();}onPeers(e){if(this.isDestroyed)return ()=>{};if(typeof e!="function")throw new TypeError("peer listener must be a function");let t=this.nextListenerId++;return this.peerListeners.set(t,e),e(this.peers),()=>this.peerListeners.delete(t)}connect(){if(this.isDestroyed||this.isOpen||this.connectionStatus==="connecting")return;this.wantsConnection=true;let e=this.hasTransportSubscription?this.epoch:++this.epoch,t=++this.connectAttempt;if(this.setStatus("connecting",false),!!this.isCurrent(e)){if(!this.hasTransportSubscription){let n;try{if(n=this.transport.onEvent(s=>this.handleTransportEvent(e,s)),typeof n!="function")throw new TypeError("Transport event subscription must return a function")}catch(s){this.failConnection(e,l("transport","Failed to subscribe to transport events",s));return}if(!this.isCurrent(e)){try{n();}catch(s){this.isDestroyed||this.report(l("transport","Failed to unsubscribe from stale transport events",s));}return}this.unsubscribeTransport=n,this.hasTransportSubscription=true;}try{let n=this.transport.connect();n&&n.catch(s=>{this.isCurrent(e)&&this.connectAttempt===t&&this.failConnection(e,l("transport","Transport connect failed",s));});}catch(n){this.failConnection(e,l("transport","Transport connect failed",n));}}}disconnect(){if(this.isDestroyed||!(this.wantsConnection||this.isOpen||this.hasTransportSubscription||this.connectionStatus!=="disconnected"))return;this.sendLeaveBestEffort(),this.stopPresence(),this.wantsConnection=false,this.isOpen=false,this.epoch+=1,this.connectAttempt+=1;let t=this.takeTransportSubscription();this.clearPending();let n=this.cleanupTransport(t,true);this.setStatus("disconnected",false);for(let s of n)this.report(s);}destroy(){if(this.isDestroyed)return;let e=this.wantsConnection||this.isOpen||this.hasTransportSubscription||this.connectionStatus==="connecting"||this.connectionStatus==="connected";this.sendLeaveBestEffort(),this.stopPresence(),this.isDestroyed=true,this.wantsConnection=false,this.isOpen=false,this.epoch+=1,this.connectAttempt+=1;let t=this.takeTransportSubscription();this.clearPending();let n=this.cleanupTransport(t,e);this.setStatus("destroyed",false);for(let s of n)this.report(s);try{this.unsubscribeReplica();}catch(s){this.report(l("replica","Failed to unsubscribe from replica updates",s));}this.unsubscribeReplica=()=>{},this.statusListeners.clear(),this.errorListeners.clear(),this.peerListeners.clear();}onStatus(e){if(this.isDestroyed)return ()=>{};if(typeof e!="function")throw new TypeError("status listener must be a function");let t=this.nextListenerId++;return this.statusListeners.set(t,e),()=>this.statusListeners.delete(t)}onError(e){if(this.isDestroyed)return ()=>{};if(typeof e!="function")throw new TypeError("error listener must be a function");let t=this.nextListenerId++;return this.errorListeners.set(t,e),()=>this.errorListeners.delete(t)}isCurrent(e){return !this.isDestroyed&&this.wantsConnection&&e===this.epoch}failConnection(e,t){if(!this.isCurrent(e))return;this.stopPresence(),this.wantsConnection=false,this.isOpen=false,this.epoch+=1,this.connectAttempt+=1;let n=this.takeTransportSubscription();this.clearPending();let s=this.cleanupTransport(n,true);this.setStatus("disconnected",false),this.report(t);for(let o of s)this.report(o);}takeTransportSubscription(){let e=this.unsubscribeTransport;return this.unsubscribeTransport=()=>{},this.hasTransportSubscription=false,e}cleanupTransport(e,t){let n=[];try{e();}catch(s){n.push(l("transport","Failed to unsubscribe from transport events",s));}if(!t)return n;try{let s=this.transport.disconnect();s&&s.catch(o=>{this.isDestroyed||this.report(l("transport","Transport disconnect failed",o));});}catch(s){n.push(l("transport","Transport disconnect failed",s));}return n}handleTransportEvent(e,t){if(this.isCurrent(e))switch(t.type){case "open":this.handleOpen(e);break;case "message":this.isOpen&&this.handleMessage(e,t.data);break;case "close":this.isOpen=false,this.connectAttempt+=1,this.stopPresence(),this.clearPending(),this.setStatus("disconnected",false);break;case "error":this.failConnection(e,l("transport","Transport error",t.error));break;case "drain":this.isOpen&&this.flushPending();break;default:this.failConnection(e,new d("transport","Unknown transport event"));}}handleOpen(e){if(this.isOpen||(this.isOpen=true,this.clearPending(),this.setStatus("connected",false),!this.isCurrent(e)||!this.isOpen))return;let t;try{t=M(this.replica.encodeStateVector(),"encodeStateVector");}catch(n){this.failConnection(e,l("replica","Failed to encode replica state vector",n));return}try{this.sendFrame(Q(t,this.maxFrameBytes));}catch(n){this.failConnection(e,l("protocol","Failed to encode collaboration handshake",n));return}if(!(!this.localUser||!this.isCurrent(e)||!this.isOpen)){try{this.sendFrame(L(this.maxFrameBytes));}catch(n){this.report(l("protocol","Failed to encode awareness query",n));}!this.isCurrent(e)||!this.isOpen||(this.broadcastLocalAwareness(),!(!this.isCurrent(e)||!this.isOpen)&&this.startPresence());}}handleMessage(e,t){let n;try{n=re(t.slice(),this.maxFrameBytes,this.maxMessagesPerFrame);}catch(s){this.failConnection(e,l("protocol","Invalid collaboration frame",s));return}for(let s of n){if(!this.isCurrent(e)||!this.isOpen)return;switch(s.type){case "sync-step-1":this.respondToSyncStep1(e,s.stateVector);break;case "sync-step-2":if(this.applyRemoteUpdate(e,s.update,false)&&this.isCurrent(e)&&(this.setStatus("connected",true),this.localUser))try{this.sendFrame(L(this.maxFrameBytes));}catch(o){this.report(l("protocol","Failed to query awareness after sync",o));}break;case "update":this.applyRemoteUpdate(e,s.update,true);break;case "awareness":{let o=[];try{let a=X(this.awarenessRecords,te(s.update,{trackedClientIds:this.awarenessRecords.keys(),localClientId:this.replica.clientId,onDiscard:u=>o.push(u)}),this.replica.clientId,v());this.awarenessRecords=a.records,a.peersChanged&&this.emitPeers();}catch(a){this.report(l("protocol","Failed to apply awareness update",a));}for(let a of o)this.report(l("protocol","Discarded over-limit awareness data",a));break}case "auth":this.failConnection(e,new d("protocol",s.reason?`Authentication denied: ${s.reason}`:"Authentication denied"));return;case "query-awareness":try{this.localUser?this.broadcastLocalAwareness():this.sendFrame(R([],this.maxFrameBytes));}catch(o){this.report(l("protocol","Failed to encode awareness response",o));}break}}}respondToSyncStep1(e,t){let n;try{n=M(this.replica.encodeStateAsUpdate(t.slice()),"encodeStateAsUpdate");}catch(s){this.failConnection(e,l("replica","Failed to encode replica update",s));return}try{this.sendFrame(Z(n,this.maxFrameBytes));}catch(s){this.failConnection(e,l("protocol","Failed to encode SyncStep2",s));}}applyRemoteUpdate(e,t,n){try{let s=this.replica.applyUpdate(t.slice()),o=n?Ue(s):null;if(o){let a=$(this.awarenessRecords,o,this.replica.clientId,v());this.awarenessRecords=a.records,a.peersChanged&&this.emitPeers();}return !0}catch(s){return this.failConnection(e,l("replica","Failed to apply remote update",s)),false}}forwardLocalUpdate(e){if(this.isDestroyed||!this.isOpen||!this.wantsConnection)return;let t=this.epoch,n;try{n=M(e,"Replica update");}catch(s){this.failConnection(t,l("replica","Invalid replica update",s));return}try{this.sendFrame(ee(n,this.maxFrameBytes));}catch(s){this.failConnection(t,l("protocol","Failed to encode update",s));}}nextAwarenessClock(){if(this.localClock>=Number.MAX_SAFE_INTEGER)throw new RangeError("Awareness clock exceeds Number.MAX_SAFE_INTEGER");return this.localClock+=1,this.localClock}encodeLocalAwareness(e,t,n){return R([{clientId:this.replica.clientId,clock:t,state:{user:e,cursor:n}}],this.maxFrameBytes)}broadcastLocalAwareness(){if(!this.localUser||!this.isOpen||this.isDestroyed||!this.wantsConnection)return;if(this.clearCursorBroadcastTimer(),this.localClock>=Number.MAX_SAFE_INTEGER){this.reportedClockExhaustion||(this.reportedClockExhaustion=true,this.report(new d("protocol","Awareness clock exceeds Number.MAX_SAFE_INTEGER")));return}let e=this.localUser,t=this.nextAwarenessClock(),n;try{n=this.encodeLocalAwareness(e,t,this.localCursor);}catch(s){let o=this.localCursor;if(this.localCursor=null,!o){this.report(l("protocol","Failed to encode local awareness",s));return}try{n=this.encodeLocalAwareness(e,t,null);}catch(a){this.report(l("protocol","Failed to encode local awareness",a));return}this.report(l("protocol","Dropped an unencodable presence cursor",s));}this.sendFrame(n),this.lastAwarenessSentAt=v();}scheduleCursorBroadcast(){if(!this.localUser||!this.isOpen||this.isDestroyed||!this.wantsConnection)return;let e=Ae-(v()-this.lastAwarenessSentAt);if(e<=0){this.broadcastLocalAwareness();return}this.cursorBroadcastTimer||(this.cursorBroadcastTimer=setTimeout(()=>{this.cursorBroadcastTimer=null,!(!this.isOpen||this.isDestroyed||!this.wantsConnection)&&this.broadcastLocalAwareness();},e),k(this.cursorBroadcastTimer));}clearCursorBroadcastTimer(){this.cursorBroadcastTimer&&clearTimeout(this.cursorBroadcastTimer),this.cursorBroadcastTimer=null;}startPresence(){!this.localUser||!this.isOpen||this.isDestroyed||!this.wantsConnection||this.heartbeatTimer||this.expiryTimer||(this.heartbeatTimer=setInterval(()=>{this.broadcastLocalAwareness();},Ce),this.expiryTimer=setInterval(()=>{let e=Y(this.awarenessRecords,v(),we);this.awarenessRecords=e.records,e.peersChanged&&this.emitPeers();},Ee),k(this.heartbeatTimer),k(this.expiryTimer));}stopPresence(){this.clearCursorBroadcastTimer(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.expiryTimer&&clearInterval(this.expiryTimer),this.heartbeatTimer=null,this.expiryTimer=null;let e=I(this.awarenessRecords).length>0;this.awarenessRecords=new Map,e&&this.emitPeers();}sendLeaveBestEffort(){if(!(!this.localUser||!this.isOpen||this.isDestroyed||!this.wantsConnection)){this.clearCursorBroadcastTimer();try{let e=R([{clientId:this.replica.clientId,clock:this.nextAwarenessClock(),state:null}],this.maxFrameBytes);this.transport.send(e.slice());}catch(e){this.report(l("transport","Failed to send awareness leave",e));}}}emitPeers(){let e=this.peers;for(let[t,n]of [...this.peerListeners])if(this.peerListeners.get(t)===n)try{n(e);}catch{}}sendFrame(e){if(!this.isOpen||this.isDestroyed||!this.wantsConnection)return;let t=this.epoch;if(this.pendingFrames.length>0){this.queueFrame(t,e);return}let n;try{n=this.transport.send(e.slice());}catch(s){this.failConnection(t,l("transport","Transport send failed",s));return}if(typeof n!="boolean"){this.failConnection(t,new d("transport","Transport send must return a boolean"));return}!n&&this.isCurrent(t)&&this.isOpen&&this.queueFrame(t,e);}queueFrame(e,t){if(t.byteLength>this.maxPendingBytes-this.queuedBytes){this.failConnection(e,new d("backpressure",`Pending collaboration data exceeds ${this.maxPendingBytes} bytes`));return}let n=t.slice();this.pendingFrames.push(n),this.queuedBytes+=n.byteLength;}flushPending(){if(!this.isFlushing){this.isFlushing=true;try{for(;this.isOpen&&!this.isDestroyed&&this.pendingFrames.length>0;){let e=this.epoch,t=this.pendingFrames[0],n;try{n=this.transport.send(t.slice());}catch(s){this.failConnection(e,l("transport","Transport send failed",s));return}if(typeof n!="boolean"){this.failConnection(e,new d("transport","Transport send must return a boolean"));return}if(!n||!this.isOpen||this.pendingFrames[0]!==t)return;this.pendingFrames.shift(),this.queuedBytes-=t.byteLength;}}finally{this.isFlushing=false;}}}clearPending(){this.pendingFrames.length=0,this.queuedBytes=0;}setStatus(e,t){if(this.connectionStatus===e&&this.isSynced===t)return;this.connectionStatus=e,this.isSynced=t;let n={status:e,synced:t};for(let[s,o]of [...this.statusListeners])if(this.statusListeners.get(s)===o)try{o(n);}catch{}}report(e){for(let[t,n]of [...this.errorListeners])if(this.errorListeners.get(t)===n)try{n(e);}catch{}}};function Re(r){return r}function xe(r,e){return {clientId:r.clientId,encodeStateVector:()=>r.encodeStateVector(),encodeStateAsUpdate:t=>r.encodeStateAsUpdate(t?.slice()),applyUpdate:t=>{let n=t.slice();r.applyUpdate(n),e.invalidate(n,r.selection());},onUpdate:t=>r.onUpdate(t)}}export{d as CollaborationError,N as CollaborationProvider,Re as createDirectCollaborationReplica,xe as createWorkerCollaborationReplica,S as resolvePresenceColor};
@@ -1,128 +1,140 @@
1
- import { C as ColorValue, P as ParagraphFormatting, a as TextFormatting, b as TableFormatting, c as TableRowFormatting, d as TableCellFormatting, B as BorderSpec, f as ThemeColorSlot } from './formatting-D1EPSaJP.mjs';
1
+ import { C as ColorValue, y as ThemeColorSlot, a as ParagraphFormatting, b as TextFormatting, c as TableFormatting, d as TableRowFormatting, e as TableCellFormatting, B as BorderSpec, m as ShapeType, k as ShapeFill, l as ShapeOutline, D as ShapeTextBody$1, P as PresetGeometryPathCommand } from './formatting-BEkIBePP.mjs';
2
2
  import { WrapType } from './docx/wrapTypes.mjs';
3
3
 
4
- /**
5
- * DrawingML shape primitives — preset shape types, fill/outline/text-body
6
- * types, and the pure a:-namespace parsers for gradients, line ends,
7
- * transforms (a:xfrm), and preset geometry.
8
- */
9
-
10
- /**
11
- * Shape types
12
- *
13
- * @public
14
- */
15
- type ShapeType = 'rect' | 'roundRect' | 'ellipse' | 'triangle' | 'rtTriangle' | 'parallelogram' | 'trapezoid' | 'pentagon' | 'hexagon' | 'heptagon' | 'octagon' | 'decagon' | 'dodecagon' | 'star4' | 'star5' | 'star6' | 'star7' | 'star8' | 'star10' | 'star12' | 'star16' | 'star24' | 'star32' | 'line' | 'straightConnector1' | 'bentConnector2' | 'bentConnector3' | 'bentConnector4' | 'bentConnector5' | 'curvedConnector2' | 'curvedConnector3' | 'curvedConnector4' | 'curvedConnector5' | 'rightArrow' | 'leftArrow' | 'upArrow' | 'downArrow' | 'leftRightArrow' | 'upDownArrow' | 'quadArrow' | 'leftRightUpArrow' | 'bentArrow' | 'uturnArrow' | 'leftUpArrow' | 'bentUpArrow' | 'curvedRightArrow' | 'curvedLeftArrow' | 'curvedUpArrow' | 'curvedDownArrow' | 'stripedRightArrow' | 'notchedRightArrow' | 'homePlate' | 'chevron' | 'rightArrowCallout' | 'downArrowCallout' | 'leftArrowCallout' | 'upArrowCallout' | 'leftRightArrowCallout' | 'quadArrowCallout' | 'circularArrow' | 'flowChartProcess' | 'flowChartAlternateProcess' | 'flowChartDecision' | 'flowChartInputOutput' | 'flowChartPredefinedProcess' | 'flowChartInternalStorage' | 'flowChartDocument' | 'flowChartMultidocument' | 'flowChartTerminator' | 'flowChartPreparation' | 'flowChartManualInput' | 'flowChartManualOperation' | 'flowChartConnector' | 'flowChartOffpageConnector' | 'flowChartPunchedCard' | 'flowChartPunchedTape' | 'flowChartSummingJunction' | 'flowChartOr' | 'flowChartCollate' | 'flowChartSort' | 'flowChartExtract' | 'flowChartMerge' | 'flowChartOnlineStorage' | 'flowChartDelay' | 'flowChartMagneticTape' | 'flowChartMagneticDisk' | 'flowChartMagneticDrum' | 'flowChartDisplay' | 'wedgeRectCallout' | 'wedgeRoundRectCallout' | 'wedgeEllipseCallout' | 'cloudCallout' | 'borderCallout1' | 'borderCallout2' | 'borderCallout3' | 'accentCallout1' | 'accentCallout2' | 'accentCallout3' | 'callout1' | 'callout2' | 'callout3' | 'accentBorderCallout1' | 'accentBorderCallout2' | 'accentBorderCallout3' | 'actionButtonBlank' | 'actionButtonHome' | 'actionButtonHelp' | 'actionButtonInformation' | 'actionButtonBackPrevious' | 'actionButtonForwardNext' | 'actionButtonBeginning' | 'actionButtonEnd' | 'actionButtonReturn' | 'actionButtonDocument' | 'actionButtonSound' | 'actionButtonMovie' | 'irregularSeal1' | 'irregularSeal2' | 'frame' | 'halfFrame' | 'corner' | 'diagStripe' | 'chord' | 'arc' | 'bracketPair' | 'bracePair' | 'leftBracket' | 'rightBracket' | 'leftBrace' | 'rightBrace' | 'can' | 'cube' | 'bevel' | 'donut' | 'noSmoking' | 'blockArc' | 'foldedCorner' | 'smileyFace' | 'heart' | 'lightningBolt' | 'sun' | 'moon' | 'cloud' | 'snip1Rect' | 'snip2SameRect' | 'snip2DiagRect' | 'snipRoundRect' | 'round1Rect' | 'round2SameRect' | 'round2DiagRect' | 'plaque' | 'teardrop' | 'mathPlus' | 'mathMinus' | 'mathMultiply' | 'mathDivide' | 'mathEqual' | 'mathNotEqual' | 'gear6' | 'gear9' | 'funnel' | 'pieWedge' | 'pie' | 'leftCircularArrow' | 'leftRightCircularArrow' | 'swooshArrow' | 'textBox';
16
- /**
17
- * Shape fill type
18
- *
19
- * @public
20
- */
21
- interface ShapeFill {
22
- type: 'none' | 'solid' | 'gradient' | 'pattern' | 'picture';
23
- /** Solid fill color */
4
+ interface ShapeFillPaint {
5
+ kind?: 'none' | 'solid' | 'gradient' | 'pattern' | 'picture' | 'theme';
24
6
  color?: ColorValue;
25
- /** Gradient stops for gradient fill */
26
- gradient?: {
27
- type: 'linear' | 'radial' | 'rectangular' | 'path';
28
- angle?: number;
29
- stops: Array<{
30
- position: number;
31
- color: ColorValue;
32
- }>;
7
+ themeColor?: ThemeColorSlot;
8
+ gradientType?: 'linear' | 'path' | 'radial' | 'rectangular';
9
+ angle?: number;
10
+ stops?: Array<{
11
+ position?: number;
12
+ color?: ColorValue;
13
+ }>;
14
+ pathShape?: 'circle' | 'rect' | 'shape';
15
+ focusRect?: {
16
+ left?: number;
17
+ top?: number;
18
+ right?: number;
19
+ bottom?: number;
33
20
  };
21
+ rotateWithShape?: boolean;
22
+ patternPreset?: string;
23
+ foregroundColor?: ColorValue;
24
+ backgroundColor?: ColorValue;
25
+ picture?: Image;
26
+ themeRefIndex?: number;
27
+ srcRect?: {
28
+ left?: number;
29
+ top?: number;
30
+ right?: number;
31
+ bottom?: number;
32
+ };
33
+ fillMode?: 'stretch' | 'tile';
34
+ tile?: {
35
+ offsetX?: number;
36
+ offsetY?: number;
37
+ scaleX?: number;
38
+ scaleY?: number;
39
+ alignment?: string;
40
+ flip?: 'none' | 'x' | 'y' | 'xy';
41
+ };
42
+ stretchRect?: {
43
+ left?: number;
44
+ top?: number;
45
+ right?: number;
46
+ bottom?: number;
47
+ };
48
+ pictureOpacity?: number;
34
49
  }
35
- /**
36
- * Shape outline/stroke
37
- *
38
- * @public
39
- */
40
- interface ShapeOutline {
41
- /** Line width in EMUs */
50
+ interface ShapeStrokePaint {
51
+ fill?: ShapeFillPaint;
42
52
  width?: number;
43
- /** Line color */
44
- color?: ColorValue;
45
- /** Line style */
46
- style?: 'solid' | 'dot' | 'dash' | 'lgDash' | 'dashDot' | 'lgDashDot' | 'lgDashDotDot' | 'sysDot' | 'sysDash' | 'sysDashDot' | 'sysDashDotDot';
47
- /** Line cap */
53
+ dash?: string;
54
+ customDash?: number[];
55
+ compound?: 'single' | 'double' | 'thickThin' | 'thinThick' | 'triple';
56
+ alignment?: 'center' | 'inset';
48
57
  cap?: 'flat' | 'round' | 'square';
49
- /** Line join */
50
58
  join?: 'bevel' | 'miter' | 'round';
51
- /** Head arrow */
59
+ miterLimit?: number;
52
60
  headEnd?: {
53
- type: 'none' | 'triangle' | 'stealth' | 'diamond' | 'oval' | 'arrow';
54
- width?: 'sm' | 'med' | 'lg';
55
- length?: 'sm' | 'med' | 'lg';
61
+ type?: string;
62
+ width?: string;
63
+ length?: string;
56
64
  };
57
- /** Tail arrow */
58
65
  tailEnd?: {
59
- type: 'none' | 'triangle' | 'stealth' | 'diamond' | 'oval' | 'arrow';
60
- width?: 'sm' | 'med' | 'lg';
61
- length?: 'sm' | 'med' | 'lg';
66
+ type?: string;
67
+ width?: string;
68
+ length?: string;
62
69
  };
70
+ themeRefIndex?: number;
63
71
  }
64
- /**
65
- * Text body inside a shape.
66
- *
67
- * `TContent` is the host's paragraph/content type — DrawingML itself does
68
- * not prescribe what a paragraph looks like (docx uses `w:p`, pptx `a:p`).
69
- *
70
- * @public
71
- */
72
- interface ShapeTextBody$1<TContent = unknown> {
73
- /** Text direction */
74
- vertical?: boolean;
75
- /** Rotation */
72
+ interface ShapeEffect {
73
+ kind?: 'shadow' | 'glow' | 'reflection' | 'softEdge' | 'blur' | 'unknown';
74
+ color?: ColorValue;
75
+ opacity?: number;
76
+ blurRadius?: number;
77
+ distance?: number;
78
+ direction?: number;
79
+ size?: number;
80
+ rawName?: string;
81
+ }
82
+ interface ShapeTextBodyProperties {
83
+ vertical?: 'horizontal' | 'vertical' | 'vertical270' | 'wordArtVertical' | 'eastAsianVertical' | 'mongolianVertical';
76
84
  rotation?: number;
77
- /** Anchor/vertical alignment */
85
+ upright?: boolean;
78
86
  anchor?: 'top' | 'middle' | 'bottom' | 'distributed' | 'justified';
79
- /** Anchor center */
80
87
  anchorCenter?: boolean;
81
- /** Auto fit */
82
- autoFit?: 'none' | 'normal' | 'shape';
83
- /** Text margins */
88
+ columns?: number;
89
+ columnSpacing?: number;
90
+ wrap?: 'square' | 'none';
91
+ horizontalOverflow?: 'clip' | 'overflow';
92
+ verticalOverflow?: 'clip' | 'ellipsis' | 'overflow';
84
93
  margins?: {
85
94
  top?: number;
86
95
  bottom?: number;
87
96
  left?: number;
88
97
  right?: number;
89
98
  };
90
- /** Paragraphs inside the shape */
91
- content: TContent[];
99
+ autoFit?: 'none' | 'normal' | 'shape';
100
+ fontScale?: number;
101
+ lineSpacingReduction?: number;
102
+ fromWordArt?: boolean;
103
+ presetTextWarp?: string;
104
+ }
105
+ interface DrawingSceneNode {
106
+ kind?: 'shape' | 'group' | 'canvas' | 'picture' | 'chart' | 'graphicFrame' | 'contentPart';
107
+ id?: string;
108
+ name?: string;
109
+ shape?: Shape;
110
+ image?: Image;
111
+ chart?: Chart;
112
+ children?: DrawingSceneNode[];
113
+ transform?: {
114
+ offsetX?: number;
115
+ offsetY?: number;
116
+ width?: number;
117
+ height?: number;
118
+ childOffsetX?: number;
119
+ childOffsetY?: number;
120
+ childWidth?: number;
121
+ childHeight?: number;
122
+ rotation?: number;
123
+ flipH?: boolean;
124
+ flipV?: boolean;
125
+ };
126
+ fill?: ShapeFillPaint;
127
+ effects?: ShapeEffect[];
128
+ relationshipId?: string;
129
+ }
130
+ interface DrawingScene {
131
+ version?: number;
132
+ root?: DrawingSceneNode;
133
+ title?: string;
134
+ description?: string;
135
+ decorative?: boolean;
136
+ hidden?: boolean;
92
137
  }
93
- /**
94
- * Normalized DrawingML preset-geometry path command.
95
- *
96
- * Coordinates are shape-local fractions in the `[0, 1]` box. Consumers scale
97
- * `x/y` and control points by the shape's resolved width/height.
98
- *
99
- * @public
100
- */
101
- type PresetGeometryPathCommand = {
102
- type: 'move';
103
- x: number;
104
- y: number;
105
- } | {
106
- type: 'line';
107
- x: number;
108
- y: number;
109
- } | {
110
- type: 'quad';
111
- cpx: number;
112
- cpy: number;
113
- x: number;
114
- y: number;
115
- } | {
116
- type: 'cubic';
117
- cp1x: number;
118
- cp1y: number;
119
- cp2x: number;
120
- cp2y: number;
121
- x: number;
122
- y: number;
123
- } | {
124
- type: 'close';
125
- };
126
138
 
127
139
  /**
128
140
  * Lists & Numbering Types
@@ -1649,151 +1661,6 @@ interface Paragraph {
1649
1661
  * Text body inside a shape (content typed as docx paragraphs)
1650
1662
  */
1651
1663
  type ShapeTextBody = ShapeTextBody$1<Paragraph>;
1652
- /** Detailed DrawingML paint server retained alongside the legacy shared fill. */
1653
- interface ShapeFillPaint {
1654
- kind?: 'none' | 'solid' | 'gradient' | 'pattern' | 'picture' | 'theme';
1655
- color?: ColorValue;
1656
- themeColor?: ThemeColorSlot;
1657
- gradientType?: 'linear' | 'path' | 'radial' | 'rectangular';
1658
- angle?: number;
1659
- stops?: Array<{
1660
- position?: number;
1661
- color?: ColorValue;
1662
- }>;
1663
- pathShape?: 'circle' | 'rect' | 'shape';
1664
- focusRect?: {
1665
- left?: number;
1666
- top?: number;
1667
- right?: number;
1668
- bottom?: number;
1669
- };
1670
- rotateWithShape?: boolean;
1671
- patternPreset?: string;
1672
- foregroundColor?: ColorValue;
1673
- backgroundColor?: ColorValue;
1674
- picture?: Image;
1675
- themeRefIndex?: number;
1676
- /** Picture-fill source crop fractions (`a:srcRect`, 0..1; negative = outset). */
1677
- srcRect?: {
1678
- left?: number;
1679
- top?: number;
1680
- right?: number;
1681
- bottom?: number;
1682
- };
1683
- /** Picture-fill mode: `a:stretch` (default) or `a:tile`. */
1684
- fillMode?: 'stretch' | 'tile';
1685
- /** Picture-fill tile parameters (`a:tile`). Offsets px, scales fractions. */
1686
- tile?: {
1687
- offsetX?: number;
1688
- offsetY?: number;
1689
- scaleX?: number;
1690
- scaleY?: number;
1691
- alignment?: string;
1692
- flip?: 'none' | 'x' | 'y' | 'xy';
1693
- };
1694
- /** Picture-fill stretch target rect fractions (`a:stretch/a:fillRect`, 0..1). */
1695
- stretchRect?: {
1696
- left?: number;
1697
- top?: number;
1698
- right?: number;
1699
- bottom?: number;
1700
- };
1701
- /** Picture-fill alpha 0..1 (`a:alphaModFix` on the blip). */
1702
- pictureOpacity?: number;
1703
- }
1704
- /** Detailed DrawingML line contract, including arrows and compound/custom dash. */
1705
- interface ShapeStrokePaint {
1706
- fill?: ShapeFillPaint;
1707
- width?: number;
1708
- dash?: string;
1709
- customDash?: number[];
1710
- compound?: 'single' | 'double' | 'thickThin' | 'thinThick' | 'triple';
1711
- alignment?: 'center' | 'inset';
1712
- cap?: 'flat' | 'round' | 'square';
1713
- join?: 'bevel' | 'miter' | 'round';
1714
- miterLimit?: number;
1715
- headEnd?: {
1716
- type?: string;
1717
- width?: string;
1718
- length?: string;
1719
- };
1720
- tailEnd?: {
1721
- type?: string;
1722
- width?: string;
1723
- length?: string;
1724
- };
1725
- themeRefIndex?: number;
1726
- }
1727
- /** Common 2-D shape effect. Missing parameters mean the OOXML default. */
1728
- interface ShapeEffect {
1729
- kind?: 'shadow' | 'glow' | 'reflection' | 'softEdge' | 'blur' | 'unknown';
1730
- color?: ColorValue;
1731
- opacity?: number;
1732
- blurRadius?: number;
1733
- distance?: number;
1734
- direction?: number;
1735
- size?: number;
1736
- rawName?: string;
1737
- }
1738
- /** Full `a:bodyPr` projection used by text-body/autofit layout. */
1739
- interface ShapeTextBodyProperties {
1740
- vertical?: 'horizontal' | 'vertical' | 'vertical270' | 'wordArtVertical' | 'eastAsianVertical' | 'mongolianVertical';
1741
- rotation?: number;
1742
- upright?: boolean;
1743
- anchor?: 'top' | 'middle' | 'bottom' | 'distributed' | 'justified';
1744
- anchorCenter?: boolean;
1745
- columns?: number;
1746
- columnSpacing?: number;
1747
- wrap?: 'square' | 'none';
1748
- horizontalOverflow?: 'clip' | 'overflow';
1749
- verticalOverflow?: 'clip' | 'ellipsis' | 'overflow';
1750
- margins?: {
1751
- top?: number;
1752
- bottom?: number;
1753
- left?: number;
1754
- right?: number;
1755
- };
1756
- autoFit?: 'none' | 'normal' | 'shape';
1757
- fontScale?: number;
1758
- lineSpacingReduction?: number;
1759
- fromWordArt?: boolean;
1760
- presetTextWarp?: string;
1761
- }
1762
- /** Heterogeneous DrawingML group/canvas scene node. */
1763
- interface DrawingSceneNode {
1764
- kind?: 'shape' | 'group' | 'canvas' | 'picture' | 'chart' | 'graphicFrame' | 'contentPart';
1765
- id?: string;
1766
- name?: string;
1767
- shape?: Shape;
1768
- image?: Image;
1769
- chart?: Chart;
1770
- children?: DrawingSceneNode[];
1771
- transform?: {
1772
- offsetX?: number;
1773
- offsetY?: number;
1774
- width?: number;
1775
- height?: number;
1776
- childOffsetX?: number;
1777
- childOffsetY?: number;
1778
- childWidth?: number;
1779
- childHeight?: number;
1780
- rotation?: number;
1781
- flipH?: boolean;
1782
- flipV?: boolean;
1783
- };
1784
- fill?: ShapeFillPaint;
1785
- effects?: ShapeEffect[];
1786
- relationshipId?: string;
1787
- }
1788
- /** Versioned general DrawingML scene. Undefined version reads as legacy v0. */
1789
- interface DrawingScene {
1790
- version?: number;
1791
- root?: DrawingSceneNode;
1792
- title?: string;
1793
- description?: string;
1794
- decorative?: boolean;
1795
- hidden?: boolean;
1796
- }
1797
1664
  /**
1798
1665
  * Shape/drawing object (wps:wsp)
1799
1666
  */
@@ -2199,4 +2066,4 @@ interface Chart {
2199
2066
  relativeHeight?: number;
2200
2067
  }
2201
2068
 
2202
- export { type FieldType as $, type AbstractNumbering as A, type BlockContent as B, type CellMarker as C, type DrawingScene as D, type EndnoteProperties as E, type FootnoteProperties as F, type CommentAuthor as G, type HeaderFooter as H, type CommentRangeEnd as I, type CommentRangeStart as J, type CommentReferenceContent as K, type ComplexField as L, type ContentPosition as M, type NoteKind as N, DEFAULT_WATERMARK_PRESETS as O, type PresetGeometryPathCommand as P, type Deletion as Q, type RevisionInfo as R, type SectionProperties as S, type DrawingContent as T, type DrawingSceneNode as U, type EndnotePosition as V, type Watermark as W, type Field as X, type FieldCharContent as Y, type FieldFormData as Z, type FieldInlineContent as _, type SdtControlState as a, type SimpleField as a$, type FooterReference as a0, type FootnotePosition as a1, type HeaderFooterType as a2, type HeaderReference as a3, type Hyperlink as a4, type HyperlinkContent as a5, type Image as a6, type ImageCrop as a7, type ImageEffect as a8, type ImageHyperlink as a9, type NumberFormat as aA, type NumberingInstance as aB, type PageNumberingProperties as aC, type PageOrientation as aD, type ParagraphContent as aE, type ParagraphPropertyChange as aF, type PictureWatermark as aG, type PropertyChangeInfo as aH, type Run as aI, type RunContent as aJ, type RunPropertyChange as aK, type SdtCheckboxGlyph as aL, type SdtDataBinding as aM, type SdtDateState as aN, type SdtGalleryState as aO, type SdtType as aP, type Section as aQ, type SectionStart as aR, type SeparatorContent as aS, type Shape as aT, type ShapeContent as aU, type ShapeFill as aV, type ShapeFillPaint as aW, type ShapeOutline as aX, type ShapeStrokePaint as aY, type ShapeTextBody as aZ, type ShapeType as a_, type ImagePadding as aa, type ImagePosition as ab, type ImageRotationBounds as ac, type ImageSize as ad, type ImageTransform as ae, type ImageWrap as af, type ImageWrapPoint as ag, type InlineSdt as ah, type Insertion as ai, type InstrTextContent as aj, type LevelSuffix as ak, type LineNumberRestart as al, type ListLevel as am, type ListRendering as an, type MathEquation as ao, type MoveFrom as ap, type MoveFromRangeEnd as aq, type MoveFromRangeStart as ar, type MoveTo as as, type MoveToRangeEnd as at, type MoveToRangeStart as au, type NoBreakHyphenContent as av, type NoteNumberRestart as aw, type NoteRefMarkContent as ax, type NoteReferenceContent as ay, type NoteSeparatorReference as az, type SdtProperties as b, type SoftHyphenContent as b0, type StructuredFieldContent as b1, type StructuredFieldTree as b2, type SymbolContent as b3, type TabContent as b4, type Table as b5, type TableCell as b6, type TableCellPropertyChange as b7, type TablePropertyChange as b8, type TableRow as b9, type TableRowPropertyChange as ba, type TableStructuralChangeInfo as bb, type TextBox as bc, type TextContent as bd, type TextWatermark as be, type TrackedChangeInfo as bf, type TrackedRunChange as bg, type VerticalAlign as bh, pictureWatermarkDisplayEmu as bi, type ShapeEffect as c, type ShapeTextBodyProperties as d, type Chart as e, type Paragraph as f, type Comment as g, type DocumentBody as h, type NumberingDefinitions as i, type Footnote as j, type Endnote as k, type BookmarkRange as l, type BlockSdt as m, type BookmarkEnd as n, type BookmarkStart as o, type BreakContent as p, type ChartAxis as q, type ChartContent as r, type ChartGrouping as s, type ChartLegend as t, type ChartPlotGroup as u, type ChartPoint as v, type ChartSeries as w, type ChartType as x, type Column as y, type CommentAnchorRange as z };
2069
+ export { type FooterReference as $, type AbstractNumbering as A, type BlockContent as B, type CellMarker as C, type DrawingScene as D, type EndnoteProperties as E, type FootnoteProperties as F, type CommentRangeEnd as G, type HeaderFooter as H, type CommentRangeStart as I, type CommentReferenceContent as J, type ComplexField as K, type ContentPosition as L, DEFAULT_WATERMARK_PRESETS as M, type NoteKind as N, type Deletion as O, type Paragraph as P, type DrawingContent as Q, type RevisionInfo as R, type SectionProperties as S, type DrawingSceneNode as T, type EndnotePosition as U, type Field as V, type Watermark as W, type FieldCharContent as X, type FieldFormData as Y, type FieldInlineContent as Z, type FieldType as _, type SdtControlState as a, type SymbolContent as a$, type FootnotePosition as a0, type HeaderFooterType as a1, type HeaderReference as a2, type Hyperlink as a3, type HyperlinkContent as a4, type Image as a5, type ImageCrop as a6, type ImageEffect as a7, type ImageHyperlink as a8, type ImagePadding as a9, type NumberingInstance as aA, type PageNumberingProperties as aB, type PageOrientation as aC, type ParagraphContent as aD, type ParagraphPropertyChange as aE, type PictureWatermark as aF, type PropertyChangeInfo as aG, type Run as aH, type RunContent as aI, type RunPropertyChange as aJ, type SdtCheckboxGlyph as aK, type SdtDataBinding as aL, type SdtDateState as aM, type SdtGalleryState as aN, type SdtType as aO, type Section as aP, type SectionStart as aQ, type SeparatorContent as aR, type Shape as aS, type ShapeContent as aT, type ShapeFillPaint as aU, type ShapeStrokePaint as aV, type ShapeTextBody as aW, type SimpleField as aX, type SoftHyphenContent as aY, type StructuredFieldContent as aZ, type StructuredFieldTree as a_, type ImagePosition as aa, type ImageRotationBounds as ab, type ImageSize as ac, type ImageTransform as ad, type ImageWrap as ae, type ImageWrapPoint as af, type InlineSdt as ag, type Insertion as ah, type InstrTextContent as ai, type LevelSuffix as aj, type LineNumberRestart as ak, type ListLevel as al, type ListRendering as am, type MathEquation as an, type MoveFrom as ao, type MoveFromRangeEnd as ap, type MoveFromRangeStart as aq, type MoveTo as ar, type MoveToRangeEnd as as, type MoveToRangeStart as at, type NoBreakHyphenContent as au, type NoteNumberRestart as av, type NoteRefMarkContent as aw, type NoteReferenceContent as ax, type NoteSeparatorReference as ay, type NumberFormat as az, type SdtProperties as b, type TabContent as b0, type Table as b1, type TableCell as b2, type TableCellPropertyChange as b3, type TablePropertyChange as b4, type TableRow as b5, type TableRowPropertyChange as b6, type TableStructuralChangeInfo as b7, type TextBox as b8, type TextContent as b9, type TextWatermark as ba, type TrackedChangeInfo as bb, type TrackedRunChange as bc, type VerticalAlign as bd, pictureWatermarkDisplayEmu as be, type ShapeEffect as c, type ShapeTextBodyProperties as d, type Chart as e, type Comment as f, type DocumentBody as g, type NumberingDefinitions as h, type Footnote as i, type Endnote as j, type BookmarkRange as k, type BlockSdt as l, type BookmarkEnd as m, type BookmarkStart as n, type BreakContent as o, type ChartAxis as p, type ChartContent as q, type ChartGrouping as r, type ChartLegend as s, type ChartPlotGroup as t, type ChartPoint as u, type ChartSeries as v, type ChartType as w, type Column as x, type CommentAnchorRange as y, type CommentAuthor as z };
package/dist/core.d.mts CHANGED
@@ -1,15 +1,15 @@
1
1
  export { a as attemptSelectiveSave, c as createDocx, p as parseDocx, r as repackDocx, u as updateMultipleFiles } from './selectiveSave-CVoajSKE.mjs';
2
2
  import { Document } from './types/document.mjs';
3
3
  export { DocxPackage } from './types/document.mjs';
4
- import { h as DocumentBody, S as SectionProperties, b5 as Table } from './content-DLFHRQav.mjs';
5
- export { B as BlockContent, n as BookmarkEnd, o as BookmarkStart, g as Comment, I as CommentRangeEnd, J as CommentRangeStart, Q as Deletion, k as Endnote, X as Field, a0 as FooterReference, j as Footnote, H as HeaderFooter, a3 as HeaderReference, a4 as Hyperlink, a6 as Image, ai as Insertion, am as ListLevel, ap as MoveFrom, as as MoveTo, i as NumberingDefinitions, f as Paragraph, aE as ParagraphContent, aI as Run, aJ as RunContent, aT as Shape, b6 as TableCell, b9 as TableRow, bc as TextBox, bd as TextContent, bf as TrackedChangeInfo, bg as TrackedRunChange } from './content-DLFHRQav.mjs';
4
+ import { g as DocumentBody, S as SectionProperties, b1 as Table } from './content-C3sTRz-u.mjs';
5
+ export { B as BlockContent, m as BookmarkEnd, n as BookmarkStart, f as Comment, G as CommentRangeEnd, I as CommentRangeStart, O as Deletion, j as Endnote, V as Field, $ as FooterReference, i as Footnote, H as HeaderFooter, a2 as HeaderReference, a3 as Hyperlink, a5 as Image, ah as Insertion, al as ListLevel, ao as MoveFrom, ar as MoveTo, h as NumberingDefinitions, P as Paragraph, aD as ParagraphContent, aH as Run, aI as RunContent, aS as Shape, b2 as TableCell, b5 as TableRow, b8 as TextBox, b9 as TextContent, bb as TrackedChangeInfo, bc as TrackedRunChange } from './content-C3sTRz-u.mjs';
6
6
  export { emuToPixels, emuToTwips, formatPx, halfPointsToPixels, pixelsToEmu, pixelsToTwips, pointsToPixels, twipsToEmu, twipsToPixels } from './utils/units.mjs';
7
- export { c as canRenderFont, a as colorsEqual, b as createRgbColor, d as createThemeColor, e as ensureHexPrefix, g as getLoadedFonts, i as isBlack, f as isFontLoaded, h as isFontsLoading, j as isGoogleFontsEnabled, k as isWhite, l as loadFont, m as loadFontFromBuffer, n as loadFonts, o as onFontsLoaded, p as parseColorString, q as preloadCommonFonts, r as resolveHighlightColor, s as resolveHighlightToCss, t as resolveShadingColor, u as setGoogleFontsEnabled } from './fontLoader-aSewHMKF.mjs';
7
+ export { T as ThemeMatrixCell, b as blendColors, c as canRenderFont, a as colorsEqual, d as createRgbColor, e as createThemeColor, f as darkenColor, g as ensureHexPrefix, h as generateThemeTintShadeMatrix, i as getContrastingColor, j as getLoadedFonts, k as getThemeTintShadeHex, l as isBlack, m as isFontLoaded, n as isFontsLoading, o as isGoogleFontsEnabled, p as isWhite, q as lightenColor, r as loadFont, s as loadFontFromBuffer, t as loadFonts, u as onFontsLoaded, v as parseColorString, w as preloadCommonFonts, x as resolveColor, y as resolveHighlightColor, z as resolveHighlightToCss, A as resolveShadingColor, B as setGoogleFontsEnabled } from './fontLoader-CMH3bZ2Z.mjs';
8
8
  export { D as DocxInput, t as toArrayBuffer } from './docxInput-DTbCa48g.mjs';
9
9
  export { EditorPluginCore, PanelConfig, PluginPanelProps, PositionCoordinates, RenderedDomContext } from './plugin-api/index.mjs';
10
- export { B as BlockExtent, F as FootnoteContent, a as Layout, L as LayoutBlock, P as Page, R as ResolvedLine, c as ResolvedSegment } from './types-DMkDbvEu.mjs';
11
- export { P as ParagraphFormatting, a as TextFormatting, e as Theme, u as ThemeColorScheme, v as ThemeFont, w as ThemeFontScheme, x as ThemeMatrixCell, y as blendColors, z as darkenColor, A as generateThemeTintShadeMatrix, D as getContrastingColor, G as getThemeTintShadeHex, H as lightenColor, I as resolveColor } from './formatting-D1EPSaJP.mjs';
12
- export { d as Relationship, a as Style, S as StyleDefinitions } from './styles-Dn_o3Vo5.mjs';
10
+ export { B as BlockExtent, F as FootnoteContent, a as Layout, L as LayoutBlock, P as Page, R as ResolvedLine, c as ResolvedSegment } from './types-C1rv3KM-.mjs';
11
+ export { a as ParagraphFormatting, b as TextFormatting, f as Theme, x as ThemeColorScheme, z as ThemeFont, A as ThemeFontScheme } from './formatting-BEkIBePP.mjs';
12
+ export { d as Relationship, a as Style, S as StyleDefinitions } from './styles-BK3Jecxs.mjs';
13
13
  import './docx/wrapTypes.mjs';
14
14
 
15
15
  /**
package/dist/core.mjs CHANGED
@@ -1 +1 @@
1
- export{i as attemptSelectiveSave,h as createDocx,a as parseDocx,f as repackDocx,c as serializeDocumentBody,b as serializeDocx,d as serializeSectionProperties,g as updateMultipleFiles}from'./chunk-AEQOEQJ7.mjs';export{f as blendColors,r as colorsEqual,o as createRgbColor,n as createThemeColor,d as darkenColor,p as ensureHexPrefix,h as generateThemeTintShadeMatrix,c as getContrastingColor,g as getThemeTintShadeHex,k as isBlack,l as isWhite,e as lightenColor,m as parseColorString,a as resolveColor,i as resolveHighlightColor,q as resolveHighlightToCss,j as resolveShadingColor}from'./chunk-IFT6DUJX.mjs';export{b as emuToPixels,i as emuToTwips,q as formatPx,k as halfPointsToPixels,c as pixelsToEmu,h as pixelsToTwips,d as pointsToPixels,j as twipsToEmu,g as twipsToPixels}from'./chunk-3UBMCDME.mjs';export{o as canRenderFont,l as getLoadedFonts,h as isFontLoaded,k as isFontsLoading,j as isGoogleFontsEnabled,f as loadFont,p as loadFontFromBuffer,g as loadFonts,m as onFontsLoaded,w as preloadCommonFonts,i as setGoogleFontsEnabled,a as toArrayBuffer}from'./chunk-AZ52IWB6.mjs';import'./chunk-NJHOPXZW.mjs';import'./chunk-B4IR6YP4.mjs';import'./chunk-T4EZMUXM.mjs';import {b as b$1}from'./chunk-TTRUPDAB.mjs';var ce={includeHeaders:true,includeFooters:true,includePageNumbers:true,pageRange:null,scale:1,printBackground:true,margins:"default"};function me(){return {...ce}}function de(){typeof window<"u"&&window.print();}var fe="@media print { body { margin: 0; padding: 0; } @page { margin: 0; } }";function ge(t="Document",r){if(typeof window>"u")return null;let e=window.open("","_blank");if(!e)return null;e.opener=null;let n=e.document;n.title=t;let o=n.createElement("style");o.textContent=fe,n.head.appendChild(o);let i=new DOMParser().parseFromString(r,"text/html");for(let l of Array.from(i.body.childNodes))n.body.appendChild(n.importNode(l,true));return e}function he(t,r){if(!t||!t.trim())return null;let e=t.trim();if(/^\d+$/.test(e)){let o=parseInt(e,10);return o>=1&&o<=r?{start:o,end:o}:null}let n=e.match(/^(\d+)-(\d+)$/);if(n){let o=parseInt(n[1],10),i=parseInt(n[2],10);if(o>=1&&i<=r&&o<=i)return {start:o,end:i}}return null}function Te(t,r){return t?t.start===t.end?`Page ${t.start}`:`Pages ${t.start}-${t.end}`:`All (${r} pages)`}function be(){return typeof window<"u"&&typeof window.print=="function"}var s=class{constructor(r){b$1(this,"listeners",new Set);b$1(this,"snapshot");b$1(this,"subscribe",r=>(this.listeners.add(r),()=>{this.listeners.delete(r);}));b$1(this,"getSnapshot",()=>this.snapshot);this.snapshot=r;}setSnapshot(r){this.snapshot=r,this.notify();}notify(){for(let r of this.listeners)r();}};var c={TABLE_INDEX:"data-table-index",ROW_INDEX:"data-row",COLUMN_INDEX:"data-col",TABLE_CELL:"data-table-cell"};function g(t,r){if(!(t instanceof Element))return null;let e=t;for(;e&&e!==r;){if(e.tagName==="TD"||e.tagName==="TH"){let n=e.getAttribute(c.ROW_INDEX),o=e.getAttribute(c.COLUMN_INDEX);if(n!==null&&o!==null){let i=e;for(;i&&i!==r;){if(i.tagName==="TABLE"){let l=i.getAttribute(c.TABLE_INDEX);if(l!==null)return {tableIndex:parseInt(l,10),rowIndex:parseInt(n,10),columnIndex:parseInt(o,10)};break}i=i.parentElement;}}break}e=e.parentElement;}return null}function h(t,r){if(!t.package?.document?.content)return null;let e=0;for(let n of t.package.document.content)if(n.type==="table"){if(e===r)return n;e++;}return null}function T(t,r,e){if(!t.package?.document?.content)return t;let n=0,o=t.package.document.content.map(i=>{if(i.type==="table"){if(n===r)return n++,e;n++;}return i});return {...t,package:{...t.package,document:{...t.package.document,content:o}}}}function b(t,r){if(!t.package?.document?.content)return t;let e=0,n=t.package.document.content.filter(o=>{if(o.type==="table"){let i=e===r;return e++,!i}return true});return {...t,package:{...t.package,document:{...t.package.document,content:n}}}}var m=class extends s{constructor(){super({selectedCell:null});}selectCell(r){this.setSnapshot({selectedCell:r});}clearSelection(){this.setSnapshot({selectedCell:null});}isCellSelected(r,e,n){let{selectedCell:o}=this.getSnapshot();return o?o.tableIndex===r&&o.rowIndex===e&&o.columnIndex===n:false}getSelectedCell(){return this.getSnapshot().selectedCell}};var d=class extends s{constructor(){super({notifications:[]});b$1(this,"notifications",[]);b$1(this,"idCounter",0);b$1(this,"timers",new Set);}showError(e,n){return this.addNotification(e,"error",n)}showWarning(e,n){return this.addNotification(e,"warning",n)}showInfo(e,n){return this.addNotification(e,"info",n)}dismiss(e){this.notifications=this.notifications.map(o=>o.id===e?{...o,dismissed:true}:o),this.emitSnapshot();let n=setTimeout(()=>{this.timers.delete(n),this.notifications=this.notifications.filter(o=>o.id!==e),this.emitSnapshot();},300);this.timers.add(n);}clearAll(){this.notifications=[];for(let e of this.timers)clearTimeout(e);this.timers.clear(),this.emitSnapshot();}destroy(){for(let e of this.timers)clearTimeout(e);this.timers.clear(),this.notifications=[];}addNotification(e,n,o){let i=`error-${++this.idCounter}-${Date.now()}`,l={id:i,message:e,severity:n,details:o,timestamp:Date.now()};if(this.notifications=[...this.notifications,l],this.emitSnapshot(),n!=="error"){let f=setTimeout(()=>{this.timers.delete(f),this.dismiss(i);},5e3);this.timers.add(f);}return i}emitSnapshot(){this.setSnapshot({notifications:this.notifications});}};var Me="0.0.2";export{d as ErrorManager,s as Subscribable,c as TABLE_DATA_ATTRIBUTES,m as TableSelectionManager,Me as VERSION,b as deleteTableFromDocument,g as findTableFromClick,Te as formatPageRange,me as getDefaultPrintOptions,h as getTableFromDocument,be as isPrintSupported,ge as openPrintWindow,he as parsePageRange,de as triggerPrint,T as updateTableInDocument};
1
+ export{i as attemptSelectiveSave,h as createDocx,a as parseDocx,f as repackDocx,c as serializeDocumentBody,b as serializeDocx,d as serializeSectionProperties,g as updateMultipleFiles}from'./chunk-NTSSE5QK.mjs';export{f as blendColors,r as colorsEqual,o as createRgbColor,n as createThemeColor,d as darkenColor,p as ensureHexPrefix,h as generateThemeTintShadeMatrix,c as getContrastingColor,g as getThemeTintShadeHex,k as isBlack,l as isWhite,e as lightenColor,m as parseColorString,a as resolveColor,i as resolveHighlightColor,q as resolveHighlightToCss,j as resolveShadingColor}from'./chunk-LTVVQMHB.mjs';export{b as emuToPixels,i as emuToTwips,q as formatPx,k as halfPointsToPixels,c as pixelsToEmu,h as pixelsToTwips,d as pointsToPixels,j as twipsToEmu,g as twipsToPixels}from'./chunk-CTBUQRYQ.mjs';export{n as canRenderFont,k as getLoadedFonts,g as isFontLoaded,j as isFontsLoading,i as isGoogleFontsEnabled,e as loadFont,o as loadFontFromBuffer,f as loadFonts,l as onFontsLoaded,v as preloadCommonFonts,h as setGoogleFontsEnabled,a as toArrayBuffer}from'./chunk-YTILOUAA.mjs';import'./chunk-6KDV6AIL.mjs';import'./chunk-NJHOPXZW.mjs';import'./chunk-B4IR6YP4.mjs';import'./chunk-T4EZMUXM.mjs';import {b as b$1}from'./chunk-TTRUPDAB.mjs';var ce={includeHeaders:true,includeFooters:true,includePageNumbers:true,pageRange:null,scale:1,printBackground:true,margins:"default"};function me(){return {...ce}}function de(){typeof window<"u"&&window.print();}var fe="@media print { body { margin: 0; padding: 0; } @page { margin: 0; } }";function ge(t="Document",r){if(typeof window>"u")return null;let e=window.open("","_blank");if(!e)return null;e.opener=null;let n=e.document;n.title=t;let o=n.createElement("style");o.textContent=fe,n.head.appendChild(o);let i=new DOMParser().parseFromString(r,"text/html");for(let l of Array.from(i.body.childNodes))n.body.appendChild(n.importNode(l,true));return e}function he(t,r){if(!t||!t.trim())return null;let e=t.trim();if(/^\d+$/.test(e)){let o=parseInt(e,10);return o>=1&&o<=r?{start:o,end:o}:null}let n=e.match(/^(\d+)-(\d+)$/);if(n){let o=parseInt(n[1],10),i=parseInt(n[2],10);if(o>=1&&i<=r&&o<=i)return {start:o,end:i}}return null}function Te(t,r){return t?t.start===t.end?`Page ${t.start}`:`Pages ${t.start}-${t.end}`:`All (${r} pages)`}function be(){return typeof window<"u"&&typeof window.print=="function"}var s=class{constructor(r){b$1(this,"listeners",new Set);b$1(this,"snapshot");b$1(this,"subscribe",r=>(this.listeners.add(r),()=>{this.listeners.delete(r);}));b$1(this,"getSnapshot",()=>this.snapshot);this.snapshot=r;}setSnapshot(r){this.snapshot=r,this.notify();}notify(){for(let r of this.listeners)r();}};var c={TABLE_INDEX:"data-table-index",ROW_INDEX:"data-row",COLUMN_INDEX:"data-col",TABLE_CELL:"data-table-cell"};function g(t,r){if(!(t instanceof Element))return null;let e=t;for(;e&&e!==r;){if(e.tagName==="TD"||e.tagName==="TH"){let n=e.getAttribute(c.ROW_INDEX),o=e.getAttribute(c.COLUMN_INDEX);if(n!==null&&o!==null){let i=e;for(;i&&i!==r;){if(i.tagName==="TABLE"){let l=i.getAttribute(c.TABLE_INDEX);if(l!==null)return {tableIndex:parseInt(l,10),rowIndex:parseInt(n,10),columnIndex:parseInt(o,10)};break}i=i.parentElement;}}break}e=e.parentElement;}return null}function h(t,r){if(!t.package?.document?.content)return null;let e=0;for(let n of t.package.document.content)if(n.type==="table"){if(e===r)return n;e++;}return null}function T(t,r,e){if(!t.package?.document?.content)return t;let n=0,o=t.package.document.content.map(i=>{if(i.type==="table"){if(n===r)return n++,e;n++;}return i});return {...t,package:{...t.package,document:{...t.package.document,content:o}}}}function b(t,r){if(!t.package?.document?.content)return t;let e=0,n=t.package.document.content.filter(o=>{if(o.type==="table"){let i=e===r;return e++,!i}return true});return {...t,package:{...t.package,document:{...t.package.document,content:n}}}}var m=class extends s{constructor(){super({selectedCell:null});}selectCell(r){this.setSnapshot({selectedCell:r});}clearSelection(){this.setSnapshot({selectedCell:null});}isCellSelected(r,e,n){let{selectedCell:o}=this.getSnapshot();return o?o.tableIndex===r&&o.rowIndex===e&&o.columnIndex===n:false}getSelectedCell(){return this.getSnapshot().selectedCell}};var d=class extends s{constructor(){super({notifications:[]});b$1(this,"notifications",[]);b$1(this,"idCounter",0);b$1(this,"timers",new Set);}showError(e,n){return this.addNotification(e,"error",n)}showWarning(e,n){return this.addNotification(e,"warning",n)}showInfo(e,n){return this.addNotification(e,"info",n)}dismiss(e){this.notifications=this.notifications.map(o=>o.id===e?{...o,dismissed:true}:o),this.emitSnapshot();let n=setTimeout(()=>{this.timers.delete(n),this.notifications=this.notifications.filter(o=>o.id!==e),this.emitSnapshot();},300);this.timers.add(n);}clearAll(){this.notifications=[];for(let e of this.timers)clearTimeout(e);this.timers.clear(),this.emitSnapshot();}destroy(){for(let e of this.timers)clearTimeout(e);this.timers.clear(),this.notifications=[];}addNotification(e,n,o){let i=`error-${++this.idCounter}-${Date.now()}`,l={id:i,message:e,severity:n,details:o,timestamp:Date.now()};if(this.notifications=[...this.notifications,l],this.emitSnapshot(),n!=="error"){let f=setTimeout(()=>{this.timers.delete(f),this.dismiss(i);},5e3);this.timers.add(f);}return i}emitSnapshot(){this.setSnapshot({notifications:this.notifications});}};var Me="0.0.2";export{d as ErrorManager,s as Subscribable,c as TABLE_DATA_ATTRIBUTES,m as TableSelectionManager,Me as VERSION,b as deleteTableFromDocument,g as findTableFromClick,Te as formatPageRange,me as getDefaultPrintOptions,h as getTableFromDocument,be as isPrintSupported,ge as openPrintWindow,he as parsePageRange,de as triggerPrint,T as updateTableInDocument};