logisheets 1.15.1 → 1.16.1

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/define_name.d.ts +18 -0
  18. package/dist/src/bindings/define_name.js +30 -0
  19. package/dist/src/bindings/defined_name_info.d.ts +4 -0
  20. package/dist/src/bindings/defined_name_info.js +2 -0
  21. package/dist/src/bindings/edit_payload.d.ts +12 -0
  22. package/dist/src/bindings/index.d.ts +4 -0
  23. package/dist/src/bindings/index.js +4 -0
  24. package/dist/src/bindings/remove_name.d.ts +10 -0
  25. package/dist/src/bindings/remove_name.js +16 -0
  26. package/dist/src/bindings/rename_name.d.ts +14 -0
  27. package/dist/src/bindings/rename_name.js +23 -0
  28. package/dist/src/bindings/rpc_workbook_methods.d.ts +3 -1
  29. package/dist/src/bindings/save_file_result.d.ts +0 -1
  30. package/dist/src/client.d.ts +39 -2
  31. package/dist/src/layout.d.ts +2 -0
  32. package/dist/src/pure.js +10 -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 +2 -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
@@ -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;
package/dist/src/pure.js CHANGED
@@ -10,6 +10,16 @@
10
10
  // handle factory, and the Client *type*. Consumers that only need to construct
11
11
  // payloads / inspect types / share logic (e.g. logician running on Node) import
12
12
  // from here and stay engine-free.
13
+ //
14
+ // The `node` export condition resolves to `dist/pure.node.js`, an esbuild
15
+ // bundle of this file, NOT to the tsc output beside it. That is not an
16
+ // optimization: this package's relative imports are all extensionless and
17
+ // `./bindings` is a directory, both of which only a bundler resolves — and
18
+ // `src/bindings` is generated by gents ("DO NOT EDIT", 290 files), so the
19
+ // specifiers cannot simply be rewritten. Bundling is what makes this subpath
20
+ // loadable under plain Node ESM; `packages/node/__tests__/packaging.test.ts`
21
+ // holds that line. Everything else (browsers, bundlers) still gets the tsc
22
+ // output via `default`.
13
23
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
24
  if (k2 === undefined) k2 = k;
15
25
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -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,9 +1,22 @@
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;
4
11
  /**
5
- * Input: AsyncFuncResult
6
- * Output: ActionAffect
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
+ * Deliver the values the host computed for this workbook's async functions:
18
+ * an `AsyncFuncResult` in, an `ActionEffect` or an `ErrorMessage` out. Like
19
+ * `rpc::handle`, this must never panic.
7
20
  */
8
21
  export function input_async_result(id: number, result: any): any;
9
22
  /**
@@ -13,8 +26,3 @@ export function input_async_result(id: number, result: any): any;
13
26
  * JavaScript `String(value)` representation, matching the previous behavior.
14
27
  */
15
28
  export function format_number(fmt: string, value: number): string;
16
- /**
17
- * Render a text value with an Excel number-format code (for the `@` text
18
- * section). Falls back to the text itself on an unsupported format.
19
- */
20
- export function format_text(fmt: string, text: string): string;
@@ -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}
@@ -181,8 +186,33 @@ module.exports.handle = function(msg, book_id) {
181
186
  };
182
187
 
183
188
  /**
184
- * Input: AsyncFuncResult
185
- * Output: ActionAffect
189
+ * Render a text value with an Excel number-format code (for the `@` text
190
+ * section). Falls back to the text itself on an unsupported format.
191
+ * @param {string} fmt
192
+ * @param {string} text
193
+ * @returns {string}
194
+ */
195
+ module.exports.format_text = function(fmt, text) {
196
+ let deferred3_0;
197
+ let deferred3_1;
198
+ try {
199
+ const ptr0 = passStringToWasm0(fmt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
200
+ const len0 = WASM_VECTOR_LEN;
201
+ const ptr1 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
202
+ const len1 = WASM_VECTOR_LEN;
203
+ const ret = wasm.format_text(ptr0, len0, ptr1, len1);
204
+ deferred3_0 = ret[0];
205
+ deferred3_1 = ret[1];
206
+ return getStringFromWasm0(ret[0], ret[1]);
207
+ } finally {
208
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
209
+ }
210
+ };
211
+
212
+ /**
213
+ * Deliver the values the host computed for this workbook's async functions:
214
+ * an `AsyncFuncResult` in, an `ActionEffect` or an `ErrorMessage` out. Like
215
+ * `rpc::handle`, this must never panic.
186
216
  * @param {number} id
187
217
  * @param {any} result
188
218
  * @returns {any}
@@ -216,30 +246,6 @@ module.exports.format_number = function(fmt, value) {
216
246
  }
217
247
  };
218
248
 
219
- /**
220
- * Render a text value with an Excel number-format code (for the `@` text
221
- * section). Falls back to the text itself on an unsupported format.
222
- * @param {string} fmt
223
- * @param {string} text
224
- * @returns {string}
225
- */
226
- module.exports.format_text = function(fmt, text) {
227
- let deferred3_0;
228
- let deferred3_1;
229
- try {
230
- const ptr0 = passStringToWasm0(fmt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
231
- const len0 = WASM_VECTOR_LEN;
232
- const ptr1 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
233
- const len1 = WASM_VECTOR_LEN;
234
- const ret = wasm.format_text(ptr0, len0, ptr1, len1);
235
- deferred3_0 = ret[0];
236
- deferred3_1 = ret[1];
237
- return getStringFromWasm0(ret[0], ret[1]);
238
- } finally {
239
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
240
- }
241
- };
242
-
243
249
  module.exports.__wbg_String_eecc4a11987127d6 = function(arg0, arg1) {
244
250
  const ret = String(arg1);
245
251
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -3,7 +3,7 @@
3
3
  "collaborators": [
4
4
  "JeremyHe <yiliang.he@qq.com>"
5
5
  ],
6
- "version": "1.15.1",
6
+ "version": "1.16.1",
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.1",
3
+ "version": "1.16.1",
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",
@@ -9,6 +9,7 @@
9
9
  "link": "rm -rf ./src && cp -r ../web/src ./src",
10
10
  "build": "yarn wasm-build && npx tsc && cp -R wasm dist/",
11
11
  "test": "npx vitest run",
12
+ "test:packaging": "npx vitest run --config vitest.packaging.config.ts",
12
13
  "prepublishOnly": "yarn run link && yarn wasm-build && yarn build",
13
14
  "prepare": "yarn link && yarn wasm-build"
14
15
  },
@@ -1,9 +1,22 @@
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;
4
11
  /**
5
- * Input: AsyncFuncResult
6
- * Output: ActionAffect
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
+ * Deliver the values the host computed for this workbook's async functions:
18
+ * an `AsyncFuncResult` in, an `ActionEffect` or an `ErrorMessage` out. Like
19
+ * `rpc::handle`, this must never panic.
7
20
  */
8
21
  export function input_async_result(id: number, result: any): any;
9
22
  /**
@@ -13,8 +26,3 @@ export function input_async_result(id: number, result: any): any;
13
26
  * JavaScript `String(value)` representation, matching the previous behavior.
14
27
  */
15
28
  export function format_number(fmt: string, value: number): string;
16
- /**
17
- * Render a text value with an Excel number-format code (for the `@` text
18
- * section). Falls back to the text itself on an unsupported format.
19
- */
20
- export function format_text(fmt: string, text: string): string;
@@ -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}
@@ -181,8 +186,33 @@ module.exports.handle = function(msg, book_id) {
181
186
  };
182
187
 
183
188
  /**
184
- * Input: AsyncFuncResult
185
- * Output: ActionAffect
189
+ * Render a text value with an Excel number-format code (for the `@` text
190
+ * section). Falls back to the text itself on an unsupported format.
191
+ * @param {string} fmt
192
+ * @param {string} text
193
+ * @returns {string}
194
+ */
195
+ module.exports.format_text = function(fmt, text) {
196
+ let deferred3_0;
197
+ let deferred3_1;
198
+ try {
199
+ const ptr0 = passStringToWasm0(fmt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
200
+ const len0 = WASM_VECTOR_LEN;
201
+ const ptr1 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
202
+ const len1 = WASM_VECTOR_LEN;
203
+ const ret = wasm.format_text(ptr0, len0, ptr1, len1);
204
+ deferred3_0 = ret[0];
205
+ deferred3_1 = ret[1];
206
+ return getStringFromWasm0(ret[0], ret[1]);
207
+ } finally {
208
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
209
+ }
210
+ };
211
+
212
+ /**
213
+ * Deliver the values the host computed for this workbook's async functions:
214
+ * an `AsyncFuncResult` in, an `ActionEffect` or an `ErrorMessage` out. Like
215
+ * `rpc::handle`, this must never panic.
186
216
  * @param {number} id
187
217
  * @param {any} result
188
218
  * @returns {any}
@@ -216,30 +246,6 @@ module.exports.format_number = function(fmt, value) {
216
246
  }
217
247
  };
218
248
 
219
- /**
220
- * Render a text value with an Excel number-format code (for the `@` text
221
- * section). Falls back to the text itself on an unsupported format.
222
- * @param {string} fmt
223
- * @param {string} text
224
- * @returns {string}
225
- */
226
- module.exports.format_text = function(fmt, text) {
227
- let deferred3_0;
228
- let deferred3_1;
229
- try {
230
- const ptr0 = passStringToWasm0(fmt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
231
- const len0 = WASM_VECTOR_LEN;
232
- const ptr1 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
233
- const len1 = WASM_VECTOR_LEN;
234
- const ret = wasm.format_text(ptr0, len0, ptr1, len1);
235
- deferred3_0 = ret[0];
236
- deferred3_1 = ret[1];
237
- return getStringFromWasm0(ret[0], ret[1]);
238
- } finally {
239
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
240
- }
241
- };
242
-
243
249
  module.exports.__wbg_String_eecc4a11987127d6 = function(arg0, arg1) {
244
250
  const ret = String(arg1);
245
251
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
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.1",
6
+ "version": "1.16.1",
7
7
  "files": [
8
8
  "logisheets_wasm_server_bg.wasm",
9
9
  "logisheets_wasm_server.js",