@bilig/xlsx 0.164.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 (83) hide show
  1. package/README.md +25 -0
  2. package/dist/address.d.ts +15 -0
  3. package/dist/address.js +82 -0
  4. package/dist/address.js.map +1 -0
  5. package/dist/external-workbook-types.d.ts +44 -0
  6. package/dist/external-workbook-types.js +12 -0
  7. package/dist/external-workbook-types.js.map +1 -0
  8. package/dist/file-source.d.ts +10 -0
  9. package/dist/file-source.js +76 -0
  10. package/dist/file-source.js.map +1 -0
  11. package/dist/formula-cache-reader.d.ts +30 -0
  12. package/dist/formula-cache-reader.js +350 -0
  13. package/dist/formula-cache-reader.js.map +1 -0
  14. package/dist/index.d.ts +17 -0
  15. package/dist/index.js +18 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/simple-workbook-writer.d.ts +114 -0
  18. package/dist/simple-workbook-writer.js +621 -0
  19. package/dist/simple-workbook-writer.js.map +1 -0
  20. package/dist/source-preserving-literal-patches.d.ts +43 -0
  21. package/dist/source-preserving-literal-patches.js +615 -0
  22. package/dist/source-preserving-literal-patches.js.map +1 -0
  23. package/dist/source-preserving-zip.d.ts +25 -0
  24. package/dist/source-preserving-zip.js +341 -0
  25. package/dist/source-preserving-zip.js.map +1 -0
  26. package/dist/streaming-native-cell-arena.d.ts +57 -0
  27. package/dist/streaming-native-cell-arena.js +233 -0
  28. package/dist/streaming-native-cell-arena.js.map +1 -0
  29. package/dist/streaming-native-external-cache.d.ts +13 -0
  30. package/dist/streaming-native-external-cache.js +753 -0
  31. package/dist/streaming-native-external-cache.js.map +1 -0
  32. package/dist/streaming-native-inspect.d.ts +42 -0
  33. package/dist/streaming-native-inspect.js +297 -0
  34. package/dist/streaming-native-inspect.js.map +1 -0
  35. package/dist/streaming-native-lookup-wasm.d.ts +13 -0
  36. package/dist/streaming-native-lookup-wasm.js +250 -0
  37. package/dist/streaming-native-lookup-wasm.js.map +1 -0
  38. package/dist/streaming-native-recalc-evaluator.d.ts +17 -0
  39. package/dist/streaming-native-recalc-evaluator.js +743 -0
  40. package/dist/streaming-native-recalc-evaluator.js.map +1 -0
  41. package/dist/streaming-native-recalc.d.ts +97 -0
  42. package/dist/streaming-native-recalc.js +652 -0
  43. package/dist/streaming-native-recalc.js.map +1 -0
  44. package/dist/streaming-native-row-chain-conditionals.d.ts +8 -0
  45. package/dist/streaming-native-row-chain-conditionals.js +385 -0
  46. package/dist/streaming-native-row-chain-conditionals.js.map +1 -0
  47. package/dist/streaming-native-row-chain-dependencies.d.ts +17 -0
  48. package/dist/streaming-native-row-chain-dependencies.js +365 -0
  49. package/dist/streaming-native-row-chain-dependencies.js.map +1 -0
  50. package/dist/streaming-native-row-chain-references.d.ts +3 -0
  51. package/dist/streaming-native-row-chain-references.js +36 -0
  52. package/dist/streaming-native-row-chain-references.js.map +1 -0
  53. package/dist/streaming-native-row-chain-wasm.d.ts +56 -0
  54. package/dist/streaming-native-row-chain-wasm.js +546 -0
  55. package/dist/streaming-native-row-chain-wasm.js.map +1 -0
  56. package/dist/streaming-native-text.d.ts +2 -0
  57. package/dist/streaming-native-text.js +14 -0
  58. package/dist/streaming-native-text.js.map +1 -0
  59. package/dist/streaming-native-workbook-core.d.ts +47 -0
  60. package/dist/streaming-native-workbook-core.js +110 -0
  61. package/dist/streaming-native-workbook-core.js.map +1 -0
  62. package/dist/targeted-cell-reader.d.ts +11 -0
  63. package/dist/targeted-cell-reader.js +92 -0
  64. package/dist/targeted-cell-reader.js.map +1 -0
  65. package/dist/workbook-cell-reader.d.ts +29 -0
  66. package/dist/workbook-cell-reader.js +200 -0
  67. package/dist/workbook-cell-reader.js.map +1 -0
  68. package/dist/workbook-compatibility-report.d.ts +101 -0
  69. package/dist/workbook-compatibility-report.js +654 -0
  70. package/dist/workbook-compatibility-report.js.map +1 -0
  71. package/dist/workbook-sheet-paths.d.ts +8 -0
  72. package/dist/workbook-sheet-paths.js +79 -0
  73. package/dist/workbook-sheet-paths.js.map +1 -0
  74. package/dist/xml-part-patch.d.ts +12 -0
  75. package/dist/xml-part-patch.js +45 -0
  76. package/dist/xml-part-patch.js.map +1 -0
  77. package/dist/xml.d.ts +9 -0
  78. package/dist/xml.js +42 -0
  79. package/dist/xml.js.map +1 -0
  80. package/dist/zip-reader.d.ts +51 -0
  81. package/dist/zip-reader.js +448 -0
  82. package/dist/zip-reader.js.map +1 -0
  83. package/package.json +113 -0
@@ -0,0 +1,25 @@
1
+ type SourcePreservingZip = Record<string, Uint8Array>;
2
+ export interface PreparedZipEntrySizes {
3
+ readonly compressedSize: number;
4
+ readonly uncompressedSize: number;
5
+ readonly crc: number;
6
+ }
7
+ export interface PreparedZipEntry extends PreparedZipEntrySizes {
8
+ readonly compressedChunks: readonly Uint8Array[];
9
+ }
10
+ export interface FilePreparedZipEntry extends PreparedZipEntrySizes {
11
+ readonly compressedPath: string;
12
+ }
13
+ export interface ZipDosTimeParts {
14
+ readonly time: number;
15
+ readonly date: number;
16
+ }
17
+ export interface SourcePreservingZipOptions {
18
+ readonly dosTime?: ZipDosTimeParts;
19
+ }
20
+ export declare function crc32Update(crc: number, bytes: Uint8Array): number;
21
+ export declare function crc32Finalize(crc: number): number;
22
+ export declare function zipSourcePreservingEntries(zip: SourcePreservingZip, preparedEntries?: ReadonlyMap<string, PreparedZipEntry>, options?: SourcePreservingZipOptions): Uint8Array;
23
+ export declare function writeAllSync(fd: number, chunk: Uint8Array): void;
24
+ export declare function zipSourcePreservingEntriesToFile(zip: SourcePreservingZip, preparedEntries: ReadonlyMap<string, FilePreparedZipEntry>, outputPath: string, options?: SourcePreservingZipOptions): number;
25
+ export {};
@@ -0,0 +1,341 @@
1
+ import { closeSync, openSync, readSync, writeSync } from 'node:fs';
2
+ import { deflateRawSync } from 'node:zlib';
3
+ import { readLazyXlsxZipEntryCompressedSource } from './zip-reader.js';
4
+ const zipLocalFileHeaderSignature = 0x04034b50;
5
+ const zipCentralDirectoryFileHeaderSignature = 0x02014b50;
6
+ const zipEndOfCentralDirectorySignature = 0x06054b50;
7
+ const zipDeflateCompressionMethod = 8;
8
+ const zipVersionNeeded = 20;
9
+ const zipSourceCopyChunkSize = 1024 * 1024;
10
+ const zipTextEncoder = new TextEncoder();
11
+ let crc32Table;
12
+ function writeUint16(output, offset, value) {
13
+ output[offset] = value & 0xff;
14
+ output[offset + 1] = (value >>> 8) & 0xff;
15
+ }
16
+ function writeUint32(output, offset, value) {
17
+ output[offset] = value & 0xff;
18
+ output[offset + 1] = (value >>> 8) & 0xff;
19
+ output[offset + 2] = (value >>> 16) & 0xff;
20
+ output[offset + 3] = (value >>> 24) & 0xff;
21
+ }
22
+ function currentZipDosTimeParts() {
23
+ const now = new Date();
24
+ const year = Math.max(1980, Math.min(2099, now.getFullYear()));
25
+ return {
26
+ time: (now.getHours() << 11) | (now.getMinutes() << 5) | Math.trunc(now.getSeconds() / 2),
27
+ date: ((year - 1980) << 9) | ((now.getMonth() + 1) << 5) | now.getDate(),
28
+ };
29
+ }
30
+ function getCrc32Table() {
31
+ if (crc32Table) {
32
+ return crc32Table;
33
+ }
34
+ const table = new Uint32Array(256);
35
+ for (let index = 0; index < table.length; index += 1) {
36
+ let value = index;
37
+ for (let bit = 0; bit < 8; bit += 1) {
38
+ value = (value & 1) === 1 ? 0xedb88320 ^ (value >>> 1) : value >>> 1;
39
+ }
40
+ table[index] = value >>> 0;
41
+ }
42
+ crc32Table = table;
43
+ return table;
44
+ }
45
+ function crc32(bytes) {
46
+ return crc32Finalize(crc32Update(0xffffffff, bytes));
47
+ }
48
+ export function crc32Update(crc, bytes) {
49
+ const table = getCrc32Table();
50
+ let nextCrc = crc;
51
+ for (const byte of bytes) {
52
+ nextCrc = table[(nextCrc ^ byte) & 0xff] ^ (nextCrc >>> 8);
53
+ }
54
+ return nextCrc >>> 0;
55
+ }
56
+ export function crc32Finalize(crc) {
57
+ return (crc ^ 0xffffffff) >>> 0;
58
+ }
59
+ function deflateZipEntry(bytes) {
60
+ return deflateRawSync(bytes);
61
+ }
62
+ function encodeZipPath(path) {
63
+ const bytes = zipTextEncoder.encode(path);
64
+ if (bytes.byteLength > 0xffff) {
65
+ throw new Error('XLSX ZIP entry path is too long');
66
+ }
67
+ return { bytes, utf8: bytes.byteLength !== path.length };
68
+ }
69
+ function assertZip32Size(value) {
70
+ if (!Number.isSafeInteger(value) || value < 0 || value > 0xffffffff) {
71
+ throw new Error('XLSX ZIP entry is too large for source-preserving export');
72
+ }
73
+ }
74
+ function totalByteLength(chunks) {
75
+ let total = 0;
76
+ for (const chunk of chunks) {
77
+ total += chunk.byteLength;
78
+ }
79
+ return total;
80
+ }
81
+ function readUnmaterializedSourceEntry(zip, path) {
82
+ const descriptor = Object.getOwnPropertyDescriptor(zip, path);
83
+ if (!descriptor || typeof descriptor.get !== 'function') {
84
+ return null;
85
+ }
86
+ return readLazyXlsxZipEntryCompressedSource(zip, path);
87
+ }
88
+ function compressedSourceEntryChunks(entry) {
89
+ if (entry.dataEnd - entry.dataStart !== entry.compressedSize) {
90
+ throw new Error('Invalid XLSX source ZIP compressed data length');
91
+ }
92
+ const chunks = [];
93
+ for (let offset = entry.dataStart; offset < entry.dataEnd; offset += zipSourceCopyChunkSize) {
94
+ chunks.push(entry.source.readRange(offset, Math.min(entry.dataEnd, offset + zipSourceCopyChunkSize)));
95
+ }
96
+ return chunks;
97
+ }
98
+ function readSourceRange(source, start, end, scratch) {
99
+ const length = end - start;
100
+ if (!scratch || !source.readRangeInto || length > scratch.byteLength) {
101
+ return source.readRange(start, end);
102
+ }
103
+ const chunk = source.readRangeInto(start, end, scratch);
104
+ if (chunk.byteLength !== length) {
105
+ throw new Error('XLSX ZIP byte source returned an invalid chunk length');
106
+ }
107
+ return chunk;
108
+ }
109
+ function copyCompressedSourceEntryToZipOutput(entry, pushOutput) {
110
+ if (entry.dataEnd - entry.dataStart !== entry.compressedSize) {
111
+ throw new Error('Invalid XLSX source ZIP compressed data length');
112
+ }
113
+ const scratch = entry.source.readRangeInto ? new Uint8Array(zipSourceCopyChunkSize) : undefined;
114
+ for (let offset = entry.dataStart; offset < entry.dataEnd; offset += zipSourceCopyChunkSize) {
115
+ pushOutput(readSourceRange(entry.source, offset, Math.min(entry.dataEnd, offset + zipSourceCopyChunkSize), scratch));
116
+ }
117
+ }
118
+ function localFileHeader(record, time, date) {
119
+ const output = new Uint8Array(30 + record.pathBytes.byteLength);
120
+ writeUint32(output, 0, zipLocalFileHeaderSignature);
121
+ writeUint16(output, 4, zipVersionNeeded);
122
+ writeUint16(output, 6, record.flags | (record.utf8 ? 0x0800 : 0));
123
+ writeUint16(output, 8, record.compressionMethod);
124
+ writeUint16(output, 10, time);
125
+ writeUint16(output, 12, date);
126
+ writeUint32(output, 14, record.crc);
127
+ writeUint32(output, 18, record.compressedSize);
128
+ writeUint32(output, 22, record.uncompressedSize);
129
+ writeUint16(output, 26, record.pathBytes.byteLength);
130
+ writeUint16(output, 28, 0);
131
+ output.set(record.pathBytes, 30);
132
+ return output;
133
+ }
134
+ function centralDirectoryHeader(record, time, date) {
135
+ const output = new Uint8Array(46 + record.pathBytes.byteLength);
136
+ writeUint32(output, 0, zipCentralDirectoryFileHeaderSignature);
137
+ writeUint16(output, 4, zipVersionNeeded);
138
+ writeUint16(output, 6, zipVersionNeeded);
139
+ writeUint16(output, 8, record.flags | (record.utf8 ? 0x0800 : 0));
140
+ writeUint16(output, 10, record.compressionMethod);
141
+ writeUint16(output, 12, time);
142
+ writeUint16(output, 14, date);
143
+ writeUint32(output, 16, record.crc);
144
+ writeUint32(output, 20, record.compressedSize);
145
+ writeUint32(output, 24, record.uncompressedSize);
146
+ writeUint16(output, 28, record.pathBytes.byteLength);
147
+ writeUint16(output, 30, 0);
148
+ writeUint16(output, 32, 0);
149
+ writeUint16(output, 34, 0);
150
+ writeUint16(output, 36, 0);
151
+ writeUint32(output, 38, 0);
152
+ writeUint32(output, 42, record.localHeaderOffset);
153
+ output.set(record.pathBytes, 46);
154
+ return output;
155
+ }
156
+ function endOfCentralDirectory(recordCount, centralDirectorySize, centralDirectoryOffset) {
157
+ if (recordCount > 0xffff) {
158
+ throw new Error('XLSX ZIP has too many entries for source-preserving export');
159
+ }
160
+ assertZip32Size(centralDirectorySize);
161
+ assertZip32Size(centralDirectoryOffset);
162
+ const output = new Uint8Array(22);
163
+ writeUint32(output, 0, zipEndOfCentralDirectorySignature);
164
+ writeUint16(output, 4, 0);
165
+ writeUint16(output, 6, 0);
166
+ writeUint16(output, 8, recordCount);
167
+ writeUint16(output, 10, recordCount);
168
+ writeUint32(output, 12, centralDirectorySize);
169
+ writeUint32(output, 16, centralDirectoryOffset);
170
+ writeUint16(output, 20, 0);
171
+ return output;
172
+ }
173
+ export function zipSourcePreservingEntries(zip, preparedEntries = new Map(), options = {}) {
174
+ const outputChunks = [];
175
+ let outputByteLength = 0;
176
+ const records = [];
177
+ const { time, date } = options.dosTime ?? currentZipDosTimeParts();
178
+ const pushOutput = (chunk) => {
179
+ outputChunks.push(chunk);
180
+ outputByteLength += chunk.byteLength;
181
+ };
182
+ const paths = [...new Set([...Object.keys(zip), ...preparedEntries.keys()])];
183
+ for (const path of paths) {
184
+ const preparedEntry = preparedEntries.get(path);
185
+ const sourceEntry = preparedEntry ? null : readUnmaterializedSourceEntry(zip, path);
186
+ const bytes = preparedEntry || sourceEntry ? undefined : zip[path];
187
+ if (!preparedEntry && !sourceEntry && !bytes) {
188
+ continue;
189
+ }
190
+ assertZip32Size(outputByteLength);
191
+ const uncompressedSize = preparedEntry?.uncompressedSize ?? sourceEntry?.uncompressedSize ?? bytes.byteLength;
192
+ const compressedChunks = preparedEntry?.compressedChunks ?? (sourceEntry ? compressedSourceEntryChunks(sourceEntry) : [deflateZipEntry(bytes)]);
193
+ const compressedSize = preparedEntry?.compressedSize ?? sourceEntry?.compressedSize ?? totalByteLength(compressedChunks);
194
+ const crc = preparedEntry?.crc ?? sourceEntry?.crc ?? crc32(bytes);
195
+ assertZip32Size(uncompressedSize);
196
+ assertZip32Size(compressedSize);
197
+ const { bytes: pathBytes, utf8 } = encodeZipPath(path);
198
+ const record = {
199
+ pathBytes,
200
+ utf8,
201
+ flags: 0,
202
+ compressionMethod: sourceEntry?.compressionMethod ?? zipDeflateCompressionMethod,
203
+ crc,
204
+ compressedSize,
205
+ uncompressedSize,
206
+ localHeaderOffset: outputByteLength,
207
+ };
208
+ pushOutput(localFileHeader(record, time, date));
209
+ for (const compressedChunk of compressedChunks) {
210
+ pushOutput(compressedChunk);
211
+ }
212
+ records.push(record);
213
+ delete zip[path];
214
+ }
215
+ const centralDirectoryOffset = outputByteLength;
216
+ for (const record of records) {
217
+ pushOutput(centralDirectoryHeader(record, time, date));
218
+ }
219
+ const centralDirectorySize = outputByteLength - centralDirectoryOffset;
220
+ pushOutput(endOfCentralDirectory(records.length, centralDirectorySize, centralDirectoryOffset));
221
+ const output = new Uint8Array(outputByteLength);
222
+ let offset = 0;
223
+ for (const chunk of outputChunks) {
224
+ output.set(chunk, offset);
225
+ offset += chunk.byteLength;
226
+ }
227
+ return output;
228
+ }
229
+ export function writeAllSync(fd, chunk) {
230
+ let offset = 0;
231
+ while (offset < chunk.byteLength) {
232
+ offset += writeSync(fd, chunk, offset, chunk.byteLength - offset);
233
+ }
234
+ }
235
+ export function zipSourcePreservingEntriesToFile(zip, preparedEntries, outputPath, options = {}) {
236
+ let outputByteLength = 0;
237
+ const records = [];
238
+ const { time, date } = options.dosTime ?? currentZipDosTimeParts();
239
+ const paths = [...new Set([...Object.keys(zip), ...preparedEntries.keys()])];
240
+ const fd = openSync(outputPath, 'w');
241
+ const pushOutput = (chunk) => {
242
+ writeAllSync(fd, chunk);
243
+ outputByteLength += chunk.byteLength;
244
+ };
245
+ try {
246
+ for (const path of paths) {
247
+ const preparedEntry = preparedEntries.get(path);
248
+ const sourceEntry = preparedEntry ? null : readUnmaterializedSourceEntry(zip, path);
249
+ const bytes = preparedEntry || sourceEntry ? undefined : zip[path];
250
+ if (!preparedEntry && !sourceEntry && !bytes) {
251
+ continue;
252
+ }
253
+ assertZip32Size(outputByteLength);
254
+ const { bytes: pathBytes, utf8 } = encodeZipPath(path);
255
+ const localHeaderOffset = outputByteLength;
256
+ if (preparedEntry) {
257
+ assertZip32Size(preparedEntry.uncompressedSize);
258
+ assertZip32Size(preparedEntry.compressedSize);
259
+ const record = {
260
+ pathBytes,
261
+ utf8,
262
+ flags: 0,
263
+ compressionMethod: zipDeflateCompressionMethod,
264
+ crc: preparedEntry.crc,
265
+ compressedSize: preparedEntry.compressedSize,
266
+ uncompressedSize: preparedEntry.uncompressedSize,
267
+ localHeaderOffset,
268
+ };
269
+ pushOutput(localFileHeader(record, time, date));
270
+ copyFileToZipOutput(preparedEntry.compressedPath, pushOutput);
271
+ records.push(record);
272
+ }
273
+ else if (sourceEntry) {
274
+ assertZip32Size(sourceEntry.uncompressedSize);
275
+ assertZip32Size(sourceEntry.compressedSize);
276
+ const record = {
277
+ pathBytes,
278
+ utf8,
279
+ flags: 0,
280
+ compressionMethod: sourceEntry.compressionMethod,
281
+ crc: sourceEntry.crc,
282
+ compressedSize: sourceEntry.compressedSize,
283
+ uncompressedSize: sourceEntry.uncompressedSize,
284
+ localHeaderOffset,
285
+ };
286
+ pushOutput(localFileHeader(record, time, date));
287
+ copyCompressedSourceEntryToZipOutput(sourceEntry, pushOutput);
288
+ records.push(record);
289
+ }
290
+ else {
291
+ const uncompressedSize = bytes.byteLength;
292
+ const compressed = deflateZipEntry(bytes);
293
+ const compressedSize = compressed.byteLength;
294
+ const crc = crc32(bytes);
295
+ assertZip32Size(uncompressedSize);
296
+ assertZip32Size(compressedSize);
297
+ const record = {
298
+ pathBytes,
299
+ utf8,
300
+ flags: 0,
301
+ compressionMethod: zipDeflateCompressionMethod,
302
+ crc,
303
+ compressedSize,
304
+ uncompressedSize,
305
+ localHeaderOffset,
306
+ };
307
+ pushOutput(localFileHeader(record, time, date));
308
+ pushOutput(compressed);
309
+ records.push(record);
310
+ }
311
+ delete zip[path];
312
+ }
313
+ const centralDirectoryOffset = outputByteLength;
314
+ for (const record of records) {
315
+ pushOutput(centralDirectoryHeader(record, time, date));
316
+ }
317
+ const centralDirectorySize = outputByteLength - centralDirectoryOffset;
318
+ pushOutput(endOfCentralDirectory(records.length, centralDirectorySize, centralDirectoryOffset));
319
+ }
320
+ finally {
321
+ closeSync(fd);
322
+ }
323
+ return outputByteLength;
324
+ }
325
+ function copyFileToZipOutput(path, pushOutput) {
326
+ const fd = openSync(path, 'r');
327
+ const scratch = new Uint8Array(64 * 1024);
328
+ try {
329
+ let bytesRead = 0;
330
+ do {
331
+ bytesRead = readSync(fd, scratch, 0, scratch.byteLength, null);
332
+ if (bytesRead > 0) {
333
+ pushOutput(scratch.subarray(0, bytesRead));
334
+ }
335
+ } while (bytesRead > 0);
336
+ }
337
+ finally {
338
+ closeSync(fd);
339
+ }
340
+ }
341
+ //# sourceMappingURL=source-preserving-zip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-preserving-zip.js","sourceRoot":"","sources":["../src/source-preserving-zip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAE1C,OAAO,EAAE,oCAAoC,EAA6D,MAAM,iBAAiB,CAAA;AAsCjI,MAAM,2BAA2B,GAAG,UAAU,CAAA;AAC9C,MAAM,sCAAsC,GAAG,UAAU,CAAA;AACzD,MAAM,iCAAiC,GAAG,UAAU,CAAA;AACpD,MAAM,2BAA2B,GAAG,CAAC,CAAA;AACrC,MAAM,gBAAgB,GAAG,EAAE,CAAA;AAC3B,MAAM,sBAAsB,GAAG,IAAI,GAAG,IAAI,CAAA;AAC1C,MAAM,cAAc,GAAG,IAAI,WAAW,EAAE,CAAA;AAExC,IAAI,UAAmC,CAAA;AAEvC,SAAS,WAAW,CAAC,MAAkB,EAAE,MAAc,EAAE,KAAa;IACpE,MAAM,CAAC,MAAM,CAAC,GA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5C,CAAC;QACH,CAAC,QAAQ,SAAS,GAAG,CAAC,EAAC;IACzB,CAAC;YAAS,CAAC;QACT,SAAS,CAAC,EAAE,CAAC,CAAA;IACf,CAAC;AACH,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { type CellValue } from '@bilig/protocol';
2
+ export interface StreamingNativeSharedStringReference {
3
+ readonly kind: 'shared-string';
4
+ readonly index: number;
5
+ }
6
+ export type StreamingNativePendingCellValue = CellValue | StreamingNativeSharedStringReference;
7
+ export interface StreamingNativePendingCellRow {
8
+ readonly size: number;
9
+ get(col: number): StreamingNativePendingCellValue | undefined;
10
+ entries(): IterableIterator<[number, StreamingNativePendingCellValue]>;
11
+ values(): IterableIterator<StreamingNativePendingCellValue>;
12
+ [Symbol.iterator](): IterableIterator<[number, StreamingNativePendingCellValue]>;
13
+ }
14
+ export interface StreamingNativeMutablePendingCellRow extends StreamingNativePendingCellRow {
15
+ set(col: number, value: StreamingNativePendingCellValue): this;
16
+ }
17
+ export interface StreamingNativePendingCellRows {
18
+ get(row: number): StreamingNativePendingCellRow | undefined;
19
+ entries(): IterableIterator<[number, StreamingNativePendingCellRow]>;
20
+ values(): IterableIterator<StreamingNativePendingCellRow>;
21
+ [Symbol.iterator](): IterableIterator<[number, StreamingNativePendingCellRow]>;
22
+ }
23
+ export interface StreamingNativeMutablePendingCellRows extends StreamingNativePendingCellRows {
24
+ get(row: number): StreamingNativeMutablePendingCellRow | undefined;
25
+ getOrCreate(row: number): StreamingNativeMutablePendingCellRow;
26
+ set(row: number, values: StreamingNativePendingCellRow): this;
27
+ clear(): void;
28
+ }
29
+ export declare class StreamingNativeSheetCellArena implements StreamingNativeMutablePendingCellRows {
30
+ private rowNumbers;
31
+ private columnNumbers;
32
+ private valueTags;
33
+ private numberValues;
34
+ private stringIds;
35
+ private errorCodes;
36
+ private stringValues;
37
+ private readonly slotsByRow;
38
+ private readonly rowViews;
39
+ private cellCount;
40
+ get(row: number): StreamingNativeMutablePendingCellRow | undefined;
41
+ getOrCreate(row: number): StreamingNativeMutablePendingCellRow;
42
+ set(row: number, values: StreamingNativePendingCellRow): this;
43
+ entries(): IterableIterator<[number, StreamingNativeMutablePendingCellRow]>;
44
+ values(): IterableIterator<StreamingNativeMutablePendingCellRow>;
45
+ [Symbol.iterator](): IterableIterator<[number, StreamingNativeMutablePendingCellRow]>;
46
+ clear(): void;
47
+ rowSize(row: number): number;
48
+ getCell(row: number, col: number): StreamingNativePendingCellValue | undefined;
49
+ setCell(row: number, col: number, value: StreamingNativePendingCellValue): void;
50
+ rowEntries(row: number): IterableIterator<[number, StreamingNativePendingCellValue]>;
51
+ rowValues(row: number): IterableIterator<StreamingNativePendingCellValue>;
52
+ private slotForCell;
53
+ private appendCell;
54
+ private ensureCapacity;
55
+ private storeValue;
56
+ private valueAtSlot;
57
+ }
@@ -0,0 +1,233 @@
1
+ import { ErrorCode, ValueTag } from '@bilig/protocol';
2
+ const storedCellTag = {
3
+ Empty: 0,
4
+ Number: 1,
5
+ Boolean: 2,
6
+ String: 3,
7
+ Error: 4,
8
+ SharedString: 5,
9
+ };
10
+ const errorCodeByStoredNumber = {
11
+ [ErrorCode.None]: ErrorCode.None,
12
+ [ErrorCode.Div0]: ErrorCode.Div0,
13
+ [ErrorCode.Ref]: ErrorCode.Ref,
14
+ [ErrorCode.Value]: ErrorCode.Value,
15
+ [ErrorCode.Name]: ErrorCode.Name,
16
+ [ErrorCode.NA]: ErrorCode.NA,
17
+ [ErrorCode.Cycle]: ErrorCode.Cycle,
18
+ [ErrorCode.Spill]: ErrorCode.Spill,
19
+ [ErrorCode.Blocked]: ErrorCode.Blocked,
20
+ [ErrorCode.Num]: ErrorCode.Num,
21
+ [ErrorCode.Field]: ErrorCode.Field,
22
+ [ErrorCode.Null]: ErrorCode.Null,
23
+ };
24
+ const initialCapacity = 64;
25
+ export class StreamingNativeSheetCellArena {
26
+ rowNumbers = new Int32Array(initialCapacity);
27
+ columnNumbers = new Int32Array(initialCapacity);
28
+ valueTags = new Uint8Array(initialCapacity);
29
+ numberValues = new Float64Array(initialCapacity);
30
+ stringIds = new Int32Array(initialCapacity);
31
+ errorCodes = new Int16Array(initialCapacity);
32
+ stringValues = [];
33
+ slotsByRow = new Map();
34
+ rowViews = new Map();
35
+ cellCount = 0;
36
+ get(row) {
37
+ return this.rowViews.get(row);
38
+ }
39
+ getOrCreate(row) {
40
+ let rowView = this.rowViews.get(row);
41
+ if (!rowView) {
42
+ rowView = new StreamingNativeCellRowView(this, row);
43
+ this.rowViews.set(row, rowView);
44
+ this.slotsByRow.set(row, []);
45
+ }
46
+ return rowView;
47
+ }
48
+ set(row, values) {
49
+ const target = this.getOrCreate(row);
50
+ for (const [col, value] of values.entries()) {
51
+ target.set(col, value);
52
+ }
53
+ return this;
54
+ }
55
+ *entries() {
56
+ for (const [row, rowView] of this.rowViews.entries()) {
57
+ yield [row, rowView];
58
+ }
59
+ }
60
+ values() {
61
+ return this.rowViews.values();
62
+ }
63
+ [Symbol.iterator]() {
64
+ return this.entries();
65
+ }
66
+ clear() {
67
+ for (let index = 0; index < this.cellCount; index += 1) {
68
+ this.stringValues[index] = undefined;
69
+ }
70
+ this.cellCount = 0;
71
+ this.slotsByRow.clear();
72
+ this.rowViews.clear();
73
+ }
74
+ rowSize(row) {
75
+ return this.slotsByRow.get(row)?.length ?? 0;
76
+ }
77
+ getCell(row, col) {
78
+ const slot = this.slotForCell(row, col);
79
+ return slot === undefined ? undefined : this.valueAtSlot(slot);
80
+ }
81
+ setCell(row, col, value) {
82
+ const slot = this.slotForCell(row, col) ?? this.appendCell(row, col);
83
+ this.storeValue(slot, value);
84
+ }
85
+ *rowEntries(row) {
86
+ for (const slot of this.slotsByRow.get(row) ?? []) {
87
+ yield [this.columnNumbers[slot], this.valueAtSlot(slot)];
88
+ }
89
+ }
90
+ *rowValues(row) {
91
+ for (const slot of this.slotsByRow.get(row) ?? []) {
92
+ yield this.valueAtSlot(slot);
93
+ }
94
+ }
95
+ slotForCell(row, col) {
96
+ const slots = this.slotsByRow.get(row);
97
+ if (!slots) {
98
+ return undefined;
99
+ }
100
+ return slots.find((slot) => this.columnNumbers[slot] === col);
101
+ }
102
+ appendCell(row, col) {
103
+ this.ensureCapacity(this.cellCount + 1);
104
+ const slot = this.cellCount;
105
+ this.cellCount += 1;
106
+ this.rowNumbers[slot] = row;
107
+ this.columnNumbers[slot] = col;
108
+ const slots = this.slotsByRow.get(row) ?? [];
109
+ slots.push(slot);
110
+ this.slotsByRow.set(row, slots);
111
+ if (!this.rowViews.has(row)) {
112
+ this.rowViews.set(row, new StreamingNativeCellRowView(this, row));
113
+ }
114
+ return slot;
115
+ }
116
+ ensureCapacity(requiredCapacity) {
117
+ if (requiredCapacity <= this.rowNumbers.length) {
118
+ return;
119
+ }
120
+ let nextCapacity = this.rowNumbers.length;
121
+ while (nextCapacity < requiredCapacity) {
122
+ nextCapacity *= 2;
123
+ }
124
+ this.rowNumbers = growInt32Array(this.rowNumbers, nextCapacity);
125
+ this.columnNumbers = growInt32Array(this.columnNumbers, nextCapacity);
126
+ this.valueTags = growUint8Array(this.valueTags, nextCapacity);
127
+ this.numberValues = growFloat64Array(this.numberValues, nextCapacity);
128
+ this.stringIds = growInt32Array(this.stringIds, nextCapacity);
129
+ this.errorCodes = growInt16Array(this.errorCodes, nextCapacity);
130
+ }
131
+ storeValue(slot, value) {
132
+ this.stringValues[slot] = undefined;
133
+ if (isSharedStringReference(value)) {
134
+ this.valueTags[slot] = storedCellTag.SharedString;
135
+ this.stringIds[slot] = value.index;
136
+ return;
137
+ }
138
+ switch (value.tag) {
139
+ case ValueTag.Empty:
140
+ this.valueTags[slot] = storedCellTag.Empty;
141
+ return;
142
+ case ValueTag.Number:
143
+ this.valueTags[slot] = storedCellTag.Number;
144
+ this.numberValues[slot] = value.value;
145
+ return;
146
+ case ValueTag.Boolean:
147
+ this.valueTags[slot] = storedCellTag.Boolean;
148
+ this.numberValues[slot] = value.value ? 1 : 0;
149
+ return;
150
+ case ValueTag.String:
151
+ this.valueTags[slot] = storedCellTag.String;
152
+ this.stringValues[slot] = value.value;
153
+ this.stringIds[slot] = value.stringId ?? 0;
154
+ return;
155
+ case ValueTag.Error:
156
+ this.valueTags[slot] = storedCellTag.Error;
157
+ this.errorCodes[slot] = value.code;
158
+ return;
159
+ }
160
+ }
161
+ valueAtSlot(slot) {
162
+ const tag = this.valueTags[slot] ?? storedCellTag.Empty;
163
+ switch (tag) {
164
+ case storedCellTag.Number:
165
+ return { tag: ValueTag.Number, value: this.numberValues[slot] };
166
+ case storedCellTag.Boolean:
167
+ return { tag: ValueTag.Boolean, value: this.numberValues[slot] === 1 };
168
+ case storedCellTag.String:
169
+ return { tag: ValueTag.String, value: this.stringValues[slot] ?? '', stringId: this.stringIds[slot] ?? 0 };
170
+ case storedCellTag.Error:
171
+ return { tag: ValueTag.Error, code: errorCodeForStoredCode(this.errorCodes[slot] ?? ErrorCode.Value) };
172
+ case storedCellTag.SharedString:
173
+ return { kind: 'shared-string', index: this.stringIds[slot] ?? 0 };
174
+ case storedCellTag.Empty:
175
+ default:
176
+ return { tag: ValueTag.Empty };
177
+ }
178
+ }
179
+ }
180
+ class StreamingNativeCellRowView {
181
+ arena;
182
+ row;
183
+ constructor(arena, row) {
184
+ this.arena = arena;
185
+ this.row = row;
186
+ }
187
+ get size() {
188
+ return this.arena.rowSize(this.row);
189
+ }
190
+ get(col) {
191
+ return this.arena.getCell(this.row, col);
192
+ }
193
+ set(col, value) {
194
+ this.arena.setCell(this.row, col, value);
195
+ return this;
196
+ }
197
+ entries() {
198
+ return this.arena.rowEntries(this.row);
199
+ }
200
+ values() {
201
+ return this.arena.rowValues(this.row);
202
+ }
203
+ [Symbol.iterator]() {
204
+ return this.entries();
205
+ }
206
+ }
207
+ function isSharedStringReference(value) {
208
+ return typeof value === 'object' && value !== null && 'kind' in value && value.kind === 'shared-string';
209
+ }
210
+ function errorCodeForStoredCode(code) {
211
+ return errorCodeByStoredNumber[code] ?? ErrorCode.Value;
212
+ }
213
+ function growInt32Array(source, length) {
214
+ const next = new Int32Array(length);
215
+ next.set(source);
216
+ return next;
217
+ }
218
+ function growInt16Array(source, length) {
219
+ const next = new Int16Array(length);
220
+ next.set(source);
221
+ return next;
222
+ }
223
+ function growUint8Array(source, length) {
224
+ const next = new Uint8Array(length);
225
+ next.set(source);
226
+ return next;
227
+ }
228
+ function growFloat64Array(source, length) {
229
+ const next = new Float64Array(length);
230
+ next.set(source);
231
+ return next;
232
+ }
233
+ //# sourceMappingURL=streaming-native-cell-arena.js.map