@truecalc/core 0.6.4 → 0.8.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 +51 -9
- package/package.json +1 -1
- package/truecalc_wasm.d.ts +24 -2
- package/truecalc_wasm_bg.js +14 -0
- package/truecalc_wasm_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -79,15 +79,57 @@ evaluate('CONCAT("Hello, ", name)', { name: 'world' })
|
|
|
79
79
|
// => { type: 'text', value: 'Hello, world' }
|
|
80
80
|
```
|
|
81
81
|
|
|
82
|
-
**Return value shape
|
|
83
|
-
|
|
84
|
-
| `type`
|
|
85
|
-
|
|
86
|
-
| `number`
|
|
87
|
-
| `text`
|
|
88
|
-
| `
|
|
89
|
-
| `
|
|
90
|
-
| `
|
|
82
|
+
**Return value shape** (a discriminated union tagged by `type`):
|
|
83
|
+
|
|
84
|
+
| `type` | Shape |
|
|
85
|
+
|----------|--------------------------------------------------------|
|
|
86
|
+
| `number` | `{ type: 'number', value: 6 }` |
|
|
87
|
+
| `text` | `{ type: 'text', value: 'yes' }` |
|
|
88
|
+
| `bool` | `{ type: 'bool', value: true }` |
|
|
89
|
+
| `date` | `{ type: 'date', value: 46180 }` |
|
|
90
|
+
| `error` | `{ type: 'error', error: '#NAME?' }` |
|
|
91
|
+
| `empty` | `{ type: 'empty' }` |
|
|
92
|
+
| `array` | `{ type: 'array', value: [ /* EvalResult cells */ ] }` |
|
|
93
|
+
|
|
94
|
+
`date` carries a spreadsheet **serial number** (`value`); the epoch is implied by
|
|
95
|
+
the engine flavor (`google-sheets`: day 0 = 1899-12-30). Format it yourself if you
|
|
96
|
+
need a calendar date.
|
|
97
|
+
|
|
98
|
+
`array` is **recursive**: each element is itself an `EvalResult`, so a 1-D result is
|
|
99
|
+
a flat `value` list of scalar cells and a 2-D result is a `value` list of `array`
|
|
100
|
+
rows whose elements are scalar cells. Array cells keep their own type (including
|
|
101
|
+
nested `date`/`error`/`empty`).
|
|
102
|
+
|
|
103
|
+
```js
|
|
104
|
+
evaluate('SEQUENCE(2,2)')
|
|
105
|
+
// => {
|
|
106
|
+
// type: 'array',
|
|
107
|
+
// value: [
|
|
108
|
+
// { type: 'array', value: [ { type: 'number', value: 1 }, { type: 'number', value: 2 } ] },
|
|
109
|
+
// { type: 'array', value: [ { type: 'number', value: 3 }, { type: 'number', value: 4 } ] },
|
|
110
|
+
// ],
|
|
111
|
+
// }
|
|
112
|
+
|
|
113
|
+
evaluate('TODAY()')
|
|
114
|
+
// => { type: 'date', value: 46180 }
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
> #### Breaking change in 0.7.0 (surface shape)
|
|
118
|
+
>
|
|
119
|
+
> 0.7.0 ships the unspilled-array core change (see core PR #566 / issue #569).
|
|
120
|
+
> Two observable shapes changed for npm consumers:
|
|
121
|
+
>
|
|
122
|
+
> - **Array-producing formulas** (`SORT`, `FILTER`, `UNIQUE`, `SEQUENCE`,
|
|
123
|
+
> `TRANSPOSE`, `MMULT`, `HSTACK`/`VSTACK`, `RANDARRAY`, array literals, ...) now
|
|
124
|
+
> return a full `{ type: 'array', value: [...] }` result. In `<= 0.6.x` these
|
|
125
|
+
> returned the top-left anchor-cell **scalar** (and, transiently after #566 but
|
|
126
|
+
> before this fix, an `{ type: 'error', error: 'array not supported' }` object).
|
|
127
|
+
> To recover the old single-cell behavior, read the first cell yourself, e.g.
|
|
128
|
+
> `const tl = r.type === 'array' ? r.value[0] : r;` (recurse once more for 2-D).
|
|
129
|
+
> - **Date-producing functions** (`TODAY`, `DATE`, ...) now return
|
|
130
|
+
> `{ type: 'date', value }` instead of `{ type: 'number', value }`. If you were
|
|
131
|
+
> treating the result as a number, also accept `type === 'date'` (the `value`
|
|
132
|
+
> encoding is identical — a serial number).
|
|
91
133
|
|
|
92
134
|
### `validate(formula)`
|
|
93
135
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@truecalc/core",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "Spreadsheet formula engine for the browser — Excel-compatible formula evaluator compiled to WebAssembly",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.8.0",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
package/truecalc_wasm.d.ts
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* The result of evaluating a formula on the WASM surface.
|
|
5
|
+
*
|
|
6
|
+
* A discriminated union tagged by `type`. Scalars carry their value directly;
|
|
7
|
+
* the `array` variant is recursive -- each element is itself an `EvalResult`,
|
|
8
|
+
* so a 2-D array result is an array of `array` rows whose elements are scalar
|
|
9
|
+
* `EvalResult`s. This mirrors how `truecalc-core` represents array values
|
|
10
|
+
* internally (1-D arrays are flat, 2-D arrays nest row sub-arrays) and matches
|
|
11
|
+
* the recursive shape `truecalc-mcp` already emits.
|
|
12
|
+
*
|
|
13
|
+
* # Surface shape (npm `@truecalc/core` >= 0.7.0)
|
|
14
|
+
*
|
|
15
|
+
* - `{ type: \"number\", value: 1.5 }`
|
|
16
|
+
* - `{ type: \"text\", value: \"yes\" }`
|
|
17
|
+
* - `{ type: \"bool\", value: true }`
|
|
18
|
+
* - `{ type: \"empty\" }`
|
|
19
|
+
* - `{ type: \"error\", error: \"#REF!\" }`
|
|
20
|
+
* - `{ type: \"date\", value: 46180 }` -- spreadsheet serial number (epoch implied
|
|
21
|
+
* by the engine flavor; `sheets` day 0 = 1899-12-30)
|
|
22
|
+
* - `{ type: \"array\", value: [ EvalResult, ... ] }` -- recursive; a 2-D result is
|
|
23
|
+
* `{ type: \"array\", value: [ { type: \"array\", value: [ <cells> ] }, ... ] }`
|
|
24
|
+
*/
|
|
25
|
+
export type EvalResult = { type: "number"; value: number } | { type: "text"; value: string } | { type: "bool"; value: boolean } | { type: "date"; value: number } | { type: "error"; error: string } | { type: "empty" } | { type: "array"; value: EvalResult[] };
|
|
26
|
+
|
|
3
27
|
export interface FunctionInfo {
|
|
4
28
|
name: string;
|
|
5
29
|
category: string;
|
|
@@ -12,8 +36,6 @@ export interface ValidateResult {
|
|
|
12
36
|
error?: string;
|
|
13
37
|
}
|
|
14
38
|
|
|
15
|
-
export type EvalResult = { type: "number"; value: number } | { type: "text"; value: string } | { type: "bool"; value: boolean } | { type: "error"; error: string } | { type: "empty" };
|
|
16
|
-
|
|
17
39
|
|
|
18
40
|
/**
|
|
19
41
|
* A stateful engine bound to a conformance target.
|
package/truecalc_wasm_bg.js
CHANGED
|
@@ -115,6 +115,13 @@ export function __wbg_Error_960c155d3d49e4c2(arg0, arg1) {
|
|
|
115
115
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
116
116
|
return addHeapObject(ret);
|
|
117
117
|
}
|
|
118
|
+
export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
119
|
+
const ret = String(getObject(arg1));
|
|
120
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
121
|
+
const len1 = WASM_VECTOR_LEN;
|
|
122
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
123
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
124
|
+
}
|
|
118
125
|
export function __wbg___wbindgen_bigint_get_as_i64_3d3aba5d616c6a51(arg0, arg1) {
|
|
119
126
|
const v = getObject(arg1);
|
|
120
127
|
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
@@ -253,6 +260,10 @@ export function __wbg_new_0c7403db6e782f19(arg0) {
|
|
|
253
260
|
const ret = new Uint8Array(getObject(arg0));
|
|
254
261
|
return addHeapObject(ret);
|
|
255
262
|
}
|
|
263
|
+
export function __wbg_new_682678e2f47e32bc() {
|
|
264
|
+
const ret = new Array();
|
|
265
|
+
return addHeapObject(ret);
|
|
266
|
+
}
|
|
256
267
|
export function __wbg_new_aa8d0fa9762c29bd() {
|
|
257
268
|
const ret = new Object();
|
|
258
269
|
return addHeapObject(ret);
|
|
@@ -268,6 +279,9 @@ export function __wbg_next_7646edaa39458ef7(arg0) {
|
|
|
268
279
|
export function __wbg_prototypesetcall_a6b02eb00b0f4ce2(arg0, arg1, arg2) {
|
|
269
280
|
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
270
281
|
}
|
|
282
|
+
export function __wbg_set_3bf1de9fab0cd644(arg0, arg1, arg2) {
|
|
283
|
+
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
|
|
284
|
+
}
|
|
271
285
|
export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
|
|
272
286
|
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
|
273
287
|
}
|
package/truecalc_wasm_bg.wasm
CHANGED
|
Binary file
|