@truecalc/workbook 3.0.0 → 3.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.
package/package.json
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Result of [`translate_formula`]: either the rewritten `formula` text or an
|
|
5
|
+
* `error` message (mutually exclusive). Mirrors the `TranslateResult` shape
|
|
6
|
+
* exposed by the calc-only `@truecalc/core` WASM binding so both packages
|
|
7
|
+
* present the same reference-translation surface.
|
|
8
|
+
*/
|
|
9
|
+
export interface TranslateResult {
|
|
10
|
+
formula?: string;
|
|
11
|
+
error?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
3
14
|
|
|
4
15
|
/**
|
|
5
16
|
* A spreadsheet workbook exposed to JavaScript.
|
|
@@ -66,12 +77,43 @@ export class JsWorkbook {
|
|
|
66
77
|
* becomes a `Text` value.
|
|
67
78
|
*/
|
|
68
79
|
set(sheet: string, a1: string, input: string): void;
|
|
80
|
+
/**
|
|
81
|
+
* Sets the cell at `a1` on `sheet` to a **Date-typed** serial value.
|
|
82
|
+
*
|
|
83
|
+
* Unlike [`set`](Self::set) — which stores a numeric string as a plain
|
|
84
|
+
* `Number` — this stores `serial` as a `Date`, the type a host uses for a
|
|
85
|
+
* cell it means as a date. The engine's arithmetic type propagation then
|
|
86
|
+
* keeps it rendering as a date through offset arithmetic: `=A1+1` and
|
|
87
|
+
* `=A1-7` on a Date cell stay dates (`=A1-B1` between two Date cells is a
|
|
88
|
+
* plain day count, matching Google Sheets).
|
|
89
|
+
*
|
|
90
|
+
* The serial round-trips exactly — it is stored verbatim, never
|
|
91
|
+
* reconstructed via `DATE(y, m, d)` — so pre-1900 (negative) serials and
|
|
92
|
+
* fractional time-of-day components are preserved bit-for-bit.
|
|
93
|
+
*/
|
|
94
|
+
setDate(sheet: string, a1: string, serial: number): void;
|
|
69
95
|
/**
|
|
70
96
|
* Serializes the workbook to its canonical JSON string.
|
|
71
97
|
*/
|
|
72
98
|
toJSON(): string;
|
|
73
99
|
}
|
|
74
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Shift every relative cell/range reference in `formula` by `(dRow, dCol)` —
|
|
103
|
+
* the fill / copy-paste reference-adjustment transform — using the engine's
|
|
104
|
+
* authoritative parser instead of a re-implemented tokenizer.
|
|
105
|
+
*
|
|
106
|
+
* `$`-absolute axes stay fixed; range endpoints and cross-sheet refs adjust
|
|
107
|
+
* while the sheet name is preserved; references inside string literals and
|
|
108
|
+
* function names are never rewritten; a name bound by `LET`/`LAMBDA` is left
|
|
109
|
+
* untouched. An axis that shifts out of the grid becomes a literal `#REF!`
|
|
110
|
+
* for that corner.
|
|
111
|
+
*
|
|
112
|
+
* Sheets flavor only (Excel grid bounds are a follow-up); a parse error is
|
|
113
|
+
* surfaced in the `error` field.
|
|
114
|
+
*/
|
|
115
|
+
export function translateFormula(formula: string, d_row: number, d_col: number): TranslateResult;
|
|
116
|
+
|
|
75
117
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
76
118
|
|
|
77
119
|
export interface InitOutput {
|
|
@@ -86,10 +128,12 @@ export interface InitOutput {
|
|
|
86
128
|
readonly jsworkbook_redefineName: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
87
129
|
readonly jsworkbook_resolved: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
88
130
|
readonly jsworkbook_set: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
131
|
+
readonly jsworkbook_setDate: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
89
132
|
readonly jsworkbook_toJSON: (a: number, b: number) => void;
|
|
90
|
-
readonly
|
|
133
|
+
readonly translateFormula: (a: number, b: number, c: number, d: number) => number;
|
|
91
134
|
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
92
135
|
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
136
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
93
137
|
readonly __wbindgen_export3: (a: number, b: number, c: number) => void;
|
|
94
138
|
}
|
|
95
139
|
|
|
@@ -234,6 +234,40 @@ export class JsWorkbook {
|
|
|
234
234
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
|
+
/**
|
|
238
|
+
* Sets the cell at `a1` on `sheet` to a **Date-typed** serial value.
|
|
239
|
+
*
|
|
240
|
+
* Unlike [`set`](Self::set) — which stores a numeric string as a plain
|
|
241
|
+
* `Number` — this stores `serial` as a `Date`, the type a host uses for a
|
|
242
|
+
* cell it means as a date. The engine's arithmetic type propagation then
|
|
243
|
+
* keeps it rendering as a date through offset arithmetic: `=A1+1` and
|
|
244
|
+
* `=A1-7` on a Date cell stay dates (`=A1-B1` between two Date cells is a
|
|
245
|
+
* plain day count, matching Google Sheets).
|
|
246
|
+
*
|
|
247
|
+
* The serial round-trips exactly — it is stored verbatim, never
|
|
248
|
+
* reconstructed via `DATE(y, m, d)` — so pre-1900 (negative) serials and
|
|
249
|
+
* fractional time-of-day components are preserved bit-for-bit.
|
|
250
|
+
* @param {string} sheet
|
|
251
|
+
* @param {string} a1
|
|
252
|
+
* @param {number} serial
|
|
253
|
+
*/
|
|
254
|
+
setDate(sheet, a1, serial) {
|
|
255
|
+
try {
|
|
256
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
257
|
+
const ptr0 = passStringToWasm0(sheet, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
258
|
+
const len0 = WASM_VECTOR_LEN;
|
|
259
|
+
const ptr1 = passStringToWasm0(a1, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
260
|
+
const len1 = WASM_VECTOR_LEN;
|
|
261
|
+
wasm.jsworkbook_setDate(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, serial);
|
|
262
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
263
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
264
|
+
if (r1) {
|
|
265
|
+
throw takeObject(r0);
|
|
266
|
+
}
|
|
267
|
+
} finally {
|
|
268
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
237
271
|
/**
|
|
238
272
|
* Serializes the workbook to its canonical JSON string.
|
|
239
273
|
* @returns {string}
|
|
@@ -264,6 +298,31 @@ export class JsWorkbook {
|
|
|
264
298
|
}
|
|
265
299
|
}
|
|
266
300
|
if (Symbol.dispose) JsWorkbook.prototype[Symbol.dispose] = JsWorkbook.prototype.free;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Shift every relative cell/range reference in `formula` by `(dRow, dCol)` —
|
|
304
|
+
* the fill / copy-paste reference-adjustment transform — using the engine's
|
|
305
|
+
* authoritative parser instead of a re-implemented tokenizer.
|
|
306
|
+
*
|
|
307
|
+
* `$`-absolute axes stay fixed; range endpoints and cross-sheet refs adjust
|
|
308
|
+
* while the sheet name is preserved; references inside string literals and
|
|
309
|
+
* function names are never rewritten; a name bound by `LET`/`LAMBDA` is left
|
|
310
|
+
* untouched. An axis that shifts out of the grid becomes a literal `#REF!`
|
|
311
|
+
* for that corner.
|
|
312
|
+
*
|
|
313
|
+
* Sheets flavor only (Excel grid bounds are a follow-up); a parse error is
|
|
314
|
+
* surfaced in the `error` field.
|
|
315
|
+
* @param {string} formula
|
|
316
|
+
* @param {number} d_row
|
|
317
|
+
* @param {number} d_col
|
|
318
|
+
* @returns {TranslateResult}
|
|
319
|
+
*/
|
|
320
|
+
export function translateFormula(formula, d_row, d_col) {
|
|
321
|
+
const ptr0 = passStringToWasm0(formula, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
322
|
+
const len0 = WASM_VECTOR_LEN;
|
|
323
|
+
const ret = wasm.translateFormula(ptr0, len0, d_row, d_col);
|
|
324
|
+
return takeObject(ret);
|
|
325
|
+
}
|
|
267
326
|
function __wbg_get_imports() {
|
|
268
327
|
const import0 = {
|
|
269
328
|
__proto__: null,
|
|
@@ -271,14 +330,35 @@ function __wbg_get_imports() {
|
|
|
271
330
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
272
331
|
return addHeapObject(ret);
|
|
273
332
|
},
|
|
333
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
334
|
+
const ret = String(getObject(arg1));
|
|
335
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
336
|
+
const len1 = WASM_VECTOR_LEN;
|
|
337
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
338
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
339
|
+
},
|
|
274
340
|
__wbg___wbindgen_throw_6b64449b9b9ed33c: function(arg0, arg1) {
|
|
275
341
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
276
342
|
},
|
|
343
|
+
__wbg_new_aa8d0fa9762c29bd: function() {
|
|
344
|
+
const ret = new Object();
|
|
345
|
+
return addHeapObject(ret);
|
|
346
|
+
},
|
|
347
|
+
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
348
|
+
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
|
349
|
+
},
|
|
277
350
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
278
351
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
279
352
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
280
353
|
return addHeapObject(ret);
|
|
281
354
|
},
|
|
355
|
+
__wbindgen_object_clone_ref: function(arg0) {
|
|
356
|
+
const ret = getObject(arg0);
|
|
357
|
+
return addHeapObject(ret);
|
|
358
|
+
},
|
|
359
|
+
__wbindgen_object_drop_ref: function(arg0) {
|
|
360
|
+
takeObject(arg0);
|
|
361
|
+
},
|
|
282
362
|
};
|
|
283
363
|
return {
|
|
284
364
|
__proto__: null,
|
|
Binary file
|