@beyondwork/xlsx-substrate-bindings 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +136 -0
  2. package/dist/ai/agent-metadata.d.ts +363 -0
  3. package/dist/ai/agent-metadata.js +227 -0
  4. package/dist/ai/index.d.ts +5 -1
  5. package/dist/ai/index.js +6 -0
  6. package/dist/ai/mutation-bridge.d.ts +82 -0
  7. package/dist/ai/mutation-bridge.js +179 -0
  8. package/dist/ai/types.d.ts +448 -3
  9. package/dist/index.d.ts +7 -3
  10. package/dist/index.js +20 -2
  11. package/dist/runtime/index.d.ts +1 -1
  12. package/dist/runtime/types.d.ts +57 -1
  13. package/dist/wasm/ai-session-bridge.d.ts +97 -0
  14. package/dist/wasm/ai-session-bridge.js +154 -0
  15. package/dist/wasm/bridge-contract.d.ts +108 -6
  16. package/dist/wasm/bridge-contract.js +146 -7
  17. package/dist/wasm/index.d.ts +43 -2
  18. package/dist/wasm/index.js +253 -23
  19. package/dist/wasm/memory-budget.d.ts +77 -0
  20. package/dist/wasm/memory-budget.js +532 -0
  21. package/dist/wasm/runtime-guard.d.ts +141 -0
  22. package/dist/wasm/runtime-guard.js +373 -0
  23. package/dist/wasm/web.d.ts +16 -3
  24. package/dist/wasm/web.js +91 -9
  25. package/generated/wasm-web/xlsx_substrate_wasm.d.ts +66 -0
  26. package/generated/wasm-web/xlsx_substrate_wasm.js +2488 -2104
  27. package/generated/wasm-web/xlsx_substrate_wasm_bg.wasm +0 -0
  28. package/generated/wasm-web/xlsx_substrate_wasm_bg.wasm.d.ts +15 -0
  29. package/package.json +18 -4
  30. package/dist/wasm/chart-test-fixture.d.ts +0 -19
  31. package/dist/wasm/chart-test-fixture.js +0 -42
  32. package/dist/wasm/media-test-fixture.d.ts +0 -44
  33. package/dist/wasm/media-test-fixture.js +0 -160
  34. package/dist/wasm/volatile-test-fixture.d.ts +0 -7
  35. package/dist/wasm/volatile-test-fixture.js +0 -35
  36. package/generated/wasm/package.json +0 -3
  37. package/generated/wasm/sheet-window-binary.mjs +0 -482
  38. package/generated/wasm/snippets/ironcalc_base-89b4f49381e1e289/inline0.js +0 -45
  39. package/generated/wasm/xlsx_substrate_wasm.d.ts +0 -336
  40. package/generated/wasm/xlsx_substrate_wasm.js +0 -2108
  41. package/generated/wasm/xlsx_substrate_wasm_bg.wasm +0 -0
  42. package/generated/wasm/xlsx_substrate_wasm_bg.wasm.d.ts +0 -105
@@ -1,482 +0,0 @@
1
- // GENERATED by scripts/build-wasm.mjs from src/wasm/sheet-window-binary.ts — do not edit.
2
- export const SHEET_WINDOW_BINARY_SCHEMA_ID = "xlsx-sheet-window-binary/1";
3
- export const SHEET_WINDOW_BINARY_MAGIC = 0x31575358;
4
- export const SHEET_WINDOW_BINARY_VERSION = 1;
5
- export const SHEET_WINDOW_BINARY_HEADER_BYTES = 32;
6
- export const SHEET_WINDOW_BINARY_SECTION_ENTRY_BYTES = 16;
7
- export const SHEET_WINDOW_SECTION_ROWS = 1;
8
- export const SHEET_WINDOW_SECTION_COLS = 2;
9
- export const SHEET_WINDOW_SECTION_CELLS = 3;
10
- export const SHEET_WINDOW_SECTION_PAINT_ROWS = 4;
11
- export const SHEET_WINDOW_SECTION_PAINT_COLS = 5;
12
- export const SHEET_WINDOW_SECTION_RECTS = 6;
13
- export const SHEET_WINDOW_SECTION_PAINT_CELLS = 7;
14
- export const SHEET_WINDOW_SECTION_STRTAB = 8;
15
- export const SHEET_WINDOW_SECTION_STRBLOB = 9;
16
- export const SHEET_WINDOW_LINE_RECORD_BYTES = 24;
17
- export const SHEET_WINDOW_CELL_RECORD_BYTES = 96;
18
- export const SHEET_WINDOW_PAINT_LINE_RECORD_BYTES = 32;
19
- export const SHEET_WINDOW_RECT_RECORD_BYTES = 48;
20
- export const SHEET_WINDOW_PAINT_CELL_RECORD_BYTES = 32;
21
- export const SHEET_WINDOW_STRTAB_ENTRY_BYTES = 8;
22
- export const SHEET_WINDOW_U32_NONE = 0xffffffff;
23
- export const SHEET_WINDOW_OUTLINE_NONE = 0xff;
24
- export const SHEET_WINDOW_MARKER_SEPARATOR = "\u001f";
25
- export const SHEET_WINDOW_FLAG_PAINT_GEOMETRY = 0x0001;
26
- const utf8Decoder = new TextDecoder("utf-8", {
27
- fatal: true
28
- });
29
- class SheetWindowStringTable {
30
- view;
31
- bytes;
32
- strtab;
33
- blob;
34
- cache;
35
- markerCache = new Map();
36
- constructor(view, bytes, strtab, blob){
37
- this.view = view;
38
- this.bytes = bytes;
39
- this.strtab = strtab;
40
- this.blob = blob;
41
- this.cache = new Array(strtab.recordCount);
42
- }
43
- at(id) {
44
- if (id === 0) {
45
- return undefined;
46
- }
47
- if (id >= this.strtab.recordCount) {
48
- throw new Error(`sheet-window binary: string id ${id} out of range (${this.strtab.recordCount})`);
49
- }
50
- const cached = this.cache[id];
51
- if (cached !== undefined) {
52
- return cached;
53
- }
54
- const entryOffset = this.strtab.byteOffset + id * SHEET_WINDOW_STRTAB_ENTRY_BYTES;
55
- const blobOffset = this.view.getUint32(entryOffset, true);
56
- const byteLen = this.view.getUint32(entryOffset + 4, true);
57
- if (blobOffset + byteLen > this.blob.byteLen) {
58
- throw new Error(`sheet-window binary: string id ${id} escapes the blob section`);
59
- }
60
- const start = this.blob.byteOffset + blobOffset;
61
- const decoded = utf8Decoder.decode(this.bytes.subarray(start, start + byteLen));
62
- this.cache[id] = decoded;
63
- return decoded;
64
- }
65
- required(id, field) {
66
- const value = this.at(id);
67
- if (value === undefined) {
68
- throw new Error(`sheet-window binary: required string field ${field} was absent (id 0)`);
69
- }
70
- return value;
71
- }
72
- markers(id) {
73
- if (id === 0) {
74
- return [];
75
- }
76
- const cached = this.markerCache.get(id);
77
- if (cached !== undefined) {
78
- return cached;
79
- }
80
- const joined = this.required(id, "postureMarkers");
81
- const split = Object.freeze(joined.split(SHEET_WINDOW_MARKER_SEPARATOR));
82
- this.markerCache.set(id, split);
83
- return split;
84
- }
85
- }
86
- function defineLazy(target, key, compute, recover) {
87
- Object.defineProperty(target, key, {
88
- enumerable: true,
89
- configurable: true,
90
- get () {
91
- let value;
92
- try {
93
- value = compute();
94
- } catch (error) {
95
- const recovered = recover?.(error);
96
- if (recovered === undefined) {
97
- throw error;
98
- }
99
- value = recovered.value;
100
- }
101
- Object.defineProperty(target, key, {
102
- enumerable: true,
103
- configurable: true,
104
- writable: false,
105
- value
106
- });
107
- return value;
108
- }
109
- });
110
- }
111
- const SHEET_WINDOW_VERTICAL_ALIGNMENTS = [
112
- undefined,
113
- "top",
114
- "middle",
115
- "bottom"
116
- ];
117
- const CellStr = {
118
- CellId: 0,
119
- DisplayText: 1,
120
- ValueKind: 2,
121
- FormulaText: 3,
122
- DisplayFingerprint: 4,
123
- StyleRef: 5,
124
- DisplayFormatPosture: 6,
125
- FormatCode: 7,
126
- FillColor: 8,
127
- FontColor: 9,
128
- FontName: 10,
129
- FontSizePoints: 11,
130
- DisplayTextColor: 12,
131
- HorizontalAlignment: 13,
132
- MergeRole: 14,
133
- Editability: 15
134
- };
135
- function requireSection(ctx, id, label) {
136
- const section = ctx.sections.get(id);
137
- if (!section) {
138
- throw new Error(`sheet-window binary: missing required section ${label} (${id})`);
139
- }
140
- return section;
141
- }
142
- function assertStride(section, expected, label) {
143
- if (section.recordCount === 0) {
144
- return;
145
- }
146
- if (section.recordCount * expected !== section.byteLen) {
147
- throw new Error(`sheet-window binary: section ${label} stride mismatch — ${section.byteLen} bytes for ${section.recordCount} records (expected ${expected} B/record)`);
148
- }
149
- }
150
- function decodeLineSection(ctx, sectionId, kind) {
151
- const label = kind === "row" ? "ROWS" : "COLS";
152
- const section = requireSection(ctx, sectionId, label);
153
- assertStride(section, SHEET_WINDOW_LINE_RECORD_BYTES, label);
154
- const { view, strings } = ctx;
155
- const out = new Array(section.recordCount);
156
- for(let i = 0; i < section.recordCount; i++){
157
- const o = section.byteOffset + i * SHEET_WINDOW_LINE_RECORD_BYTES;
158
- const line = view.getUint32(o, true);
159
- const metric = strings.required(view.getUint32(o + 4, true), kind === "row" ? "heightPoints" : "width");
160
- const precision = strings.required(view.getUint32(o + 8, true), "precision");
161
- const hiddenPosture = strings.at(view.getUint32(o + 12, true));
162
- const flags = view.getUint8(o + 16);
163
- const outlineRaw = view.getUint8(o + 17);
164
- out[i] = kind === "row" ? {
165
- row: line,
166
- heightPoints: metric,
167
- hidden: (flags & 0x01) !== 0,
168
- customHeight: (flags & 0x02) !== 0,
169
- precision,
170
- outlineLevel: outlineRaw === SHEET_WINDOW_OUTLINE_NONE ? undefined : outlineRaw,
171
- collapsed: (flags & 0x04) !== 0,
172
- hiddenPosture
173
- } : {
174
- column: line,
175
- width: metric,
176
- hidden: (flags & 0x01) !== 0,
177
- customWidth: (flags & 0x02) !== 0,
178
- precision,
179
- outlineLevel: outlineRaw === SHEET_WINDOW_OUTLINE_NONE ? undefined : outlineRaw,
180
- collapsed: (flags & 0x04) !== 0,
181
- hiddenPosture
182
- };
183
- }
184
- return out;
185
- }
186
- function decodeCells(ctx) {
187
- const section = requireSection(ctx, SHEET_WINDOW_SECTION_CELLS, "CELLS");
188
- assertStride(section, SHEET_WINDOW_CELL_RECORD_BYTES, "CELLS");
189
- const { view, strings, rest } = ctx;
190
- const mergedRanges = rest.mergedRanges;
191
- const rareCells = rest.rareCells ?? [];
192
- const out = new Array(section.recordCount);
193
- for(let i = 0; i < section.recordCount; i++){
194
- const o = section.byteOffset + i * SHEET_WINDOW_CELL_RECORD_BYTES;
195
- const str = (slot)=>view.getUint32(o + 8 + slot * 4, true);
196
- const numFmtRaw = view.getUint32(o + 72, true);
197
- const flags = view.getUint16(o + 76, true);
198
- const mergedRangeIdx = view.getUint32(o + 80, true);
199
- const rareIdx = view.getUint32(o + 84, true);
200
- const markersId = view.getUint32(o + 88, true);
201
- const rare = rareIdx === SHEET_WINDOW_U32_NONE ? undefined : rareCells[rareIdx];
202
- if (rareIdx !== SHEET_WINDOW_U32_NONE && rare === undefined) {
203
- throw new Error(`sheet-window binary: cell ${i} references missing rareCells[${rareIdx}]`);
204
- }
205
- const merged = mergedRangeIdx === SHEET_WINDOW_U32_NONE ? undefined : mergedRanges[mergedRangeIdx];
206
- if (mergedRangeIdx !== SHEET_WINDOW_U32_NONE && merged === undefined) {
207
- throw new Error(`sheet-window binary: cell ${i} references missing mergedRanges[${mergedRangeIdx}]`);
208
- }
209
- const cell = {
210
- address: {
211
- row: view.getUint32(o, true),
212
- column: view.getUint32(o + 4, true)
213
- },
214
- cellId: strings.at(str(CellStr.CellId)),
215
- selectionHandle: rare?.selectionHandle,
216
- displayText: strings.at(str(CellStr.DisplayText)),
217
- valueKind: strings.at(str(CellStr.ValueKind)),
218
- formulaText: strings.at(str(CellStr.FormulaText)),
219
- displayFingerprint: strings.at(str(CellStr.DisplayFingerprint)),
220
- styleRef: strings.at(str(CellStr.StyleRef)),
221
- displayFormatPosture: strings.at(str(CellStr.DisplayFormatPosture)),
222
- numFmtId: numFmtRaw === SHEET_WINDOW_U32_NONE ? undefined : numFmtRaw,
223
- formatCode: strings.at(str(CellStr.FormatCode)),
224
- bold: (flags & 0x0001) !== 0,
225
- italic: (flags & 0x0002) !== 0,
226
- underline: (flags & 0x0004) !== 0
227
- };
228
- const fillColor = strings.at(str(CellStr.FillColor));
229
- if (fillColor !== undefined) cell.fillColor = fillColor;
230
- const fontColor = strings.at(str(CellStr.FontColor));
231
- if (fontColor !== undefined) cell.fontColor = fontColor;
232
- const fontName = strings.at(str(CellStr.FontName));
233
- if (fontName !== undefined) cell.fontName = fontName;
234
- const fontSizePoints = strings.at(str(CellStr.FontSizePoints));
235
- if (fontSizePoints !== undefined) cell.fontSizePoints = fontSizePoints;
236
- const displayTextColor = strings.at(str(CellStr.DisplayTextColor));
237
- if (displayTextColor !== undefined) cell.displayTextColor = displayTextColor;
238
- const horizontalAlignment = strings.at(str(CellStr.HorizontalAlignment));
239
- if (horizontalAlignment !== undefined) cell.horizontalAlignment = horizontalAlignment;
240
- const verticalAlignment = SHEET_WINDOW_VERTICAL_ALIGNMENTS[flags >> 8 & 0x03];
241
- if (verticalAlignment !== undefined) cell.verticalAlignment = verticalAlignment;
242
- if ((flags & 0x0008) !== 0) cell.wrapText = true;
243
- if ((flags & 0x0010) !== 0) cell.borderTop = true;
244
- if ((flags & 0x0020) !== 0) cell.borderRight = true;
245
- if ((flags & 0x0040) !== 0) cell.borderBottom = true;
246
- if ((flags & 0x0080) !== 0) cell.borderLeft = true;
247
- cell.mergeRole = strings.required(str(CellStr.MergeRole), "mergeRole");
248
- cell.mergeOwner = merged ? {
249
- ...merged.owner
250
- } : undefined;
251
- cell.mergeRange = merged ? {
252
- start: {
253
- ...merged.sourceRange.start
254
- },
255
- end: {
256
- ...merged.sourceRange.end
257
- }
258
- } : undefined;
259
- cell.editability = strings.required(str(CellStr.Editability), "editability");
260
- cell.blockers = rare?.blockers ? [
261
- ...rare.blockers
262
- ] : [];
263
- cell.postureMarkers = rare?.postureMarkers ?? strings.markers(markersId);
264
- if (rare?.hyperlink !== undefined) cell.hyperlink = rare.hyperlink;
265
- out[i] = cell;
266
- }
267
- return out;
268
- }
269
- function decodePaintLines(ctx, sectionId, kind) {
270
- const label = kind === "row" ? "PAINT_ROWS" : "PAINT_COLS";
271
- const section = requireSection(ctx, sectionId, label);
272
- assertStride(section, SHEET_WINDOW_PAINT_LINE_RECORD_BYTES, label);
273
- const { view, strings } = ctx;
274
- const out = new Array(section.recordCount);
275
- for(let i = 0; i < section.recordCount; i++){
276
- const o = section.byteOffset + i * SHEET_WINDOW_PAINT_LINE_RECORD_BYTES;
277
- const line = view.getUint32(o, true);
278
- const precision = strings.required(view.getUint32(o + 4, true), "precision");
279
- const hidden = (view.getUint8(o + 8) & 0x01) !== 0;
280
- const offsetPx = view.getFloat64(o + 16, true);
281
- const sizePx = view.getFloat64(o + 24, true);
282
- out[i] = kind === "row" ? {
283
- row: line,
284
- offsetPx,
285
- sizePx,
286
- hidden,
287
- precision
288
- } : {
289
- column: line,
290
- offsetPx,
291
- sizePx,
292
- hidden,
293
- precision
294
- };
295
- }
296
- return out;
297
- }
298
- function decodeRects(ctx) {
299
- const section = requireSection(ctx, SHEET_WINDOW_SECTION_RECTS, "RECTS");
300
- assertStride(section, SHEET_WINDOW_RECT_RECORD_BYTES, "RECTS");
301
- const { view, strings } = ctx;
302
- const out = new Array(section.recordCount);
303
- for(let i = 0; i < section.recordCount; i++){
304
- const o = section.byteOffset + i * SHEET_WINDOW_RECT_RECORD_BYTES;
305
- const kind = strings.required(view.getUint32(o + 32, true), "coordinateSpace.kind");
306
- const region = strings.at(view.getUint32(o + 36, true));
307
- out[i] = {
308
- xPx: view.getFloat64(o, true),
309
- yPx: view.getFloat64(o + 8, true),
310
- widthPx: view.getFloat64(o + 16, true),
311
- heightPx: view.getFloat64(o + 24, true),
312
- coordinateSpace: region === undefined ? {
313
- kind
314
- } : {
315
- kind,
316
- region
317
- },
318
- precision: strings.required(view.getUint32(o + 40, true), "precision")
319
- };
320
- }
321
- return out;
322
- }
323
- function decodePaintCells(ctx, rects) {
324
- const section = requireSection(ctx, SHEET_WINDOW_SECTION_PAINT_CELLS, "PAINT_CELLS");
325
- assertStride(section, SHEET_WINDOW_PAINT_CELL_RECORD_BYTES, "PAINT_CELLS");
326
- const { view, strings } = ctx;
327
- const out = new Array(section.recordCount);
328
- for(let i = 0; i < section.recordCount; i++){
329
- const o = section.byteOffset + i * SHEET_WINDOW_PAINT_CELL_RECORD_BYTES;
330
- const rectStart = view.getUint32(o + 8, true);
331
- const rectCount = view.getUint16(o + 12, true);
332
- if (rectStart + rectCount > rects.length) {
333
- throw new Error(`sheet-window binary: paint cell ${i} references rects beyond the pool`);
334
- }
335
- const ownerRow = view.getUint32(o + 20, true);
336
- const ownerCol = view.getUint32(o + 24, true);
337
- out[i] = {
338
- address: {
339
- row: view.getUint32(o, true),
340
- column: view.getUint32(o + 4, true)
341
- },
342
- rects: rects.slice(rectStart, rectStart + rectCount),
343
- hidden: (view.getUint8(o + 14) & 0x01) !== 0,
344
- precision: strings.required(view.getUint32(o + 16, true), "precision"),
345
- mergeOwner: ownerRow === SHEET_WINDOW_U32_NONE ? undefined : {
346
- row: ownerRow,
347
- column: ownerCol
348
- }
349
- };
350
- }
351
- return out;
352
- }
353
- export function decodeSheetWindowBinary(env, options) {
354
- if (env.schemaId !== SHEET_WINDOW_BINARY_SCHEMA_ID) {
355
- throw new Error(`sheet-window binary: unknown schemaId ${env.schemaId}`);
356
- }
357
- let bytes = env.bytes instanceof Uint8Array ? env.bytes : Uint8Array.from(env.bytes);
358
- const backing = bytes.buffer;
359
- const plainFixedBacking = backing instanceof ArrayBuffer && backing.resizable !== true;
360
- if (!plainFixedBacking || bytes.byteOffset !== 0 || bytes.byteLength !== backing.byteLength) {
361
- bytes = bytes.slice();
362
- }
363
- if (bytes.byteLength < SHEET_WINDOW_BINARY_HEADER_BYTES) {
364
- throw new Error(`sheet-window binary: truncated header (${bytes.byteLength} bytes)`);
365
- }
366
- const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
367
- if (view.getUint32(0, true) !== SHEET_WINDOW_BINARY_MAGIC) {
368
- throw new Error("sheet-window binary: bad magic (expected XSW1 little-endian)");
369
- }
370
- const version = view.getUint16(4, true);
371
- if (version !== SHEET_WINDOW_BINARY_VERSION) {
372
- throw new Error(`sheet-window binary: unsupported version ${version}`);
373
- }
374
- const flags = view.getUint16(6, true);
375
- const sectionCount = view.getUint32(8, true);
376
- const totalByteLen = view.getUint32(12, true);
377
- if (totalByteLen > bytes.byteLength) {
378
- throw new Error(`sheet-window binary: totalByteLen ${totalByteLen} exceeds buffer ${bytes.byteLength}`);
379
- }
380
- const tableEnd = SHEET_WINDOW_BINARY_HEADER_BYTES + sectionCount * SHEET_WINDOW_BINARY_SECTION_ENTRY_BYTES;
381
- if (tableEnd > totalByteLen) {
382
- throw new Error("sheet-window binary: section table escapes the buffer");
383
- }
384
- const sections = new Map();
385
- for(let i = 0; i < sectionCount; i++){
386
- const o = SHEET_WINDOW_BINARY_HEADER_BYTES + i * SHEET_WINDOW_BINARY_SECTION_ENTRY_BYTES;
387
- const sectionId = view.getUint32(o, true);
388
- const byteOffset = view.getUint32(o + 4, true);
389
- const byteLen = view.getUint32(o + 8, true);
390
- if (byteOffset + byteLen > totalByteLen) {
391
- throw new Error(`sheet-window binary: section ${sectionId} escapes the buffer`);
392
- }
393
- sections.set(sectionId, {
394
- byteOffset,
395
- byteLen,
396
- recordCount: view.getUint32(o + 12, true)
397
- });
398
- }
399
- const strtab = sections.get(SHEET_WINDOW_SECTION_STRTAB);
400
- const blob = sections.get(SHEET_WINDOW_SECTION_STRBLOB);
401
- if (!strtab || !blob) {
402
- throw new Error("sheet-window binary: missing required string sections (STRTAB/STRBLOB)");
403
- }
404
- assertStride(strtab, SHEET_WINDOW_STRTAB_ENTRY_BYTES, "STRTAB");
405
- const strings = new SheetWindowStringTable(view, bytes, strtab, blob);
406
- const rest = env.rest;
407
- const ctx = {
408
- view,
409
- strings,
410
- sections,
411
- rest
412
- };
413
- const paintGeometryPresent = (flags & SHEET_WINDOW_FLAG_PAINT_GEOMETRY) !== 0;
414
- const { rareCells: _rareCells, paintGeometryPresent: _pgPresent, paintGeometryActiveSelection, paintGeometryObjects, paintGeometrySparklines, paintGeometry: nestedPaintGeometry, encodeMs: _encodeMs, ...readbackRest } = rest;
415
- const onSectionDecodeError = options?.onSectionDecodeError;
416
- const recoverSection = onSectionDecodeError ? (key)=>(error)=>{
417
- const substitute = onSectionDecodeError(error);
418
- return substitute === undefined ? undefined : {
419
- value: substitute[key]
420
- };
421
- } : undefined;
422
- const out = {
423
- ...readbackRest
424
- };
425
- const defineLazySection = (key, compute)=>{
426
- defineLazy(out, key, compute, recoverSection?.(key));
427
- };
428
- defineLazySection("rows", ()=>decodeLineSection(ctx, SHEET_WINDOW_SECTION_ROWS, "row"));
429
- defineLazySection("columns", ()=>decodeLineSection(ctx, SHEET_WINDOW_SECTION_COLS, "column"));
430
- defineLazySection("cells", ()=>decodeCells(ctx));
431
- defineLazySection("paintGeometry", ()=>{
432
- if (!paintGeometryPresent) {
433
- return undefined;
434
- }
435
- const rects = decodeRects(ctx);
436
- const geometry = {
437
- rows: decodePaintLines(ctx, SHEET_WINDOW_SECTION_PAINT_ROWS, "row"),
438
- columns: decodePaintLines(ctx, SHEET_WINDOW_SECTION_PAINT_COLS, "column"),
439
- cells: decodePaintCells(ctx, rects),
440
- activeSelection: nestedPaintGeometry?.activeSelection ?? paintGeometryActiveSelection,
441
- objects: nestedPaintGeometry?.objects ?? paintGeometryObjects ?? [],
442
- sparklines: nestedPaintGeometry?.sparklines ?? paintGeometrySparklines ?? []
443
- };
444
- return geometry;
445
- });
446
- return out;
447
- }
448
- export function createSheetWindowDecodedReader(deps) {
449
- let disabled = false;
450
- const warn = deps.warn ?? ((message, error)=>{
451
- console.warn(message, error instanceof Error ? error.message : error);
452
- });
453
- const disable = (error)=>{
454
- if (disabled) {
455
- return;
456
- }
457
- disabled = true;
458
- warn(`xlsx ${SHEET_WINDOW_BINARY_SCHEMA_ID} decode failed; permanently falling back to the JSON sheet-window export for this bridge instance:`, error);
459
- };
460
- return (...args)=>{
461
- const readBinary = deps.readBinary;
462
- if (readBinary && !disabled) {
463
- let recovered;
464
- try {
465
- return decodeSheetWindowBinary(readBinary(...args), {
466
- onSectionDecodeError: (error)=>{
467
- disable(error);
468
- try {
469
- recovered ??= deps.readJson(...args);
470
- return recovered;
471
- } catch {
472
- return undefined;
473
- }
474
- }
475
- });
476
- } catch (error) {
477
- disable(error);
478
- }
479
- }
480
- return deps.readJson(...args);
481
- };
482
- }
@@ -1,45 +0,0 @@
1
-
2
- const _fmtCache = new Map();
3
- function getFormatter(tz) {
4
- let f = _fmtCache.get(tz);
5
- if (!f) {
6
- f = new Intl.DateTimeFormat('en-US', {
7
- timeZone: tz, year: 'numeric', month: '2-digit', day: '2-digit',
8
- hour: '2-digit', minute: '2-digit', second: '2-digit', hourCycle: 'h23'
9
- });
10
- _fmtCache.set(tz, f);
11
- }
12
- return f;
13
- }
14
- function ic_tz_validate(name) {
15
- try { getFormatter(name); return true; }
16
- catch(_) { return false; }
17
- }
18
- function ic_tz_all() {
19
- try {
20
- const list = Intl.supportedValuesOf('timeZone');
21
-
22
- const zones = new Set(list);
23
-
24
- const extras = [ 'UTC', 'GMT' ];
25
-
26
- for (const tz of extras) {
27
- zones.add(tz);
28
- }
29
-
30
- return Array.from(zones);
31
- } catch(e) {
32
- // no support
33
- console.log(e);
34
- return [ ];
35
- }
36
- }
37
- function ic_tz_parts(ms, tz) {
38
- const p = {};
39
- for (const x of getFormatter(tz).formatToParts(new Date(ms))) p[x.type] = x.value | 0;
40
- return [p.year, p.month, p.day, p.hour, p.minute, p.second];
41
- }
42
-
43
- exports.ic_tz_validate = ic_tz_validate;
44
- exports.ic_tz_all = ic_tz_all;
45
- exports.ic_tz_parts = ic_tz_parts;