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
@@ -6,6 +6,10 @@ const worksheet_1 = require("./worksheet");
6
6
  const calculator_1 = require("./calculator");
7
7
  const utils_1 = require("./utils");
8
8
  const block_manager_1 = require("./block_manager");
9
+ // Every engine call is one `handle(msg, bookId)` into the WASM, where `msg` is
10
+ // the bare method name for a parameterless call and `{method, value}`
11
+ // otherwise. `handle` never throws for an engine failure: it returns an
12
+ // `ErrorMessage`, which is why the methods below type their result `Result<T>`.
9
13
  function rpc(method, params, bookId
10
14
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
15
  ) {
@@ -17,7 +21,27 @@ function rpc(method, params, bookId
17
21
  function newGuid() {
18
22
  return `{${crypto.randomUUID()}}`;
19
23
  }
24
+ /**
25
+ * A synchronous handle on one engine workbook, living in the calling thread.
26
+ *
27
+ * In the browser, `initWasm()` must have resolved before the constructor runs;
28
+ * the Node build needs no init. The app does not use this directly on the main
29
+ * thread: logisheets-engine runs one inside its web worker and exposes it as
30
+ * the async {@link Client}. Shared code should target `Client`.
31
+ *
32
+ * Conventions for every method:
33
+ * - Sheet, row and column indexes are 0-based. `sheetIdx` is the tab
34
+ * position (changes when sheets move); `sheetId` is stable. Convert with
35
+ * {@link getSheetId} / {@link getSheetIdx}.
36
+ * - Reads return `Result<T>`: an `ErrorMessage` on failure, never a throw.
37
+ * - Writes go through {@link execTransaction}, which reports a rejection in
38
+ * the returned `ActionEffect` rather than throwing.
39
+ *
40
+ * Call {@link release} when done; the engine keeps the workbook alive until
41
+ * then.
42
+ */
20
43
  class Workbook {
44
+ /** Allocates a new, empty workbook in the engine. */
21
45
  constructor() {
22
46
  this._id = rpc('newWorkbook');
23
47
  this._blockManager = new block_manager_1.BlockManager((sheetIdx, blockId, rowCount, colCount) => {
@@ -26,19 +50,28 @@ class Workbook {
26
50
  return rpc('getAvailableBlockId', { sheetIdx }, this._id);
27
51
  });
28
52
  }
53
+ /** Current tab position of the sheet with stable id `sheetId`. */
29
54
  getSheetIdx(sheetId) {
30
55
  return rpc('getSheetIdx', { sheetId }, this._id);
31
56
  }
32
57
  getBlockValues(params) {
33
58
  return rpc('getBlockValues', params, this._id);
34
59
  }
60
+ /**
61
+ * An unused block id on the sheet, asked of the engine every call and not
62
+ * reserved: two calls before a `createBlock` return the same id.
63
+ * {@link createBlockForNewCraft} instead hands out ids from a local
64
+ * counter.
65
+ */
35
66
  getAvailableBlockId(params) {
36
67
  return rpc('getAvailableBlockId', params, this._id);
37
68
  }
38
69
  /**
39
- * @returns the block id if success, otherwise the error message
70
+ * Create a `rowCnt` x `colCnt` block whose master (top-left) cell is at
71
+ * (`masterRow`, `masterCol`), as a non-undoable transaction.
40
72
  *
41
- * It is caller's responsibility to store the block id.
73
+ * @returns the new block id, or an `ErrorMessage` if the engine rejected
74
+ * the block. The caller must store the id; nothing else records it.
42
75
  */
43
76
  createBlockForNewCraft(sheetIdx, masterRow, masterCol, rowCnt, colCnt) {
44
77
  const id = this._blockManager.getAvailableBlockId(sheetIdx);
@@ -168,6 +201,8 @@ class Workbook {
168
201
  temp: false,
169
202
  });
170
203
  }
204
+ /** Undo the last undoable transaction. `false` when there was nothing to
205
+ * undo; on `true` the cell and sheet update callbacks fire. */
171
206
  undo() {
172
207
  const result = rpc('undo', undefined, this._id);
173
208
  if (result) {
@@ -176,6 +211,7 @@ class Workbook {
176
211
  }
177
212
  return result;
178
213
  }
214
+ /** Redo the last undone transaction. Same contract as {@link undo}. */
179
215
  redo() {
180
216
  const result = rpc('redo', undefined, this._id);
181
217
  if (result) {
@@ -184,9 +220,13 @@ class Workbook {
184
220
  }
185
221
  return result;
186
222
  }
223
+ /** Called after a transaction reporting cell changes, after undo/redo,
224
+ * and when async custom-function results land. No unsubscribe. */
187
225
  registerCellUpdatedCallback(callback) {
188
226
  this._cellUpdatedCallbacks.push(callback);
189
227
  }
228
+ /** Called after a transaction reporting sheet-level changes, and after
229
+ * undo/redo. No unsubscribe. */
190
230
  registerSheetInfoUpdateCallback(callback) {
191
231
  this._sheetInfoUpdatedCallbacks.push(callback);
192
232
  }
@@ -201,6 +241,7 @@ class Workbook {
201
241
  getSheetNameByIdx(idx) {
202
242
  return rpc('getSheetNameByIdx', { idx }, this._id);
203
243
  }
244
+ /** Every sheet, in tab order. */
204
245
  getAllSheetInfo() {
205
246
  return rpc('getAllSheetInfo', undefined, this._id);
206
247
  }
@@ -212,9 +253,17 @@ class Workbook {
212
253
  getFormulaFunctionNames() {
213
254
  return rpc('getFormulaFunctionNames', undefined, this._id);
214
255
  }
256
+ /** Whether `f` looks like a formula: it must start with `=` and the rest
257
+ * must lex. A cheap syntax screen, not a full parse; nothing is evaluated. */
215
258
  checkFormula(f) {
216
259
  return rpc('checkFormula', { formula: f }, this._id);
217
260
  }
261
+ /**
262
+ * Evaluate a boolean formula on sheet `sheetIdx`. `f` is written as cell
263
+ * content into one engine-owned scratch ephemeral cell, so a formula needs
264
+ * its leading `=`. An `ErrorMessage` when the result is an error value or
265
+ * the write is rejected.
266
+ */
218
267
  calcCondition(sheetIdx, f) {
219
268
  return rpc('calcCondition', { sheetIdx, condition: f }, this._id);
220
269
  }
@@ -255,6 +304,7 @@ class Workbook {
255
304
  isInTempMode() {
256
305
  return rpc('isInTempMode', undefined, this._id);
257
306
  }
307
+ /** Stable id of the sheet at tab position `sheetIdx`. */
258
308
  getSheetId(sheetIdx) {
259
309
  return rpc('getSheetId', { sheetIdx }, this._id);
260
310
  }
@@ -267,6 +317,11 @@ class Workbook {
267
317
  getDisplayUnitsOfFormula(f) {
268
318
  return rpc('getDisplayUnitsOfFormula', { formula: f }, this._id);
269
319
  }
320
+ /**
321
+ * Subscribe to value changes of the cell now at (sheetIdx, rowIdx,
322
+ * colIdx). The coordinate is resolved to a cell id once, up front.
323
+ * Returns an `ErrorMessage` if it cannot be resolved.
324
+ */
270
325
  onCellValueChanged(sheetIdx, rowIdx, colIdx, callback) {
271
326
  const cellId = this.getCellId({ sheetIdx, rowIdx, colIdx });
272
327
  if ((0, utils_1.isErrorMessage)(cellId)) {
@@ -307,21 +362,45 @@ class Workbook {
307
362
  registerCellValueChangedByCellId(cellId, callback) {
308
363
  this._registerCellValueChangedCallback(cellId, callback);
309
364
  }
365
+ /**
366
+ * Temp branch (speculative edits). Transactions sent with `temp: true`
367
+ * land on ONE workbook-wide branch; {@link commitTempStatus} folds it into
368
+ * the real state, {@link cleanupTempStatus} discards all of it, and
369
+ * {@link toggleStatus} picks which state reads are served from. Any
370
+ * non-temp write discards the branch. Check {@link isInTempMode} before
371
+ * assuming the slot is free.
372
+ */
310
373
  commitTempStatus() {
311
- rpc('commitTempStatus', undefined, this._id);
374
+ return rpc('commitTempStatus', undefined, this._id);
312
375
  }
313
376
  cleanupTempStatus() {
314
- rpc('cleanupTempStatus', undefined, this._id);
377
+ return rpc('cleanupTempStatus', undefined, this._id);
315
378
  }
379
+ /** Serve reads from the temp branch (`true`) or the committed state. */
316
380
  toggleStatus(useTemp) {
317
- rpc('toggleStatus', { useTemp }, this._id);
381
+ return rpc('toggleStatus', { useTemp }, this._id);
318
382
  }
383
+ /** Cell infos for stable cell ids, in input order. Works for ephemeral and
384
+ * shadow cells, which have no coordinate. */
319
385
  batchGetCellInfoById(ids) {
320
386
  return rpc('batchGetCellInfoById', { ids }, this._id);
321
387
  }
322
388
  batchGetCellCoordinateWithSheetById(ids) {
323
389
  return rpc('batchGetCellCoordinateWithSheetById', { ids }, this._id);
324
390
  }
391
+ /**
392
+ * Apply a transaction: all payloads, in order, as one unit and (when
393
+ * `tx.undoable`) one undo step.
394
+ *
395
+ * Never throws for an engine refusal. A rejected transaction applies
396
+ * nothing and returns an `ActionEffect` with `status.type === 'err'` and
397
+ * the reason (naming the offending payload) in `errorMessage`; check it
398
+ * whenever the write must land. Callbacks fire only on success.
399
+ *
400
+ * Custom-function calls in the new formulas come back as `asyncTasks`;
401
+ * they are run here through the registered {@link CustomFunc}s and their
402
+ * results fed back later, so those cells update after this returns.
403
+ */
325
404
  execTransaction(tx) {
326
405
  const result = rpc('handleTransaction', { transaction: tx }, this._id);
327
406
  if (result.asyncTasks.length > 0) {
@@ -371,6 +450,10 @@ class Workbook {
371
450
  }
372
451
  return result;
373
452
  }
453
+ /**
454
+ * Replace this workbook's contents with a parsed .xlsx. An unreadable file
455
+ * comes back as an {@link ErrorMessage} and leaves this workbook as it was.
456
+ */
374
457
  load(buf, bookName) {
375
458
  return rpc('loadWorkbook', { content: Array.from(buf), name: bookName }, this._id);
376
459
  }
@@ -383,10 +466,16 @@ class Workbook {
383
466
  * so a file Excel must recalculate needs the coordinates. One-way — a
384
467
  * resolved `BLOCKREFS` becomes a plain range, which LogiSheets does not
385
468
  * parse back when it straddles a block.
469
+ *
470
+ * `data` is the opaque AppData string stored in the file (craft state and
471
+ * friends); read it back with {@link getAppData} after a load. Despite the
472
+ * return type, a failed save returns an `ErrorMessage`: check with
473
+ * `isErrorMessage`.
386
474
  */
387
475
  save(data, resolveBlockRefs = false) {
388
476
  return rpc('saveWorkbook', { appData: data, resolveBlockRefs }, this._id);
389
477
  }
478
+ /** The AppData entries carried by the loaded file (see {@link save}). */
390
479
  getAppData() {
391
480
  return rpc('getAppData', undefined, this._id);
392
481
  }
@@ -395,12 +484,16 @@ class Workbook {
395
484
  getVersion() {
396
485
  return rpc('getVersion', undefined, this._id);
397
486
  }
487
+ /** Free the engine workbook. Every later call on this handle, or on a
488
+ * `Worksheet` taken from it, is invalid. */
398
489
  release() {
399
490
  rpc('release', undefined, this._id);
400
491
  }
401
492
  getSheetCount() {
402
493
  return rpc('getSheetCount', undefined, this._id);
403
494
  }
495
+ /** The sheet at tab position `idx`. THROWS when `idx` is out of range,
496
+ * unlike the `Result`-returning reads. */
404
497
  getWorksheet(idx) {
405
498
  if (idx >= this.getSheetCount())
406
499
  throw Error(`invalid sheet index: ${idx}`);
@@ -538,12 +631,21 @@ class Workbook {
538
631
  temp: false,
539
632
  });
540
633
  }
634
+ /** The sheet with stable id `id`. Not validated: an unknown id yields a
635
+ * `Worksheet` whose calls fail. */
541
636
  getWorksheetById(id) {
542
637
  return new worksheet_1.Worksheet(this._id, id, false);
543
638
  }
639
+ /** Make `customFunc.funcName` callable from formulas. The engine hands
640
+ * such calls back as async tasks, see {@link execTransaction}. */
544
641
  registryCustomFunc(customFunc) {
545
642
  this._calculator.registry(customFunc);
546
643
  }
644
+ /**
645
+ * The id of a cell's shadow: an ephemeral companion cell the engine keeps
646
+ * per (cell, kind) for validation-style formulas. Allocated on first ask
647
+ * and stable afterwards.
648
+ */
547
649
  getShadowCellId(params) {
548
650
  return rpc('getShadowCellId', params, this._id);
549
651
  }
@@ -553,6 +655,8 @@ class Workbook {
553
655
  getShadowInfoById(params) {
554
656
  return rpc('getShadowInfoById', params, this._id);
555
657
  }
658
+ /** The stable id of the cell at a coordinate. It survives row/column
659
+ * insertion and deletion, unlike the coordinate. */
556
660
  getCellId(params) {
557
661
  return rpc('getCellId', params, this._id);
558
662
  }
@@ -599,6 +703,15 @@ class Workbook {
599
703
  getEnumSets() {
600
704
  return rpc('getEnumSets', undefined, this._id);
601
705
  }
706
+ /**
707
+ * The workbook's defined names, ordered by name. Each definition is
708
+ * sheet-qualified (`Sheet1!$B$2:$B$9`) so it reads the same from any sheet.
709
+ * Define, rename and remove them with the `defineName` / `renameName` /
710
+ * `removeName` payloads.
711
+ */
712
+ getDefinedNames() {
713
+ return rpc('getDefinedNames', undefined, this._id);
714
+ }
602
715
  /**
603
716
  * Every duplicated block row key in the workbook.
604
717
  *
@@ -672,6 +785,9 @@ class Workbook {
672
785
  _cellUpdatedCallbacks = [];
673
786
  _sheetInfoUpdatedCallbacks = [];
674
787
  _headerUpdatedCallbacks = [];
788
+ // NOTE: keyed by SheetCellId OBJECT identity, while execTransaction looks
789
+ // up the fresh objects each ActionEffect carries, so these lookups do not
790
+ // match. logisheets-engine's client keys by a string form instead.
675
791
  _cellValueChangedCallbacks = new Map();
676
792
  _cellRemovedCallbacks = new Map();
677
793
  // The book id which is generated by `WASM`
@@ -1,7 +1,24 @@
1
1
  import { BlockInfo, CellPosition, ColInfo, DisplayWindow, DisplayWindowWithStartPoint, RowInfo, Style, Value, CellInfo, SheetDimension, MergeCell, AppendixWithCell, ReproducibleCell, SheetCoordinate, CellInput, Comment, CellImageInfo, ChartInfo, CfRuleInfo, DependentCell, CellRefRange, LinkInfo } from '../bindings';
2
2
  import { Cell } from './cell';
3
3
  import { Result } from './utils';
4
+ /**
5
+ * The read surface of one sheet of a {@link Workbook}. Obtain it from
6
+ * `Workbook.getWorksheet` / `getWorksheetById`; writes go through the
7
+ * workbook's transactions.
8
+ *
9
+ * The constructor resolves the sheet's tab index AND its stable id once and
10
+ * caches both. Methods send one or the other to the engine, so after sheets
11
+ * are created, deleted or moved, take a fresh `Worksheet` rather than keep an
12
+ * old one.
13
+ *
14
+ * Rows and columns are 0-based; `start..end` ranges are inclusive on both
15
+ * ends. Reads return an `ErrorMessage` instead of throwing. Some are typed
16
+ * without `Result` but can still return one when the engine refuses (e.g. a
17
+ * stale sheet), so guard them with `isErrorMessage` too.
18
+ */
4
19
  export declare class Worksheet {
20
+ /** @param id the engine book id. `sheetIdxOrId` is a tab index, or a
21
+ * stable sheet id when `isSheetIdx` is false. */
5
22
  constructor(id: number, sheetIdxOrId: number, isSheetIdx?: boolean);
6
23
  getSheetDimension(): Result<SheetDimension>;
7
24
  /**
@@ -31,15 +48,22 @@ export declare class Worksheet {
31
48
  getRightwardDataBoundary(row: number, col: number): CellPosition;
32
49
  getDisplayWindowWithCellPosition(row: number, col: number, height: number, width: number): DisplayWindowWithStartPoint;
33
50
  getBlockDisplayWindow(blockId: number): Result<DisplayWindow>;
51
+ /** Row height in points; the sheet default when the row has none set. */
34
52
  getRowHeight(rowIdx: number): Result<number>;
35
53
  getColWidth(colIdx: number): Result<number>;
36
54
  getRowInfo(rowIdx: number): Result<RowInfo>;
37
55
  getColInfo(colIdx: number): Result<ColInfo>;
56
+ /** Value, formula, style and block membership of one cell. An empty cell
57
+ * still yields a `CellInfo` (value `'empty'`). */
38
58
  getCellInfo(rowIdx: number, colIdx: number): Result<CellInfo>;
39
59
  getCellListValidation(rowIdx: number, colIdx: number): Result<readonly string[] | undefined>;
40
60
  getReproducibleCell(rowIdx: number, colIdx: number): Result<ReproducibleCell>;
41
61
  getReproducibleCells(coordinates: readonly SheetCoordinate[]): Result<readonly ReproducibleCell[]>;
62
+ /** One `CellInfo` per cell of the inclusive rectangle, row-major. Fails
63
+ * whole if any cell fails. */
42
64
  getCellInfos(startRow: number, startCol: number, endRow: number, endCol: number): Result<readonly CellInfo[]>;
65
+ /** Like {@link getCellInfos}, skipping the cells inside the inclusive
66
+ * `window*` rectangle (already fetched by the caller). */
43
67
  getCellInfosExceptWindow(startRow: number, startCol: number, endRow: number, endCol: number, windowStartRow: number, windowStartCol: number, windowEndRow: number, windowEndCol: number): Result<readonly CellInfo[]>;
44
68
  /**
45
69
  * Predict the fill-handle result: given a source block and the target
@@ -62,11 +86,18 @@ export declare class Worksheet {
62
86
  endRow: number;
63
87
  endCol: number;
64
88
  }): Result<readonly CellInput[]>;
89
+ /** A block's geometry, schema and governance fields. Typed without
90
+ * `Result` but returns an `ErrorMessage` for an unknown block. */
65
91
  getBlockInfo(blockId: number): BlockInfo;
66
92
  getMergedCells(startRow: number, startCol: number, endRow: number, endCol: number): readonly MergeCell[];
67
93
  getCell(rowIdx: number, colIdx: number): Result<Cell>;
94
+ /** The cell's formula without the leading `=`, or `''` for a plain value.
95
+ * Regenerated from the parsed formula, so not necessarily the text as
96
+ * typed. */
68
97
  getFormula(rowIdx: number, colIdx: number): Result<string>;
69
98
  getStyle(rowIdx: number, colIdx: number): Result<Style>;
99
+ /** The evaluated value. An empty cell is the string `'empty'`, not an
100
+ * object. */
70
101
  getValue(rowIdx: number, colIdx: number): Result<Value>;
71
102
  getDiyCellIdWithBlockId(blockId: number, row: number, col: number): Result<number>;
72
103
  lookupAppendixUpward(blockId: number, row: number, col: number, craftId: string, tag: number): Result<AppendixWithCell>;
@@ -10,7 +10,24 @@ function rpc(method, params, bookId
10
10
  const msg = params === undefined ? method : { method, value: params };
11
11
  return (0, logisheets_wasm_server_1.handle)(msg, bookId ?? null);
12
12
  }
13
+ /**
14
+ * The read surface of one sheet of a {@link Workbook}. Obtain it from
15
+ * `Workbook.getWorksheet` / `getWorksheetById`; writes go through the
16
+ * workbook's transactions.
17
+ *
18
+ * The constructor resolves the sheet's tab index AND its stable id once and
19
+ * caches both. Methods send one or the other to the engine, so after sheets
20
+ * are created, deleted or moved, take a fresh `Worksheet` rather than keep an
21
+ * old one.
22
+ *
23
+ * Rows and columns are 0-based; `start..end` ranges are inclusive on both
24
+ * ends. Reads return an `ErrorMessage` instead of throwing. Some are typed
25
+ * without `Result` but can still return one when the engine refuses (e.g. a
26
+ * stale sheet), so guard them with `isErrorMessage` too.
27
+ */
13
28
  class Worksheet {
29
+ /** @param id the engine book id. `sheetIdxOrId` is a tab index, or a
30
+ * stable sheet id when `isSheetIdx` is false. */
14
31
  constructor(id, sheetIdxOrId, isSheetIdx = true) {
15
32
  this._id = id;
16
33
  if (isSheetIdx) {
@@ -128,6 +145,7 @@ class Worksheet {
128
145
  getBlockDisplayWindow(blockId) {
129
146
  return rpc('getBlockDisplayWindow', { sheetId: this._sheetId, blockId }, this._id);
130
147
  }
148
+ /** Row height in points; the sheet default when the row has none set. */
131
149
  getRowHeight(rowIdx) {
132
150
  return rpc('getRowHeight', { sheetId: this._sheetId, rowIdx }, this._id);
133
151
  }
@@ -140,6 +158,8 @@ class Worksheet {
140
158
  getColInfo(colIdx) {
141
159
  return rpc('getColInfo', { sheetIdx: this._sheetIdx, colIdx }, this._id);
142
160
  }
161
+ /** Value, formula, style and block membership of one cell. An empty cell
162
+ * still yields a `CellInfo` (value `'empty'`). */
143
163
  getCellInfo(rowIdx, colIdx) {
144
164
  return rpc('getCell', { sheetIdx: this._sheetIdx, row: rowIdx, col: colIdx }, this._id);
145
165
  }
@@ -155,9 +175,13 @@ class Worksheet {
155
175
  getReproducibleCells(coordinates) {
156
176
  return rpc('getReproducibleCells', { sheetIdx: this._sheetIdx, coordinates }, this._id);
157
177
  }
178
+ /** One `CellInfo` per cell of the inclusive rectangle, row-major. Fails
179
+ * whole if any cell fails. */
158
180
  getCellInfos(startRow, startCol, endRow, endCol) {
159
181
  return rpc('getCellInfos', { sheetIdx: this._sheetIdx, startRow, startCol, endRow, endCol }, this._id);
160
182
  }
183
+ /** Like {@link getCellInfos}, skipping the cells inside the inclusive
184
+ * `window*` rectangle (already fetched by the caller). */
161
185
  getCellInfosExceptWindow(startRow, startCol, endRow, endCol, windowStartRow, windowStartCol, windowEndRow, windowEndCol) {
162
186
  return rpc('getCellsExceptWindow', {
163
187
  sheetIdx: this._sheetIdx,
@@ -194,6 +218,8 @@ class Worksheet {
194
218
  dstEndCol: dst.endCol,
195
219
  }, this._id);
196
220
  }
221
+ /** A block's geometry, schema and governance fields. Typed without
222
+ * `Result` but returns an `ErrorMessage` for an unknown block. */
197
223
  getBlockInfo(blockId) {
198
224
  return rpc('getBlockInfo', { sheetId: this._sheetId, blockId }, this._id);
199
225
  }
@@ -207,12 +233,17 @@ class Worksheet {
207
233
  }
208
234
  return new cell_1.Cell(cellInfo);
209
235
  }
236
+ /** The cell's formula without the leading `=`, or `''` for a plain value.
237
+ * Regenerated from the parsed formula, so not necessarily the text as
238
+ * typed. */
210
239
  getFormula(rowIdx, colIdx) {
211
240
  return rpc('getFormula', { sheetIdx: this._sheetIdx, row: rowIdx, col: colIdx }, this._id);
212
241
  }
213
242
  getStyle(rowIdx, colIdx) {
214
243
  return rpc('getStyle', { sheetIdx: this._sheetIdx, row: rowIdx, col: colIdx }, this._id);
215
244
  }
245
+ /** The evaluated value. An empty cell is the string `'empty'`, not an
246
+ * object. */
216
247
  getValue(rowIdx, colIdx) {
217
248
  return rpc('getValue', { sheetIdx: this._sheetIdx, row: rowIdx, col: colIdx }, this._id);
218
249
  }
@@ -10,5 +10,6 @@ export interface BlockSchema {
10
10
  fields: readonly BlockSchemaFieldEntry[];
11
11
  randomEntries: readonly BlockSchemaRandomEntry[];
12
12
  headerIdx?: number;
13
+ keyIdx?: number;
13
14
  uniqueTogether: readonly UniqueTogetherGroup[];
14
15
  }
@@ -0,0 +1,18 @@
1
+ export interface DefineName {
2
+ name: string;
3
+ formula: string;
4
+ sheetIdx: number;
5
+ }
6
+ export declare class DefineNameBuilder {
7
+ private _name;
8
+ private _formula;
9
+ private _sheetIdx;
10
+ name(value: string): this;
11
+ formula(value: string): this;
12
+ sheetIdx(value: number): this;
13
+ build(): {
14
+ name: string;
15
+ formula: string;
16
+ sheetIdx: number;
17
+ };
18
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefineNameBuilder = void 0;
4
+ class DefineNameBuilder {
5
+ _name;
6
+ _formula;
7
+ _sheetIdx;
8
+ name(value) {
9
+ this._name = value;
10
+ return this;
11
+ }
12
+ formula(value) {
13
+ this._formula = value;
14
+ return this;
15
+ }
16
+ sheetIdx(value) {
17
+ this._sheetIdx = value;
18
+ return this;
19
+ }
20
+ build() {
21
+ if (this._name === undefined)
22
+ throw new Error('missing name');
23
+ if (this._formula === undefined)
24
+ throw new Error('missing formula');
25
+ if (this._sheetIdx === undefined)
26
+ throw new Error('missing sheetIdx');
27
+ return { name: this._name, formula: this._formula, sheetIdx: this._sheetIdx };
28
+ }
29
+ }
30
+ exports.DefineNameBuilder = DefineNameBuilder;
@@ -0,0 +1,4 @@
1
+ export interface DefinedNameInfo {
2
+ name: string;
3
+ formula: string;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -18,6 +18,7 @@ import { CreateDiyCell } from './create_diy_cell';
18
18
  import { CreateDiyCellById } from './create_diy_cell_by_id';
19
19
  import { CreateLink } from './create_link';
20
20
  import { CreateSheet } from './create_sheet';
21
+ import { DefineName } from './define_name';
21
22
  import { DeleteCellImage } from './delete_cell_image';
22
23
  import { DeleteChart } from './delete_chart';
23
24
  import { DeleteCols } from './delete_cols';
@@ -47,6 +48,8 @@ import { RemoveBlock } from './remove_block';
47
48
  import { RemoveDiyCell } from './remove_diy_cell';
48
49
  import { RemoveDiyCellById } from './remove_diy_cell_by_id';
49
50
  import { RemoveEnumSet } from './remove_enum_set';
51
+ import { RemoveName } from './remove_name';
52
+ import { RenameName } from './rename_name';
50
53
  import { ReorderBlockLines } from './reorder_block_lines';
51
54
  import { ReproduceCells } from './reproduce_cells';
52
55
  import { ResizeBlock } from './resize_block';
@@ -159,6 +162,15 @@ export type EditPayload = {
159
162
  } | {
160
163
  type: 'removeEnumSet';
161
164
  value: RemoveEnumSet;
165
+ } | {
166
+ type: 'defineName';
167
+ value: DefineName;
168
+ } | {
169
+ type: 'renameName';
170
+ value: RenameName;
171
+ } | {
172
+ type: 'removeName';
173
+ value: RemoveName;
162
174
  } | {
163
175
  type: 'cellFormatBrush';
164
176
  value: CellFormatBrush;
@@ -88,6 +88,8 @@ export * from './ct_font';
88
88
  export * from './ct_gradient_fill';
89
89
  export * from './ct_gradient_stop';
90
90
  export * from './ct_pattern_fill';
91
+ export * from './define_name';
92
+ export * from './defined_name_info';
91
93
  export * from './delete_cell_image';
92
94
  export * from './delete_chart';
93
95
  export * from './delete_cols';
@@ -165,6 +167,8 @@ export * from './remove_block';
165
167
  export * from './remove_diy_cell';
166
168
  export * from './remove_diy_cell_by_id';
167
169
  export * from './remove_enum_set';
170
+ export * from './remove_name';
171
+ export * from './rename_name';
168
172
  export * from './reorder_block_lines';
169
173
  export * from './reproduce_cells';
170
174
  export * from './reproducible_cell';
@@ -105,6 +105,8 @@ __exportStar(require("./ct_font"), exports);
105
105
  __exportStar(require("./ct_gradient_fill"), exports);
106
106
  __exportStar(require("./ct_gradient_stop"), exports);
107
107
  __exportStar(require("./ct_pattern_fill"), exports);
108
+ __exportStar(require("./define_name"), exports);
109
+ __exportStar(require("./defined_name_info"), exports);
108
110
  __exportStar(require("./delete_cell_image"), exports);
109
111
  __exportStar(require("./delete_chart"), exports);
110
112
  __exportStar(require("./delete_cols"), exports);
@@ -182,6 +184,8 @@ __exportStar(require("./remove_block"), exports);
182
184
  __exportStar(require("./remove_diy_cell"), exports);
183
185
  __exportStar(require("./remove_diy_cell_by_id"), exports);
184
186
  __exportStar(require("./remove_enum_set"), exports);
187
+ __exportStar(require("./remove_name"), exports);
188
+ __exportStar(require("./rename_name"), exports);
185
189
  __exportStar(require("./reorder_block_lines"), exports);
186
190
  __exportStar(require("./reproduce_cells"), exports);
187
191
  __exportStar(require("./reproducible_cell"), exports);
@@ -0,0 +1,10 @@
1
+ export interface RemoveName {
2
+ name: string;
3
+ }
4
+ export declare class RemoveNameBuilder {
5
+ private _name;
6
+ name(value: string): this;
7
+ build(): {
8
+ name: string;
9
+ };
10
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RemoveNameBuilder = void 0;
4
+ class RemoveNameBuilder {
5
+ _name;
6
+ name(value) {
7
+ this._name = value;
8
+ return this;
9
+ }
10
+ build() {
11
+ if (this._name === undefined)
12
+ throw new Error('missing name');
13
+ return { name: this._name };
14
+ }
15
+ }
16
+ exports.RemoveNameBuilder = RemoveNameBuilder;
@@ -0,0 +1,14 @@
1
+ export interface RenameName {
2
+ oldName: string;
3
+ newName: string;
4
+ }
5
+ export declare class RenameNameBuilder {
6
+ private _oldName;
7
+ private _newName;
8
+ oldName(value: string): this;
9
+ newName(value: string): this;
10
+ build(): {
11
+ oldName: string;
12
+ newName: string;
13
+ };
14
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RenameNameBuilder = void 0;
4
+ class RenameNameBuilder {
5
+ _oldName;
6
+ _newName;
7
+ oldName(value) {
8
+ this._oldName = value;
9
+ return this;
10
+ }
11
+ newName(value) {
12
+ this._newName = value;
13
+ return this;
14
+ }
15
+ build() {
16
+ if (this._oldName === undefined)
17
+ throw new Error('missing oldName');
18
+ if (this._newName === undefined)
19
+ throw new Error('missing newName');
20
+ return { oldName: this._oldName, newName: this._newName };
21
+ }
22
+ }
23
+ exports.RenameNameBuilder = RenameNameBuilder;