@tryganit/core 0.1.1 → 0.1.3
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/ganit_wasm.d.ts +17 -4
- package/ganit_wasm_bg.js +28 -25
- package/ganit_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/ganit_wasm.d.ts
CHANGED
|
@@ -1,25 +1,38 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
+
export interface FunctionInfo {
|
|
4
|
+
name: string;
|
|
5
|
+
category: string;
|
|
6
|
+
syntax: string;
|
|
7
|
+
description: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ValidateResult {
|
|
11
|
+
valid: boolean;
|
|
12
|
+
error?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type EvalResult = { type: "number"; value: number } | { type: "text"; value: string } | { type: "bool"; value: boolean } | { type: "error"; error: string } | { type: "empty" };
|
|
16
|
+
|
|
3
17
|
|
|
4
18
|
/**
|
|
5
19
|
* Evaluate a formula with named variables supplied as a JS object.
|
|
6
20
|
*
|
|
7
21
|
* `variables` must be a plain JS object mapping string keys to number/string/bool/null.
|
|
8
22
|
* Passing `undefined` or `null` is safe and is treated as no variables.
|
|
9
|
-
* Returns `{ value, type }` or `{ value: null, type: "error", error: "..." }`.
|
|
10
23
|
*/
|
|
11
|
-
export function evaluate(formula: string, variables: any):
|
|
24
|
+
export function evaluate(formula: string, variables: any): EvalResult;
|
|
12
25
|
|
|
13
26
|
/**
|
|
14
27
|
* Return metadata for all built-in functions as a JS array.
|
|
15
28
|
*
|
|
16
29
|
* Each entry: `{ name, category, syntax, description }`.
|
|
17
30
|
*/
|
|
18
|
-
export function list_functions():
|
|
31
|
+
export function list_functions(): FunctionInfo[];
|
|
19
32
|
|
|
20
33
|
/**
|
|
21
34
|
* Validate a formula string without evaluating it.
|
|
22
35
|
*
|
|
23
36
|
* Returns `{ valid: true }` on success or `{ valid: false, error: "..." }` on failure.
|
|
24
37
|
*/
|
|
25
|
-
export function validate(formula: string):
|
|
38
|
+
export function validate(formula: string): ValidateResult;
|
package/ganit_wasm_bg.js
CHANGED
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* `variables` must be a plain JS object mapping string keys to number/string/bool/null.
|
|
5
5
|
* Passing `undefined` or `null` is safe and is treated as no variables.
|
|
6
|
-
* Returns `{ value, type }` or `{ value: null, type: "error", error: "..." }`.
|
|
7
6
|
* @param {string} formula
|
|
8
7
|
* @param {any} variables
|
|
9
|
-
* @returns {
|
|
8
|
+
* @returns {EvalResult}
|
|
10
9
|
*/
|
|
11
10
|
export function evaluate(formula, variables) {
|
|
12
11
|
const ptr0 = passStringToWasm0(formula, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
@@ -19,11 +18,20 @@ export function evaluate(formula, variables) {
|
|
|
19
18
|
* Return metadata for all built-in functions as a JS array.
|
|
20
19
|
*
|
|
21
20
|
* Each entry: `{ name, category, syntax, description }`.
|
|
22
|
-
* @returns {
|
|
21
|
+
* @returns {FunctionInfo[]}
|
|
23
22
|
*/
|
|
24
23
|
export function list_functions() {
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
try {
|
|
25
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
26
|
+
wasm.list_functions(retptr);
|
|
27
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
28
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
29
|
+
var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
30
|
+
wasm.__wbindgen_export4(r0, r1 * 4, 4);
|
|
31
|
+
return v1;
|
|
32
|
+
} finally {
|
|
33
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
34
|
+
}
|
|
27
35
|
}
|
|
28
36
|
|
|
29
37
|
/**
|
|
@@ -31,7 +39,7 @@ export function list_functions() {
|
|
|
31
39
|
*
|
|
32
40
|
* Returns `{ valid: true }` on success or `{ valid: false, error: "..." }` on failure.
|
|
33
41
|
* @param {string} formula
|
|
34
|
-
* @returns {
|
|
42
|
+
* @returns {ValidateResult}
|
|
35
43
|
*/
|
|
36
44
|
export function validate(formula) {
|
|
37
45
|
const ptr0 = passStringToWasm0(formula, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
@@ -78,10 +86,6 @@ export function __wbg___wbindgen_is_object_63322ec0cd6ea4ef(arg0) {
|
|
|
78
86
|
const ret = typeof(val) === 'object' && val !== null;
|
|
79
87
|
return ret;
|
|
80
88
|
}
|
|
81
|
-
export function __wbg___wbindgen_is_string_6df3bf7ef1164ed3(arg0) {
|
|
82
|
-
const ret = typeof(getObject(arg0)) === 'string';
|
|
83
|
-
return ret;
|
|
84
|
-
}
|
|
85
89
|
export function __wbg___wbindgen_jsval_eq_d3465d8a07697228(arg0, arg1) {
|
|
86
90
|
const ret = getObject(arg0) === getObject(arg1);
|
|
87
91
|
return ret;
|
|
@@ -185,14 +189,6 @@ export function __wbg_new_0c7403db6e782f19(arg0) {
|
|
|
185
189
|
const ret = new Uint8Array(getObject(arg0));
|
|
186
190
|
return addHeapObject(ret);
|
|
187
191
|
}
|
|
188
|
-
export function __wbg_new_34d45cc8e36aaead() {
|
|
189
|
-
const ret = new Map();
|
|
190
|
-
return addHeapObject(ret);
|
|
191
|
-
}
|
|
192
|
-
export function __wbg_new_682678e2f47e32bc() {
|
|
193
|
-
const ret = new Array();
|
|
194
|
-
return addHeapObject(ret);
|
|
195
|
-
}
|
|
196
192
|
export function __wbg_new_aa8d0fa9762c29bd() {
|
|
197
193
|
const ret = new Object();
|
|
198
194
|
return addHeapObject(ret);
|
|
@@ -208,16 +204,9 @@ export function __wbg_next_7646edaa39458ef7(arg0) {
|
|
|
208
204
|
export function __wbg_prototypesetcall_a6b02eb00b0f4ce2(arg0, arg1, arg2) {
|
|
209
205
|
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
210
206
|
}
|
|
211
|
-
export function __wbg_set_3bf1de9fab0cd644(arg0, arg1, arg2) {
|
|
212
|
-
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
|
|
213
|
-
}
|
|
214
207
|
export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
|
|
215
208
|
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
|
216
209
|
}
|
|
217
|
-
export function __wbg_set_fde2cec06c23692b(arg0, arg1, arg2) {
|
|
218
|
-
const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
|
|
219
|
-
return addHeapObject(ret);
|
|
220
|
-
}
|
|
221
210
|
export function __wbg_value_ee3a06f4579184fa(arg0) {
|
|
222
211
|
const ret = getObject(arg0).value;
|
|
223
212
|
return addHeapObject(ret);
|
|
@@ -242,6 +231,10 @@ export function __wbindgen_cast_0000000000000004(arg0) {
|
|
|
242
231
|
const ret = BigInt.asUintN(64, arg0);
|
|
243
232
|
return addHeapObject(ret);
|
|
244
233
|
}
|
|
234
|
+
export function __wbindgen_object_clone_ref(arg0) {
|
|
235
|
+
const ret = getObject(arg0);
|
|
236
|
+
return addHeapObject(ret);
|
|
237
|
+
}
|
|
245
238
|
export function __wbindgen_object_drop_ref(arg0) {
|
|
246
239
|
takeObject(arg0);
|
|
247
240
|
}
|
|
@@ -325,6 +318,16 @@ function dropObject(idx) {
|
|
|
325
318
|
heap_next = idx;
|
|
326
319
|
}
|
|
327
320
|
|
|
321
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
322
|
+
ptr = ptr >>> 0;
|
|
323
|
+
const mem = getDataViewMemory0();
|
|
324
|
+
const result = [];
|
|
325
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
326
|
+
result.push(takeObject(mem.getUint32(i, true)));
|
|
327
|
+
}
|
|
328
|
+
return result;
|
|
329
|
+
}
|
|
330
|
+
|
|
328
331
|
function getArrayU8FromWasm0(ptr, len) {
|
|
329
332
|
ptr = ptr >>> 0;
|
|
330
333
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
package/ganit_wasm_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tryganit/core",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "Spreadsheet formula engine for the browser — Excel-compatible formula evaluator compiled to WebAssembly",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.3",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|