@betteroffice/xlsx 0.0.5 → 0.0.7

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.
package/README.md CHANGED
@@ -39,4 +39,39 @@ package exports onto your own `<canvas>` 2D context — `paintDisplayList`,
39
39
  `cellAtPoint` / `cellRect` / `rangeRect` (hit-testing), the `viewport` math,
40
40
  `buildA11yGrid`, and `toTsv` / `fromTsv` (clipboard).
41
41
 
42
+ ## Collaboration
43
+
44
+ Open a collaborative replica, then connect it to any reliable binary transport:
45
+
46
+ ```ts
47
+ import { initWasm, openWorkbook } from "@betteroffice/xlsx";
48
+ import {
49
+ CollaborationProvider,
50
+ type CollaborationTransport,
51
+ } from "@betteroffice/xlsx/collaboration";
52
+
53
+ await initWasm();
54
+ const workbook = openWorkbook(bytes, { collaborative: true });
55
+ const transport: CollaborationTransport = createTransport();
56
+ const provider = new CollaborationProvider(workbook, transport);
57
+ provider.connect();
58
+
59
+ function dispose() {
60
+ provider.destroy();
61
+ workbook.dispose();
62
+ }
63
+ ```
64
+
65
+ The provider speaks the Yjs sync-v1 protocol used by y-websocket. WebSocket room
66
+ routing, authentication, WebRTC signaling, reconnection policy, and awareness
67
+ remain transport concerns; document updates flow directly between the connection
68
+ and the Rust/WASM Yrs replica without a second JavaScript `Y.Doc`.
69
+ After a close, the transport may reopen itself or the caller may invoke
70
+ `provider.connect()` for another connection attempt.
71
+ Call `provider.destroy()` before discarding its transport or workbook.
72
+
73
+ Collaborative sessions currently support cell content, formulas, styles, column
74
+ widths, and row heights. Structural edits and inverse-op undo are rejected until
75
+ they have stable axis identities and a Yrs-aware undo manager.
76
+
42
77
  Docs: https://betteroffice.dev · Apache-2.0.
@@ -0,0 +1,4 @@
1
+ function L(t){return Math.max(0,t.length-1)}function D(t){return t.length>0?t[t.length-1]:0}function x(t,e,n){return Math.max(e,Math.min(n,t))}function E(t,e,n,o){let r=n,l=o;for(;r<l;){let c=r+l+1>>1;t[c]<=e?r=c:l=c-1;}return r}function M(t,e,n,o){let r=L(t);if(r===0)return {first:0,last:-1};let l=x(Math.trunc(e),0,r);if(l>=r)return {first:0,last:-1};let c=t[l]-t[0],i=t[l]+Math.max(0,n),s=Math.max(0,o-c),p=i+s,m=E(t,i,l,r-1);if(t[m+1]<=i||s===0)return {first:0,last:-1};let C=E(t,p,m,r-1);return {first:m,last:C}}function V(t,e,n){return {cols:M(e,t.frozenCols,t.scrollX,t.width),rows:M(n,t.frozenRows,t.scrollY,t.height)}}function T(t,e,n){let o=L(t),r=x(Math.trunc(e),0,o),l=D(t)-t[r],c=Math.max(0,n-(t[r]-t[0]));return Math.max(0,l-c)}function z(t,e,n){let o=x(t.scrollX,0,T(e,t.frozenCols,t.width)),r=x(t.scrollY,0,T(n,t.frozenRows,t.height));return o===t.scrollX&&r===t.scrollY?t:{...t,scrollX:o,scrollY:r}}function H(t,e){let n=new Array(t+1);for(let o=0;o<=t;o++)n[o]=o*e;return n}function S(t,e,n){return Math.max(e,Math.min(n,t))}function u(t){return {anchor:{...t},focus:{...t}}}function y(t){return {top:Math.min(t.anchor.row,t.focus.row),bottom:Math.max(t.anchor.row,t.focus.row),left:Math.min(t.anchor.col,t.focus.col),right:Math.max(t.anchor.col,t.focus.col)}}function _(t,e){let n=y(t);return e.row>=n.top&&e.row<=n.bottom&&e.col>=n.left&&e.col<=n.right}function $(t){let e=y(t);return (e.bottom-e.top+1)*(e.right-e.left+1)}function A(t,e,n){let o=n?{row:S(e.row,0,n.rows-1),col:S(e.col,0,n.cols-1)}:{...e};return {anchor:{...t.anchor},focus:o}}function k(t,e){switch(t){case "up":return {row:-e,col:0};case "down":return {row:e,col:0};case "left":return {row:0,col:-e};case "right":return {row:0,col:e}}}function h(t,e,n){let{limits:o}=n,r=n.step??1,l=k(e,r),c={row:S(t.focus.row+l.row,0,o.rows-1),col:S(t.focus.col+l.col,0,o.cols-1)};return n.extend?A(t,c):u(c)}var B={ArrowUp:"up",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right"};function g(t){return !!(t.metaKey||t.ctrlKey)}function X(t,e,n){switch(e){case "up":return {row:0,col:t.col};case "down":return {row:n.rows-1,col:t.col};case "left":return {row:t.row,col:0};case "right":return {row:t.row,col:n.cols-1}}}function a(t){return {type:"move",selection:t}}function Y(t,e,n){let{row:o,col:r}=t.focus;return !e&&r>=n.cols-1?u({row:Math.min(o+1,n.rows-1),col:0}):e&&r<=0?u({row:Math.max(o-1,0),col:n.cols-1}):u({row:o,col:r+(e?-1:1)})}function W(t){return t.key.length===1&&!t.ctrlKey&&!t.metaKey&&!t.altKey}function j(t,e,n){let o=B[e.key];if(o){if(g(e)){let r=X(t.focus,o,n);return a(e.shiftKey?A(t,r,n):u(r))}return a(h(t,o,{extend:e.shiftKey,limits:n}))}switch(e.key){case "Tab":return a(Y(t,!!e.shiftKey,n));case "Enter":return a(h(t,e.shiftKey?"up":"down",{extend:false,limits:n}));case "Home":return a(g(e)?u({row:0,col:0}):u({row:t.focus.row,col:0}));case "End":return a(g(e)?u({row:n.rows-1,col:n.cols-1}):u({row:t.focus.row,col:n.cols-1}));case "PageDown":return a(h(t,"down",{extend:e.shiftKey,step:n.rowsPerPage,limits:n}));case "PageUp":return a(h(t,"up",{extend:e.shiftKey,step:n.rowsPerPage,limits:n}));case "F2":return {type:"startEdit"};case "Delete":case "Backspace":return {type:"clear"}}return (e.key==="a"||e.key==="A")&&g(e)?a({anchor:{row:0,col:0},focus:{row:n.rows-1,col:n.cols-1}}):W(e)?{type:"startEdit",initialInput:e.key}:{type:"none"}}function I(t,e){let n=t.length-1;if(n<=0||e<t[0]||e>=t[n])return -1;let o=0,r=n-1;for(;o<r;){let l=o+r+1>>1;t[l]<=e?o=l:r=l-1;}return o}function at(t,e,n){if(!t)return null;let o=I(t.colOffsets,e),r=I(t.rowOffsets,n);return o<0||r<0?null:{row:t.startRow+r,col:t.startCol+o}}function K(t,e,n){let o=n-t;return o>=0&&o<e.length-1?o:-1}function mt(t,e,n){if(!t)return null;let o=K(t.startCol,t.colOffsets,n),r=K(t.startRow,t.rowOffsets,e);return o<0||r<0?null:{x:t.colOffsets[o],y:t.rowOffsets[r],w:t.colOffsets[o+1]-t.colOffsets[o],h:t.rowOffsets[r+1]-t.rowOffsets[r]}}function R(t,e,n){return Math.max(0,Math.min(e-1,n-t))}function pt(t,e){if(!t)return null;let n=t.colOffsets.length-1,o=t.rowOffsets.length-1;if(n<=0||o<=0)return null;let r=t.startCol+n-1,l=t.startRow+o-1;if(e.right<t.startCol||e.left>r||e.bottom<t.startRow||e.top>l)return null;let c=R(t.startCol,n,e.left),i=R(t.startCol,n,e.right),s=R(t.startRow,o,e.top),p=R(t.startRow,o,e.bottom);return {x:t.colOffsets[c],y:t.rowOffsets[s],w:t.colOffsets[i+1]-t.colOffsets[c],h:t.rowOffsets[p+1]-t.rowOffsets[s]}}var U=new Set(["=","+","-","@"]);function q(t){let e=t.charCodeAt(0);return U.has(t[0])||e===9||e===13||e===10}function J(t){return /[\t\n\r"]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function N(t){let e=!t.isFormula&&t.input.length>0&&q(t.input);return J(e?`'${t.input}`:t.input)}function ht(t){return t.map(e=>e.map(N).join(" ")).join(`\r
2
+ `)}function bt(t){let e=[],n=[],o="",r=false,l=0,c=()=>{n.push(o),o="";},i=()=>{c(),e.push(n),n=[];};for(;l<t.length;){let s=t[l];if(r){if(s==='"'){if(t[l+1]==='"'){o+='"',l+=2;continue}r=false,l+=1;continue}o+=s,l+=1;continue}if(s==='"'){r=true,l+=1;continue}if(s===" "){c(),l+=1;continue}if(s==="\r"){i(),t[l+1]===`
3
+ `&&(l+=1),l+=1;continue}if(s===`
4
+ `){i(),l+=1;continue}o+=s,l+=1;}return (o.length>0||n.length>0)&&i(),e}function v(t){let e=t,n="";do n=String.fromCharCode(65+e%26)+n,e=Math.floor(e/26)-1;while(e>=0);return n}function Q(t,e){return `${v(e)}${t+1}`}function O(t,e){return t.replace(/\{(\w+)\}/g,(n,o)=>String(e[o]??""))}function P(t,e){return `${Math.round(t*1e3)},${Math.round(e*1e3)}`}function Z(t){let e=new Map;for(let n of t.commands)n.op==="text"&&n.clip&&!n.ghost&&e.set(P(n.clip.x,n.clip.y),n.text);return e}function tt(t,e,n){return t?e>=t.top&&e<=t.bottom&&n>=t.left&&n<=t.right:false}function et(t,e,n,o,r,l){let c=t.startRow+e,i=t.startCol+n,s=Q(c,i),m=o.length===0?r?l.emptyCellLabelSelected:l.emptyCellLabel:r?l.cellLabelSelected:l.cellLabel;return {row:c,col:i,address:s,text:o,selected:r,label:O(m,{address:s,value:o})}}function Ct(t,e,n,o){let r=t.grid,l=O(o.gridLabel,{sheet:n});if(!r)return {label:l,sheetName:n,columnHeaders:[],rows:[]};let c=r.colOffsets.length-1,i=r.rowOffsets.length-1,s=e?y(e):null,p=Z(t),m=[];for(let f=0;f<c;f++){let w=r.startCol+f,b=v(w);m.push({col:w,text:b,label:O(o.columnHeaderLabel,{column:b})});}let C=[];for(let f=0;f<i;f++){let w=r.startRow+f,b=[];for(let d=0;d<c;d++){let F=P(r.colOffsets[d],r.rowOffsets[f]),G=p.get(F)??"";b.push(et(r,f,d,G,tt(s,w,r.startCol+d),o));}C.push({row:w,header:O(o.rowHeaderLabel,{row:w+1}),cells:b});}return {label:l,sheetName:n,columnHeaders:m,rows:C}}export{L as a,D as b,M as c,V as d,z as e,H as f,u as g,y as h,_ as i,$ as j,A as k,h as l,j as m,at as n,mt as o,pt as p,ht as q,bt as r,Ct as s};
@@ -0,0 +1 @@
1
+ var d=Object.defineProperty;var e=(b,a,c)=>a in b?d(b,a,{enumerable:true,configurable:true,writable:true,value:c}):b[a]=c;var f=(b,a,c)=>e(b,typeof a!="symbol"?a+"":a,c);export{f as a};
@@ -0,0 +1,56 @@
1
+ import { C as CollaborationReplica, a as CollaborationTransport, b as CollaborationProviderOptions, c as CollaborationStatus, d as CollaborationStatusListener, e as CollaborationErrorListener } from './types-RWuztdjw.js';
2
+ export { f as CollaborationError, g as CollaborationErrorCode, h as CollaborationStatusChange, i as CollaborationTransportEvent, j as CollaborationUpdateOrigin } from './types-RWuztdjw.js';
3
+
4
+ declare class CollaborationProvider {
5
+ private readonly replica;
6
+ private readonly transport;
7
+ private readonly maxFrameBytes;
8
+ private readonly maxMessagesPerFrame;
9
+ private readonly maxPendingBytes;
10
+ private readonly statusListeners;
11
+ private readonly errorListeners;
12
+ private readonly pendingFrames;
13
+ private unsubscribeReplica;
14
+ private unsubscribeTransport;
15
+ private hasTransportSubscription;
16
+ private connectionStatus;
17
+ private isSynced;
18
+ private wantsConnection;
19
+ private isOpen;
20
+ private isDestroyed;
21
+ private epoch;
22
+ private connectAttempt;
23
+ private nextListenerId;
24
+ private queuedBytes;
25
+ private isFlushing;
26
+ private transportCleanup;
27
+ private statusRevision;
28
+ constructor(replica: CollaborationReplica, transport: CollaborationTransport, options?: CollaborationProviderOptions);
29
+ get status(): CollaborationStatus;
30
+ get synced(): boolean;
31
+ get pendingBytes(): number;
32
+ connect(): void;
33
+ private startConnection;
34
+ disconnect(): void;
35
+ destroy(): void;
36
+ onStatus(listener: CollaborationStatusListener): () => void;
37
+ onError(listener: CollaborationErrorListener): () => void;
38
+ private isCurrent;
39
+ private failConnection;
40
+ private takeTransportSubscription;
41
+ private cleanupTransport;
42
+ private handleTransportEvent;
43
+ private handleOpen;
44
+ private handleMessage;
45
+ private respondToSyncStep1;
46
+ private applyRemoteUpdate;
47
+ private forwardLocalUpdate;
48
+ private sendFrame;
49
+ private queueFrame;
50
+ private flushPending;
51
+ private clearPending;
52
+ private setStatus;
53
+ private report;
54
+ }
55
+
56
+ export { CollaborationErrorListener, CollaborationProvider, CollaborationProviderOptions, CollaborationReplica, CollaborationStatus, CollaborationStatusListener, CollaborationTransport };
@@ -0,0 +1 @@
1
+ import {a as a$1}from'./chunk-O2XFH626.js';var w=Number.MAX_SAFE_INTEGER,c=class extends Error{constructor(t){super(t),this.name="ProtocolError";}},d=class{constructor(t){a$1(this,"bytes",t);a$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++],o=n&127;if(o>Math.floor((w-t)/e))throw new c("varUint exceeds Number.MAX_SAFE_INTEGER");if(t+=o*e,r+=1,(n&128)===0){if(r>1&&o===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 h(s){if(!Number.isSafeInteger(s)||s<0)throw new c("varUint value must be a non-negative safe integer");let t=[],e=s;for(;e>=128;)t.push(e%128|128),e=Math.floor(e/128);return t.push(e),Uint8Array.from(t)}function E(s,t){let e=0;for(let o of s)if(e+=o.byteLength,e>t)throw new c(`Frame exceeds ${t} bytes`);let r=new Uint8Array(e),n=0;for(let o of s)r.set(o,n),n+=o.byteLength;return r}function y(s,t,e){return E([h(0),h(s),h(t.byteLength),t],e)}function C(s,t=67108880){return y(0,s,t)}function S(s,t=67108880){return y(1,s,t)}function A(s,t=67108880){return y(2,s,t)}function g(s=67108880){let t=Uint8Array.of(0);return E([h(1),h(t.byteLength),t],s)}function v(s,t=67108880,e=4096){if(!(s instanceof Uint8Array))throw new c("Frame must be a Uint8Array");if(s.byteLength===0)throw new c("Frame is empty");if(s.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 d(s),n=[];for(;!r.done;){if(n.length>=e)throw new c(`Frame exceeds ${e} messages`);let o=r.readVarUint();switch(o){case 0:{let p=r.readVarUint(),l=r.readVarUint8Array();if(p===0)n.push({type:"sync-step-1",stateVector:l});else if(p===1)n.push({type:"sync-step-2",update:l});else if(p===2)n.push({type:"update",update:l});else throw new c(`Unknown sync message type ${p}`);break}case 1:n.push({type:"awareness",update:r.readVarUint8Array()});break;case 2:{let p=r.readVarUint();if(p!==0)throw new c(`Unknown auth message type ${p}`);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 ${o}`)}}return n}var u=class extends Error{constructor(e,r,n){super(r);a$1(this,"code");a$1(this,"cause");this.name="CollaborationError",this.code=e,this.cause=n;}};var _=67108880;function f(s,t,e){if(!Number.isSafeInteger(t)||t<(e?0:1))throw new RangeError(`${s} must be ${e?"a non-negative":"a positive"} integer`);return t}function F(s){return s instanceof Error&&s.message?s.message:typeof s=="string"&&s?s:"Unknown error"}function a(s,t,e){return e instanceof u?e:new u(s,`${t}: ${F(e)}`,e)}function b(s,t){if(!(s instanceof Uint8Array))throw new TypeError(`${t} must return a Uint8Array`);return s.slice()}var m=class{constructor(t,e,r={}){a$1(this,"replica");a$1(this,"transport");a$1(this,"maxFrameBytes");a$1(this,"maxMessagesPerFrame");a$1(this,"maxPendingBytes");a$1(this,"statusListeners",new Map);a$1(this,"errorListeners",new Map);a$1(this,"pendingFrames",[]);a$1(this,"unsubscribeReplica");a$1(this,"unsubscribeTransport",()=>{});a$1(this,"hasTransportSubscription",false);a$1(this,"connectionStatus","disconnected");a$1(this,"isSynced",false);a$1(this,"wantsConnection",false);a$1(this,"isOpen",false);a$1(this,"isDestroyed",false);a$1(this,"epoch",0);a$1(this,"connectAttempt",0);a$1(this,"nextListenerId",0);a$1(this,"queuedBytes",0);a$1(this,"isFlushing",false);a$1(this,"transportCleanup");a$1(this,"statusRevision",0);this.replica=t,this.transport=e,this.maxFrameBytes=f("maxFrameBytes",r.maxFrameBytes??67108880,false),this.maxMessagesPerFrame=f("maxMessagesPerFrame",r.maxMessagesPerFrame??4096,false),this.maxPendingBytes=f("maxPendingBytes",r.maxPendingBytes??_,true);try{this.unsubscribeReplica=t.onUpdate((n,o)=>{o==="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(){this.isDestroyed||this.isOpen||this.connectionStatus==="connecting"||(this.wantsConnection=true,this.setStatus("connecting",false),!(this.transportCleanup||this.isDestroyed||!this.wantsConnection)&&this.startConnection());}startConnection(){if(this.isDestroyed||!this.wantsConnection||this.isOpen||this.transportCleanup)return;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 o of n)this.report(o);}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||this.transportCleanup)return r;try{let n=this.transport.disconnect();if(n){let o=!1,p=Promise.resolve(n).catch(l=>{o=!0,this.isDestroyed||this.report(a("transport","Transport disconnect failed",l));}).finally(()=>{this.transportCleanup===p&&(this.transportCleanup=void 0,!this.isDestroyed&&(o?(this.wantsConnection=!1,this.setStatus("disconnected",!1)):this.wantsConnection&&this.startConnection()));});this.transportCleanup=p;}}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 u("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=b(this.replica.encodeStateVector(),"encodeStateVector");}catch(r){this.failConnection(t,a("replica","Failed to encode replica state vector",r));return}try{this.sendFrame(C(e,this.maxFrameBytes));}catch(r){this.failConnection(t,a("protocol","Failed to encode SyncStep1",r));}}handleMessage(t,e){let r;try{if(!(e instanceof Uint8Array))throw new TypeError("Frame must be a Uint8Array");if(e.byteLength>this.maxFrameBytes)throw new RangeError(`Frame exceeds ${this.maxFrameBytes} bytes`);r=v(e,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 u("protocol",n.reason?`Authentication denied: ${n.reason}`:"Authentication denied"));return;case "query-awareness":try{this.sendFrame(g(this.maxFrameBytes));}catch(o){this.failConnection(t,a("protocol","Failed to encode awareness response",o));return}break}}}respondToSyncStep1(t,e){let r;try{r=b(this.replica.encodeStateAsUpdate(e.slice()),"encodeStateAsUpdate");}catch(n){this.failConnection(t,a("replica","Failed to encode replica update",n));return}try{this.sendFrame(S(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=b(t,"Replica update");}catch(n){this.failConnection(e,a("replica","Invalid replica update",n));return}try{this.sendFrame(A(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 u("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 u("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 u("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=++this.statusRevision,n={status:t,synced:e};for(let[o,p]of [...this.statusListeners]){if(this.statusRevision!==r)return;if(this.statusListeners.get(o)===p)try{p(n);}catch{}}}report(t){for(let[e,r]of [...this.errorListeners])if(this.errorListeners.get(e)===r)try{r(t);}catch{}}};export{u as CollaborationError,m as CollaborationProvider};
Binary file
@@ -75,8 +75,15 @@ interface TextCmd {
75
75
  italic?: boolean;
76
76
  underline?: boolean;
77
77
  strike?: boolean;
78
+ highlight?: string;
79
+ dashedUnderline?: boolean;
78
80
  /** css/font family from the style font; the backend falls back to its default. */
79
81
  fontFamily?: string;
82
+ /**
83
+ * Preview text that is not the cell's committed value (a proposal ghost's
84
+ * `new` text). Painted normally, but excluded from a11y text recovery.
85
+ */
86
+ ghost?: boolean;
80
87
  }
81
88
  /**
82
89
  * One draw command; discriminated on `op`.
package/dist/headless.js CHANGED
@@ -1 +1 @@
1
- export{t as buildA11yGrid,o as cellAtPoint,k as cellCount,p as cellRect,f as clampScroll,l as extendTo,s as fromTsv,m as moveFocus,i as normalizeRange,j as rangeContains,q as rangeRect,h as selectionAt,n as selectionKeyReducer,r as toTsv,c as totalExtent,b as trackCount,g as uniformOffsets,e as visibleCells,d as visibleRange}from'./chunk-VVLZGZMW.js';
1
+ export{s as buildA11yGrid,n as cellAtPoint,j as cellCount,o as cellRect,e as clampScroll,k as extendTo,r as fromTsv,l as moveFocus,h as normalizeRange,i as rangeContains,p as rangeRect,g as selectionAt,m as selectionKeyReducer,q as toTsv,b as totalExtent,a as trackCount,f as uniformOffsets,d as visibleCells,c as visibleRange}from'./chunk-2OVPP3IG.js';import'./chunk-O2XFH626.js';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { DisplayList } from './headless.js';
2
2
  export { A11yCell, A11yColumnHeader, A11yGrid, A11yRow, A11yStrings, CellAddr, CellInput, CellRange, Direction, DrawCmd, FillRectCmd, GridMeta, KeyInput, LineCmd, MoveOpts, Rect, Selection, SelectionAction, SelectionLimits, TextAlign, TextCmd, TrackOffsets, ViewportState, VisibleCells, VisibleRange, buildA11yGrid, cellAtPoint, cellCount, cellRect, clampScroll, extendTo, fromTsv, moveFocus, normalizeRange, rangeContains, rangeRect, selectionAt, selectionKeyReducer, toTsv, totalExtent, trackCount, uniformOffsets, visibleCells, visibleRange } from './headless.js';
3
+ import { C as CollaborationReplica, j as CollaborationUpdateOrigin } from './types-RWuztdjw.js';
3
4
 
4
5
  /**
5
6
  * Canvas2D backend for the display list — the browser paint target.
@@ -65,6 +66,80 @@ interface EditResult {
65
66
  interface CalculationStatus {
66
67
  limitedCells: string[];
67
68
  }
69
+ type NumberFormat = 'automatic' | 'plainText' | 'number' | 'percent' | 'scientific' | 'currency' | 'date' | 'time' | 'custom';
70
+ type BorderPreset = 'all' | 'inner' | 'horizontal' | 'vertical' | 'outer' | 'left' | 'top' | 'right' | 'bottom' | 'none';
71
+ type BorderStyle = 'solid' | 'dashed' | 'dotted' | 'double';
72
+ type HorizontalAlignment = 'left' | 'center' | 'right';
73
+ type VerticalAlignment = 'top' | 'middle' | 'bottom';
74
+ type TextWrapping = 'overflow' | 'wrap' | 'clip';
75
+ type StyleProperty = 'bold' | 'italic' | 'strikethrough' | 'fontFamily' | 'fontSize' | 'textColor' | 'fillColor' | 'borders' | 'horizontalAlignment' | 'verticalAlignment' | 'textWrapping';
76
+ interface BorderPatch {
77
+ preset?: BorderPreset;
78
+ style?: BorderStyle;
79
+ color?: string;
80
+ }
81
+ interface RangeStylePatch {
82
+ bold?: boolean;
83
+ italic?: boolean;
84
+ strikethrough?: boolean;
85
+ fontFamily?: string;
86
+ fontSize?: number;
87
+ textColor?: string;
88
+ fillColor?: string;
89
+ border?: BorderPatch;
90
+ horizontalAlignment?: HorizontalAlignment;
91
+ verticalAlignment?: VerticalAlignment;
92
+ textWrapping?: TextWrapping;
93
+ clear?: StyleProperty[];
94
+ }
95
+ type NumberFormatMutation = Exclude<NumberFormat, 'custom'> | 'increaseDecimal' | 'decreaseDecimal' | {
96
+ type: 'custom';
97
+ pattern: string;
98
+ };
99
+ interface SelectionFormatting {
100
+ numberFormat?: NumberFormat;
101
+ numberFormatPattern?: string;
102
+ fontFamily?: string;
103
+ fontSize?: number;
104
+ bold?: boolean;
105
+ italic?: boolean;
106
+ strikethrough?: boolean;
107
+ textColor?: string;
108
+ fillColor?: string;
109
+ borderPreset?: BorderPreset;
110
+ borderStyle?: BorderStyle;
111
+ borderColor?: string;
112
+ horizontalAlignment?: HorizontalAlignment;
113
+ verticalAlignment?: VerticalAlignment;
114
+ textWrapping?: TextWrapping;
115
+ }
116
+ interface CapturedFormat {
117
+ rows: number;
118
+ columns: number;
119
+ formats: unknown[];
120
+ }
121
+ interface CellPoint {
122
+ row: number;
123
+ col: number;
124
+ }
125
+ interface MergedRange {
126
+ start: CellPoint;
127
+ end: CellPoint;
128
+ }
129
+ interface HistoryState {
130
+ canUndo: boolean;
131
+ canRedo: boolean;
132
+ undoDepth: number;
133
+ redoDepth: number;
134
+ }
135
+ type WorkbookUpdateOrigin = CollaborationUpdateOrigin;
136
+ type WorkbookUpdateListener = (update: Uint8Array, origin: WorkbookUpdateOrigin) => void;
137
+ interface OpenWorkbookOptions {
138
+ /** Open a Yrs-backed replica that can accept peer updates. */
139
+ collaborative?: boolean;
140
+ /** Peer-unique positive safe integer. Generated securely when omitted. */
141
+ clientId?: number;
142
+ }
68
143
  /**
69
144
  * The editable view of one cell: A1 address, the exact string the user would
70
145
  * edit (formulas as `=...`, guarded literals with a leading `'`), and whether
@@ -88,6 +163,7 @@ interface CellInputEdit {
88
163
  */
89
164
  interface ProposalEdit extends CellInputEdit {
90
165
  sheet: number;
166
+ numberFormat?: NumberFormatMutation;
91
167
  }
92
168
  /**
93
169
  * One cell of a pending proposal: where it lands and the *formatted display
@@ -128,7 +204,16 @@ declare class StaleProposalError extends Error {
128
204
  * A typed handle over an open workbook, hiding the wasm object and its JSON
129
205
  * boundary. Call {@link WorkbookHandle.dispose} to free the wasm memory.
130
206
  */
131
- interface WorkbookHandle {
207
+ interface WorkbookHandle extends CollaborationReplica {
208
+ readonly clientId: number;
209
+ /** Available in both modes; encodes this handle's current Yrs state vector. */
210
+ encodeStateVector(): Uint8Array;
211
+ /** Available in both modes; pass a peer vector to encode only the missing state. */
212
+ encodeStateAsUpdate(remoteStateVector?: Uint8Array): Uint8Array;
213
+ /** Apply a peer update. Standalone handles throw the Rust `NotCollaborative` error. */
214
+ applyUpdate(update: Uint8Array): EditResult;
215
+ /** Observe owned update bytes from local commits and accepted remote updates. */
216
+ onUpdate(listener: WorkbookUpdateListener): () => void;
132
217
  sheetInfo(): SheetInfo;
133
218
  calculationStatus(): CalculationStatus;
134
219
  displayList(viewport: Viewport): DisplayList;
@@ -149,6 +234,13 @@ interface WorkbookHandle {
149
234
  cell(sheet: number, row: number, col: number): CellEdit;
150
235
  /** row-major editable views for a range, e.g. "A1:C3" (clipboard copy). */
151
236
  rangeCells(sheet: number, range: string): CellEdit[][];
237
+ patchRangeStyle(sheet: number, range: string, patch: RangeStylePatch): EditResult;
238
+ setNumberFormat(sheet: number, range: string, format: NumberFormatMutation): EditResult;
239
+ selectionFormatting(sheet: number, range: string): SelectionFormatting;
240
+ captureFormat(sheet: number, range: string): CapturedFormat;
241
+ applyFormat(sheet: number, range: string, format: CapturedFormat): EditResult;
242
+ mergedRanges(sheet: number, range: string): MergedRange[];
243
+ historyState(): HistoryState;
152
244
  /**
153
245
  * render the current sheet viewport to png bytes via the native raster
154
246
  * backend — the same display list the canvas paints, rasterized server-side.
@@ -214,10 +306,10 @@ declare function isProposalsAvailable(): boolean;
214
306
  * Open a workbook from raw `.xlsx` bytes, initializing the core if needed.
215
307
  * Throws an `Error` if the bytes are not a readable workbook.
216
308
  */
217
- declare function openWorkbook(bytes: Uint8Array): WorkbookHandle;
309
+ declare function openWorkbook(bytes: Uint8Array, options?: OpenWorkbookOptions): WorkbookHandle;
218
310
  /**
219
311
  * The crate version string, for asserting wasm/js parity.
220
312
  */
221
313
  declare function wasmVersion(): string;
222
314
 
223
- export { type CalculationStatus, type CellEdit, type CellInputEdit, DisplayList, type EditResult, type Proposal, type ProposalCell, type ProposalEdit, type SheetInfo, StaleProposalError, type Viewport, type WasmInitInput, type WorkbookHandle, initWasm, isPngExportAvailable, isProposalsAvailable, isWasmAvailable, openWorkbook, paintDisplayList, wasmVersion };
315
+ export { type BorderPatch, type BorderPreset, type BorderStyle, type CalculationStatus, type CapturedFormat, type CellEdit, type CellInputEdit, type CellPoint, DisplayList, type EditResult, type HistoryState, type HorizontalAlignment, type MergedRange, type NumberFormat, type NumberFormatMutation, type OpenWorkbookOptions, type Proposal, type ProposalCell, type ProposalEdit, type RangeStylePatch, type SelectionFormatting, type SheetInfo, StaleProposalError, type StyleProperty, type TextWrapping, type VerticalAlignment, type Viewport, type WasmInitInput, type WorkbookHandle, type WorkbookUpdateListener, type WorkbookUpdateOrigin, initWasm, isPngExportAvailable, isProposalsAvailable, isWasmAvailable, openWorkbook, paintDisplayList, wasmVersion };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import {a}from'./chunk-VVLZGZMW.js';export{t as buildA11yGrid,o as cellAtPoint,k as cellCount,p as cellRect,f as clampScroll,l as extendTo,s as fromTsv,m as moveFocus,i as normalizeRange,j as rangeContains,q as rangeRect,h as selectionAt,n as selectionKeyReducer,r as toTsv,c as totalExtent,b as trackCount,g as uniformOffsets,e as visibleCells,d as visibleRange}from'./chunk-VVLZGZMW.js';var Q={left:"left",center:"center",right:"right"},Z={dashed:[4,2],dotted:[1,2]};function ee(n,e,t){n.save(),n.setTransform(t,0,0,t,0,0),n.clearRect(0,0,e.width,e.height);for(let r of e.commands)te(n,r);n.restore();}function te(n,e){switch(e.op){case "fillRect":n.fillStyle=e.color,n.fillRect(e.x,e.y,e.w,e.h);return;case "line":ne(n,e);return;case "text":re(n,e);return}}function ne(n,e){if(n.strokeStyle=e.color,e.style==="double"){let t=Math.max(e.width*.8,.8),r=Math.abs(e.y1-e.y2)<=Math.abs(e.x1-e.x2),[o,s]=r?[0,t]:[t,0];n.lineWidth=Math.max(e.width*.6,.5),S(n,e.x1-o,e.y1-s,e.x2-o,e.y2-s),S(n,e.x1+o,e.y1+s,e.x2+o,e.y2+s);return}n.lineWidth=e.width,n.save(),n.setLineDash(e.style?Z[e.style]:[]),S(n,e.x1,e.y1,e.x2,e.y2),n.restore();}function S(n,e,t,r,o){n.beginPath(),n.moveTo(e,t),n.lineTo(r,o),n.stroke();}function re(n,e){n.save(),e.clip&&(n.beginPath(),n.rect(e.clip.x,e.clip.y,e.clip.w,e.clip.h),n.clip()),n.fillStyle=e.color,n.font=oe(e),n.textAlign=Q[e.align??"left"],n.textBaseline="alphabetic",n.fillText(e.text,e.x,e.y),(e.underline||e.strike)&&se(n,e),n.restore();}function oe(n){let e=n.italic?"italic ":"",t=n.bold?"bold ":"",r=n.fontFamily??"sans-serif";return `${e}${t}${n.fontSize}px ${r}`}function se(n,e){let t=n.measureText(e.text).width,r=e.align??"left",o=r==="right"?e.x-t:r==="center"?e.x-t/2:e.x,s=Math.max(e.fontSize*.05,.5);n.fillStyle=e.color,e.underline&&n.fillRect(o,e.y+e.fontSize*.1,t,s),e.strike&&n.fillRect(o,e.y-e.fontSize*.26,t,s);}var g=class n{static __wrap(e){let t=Object.create(n.prototype);return t.__wbg_ptr=e,A.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,A.unregister(this),e}free(){let e=this.__destroy_into_raw();i.__wbg_xlsxdocument_free(e,0);}acceptProposalJson(e){let t,r;try{let a=_(e,i.__wbindgen_malloc,i.__wbindgen_realloc),c=d,l=i.xlsxdocument_acceptProposalJson(this.__wbg_ptr,a,c);var o=l[0],s=l[1];if(l[3])throw o=0,s=0,f(l[2]);return t=o,r=s,u(o,s)}finally{i.__wbindgen_free(t,r,1);}}applyOpsJson(e){let t,r;try{let a=_(e,i.__wbindgen_malloc,i.__wbindgen_realloc),c=d,l=i.xlsxdocument_applyOpsJson(this.__wbg_ptr,a,c);var o=l[0],s=l[1];if(l[3])throw o=0,s=0,f(l[2]);return t=o,r=s,u(o,s)}finally{i.__wbindgen_free(t,r,1);}}calculationStatusJson(){let e,t;try{let s=i.xlsxdocument_calculationStatusJson(this.__wbg_ptr);var r=s[0],o=s[1];if(s[3])throw r=0,o=0,f(s[2]);return e=r,t=o,u(r,o)}finally{i.__wbindgen_free(e,t,1);}}cellJson(e){let t,r;try{let a=_(e,i.__wbindgen_malloc,i.__wbindgen_realloc),c=d,l=i.xlsxdocument_cellJson(this.__wbg_ptr,a,c);var o=l[0],s=l[1];if(l[3])throw o=0,s=0,f(l[2]);return t=o,r=s,u(o,s)}finally{i.__wbindgen_free(t,r,1);}}displayListJson(e){let t,r;try{let a=_(e,i.__wbindgen_malloc,i.__wbindgen_realloc),c=d,l=i.xlsxdocument_displayListJson(this.__wbg_ptr,a,c);var o=l[0],s=l[1];if(l[3])throw o=0,s=0,f(l[2]);return t=o,r=s,u(o,s)}finally{i.__wbindgen_free(t,r,1);}}editCellJson(e){let t,r;try{let a=_(e,i.__wbindgen_malloc,i.__wbindgen_realloc),c=d,l=i.xlsxdocument_editCellJson(this.__wbg_ptr,a,c);var o=l[0],s=l[1];if(l[3])throw o=0,s=0,f(l[2]);return t=o,r=s,u(o,s)}finally{i.__wbindgen_free(t,r,1);}}editCellsJson(e){let t,r;try{let a=_(e,i.__wbindgen_malloc,i.__wbindgen_realloc),c=d,l=i.xlsxdocument_editCellsJson(this.__wbg_ptr,a,c);var o=l[0],s=l[1];if(l[3])throw o=0,s=0,f(l[2]);return t=o,r=s,u(o,s)}finally{i.__wbindgen_free(t,r,1);}}listProposalsJson(){let e,t;try{let s=i.xlsxdocument_listProposalsJson(this.__wbg_ptr);var r=s[0],o=s[1];if(s[3])throw r=0,o=0,f(s[2]);return e=r,t=o,u(r,o)}finally{i.__wbindgen_free(e,t,1);}}static open(e){let t=le(e,i.__wbindgen_malloc),r=d,o=i.xlsxdocument_open(t,r);if(o[2])throw f(o[1]);return n.__wrap(o[0])}proposeJson(e){let t,r;try{let a=_(e,i.__wbindgen_malloc,i.__wbindgen_realloc),c=d,l=i.xlsxdocument_proposeJson(this.__wbg_ptr,a,c);var o=l[0],s=l[1];if(l[3])throw o=0,s=0,f(l[2]);return t=o,r=s,u(o,s)}finally{i.__wbindgen_free(t,r,1);}}rangeCellsJson(e){let t,r;try{let a=_(e,i.__wbindgen_malloc,i.__wbindgen_realloc),c=d,l=i.xlsxdocument_rangeCellsJson(this.__wbg_ptr,a,c);var o=l[0],s=l[1];if(l[3])throw o=0,s=0,f(l[2]);return t=o,r=s,u(o,s)}finally{i.__wbindgen_free(t,r,1);}}redoJson(){let e,t;try{let s=i.xlsxdocument_redoJson(this.__wbg_ptr);var r=s[0],o=s[1];if(s[3])throw r=0,o=0,f(s[2]);return e=r,t=o,u(r,o)}finally{i.__wbindgen_free(e,t,1);}}rejectProposalJson(e){let t,r;try{let a=_(e,i.__wbindgen_malloc,i.__wbindgen_realloc),c=d,l=i.xlsxdocument_rejectProposalJson(this.__wbg_ptr,a,c);var o=l[0],s=l[1];if(l[3])throw o=0,s=0,f(l[2]);return t=o,r=s,u(o,s)}finally{i.__wbindgen_free(t,r,1);}}renderPng(e){let t=_(e,i.__wbindgen_malloc,i.__wbindgen_realloc),r=d,o=i.xlsxdocument_renderPng(this.__wbg_ptr,t,r);if(o[3])throw f(o[2]);var s=J(o[0],o[1]).slice();return i.__wbindgen_free(o[0],o[1]*1,1),s}renderRangePng(e){let t=_(e,i.__wbindgen_malloc,i.__wbindgen_realloc),r=d,o=i.xlsxdocument_renderRangePng(this.__wbg_ptr,t,r);if(o[3])throw f(o[2]);var s=J(o[0],o[1]).slice();return i.__wbindgen_free(o[0],o[1]*1,1),s}saveBytes(){let e=i.xlsxdocument_saveBytes(this.__wbg_ptr);if(e[3])throw f(e[2]);var t=J(e[0],e[1]).slice();return i.__wbindgen_free(e[0],e[1]*1,1),t}setActiveSheet(e){let t=i.xlsxdocument_setActiveSheet(this.__wbg_ptr,e);if(t[1])throw f(t[0])}sheetInfoJson(){let e,t;try{let s=i.xlsxdocument_sheetInfoJson(this.__wbg_ptr);var r=s[0],o=s[1];if(s[3])throw r=0,o=0,f(s[2]);return e=r,t=o,u(r,o)}finally{i.__wbindgen_free(e,t,1);}}undoJson(){let e,t;try{let s=i.xlsxdocument_undoJson(this.__wbg_ptr);var r=s[0],o=s[1];if(s[3])throw r=0,o=0,f(s[2]);return e=r,t=o,u(r,o)}finally{i.__wbindgen_free(e,t,1);}}static version(){let e,t;try{let r=i.xlsxdocument_version();return e=r[0],t=r[1],u(r[0],r[1])}finally{i.__wbindgen_free(e,t,1);}}};Symbol.dispose&&(g.prototype[Symbol.dispose]=g.prototype.free);function ie(){return {__proto__:null,"./xlsx_wasm_bg.js":{__proto__:null,__wbg___wbindgen_throw_344f42d3211c4765:function(e,t){throw new Error(u(e,t))},__wbg_now_86c0d4ba3fa605b8:function(){return Date.now()},__wbindgen_cast_0000000000000001:function(e,t){return u(e,t)},__wbindgen_init_externref_table:function(){let e=i.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,true),e.set(t+3,false);}}}}var A=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_xlsxdocument_free(n,1));function J(n,e){return n=n>>>0,w().subarray(n/1,n/1+e)}function u(n,e){return ce(n>>>0,e)}var y=null;function w(){return (y===null||y.byteLength===0)&&(y=new Uint8Array(i.memory.buffer)),y}function le(n,e){let t=e(n.length*1,1)>>>0;return w().set(n,t/1),d=n.length,t}function _(n,e,t){if(t===void 0){let c=h.encode(n),l=e(c.length,1)>>>0;return w().subarray(l,l+c.length).set(c),d=c.length,l}let r=n.length,o=e(r,1)>>>0,s=w(),a=0;for(;a<r;a++){let c=n.charCodeAt(a);if(c>127)break;s[o+a]=c;}if(a!==r){a!==0&&(n=n.slice(a)),o=t(o,r,r=a+n.length*3,1)>>>0;let c=w().subarray(o+a,o+r),l=h.encodeInto(n,c);a+=l.written,o=t(o,r,a,1)>>>0;}return d=a,o}function f(n){let e=i.__wbindgen_externrefs.get(n);return i.__externref_table_dealloc(n),e}var v=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true});v.decode();var ae=2146435072,E=0;function ce(n,e){return E+=e,E>=ae&&(v=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true}),v.decode(),E=e),v.decode(w().subarray(n,n+e))}var h=new TextEncoder;"encodeInto"in h||(h.encodeInto=function(n,e){let t=h.encode(n);return e.set(t),{read:n.length,written:t.length}});var d=0,i;function de(n,e){return i=n.exports,y=null,i.__wbindgen_start(),i}async function _e(n,e){if(typeof Response=="function"&&n instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(n,e)}catch(o){if(n.ok&&t(n.type)&&n.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}let r=await n.arrayBuffer();return await WebAssembly.instantiate(r,e)}else {let r=await WebAssembly.instantiate(n,e);return r instanceof WebAssembly.Instance?{instance:r,module:n}:r}function t(r){switch(r){case "basic":case "cors":case "default":return true}return false}}async function I(n){if(i!==void 0)return i;if(n!==void 0&&(Object.getPrototypeOf(n)===Object.prototype?{module_or_path:n}=n:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),n===void 0)throw new Error("xlsx-wasm requires an explicit module or URL");let e=ie();(typeof n=="string"||typeof Request=="function"&&n instanceof Request||typeof URL=="function"&&n instanceof URL)&&(n=fetch(n));let{instance:t,module:r}=await _e(await n,e);return de(t)}var C=class extends Error{constructor(t){super(`stale: ${t.join(", ")}`);a(this,"cells");this.name="StaleProposalError",this.cells=t;}},T="stale: ";function pe(n){let e=n.slice(T.length).split(",").map(t=>t.trim()).filter(t=>t.length>0);return new C(e)}var P=false,x;function ge(n=new URL("./generated/xlsx_wasm_bg.wasm",import.meta.url)){return P?Promise.resolve():x||(x=I({module_or_path:n}).then(()=>{P=true;},e=>{throw x=void 0,p(e)}),x)}function O(){if(!P)throw new Error("xlsx wasm is not initialized; call initWasm() first")}function p(n){return n instanceof Error?n:new Error(typeof n=="string"?n:String(n))}function be(){return typeof WebAssembly=="object"}function we(){return typeof g.prototype.renderPng=="function"}function ye(){return typeof g.prototype.proposeJson=="function"}function he(n){O();let e;try{e=g.open(n);}catch(t){throw p(t)}return {sheetInfo(){try{return JSON.parse(e.sheetInfoJson())}catch(t){throw p(t)}},calculationStatus(){let t=e.calculationStatusJson;return typeof t!="function"?{limitedCells:[]}:b(()=>t.call(e))},displayList(t){try{return JSON.parse(e.displayListJson(JSON.stringify(t)))}catch(r){throw p(r)}},setActiveSheet(t){try{e.setActiveSheet(t);}catch(r){throw p(r)}},editCell(t,r,o,s){return m(()=>e.editCellJson(JSON.stringify({sheet:t,row:r,col:o,input:s})))},editCells(t,r){return m(()=>e.editCellsJson(JSON.stringify({sheet:t,edits:r})))},applyOps(t){return m(()=>e.applyOpsJson(JSON.stringify({ops:t})))},undo(){return m(()=>e.undoJson())},redo(){return m(()=>e.redoJson())},cell(t,r,o){return b(()=>e.cellJson(JSON.stringify({sheet:t,row:r,col:o})))},rangeCells(t,r){return b(()=>e.rangeCellsJson(JSON.stringify({sheet:t,range:r}))).cells},renderPng(t){let r=e.renderPng;if(typeof r!="function")throw new Error("png export not in this build");try{return r.call(e,JSON.stringify(t))}catch(o){throw p(o)}},renderRangePng(t){let r=e.renderRangePng;if(typeof r!="function")throw new Error("png export not in this build");try{return r.call(e,JSON.stringify(t??{}))}catch(o){throw p(o)}},save(){try{return e.saveBytes()}catch(t){throw p(t)}},propose(t,r,o){let s=e.proposeJson;if(typeof s!="function")throw new Error("proposals not in this build");return b(()=>s.call(e,JSON.stringify({agentId:t,note:r,edits:o})))},listProposals(){let t=e.listProposalsJson;return typeof t!="function"?[]:b(()=>t.call(e)).proposals},acceptProposal(t,r){let o=e.acceptProposalJson;if(typeof o!="function")throw new Error("proposals not in this build");try{return JSON.parse(o.call(e,JSON.stringify({id:t,force:r?.force??!1})))}catch(s){let a=s instanceof Error?s.message:typeof s=="string"?s:String(s);throw a.startsWith(T)?pe(a):p(s)}},rejectProposal(t){let r=e.rejectProposalJson;return typeof r!="function"?false:b(()=>r.call(e,JSON.stringify({id:t}))).removed},isProposalsAvailable(){return typeof e.proposeJson=="function"},dispose(){e.free();}}}function b(n){try{return JSON.parse(n())}catch(e){throw p(e)}}function m(n){return b(n)}function xe(){return O(),g.version()}export{C as StaleProposalError,ge as initWasm,we as isPngExportAvailable,ye as isProposalsAvailable,be as isWasmAvailable,he as openWorkbook,ee as paintDisplayList,xe as wasmVersion};
1
+ export{s as buildA11yGrid,n as cellAtPoint,j as cellCount,o as cellRect,e as clampScroll,k as extendTo,r as fromTsv,l as moveFocus,h as normalizeRange,i as rangeContains,p as rangeRect,g as selectionAt,m as selectionKeyReducer,q as toTsv,b as totalExtent,a as trackCount,f as uniformOffsets,d as visibleCells,c as visibleRange}from'./chunk-2OVPP3IG.js';import {a}from'./chunk-O2XFH626.js';var ye={left:"left",center:"center",right:"right"},we={dashed:[4,2],dotted:[1,2]};function me(o,e,n){o.save(),o.setTransform(n,0,0,n,0,0),o.clearRect(0,0,e.width,e.height);for(let t of e.commands)he(o,t);o.restore();}function he(o,e){switch(e.op){case "fillRect":o.fillStyle=e.color,o.fillRect(e.x,e.y,e.w,e.h);return;case "line":xe(o,e);return;case "text":ve(o,e);return}}function xe(o,e){if(o.strokeStyle=e.color,e.style==="double"){let n=Math.max(e.width*.8,.8),t=Math.abs(e.y1-e.y2)<=Math.abs(e.x1-e.x2),[r,i]=t?[0,n]:[n,0];o.lineWidth=Math.max(e.width*.6,.5),k(o,e.x1-r,e.y1-i,e.x2-r,e.y2-i),k(o,e.x1+r,e.y1+i,e.x2+r,e.y2+i);return}o.lineWidth=e.width,o.save(),o.setLineDash(e.style?we[e.style]:[]),k(o,e.x1,e.y1,e.x2,e.y2),o.restore();}function k(o,e,n,t,r){o.beginPath(),o.moveTo(e,n),o.lineTo(t,r),o.stroke();}function ve(o,e){o.save(),e.clip&&(o.beginPath(),o.rect(e.clip.x,e.clip.y,e.clip.w,e.clip.h),o.clip()),o.fillStyle=e.color,o.font=Se(e),o.textAlign=ye[e.align??"left"],o.textBaseline="alphabetic",e.highlight&&Re(o,e),o.fillStyle=e.color,o.fillText(e.text,e.x,e.y),(e.underline||e.strike||e.dashedUnderline)&&Ce(o,e),o.restore();}function Se(o){let e=o.italic?"italic ":"",n=o.bold?"bold ":"",t=o.fontFamily?`"${o.fontFamily}", sans-serif`:"sans-serif";return `${e}${n}${o.fontSize}px ${t}`}function Ce(o,e){let n=o.measureText(e.text).width,t=e.align??"left",r=t==="right"?e.x-n:t==="center"?e.x-n/2:e.x,i=Math.max(e.fontSize*.05,.5);o.fillStyle=e.color,e.underline&&o.fillRect(r,e.y+e.fontSize*.1,n,i),e.strike&&o.fillRect(r,e.y-e.fontSize*.26,n,i),e.dashedUnderline&&(o.save(),o.strokeStyle=e.color,o.lineWidth=i,o.setLineDash([3,2]),k(o,r,e.y+e.fontSize*.1,r+n,e.y+e.fontSize*.1),o.restore());}function Re(o,e){let n=o.measureText(e.text),t=n.width,r=e.align??"left",i=r==="right"?e.x-t:r==="center"?e.x-t/2:e.x,d=n.actualBoundingBoxAscent||e.fontSize*.8,c=n.actualBoundingBoxDescent||e.fontSize*.2;o.fillStyle=e.highlight,o.fillRect(i-2,e.y-d-1,t+4,d+c+2);}var x=class o{static __wrap(e){let n=Object.create(o.prototype);return n.__wbg_ptr=e,V.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,V.unregister(this),e}free(){let e=this.__destroy_into_raw();s.__wbg_xlsxdocument_free(e,0);}acceptProposalJson(e){let n,t;try{let d=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),c=g,a=s.xlsxdocument_acceptProposalJson(this.__wbg_ptr,d,c);var r=a[0],i=a[1];if(a[3])throw r=0,i=0,_(a[2]);return n=r,t=i,p(r,i)}finally{s.__wbindgen_free(n,t,1);}}applyFormatJson(e){let n,t;try{let d=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),c=g,a=s.xlsxdocument_applyFormatJson(this.__wbg_ptr,d,c);var r=a[0],i=a[1];if(a[3])throw r=0,i=0,_(a[2]);return n=r,t=i,p(r,i)}finally{s.__wbindgen_free(n,t,1);}}applyOpsJson(e){let n,t;try{let d=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),c=g,a=s.xlsxdocument_applyOpsJson(this.__wbg_ptr,d,c);var r=a[0],i=a[1];if(a[3])throw r=0,i=0,_(a[2]);return n=r,t=i,p(r,i)}finally{s.__wbindgen_free(n,t,1);}}applyUpdateJson(e){let n,t;try{let d=I(e,s.__wbindgen_malloc),c=g,a=s.xlsxdocument_applyUpdateJson(this.__wbg_ptr,d,c);var r=a[0],i=a[1];if(a[3])throw r=0,i=0,_(a[2]);return n=r,t=i,p(r,i)}finally{s.__wbindgen_free(n,t,1);}}calculationStatusJson(){let e,n;try{let i=s.xlsxdocument_calculationStatusJson(this.__wbg_ptr);var t=i[0],r=i[1];if(i[3])throw t=0,r=0,_(i[2]);return e=t,n=r,p(t,r)}finally{s.__wbindgen_free(e,n,1);}}captureFormatJson(e){let n,t;try{let d=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),c=g,a=s.xlsxdocument_captureFormatJson(this.__wbg_ptr,d,c);var r=a[0],i=a[1];if(a[3])throw r=0,i=0,_(a[2]);return n=r,t=i,p(r,i)}finally{s.__wbindgen_free(n,t,1);}}cellJson(e){let n,t;try{let d=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),c=g,a=s.xlsxdocument_cellJson(this.__wbg_ptr,d,c);var r=a[0],i=a[1];if(a[3])throw r=0,i=0,_(a[2]);return n=r,t=i,p(r,i)}finally{s.__wbindgen_free(n,t,1);}}clearUpdateObservation(){s.xlsxdocument_clearUpdateObservation(this.__wbg_ptr);}get clientId(){return s.xlsxdocument_clientId(this.__wbg_ptr)}displayListJson(e){let n,t;try{let d=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),c=g,a=s.xlsxdocument_displayListJson(this.__wbg_ptr,d,c);var r=a[0],i=a[1];if(a[3])throw r=0,i=0,_(a[2]);return n=r,t=i,p(r,i)}finally{s.__wbindgen_free(n,t,1);}}drainUpdateEvent(){let e=s.xlsxdocument_drainUpdateEvent(this.__wbg_ptr);if(e[3])throw _(e[2]);var n=h(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*1,1),n}editCellJson(e){let n,t;try{let d=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),c=g,a=s.xlsxdocument_editCellJson(this.__wbg_ptr,d,c);var r=a[0],i=a[1];if(a[3])throw r=0,i=0,_(a[2]);return n=r,t=i,p(r,i)}finally{s.__wbindgen_free(n,t,1);}}editCellsJson(e){let n,t;try{let d=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),c=g,a=s.xlsxdocument_editCellsJson(this.__wbg_ptr,d,c);var r=a[0],i=a[1];if(a[3])throw r=0,i=0,_(a[2]);return n=r,t=i,p(r,i)}finally{s.__wbindgen_free(n,t,1);}}encodeDiff(e){let n=I(e,s.__wbindgen_malloc),t=g,r=s.xlsxdocument_encodeDiff(this.__wbg_ptr,n,t);if(r[3])throw _(r[2]);var i=h(r[0],r[1]).slice();return s.__wbindgen_free(r[0],r[1]*1,1),i}encodeStateAsUpdate(){let e=s.xlsxdocument_encodeStateAsUpdate(this.__wbg_ptr);var n=h(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*1,1),n}encodeStateVector(){let e=s.xlsxdocument_encodeStateVector(this.__wbg_ptr);var n=h(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*1,1),n}historyStateJson(){let e,n;try{let i=s.xlsxdocument_historyStateJson(this.__wbg_ptr);var t=i[0],r=i[1];if(i[3])throw t=0,r=0,_(i[2]);return e=t,n=r,p(t,r)}finally{s.__wbindgen_free(e,n,1);}}listProposalsJson(){let e,n;try{let i=s.xlsxdocument_listProposalsJson(this.__wbg_ptr);var t=i[0],r=i[1];if(i[3])throw t=0,r=0,_(i[2]);return e=t,n=r,p(t,r)}finally{s.__wbindgen_free(e,n,1);}}mergedRangesJson(e){let n,t;try{let d=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),c=g,a=s.xlsxdocument_mergedRangesJson(this.__wbg_ptr,d,c);var r=a[0],i=a[1];if(a[3])throw r=0,i=0,_(a[2]);return n=r,t=i,p(r,i)}finally{s.__wbindgen_free(n,t,1);}}static open(e){let n=I(e,s.__wbindgen_malloc),t=g,r=s.xlsxdocument_open(n,t);if(r[2])throw _(r[1]);return o.__wrap(r[0])}static openCollaborative(e,n){let t=I(e,s.__wbindgen_malloc),r=g,i=s.xlsxdocument_openCollaborative(t,r,n);if(i[2])throw _(i[1]);return o.__wrap(i[0])}patchRangeStyleJson(e){let n,t;try{let d=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),c=g,a=s.xlsxdocument_patchRangeStyleJson(this.__wbg_ptr,d,c);var r=a[0],i=a[1];if(a[3])throw r=0,i=0,_(a[2]);return n=r,t=i,p(r,i)}finally{s.__wbindgen_free(n,t,1);}}proposeJson(e){let n,t;try{let d=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),c=g,a=s.xlsxdocument_proposeJson(this.__wbg_ptr,d,c);var r=a[0],i=a[1];if(a[3])throw r=0,i=0,_(a[2]);return n=r,t=i,p(r,i)}finally{s.__wbindgen_free(n,t,1);}}rangeCellsJson(e){let n,t;try{let d=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),c=g,a=s.xlsxdocument_rangeCellsJson(this.__wbg_ptr,d,c);var r=a[0],i=a[1];if(a[3])throw r=0,i=0,_(a[2]);return n=r,t=i,p(r,i)}finally{s.__wbindgen_free(n,t,1);}}redoJson(){let e,n;try{let i=s.xlsxdocument_redoJson(this.__wbg_ptr);var t=i[0],r=i[1];if(i[3])throw t=0,r=0,_(i[2]);return e=t,n=r,p(t,r)}finally{s.__wbindgen_free(e,n,1);}}rejectProposalJson(e){let n,t;try{let d=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),c=g,a=s.xlsxdocument_rejectProposalJson(this.__wbg_ptr,d,c);var r=a[0],i=a[1];if(a[3])throw r=0,i=0,_(a[2]);return n=r,t=i,p(r,i)}finally{s.__wbindgen_free(n,t,1);}}renderPng(e){let n=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),t=g,r=s.xlsxdocument_renderPng(this.__wbg_ptr,n,t);if(r[3])throw _(r[2]);var i=h(r[0],r[1]).slice();return s.__wbindgen_free(r[0],r[1]*1,1),i}renderRangePng(e){let n=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),t=g,r=s.xlsxdocument_renderRangePng(this.__wbg_ptr,n,t);if(r[3])throw _(r[2]);var i=h(r[0],r[1]).slice();return s.__wbindgen_free(r[0],r[1]*1,1),i}saveBytes(){let e=s.xlsxdocument_saveBytes(this.__wbg_ptr);if(e[3])throw _(e[2]);var n=h(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*1,1),n}selectionFormattingJson(e){let n,t;try{let d=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),c=g,a=s.xlsxdocument_selectionFormattingJson(this.__wbg_ptr,d,c);var r=a[0],i=a[1];if(a[3])throw r=0,i=0,_(a[2]);return n=r,t=i,p(r,i)}finally{s.__wbindgen_free(n,t,1);}}setActiveSheet(e){let n=s.xlsxdocument_setActiveSheet(this.__wbg_ptr,e);if(n[1])throw _(n[0])}setRangeNumberFormatJson(e){let n,t;try{let d=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),c=g,a=s.xlsxdocument_setRangeNumberFormatJson(this.__wbg_ptr,d,c);var r=a[0],i=a[1];if(a[3])throw r=0,i=0,_(a[2]);return n=r,t=i,p(r,i)}finally{s.__wbindgen_free(n,t,1);}}sheetInfoJson(){let e,n;try{let i=s.xlsxdocument_sheetInfoJson(this.__wbg_ptr);var t=i[0],r=i[1];if(i[3])throw t=0,r=0,_(i[2]);return e=t,n=r,p(t,r)}finally{s.__wbindgen_free(e,n,1);}}startUpdateObservation(){let e=s.xlsxdocument_startUpdateObservation(this.__wbg_ptr);if(e[1])throw _(e[0])}undoJson(){let e,n;try{let i=s.xlsxdocument_undoJson(this.__wbg_ptr);var t=i[0],r=i[1];if(i[3])throw t=0,r=0,_(i[2]);return e=t,n=r,p(t,r)}finally{s.__wbindgen_free(e,n,1);}}static version(){let e,n;try{let t=s.xlsxdocument_version();return e=t[0],n=t[1],p(t[0],t[1])}finally{s.__wbindgen_free(e,n,1);}}};Symbol.dispose&&(x.prototype[Symbol.dispose]=x.prototype.free);function Je(){return {__proto__:null,"./xlsx_wasm_bg.js":{__proto__:null,__wbg___wbindgen_string_get_b0ca35b86a603356:function(e,n){let t=n,r=typeof t=="string"?t:void 0;var i=Ee(r)?0:b(r,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g;B().setInt32(e+4,d,true),B().setInt32(e+0,i,true);},__wbg___wbindgen_throw_344f42d3211c4765:function(e,n){throw new Error(p(e,n))},__wbg_getRandomValues_3f44b700395062e5:function(){return N(function(e,n){globalThis.crypto.getRandomValues(h(e,n));},arguments)},__wbg_get_78f252d074a84d0b:function(){return N(function(e,n){return Reflect.get(e,n)},arguments)},__wbg_get_unchecked_6e0ad6d2a41b06f6:function(e,n){return e[n>>>0]},__wbg_instanceof_Object_33f20e6f12439f3e:function(e){let n;try{n=e instanceof Object;}catch{n=false;}return n},__wbg_keys_58421f8f96795607:function(e){return Object.keys(e)},__wbg_length_1f0964f4a5e2c6d8:function(e){return e.length},__wbg_length_370319915dc99107:function(e){return e.length},__wbg_new_cd45aabdf6073e84:function(e){return new Uint8Array(e)},__wbg_new_da52cf8fe3429cb2:function(){return new Object},__wbg_new_from_slice_77cdfb7977362f3c:function(e,n){return new Uint8Array(h(e,n))},__wbg_now_86c0d4ba3fa605b8:function(){return Date.now()},__wbg_prototypesetcall_4770620bbe4688a0:function(e,n,t){Uint8Array.prototype.set.call(h(e,n),t);},__wbg_set_8535240470bf2500:function(){return N(function(e,n,t){return Reflect.set(e,n,t)},arguments)},__wbindgen_cast_0000000000000001:function(e,n){return p(e,n)},__wbindgen_init_externref_table:function(){let e=s.__wbindgen_externrefs,n=e.grow(4);e.set(0,void 0),e.set(n+0,void 0),e.set(n+1,null),e.set(n+2,true),e.set(n+3,false);}}}}var V=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(o=>s.__wbg_xlsxdocument_free(o,1));function Ae(o){let e=s.__externref_table_alloc();return s.__wbindgen_externrefs.set(e,o),e}function h(o,e){return o=o>>>0,R().subarray(o/1,o/1+e)}var S=null;function B(){return (S===null||S.buffer.detached===true||S.buffer.detached===void 0&&S.buffer!==s.memory.buffer)&&(S=new DataView(s.memory.buffer)),S}function p(o,e){return Ue(o>>>0,e)}var J=null;function R(){return (J===null||J.byteLength===0)&&(J=new Uint8Array(s.memory.buffer)),J}function N(o,e){try{return o.apply(this,e)}catch(n){let t=Ae(n);s.__wbindgen_exn_store(t);}}function Ee(o){return o==null}function I(o,e){let n=e(o.length*1,1)>>>0;return R().set(o,n/1),g=o.length,n}function b(o,e,n){if(n===void 0){let c=A.encode(o),a=e(c.length,1)>>>0;return R().subarray(a,a+c.length).set(c),g=c.length,a}let t=o.length,r=e(t,1)>>>0,i=R(),d=0;for(;d<t;d++){let c=o.charCodeAt(d);if(c>127)break;i[r+d]=c;}if(d!==t){d!==0&&(o=o.slice(d)),r=n(r,t,t=d+o.length*3,1)>>>0;let c=R().subarray(r+d,r+t),a=A.encodeInto(o,c);d+=a.written,r=n(r,t,d,1)>>>0;}return g=d,r}function _(o){let e=s.__wbindgen_externrefs.get(o);return s.__externref_table_dealloc(o),e}var T=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true});T.decode();var Pe=2146435072,D=0;function Ue(o,e){return D+=e,D>=Pe&&(T=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true}),T.decode(),D=e),T.decode(R().subarray(o,o+e))}var A=new TextEncoder;"encodeInto"in A||(A.encodeInto=function(o,e){let n=A.encode(o);return e.set(n),{read:o.length,written:n.length}});var g=0,s;function Ie(o,e){return s=o.exports,S=null,J=null,s.__wbindgen_start(),s}async function Te(o,e){if(typeof Response=="function"&&o instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(o,e)}catch(r){if(o.ok&&n(o.type)&&o.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",r);else throw r}let t=await o.arrayBuffer();return await WebAssembly.instantiate(t,e)}else {let t=await WebAssembly.instantiate(o,e);return t instanceof WebAssembly.Instance?{instance:t,module:o}:t}function n(t){switch(t){case "basic":case "cors":case "default":return true}return false}}async function j(o){if(s!==void 0)return s;if(o!==void 0&&(Object.getPrototypeOf(o)===Object.prototype?{module_or_path:o}=o:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),o===void 0)throw new Error("xlsx-wasm requires an explicit module or URL");let e=Je();(typeof o=="string"||typeof Request=="function"&&o instanceof Request||typeof URL=="function"&&o instanceof URL)&&(o=fetch(o));let{instance:n,module:t}=await Te(await o,e);return Ie(n)}var F=class extends Error{constructor(n){super(`stale: ${n.join(", ")}`);a(this,"cells");this.name="StaleProposalError",this.cells=n;}},H="stale: ";function Fe(o){let e=o.slice(H.length).split(",").map(n=>n.trim()).filter(n=>n.length>0);return new F(e)}var z=false,E;function We(o=new URL("./generated/xlsx_wasm_bg.wasm",import.meta.url)){return z?Promise.resolve():E||(E=j({module_or_path:o}).then(()=>{z=true;},e=>{throw E=void 0,P(e)}),E)}function $(){if(!z)throw new Error("xlsx wasm is not initialized; call initWasm() first")}function P(o){return o instanceof Error?o:new Error(typeof o=="string"?o:String(o))}function Ne(){return typeof WebAssembly=="object"}function De(){return typeof x.prototype.renderPng=="function"}function ze(){return typeof x.prototype.proposeJson=="function"}function Le(o,e={}){$();let n=Me(e),t;try{t=n===void 0?x.open(o):x.openCollaborative(o,n);}catch(l){throw P(l)}let r=new Map,i=[],d=0,c=false,a=false,U=0,W=false;function L(){if(c)throw new Error("workbook handle is disposed")}function q(){if(!(c||W||U!==0)){W=true;try{for(;!c&&i.length>0;){let l=i.shift();if(!l)break;for(let[u,f]of [...r]){if(c)return;if(r.get(u)===f)try{f(l.update.slice(),l.origin);}catch{}}}}finally{W=false,c&&(i.length=0);}}}function G(){if(!(!a||c))for(;;){let l=t.drainUpdateEvent();if(l.byteLength===0)return;let u=l[0];if(u!==0&&u!==1)throw new Error(`xlsx wasm returned unknown update origin ${u}`);i.push({update:l.slice(1),origin:u===0?"local":"remote"});}}function m(l,u=false){L(),U+=1;try{let f,w,C=!1;try{f=l();}catch(v){w=v,C=!0;}if(u)try{G();}catch(v){C||(w=v,C=!0);}if(C)throw P(w);return f}finally{U-=1,U===0&&q();}}function O(l){return m(l,true)}function y(l,u=false){return m(()=>JSON.parse(l()),u)}function X(){a||(m(()=>t.startUpdateObservation()),a=true);}function K(){!a||r.size>0||c||(i.length=0,m(()=>t.clearUpdateObservation()),a=false);}return {get clientId(){return m(()=>t.clientId)},encodeStateVector(){return m(()=>t.encodeStateVector().slice())},encodeStateAsUpdate(l){return m(()=>l===void 0?t.encodeStateAsUpdate().slice():t.encodeDiff(l.slice()).slice())},applyUpdate(l){return y(()=>t.applyUpdateJson(l.slice()),true)},onUpdate(l){if(L(),typeof l!="function")throw new TypeError("update listener must be a function");let u=d++;r.set(u,l);try{X();}catch(w){throw r.delete(u),w}let f=true;return ()=>{f&&(f=false,r.delete(u),K());}},sheetInfo(){return y(()=>t.sheetInfoJson())},calculationStatus(){return m(()=>{let l=t.calculationStatusJson;return typeof l!="function"?{limitedCells:[]}:JSON.parse(l.call(t))})},displayList(l){return y(()=>t.displayListJson(JSON.stringify(l)))},setActiveSheet(l){O(()=>t.setActiveSheet(l));},editCell(l,u,f,w){return y(()=>t.editCellJson(JSON.stringify({sheet:l,row:u,col:f,input:w})),true)},editCells(l,u){return y(()=>t.editCellsJson(JSON.stringify({sheet:l,edits:u})),true)},applyOps(l){return y(()=>t.applyOpsJson(JSON.stringify({ops:l})),true)},undo(){return y(()=>t.undoJson(),true)},redo(){return y(()=>t.redoJson(),true)},cell(l,u,f){return y(()=>t.cellJson(JSON.stringify({sheet:l,row:u,col:f})))},rangeCells(l,u){return y(()=>t.rangeCellsJson(JSON.stringify({sheet:l,range:u}))).cells},patchRangeStyle(l,u,f){return y(()=>t.patchRangeStyleJson(JSON.stringify({sheet:l,range:u,patch:f})),true)},setNumberFormat(l,u,f){let w=typeof f=="string"?{type:f}:f;return y(()=>t.setRangeNumberFormatJson(JSON.stringify({sheet:l,range:u,format:w})),true)},selectionFormatting(l,u){return y(()=>t.selectionFormattingJson(JSON.stringify({sheet:l,range:u})))},captureFormat(l,u){return y(()=>t.captureFormatJson(JSON.stringify({sheet:l,range:u})))},applyFormat(l,u,f){return y(()=>t.applyFormatJson(JSON.stringify({sheet:l,range:u,format:f})),true)},mergedRanges(l,u){return y(()=>t.mergedRangesJson(JSON.stringify({sheet:l,range:u}))).ranges},historyState(){return y(()=>t.historyStateJson())},renderPng(l){return m(()=>{let u=t.renderPng;if(typeof u!="function")throw new Error("png export not in this build");return u.call(t,JSON.stringify(l)).slice()})},renderRangePng(l){return m(()=>{let u=t.renderRangePng;if(typeof u!="function")throw new Error("png export not in this build");return u.call(t,JSON.stringify(l??{})).slice()})},save(){return m(()=>t.saveBytes().slice())},propose(l,u,f){return O(()=>{let w=t.proposeJson;if(typeof w!="function")throw new Error("proposals not in this build");let C=f.map(({numberFormat:v,...Y})=>({...Y,...v===void 0?{}:{numberFormat:typeof v=="string"?{type:v}:v}}));return JSON.parse(w.call(t,JSON.stringify({agentId:l,note:u,edits:C})))})},listProposals(){return m(()=>{let l=t.listProposalsJson;return typeof l!="function"?[]:JSON.parse(l.call(t)).proposals})},acceptProposal(l,u){try{return O(()=>{let f=t.acceptProposalJson;if(typeof f!="function")throw new Error("proposals not in this build");return JSON.parse(f.call(t,JSON.stringify({id:l,force:u?.force??!1})))})}catch(f){let w=f instanceof Error?f.message:typeof f=="string"?f:String(f);throw w.startsWith(H)?Fe(w):P(f)}},rejectProposal(l){return O(()=>{let u=t.rejectProposalJson;return typeof u!="function"?false:JSON.parse(u.call(t,JSON.stringify({id:l}))).removed})},isProposalsAvailable(){return m(()=>typeof t.proposeJson=="function")},dispose(){if(c)return;c=true,r.clear(),i.length=0;let l;if(a){try{t.clearUpdateObservation();}catch(u){l=u;}a=false;}try{t.free();}catch(u){l??(l=u);}if(l!==void 0)throw P(l)}}}function Me(o){if(!o.collaborative){if(o.clientId!==void 0)throw new TypeError("clientId requires collaborative mode");return}if(o.clientId!==void 0){if(!Number.isSafeInteger(o.clientId)||o.clientId<=0||o.clientId>Number.MAX_SAFE_INTEGER)throw new RangeError("clientId must be a nonzero safe integer");return o.clientId}let e=globalThis.crypto;if(!e||typeof e.getRandomValues!="function")throw new Error("crypto.getRandomValues is required to generate a collaboration client ID");let n=new Uint32Array(2),t;do e.getRandomValues(n),t=(n[0]&2097151)*4294967296+n[1];while(t===0);return t}function Ve(){return $(),x.version()}export{F as StaleProposalError,We as initWasm,De as isPngExportAvailable,ze as isProposalsAvailable,Ne as isWasmAvailable,Le as openWorkbook,me as paintDisplayList,Ve as wasmVersion};
@@ -0,0 +1,50 @@
1
+ type CollaborationUpdateOrigin = 'local' | 'remote';
2
+ interface CollaborationReplica {
3
+ readonly clientId: number;
4
+ encodeStateVector(): Uint8Array;
5
+ encodeStateAsUpdate(remoteStateVector?: Uint8Array): Uint8Array;
6
+ applyUpdate(update: Uint8Array): unknown;
7
+ onUpdate(listener: (update: Uint8Array, origin: CollaborationUpdateOrigin) => void): () => void;
8
+ }
9
+ type CollaborationTransportEvent = {
10
+ type: 'open';
11
+ } | {
12
+ type: 'message';
13
+ data: Uint8Array;
14
+ } | {
15
+ type: 'close';
16
+ reason?: string;
17
+ } | {
18
+ type: 'error';
19
+ error: unknown;
20
+ } | {
21
+ type: 'drain';
22
+ };
23
+ interface CollaborationTransport {
24
+ /** Starts one attempt; after close, reopen internally or require another provider.connect(). */
25
+ connect(): void | Promise<void>;
26
+ disconnect(): void | Promise<void>;
27
+ /** Returns true only when the owned frame was accepted; false requires a later drain event. */
28
+ send(data: Uint8Array): boolean;
29
+ onEvent(listener: (event: CollaborationTransportEvent) => void): () => void;
30
+ }
31
+ type CollaborationStatus = 'disconnected' | 'connecting' | 'connected' | 'destroyed';
32
+ interface CollaborationStatusChange {
33
+ status: CollaborationStatus;
34
+ synced: boolean;
35
+ }
36
+ type CollaborationErrorCode = 'backpressure' | 'protocol' | 'replica' | 'transport';
37
+ declare class CollaborationError extends Error {
38
+ readonly code: CollaborationErrorCode;
39
+ readonly cause: unknown;
40
+ constructor(code: CollaborationErrorCode, message: string, cause?: unknown);
41
+ }
42
+ interface CollaborationProviderOptions {
43
+ maxFrameBytes?: number;
44
+ maxMessagesPerFrame?: number;
45
+ maxPendingBytes?: number;
46
+ }
47
+ type CollaborationStatusListener = (change: CollaborationStatusChange) => void;
48
+ type CollaborationErrorListener = (error: CollaborationError) => void;
49
+
50
+ export { type CollaborationReplica as C, type CollaborationTransport as a, type CollaborationProviderOptions as b, type CollaborationStatus as c, type CollaborationStatusListener as d, type CollaborationErrorListener as e, CollaborationError as f, type CollaborationErrorCode as g, type CollaborationStatusChange as h, type CollaborationTransportEvent as i, type CollaborationUpdateOrigin as j };
package/package.json CHANGED
@@ -1,7 +1,20 @@
1
1
  {
2
2
  "name": "@betteroffice/xlsx",
3
- "version": "0.0.5",
4
- "description": "Framework-free core for the BetterOffice xlsx editor: display list, viewport math, wasm loader.",
3
+ "version": "0.0.7",
4
+ "description": "Excel-faithful XLSX spreadsheet editor and viewer core — full OOXML fidelity, real-time human + AI agent collaboration. Framework-free (Rust/Wasm).",
5
+ "keywords": [
6
+ "xlsx",
7
+ "excel",
8
+ "spreadsheet",
9
+ "ooxml",
10
+ "office",
11
+ "editor",
12
+ "viewer",
13
+ "collaborative",
14
+ "real-time",
15
+ "ai-agent",
16
+ "wasm"
17
+ ],
5
18
  "type": "module",
6
19
  "sideEffects": false,
7
20
  "main": "./dist/index.js",
@@ -15,6 +28,10 @@
15
28
  "./headless": {
16
29
  "types": "./dist/headless.d.ts",
17
30
  "import": "./dist/headless.js"
31
+ },
32
+ "./collaboration": {
33
+ "types": "./dist/collaboration.d.ts",
34
+ "import": "./dist/collaboration.js"
18
35
  }
19
36
  },
20
37
  "files": [
@@ -22,7 +39,7 @@
22
39
  ],
23
40
  "scripts": {
24
41
  "build": "bun run build:wasm && tsup",
25
- "build:wasm": "node ../../scripts/build-xlsx-wasm.mjs",
42
+ "build:wasm": "bun ../../scripts/build-xlsx-wasm.ts",
26
43
  "typecheck": "tsc --noEmit -p ."
27
44
  },
28
45
  "devDependencies": {
@@ -1,4 +0,0 @@
1
- var V=Object.defineProperty;var z=(t,e,n)=>e in t?V(t,e,{enumerable:true,configurable:true,writable:true,value:n}):t[e]=n;var rt=(t,e,n)=>z(t,typeof e!="symbol"?e+"":e,n);function L(t){return Math.max(0,t.length-1)}function D(t){return t.length>0?t[t.length-1]:0}function x(t,e,n){return Math.max(e,Math.min(n,t))}function E(t,e,n,o){let r=n,l=o;for(;r<l;){let c=r+l+1>>1;t[c]<=e?r=c:l=c-1;}return r}function M(t,e,n,o){let r=L(t);if(r===0)return {first:0,last:-1};let l=x(Math.trunc(e),0,r);if(l>=r)return {first:0,last:-1};let c=t[l]-t[0],i=t[l]+Math.max(0,n),s=Math.max(0,o-c),p=i+s,m=E(t,i,l,r-1);if(t[m+1]<=i||s===0)return {first:0,last:-1};let C=E(t,p,m,r-1);return {first:m,last:C}}function H(t,e,n){return {cols:M(e,t.frozenCols,t.scrollX,t.width),rows:M(n,t.frozenRows,t.scrollY,t.height)}}function T(t,e,n){let o=L(t),r=x(Math.trunc(e),0,o),l=D(t)-t[r],c=Math.max(0,n-(t[r]-t[0]));return Math.max(0,l-c)}function _(t,e,n){let o=x(t.scrollX,0,T(e,t.frozenCols,t.width)),r=x(t.scrollY,0,T(n,t.frozenRows,t.height));return o===t.scrollX&&r===t.scrollY?t:{...t,scrollX:o,scrollY:r}}function $(t,e){let n=new Array(t+1);for(let o=0;o<=t;o++)n[o]=o*e;return n}function S(t,e,n){return Math.max(e,Math.min(n,t))}function u(t){return {anchor:{...t},focus:{...t}}}function y(t){return {top:Math.min(t.anchor.row,t.focus.row),bottom:Math.max(t.anchor.row,t.focus.row),left:Math.min(t.anchor.col,t.focus.col),right:Math.max(t.anchor.col,t.focus.col)}}function k(t,e){let n=y(t);return e.row>=n.top&&e.row<=n.bottom&&e.col>=n.left&&e.col<=n.right}function B(t){let e=y(t);return (e.bottom-e.top+1)*(e.right-e.left+1)}function A(t,e,n){let o=n?{row:S(e.row,0,n.rows-1),col:S(e.col,0,n.cols-1)}:{...e};return {anchor:{...t.anchor},focus:o}}function X(t,e){switch(t){case "up":return {row:-e,col:0};case "down":return {row:e,col:0};case "left":return {row:0,col:-e};case "right":return {row:0,col:e}}}function b(t,e,n){let{limits:o}=n,r=n.step??1,l=X(e,r),c={row:S(t.focus.row+l.row,0,o.rows-1),col:S(t.focus.col+l.col,0,o.cols-1)};return n.extend?A(t,c):u(c)}var Y={ArrowUp:"up",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right"};function g(t){return !!(t.metaKey||t.ctrlKey)}function W(t,e,n){switch(e){case "up":return {row:0,col:t.col};case "down":return {row:n.rows-1,col:t.col};case "left":return {row:t.row,col:0};case "right":return {row:t.row,col:n.cols-1}}}function a(t){return {type:"move",selection:t}}function j(t,e,n){let{row:o,col:r}=t.focus;return !e&&r>=n.cols-1?u({row:Math.min(o+1,n.rows-1),col:0}):e&&r<=0?u({row:Math.max(o-1,0),col:n.cols-1}):u({row:o,col:r+(e?-1:1)})}function U(t){return t.key.length===1&&!t.ctrlKey&&!t.metaKey&&!t.altKey}function q(t,e,n){let o=Y[e.key];if(o){if(g(e)){let r=W(t.focus,o,n);return a(e.shiftKey?A(t,r,n):u(r))}return a(b(t,o,{extend:e.shiftKey,limits:n}))}switch(e.key){case "Tab":return a(j(t,!!e.shiftKey,n));case "Enter":return a(b(t,e.shiftKey?"up":"down",{extend:false,limits:n}));case "Home":return a(g(e)?u({row:0,col:0}):u({row:t.focus.row,col:0}));case "End":return a(g(e)?u({row:n.rows-1,col:n.cols-1}):u({row:t.focus.row,col:n.cols-1}));case "PageDown":return a(b(t,"down",{extend:e.shiftKey,step:n.rowsPerPage,limits:n}));case "PageUp":return a(b(t,"up",{extend:e.shiftKey,step:n.rowsPerPage,limits:n}));case "F2":return {type:"startEdit"};case "Delete":case "Backspace":return {type:"clear"}}return (e.key==="a"||e.key==="A")&&g(e)?a({anchor:{row:0,col:0},focus:{row:n.rows-1,col:n.cols-1}}):U(e)?{type:"startEdit",initialInput:e.key}:{type:"none"}}function I(t,e){let n=t.length-1;if(n<=0||e<t[0]||e>=t[n])return -1;let o=0,r=n-1;for(;o<r;){let l=o+r+1>>1;t[l]<=e?o=l:r=l-1;}return o}function bt(t,e,n){if(!t)return null;let o=I(t.colOffsets,e),r=I(t.rowOffsets,n);return o<0||r<0?null:{row:t.startRow+r,col:t.startCol+o}}function K(t,e,n){let o=n-t;return o>=0&&o<e.length-1?o:-1}function ht(t,e,n){if(!t)return null;let o=K(t.startCol,t.colOffsets,n),r=K(t.startRow,t.rowOffsets,e);return o<0||r<0?null:{x:t.colOffsets[o],y:t.rowOffsets[r],w:t.colOffsets[o+1]-t.colOffsets[o],h:t.rowOffsets[r+1]-t.rowOffsets[r]}}function R(t,e,n){return Math.max(0,Math.min(e-1,n-t))}function dt(t,e){if(!t)return null;let n=t.colOffsets.length-1,o=t.rowOffsets.length-1;if(n<=0||o<=0)return null;let r=t.startCol+n-1,l=t.startRow+o-1;if(e.right<t.startCol||e.left>r||e.bottom<t.startRow||e.top>l)return null;let c=R(t.startCol,n,e.left),i=R(t.startCol,n,e.right),s=R(t.startRow,o,e.top),p=R(t.startRow,o,e.bottom);return {x:t.colOffsets[c],y:t.rowOffsets[s],w:t.colOffsets[i+1]-t.colOffsets[c],h:t.rowOffsets[p+1]-t.rowOffsets[s]}}var J=new Set(["=","+","-","@"]);function N(t){let e=t.charCodeAt(0);return J.has(t[0])||e===9||e===13||e===10}function Q(t){return /[\t\n\r"]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function Z(t){let e=!t.isFormula&&t.input.length>0&&N(t.input);return Q(e?`'${t.input}`:t.input)}function Ct(t){return t.map(e=>e.map(Z).join(" ")).join(`\r
2
- `)}function xt(t){let e=[],n=[],o="",r=false,l=0,c=()=>{n.push(o),o="";},i=()=>{c(),e.push(n),n=[];};for(;l<t.length;){let s=t[l];if(r){if(s==='"'){if(t[l+1]==='"'){o+='"',l+=2;continue}r=false,l+=1;continue}o+=s,l+=1;continue}if(s==='"'){r=true,l+=1;continue}if(s===" "){c(),l+=1;continue}if(s==="\r"){i(),t[l+1]===`
3
- `&&(l+=1),l+=1;continue}if(s===`
4
- `){i(),l+=1;continue}o+=s,l+=1;}return (o.length>0||n.length>0)&&i(),e}function v(t){let e=t,n="";do n=String.fromCharCode(65+e%26)+n,e=Math.floor(e/26)-1;while(e>=0);return n}function tt(t,e){return `${v(e)}${t+1}`}function O(t,e){return t.replace(/\{(\w+)\}/g,(n,o)=>String(e[o]??""))}function P(t,e){return `${Math.round(t*1e3)},${Math.round(e*1e3)}`}function et(t){let e=new Map;for(let n of t.commands)n.op==="text"&&n.clip&&e.set(P(n.clip.x,n.clip.y),n.text);return e}function nt(t,e,n){return t?e>=t.top&&e<=t.bottom&&n>=t.left&&n<=t.right:false}function ot(t,e,n,o,r,l){let c=t.startRow+e,i=t.startCol+n,s=tt(c,i),m=o.length===0?r?l.emptyCellLabelSelected:l.emptyCellLabel:r?l.cellLabelSelected:l.cellLabel;return {row:c,col:i,address:s,text:o,selected:r,label:O(m,{address:s,value:o})}}function gt(t,e,n,o){let r=t.grid,l=O(o.gridLabel,{sheet:n});if(!r)return {label:l,sheetName:n,columnHeaders:[],rows:[]};let c=r.colOffsets.length-1,i=r.rowOffsets.length-1,s=e?y(e):null,p=et(t),m=[];for(let f=0;f<c;f++){let w=r.startCol+f,h=v(w);m.push({col:w,text:h,label:O(o.columnHeaderLabel,{column:h})});}let C=[];for(let f=0;f<i;f++){let w=r.startRow+f,h=[];for(let d=0;d<c;d++){let F=P(r.colOffsets[d],r.rowOffsets[f]),G=p.get(F)??"";h.push(ot(r,f,d,G,nt(s,w,r.startCol+d),o));}C.push({row:w,header:O(o.rowHeaderLabel,{row:w+1}),cells:h});}return {label:l,sheetName:n,columnHeaders:m,rows:C}}export{rt as a,L as b,D as c,M as d,H as e,_ as f,$ as g,u as h,y as i,k as j,B as k,A as l,b as m,q as n,bt as o,ht as p,dt as q,Ct as r,xt as s,gt as t};