@betteroffice/xlsx 0.0.8 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/chunk-E6PJOEEH.js +4 -0
- package/dist/generated/xlsx_wasm_bg.wasm +0 -0
- package/dist/headless.d.ts +91 -7
- package/dist/headless.js +1 -1
- package/dist/index.d.ts +21 -3
- package/dist/index.js +1 -1
- package/package.json +11 -2
- package/dist/chunk-4LMGHPXC.js +0 -4
package/README.md
CHANGED
|
@@ -112,7 +112,8 @@ they have stable axis identities and a Yrs-aware undo manager.
|
|
|
112
112
|
## Development
|
|
113
113
|
|
|
114
114
|
The generated `.wasm` binary is intentionally not committed. From the repository
|
|
115
|
-
root, install `wasm-pack` 0.15.0 and
|
|
116
|
-
tests, demo startup, and CI run this
|
|
115
|
+
root, install `wasm-pack` 0.15.0 and `binaryen`, then run
|
|
116
|
+
`bun run build:xlsx-wasm`. Package builds, tests, demo startup, and CI run this
|
|
117
|
+
step automatically.
|
|
117
118
|
|
|
118
119
|
Docs: https://betteroffice.dev · Apache-2.0.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
function I(e){return Math.max(0,e.length-1)}function E(e){return e.length>0?e[e.length-1]:0}function C(e,t,n){return Math.max(t,Math.min(n,e))}function T(e,t,n,r){let o=n,l=r;for(;o<l;){let c=o+l+1>>1;e[c]<=t?o=c:l=c-1;}return o}function M(e,t,n,r){let o=I(e);if(o===0)return {first:0,last:-1};let l=C(Math.trunc(t),0,o);if(l>=o)return {first:0,last:-1};let c=e[l]-e[0],i=e[l]+Math.max(0,n),s=Math.max(0,r-c),f=i+s,a=T(e,i,l,o-1);if(e[a+1]<=i||s===0)return {first:0,last:-1};let x=T(e,f,a,o-1);return {first:a,last:x}}function z(e,t,n){return {cols:M(t,e.frozenCols,e.scrollX,e.width),rows:M(n,e.frozenRows,e.scrollY,e.height)}}function D(e,t,n){let r=I(e),o=C(Math.trunc(t),0,r),l=E(e)-e[o],c=Math.max(0,n-(e[o]-e[0]));return Math.max(0,l-c)}function _(e,t,n){let r=C(e.scrollX,0,D(t,e.frozenCols,e.width)),o=C(e.scrollY,0,D(n,e.frozenRows,e.height));return r===e.scrollX&&o===e.scrollY?e:{...e,scrollX:r,scrollY:o}}function $(e,t){let n=new Array(e+1);for(let r=0;r<=e;r++)n[r]=r*t;return n}function A(e,t,n){return Math.max(t,Math.min(n,e))}function p(e){return {anchor:{...e},focus:{...e}}}function y(e){return {top:Math.min(e.anchor.row,e.focus.row),bottom:Math.max(e.anchor.row,e.focus.row),left:Math.min(e.anchor.col,e.focus.col),right:Math.max(e.anchor.col,e.focus.col)}}function N(e,t){let n=y(e);return t.row>=n.top&&t.row<=n.bottom&&t.col>=n.left&&t.col<=n.right}function U(e){let t=y(e);return (t.bottom-t.top+1)*(t.right-t.left+1)}function S(e,t,n){let r=n?{row:A(t.row,0,n.rows-1),col:A(t.col,0,n.cols-1)}:{...t};return {anchor:{...e.anchor},focus:r}}function W(e,t){switch(e){case "up":return {row:-t,col:0};case "down":return {row:t,col:0};case "left":return {row:0,col:-t};case "right":return {row:0,col:t}}}function w(e,t,n){let{limits:r}=n,o=n.step??1,l=W(t,o),c={row:A(e.focus.row+l.row,0,r.rows-1),col:A(e.focus.col+l.col,0,r.cols-1)};return n.extend?S(e,c):p(c)}var B={ArrowUp:"up",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right"};function R(e){return !!(e.metaKey||e.ctrlKey)}function X(e,t,n){switch(t){case "up":return {row:0,col:e.col};case "down":return {row:n.rows-1,col:e.col};case "left":return {row:e.row,col:0};case "right":return {row:e.row,col:n.cols-1}}}function m(e){return {type:"move",selection:e}}function Y(e,t,n){let{row:r,col:o}=e.focus;return !t&&o>=n.cols-1?p({row:Math.min(r+1,n.rows-1),col:0}):t&&o<=0?p({row:Math.max(r-1,0),col:n.cols-1}):p({row:r,col:o+(t?-1:1)})}function j(e){return e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey}function q(e,t,n){let r=B[t.key];if(r){if(R(t)){let o=X(e.focus,r,n);return m(t.shiftKey?S(e,o,n):p(o))}return m(w(e,r,{extend:t.shiftKey,limits:n}))}switch(t.key){case "Tab":return m(Y(e,!!t.shiftKey,n));case "Enter":return m(w(e,t.shiftKey?"up":"down",{extend:false,limits:n}));case "Home":return m(R(t)?p({row:0,col:0}):p({row:e.focus.row,col:0}));case "End":return m(R(t)?p({row:n.rows-1,col:n.cols-1}):p({row:e.focus.row,col:n.cols-1}));case "PageDown":return m(w(e,"down",{extend:t.shiftKey,step:n.rowsPerPage,limits:n}));case "PageUp":return m(w(e,"up",{extend:t.shiftKey,step:n.rowsPerPage,limits:n}));case "F2":return {type:"startEdit"};case "Delete":case "Backspace":return {type:"clear"}}return (t.key==="a"||t.key==="A")&&R(t)?m({anchor:{row:0,col:0},focus:{row:n.rows-1,col:n.cols-1}}):j(t)?{type:"startEdit",initialInput:t.key}:{type:"none"}}function we(e,t,n){if(!e)return null;let r=Math.fround(t),o=Math.fround(n);if(!Number.isFinite(r)||!Number.isFinite(o))return null;for(let l=e.length-1;l>=0;l--){let c=e[l].clip,i=Math.fround(c.x),s=Math.fround(c.y),f=Math.fround(i+Math.fround(c.w)),a=Math.fround(s+Math.fround(c.h));if(r>=i&&r<f&&o>=s&&o<a)return e[l]}return null}function v(e,t){let n=e.length-1;if(n<=0||t<e[0]||t>=e[n])return -1;let r=0,o=n-1;for(;r<o;){let l=r+o+1>>1;e[l]<=t?r=l:o=l-1;}return r}function de(e,t,n){if(!e)return null;let r=v(e.colOffsets,t),o=v(e.rowOffsets,n);return r<0||o<0?null:{row:e.rowIndices?.[o]??e.startRow+o,col:e.colIndices?.[r]??e.startCol+r}}function K(e,t,n,r){if(t){let l=0,c=t.length-1;for(;l<=c;){let i=l+c>>1,s=t[i];if(s===r)return i;s<r?l=i+1:c=i-1;}return -1}let o=r-e;return o>=0&&o<n.length-1?o:-1}function be(e,t,n){if(!e)return null;let r=K(e.startCol,e.colIndices,e.colOffsets,n),o=K(e.startRow,e.rowIndices,e.rowOffsets,t);return r<0||o<0?null:{x:e.colOffsets[r],y:e.rowOffsets[o],w:e.colOffsets[r+1]-e.colOffsets[r],h:e.rowOffsets[o+1]-e.rowOffsets[o]}}function J(e,t,n){return t?.[n]??e+n}function H(e,t,n,r,o){let l=-1,c=-1;for(let i=0;i<n;i++){let s=J(e,t,i);if(!(s<r)){if(s>o)break;l<0&&(l=i),c=i;}}return l<0?null:[l,c]}function ye(e,t){if(!e)return null;let n=e.colOffsets.length-1,r=e.rowOffsets.length-1;if(n<=0||r<=0)return null;let o=H(e.startCol,e.colIndices,n,t.left,t.right),l=H(e.startRow,e.rowIndices,r,t.top,t.bottom);if(!o||!l)return null;let[c,i]=o,[s,f]=l;return {x:e.colOffsets[c],y:e.rowOffsets[s],w:e.colOffsets[i+1]-e.colOffsets[c],h:e.rowOffsets[f+1]-e.rowOffsets[s]}}function xe(e,t,n){return e.hyperlinks?.find(r=>t>=r.top&&t<=r.bottom&&n>=r.left&&n<=r.right)??null}function Ce(e){if(!e.externalTarget)return null;let t;try{t=new URL(e.externalTarget);}catch{return null}return ["http:","https:","mailto:","tel:"].includes(t.protocol)?(e.location&&!t.hash&&(t.hash=e.location.replace(/^#/,"")),t.href):null}function Ae(e,t){let n=e.replace(/^#/,""),r=n.lastIndexOf("!"),o=r<0?t:n.slice(0,r),l=(r<0?n:n.slice(r+1)).split(":",1)[0],c=/^\$?([A-Za-z]{1,3})\$?([1-9]\d*)$/.exec(l);if(!c)return null;let i=0;for(let a of c[1].toUpperCase())i=i*26+a.charCodeAt(0)-64;let s=Number(c[2]);if(i<1||i>16384||s<1||s>1048576)return null;let f=o.startsWith("'")&&o.endsWith("'")?o.slice(1,-1).replace(/''/g,"'"):o;return f?{sheetName:f,row:s-1,col:i-1}:null}var Z=new Set(["=","+","-","@"]);function Q(e){let t=e.charCodeAt(0);return Z.has(e[0])||t===9||t===13||t===10}function ee(e){return /[\t\n\r"]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function te(e){let t=!e.isFormula&&e.input.length>0&&Q(e.input);return ee(t?`'${e.input}`:e.input)}function Re(e){return e.map(t=>t.map(te).join(" ")).join(`\r
|
|
2
|
+
`)}function Oe(e){let t=[],n=[],r="",o=false,l=0,c=()=>{n.push(r),r="";},i=()=>{c(),t.push(n),n=[];};for(;l<e.length;){let s=e[l];if(o){if(s==='"'){if(e[l+1]==='"'){r+='"',l+=2;continue}o=false,l+=1;continue}r+=s,l+=1;continue}if(s==='"'){o=true,l+=1;continue}if(s===" "){c(),l+=1;continue}if(s==="\r"){i(),e[l+1]===`
|
|
3
|
+
`&&(l+=1),l+=1;continue}if(s===`
|
|
4
|
+
`){i(),l+=1;continue}r+=s,l+=1;}return (r.length>0||n.length>0)&&i(),t}function P(e){let t=e,n="";do n=String.fromCharCode(65+t%26)+n,t=Math.floor(t/26)-1;while(t>=0);return n}function ne(e,t){return `${P(t)}${e+1}`}function O(e,t){return e.replace(/\{(\w+)\}/g,(n,r)=>String(t[r]??""))}function F(e,t){return `${Math.round(e*1e3)},${Math.round(t*1e3)}`}function re(e){let t=new Map;for(let n of e.commands)n.op==="text"&&n.clip&&!n.ghost&&!n.chart&&t.set(F(n.clip.x,n.clip.y),n.text);return t}function oe(e,t,n){return e?t>=e.top&&t<=e.bottom&&n>=e.left&&n<=e.right:false}function g(e,t,n){return t?.[n]??e+n}function le(e,t,n,r,o,l){let c=g(e.startRow,e.rowIndices,t),i=g(e.startCol,e.colIndices,n),s=ne(c,i),a=r.length===0?o?l.emptyCellLabelSelected:l.emptyCellLabel:o?l.cellLabelSelected:l.cellLabel;return {row:c,col:i,address:s,text:r,selected:o,label:O(a,{address:s,value:r})}}function Le(e,t,n,r){let o=e.grid,l=O(r.gridLabel,{sheet:n}),c=(e.charts??[]).map(u=>({label:u.label,placeholder:u.placeholder??false}));if(!o)return {label:l,sheetName:n,columnHeaders:[],rows:[],charts:c};let i=o.colOffsets.length-1,s=o.rowOffsets.length-1,f=t?y(t):null,a=re(e),x=[];for(let u=0;u<i;u++){let h=g(o.startCol,o.colIndices,u),d=P(h);x.push({col:h,text:d,label:O(r.columnHeaderLabel,{column:d})});}let L=[];for(let u=0;u<s;u++){let h=g(o.startRow,o.rowIndices,u),d=[];for(let b=0;b<i;b++){let k=F(o.colOffsets[b],o.rowOffsets[u]),G=a.get(k)??"",V=g(o.startCol,o.colIndices,b);d.push(le(o,u,b,G,oe(f,h,V),r));}L.push({row:h,header:O(r.rowHeaderLabel,{row:h+1}),cells:d});}return {label:l,sheetName:n,columnHeaders:x,rows:L,charts:c}}export{I as a,E as b,M as c,z as d,_ as e,$ as f,p as g,y as h,N as i,U as j,S as k,w as l,q as m,we as n,de as o,be as p,ye as q,xe as r,Ce as s,Ae as t,Re as u,Oe as v,Le as w};
|
|
Binary file
|
package/dist/headless.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ interface FillRectCmd {
|
|
|
32
32
|
h: number;
|
|
33
33
|
/** css color string (`#rrggbb`, `rgba(...)`), resolved from theme + tint in Rust. */
|
|
34
34
|
color: string;
|
|
35
|
+
clip?: Rect;
|
|
35
36
|
}
|
|
36
37
|
/**
|
|
37
38
|
* Stroke a straight line — gridlines, cell borders, frozen-pane dividers.
|
|
@@ -50,6 +51,43 @@ interface LineCmd {
|
|
|
50
51
|
* serialized at its default in Rust, so a solid line omits the field.
|
|
51
52
|
*/
|
|
52
53
|
style?: 'dashed' | 'dotted' | 'double';
|
|
54
|
+
clip?: Rect;
|
|
55
|
+
}
|
|
56
|
+
type GeometryPathCommand = {
|
|
57
|
+
type: 'move';
|
|
58
|
+
x: number;
|
|
59
|
+
y: number;
|
|
60
|
+
} | {
|
|
61
|
+
type: 'line';
|
|
62
|
+
x: number;
|
|
63
|
+
y: number;
|
|
64
|
+
} | {
|
|
65
|
+
type: 'quad';
|
|
66
|
+
cpx: number;
|
|
67
|
+
cpy: number;
|
|
68
|
+
x: number;
|
|
69
|
+
y: number;
|
|
70
|
+
} | {
|
|
71
|
+
type: 'cubic';
|
|
72
|
+
cp1x: number;
|
|
73
|
+
cp1y: number;
|
|
74
|
+
cp2x: number;
|
|
75
|
+
cp2y: number;
|
|
76
|
+
x: number;
|
|
77
|
+
y: number;
|
|
78
|
+
} | {
|
|
79
|
+
type: 'close';
|
|
80
|
+
};
|
|
81
|
+
interface PathStroke {
|
|
82
|
+
color: string;
|
|
83
|
+
width: number;
|
|
84
|
+
}
|
|
85
|
+
interface PathCmd {
|
|
86
|
+
op: 'path';
|
|
87
|
+
commands: GeometryPathCommand[];
|
|
88
|
+
fill: string;
|
|
89
|
+
stroke?: PathStroke;
|
|
90
|
+
clip?: Rect;
|
|
53
91
|
}
|
|
54
92
|
/**
|
|
55
93
|
* Paint a single-line text run. Spreadsheet cell text is single-line and
|
|
@@ -84,11 +122,12 @@ interface TextCmd {
|
|
|
84
122
|
* `new` text). Painted normally, but excluded from a11y text recovery.
|
|
85
123
|
*/
|
|
86
124
|
ghost?: boolean;
|
|
125
|
+
chart?: boolean;
|
|
87
126
|
}
|
|
88
127
|
/**
|
|
89
128
|
* One draw command; discriminated on `op`.
|
|
90
129
|
*/
|
|
91
|
-
type DrawCmd = FillRectCmd | LineCmd | TextCmd;
|
|
130
|
+
type DrawCmd = FillRectCmd | LineCmd | PathCmd | TextCmd;
|
|
92
131
|
/**
|
|
93
132
|
* Grid metadata for the frame: which sheet cells the visible tracks map to and
|
|
94
133
|
* their viewport-local pixel boundaries. `rowOffsets[i]`/`colOffsets[i]` is the
|
|
@@ -117,6 +156,35 @@ interface HyperlinkRegion {
|
|
|
117
156
|
location?: string;
|
|
118
157
|
tooltip?: string;
|
|
119
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* A chart's placement in the frame: the id that addresses it across the wasm
|
|
161
|
+
* boundary, what a screen reader reads, whether the renderer managed to draw
|
|
162
|
+
* it, its full viewport-local rect and the visible part after pane clipping. A
|
|
163
|
+
* chart that degraded to a placeholder still gets a region, so it stays an
|
|
164
|
+
* addressable object on the sheet.
|
|
165
|
+
*
|
|
166
|
+
* Hand-mirrored from crates/xlsx-render/src/display_list.rs — keep in sync.
|
|
167
|
+
*/
|
|
168
|
+
interface ChartRegion {
|
|
169
|
+
/**
|
|
170
|
+
* the drawing part and the anchor in it, unique within a sheet. Opaque —
|
|
171
|
+
* never the chart part's path, which two anchors may share.
|
|
172
|
+
*/
|
|
173
|
+
id: string;
|
|
174
|
+
label: string;
|
|
175
|
+
/**
|
|
176
|
+
* the chart could not be drawn; a neutral box occupies its rect instead.
|
|
177
|
+
* skip-serialized at `false` in Rust, so treat absent as `false`.
|
|
178
|
+
*/
|
|
179
|
+
placeholder?: boolean;
|
|
180
|
+
rect: Rect;
|
|
181
|
+
/** `rect` intersected with the pane band it paints in — the hit area. */
|
|
182
|
+
clip: Rect;
|
|
183
|
+
/** whether the anchor can be repinned; an absolute one cannot. */
|
|
184
|
+
movable: boolean;
|
|
185
|
+
}
|
|
186
|
+
/** Former name of {@link ChartRegion}, when it carried the label alone. */
|
|
187
|
+
type ChartA11yAttrs = ChartRegion;
|
|
120
188
|
/**
|
|
121
189
|
* A full frame to paint: logical size plus the ordered command stream. `grid`
|
|
122
190
|
* is optional so a synthetic or pre-grid-metadata frame still type-checks; the
|
|
@@ -128,11 +196,11 @@ interface DisplayList {
|
|
|
128
196
|
commands: DrawCmd[];
|
|
129
197
|
grid?: GridMeta;
|
|
130
198
|
hyperlinks?: HyperlinkRegion[];
|
|
199
|
+
charts?: ChartRegion[];
|
|
131
200
|
}
|
|
132
201
|
|
|
133
202
|
/**
|
|
134
|
-
* Pure viewport types
|
|
135
|
-
* canvas painter, and a future Rust port all read from.
|
|
203
|
+
* Pure viewport types shared by the accessibility grid and canvas painter.
|
|
136
204
|
*/
|
|
137
205
|
/**
|
|
138
206
|
* Cumulative pixel offsets for a track axis (columns or rows). `offsets[i]` is
|
|
@@ -175,8 +243,7 @@ interface VisibleCells {
|
|
|
175
243
|
/**
|
|
176
244
|
* Pure viewport math: visible-range computation against cumulative track
|
|
177
245
|
* offsets, and scroll clamping. No DOM, no side effects — every function is a
|
|
178
|
-
* deterministic transform of plain numbers so it is golden-testable
|
|
179
|
-
* mirrored in Rust.
|
|
246
|
+
* deterministic transform of plain numbers so it is golden-testable.
|
|
180
247
|
*/
|
|
181
248
|
|
|
182
249
|
/**
|
|
@@ -209,7 +276,7 @@ declare function uniformOffsets(count: number, size: number): TrackOffsets;
|
|
|
209
276
|
|
|
210
277
|
/**
|
|
211
278
|
* Pure selection types. Plain data only — no DOM, no framework — so the model
|
|
212
|
-
* is golden-testable
|
|
279
|
+
* is golden-testable. The chrome layer interprets the
|
|
213
280
|
* declarative {@link SelectionAction}s the reducer emits.
|
|
214
281
|
*/
|
|
215
282
|
/**
|
|
@@ -347,6 +414,17 @@ declare function selectionKeyReducer(state: Selection, key: KeyInput, limits: Se
|
|
|
347
414
|
* handling and the selection overlay share one geometry source with the painter.
|
|
348
415
|
*/
|
|
349
416
|
|
|
417
|
+
/**
|
|
418
|
+
* The topmost chart whose visible region contains a viewport-local point, or
|
|
419
|
+
* `null`. Mirrors `chart_at_point` in crates/xlsx-render/src/hit.rs: regions are
|
|
420
|
+
* in paint order so the last match wins, and the clipped region bounds the hit,
|
|
421
|
+
* so a chart scrolled under a frozen pane is not hit where it is hidden.
|
|
422
|
+
*
|
|
423
|
+
* Every coordinate is rounded to f32 first. The regions arrive as f32 off the
|
|
424
|
+
* wire, and the engine compares against `clip.x + clip.w` computed in f32; the
|
|
425
|
+
* same sum in f64 lands on the other side of the edge at reachable coordinates.
|
|
426
|
+
*/
|
|
427
|
+
declare function chartRegionAtPoint(charts: readonly ChartRegion[] | undefined, x: number, y: number): ChartRegion | null;
|
|
350
428
|
/**
|
|
351
429
|
* The cell under a viewport-local point, or `null` when the point is outside the
|
|
352
430
|
* visible grid (or the frame carries no grid metadata).
|
|
@@ -458,6 +536,11 @@ interface A11yRow {
|
|
|
458
536
|
header: string;
|
|
459
537
|
cells: A11yCell[];
|
|
460
538
|
}
|
|
539
|
+
interface A11yChart {
|
|
540
|
+
label: string;
|
|
541
|
+
/** the chart could not be drawn; a neutral box occupies its rect instead. */
|
|
542
|
+
placeholder: boolean;
|
|
543
|
+
}
|
|
461
544
|
/**
|
|
462
545
|
* The full offscreen grid mirror for the current frame.
|
|
463
546
|
*/
|
|
@@ -466,6 +549,7 @@ interface A11yGrid {
|
|
|
466
549
|
sheetName: string;
|
|
467
550
|
columnHeaders: A11yColumnHeader[];
|
|
468
551
|
rows: A11yRow[];
|
|
552
|
+
charts: A11yChart[];
|
|
469
553
|
}
|
|
470
554
|
|
|
471
555
|
/**
|
|
@@ -483,4 +567,4 @@ interface A11yGrid {
|
|
|
483
567
|
*/
|
|
484
568
|
declare function buildA11yGrid(displayList: DisplayList, selection: Selection | null, sheetName: string, t: A11yStrings): A11yGrid;
|
|
485
569
|
|
|
486
|
-
export { type A11yCell, type A11yColumnHeader, type A11yGrid, type A11yRow, type A11yStrings, type CellAddr, type CellInput, type CellRange, type Direction, type DisplayList, type DrawCmd, type FillRectCmd, type GridMeta, type HyperlinkDestination, type HyperlinkRegion, type KeyInput, type LineCmd, type MoveOpts, type Rect, type Selection, type SelectionAction, type SelectionLimits, type TextAlign, type TextCmd, type TrackOffsets, type ViewportState, type VisibleCells, type VisibleRange, buildA11yGrid, cellAtPoint, cellCount, cellRect, clampScroll, extendTo, fromTsv, hyperlinkAtCell, moveFocus, normalizeRange, parseHyperlinkLocation, rangeContains, rangeRect, safeExternalHyperlink, selectionAt, selectionKeyReducer, toTsv, totalExtent, trackCount, uniformOffsets, visibleCells, visibleRange };
|
|
570
|
+
export { type A11yCell, type A11yChart, type A11yColumnHeader, type A11yGrid, type A11yRow, type A11yStrings, type CellAddr, type CellInput, type CellRange, type ChartA11yAttrs, type ChartRegion, type Direction, type DisplayList, type DrawCmd, type FillRectCmd, type GeometryPathCommand, type GridMeta, type HyperlinkDestination, type HyperlinkRegion, type KeyInput, type LineCmd, type MoveOpts, type PathCmd, type PathStroke, type Rect, type Selection, type SelectionAction, type SelectionLimits, type TextAlign, type TextCmd, type TrackOffsets, type ViewportState, type VisibleCells, type VisibleRange, buildA11yGrid, cellAtPoint, cellCount, cellRect, chartRegionAtPoint, clampScroll, extendTo, fromTsv, hyperlinkAtCell, moveFocus, normalizeRange, parseHyperlinkLocation, rangeContains, rangeRect, safeExternalHyperlink, selectionAt, selectionKeyReducer, toTsv, totalExtent, trackCount, uniformOffsets, visibleCells, visibleRange };
|
package/dist/headless.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{w as buildA11yGrid,o as cellAtPoint,j as cellCount,p as cellRect,n as chartRegionAtPoint,e as clampScroll,k as extendTo,v as fromTsv,r as hyperlinkAtCell,l as moveFocus,h as normalizeRange,t as parseHyperlinkLocation,i as rangeContains,q as rangeRect,s as safeExternalHyperlink,g as selectionAt,m as selectionKeyReducer,u as toTsv,b as totalExtent,a as trackCount,f as uniformOffsets,d as visibleCells,c as visibleRange}from'./chunk-E6PJOEEH.js';import'./chunk-O2XFH626.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DisplayList } from './headless.js';
|
|
2
|
-
export { A11yCell, A11yColumnHeader, A11yGrid, A11yRow, A11yStrings, CellAddr, CellInput, CellRange, Direction, DrawCmd, FillRectCmd, GridMeta, HyperlinkDestination, HyperlinkRegion, KeyInput, LineCmd, MoveOpts, Rect, Selection, SelectionAction, SelectionLimits, TextAlign, TextCmd, TrackOffsets, ViewportState, VisibleCells, VisibleRange, buildA11yGrid, cellAtPoint, cellCount, cellRect, clampScroll, extendTo, fromTsv, hyperlinkAtCell, moveFocus, normalizeRange, parseHyperlinkLocation, rangeContains, rangeRect, safeExternalHyperlink, selectionAt, selectionKeyReducer, toTsv, totalExtent, trackCount, uniformOffsets, visibleCells, visibleRange } from './headless.js';
|
|
1
|
+
import { DisplayList, ChartRegion } from './headless.js';
|
|
2
|
+
export { A11yCell, A11yChart, A11yColumnHeader, A11yGrid, A11yRow, A11yStrings, CellAddr, CellInput, CellRange, ChartA11yAttrs, Direction, DrawCmd, FillRectCmd, GeometryPathCommand, GridMeta, HyperlinkDestination, HyperlinkRegion, KeyInput, LineCmd, MoveOpts, PathCmd, PathStroke, Rect, Selection, SelectionAction, SelectionLimits, TextAlign, TextCmd, TrackOffsets, ViewportState, VisibleCells, VisibleRange, buildA11yGrid, cellAtPoint, cellCount, cellRect, chartRegionAtPoint, clampScroll, extendTo, fromTsv, hyperlinkAtCell, moveFocus, normalizeRange, parseHyperlinkLocation, rangeContains, rangeRect, safeExternalHyperlink, selectionAt, selectionKeyReducer, toTsv, totalExtent, trackCount, uniformOffsets, visibleCells, visibleRange } from './headless.js';
|
|
3
3
|
import { C as CollaborationReplica, s as CollaborationUpdateOrigin } from './types-C24EBcAP.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -226,6 +226,24 @@ interface WorkbookHandle extends CollaborationReplica {
|
|
|
226
226
|
sheetInfo(): SheetInfo;
|
|
227
227
|
calculationStatus(): CalculationStatus;
|
|
228
228
|
displayList(viewport: Viewport): DisplayList;
|
|
229
|
+
/**
|
|
230
|
+
* the chart under a viewport-local point on the active sheet, or `null`,
|
|
231
|
+
* resolved against the current model from the same anchor geometry the
|
|
232
|
+
* display list is built from. the returned `label` is always empty: a hit
|
|
233
|
+
* test resolves anchors only and never reads a chart part.
|
|
234
|
+
*
|
|
235
|
+
* this answers for the model as it is now. chrome painting a frame should
|
|
236
|
+
* hit-test that frame's own `charts` with `chartRegionAtPoint` instead, or a
|
|
237
|
+
* mutation the canvas has not drawn yet will move the answer off the pixels.
|
|
238
|
+
*/
|
|
239
|
+
chartAtPoint(viewport: Viewport, x: number, y: number): ChartRegion | null;
|
|
240
|
+
/**
|
|
241
|
+
* slide the chart frame `chart` names — a {@link ChartRegion} id — by a
|
|
242
|
+
* content-pixel delta, clamped to the grid, as one undo step. the new anchor
|
|
243
|
+
* is written back on save. throws for a chart pinned to the sheet by an
|
|
244
|
+
* absolute anchor.
|
|
245
|
+
*/
|
|
246
|
+
moveChart(sheet: number, chart: string, dx: number, dy: number): EditResult;
|
|
229
247
|
setActiveSheet(index: number): void;
|
|
230
248
|
/**
|
|
231
249
|
* apply one user input to a cell (parses number/bool/formula/text) and
|
|
@@ -322,4 +340,4 @@ declare function openWorkbook(bytes: Uint8Array, options?: OpenWorkbookOptions):
|
|
|
322
340
|
*/
|
|
323
341
|
declare function wasmVersion(): string;
|
|
324
342
|
|
|
325
|
-
export { type BorderPatch, type BorderPreset, type BorderStyle, type CalculationStatus, type CapturedFormat, type CellEdit, type CellInputEdit, type CellPoint, type CellPosition, 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 };
|
|
343
|
+
export { type BorderPatch, type BorderPreset, type BorderStyle, type CalculationStatus, type CapturedFormat, type CellEdit, type CellInputEdit, type CellPoint, type CellPosition, ChartRegion, 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
|
-
export{v as buildA11yGrid,n as cellAtPoint,j as cellCount,o as cellRect,e as clampScroll,k as extendTo,u as fromTsv,q as hyperlinkAtCell,l as moveFocus,h as normalizeRange,s as parseHyperlinkLocation,i as rangeContains,p as rangeRect,r as safeExternalHyperlink,g as selectionAt,m as selectionKeyReducer,t as toTsv,b as totalExtent,a as trackCount,f as uniformOffsets,d as visibleCells,c as visibleRange}from'./chunk-4LMGHPXC.js';import {a}from'./chunk-O2XFH626.js';var he={left:"left",center:"center",right:"right"},xe={dashed:[4,2],dotted:[1,2]};function ve(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)Se(o,t);o.restore();}function Se(o,e){switch(e.op){case "fillRect":o.fillStyle=e.color,o.fillRect(e.x,e.y,e.w,e.h);return;case "line":Ce(o,e);return;case "text":Re(o,e);return}}function Ce(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),U(o,e.x1-r,e.y1-i,e.x2-r,e.y2-i),U(o,e.x1+r,e.y1+i,e.x2+r,e.y2+i);return}o.lineWidth=e.width,o.save(),o.setLineDash(e.style?xe[e.style]:[]),U(o,e.x1,e.y1,e.x2,e.y2),o.restore();}function U(o,e,n,t,r){o.beginPath(),o.moveTo(e,n),o.lineTo(t,r),o.stroke();}function Re(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=Je(e),o.textAlign=he[e.align??"left"],o.textBaseline="alphabetic",e.highlight&&Pe(o,e),o.fillStyle=e.color,o.fillText(e.text,e.x,e.y),(e.underline||e.strike||e.dashedUnderline)&&Ae(o,e),o.restore();}function Je(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 Ae(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]),U(o,r,e.y+e.fontSize*.1,r+n,e.y+e.fontSize*.1),o.restore());}function Pe(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);}}cellPositionJson(e){let n,t;try{let d=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),c=g,a=s.xlsxdocument_cellPositionJson(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 Ee(){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=Oe(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 ke(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 Ie(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=ke(n);s.__wbindgen_exn_store(t);}}function Oe(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 Ue=2146435072,D=0;function Ie(o,e){return D+=e,D>=Ue&&(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 We(o,e){return s=o.exports,S=null,J=null,s.__wbindgen_start(),s}async function Ne(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=Ee();(typeof o=="string"||typeof Request=="function"&&o instanceof Request||typeof URL=="function"&&o instanceof URL)&&(o=fetch(o));let{instance:n,module:t}=await Ne(await o,e);return We(n)}var F=class extends Error{constructor(n){super(`stale: ${n.join(", ")}`);a(this,"cells");this.name="StaleProposalError",this.cells=n;}},H="stale: ";function De(o){let e=o.slice(H.length).split(",").map(n=>n.trim()).filter(n=>n.length>0);return new F(e)}var z=false,P;function ze(o=new URL("./generated/xlsx_wasm_bg.wasm",import.meta.url)){return z?Promise.resolve():P||(P=j({module_or_path:o}).then(()=>{z=true;},e=>{throw P=void 0,E(e)}),P)}function X(){if(!z)throw new Error("xlsx wasm is not initialized; call initWasm() first")}function E(o){return o instanceof Error?o:new Error(typeof o=="string"?o:String(o))}function Le(){return typeof WebAssembly=="object"}function Me(){return typeof x.prototype.renderPng=="function"}function Ve(){return typeof x.prototype.proposeJson=="function"}function Be(o,e={}){X();let n=je(e),t;try{t=n===void 0?x.open(o):x.openCollaborative(o,n);}catch(l){throw E(l)}let r=new Map,i=[],d=0,c=false,a=false,k=0,W=false;function L(){if(c)throw new Error("workbook handle is disposed")}function $(){if(!(c||W||k!==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 q(){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(),k+=1;try{let f,w,C=!1;try{f=l();}catch(v){w=v,C=!0;}if(u)try{q();}catch(v){C||(w=v,C=!0);}if(C)throw E(w);return f}finally{k-=1,k===0&&$();}}function O(l){return m(l,true)}function y(l,u=false){return m(()=>JSON.parse(l()),u)}function G(){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{G();}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})))},cellPosition(l,u,f){return y(()=>t.cellPositionJson(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)?De(w):E(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 E(l)}}}function je(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 He(){return X(),x.version()}export{F as StaleProposalError,ze as initWasm,Me as isPngExportAvailable,Ve as isProposalsAvailable,Le as isWasmAvailable,Be as openWorkbook,ve as paintDisplayList,He as wasmVersion};
|
|
1
|
+
export{w as buildA11yGrid,o as cellAtPoint,j as cellCount,p as cellRect,n as chartRegionAtPoint,e as clampScroll,k as extendTo,v as fromTsv,r as hyperlinkAtCell,l as moveFocus,h as normalizeRange,t as parseHyperlinkLocation,i as rangeContains,q as rangeRect,s as safeExternalHyperlink,g as selectionAt,m as selectionKeyReducer,u as toTsv,b as totalExtent,a as trackCount,f as uniformOffsets,d as visibleCells,c as visibleRange}from'./chunk-E6PJOEEH.js';import {a}from'./chunk-O2XFH626.js';var Ce=1.3333333333333333,Se={left:"left",center:"center",right:"right"},Re={dashed:[4,2],dotted:[1,2]};function Pe(r,e,t){r.save(),r.setTransform(t,0,0,t,0,0),r.clearRect(0,0,e.width,e.height);for(let n of e.commands)Je(r,n);r.restore();}function Je(r,e){switch(e.op){case "fillRect":N(r,e.clip,()=>{r.fillStyle=e.color,r.fillRect(e.x,e.y,e.w,e.h);});return;case "line":N(r,e.clip,()=>Ee(r,e));return;case "path":N(r,e.clip,()=>Ae(r,e));return;case "text":ke(r,e);return}}function N(r,e,t){if(!e){t();return}r.save(),r.beginPath(),r.rect(e.x,e.y,e.w,e.h),r.clip(),t(),r.restore();}function Ae(r,e){r.beginPath();for(let t of e.commands)switch(t.type){case "move":r.moveTo(t.x,t.y);break;case "line":r.lineTo(t.x,t.y);break;case "quad":r.quadraticCurveTo(t.cpx,t.cpy,t.x,t.y);break;case "cubic":r.bezierCurveTo(t.cp1x,t.cp1y,t.cp2x,t.cp2y,t.x,t.y);break;case "close":r.closePath();break}r.fillStyle=e.fill,r.fill(),e.stroke&&(r.strokeStyle=e.stroke.color,r.lineWidth=e.stroke.width,r.setLineDash([]),r.stroke());}function Ee(r,e){if(r.strokeStyle=e.color,e.style==="double"){let t=Math.max(e.width*.8,.8),n=Math.abs(e.y1-e.y2)<=Math.abs(e.x1-e.x2),[o,i]=n?[0,t]:[t,0];r.lineWidth=Math.max(e.width*.6,.5),U(r,e.x1-o,e.y1-i,e.x2-o,e.y2-i),U(r,e.x1+o,e.y1+i,e.x2+o,e.y2+i);return}r.lineWidth=e.width,r.save(),r.setLineDash(e.style?Re[e.style]:[]),U(r,e.x1,e.y1,e.x2,e.y2),r.restore();}function U(r,e,t,n,o){r.beginPath(),r.moveTo(e,t),r.lineTo(n,o),r.stroke();}function ke(r,e){r.save(),e.clip&&(r.beginPath(),r.rect(e.clip.x,e.clip.y,e.clip.w,e.clip.h),r.clip()),r.fillStyle=e.color,r.font=Oe(e),r.textAlign=Se[e.align??"left"],r.textBaseline="alphabetic",e.highlight&&Ie(r,e),r.fillStyle=e.color,r.fillText(e.text,e.x,e.y),(e.underline||e.strike||e.dashedUnderline)&&Ue(r,e),r.restore();}function Oe(r){let e=r.italic?"italic ":"",t=r.bold?"bold ":"",n=r.fontFamily?r.chart?r.fontFamily:`"${r.fontFamily.replace(/"/g,'\\"')}", sans-serif`:"sans-serif";return `${e}${t}${D(r)}px ${n}`}function D(r){return r.chart?r.fontSize*Ce:r.fontSize}function Ue(r,e){let t=r.measureText(e.text).width,n=e.align??"left",o=n==="right"?e.x-t:n==="center"?e.x-t/2:e.x,i=D(e),c=Math.max(i*.05,.5);r.fillStyle=e.color,e.underline&&r.fillRect(o,e.y+i*.1,t,c),e.strike&&r.fillRect(o,e.y-i*.26,t,c),e.dashedUnderline&&(r.save(),r.strokeStyle=e.color,r.lineWidth=c,r.setLineDash([3,2]),U(r,o,e.y+i*.1,o+t,e.y+i*.1),r.restore());}function Ie(r,e){let t=r.measureText(e.text),n=t.width,o=e.align??"left",i=o==="right"?e.x-n:o==="center"?e.x-n/2:e.x,c=D(e),d=t.actualBoundingBoxAscent||c*.8,a=t.actualBoundingBoxDescent||c*.2;r.fillStyle=e.highlight,r.fillRect(i-2,e.y-d-1,n+4,d+a+2);}var x=class r{static __wrap(e){let t=Object.create(r.prototype);return t.__wbg_ptr=e,j.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,j.unregister(this),e}free(){let e=this.__destroy_into_raw();s.__wbg_xlsxdocument_free(e,0);}acceptProposalJson(e){let t,n;try{let c=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_acceptProposalJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,f(a[2]);return t=o,n=i,p(o,i)}finally{s.__wbindgen_free(t,n,1);}}applyFormatJson(e){let t,n;try{let c=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_applyFormatJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,f(a[2]);return t=o,n=i,p(o,i)}finally{s.__wbindgen_free(t,n,1);}}applyOpsJson(e){let t,n;try{let c=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_applyOpsJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,f(a[2]);return t=o,n=i,p(o,i)}finally{s.__wbindgen_free(t,n,1);}}applyUpdateJson(e){let t,n;try{let c=I(e,s.__wbindgen_malloc),d=g,a=s.xlsxdocument_applyUpdateJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,f(a[2]);return t=o,n=i,p(o,i)}finally{s.__wbindgen_free(t,n,1);}}calculationStatusJson(){let e,t;try{let i=s.xlsxdocument_calculationStatusJson(this.__wbg_ptr);var n=i[0],o=i[1];if(i[3])throw n=0,o=0,f(i[2]);return e=n,t=o,p(n,o)}finally{s.__wbindgen_free(e,t,1);}}captureFormatJson(e){let t,n;try{let c=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_captureFormatJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,f(a[2]);return t=o,n=i,p(o,i)}finally{s.__wbindgen_free(t,n,1);}}cellJson(e){let t,n;try{let c=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_cellJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,f(a[2]);return t=o,n=i,p(o,i)}finally{s.__wbindgen_free(t,n,1);}}cellPositionJson(e){let t,n;try{let c=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_cellPositionJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,f(a[2]);return t=o,n=i,p(o,i)}finally{s.__wbindgen_free(t,n,1);}}chartAtPointJson(e){let t,n;try{let c=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_chartAtPointJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,f(a[2]);return t=o,n=i,p(o,i)}finally{s.__wbindgen_free(t,n,1);}}clearUpdateObservation(){s.xlsxdocument_clearUpdateObservation(this.__wbg_ptr);}get clientId(){return s.xlsxdocument_clientId(this.__wbg_ptr)}displayListJson(e){let t,n;try{let c=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_displayListJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,f(a[2]);return t=o,n=i,p(o,i)}finally{s.__wbindgen_free(t,n,1);}}drainUpdateEvent(){let e=s.xlsxdocument_drainUpdateEvent(this.__wbg_ptr);if(e[3])throw f(e[2]);var t=h(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*1,1),t}editCellJson(e){let t,n;try{let c=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_editCellJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,f(a[2]);return t=o,n=i,p(o,i)}finally{s.__wbindgen_free(t,n,1);}}editCellsJson(e){let t,n;try{let c=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_editCellsJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,f(a[2]);return t=o,n=i,p(o,i)}finally{s.__wbindgen_free(t,n,1);}}encodeDiff(e){let t=I(e,s.__wbindgen_malloc),n=g,o=s.xlsxdocument_encodeDiff(this.__wbg_ptr,t,n);if(o[3])throw f(o[2]);var i=h(o[0],o[1]).slice();return s.__wbindgen_free(o[0],o[1]*1,1),i}encodeStateAsUpdate(){let e=s.xlsxdocument_encodeStateAsUpdate(this.__wbg_ptr);var t=h(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*1,1),t}encodeStateVector(){let e=s.xlsxdocument_encodeStateVector(this.__wbg_ptr);var t=h(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*1,1),t}historyStateJson(){let e,t;try{let i=s.xlsxdocument_historyStateJson(this.__wbg_ptr);var n=i[0],o=i[1];if(i[3])throw n=0,o=0,f(i[2]);return e=n,t=o,p(n,o)}finally{s.__wbindgen_free(e,t,1);}}listProposalsJson(){let e,t;try{let i=s.xlsxdocument_listProposalsJson(this.__wbg_ptr);var n=i[0],o=i[1];if(i[3])throw n=0,o=0,f(i[2]);return e=n,t=o,p(n,o)}finally{s.__wbindgen_free(e,t,1);}}mergedRangesJson(e){let t,n;try{let c=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_mergedRangesJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,f(a[2]);return t=o,n=i,p(o,i)}finally{s.__wbindgen_free(t,n,1);}}moveChartJson(e){let t,n;try{let c=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_moveChartJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,f(a[2]);return t=o,n=i,p(o,i)}finally{s.__wbindgen_free(t,n,1);}}static open(e){let t=I(e,s.__wbindgen_malloc),n=g,o=s.xlsxdocument_open(t,n);if(o[2])throw f(o[1]);return r.__wrap(o[0])}static openCollaborative(e,t){let n=I(e,s.__wbindgen_malloc),o=g,i=s.xlsxdocument_openCollaborative(n,o,t);if(i[2])throw f(i[1]);return r.__wrap(i[0])}patchRangeStyleJson(e){let t,n;try{let c=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_patchRangeStyleJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,f(a[2]);return t=o,n=i,p(o,i)}finally{s.__wbindgen_free(t,n,1);}}proposeJson(e){let t,n;try{let c=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_proposeJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,f(a[2]);return t=o,n=i,p(o,i)}finally{s.__wbindgen_free(t,n,1);}}rangeCellsJson(e){let t,n;try{let c=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_rangeCellsJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,f(a[2]);return t=o,n=i,p(o,i)}finally{s.__wbindgen_free(t,n,1);}}redoJson(){let e,t;try{let i=s.xlsxdocument_redoJson(this.__wbg_ptr);var n=i[0],o=i[1];if(i[3])throw n=0,o=0,f(i[2]);return e=n,t=o,p(n,o)}finally{s.__wbindgen_free(e,t,1);}}rejectProposalJson(e){let t,n;try{let c=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_rejectProposalJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,f(a[2]);return t=o,n=i,p(o,i)}finally{s.__wbindgen_free(t,n,1);}}renderPng(e){let t=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),n=g,o=s.xlsxdocument_renderPng(this.__wbg_ptr,t,n);if(o[3])throw f(o[2]);var i=h(o[0],o[1]).slice();return s.__wbindgen_free(o[0],o[1]*1,1),i}renderRangePng(e){let t=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),n=g,o=s.xlsxdocument_renderRangePng(this.__wbg_ptr,t,n);if(o[3])throw f(o[2]);var i=h(o[0],o[1]).slice();return s.__wbindgen_free(o[0],o[1]*1,1),i}saveBytes(){let e=s.xlsxdocument_saveBytes(this.__wbg_ptr);if(e[3])throw f(e[2]);var t=h(e[0],e[1]).slice();return s.__wbindgen_free(e[0],e[1]*1,1),t}selectionFormattingJson(e){let t,n;try{let c=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_selectionFormattingJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,f(a[2]);return t=o,n=i,p(o,i)}finally{s.__wbindgen_free(t,n,1);}}setActiveSheet(e){let t=s.xlsxdocument_setActiveSheet(this.__wbg_ptr,e);if(t[1])throw f(t[0])}setRangeNumberFormatJson(e){let t,n;try{let c=b(e,s.__wbindgen_malloc,s.__wbindgen_realloc),d=g,a=s.xlsxdocument_setRangeNumberFormatJson(this.__wbg_ptr,c,d);var o=a[0],i=a[1];if(a[3])throw o=0,i=0,f(a[2]);return t=o,n=i,p(o,i)}finally{s.__wbindgen_free(t,n,1);}}sheetInfoJson(){let e,t;try{let i=s.xlsxdocument_sheetInfoJson(this.__wbg_ptr);var n=i[0],o=i[1];if(i[3])throw n=0,o=0,f(i[2]);return e=n,t=o,p(n,o)}finally{s.__wbindgen_free(e,t,1);}}startUpdateObservation(){let e=s.xlsxdocument_startUpdateObservation(this.__wbg_ptr);if(e[1])throw f(e[0])}undoJson(){let e,t;try{let i=s.xlsxdocument_undoJson(this.__wbg_ptr);var n=i[0],o=i[1];if(i[3])throw n=0,o=0,f(i[2]);return e=n,t=o,p(n,o)}finally{s.__wbindgen_free(e,t,1);}}static version(){let e,t;try{let n=s.xlsxdocument_version();return e=n[0],t=n[1],p(n[0],n[1])}finally{s.__wbindgen_free(e,t,1);}}};Symbol.dispose&&(x.prototype[Symbol.dispose]=x.prototype.free);function Te(){return {__proto__:null,"./xlsx_wasm_bg.js":{__proto__:null,__wbg___wbindgen_string_get_b0ca35b86a603356:function(e,t){let n=t,o=typeof n=="string"?n:void 0;var i=We(o)?0:b(o,s.__wbindgen_malloc,s.__wbindgen_realloc),c=g;H().setInt32(e+4,c,true),H().setInt32(e+0,i,true);},__wbg___wbindgen_throw_344f42d3211c4765:function(e,t){throw new Error(p(e,t))},__wbg_getRandomValues_3f44b700395062e5:function(){return L(function(e,t){globalThis.crypto.getRandomValues(h(e,t));},arguments)},__wbg_get_78f252d074a84d0b:function(){return L(function(e,t){return Reflect.get(e,t)},arguments)},__wbg_get_unchecked_6e0ad6d2a41b06f6:function(e,t){return e[t>>>0]},__wbg_instanceof_Object_33f20e6f12439f3e:function(e){let t;try{t=e instanceof Object;}catch{t=false;}return t},__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,t){return new Uint8Array(h(e,t))},__wbg_now_86c0d4ba3fa605b8:function(){return Date.now()},__wbg_prototypesetcall_4770620bbe4688a0:function(e,t,n){Uint8Array.prototype.set.call(h(e,t),n);},__wbg_set_8535240470bf2500:function(){return L(function(e,t,n){return Reflect.set(e,t,n)},arguments)},__wbindgen_cast_0000000000000001:function(e,t){return p(e,t)},__wbindgen_init_externref_table:function(){let e=s.__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 j=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(r=>s.__wbg_xlsxdocument_free(r,1));function Fe(r){let e=s.__externref_table_alloc();return s.__wbindgen_externrefs.set(e,r),e}function h(r,e){return r=r>>>0,R().subarray(r/1,r/1+e)}var C=null;function H(){return (C===null||C.buffer.detached===true||C.buffer.detached===void 0&&C.buffer!==s.memory.buffer)&&(C=new DataView(s.memory.buffer)),C}function p(r,e){return De(r>>>0,e)}var P=null;function R(){return (P===null||P.byteLength===0)&&(P=new Uint8Array(s.memory.buffer)),P}function L(r,e){try{return r.apply(this,e)}catch(t){let n=Fe(t);s.__wbindgen_exn_store(n);}}function We(r){return r==null}function I(r,e){let t=e(r.length*1,1)>>>0;return R().set(r,t/1),g=r.length,t}function b(r,e,t){if(t===void 0){let d=J.encode(r),a=e(d.length,1)>>>0;return R().subarray(a,a+d.length).set(d),g=d.length,a}let n=r.length,o=e(n,1)>>>0,i=R(),c=0;for(;c<n;c++){let d=r.charCodeAt(c);if(d>127)break;i[o+c]=d;}if(c!==n){c!==0&&(r=r.slice(c)),o=t(o,n,n=c+r.length*3,1)>>>0;let d=R().subarray(o+c,o+n),a=J.encodeInto(r,d);c+=a.written,o=t(o,n,c,1)>>>0;}return g=c,o}function f(r){let e=s.__wbindgen_externrefs.get(r);return s.__externref_table_dealloc(r),e}var T=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true});T.decode();var Ne=2146435072,z=0;function De(r,e){return z+=e,z>=Ne&&(T=new TextDecoder("utf-8",{ignoreBOM:true,fatal:true}),T.decode(),z=e),T.decode(R().subarray(r,r+e))}var J=new TextEncoder;"encodeInto"in J||(J.encodeInto=function(r,e){let t=J.encode(r);return e.set(t),{read:r.length,written:t.length}});var g=0,s;function Me(r,e){return s=r.exports,C=null,P=null,s.__wbindgen_start(),s}async function Ve(r,e){if(typeof Response=="function"&&r instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(r,e)}catch(o){if(r.ok&&t(r.type)&&r.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 n=await r.arrayBuffer();return await WebAssembly.instantiate(n,e)}else {let n=await WebAssembly.instantiate(r,e);return n instanceof WebAssembly.Instance?{instance:n,module:r}:n}function t(n){switch(n){case "basic":case "cors":case "default":return true}return false}}async function q(r){if(s!==void 0)return s;if(r!==void 0&&(Object.getPrototypeOf(r)===Object.prototype?{module_or_path:r}=r:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),r===void 0)throw new Error("xlsx-wasm requires an explicit module or URL");let e=Te();(typeof r=="string"||typeof Request=="function"&&r instanceof Request||typeof URL=="function"&&r instanceof URL)&&(r=fetch(r));let{instance:t,module:n}=await Ve(await r,e);return Me(t)}var F=class extends Error{constructor(t){super(`stale: ${t.join(", ")}`);a(this,"cells");this.name="StaleProposalError",this.cells=t;}},X="stale: ";function Be(r){let e=r.slice(X.length).split(",").map(t=>t.trim()).filter(t=>t.length>0);return new F(e)}var M=false,A;function je(r=new URL("./generated/xlsx_wasm_bg.wasm",import.meta.url)){return M?Promise.resolve():A||(A=q({module_or_path:r}).then(()=>{M=true;},e=>{throw A=void 0,E(e)}),A)}function G(){if(!M)throw new Error("xlsx wasm is not initialized; call initWasm() first")}function E(r){return r instanceof Error?r:new Error(typeof r=="string"?r:String(r))}function He(){return typeof WebAssembly=="object"}function qe(){return typeof x.prototype.renderPng=="function"}function Xe(){return typeof x.prototype.proposeJson=="function"}function Ge(r,e={}){G();let t=$e(e),n;try{n=t===void 0?x.open(r):x.openCollaborative(r,t);}catch(l){throw E(l)}let o=new Map,i=[],c=0,d=false,a=false,k=0,W=false;function V(){if(d)throw new Error("workbook handle is disposed")}function $(){if(!(d||W||k!==0)){W=true;try{for(;!d&&i.length>0;){let l=i.shift();if(!l)break;for(let[u,_]of [...o]){if(d)return;if(o.get(u)===_)try{_(l.update.slice(),l.origin);}catch{}}}}finally{W=false,d&&(i.length=0);}}}function K(){if(!(!a||d))for(;;){let l=n.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){V(),k+=1;try{let _,w,S=!1;try{_=l();}catch(v){w=v,S=!0;}if(u)try{K();}catch(v){S||(w=v,S=!0);}if(S)throw E(w);return _}finally{k-=1,k===0&&$();}}function O(l){return m(l,true)}function y(l,u=false){return m(()=>JSON.parse(l()),u)}function Y(){a||(m(()=>n.startUpdateObservation()),a=true);}function Q(){!a||o.size>0||d||(i.length=0,m(()=>n.clearUpdateObservation()),a=false);}return {get clientId(){return m(()=>n.clientId)},encodeStateVector(){return m(()=>n.encodeStateVector().slice())},encodeStateAsUpdate(l){return m(()=>l===void 0?n.encodeStateAsUpdate().slice():n.encodeDiff(l.slice()).slice())},applyUpdate(l){return y(()=>n.applyUpdateJson(l.slice()),true)},onUpdate(l){if(V(),typeof l!="function")throw new TypeError("update listener must be a function");let u=c++;o.set(u,l);try{Y();}catch(w){throw o.delete(u),w}let _=true;return ()=>{_&&(_=false,o.delete(u),Q());}},sheetInfo(){return y(()=>n.sheetInfoJson())},calculationStatus(){return m(()=>{let l=n.calculationStatusJson;return typeof l!="function"?{limitedCells:[]}:JSON.parse(l.call(n))})},displayList(l){return y(()=>n.displayListJson(JSON.stringify(l)))},chartAtPoint(l,u,_){return y(()=>n.chartAtPointJson(JSON.stringify({viewport:l,x:u,y:_})))},moveChart(l,u,_,w){return y(()=>n.moveChartJson(JSON.stringify({sheet:l,chart:u,dx:_,dy:w})),true)},setActiveSheet(l){O(()=>n.setActiveSheet(l));},editCell(l,u,_,w){return y(()=>n.editCellJson(JSON.stringify({sheet:l,row:u,col:_,input:w})),true)},editCells(l,u){return y(()=>n.editCellsJson(JSON.stringify({sheet:l,edits:u})),true)},applyOps(l){return y(()=>n.applyOpsJson(JSON.stringify({ops:l})),true)},undo(){return y(()=>n.undoJson(),true)},redo(){return y(()=>n.redoJson(),true)},cell(l,u,_){return y(()=>n.cellJson(JSON.stringify({sheet:l,row:u,col:_})))},cellPosition(l,u,_){return y(()=>n.cellPositionJson(JSON.stringify({sheet:l,row:u,col:_})))},rangeCells(l,u){return y(()=>n.rangeCellsJson(JSON.stringify({sheet:l,range:u}))).cells},patchRangeStyle(l,u,_){return y(()=>n.patchRangeStyleJson(JSON.stringify({sheet:l,range:u,patch:_})),true)},setNumberFormat(l,u,_){let w=typeof _=="string"?{type:_}:_;return y(()=>n.setRangeNumberFormatJson(JSON.stringify({sheet:l,range:u,format:w})),true)},selectionFormatting(l,u){return y(()=>n.selectionFormattingJson(JSON.stringify({sheet:l,range:u})))},captureFormat(l,u){return y(()=>n.captureFormatJson(JSON.stringify({sheet:l,range:u})))},applyFormat(l,u,_){return y(()=>n.applyFormatJson(JSON.stringify({sheet:l,range:u,format:_})),true)},mergedRanges(l,u){return y(()=>n.mergedRangesJson(JSON.stringify({sheet:l,range:u}))).ranges},historyState(){return y(()=>n.historyStateJson())},renderPng(l){return m(()=>{let u=n.renderPng;if(typeof u!="function")throw new Error("png export not in this build");return u.call(n,JSON.stringify(l)).slice()})},renderRangePng(l){return m(()=>{let u=n.renderRangePng;if(typeof u!="function")throw new Error("png export not in this build");return u.call(n,JSON.stringify(l??{})).slice()})},save(){return m(()=>n.saveBytes().slice())},propose(l,u,_){return O(()=>{let w=n.proposeJson;if(typeof w!="function")throw new Error("proposals not in this build");let S=_.map(({numberFormat:v,...Z})=>({...Z,...v===void 0?{}:{numberFormat:typeof v=="string"?{type:v}:v}}));return JSON.parse(w.call(n,JSON.stringify({agentId:l,note:u,edits:S})))})},listProposals(){return m(()=>{let l=n.listProposalsJson;return typeof l!="function"?[]:JSON.parse(l.call(n)).proposals})},acceptProposal(l,u){try{return O(()=>{let _=n.acceptProposalJson;if(typeof _!="function")throw new Error("proposals not in this build");return JSON.parse(_.call(n,JSON.stringify({id:l,force:u?.force??!1})))})}catch(_){let w=_ instanceof Error?_.message:typeof _=="string"?_:String(_);throw w.startsWith(X)?Be(w):E(_)}},rejectProposal(l){return O(()=>{let u=n.rejectProposalJson;return typeof u!="function"?false:JSON.parse(u.call(n,JSON.stringify({id:l}))).removed})},isProposalsAvailable(){return m(()=>typeof n.proposeJson=="function")},dispose(){if(d)return;d=true,o.clear(),i.length=0;let l;if(a){try{n.clearUpdateObservation();}catch(u){l=u;}a=false;}try{n.free();}catch(u){l??(l=u);}if(l!==void 0)throw E(l)}}}function $e(r){if(!r.collaborative){if(r.clientId!==void 0)throw new TypeError("clientId requires collaborative mode");return}if(r.clientId!==void 0){if(!Number.isSafeInteger(r.clientId)||r.clientId<=0||r.clientId>Number.MAX_SAFE_INTEGER)throw new RangeError("clientId must be a nonzero safe integer");return r.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 t=new Uint32Array(2),n;do e.getRandomValues(t),n=(t[0]&2097151)*4294967296+t[1];while(n===0);return n}function Ke(){return G(),x.version()}export{F as StaleProposalError,je as initWasm,qe as isPngExportAvailable,Xe as isProposalsAvailable,He as isWasmAvailable,Ge as openWorkbook,Pe as paintDisplayList,Ke as wasmVersion};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@betteroffice/xlsx",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Excel-faithful XLSX spreadsheet editor and viewer core — full OOXML fidelity, real-time human + AI agent collaboration. Framework-free (Rust/Wasm).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"xlsx",
|
|
@@ -10,10 +10,19 @@
|
|
|
10
10
|
"office",
|
|
11
11
|
"editor",
|
|
12
12
|
"viewer",
|
|
13
|
+
"xlsx-editor",
|
|
14
|
+
"xlsx-viewer",
|
|
15
|
+
"xlsx-parser",
|
|
16
|
+
"spreadsheet-editor",
|
|
17
|
+
"formula",
|
|
13
18
|
"collaborative",
|
|
14
19
|
"real-time",
|
|
20
|
+
"crdt",
|
|
21
|
+
"yjs",
|
|
15
22
|
"ai-agent",
|
|
16
|
-
"
|
|
23
|
+
"headless",
|
|
24
|
+
"wasm",
|
|
25
|
+
"rust"
|
|
17
26
|
],
|
|
18
27
|
"type": "module",
|
|
19
28
|
"sideEffects": false,
|
package/dist/chunk-4LMGHPXC.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
function I(e){return Math.max(0,e.length-1)}function D(e){return e.length>0?e[e.length-1]:0}function C(e,t,n){return Math.max(t,Math.min(n,e))}function L(e,t,n,r){let o=n,l=r;for(;o<l;){let c=o+l+1>>1;e[c]<=t?o=c:l=c-1;}return o}function M(e,t,n,r){let o=I(e);if(o===0)return {first:0,last:-1};let l=C(Math.trunc(t),0,o);if(l>=o)return {first:0,last:-1};let c=e[l]-e[0],i=e[l]+Math.max(0,n),s=Math.max(0,r-c),a=i+s,f=L(e,i,l,o-1);if(e[f+1]<=i||s===0)return {first:0,last:-1};let x=L(e,a,f,o-1);return {first:f,last:x}}function V(e,t,n){return {cols:M(t,e.frozenCols,e.scrollX,e.width),rows:M(n,e.frozenRows,e.scrollY,e.height)}}function T(e,t,n){let r=I(e),o=C(Math.trunc(t),0,r),l=D(e)-e[o],c=Math.max(0,n-(e[o]-e[0]));return Math.max(0,l-c)}function z(e,t,n){let r=C(e.scrollX,0,T(t,e.frozenCols,e.width)),o=C(e.scrollY,0,T(n,e.frozenRows,e.height));return r===e.scrollX&&o===e.scrollY?e:{...e,scrollX:r,scrollY:o}}function _(e,t){let n=new Array(e+1);for(let r=0;r<=e;r++)n[r]=r*t;return n}function A(e,t,n){return Math.max(t,Math.min(n,e))}function u(e){return {anchor:{...e},focus:{...e}}}function y(e){return {top:Math.min(e.anchor.row,e.focus.row),bottom:Math.max(e.anchor.row,e.focus.row),left:Math.min(e.anchor.col,e.focus.col),right:Math.max(e.anchor.col,e.focus.col)}}function $(e,t){let n=y(e);return t.row>=n.top&&t.row<=n.bottom&&t.col>=n.left&&t.col<=n.right}function U(e){let t=y(e);return (t.bottom-t.top+1)*(t.right-t.left+1)}function S(e,t,n){let r=n?{row:A(t.row,0,n.rows-1),col:A(t.col,0,n.cols-1)}:{...t};return {anchor:{...e.anchor},focus:r}}function W(e,t){switch(e){case "up":return {row:-t,col:0};case "down":return {row:t,col:0};case "left":return {row:0,col:-t};case "right":return {row:0,col:t}}}function h(e,t,n){let{limits:r}=n,o=n.step??1,l=W(t,o),c={row:A(e.focus.row+l.row,0,r.rows-1),col:A(e.focus.col+l.col,0,r.cols-1)};return n.extend?S(e,c):u(c)}var B={ArrowUp:"up",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right"};function R(e){return !!(e.metaKey||e.ctrlKey)}function X(e,t,n){switch(t){case "up":return {row:0,col:e.col};case "down":return {row:n.rows-1,col:e.col};case "left":return {row:e.row,col:0};case "right":return {row:e.row,col:n.cols-1}}}function m(e){return {type:"move",selection:e}}function Y(e,t,n){let{row:r,col:o}=e.focus;return !t&&o>=n.cols-1?u({row:Math.min(r+1,n.rows-1),col:0}):t&&o<=0?u({row:Math.max(r-1,0),col:n.cols-1}):u({row:r,col:o+(t?-1:1)})}function N(e){return e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey}function j(e,t,n){let r=B[t.key];if(r){if(R(t)){let o=X(e.focus,r,n);return m(t.shiftKey?S(e,o,n):u(o))}return m(h(e,r,{extend:t.shiftKey,limits:n}))}switch(t.key){case "Tab":return m(Y(e,!!t.shiftKey,n));case "Enter":return m(h(e,t.shiftKey?"up":"down",{extend:false,limits:n}));case "Home":return m(R(t)?u({row:0,col:0}):u({row:e.focus.row,col:0}));case "End":return m(R(t)?u({row:n.rows-1,col:n.cols-1}):u({row:e.focus.row,col:n.cols-1}));case "PageDown":return m(h(e,"down",{extend:t.shiftKey,step:n.rowsPerPage,limits:n}));case "PageUp":return m(h(e,"up",{extend:t.shiftKey,step:n.rowsPerPage,limits:n}));case "F2":return {type:"startEdit"};case "Delete":case "Backspace":return {type:"clear"}}return (t.key==="a"||t.key==="A")&&R(t)?m({anchor:{row:0,col:0},focus:{row:n.rows-1,col:n.cols-1}}):N(t)?{type:"startEdit",initialInput:t.key}:{type:"none"}}function E(e,t){let n=e.length-1;if(n<=0||t<e[0]||t>=e[n])return -1;let r=0,o=n-1;for(;r<o;){let l=r+o+1>>1;e[l]<=t?r=l:o=l-1;}return r}function we(e,t,n){if(!e)return null;let r=E(e.colOffsets,t),o=E(e.rowOffsets,n);return r<0||o<0?null:{row:e.rowIndices?.[o]??e.startRow+o,col:e.colIndices?.[r]??e.startCol+r}}function v(e,t,n,r){if(t){let l=0,c=t.length-1;for(;l<=c;){let i=l+c>>1,s=t[i];if(s===r)return i;s<r?l=i+1:c=i-1;}return -1}let o=r-e;return o>=0&&o<n.length-1?o:-1}function he(e,t,n){if(!e)return null;let r=v(e.startCol,e.colIndices,e.colOffsets,n),o=v(e.startRow,e.rowIndices,e.rowOffsets,t);return r<0||o<0?null:{x:e.colOffsets[r],y:e.rowOffsets[o],w:e.colOffsets[r+1]-e.colOffsets[r],h:e.rowOffsets[o+1]-e.rowOffsets[o]}}function q(e,t,n){return t?.[n]??e+n}function K(e,t,n,r,o){let l=-1,c=-1;for(let i=0;i<n;i++){let s=q(e,t,i);if(!(s<r)){if(s>o)break;l<0&&(l=i),c=i;}}return l<0?null:[l,c]}function be(e,t){if(!e)return null;let n=e.colOffsets.length-1,r=e.rowOffsets.length-1;if(n<=0||r<=0)return null;let o=K(e.startCol,e.colIndices,n,t.left,t.right),l=K(e.startRow,e.rowIndices,r,t.top,t.bottom);if(!o||!l)return null;let[c,i]=o,[s,a]=l;return {x:e.colOffsets[c],y:e.rowOffsets[s],w:e.colOffsets[i+1]-e.colOffsets[c],h:e.rowOffsets[a+1]-e.rowOffsets[s]}}function ye(e,t,n){return e.hyperlinks?.find(r=>t>=r.top&&t<=r.bottom&&n>=r.left&&n<=r.right)??null}function ge(e){if(!e.externalTarget)return null;let t;try{t=new URL(e.externalTarget);}catch{return null}return ["http:","https:","mailto:","tel:"].includes(t.protocol)?(e.location&&!t.hash&&(t.hash=e.location.replace(/^#/,"")),t.href):null}function xe(e,t){let n=e.replace(/^#/,""),r=n.lastIndexOf("!"),o=r<0?t:n.slice(0,r),l=(r<0?n:n.slice(r+1)).split(":",1)[0],c=/^\$?([A-Za-z]{1,3})\$?([1-9]\d*)$/.exec(l);if(!c)return null;let i=0;for(let f of c[1].toUpperCase())i=i*26+f.charCodeAt(0)-64;let s=Number(c[2]);if(i<1||i>16384||s<1||s>1048576)return null;let a=o.startsWith("'")&&o.endsWith("'")?o.slice(1,-1).replace(/''/g,"'"):o;return a?{sheetName:a,row:s-1,col:i-1}:null}var J=new Set(["=","+","-","@"]);function Z(e){let t=e.charCodeAt(0);return J.has(e[0])||t===9||t===13||t===10}function Q(e){return /[\t\n\r"]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function ee(e){let t=!e.isFormula&&e.input.length>0&&Z(e.input);return Q(t?`'${e.input}`:e.input)}function Ae(e){return e.map(t=>t.map(ee).join(" ")).join(`\r
|
|
2
|
-
`)}function Se(e){let t=[],n=[],r="",o=false,l=0,c=()=>{n.push(r),r="";},i=()=>{c(),t.push(n),n=[];};for(;l<e.length;){let s=e[l];if(o){if(s==='"'){if(e[l+1]==='"'){r+='"',l+=2;continue}o=false,l+=1;continue}r+=s,l+=1;continue}if(s==='"'){o=true,l+=1;continue}if(s===" "){c(),l+=1;continue}if(s==="\r"){i(),e[l+1]===`
|
|
3
|
-
`&&(l+=1),l+=1;continue}if(s===`
|
|
4
|
-
`){i(),l+=1;continue}r+=s,l+=1;}return (r.length>0||n.length>0)&&i(),t}function H(e){let t=e,n="";do n=String.fromCharCode(65+t%26)+n,t=Math.floor(t/26)-1;while(t>=0);return n}function te(e,t){return `${H(t)}${e+1}`}function O(e,t){return e.replace(/\{(\w+)\}/g,(n,r)=>String(t[r]??""))}function P(e,t){return `${Math.round(e*1e3)},${Math.round(t*1e3)}`}function ne(e){let t=new Map;for(let n of e.commands)n.op==="text"&&n.clip&&!n.ghost&&t.set(P(n.clip.x,n.clip.y),n.text);return t}function re(e,t,n){return e?t>=e.top&&t<=e.bottom&&n>=e.left&&n<=e.right:false}function g(e,t,n){return t?.[n]??e+n}function oe(e,t,n,r,o,l){let c=g(e.startRow,e.rowIndices,t),i=g(e.startCol,e.colIndices,n),s=te(c,i),f=r.length===0?o?l.emptyCellLabelSelected:l.emptyCellLabel:o?l.cellLabelSelected:l.cellLabel;return {row:c,col:i,address:s,text:r,selected:o,label:O(f,{address:s,value:r})}}function Me(e,t,n,r){let o=e.grid,l=O(r.gridLabel,{sheet:n});if(!o)return {label:l,sheetName:n,columnHeaders:[],rows:[]};let c=o.colOffsets.length-1,i=o.rowOffsets.length-1,s=t?y(t):null,a=ne(e),f=[];for(let p=0;p<c;p++){let w=g(o.startCol,o.colIndices,p),b=H(w);f.push({col:w,text:b,label:O(r.columnHeaderLabel,{column:b})});}let x=[];for(let p=0;p<i;p++){let w=g(o.startRow,o.rowIndices,p),b=[];for(let d=0;d<c;d++){let k=P(o.colOffsets[d],o.rowOffsets[p]),F=a.get(k)??"",G=g(o.startCol,o.colIndices,d);b.push(oe(o,p,d,F,re(s,w,G),r));}x.push({row:w,header:O(r.rowHeaderLabel,{row:w+1}),cells:b});}return {label:l,sheetName:n,columnHeaders:f,rows:x}}export{I as a,D as b,M as c,V as d,z as e,_ as f,u as g,y as h,$ as i,U as j,S as k,h as l,j as m,we as n,he as o,be as p,ye as q,ge as r,xe as s,Ae as t,Se as u,Me as v};
|