@truecalc/core 7.0.7 → 7.1.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 +56 -0
- package/package.json +16 -3
- package/truecalc_wasm_bg.wasm +0 -0
- package/truecalc_wasm_bun.d.ts +231 -0
- package/truecalc_wasm_bun.js +673 -0
package/README.md
CHANGED
|
@@ -36,6 +36,62 @@ const result = evaluate('SUM(A1, B1)', { A1: 100, B1: 200 });
|
|
|
36
36
|
// => { type: 'number', value: 300 }
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
+
### Bun
|
|
40
|
+
|
|
41
|
+
Bun resolves to a separate build that requires an explicit `init()` first:
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
import init, { evaluate } from '@truecalc/core';
|
|
45
|
+
|
|
46
|
+
await init();
|
|
47
|
+
evaluate('SUM(A1, B1)', { A1: 100, B1: 200 });
|
|
48
|
+
// => { type: 'number', value: 300 }
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
That extra call is not optional and not needed on any other runtime. The main
|
|
52
|
+
build relies on WebAssembly ESM integration, which Node and Deno support and
|
|
53
|
+
Bun does not — under Bun it fails with `malloc is not a function`. So
|
|
54
|
+
`package.json` routes Bun to a `--target web` build, which works but must be
|
|
55
|
+
initialised explicitly.
|
|
56
|
+
|
|
57
|
+
**TypeScript:** add `"customConditions": ["bun"]` to your `tsconfig.json`
|
|
58
|
+
`compilerOptions`. TypeScript does not match the `bun` export condition on its
|
|
59
|
+
own — not even under the tsconfig `bun init` generates — so without it the
|
|
60
|
+
snippet above reports *"Module has no default export"* and `init` is missing
|
|
61
|
+
from autocomplete. Runtime is unaffected either way.
|
|
62
|
+
|
|
63
|
+
**`bun build` bundling:** the wasm is not emitted as a sibling asset, so
|
|
64
|
+
`await init()` cannot find it and fails with `ERR_BODY_ALREADY_USED`. Pass the
|
|
65
|
+
bytes explicitly instead:
|
|
66
|
+
|
|
67
|
+
```js
|
|
68
|
+
import init, { evaluate } from '@truecalc/core';
|
|
69
|
+
import wasmPath from '@truecalc/core/truecalc_wasm_bg.wasm' with { type: 'file' };
|
|
70
|
+
|
|
71
|
+
// Resolve against import.meta.url — the imported path is relative to the
|
|
72
|
+
// process's working directory, so a bare `Bun.file(wasmPath)` only works when
|
|
73
|
+
// you happen to run from the output directory.
|
|
74
|
+
await init(await Bun.file(new URL(wasmPath, import.meta.url)).arrayBuffer());
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Only `bun build --target=bun` is affected; `--target=node` and
|
|
78
|
+
`--target=browser` resolve the default build and bundle normally.
|
|
79
|
+
|
|
80
|
+
Nothing changes for Node, Deno or bundlers, which continue to resolve the
|
|
81
|
+
init-free build. `@truecalc/workbook` is unaffected: it already ships in the
|
|
82
|
+
form Bun can consume, and its `init()` is part of its documented API.
|
|
83
|
+
|
|
84
|
+
### Writing a library on top of this
|
|
85
|
+
|
|
86
|
+
Because only the Bun build has a default export, a library that must work on
|
|
87
|
+
every runtime cannot call `init()` unconditionally:
|
|
88
|
+
|
|
89
|
+
```js
|
|
90
|
+
const mod = await import('@truecalc/core');
|
|
91
|
+
if (typeof mod.default === 'function') await mod.default(); // Bun only
|
|
92
|
+
mod.evaluate('SUM(A1, B1)', { A1: 100, B1: 200 });
|
|
93
|
+
```
|
|
94
|
+
|
|
39
95
|
### Vite
|
|
40
96
|
|
|
41
97
|
Install the wasm plugin first:
|
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 — Google Sheets–compatible formula evaluator compiled to WebAssembly",
|
|
5
|
-
"version": "7.0
|
|
5
|
+
"version": "7.1.0",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
"truecalc_wasm_bg.wasm",
|
|
13
13
|
"truecalc_wasm.js",
|
|
14
14
|
"truecalc_wasm_bg.js",
|
|
15
|
-
"truecalc_wasm.d.ts"
|
|
15
|
+
"truecalc_wasm.d.ts",
|
|
16
|
+
"truecalc_wasm_bun.js",
|
|
17
|
+
"truecalc_wasm_bun.d.ts"
|
|
16
18
|
],
|
|
17
19
|
"main": "truecalc_wasm.js",
|
|
18
20
|
"types": "truecalc_wasm.d.ts",
|
|
@@ -26,5 +28,16 @@
|
|
|
26
28
|
"google-sheets",
|
|
27
29
|
"excel",
|
|
28
30
|
"wasm"
|
|
29
|
-
]
|
|
31
|
+
],
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"bun": {
|
|
35
|
+
"types": "./truecalc_wasm_bun.d.ts",
|
|
36
|
+
"default": "./truecalc_wasm_bun.js"
|
|
37
|
+
},
|
|
38
|
+
"types": "./truecalc_wasm.d.ts",
|
|
39
|
+
"default": "./truecalc_wasm.js"
|
|
40
|
+
},
|
|
41
|
+
"./*": "./*"
|
|
42
|
+
}
|
|
30
43
|
}
|
package/truecalc_wasm_bg.wasm
CHANGED
|
Binary file
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* A parsed sparkline render spec on the WASM surface. `data` points and
|
|
5
|
+
* option values are ordinary [`EvalResult`] cells (a blank cell inside the
|
|
6
|
+
* source range is `empty`).
|
|
7
|
+
*/
|
|
8
|
+
export interface SparklineSpecResult {
|
|
9
|
+
/**
|
|
10
|
+
* `line` (the default), `bar`, `column` or `winloss`.
|
|
11
|
+
*/
|
|
12
|
+
charttype: string;
|
|
13
|
+
/**
|
|
14
|
+
* The points to plot, row-major.
|
|
15
|
+
*/
|
|
16
|
+
data: EvalResult[];
|
|
17
|
+
/**
|
|
18
|
+
* The remaining option key/value pairs, in the order given, keys
|
|
19
|
+
* lower-cased. Keys the engine does not recognise are kept, not rejected:
|
|
20
|
+
* Sheets ignores an unknown option key rather than erroring.
|
|
21
|
+
*/
|
|
22
|
+
options: [string, EvalResult][];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Metadata for one built-in function, as returned by [`list_functions`].
|
|
27
|
+
*
|
|
28
|
+
* Derived from the engine\'s function registry, so it always reflects what the
|
|
29
|
+
* engine actually implements.
|
|
30
|
+
*/
|
|
31
|
+
export interface FunctionInfo {
|
|
32
|
+
/**
|
|
33
|
+
* The function name in upper case, e.g. `\"SUM\"`.
|
|
34
|
+
*/
|
|
35
|
+
name: string;
|
|
36
|
+
/**
|
|
37
|
+
* The registry category, e.g. `\"math\"`, `\"text\"`, `\"financial\"`.
|
|
38
|
+
*/
|
|
39
|
+
category: string;
|
|
40
|
+
/**
|
|
41
|
+
* The call signature, e.g. `\"PMT(rate, nper, pv, [fv], [type])\"`.
|
|
42
|
+
* Optional arguments appear in square brackets.
|
|
43
|
+
*/
|
|
44
|
+
syntax: string;
|
|
45
|
+
/**
|
|
46
|
+
* A one-line description of what the function does.
|
|
47
|
+
*/
|
|
48
|
+
description: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The outcome of a [`rename_sheet_refs`] call.
|
|
53
|
+
*
|
|
54
|
+
* Exactly one of `formula` or `error` is present.
|
|
55
|
+
*/
|
|
56
|
+
export interface RenameSheetRefsResult {
|
|
57
|
+
/**
|
|
58
|
+
* The rewritten formula. Absent when the input failed to parse.
|
|
59
|
+
*/
|
|
60
|
+
formula?: string;
|
|
61
|
+
/**
|
|
62
|
+
* The parse error message. Absent on success.
|
|
63
|
+
*/
|
|
64
|
+
error?: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The outcome of a [`translate_formula`] call.
|
|
69
|
+
*
|
|
70
|
+
* Exactly one of `formula` or `error` is present.
|
|
71
|
+
*/
|
|
72
|
+
export interface TranslateResult {
|
|
73
|
+
/**
|
|
74
|
+
* The rewritten formula. Absent when the input failed to parse.
|
|
75
|
+
*/
|
|
76
|
+
formula?: string;
|
|
77
|
+
/**
|
|
78
|
+
* The parse error message. Absent on success.
|
|
79
|
+
*/
|
|
80
|
+
error?: string;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The outcome of a [`validate`] call.
|
|
85
|
+
*
|
|
86
|
+
* `{ valid: true }` when the formula parses, otherwise
|
|
87
|
+
* `{ valid: false, error: \"...\" }`.
|
|
88
|
+
*/
|
|
89
|
+
export interface ValidateResult {
|
|
90
|
+
/**
|
|
91
|
+
* `true` when the formula parses.
|
|
92
|
+
*/
|
|
93
|
+
valid: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* The parse error message. Absent when `valid` is `true`.
|
|
96
|
+
*/
|
|
97
|
+
error?: string;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The result of evaluating a formula on the WASM surface.
|
|
102
|
+
*
|
|
103
|
+
* A discriminated union tagged by `type`. Scalars carry their value directly;
|
|
104
|
+
* the `array` variant is recursive -- each element is itself an `EvalResult`,
|
|
105
|
+
* so a 2-D array result is an array of `array` rows whose elements are scalar
|
|
106
|
+
* `EvalResult`s. This mirrors how `truecalc-core` represents array values
|
|
107
|
+
* internally (1-D arrays are flat, 2-D arrays nest row sub-arrays) and matches
|
|
108
|
+
* the recursive shape `truecalc-mcp` already emits.
|
|
109
|
+
*
|
|
110
|
+
* # Surface shape (npm `@truecalc/core` >= 0.7.0)
|
|
111
|
+
*
|
|
112
|
+
* - `{ type: \"number\", value: 1.5 }`
|
|
113
|
+
* - `{ type: \"text\", value: \"yes\" }`
|
|
114
|
+
* - `{ type: \"bool\", value: true }`
|
|
115
|
+
* - `{ type: \"empty\" }`
|
|
116
|
+
* - `{ type: \"error\", error: \"#REF!\" }` -- and, when a diagnostic is available,
|
|
117
|
+
* `{ type: \"error\", error: \"#N/A\", message: \"Wrong number of arguments to
|
|
118
|
+
* DATE. Expected 3 arguments, but got 0 arguments.\" }`. `message` is additive and
|
|
119
|
+
* omitted for errors without a diagnostic, so existing consumers are unaffected.
|
|
120
|
+
* - `{ type: \"date\", value: 46180 }` -- spreadsheet serial number (epoch implied
|
|
121
|
+
* by the engine flavor; `sheets` day 0 = 1899-12-30)
|
|
122
|
+
* - `{ type: \"array\", value: [ EvalResult, ... ] }` -- recursive; a 2-D result is
|
|
123
|
+
* `{ type: \"array\", value: [ { type: \"array\", value: [ <cells> ] }, ... ] }`
|
|
124
|
+
*/
|
|
125
|
+
export type EvalResult = { type: "number"; value: number } | { type: "text"; value: string } | { type: "bool"; value: boolean } | { type: "date"; value: number } | { type: "zoned"; value: string } | { type: "error"; error: string; message?: string } | { type: "empty" } | { type: "array"; value: EvalResult[] } | { type: "sparkline"; value: SparklineSpecResult };
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* A stateful engine bound to a conformance target.
|
|
130
|
+
*
|
|
131
|
+
* Obtained via `createEngine('google-sheets')`.
|
|
132
|
+
*/
|
|
133
|
+
export class Engine {
|
|
134
|
+
private constructor();
|
|
135
|
+
free(): void;
|
|
136
|
+
[Symbol.dispose](): void;
|
|
137
|
+
/**
|
|
138
|
+
* Evaluate a formula using this engine's conformance target.
|
|
139
|
+
*/
|
|
140
|
+
evaluate(formula: string, variables: any): EvalResult;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Create an engine for a specific conformance target.
|
|
145
|
+
*
|
|
146
|
+
* Supported targets: `"google-sheets"`.
|
|
147
|
+
* Returns an error for unknown targets.
|
|
148
|
+
*/
|
|
149
|
+
export function createEngine(target: string): Engine;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Evaluate a formula with named variables supplied as a JS object.
|
|
153
|
+
*
|
|
154
|
+
* `variables` must be a plain JS object mapping string keys to number/string/bool/null.
|
|
155
|
+
* Passing `undefined` or `null` is safe and is treated as no variables.
|
|
156
|
+
*/
|
|
157
|
+
export function evaluate(formula: string, variables: any): EvalResult;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Return metadata for all built-in functions as a JS array.
|
|
161
|
+
*
|
|
162
|
+
* Each entry: `{ name, category, syntax, description }`.
|
|
163
|
+
*/
|
|
164
|
+
export function list_functions(): FunctionInfo[];
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Rewrite the sheet qualifier of every cell/range reference in `formula`
|
|
168
|
+
* that points at `old` to point at `new` instead — the sheet-rename
|
|
169
|
+
* reference-rewrite transform. Sheet-name matching is case-insensitive.
|
|
170
|
+
* Requoting is handled automatically. Unqualified refs, refs to other
|
|
171
|
+
* sheets, string literals, function names, and defined names are left
|
|
172
|
+
* untouched; no-op if `formula` has no `old`-qualified refs.
|
|
173
|
+
*/
|
|
174
|
+
export function rename_sheet_refs(formula: string, old: string, _new: string): RenameSheetRefsResult;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Shift every relative cell/range reference in `formula` by `(d_row, d_col)`
|
|
178
|
+
* — the fill / copy-paste reference-adjustment transform. `$`-absolute axes
|
|
179
|
+
* are left unchanged; an out-of-bounds corner becomes literal `#REF!`.
|
|
180
|
+
*
|
|
181
|
+
* Sheets flavor only (issue #709 v1); Excel support is a follow-up.
|
|
182
|
+
*/
|
|
183
|
+
export function translate_formula(formula: string, d_row: number, d_col: number): TranslateResult;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Validate a formula string without evaluating it.
|
|
187
|
+
*
|
|
188
|
+
* Returns `{ valid: true }` on success or `{ valid: false, error: "..." }` on failure.
|
|
189
|
+
*/
|
|
190
|
+
export function validate(formula: string): ValidateResult;
|
|
191
|
+
|
|
192
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
193
|
+
|
|
194
|
+
export interface InitOutput {
|
|
195
|
+
readonly memory: WebAssembly.Memory;
|
|
196
|
+
readonly __wbg_engine_free: (a: number, b: number) => void;
|
|
197
|
+
readonly createEngine: (a: number, b: number, c: number) => void;
|
|
198
|
+
readonly evaluate: (a: number, b: number, c: number) => number;
|
|
199
|
+
readonly list_functions: (a: number) => void;
|
|
200
|
+
readonly rename_sheet_refs: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
|
201
|
+
readonly translate_formula: (a: number, b: number, c: number, d: number) => number;
|
|
202
|
+
readonly validate: (a: number, b: number) => number;
|
|
203
|
+
readonly wasmengine_evaluate: (a: number, b: number, c: number, d: number) => number;
|
|
204
|
+
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
205
|
+
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
206
|
+
readonly __wbindgen_export3: (a: number) => void;
|
|
207
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
208
|
+
readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
215
|
+
* a precompiled `WebAssembly.Module`.
|
|
216
|
+
*
|
|
217
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
218
|
+
*
|
|
219
|
+
* @returns {InitOutput}
|
|
220
|
+
*/
|
|
221
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
225
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
226
|
+
*
|
|
227
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
228
|
+
*
|
|
229
|
+
* @returns {Promise<InitOutput>}
|
|
230
|
+
*/
|
|
231
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
@@ -0,0 +1,673 @@
|
|
|
1
|
+
/* @ts-self-types="./truecalc_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A stateful engine bound to a conformance target.
|
|
5
|
+
*
|
|
6
|
+
* Obtained via `createEngine('google-sheets')`.
|
|
7
|
+
*/
|
|
8
|
+
export class Engine {
|
|
9
|
+
static __wrap(ptr) {
|
|
10
|
+
ptr = ptr >>> 0;
|
|
11
|
+
const obj = Object.create(Engine.prototype);
|
|
12
|
+
obj.__wbg_ptr = ptr;
|
|
13
|
+
EngineFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
14
|
+
return obj;
|
|
15
|
+
}
|
|
16
|
+
__destroy_into_raw() {
|
|
17
|
+
const ptr = this.__wbg_ptr;
|
|
18
|
+
this.__wbg_ptr = 0;
|
|
19
|
+
EngineFinalization.unregister(this);
|
|
20
|
+
return ptr;
|
|
21
|
+
}
|
|
22
|
+
free() {
|
|
23
|
+
const ptr = this.__destroy_into_raw();
|
|
24
|
+
wasm.__wbg_engine_free(ptr, 0);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Evaluate a formula using this engine's conformance target.
|
|
28
|
+
* @param {string} formula
|
|
29
|
+
* @param {any} variables
|
|
30
|
+
* @returns {EvalResult}
|
|
31
|
+
*/
|
|
32
|
+
evaluate(formula, variables) {
|
|
33
|
+
const ptr0 = passStringToWasm0(formula, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
34
|
+
const len0 = WASM_VECTOR_LEN;
|
|
35
|
+
const ret = wasm.wasmengine_evaluate(this.__wbg_ptr, ptr0, len0, addHeapObject(variables));
|
|
36
|
+
return takeObject(ret);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (Symbol.dispose) Engine.prototype[Symbol.dispose] = Engine.prototype.free;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Create an engine for a specific conformance target.
|
|
43
|
+
*
|
|
44
|
+
* Supported targets: `"google-sheets"`.
|
|
45
|
+
* Returns an error for unknown targets.
|
|
46
|
+
* @param {string} target
|
|
47
|
+
* @returns {Engine}
|
|
48
|
+
*/
|
|
49
|
+
export function createEngine(target) {
|
|
50
|
+
try {
|
|
51
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
52
|
+
const ptr0 = passStringToWasm0(target, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
53
|
+
const len0 = WASM_VECTOR_LEN;
|
|
54
|
+
wasm.createEngine(retptr, ptr0, len0);
|
|
55
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
56
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
57
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
58
|
+
if (r2) {
|
|
59
|
+
throw takeObject(r1);
|
|
60
|
+
}
|
|
61
|
+
return Engine.__wrap(r0);
|
|
62
|
+
} finally {
|
|
63
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Evaluate a formula with named variables supplied as a JS object.
|
|
69
|
+
*
|
|
70
|
+
* `variables` must be a plain JS object mapping string keys to number/string/bool/null.
|
|
71
|
+
* Passing `undefined` or `null` is safe and is treated as no variables.
|
|
72
|
+
* @param {string} formula
|
|
73
|
+
* @param {any} variables
|
|
74
|
+
* @returns {EvalResult}
|
|
75
|
+
*/
|
|
76
|
+
export function evaluate(formula, variables) {
|
|
77
|
+
const ptr0 = passStringToWasm0(formula, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
78
|
+
const len0 = WASM_VECTOR_LEN;
|
|
79
|
+
const ret = wasm.evaluate(ptr0, len0, addHeapObject(variables));
|
|
80
|
+
return takeObject(ret);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Return metadata for all built-in functions as a JS array.
|
|
85
|
+
*
|
|
86
|
+
* Each entry: `{ name, category, syntax, description }`.
|
|
87
|
+
* @returns {FunctionInfo[]}
|
|
88
|
+
*/
|
|
89
|
+
export function list_functions() {
|
|
90
|
+
try {
|
|
91
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
92
|
+
wasm.list_functions(retptr);
|
|
93
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
94
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
95
|
+
var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
96
|
+
wasm.__wbindgen_export4(r0, r1 * 4, 4);
|
|
97
|
+
return v1;
|
|
98
|
+
} finally {
|
|
99
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Rewrite the sheet qualifier of every cell/range reference in `formula`
|
|
105
|
+
* that points at `old` to point at `new` instead — the sheet-rename
|
|
106
|
+
* reference-rewrite transform. Sheet-name matching is case-insensitive.
|
|
107
|
+
* Requoting is handled automatically. Unqualified refs, refs to other
|
|
108
|
+
* sheets, string literals, function names, and defined names are left
|
|
109
|
+
* untouched; no-op if `formula` has no `old`-qualified refs.
|
|
110
|
+
* @param {string} formula
|
|
111
|
+
* @param {string} old
|
|
112
|
+
* @param {string} _new
|
|
113
|
+
* @returns {RenameSheetRefsResult}
|
|
114
|
+
*/
|
|
115
|
+
export function rename_sheet_refs(formula, old, _new) {
|
|
116
|
+
const ptr0 = passStringToWasm0(formula, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
117
|
+
const len0 = WASM_VECTOR_LEN;
|
|
118
|
+
const ptr1 = passStringToWasm0(old, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
119
|
+
const len1 = WASM_VECTOR_LEN;
|
|
120
|
+
const ptr2 = passStringToWasm0(_new, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
121
|
+
const len2 = WASM_VECTOR_LEN;
|
|
122
|
+
const ret = wasm.rename_sheet_refs(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
123
|
+
return takeObject(ret);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Shift every relative cell/range reference in `formula` by `(d_row, d_col)`
|
|
128
|
+
* — the fill / copy-paste reference-adjustment transform. `$`-absolute axes
|
|
129
|
+
* are left unchanged; an out-of-bounds corner becomes literal `#REF!`.
|
|
130
|
+
*
|
|
131
|
+
* Sheets flavor only (issue #709 v1); Excel support is a follow-up.
|
|
132
|
+
* @param {string} formula
|
|
133
|
+
* @param {number} d_row
|
|
134
|
+
* @param {number} d_col
|
|
135
|
+
* @returns {TranslateResult}
|
|
136
|
+
*/
|
|
137
|
+
export function translate_formula(formula, d_row, d_col) {
|
|
138
|
+
const ptr0 = passStringToWasm0(formula, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
139
|
+
const len0 = WASM_VECTOR_LEN;
|
|
140
|
+
const ret = wasm.translate_formula(ptr0, len0, d_row, d_col);
|
|
141
|
+
return takeObject(ret);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Validate a formula string without evaluating it.
|
|
146
|
+
*
|
|
147
|
+
* Returns `{ valid: true }` on success or `{ valid: false, error: "..." }` on failure.
|
|
148
|
+
* @param {string} formula
|
|
149
|
+
* @returns {ValidateResult}
|
|
150
|
+
*/
|
|
151
|
+
export function validate(formula) {
|
|
152
|
+
const ptr0 = passStringToWasm0(formula, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
153
|
+
const len0 = WASM_VECTOR_LEN;
|
|
154
|
+
const ret = wasm.validate(ptr0, len0);
|
|
155
|
+
return takeObject(ret);
|
|
156
|
+
}
|
|
157
|
+
function __wbg_get_imports() {
|
|
158
|
+
const import0 = {
|
|
159
|
+
__proto__: null,
|
|
160
|
+
__wbg_Error_960c155d3d49e4c2: function(arg0, arg1) {
|
|
161
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
162
|
+
return addHeapObject(ret);
|
|
163
|
+
},
|
|
164
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
165
|
+
const ret = String(getObject(arg1));
|
|
166
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
167
|
+
const len1 = WASM_VECTOR_LEN;
|
|
168
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
169
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
170
|
+
},
|
|
171
|
+
__wbg___wbindgen_bigint_get_as_i64_3d3aba5d616c6a51: function(arg0, arg1) {
|
|
172
|
+
const v = getObject(arg1);
|
|
173
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
174
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
175
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
176
|
+
},
|
|
177
|
+
__wbg___wbindgen_boolean_get_6ea149f0a8dcc5ff: function(arg0) {
|
|
178
|
+
const v = getObject(arg0);
|
|
179
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
180
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
181
|
+
},
|
|
182
|
+
__wbg___wbindgen_debug_string_ab4b34d23d6778bd: function(arg0, arg1) {
|
|
183
|
+
const ret = debugString(getObject(arg1));
|
|
184
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
185
|
+
const len1 = WASM_VECTOR_LEN;
|
|
186
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
187
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
188
|
+
},
|
|
189
|
+
__wbg___wbindgen_in_a5d8b22e52b24dd1: function(arg0, arg1) {
|
|
190
|
+
const ret = getObject(arg0) in getObject(arg1);
|
|
191
|
+
return ret;
|
|
192
|
+
},
|
|
193
|
+
__wbg___wbindgen_is_bigint_ec25c7f91b4d9e93: function(arg0) {
|
|
194
|
+
const ret = typeof(getObject(arg0)) === 'bigint';
|
|
195
|
+
return ret;
|
|
196
|
+
},
|
|
197
|
+
__wbg___wbindgen_is_function_3baa9db1a987f47d: function(arg0) {
|
|
198
|
+
const ret = typeof(getObject(arg0)) === 'function';
|
|
199
|
+
return ret;
|
|
200
|
+
},
|
|
201
|
+
__wbg___wbindgen_is_object_63322ec0cd6ea4ef: function(arg0) {
|
|
202
|
+
const val = getObject(arg0);
|
|
203
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
204
|
+
return ret;
|
|
205
|
+
},
|
|
206
|
+
__wbg___wbindgen_jsval_eq_d3465d8a07697228: function(arg0, arg1) {
|
|
207
|
+
const ret = getObject(arg0) === getObject(arg1);
|
|
208
|
+
return ret;
|
|
209
|
+
},
|
|
210
|
+
__wbg___wbindgen_jsval_loose_eq_cac3565e89b4134c: function(arg0, arg1) {
|
|
211
|
+
const ret = getObject(arg0) == getObject(arg1);
|
|
212
|
+
return ret;
|
|
213
|
+
},
|
|
214
|
+
__wbg___wbindgen_number_get_c7f42aed0525c451: function(arg0, arg1) {
|
|
215
|
+
const obj = getObject(arg1);
|
|
216
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
217
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
218
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
219
|
+
},
|
|
220
|
+
__wbg___wbindgen_string_get_7ed5322991caaec5: function(arg0, arg1) {
|
|
221
|
+
const obj = getObject(arg1);
|
|
222
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
223
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
224
|
+
var len1 = WASM_VECTOR_LEN;
|
|
225
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
226
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
227
|
+
},
|
|
228
|
+
__wbg___wbindgen_throw_6b64449b9b9ed33c: function(arg0, arg1) {
|
|
229
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
230
|
+
},
|
|
231
|
+
__wbg_call_14b169f759b26747: function() { return handleError(function (arg0, arg1) {
|
|
232
|
+
const ret = getObject(arg0).call(getObject(arg1));
|
|
233
|
+
return addHeapObject(ret);
|
|
234
|
+
}, arguments); },
|
|
235
|
+
__wbg_done_9158f7cc8751ba32: function(arg0) {
|
|
236
|
+
const ret = getObject(arg0).done;
|
|
237
|
+
return ret;
|
|
238
|
+
},
|
|
239
|
+
__wbg_entries_e0b73aa8571ddb56: function(arg0) {
|
|
240
|
+
const ret = Object.entries(getObject(arg0));
|
|
241
|
+
return addHeapObject(ret);
|
|
242
|
+
},
|
|
243
|
+
__wbg_get_1affdbdd5573b16a: function() { return handleError(function (arg0, arg1) {
|
|
244
|
+
const ret = Reflect.get(getObject(arg0), getObject(arg1));
|
|
245
|
+
return addHeapObject(ret);
|
|
246
|
+
}, arguments); },
|
|
247
|
+
__wbg_get_8360291721e2339f: function(arg0, arg1) {
|
|
248
|
+
const ret = getObject(arg0)[arg1 >>> 0];
|
|
249
|
+
return addHeapObject(ret);
|
|
250
|
+
},
|
|
251
|
+
__wbg_get_unchecked_17f53dad852b9588: function(arg0, arg1) {
|
|
252
|
+
const ret = getObject(arg0)[arg1 >>> 0];
|
|
253
|
+
return addHeapObject(ret);
|
|
254
|
+
},
|
|
255
|
+
__wbg_instanceof_ArrayBuffer_7c8433c6ed14ffe3: function(arg0) {
|
|
256
|
+
let result;
|
|
257
|
+
try {
|
|
258
|
+
result = getObject(arg0) instanceof ArrayBuffer;
|
|
259
|
+
} catch (_) {
|
|
260
|
+
result = false;
|
|
261
|
+
}
|
|
262
|
+
const ret = result;
|
|
263
|
+
return ret;
|
|
264
|
+
},
|
|
265
|
+
__wbg_instanceof_Map_1b76fd4635be43eb: function(arg0) {
|
|
266
|
+
let result;
|
|
267
|
+
try {
|
|
268
|
+
result = getObject(arg0) instanceof Map;
|
|
269
|
+
} catch (_) {
|
|
270
|
+
result = false;
|
|
271
|
+
}
|
|
272
|
+
const ret = result;
|
|
273
|
+
return ret;
|
|
274
|
+
},
|
|
275
|
+
__wbg_instanceof_Uint8Array_152ba1f289edcf3f: function(arg0) {
|
|
276
|
+
let result;
|
|
277
|
+
try {
|
|
278
|
+
result = getObject(arg0) instanceof Uint8Array;
|
|
279
|
+
} catch (_) {
|
|
280
|
+
result = false;
|
|
281
|
+
}
|
|
282
|
+
const ret = result;
|
|
283
|
+
return ret;
|
|
284
|
+
},
|
|
285
|
+
__wbg_isArray_c3109d14ffc06469: function(arg0) {
|
|
286
|
+
const ret = Array.isArray(getObject(arg0));
|
|
287
|
+
return ret;
|
|
288
|
+
},
|
|
289
|
+
__wbg_isSafeInteger_4fc213d1989d6d2a: function(arg0) {
|
|
290
|
+
const ret = Number.isSafeInteger(getObject(arg0));
|
|
291
|
+
return ret;
|
|
292
|
+
},
|
|
293
|
+
__wbg_iterator_013bc09ec998c2a7: function() {
|
|
294
|
+
const ret = Symbol.iterator;
|
|
295
|
+
return addHeapObject(ret);
|
|
296
|
+
},
|
|
297
|
+
__wbg_length_3d4ecd04bd8d22f1: function(arg0) {
|
|
298
|
+
const ret = getObject(arg0).length;
|
|
299
|
+
return ret;
|
|
300
|
+
},
|
|
301
|
+
__wbg_length_9f1775224cf1d815: function(arg0) {
|
|
302
|
+
const ret = getObject(arg0).length;
|
|
303
|
+
return ret;
|
|
304
|
+
},
|
|
305
|
+
__wbg_new_0c7403db6e782f19: function(arg0) {
|
|
306
|
+
const ret = new Uint8Array(getObject(arg0));
|
|
307
|
+
return addHeapObject(ret);
|
|
308
|
+
},
|
|
309
|
+
__wbg_new_682678e2f47e32bc: function() {
|
|
310
|
+
const ret = new Array();
|
|
311
|
+
return addHeapObject(ret);
|
|
312
|
+
},
|
|
313
|
+
__wbg_new_aa8d0fa9762c29bd: function() {
|
|
314
|
+
const ret = new Object();
|
|
315
|
+
return addHeapObject(ret);
|
|
316
|
+
},
|
|
317
|
+
__wbg_next_0340c4ae324393c3: function() { return handleError(function (arg0) {
|
|
318
|
+
const ret = getObject(arg0).next();
|
|
319
|
+
return addHeapObject(ret);
|
|
320
|
+
}, arguments); },
|
|
321
|
+
__wbg_next_7646edaa39458ef7: function(arg0) {
|
|
322
|
+
const ret = getObject(arg0).next;
|
|
323
|
+
return addHeapObject(ret);
|
|
324
|
+
},
|
|
325
|
+
__wbg_prototypesetcall_a6b02eb00b0f4ce2: function(arg0, arg1, arg2) {
|
|
326
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
327
|
+
},
|
|
328
|
+
__wbg_set_3bf1de9fab0cd644: function(arg0, arg1, arg2) {
|
|
329
|
+
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
|
|
330
|
+
},
|
|
331
|
+
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
332
|
+
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
|
333
|
+
},
|
|
334
|
+
__wbg_value_ee3a06f4579184fa: function(arg0) {
|
|
335
|
+
const ret = getObject(arg0).value;
|
|
336
|
+
return addHeapObject(ret);
|
|
337
|
+
},
|
|
338
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
339
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
340
|
+
const ret = arg0;
|
|
341
|
+
return addHeapObject(ret);
|
|
342
|
+
},
|
|
343
|
+
__wbindgen_cast_0000000000000002: function(arg0) {
|
|
344
|
+
// Cast intrinsic for `I64 -> Externref`.
|
|
345
|
+
const ret = arg0;
|
|
346
|
+
return addHeapObject(ret);
|
|
347
|
+
},
|
|
348
|
+
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
349
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
350
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
351
|
+
return addHeapObject(ret);
|
|
352
|
+
},
|
|
353
|
+
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
354
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
355
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
356
|
+
return addHeapObject(ret);
|
|
357
|
+
},
|
|
358
|
+
__wbindgen_object_clone_ref: function(arg0) {
|
|
359
|
+
const ret = getObject(arg0);
|
|
360
|
+
return addHeapObject(ret);
|
|
361
|
+
},
|
|
362
|
+
__wbindgen_object_drop_ref: function(arg0) {
|
|
363
|
+
takeObject(arg0);
|
|
364
|
+
},
|
|
365
|
+
};
|
|
366
|
+
return {
|
|
367
|
+
__proto__: null,
|
|
368
|
+
"./truecalc_wasm_bg.js": import0,
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
const EngineFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
373
|
+
? { register: () => {}, unregister: () => {} }
|
|
374
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_engine_free(ptr >>> 0, 1));
|
|
375
|
+
|
|
376
|
+
function addHeapObject(obj) {
|
|
377
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
378
|
+
const idx = heap_next;
|
|
379
|
+
heap_next = heap[idx];
|
|
380
|
+
|
|
381
|
+
heap[idx] = obj;
|
|
382
|
+
return idx;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function debugString(val) {
|
|
386
|
+
// primitive types
|
|
387
|
+
const type = typeof val;
|
|
388
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
389
|
+
return `${val}`;
|
|
390
|
+
}
|
|
391
|
+
if (type == 'string') {
|
|
392
|
+
return `"${val}"`;
|
|
393
|
+
}
|
|
394
|
+
if (type == 'symbol') {
|
|
395
|
+
const description = val.description;
|
|
396
|
+
if (description == null) {
|
|
397
|
+
return 'Symbol';
|
|
398
|
+
} else {
|
|
399
|
+
return `Symbol(${description})`;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
if (type == 'function') {
|
|
403
|
+
const name = val.name;
|
|
404
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
405
|
+
return `Function(${name})`;
|
|
406
|
+
} else {
|
|
407
|
+
return 'Function';
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
// objects
|
|
411
|
+
if (Array.isArray(val)) {
|
|
412
|
+
const length = val.length;
|
|
413
|
+
let debug = '[';
|
|
414
|
+
if (length > 0) {
|
|
415
|
+
debug += debugString(val[0]);
|
|
416
|
+
}
|
|
417
|
+
for(let i = 1; i < length; i++) {
|
|
418
|
+
debug += ', ' + debugString(val[i]);
|
|
419
|
+
}
|
|
420
|
+
debug += ']';
|
|
421
|
+
return debug;
|
|
422
|
+
}
|
|
423
|
+
// Test for built-in
|
|
424
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
425
|
+
let className;
|
|
426
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
427
|
+
className = builtInMatches[1];
|
|
428
|
+
} else {
|
|
429
|
+
// Failed to match the standard '[object ClassName]'
|
|
430
|
+
return toString.call(val);
|
|
431
|
+
}
|
|
432
|
+
if (className == 'Object') {
|
|
433
|
+
// we're a user defined class or Object
|
|
434
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
435
|
+
// easier than looping through ownProperties of `val`.
|
|
436
|
+
try {
|
|
437
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
438
|
+
} catch (_) {
|
|
439
|
+
return 'Object';
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
// errors
|
|
443
|
+
if (val instanceof Error) {
|
|
444
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
445
|
+
}
|
|
446
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
447
|
+
return className;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
function dropObject(idx) {
|
|
451
|
+
if (idx < 1028) return;
|
|
452
|
+
heap[idx] = heap_next;
|
|
453
|
+
heap_next = idx;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
457
|
+
ptr = ptr >>> 0;
|
|
458
|
+
const mem = getDataViewMemory0();
|
|
459
|
+
const result = [];
|
|
460
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
461
|
+
result.push(takeObject(mem.getUint32(i, true)));
|
|
462
|
+
}
|
|
463
|
+
return result;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
467
|
+
ptr = ptr >>> 0;
|
|
468
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
let cachedDataViewMemory0 = null;
|
|
472
|
+
function getDataViewMemory0() {
|
|
473
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
474
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
475
|
+
}
|
|
476
|
+
return cachedDataViewMemory0;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
function getStringFromWasm0(ptr, len) {
|
|
480
|
+
ptr = ptr >>> 0;
|
|
481
|
+
return decodeText(ptr, len);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
let cachedUint8ArrayMemory0 = null;
|
|
485
|
+
function getUint8ArrayMemory0() {
|
|
486
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
487
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
488
|
+
}
|
|
489
|
+
return cachedUint8ArrayMemory0;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
function getObject(idx) { return heap[idx]; }
|
|
493
|
+
|
|
494
|
+
function handleError(f, args) {
|
|
495
|
+
try {
|
|
496
|
+
return f.apply(this, args);
|
|
497
|
+
} catch (e) {
|
|
498
|
+
wasm.__wbindgen_export3(addHeapObject(e));
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
let heap = new Array(1024).fill(undefined);
|
|
503
|
+
heap.push(undefined, null, true, false);
|
|
504
|
+
|
|
505
|
+
let heap_next = heap.length;
|
|
506
|
+
|
|
507
|
+
function isLikeNone(x) {
|
|
508
|
+
return x === undefined || x === null;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
512
|
+
if (realloc === undefined) {
|
|
513
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
514
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
515
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
516
|
+
WASM_VECTOR_LEN = buf.length;
|
|
517
|
+
return ptr;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
let len = arg.length;
|
|
521
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
522
|
+
|
|
523
|
+
const mem = getUint8ArrayMemory0();
|
|
524
|
+
|
|
525
|
+
let offset = 0;
|
|
526
|
+
|
|
527
|
+
for (; offset < len; offset++) {
|
|
528
|
+
const code = arg.charCodeAt(offset);
|
|
529
|
+
if (code > 0x7F) break;
|
|
530
|
+
mem[ptr + offset] = code;
|
|
531
|
+
}
|
|
532
|
+
if (offset !== len) {
|
|
533
|
+
if (offset !== 0) {
|
|
534
|
+
arg = arg.slice(offset);
|
|
535
|
+
}
|
|
536
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
537
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
538
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
539
|
+
|
|
540
|
+
offset += ret.written;
|
|
541
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
WASM_VECTOR_LEN = offset;
|
|
545
|
+
return ptr;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
function takeObject(idx) {
|
|
549
|
+
const ret = getObject(idx);
|
|
550
|
+
dropObject(idx);
|
|
551
|
+
return ret;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
555
|
+
cachedTextDecoder.decode();
|
|
556
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
557
|
+
let numBytesDecoded = 0;
|
|
558
|
+
function decodeText(ptr, len) {
|
|
559
|
+
numBytesDecoded += len;
|
|
560
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
561
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
562
|
+
cachedTextDecoder.decode();
|
|
563
|
+
numBytesDecoded = len;
|
|
564
|
+
}
|
|
565
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
const cachedTextEncoder = new TextEncoder();
|
|
569
|
+
|
|
570
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
571
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
572
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
573
|
+
view.set(buf);
|
|
574
|
+
return {
|
|
575
|
+
read: arg.length,
|
|
576
|
+
written: buf.length
|
|
577
|
+
};
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
let WASM_VECTOR_LEN = 0;
|
|
582
|
+
|
|
583
|
+
let wasmModule, wasm;
|
|
584
|
+
function __wbg_finalize_init(instance, module) {
|
|
585
|
+
wasm = instance.exports;
|
|
586
|
+
wasmModule = module;
|
|
587
|
+
cachedDataViewMemory0 = null;
|
|
588
|
+
cachedUint8ArrayMemory0 = null;
|
|
589
|
+
return wasm;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
async function __wbg_load(module, imports) {
|
|
593
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
594
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
595
|
+
try {
|
|
596
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
597
|
+
} catch (e) {
|
|
598
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
599
|
+
|
|
600
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
601
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
602
|
+
|
|
603
|
+
} else { throw e; }
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
const bytes = await module.arrayBuffer();
|
|
608
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
609
|
+
} else {
|
|
610
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
611
|
+
|
|
612
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
613
|
+
return { instance, module };
|
|
614
|
+
} else {
|
|
615
|
+
return instance;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
function expectedResponseType(type) {
|
|
620
|
+
switch (type) {
|
|
621
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
622
|
+
}
|
|
623
|
+
return false;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
function initSync(module) {
|
|
628
|
+
if (wasm !== undefined) return wasm;
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
if (module !== undefined) {
|
|
632
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
633
|
+
({module} = module)
|
|
634
|
+
} else {
|
|
635
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
const imports = __wbg_get_imports();
|
|
640
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
641
|
+
module = new WebAssembly.Module(module);
|
|
642
|
+
}
|
|
643
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
644
|
+
return __wbg_finalize_init(instance, module);
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
async function __wbg_init(module_or_path) {
|
|
648
|
+
if (wasm !== undefined) return wasm;
|
|
649
|
+
|
|
650
|
+
|
|
651
|
+
if (module_or_path !== undefined) {
|
|
652
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
653
|
+
({module_or_path} = module_or_path)
|
|
654
|
+
} else {
|
|
655
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
if (module_or_path === undefined) {
|
|
660
|
+
module_or_path = new URL('truecalc_wasm_bg.wasm', import.meta.url);
|
|
661
|
+
}
|
|
662
|
+
const imports = __wbg_get_imports();
|
|
663
|
+
|
|
664
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
665
|
+
module_or_path = fetch(module_or_path);
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
669
|
+
|
|
670
|
+
return __wbg_finalize_init(instance, module);
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
export { initSync, __wbg_init as default };
|