@truecalc/core 6.0.1 → 7.0.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
@@ -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": "6.0.1",
5
+ "version": "7.0.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -1,5 +1,27 @@
1
1
  /* tslint:disable */
2
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
+
3
25
  /**
4
26
  * The result of evaluating a formula on the WASM surface.
5
27
  *
@@ -25,7 +47,7 @@
25
47
  * - `{ type: \"array\", value: [ EvalResult, ... ] }` -- recursive; a 2-D result is
26
48
  * `{ type: \"array\", value: [ { type: \"array\", value: [ <cells> ] }, ... ] }`
27
49
  */
28
- 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[] };
50
+ 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 };
29
51
 
30
52
  export interface FunctionInfo {
31
53
  name: string;
@@ -34,6 +56,11 @@ export interface FunctionInfo {
34
56
  description: string;
35
57
  }
36
58
 
59
+ export interface RenameSheetRefsResult {
60
+ formula?: string;
61
+ error?: string;
62
+ }
63
+
37
64
  export interface TranslateResult {
38
65
  formula?: string;
39
66
  error?: string;
@@ -83,6 +110,16 @@ export function evaluate(formula: string, variables: any): EvalResult;
83
110
  */
84
111
  export function list_functions(): FunctionInfo[];
85
112
 
113
+ /**
114
+ * Rewrite the sheet qualifier of every cell/range reference in `formula`
115
+ * that points at `old` to point at `new` instead — the sheet-rename
116
+ * reference-rewrite transform. Sheet-name matching is case-insensitive.
117
+ * Requoting is handled automatically. Unqualified refs, refs to other
118
+ * sheets, string literals, function names, and defined names are left
119
+ * untouched; no-op if `formula` has no `old`-qualified refs.
120
+ */
121
+ export function rename_sheet_refs(formula: string, old: string, _new: string): RenameSheetRefsResult;
122
+
86
123
  /**
87
124
  * Shift every relative cell/range reference in `formula` by `(d_row, d_col)`
88
125
  * — the fill / copy-paste reference-adjustment transform. `$`-absolute axes
package/truecalc_wasm.js CHANGED
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./truecalc_wasm_bg.js";
5
5
  __wbg_set_wasm(wasm);
6
6
 
7
7
  export {
8
- Engine, createEngine, evaluate, list_functions, translate_formula, validate
8
+ Engine, createEngine, evaluate, list_functions, rename_sheet_refs, translate_formula, validate
9
9
  } from "./truecalc_wasm_bg.js";
@@ -98,6 +98,29 @@ export function list_functions() {
98
98
  }
99
99
  }
100
100
 
101
+ /**
102
+ * Rewrite the sheet qualifier of every cell/range reference in `formula`
103
+ * that points at `old` to point at `new` instead — the sheet-rename
104
+ * reference-rewrite transform. Sheet-name matching is case-insensitive.
105
+ * Requoting is handled automatically. Unqualified refs, refs to other
106
+ * sheets, string literals, function names, and defined names are left
107
+ * untouched; no-op if `formula` has no `old`-qualified refs.
108
+ * @param {string} formula
109
+ * @param {string} old
110
+ * @param {string} _new
111
+ * @returns {RenameSheetRefsResult}
112
+ */
113
+ export function rename_sheet_refs(formula, old, _new) {
114
+ const ptr0 = passStringToWasm0(formula, wasm.__wbindgen_export, wasm.__wbindgen_export2);
115
+ const len0 = WASM_VECTOR_LEN;
116
+ const ptr1 = passStringToWasm0(old, wasm.__wbindgen_export, wasm.__wbindgen_export2);
117
+ const len1 = WASM_VECTOR_LEN;
118
+ const ptr2 = passStringToWasm0(_new, wasm.__wbindgen_export, wasm.__wbindgen_export2);
119
+ const len2 = WASM_VECTOR_LEN;
120
+ const ret = wasm.rename_sheet_refs(ptr0, len0, ptr1, len1, ptr2, len2);
121
+ return takeObject(ret);
122
+ }
123
+
101
124
  /**
102
125
  * Shift every relative cell/range reference in `formula` by `(d_row, d_col)`
103
126
  * — the fill / copy-paste reference-adjustment transform. `$`-absolute axes
Binary file