logisheets 1.15.0 → 1.16.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.
Files changed (45) hide show
  1. package/README.md +3 -2
  2. package/dist/index.js +17 -0
  3. package/dist/src/api/block_manager.d.ts +2 -0
  4. package/dist/src/api/block_manager.js +2 -0
  5. package/dist/src/api/calculator.d.ts +12 -0
  6. package/dist/src/api/calculator.js +8 -0
  7. package/dist/src/api/cell.d.ts +4 -0
  8. package/dist/src/api/cell.js +4 -0
  9. package/dist/src/api/craft-calc.d.ts +11 -2
  10. package/dist/src/api/craft-calc.js +16 -2
  11. package/dist/src/api/utils.d.ts +8 -0
  12. package/dist/src/api/utils.js +7 -0
  13. package/dist/src/api/workbook.d.ts +114 -8
  14. package/dist/src/api/workbook.js +121 -5
  15. package/dist/src/api/worksheet.d.ts +31 -0
  16. package/dist/src/api/worksheet.js +31 -0
  17. package/dist/src/bindings/block_schema.d.ts +1 -0
  18. package/dist/src/bindings/define_name.d.ts +18 -0
  19. package/dist/src/bindings/define_name.js +30 -0
  20. package/dist/src/bindings/defined_name_info.d.ts +4 -0
  21. package/dist/src/bindings/defined_name_info.js +2 -0
  22. package/dist/src/bindings/edit_payload.d.ts +12 -0
  23. package/dist/src/bindings/index.d.ts +4 -0
  24. package/dist/src/bindings/index.js +4 -0
  25. package/dist/src/bindings/remove_name.d.ts +10 -0
  26. package/dist/src/bindings/remove_name.js +16 -0
  27. package/dist/src/bindings/rename_name.d.ts +14 -0
  28. package/dist/src/bindings/rename_name.js +23 -0
  29. package/dist/src/bindings/rpc_workbook_methods.d.ts +3 -1
  30. package/dist/src/bindings/save_file_result.d.ts +0 -1
  31. package/dist/src/client.d.ts +39 -2
  32. package/dist/src/layout.d.ts +2 -0
  33. package/dist/src/types.d.ts +8 -0
  34. package/dist/src/types.js +2 -0
  35. package/dist/src/utils.d.ts +4 -0
  36. package/dist/src/utils.js +4 -0
  37. package/dist/wasm/logisheets_wasm_server.d.ts +15 -7
  38. package/dist/wasm/logisheets_wasm_server.js +32 -26
  39. package/dist/wasm/logisheets_wasm_server_bg.wasm +0 -0
  40. package/dist/wasm/package.json +1 -1
  41. package/package.json +1 -1
  42. package/wasm/logisheets_wasm_server.d.ts +15 -7
  43. package/wasm/logisheets_wasm_server.js +32 -26
  44. package/wasm/logisheets_wasm_server_bg.wasm +0 -0
  45. package/wasm/package.json +1 -1
@@ -23,6 +23,7 @@ import { CheckFieldValidationParams } from './check_field_validation_params';
23
23
  import { CheckFormulaParams } from './rpc_check_formula_params';
24
24
  import { CheckpointMetaDto } from './checkpoint_meta';
25
25
  import { Comment } from './comment';
26
+ import { DefinedNameInfo } from './defined_name_info';
26
27
  import { DeleteCheckpointParams } from './rpc_delete_checkpoint_params';
27
28
  import { DependentCell } from './dependent_cell';
28
29
  import { DisplayWindow } from './display_window';
@@ -146,6 +147,7 @@ export interface WorkbookMethods {
146
147
  getAllBlockFields(bookId?: number): Promise<readonly BlockField[] | ErrorMessage>;
147
148
  duplicateBlockKeys(bookId?: number): Promise<readonly DuplicateBlockKey[] | ErrorMessage>;
148
149
  getEnumSets(bookId?: number): Promise<readonly EnumSetInfo[] | ErrorMessage>;
150
+ getDefinedNames(bookId?: number): Promise<readonly DefinedNameInfo[] | ErrorMessage>;
149
151
  getBlockOpForPayloads(bookId?: number): Promise<readonly BlockOpForPayload[] | ErrorMessage>;
150
152
  getBlockOpPolicies(params: GetBlockOpPoliciesParams, bookId?: number): Promise<readonly BlockOpPolicy[] | ErrorMessage>;
151
153
  getAllBlocks(params: GetAllBlocksParams, bookId?: number): Promise<readonly BlockInfo[] | ErrorMessage>;
@@ -169,7 +171,7 @@ export interface WorkbookMethods {
169
171
  cleanHistory(bookId?: number): Promise<void | ErrorMessage>;
170
172
  toggleStatus(params: ToggleStatusParams, bookId?: number): Promise<void | ErrorMessage>;
171
173
  cleanupTempStatus(bookId?: number): Promise<void | ErrorMessage>;
172
- commitTempStatus(bookId?: number): Promise<ActionEffect | ErrorMessage>;
174
+ commitTempStatus(bookId?: number): Promise<void | ErrorMessage>;
173
175
  loadWorkbook(params: LoadWorkbookParams, bookId?: number): Promise<void | ErrorMessage>;
174
176
  save(params: SaveParams, bookId?: number): Promise<SaveFileResult | ErrorMessage>;
175
177
  getAppData(bookId?: number): Promise<readonly AppData[] | ErrorMessage>;
@@ -1,4 +1,3 @@
1
1
  export interface SaveFileResult {
2
2
  data: Uint8Array;
3
- code: number;
4
3
  }
@@ -1,16 +1,49 @@
1
1
  import type { ErrorMessage, ActionEffect, SheetCellId, WorkbookMethods, HandleTransactionParams } from './bindings';
2
2
  import type { CustomFunc } from './api';
3
+ /** An async engine reply: the value, or an {@link ErrorMessage} on failure. */
3
4
  export type Resp<T> = Promise<T | ErrorMessage>;
4
5
  /**
5
- * The client is the interface for the workbook. This is used when the workbook
6
- * is wrapped by a server.
6
+ * The async engine contract shared logic codes against. Every method of the
7
+ * generated {@link WorkbookMethods} is `method(params) => Promise<T |
8
+ * ErrorMessage>`, bound to one workbook.
9
+ *
10
+ * Implementations: logisheets-engine's worker-backed `WorkbookClient` in the
11
+ * browser, and logisheets-runtime's `handle()` proxy on Node. The
12
+ * `register*` members below are host-side subscriptions; the Node proxy does
13
+ * not implement them, so code that must run headless should not rely on them.
14
+ *
15
+ * Failure contract (holds for every implementation):
16
+ * - Methods never reject for an engine-level failure; they resolve an
17
+ * `ErrorMessage` (check with `isErrorMessage`).
18
+ * - `handleTransaction` does NOT resolve an `ErrorMessage` when the engine
19
+ * refuses the edit. It resolves an `ActionEffect` whose
20
+ * `status.type === 'err'`, with the reason in `errorMessage`, and nothing
21
+ * is applied. A caller that needs the write to land must check `status`.
7
22
  */
8
23
  export interface Client extends WorkbookMethods {
24
+ /** Resolves once the engine can serve calls (the browser worker has
25
+ * loaded its WASM). Await it before the first call. */
9
26
  isReady(): Promise<void>;
27
+ /**
28
+ * `handleTransaction` without the host's per-cell change notifications.
29
+ * Same failure contract: a rejection is `status.type === 'err'`.
30
+ */
10
31
  handleTransactionWithoutEvents(params: HandleTransactionParams): Resp<ActionEffect>;
32
+ /** Register a custom formula function. Not implemented by the browser
33
+ * worker client. */
11
34
  registerCustomFunc(f: CustomFunc): void;
35
+ /** Fires after a transaction the engine reports as changing cells
36
+ * (status `cell` / `sheetAndCell`). */
12
37
  registerCellUpdatedCallback(f: () => void): void;
38
+ /** Fires after a transaction the engine reports as changing sheet-level
39
+ * state (status `sheet` / `sheetAndCell`). */
13
40
  registerSheetUpdatedCallback(f: () => void): void;
41
+ /**
42
+ * Subscribe to value changes of the cell currently at (sheetIdx, rowIdx,
43
+ * colIdx), all 0-based. The coordinate is resolved to a stable cell id
44
+ * once, so the subscription follows the cell if rows/cols move. Resolves
45
+ * an `ErrorMessage` if the coordinate cannot be resolved.
46
+ */
14
47
  registerCellValueChangedCallback(sheetIdx: number, rowIdx: number, colIdx: number, callback: () => void): Resp<void>;
15
48
  /**
16
49
  * Like {@link registerCellValueChangedCallback} but takes a
@@ -20,6 +53,10 @@ export interface Client extends WorkbookMethods {
20
53
  * round-trip.
21
54
  */
22
55
  registerCellValueChangedByCellId(cellId: SheetCellId, callback: () => void): void;
56
+ /** Like {@link registerCellValueChangedCallback}, but fires when the cell
57
+ * is removed (its row/col deleted). */
23
58
  registerCellRemovedCallback(sheetIdx: number, rowIdx: number, colIdx: number, callback: () => void): Resp<void>;
59
+ /** Subscribe to a cell's shadow (validation) cell. Not implemented by the
60
+ * browser worker client. */
24
61
  registerShadowCellValueChangedCallback(sheetIdx: number, rowIdx: number, colIdx: number, callback: () => void): Resp<number>;
25
62
  }
@@ -1,3 +1,5 @@
1
+ /** A per-cell overlay (marker colour, tooltip) a craft asks the host to draw
2
+ * via `window.setCellLayouts`. Row and column are 0-based sheet coordinates. */
1
3
  export interface CellLayout {
2
4
  readonly sheetIdx: number;
3
5
  readonly row: number;
@@ -1,10 +1,15 @@
1
1
  import { CellCoordinate } from './bindings';
2
+ /** Stable ids of a block's lines; they survive inserts and reorders, unlike
3
+ * indexes. See `Workbook.getBlockRowId` / `getBlockColId`. */
2
4
  export type RowId = number;
3
5
  export type ColId = number;
6
+ /** What the user has selected on one sheet (0-based indexes). */
4
7
  export interface Selection {
5
8
  readonly sheetIdx: number;
6
9
  readonly data: SelectedData;
7
10
  }
11
+ /** Either whole rows/columns or a cell rectangle; `data` is absent when
12
+ * nothing is selected. */
8
13
  export interface SelectedData {
9
14
  readonly data?: {
10
15
  ty: 'line';
@@ -15,6 +20,7 @@ export interface SelectedData {
15
20
  };
16
21
  readonly source: 'editbar' | 'none';
17
22
  }
23
+ /** A cell rectangle; both bounds inclusive. */
18
24
  export interface SelectedCellRange {
19
25
  readonly startRow: number;
20
26
  readonly endRow: number;
@@ -26,6 +32,8 @@ export interface SelectedLines {
26
32
  readonly end: number;
27
33
  readonly type: 'row' | 'col';
28
34
  }
35
+ /** Top-left cell of the selection (`y` = row, `x` = column). Throws when
36
+ * nothing is selected. */
29
37
  export declare function getFirstCell(v: SelectedData): CellCoordinate;
30
38
  export declare function getSelectedCellRange(v: SelectedData): SelectedCellRange | undefined;
31
39
  export declare function getSelectedLines(v: SelectedData): SelectedLines | undefined;
package/dist/src/types.js CHANGED
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getFirstCell = getFirstCell;
4
4
  exports.getSelectedCellRange = getSelectedCellRange;
5
5
  exports.getSelectedLines = getSelectedLines;
6
+ /** Top-left cell of the selection (`y` = row, `x` = column). Throws when
7
+ * nothing is selected. */
6
8
  function getFirstCell(v) {
7
9
  const r = getSelectedCellRange(v);
8
10
  if (r)
@@ -1 +1,5 @@
1
+ /**
2
+ * A 0-based column index as A1 column letters: 0 -> `A`, 25 -> `Z`,
3
+ * 26 -> `AA`. Throws for a negative or non-integer index.
4
+ */
1
5
  export declare function toA1notation(index: number): string;
package/dist/src/utils.js CHANGED
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toA1notation = toA1notation;
4
+ /**
5
+ * A 0-based column index as A1 column letters: 0 -> `A`, 25 -> `Z`,
6
+ * 26 -> `AA`. Throws for a negative or non-integer index.
7
+ */
4
8
  function toA1notation(index) {
5
9
  /**
6
10
  * The algorithm employed here is the same as converting numbers between
@@ -1,6 +1,18 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+ /**
4
+ * The single RPC entry point. `msg` is a [`Message`] as JS (a bare method
5
+ * name for a unit variant, otherwise `{method, value}`); `book_id` names the
6
+ * workbook and is required by everything except `newWorkbook`, which returns
7
+ * the id to use. Answers the method's result or an `ErrorMessage`, told apart
8
+ * by shape on the JS side.
9
+ */
3
10
  export function handle(msg: any, book_id?: number | null): any;
11
+ /**
12
+ * Render a text value with an Excel number-format code (for the `@` text
13
+ * section). Falls back to the text itself on an unsupported format.
14
+ */
15
+ export function format_text(fmt: string, text: string): string;
4
16
  /**
5
17
  * Render a number with an Excel number-format code, natively via `ssf-rs`
6
18
  * (the Rust port of SheetJS `ssf`). Replaces the browser's old dependency on
@@ -9,12 +21,8 @@ export function handle(msg: any, book_id?: number | null): any;
9
21
  */
10
22
  export function format_number(fmt: string, value: number): string;
11
23
  /**
12
- * Render a text value with an Excel number-format code (for the `@` text
13
- * section). Falls back to the text itself on an unsupported format.
14
- */
15
- export function format_text(fmt: string, text: string): string;
16
- /**
17
- * Input: AsyncFuncResult
18
- * Output: ActionAffect
24
+ * Deliver the values the host computed for this workbook's async functions:
25
+ * an `AsyncFuncResult` in, an `ActionEffect` or an `ErrorMessage` out. Like
26
+ * `rpc::handle`, this must never panic.
19
27
  */
20
28
  export function input_async_result(id: number, result: any): any;
@@ -171,6 +171,11 @@ function debugString(val) {
171
171
  return className;
172
172
  }
173
173
  /**
174
+ * The single RPC entry point. `msg` is a [`Message`] as JS (a bare method
175
+ * name for a unit variant, otherwise `{method, value}`); `book_id` names the
176
+ * workbook and is required by everything except `newWorkbook`, which returns
177
+ * the id to use. Answers the method's result or an `ErrorMessage`, told apart
178
+ * by shape on the JS side.
174
179
  * @param {any} msg
175
180
  * @param {number | null} [book_id]
176
181
  * @returns {any}
@@ -180,30 +185,6 @@ module.exports.handle = function(msg, book_id) {
180
185
  return ret;
181
186
  };
182
187
 
183
- /**
184
- * Render a number with an Excel number-format code, natively via `ssf-rs`
185
- * (the Rust port of SheetJS `ssf`). Replaces the browser's old dependency on
186
- * the `ssf` npm package. On an unsupported/invalid format it falls back to the
187
- * JavaScript `String(value)` representation, matching the previous behavior.
188
- * @param {string} fmt
189
- * @param {number} value
190
- * @returns {string}
191
- */
192
- module.exports.format_number = function(fmt, value) {
193
- let deferred2_0;
194
- let deferred2_1;
195
- try {
196
- const ptr0 = passStringToWasm0(fmt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
197
- const len0 = WASM_VECTOR_LEN;
198
- const ret = wasm.format_number(ptr0, len0, value);
199
- deferred2_0 = ret[0];
200
- deferred2_1 = ret[1];
201
- return getStringFromWasm0(ret[0], ret[1]);
202
- } finally {
203
- wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
204
- }
205
- };
206
-
207
188
  /**
208
189
  * Render a text value with an Excel number-format code (for the `@` text
209
190
  * section). Falls back to the text itself on an unsupported format.
@@ -229,8 +210,33 @@ module.exports.format_text = function(fmt, text) {
229
210
  };
230
211
 
231
212
  /**
232
- * Input: AsyncFuncResult
233
- * Output: ActionAffect
213
+ * Render a number with an Excel number-format code, natively via `ssf-rs`
214
+ * (the Rust port of SheetJS `ssf`). Replaces the browser's old dependency on
215
+ * the `ssf` npm package. On an unsupported/invalid format it falls back to the
216
+ * JavaScript `String(value)` representation, matching the previous behavior.
217
+ * @param {string} fmt
218
+ * @param {number} value
219
+ * @returns {string}
220
+ */
221
+ module.exports.format_number = function(fmt, value) {
222
+ let deferred2_0;
223
+ let deferred2_1;
224
+ try {
225
+ const ptr0 = passStringToWasm0(fmt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
226
+ const len0 = WASM_VECTOR_LEN;
227
+ const ret = wasm.format_number(ptr0, len0, value);
228
+ deferred2_0 = ret[0];
229
+ deferred2_1 = ret[1];
230
+ return getStringFromWasm0(ret[0], ret[1]);
231
+ } finally {
232
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
233
+ }
234
+ };
235
+
236
+ /**
237
+ * Deliver the values the host computed for this workbook's async functions:
238
+ * an `AsyncFuncResult` in, an `ActionEffect` or an `ErrorMessage` out. Like
239
+ * `rpc::handle`, this must never panic.
234
240
  * @param {number} id
235
241
  * @param {any} result
236
242
  * @returns {any}
@@ -3,7 +3,7 @@
3
3
  "collaborators": [
4
4
  "JeremyHe <yiliang.he@qq.com>"
5
5
  ],
6
- "version": "1.15.0",
6
+ "version": "1.16.0",
7
7
  "files": [
8
8
  "logisheets_wasm_server_bg.wasm",
9
9
  "logisheets_wasm_server.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "logisheets",
3
- "version": "1.15.0",
3
+ "version": "1.16.0",
4
4
  "description": "Node.js bindings for LogiSheets — a Rust + WebAssembly spreadsheet engine that reads, edits, and writes real .xlsx (Excel) files (formulas, styles, and structure preserved) with no browser required.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1,6 +1,18 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+ /**
4
+ * The single RPC entry point. `msg` is a [`Message`] as JS (a bare method
5
+ * name for a unit variant, otherwise `{method, value}`); `book_id` names the
6
+ * workbook and is required by everything except `newWorkbook`, which returns
7
+ * the id to use. Answers the method's result or an `ErrorMessage`, told apart
8
+ * by shape on the JS side.
9
+ */
3
10
  export function handle(msg: any, book_id?: number | null): any;
11
+ /**
12
+ * Render a text value with an Excel number-format code (for the `@` text
13
+ * section). Falls back to the text itself on an unsupported format.
14
+ */
15
+ export function format_text(fmt: string, text: string): string;
4
16
  /**
5
17
  * Render a number with an Excel number-format code, natively via `ssf-rs`
6
18
  * (the Rust port of SheetJS `ssf`). Replaces the browser's old dependency on
@@ -9,12 +21,8 @@ export function handle(msg: any, book_id?: number | null): any;
9
21
  */
10
22
  export function format_number(fmt: string, value: number): string;
11
23
  /**
12
- * Render a text value with an Excel number-format code (for the `@` text
13
- * section). Falls back to the text itself on an unsupported format.
14
- */
15
- export function format_text(fmt: string, text: string): string;
16
- /**
17
- * Input: AsyncFuncResult
18
- * Output: ActionAffect
24
+ * Deliver the values the host computed for this workbook's async functions:
25
+ * an `AsyncFuncResult` in, an `ActionEffect` or an `ErrorMessage` out. Like
26
+ * `rpc::handle`, this must never panic.
19
27
  */
20
28
  export function input_async_result(id: number, result: any): any;
@@ -171,6 +171,11 @@ function debugString(val) {
171
171
  return className;
172
172
  }
173
173
  /**
174
+ * The single RPC entry point. `msg` is a [`Message`] as JS (a bare method
175
+ * name for a unit variant, otherwise `{method, value}`); `book_id` names the
176
+ * workbook and is required by everything except `newWorkbook`, which returns
177
+ * the id to use. Answers the method's result or an `ErrorMessage`, told apart
178
+ * by shape on the JS side.
174
179
  * @param {any} msg
175
180
  * @param {number | null} [book_id]
176
181
  * @returns {any}
@@ -180,30 +185,6 @@ module.exports.handle = function(msg, book_id) {
180
185
  return ret;
181
186
  };
182
187
 
183
- /**
184
- * Render a number with an Excel number-format code, natively via `ssf-rs`
185
- * (the Rust port of SheetJS `ssf`). Replaces the browser's old dependency on
186
- * the `ssf` npm package. On an unsupported/invalid format it falls back to the
187
- * JavaScript `String(value)` representation, matching the previous behavior.
188
- * @param {string} fmt
189
- * @param {number} value
190
- * @returns {string}
191
- */
192
- module.exports.format_number = function(fmt, value) {
193
- let deferred2_0;
194
- let deferred2_1;
195
- try {
196
- const ptr0 = passStringToWasm0(fmt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
197
- const len0 = WASM_VECTOR_LEN;
198
- const ret = wasm.format_number(ptr0, len0, value);
199
- deferred2_0 = ret[0];
200
- deferred2_1 = ret[1];
201
- return getStringFromWasm0(ret[0], ret[1]);
202
- } finally {
203
- wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
204
- }
205
- };
206
-
207
188
  /**
208
189
  * Render a text value with an Excel number-format code (for the `@` text
209
190
  * section). Falls back to the text itself on an unsupported format.
@@ -229,8 +210,33 @@ module.exports.format_text = function(fmt, text) {
229
210
  };
230
211
 
231
212
  /**
232
- * Input: AsyncFuncResult
233
- * Output: ActionAffect
213
+ * Render a number with an Excel number-format code, natively via `ssf-rs`
214
+ * (the Rust port of SheetJS `ssf`). Replaces the browser's old dependency on
215
+ * the `ssf` npm package. On an unsupported/invalid format it falls back to the
216
+ * JavaScript `String(value)` representation, matching the previous behavior.
217
+ * @param {string} fmt
218
+ * @param {number} value
219
+ * @returns {string}
220
+ */
221
+ module.exports.format_number = function(fmt, value) {
222
+ let deferred2_0;
223
+ let deferred2_1;
224
+ try {
225
+ const ptr0 = passStringToWasm0(fmt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
226
+ const len0 = WASM_VECTOR_LEN;
227
+ const ret = wasm.format_number(ptr0, len0, value);
228
+ deferred2_0 = ret[0];
229
+ deferred2_1 = ret[1];
230
+ return getStringFromWasm0(ret[0], ret[1]);
231
+ } finally {
232
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
233
+ }
234
+ };
235
+
236
+ /**
237
+ * Deliver the values the host computed for this workbook's async functions:
238
+ * an `AsyncFuncResult` in, an `ActionEffect` or an `ErrorMessage` out. Like
239
+ * `rpc::handle`, this must never panic.
234
240
  * @param {number} id
235
241
  * @param {any} result
236
242
  * @returns {any}
Binary file
package/wasm/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "collaborators": [
4
4
  "JeremyHe <yiliang.he@qq.com>"
5
5
  ],
6
- "version": "1.15.0",
6
+ "version": "1.16.0",
7
7
  "files": [
8
8
  "logisheets_wasm_server_bg.wasm",
9
9
  "logisheets_wasm_server.js",