@ricsam/formula-engine 0.2.4 → 0.2.6

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 (43) hide show
  1. package/dist/cjs/core/commands/table-commands.cjs +158 -10
  2. package/dist/cjs/core/commands/table-commands.cjs.map +3 -3
  3. package/dist/cjs/core/commands/types.cjs.map +2 -2
  4. package/dist/cjs/core/engine-snapshot.cjs +2 -2
  5. package/dist/cjs/core/engine-snapshot.cjs.map +2 -2
  6. package/dist/cjs/core/engine.cjs +24 -3
  7. package/dist/cjs/core/engine.cjs.map +3 -3
  8. package/dist/cjs/core/managers/dependency-manager.cjs +157 -2
  9. package/dist/cjs/core/managers/dependency-manager.cjs.map +3 -3
  10. package/dist/cjs/core/managers/evaluation-manager.cjs +32 -1
  11. package/dist/cjs/core/managers/evaluation-manager.cjs.map +3 -3
  12. package/dist/cjs/core/managers/frontier-dependency-manager.cjs +4 -4
  13. package/dist/cjs/core/managers/frontier-dependency-manager.cjs.map +3 -3
  14. package/dist/cjs/core/managers/workbook-manager.cjs +48 -4
  15. package/dist/cjs/core/managers/workbook-manager.cjs.map +3 -3
  16. package/dist/cjs/evaluator/evaluation-context.cjs.map +2 -2
  17. package/dist/cjs/evaluator/formula-evaluator.cjs.map +1 -1
  18. package/dist/cjs/package.json +1 -1
  19. package/dist/mjs/core/commands/table-commands.mjs +163 -11
  20. package/dist/mjs/core/commands/table-commands.mjs.map +3 -3
  21. package/dist/mjs/core/commands/types.mjs.map +2 -2
  22. package/dist/mjs/core/engine-snapshot.mjs +2 -2
  23. package/dist/mjs/core/engine-snapshot.mjs.map +2 -2
  24. package/dist/mjs/core/engine.mjs +24 -3
  25. package/dist/mjs/core/engine.mjs.map +3 -3
  26. package/dist/mjs/core/managers/dependency-manager.mjs +157 -2
  27. package/dist/mjs/core/managers/dependency-manager.mjs.map +3 -3
  28. package/dist/mjs/core/managers/evaluation-manager.mjs +32 -1
  29. package/dist/mjs/core/managers/evaluation-manager.mjs.map +3 -3
  30. package/dist/mjs/core/managers/frontier-dependency-manager.mjs +4 -4
  31. package/dist/mjs/core/managers/frontier-dependency-manager.mjs.map +3 -3
  32. package/dist/mjs/core/managers/workbook-manager.mjs +48 -4
  33. package/dist/mjs/core/managers/workbook-manager.mjs.map +3 -3
  34. package/dist/mjs/evaluator/evaluation-context.mjs.map +2 -2
  35. package/dist/mjs/evaluator/formula-evaluator.mjs.map +1 -1
  36. package/dist/mjs/package.json +1 -1
  37. package/dist/types/core/commands/types.d.ts +5 -0
  38. package/dist/types/core/engine-snapshot.d.ts +13 -13
  39. package/dist/types/core/engine.d.ts +12 -4
  40. package/dist/types/core/managers/dependency-manager.d.ts +7 -0
  41. package/dist/types/core/managers/evaluation-manager.d.ts +1 -0
  42. package/dist/types/core/managers/workbook-manager.d.ts +3 -0
  43. package/package.json +3 -2
@@ -1,6 +1,115 @@
1
1
  // src/core/commands/table-commands.ts
2
- import { ActionTypes, emptyMutationInvalidation } from "./types.mjs";
2
+ import {
3
+ ActionTypes,
4
+ emptyMutationInvalidation,
5
+ getSerializedCellValueKind
6
+ } from "./types.mjs";
3
7
  import { getTableResourceKey } from "../resource-keys.mjs";
8
+ import { parseCellReference } from "../utils.mjs";
9
+ function getAddressKey(address) {
10
+ return `${address.workbookName}:${address.sheetName}:${address.rowIndex}:${address.colIndex}`;
11
+ }
12
+ function collectTableFootprintCells(workbookManager, table) {
13
+ const cells = new Map;
14
+ const sheet = workbookManager.getSheet({
15
+ workbookName: table.workbookName,
16
+ sheetName: table.sheetName
17
+ });
18
+ if (!sheet) {
19
+ return [];
20
+ }
21
+ const startColIndex = table.start.colIndex;
22
+ const endColIndex = startColIndex + table.headers.size - 1;
23
+ if (table.endRow.type === "number") {
24
+ for (let rowIndex = table.start.rowIndex;rowIndex <= table.endRow.value; rowIndex++) {
25
+ for (let colIndex = startColIndex;colIndex <= endColIndex; colIndex++) {
26
+ const address = {
27
+ workbookName: table.workbookName,
28
+ sheetName: table.sheetName,
29
+ rowIndex,
30
+ colIndex
31
+ };
32
+ cells.set(getAddressKey(address), {
33
+ address,
34
+ content: workbookManager.getCellContent(address)
35
+ });
36
+ }
37
+ }
38
+ return Array.from(cells.values());
39
+ }
40
+ for (const [ref, content] of sheet.content.entries()) {
41
+ const { rowIndex, colIndex } = parseCellReference(ref);
42
+ if (rowIndex < table.start.rowIndex) {
43
+ continue;
44
+ }
45
+ if (colIndex < startColIndex || colIndex > endColIndex) {
46
+ continue;
47
+ }
48
+ const address = {
49
+ workbookName: table.workbookName,
50
+ sheetName: table.sheetName,
51
+ rowIndex,
52
+ colIndex
53
+ };
54
+ cells.set(getAddressKey(address), {
55
+ address,
56
+ content
57
+ });
58
+ }
59
+ return Array.from(cells.values());
60
+ }
61
+ function buildTableTouchedCells(workbookManager, tables) {
62
+ const touchedCells = new Map;
63
+ for (const table of tables) {
64
+ if (!table) {
65
+ continue;
66
+ }
67
+ for (const cell of collectTableFootprintCells(workbookManager, table)) {
68
+ touchedCells.set(getAddressKey(cell.address), {
69
+ address: cell.address,
70
+ beforeKind: getSerializedCellValueKind(cell.content),
71
+ afterKind: getSerializedCellValueKind(cell.content)
72
+ });
73
+ }
74
+ }
75
+ return Array.from(touchedCells.values());
76
+ }
77
+ function buildTableContextChangedCells(workbookManager, tables) {
78
+ const changedCells = new Map;
79
+ for (const table of tables) {
80
+ if (!table) {
81
+ continue;
82
+ }
83
+ for (const cell of collectTableFootprintCells(workbookManager, table)) {
84
+ changedCells.set(getAddressKey(cell.address), cell.address);
85
+ }
86
+ }
87
+ return Array.from(changedCells.values());
88
+ }
89
+ function mergeTouchedCells(...groups) {
90
+ const precedence = {
91
+ empty: 0,
92
+ scalar: 1,
93
+ formula: 2
94
+ };
95
+ const merged = new Map;
96
+ for (const group of groups) {
97
+ for (const touchedCell of group) {
98
+ const key = getAddressKey(touchedCell.address);
99
+ const existing = merged.get(key);
100
+ if (!existing) {
101
+ merged.set(key, touchedCell);
102
+ continue;
103
+ }
104
+ merged.set(key, {
105
+ address: touchedCell.address,
106
+ beforeKind: precedence[touchedCell.beforeKind] >= precedence[existing.beforeKind] ? touchedCell.beforeKind : existing.beforeKind,
107
+ afterKind: precedence[touchedCell.afterKind] >= precedence[existing.afterKind] ? touchedCell.afterKind : existing.afterKind
108
+ });
109
+ }
110
+ }
111
+ return Array.from(merged.values());
112
+ }
4
113
 
5
114
  class AddTableCommand {
6
115
  deps;
@@ -13,7 +122,7 @@ class AddTableCommand {
13
122
  this.props = props;
14
123
  }
15
124
  execute() {
16
- this.deps.tableManager.addTable({
125
+ const table = this.deps.tableManager.addTable({
17
126
  ...this.props,
18
127
  getCellValue: this.deps.getCellValue
19
128
  });
@@ -22,7 +131,8 @@ class AddTableCommand {
22
131
  tableName: this.props.tableName
23
132
  });
24
133
  this.executeFootprint = {
25
- touchedCells: [],
134
+ touchedCells: buildTableTouchedCells(this.deps.workbookManager, [table]),
135
+ tableContextChangedCells: buildTableContextChangedCells(this.deps.workbookManager, [table]),
26
136
  resourceKeys: [resourceKey]
27
137
  };
28
138
  this.undoFootprint = this.executeFootprint;
@@ -66,7 +176,10 @@ class RemoveTableCommand {
66
176
  tableName: this.opts.tableName
67
177
  });
68
178
  this.executeFootprint = {
69
- touchedCells: [],
179
+ touchedCells: buildTableTouchedCells(this.deps.workbookManager, [
180
+ this.removedTable
181
+ ]),
182
+ tableContextChangedCells: buildTableContextChangedCells(this.deps.workbookManager, [this.removedTable]),
70
183
  resourceKeys: [resourceKey]
71
184
  };
72
185
  this.undoFootprint = this.executeFootprint;
@@ -112,6 +225,10 @@ class RenameTableCommand {
112
225
  this.newName = newName;
113
226
  }
114
227
  execute() {
228
+ const previousTable = this.deps.tableManager.getTable({
229
+ workbookName: this.workbookName,
230
+ name: this.oldName
231
+ });
115
232
  this.deps.tableManager.renameTable(this.workbookName, {
116
233
  oldName: this.oldName,
117
234
  newName: this.newName
@@ -119,12 +236,20 @@ class RenameTableCommand {
119
236
  const changedCells = this.deps.workbookManager.updateAllFormulas((formula) => this.deps.renameTableInFormula(formula, this.oldName, this.newName));
120
237
  const changedNamedExpressions = this.deps.namedExpressionManager.updateAllNamedExpressions((formula) => this.deps.renameTableInFormula(formula, this.oldName, this.newName));
121
238
  this.deps.apiSchemaManager.updateForTableRename(this.workbookName, this.oldName, this.newName);
239
+ const renamedTable = this.deps.tableManager.getTable({
240
+ workbookName: this.workbookName,
241
+ name: this.newName
242
+ });
122
243
  this.executeFootprint = {
123
- touchedCells: changedCells.map((address) => ({
244
+ touchedCells: mergeTouchedCells(buildTableTouchedCells(this.deps.workbookManager, [
245
+ previousTable,
246
+ renamedTable
247
+ ]), changedCells.map((address) => ({
124
248
  address,
125
249
  beforeKind: "formula",
126
250
  afterKind: "formula"
127
- })),
251
+ }))),
252
+ tableContextChangedCells: buildTableContextChangedCells(this.deps.workbookManager, [previousTable, renamedTable]),
128
253
  resourceKeys: [
129
254
  getTableResourceKey({
130
255
  workbookName: this.workbookName,
@@ -139,6 +264,10 @@ class RenameTableCommand {
139
264
  };
140
265
  }
141
266
  undo() {
267
+ const currentTable = this.deps.tableManager.getTable({
268
+ workbookName: this.workbookName,
269
+ name: this.newName
270
+ });
142
271
  this.deps.tableManager.renameTable(this.workbookName, {
143
272
  oldName: this.newName,
144
273
  newName: this.oldName
@@ -146,12 +275,20 @@ class RenameTableCommand {
146
275
  const changedCells = this.deps.workbookManager.updateAllFormulas((formula) => this.deps.renameTableInFormula(formula, this.newName, this.oldName));
147
276
  const changedNamedExpressions = this.deps.namedExpressionManager.updateAllNamedExpressions((formula) => this.deps.renameTableInFormula(formula, this.newName, this.oldName));
148
277
  this.deps.apiSchemaManager.updateForTableRename(this.workbookName, this.newName, this.oldName);
278
+ const restoredTable = this.deps.tableManager.getTable({
279
+ workbookName: this.workbookName,
280
+ name: this.oldName
281
+ });
149
282
  this.undoFootprint = {
150
- touchedCells: changedCells.map((address) => ({
283
+ touchedCells: mergeTouchedCells(buildTableTouchedCells(this.deps.workbookManager, [
284
+ currentTable,
285
+ restoredTable
286
+ ]), changedCells.map((address) => ({
151
287
  address,
152
288
  beforeKind: "formula",
153
289
  afterKind: "formula"
154
- })),
290
+ }))),
291
+ tableContextChangedCells: buildTableContextChangedCells(this.deps.workbookManager, [currentTable, restoredTable]),
155
292
  resourceKeys: [
156
293
  getTableResourceKey({
157
294
  workbookName: this.workbookName,
@@ -204,8 +341,16 @@ class UpdateTableCommand {
204
341
  workbookName: this.opts.workbookName,
205
342
  tableName: this.opts.tableName
206
343
  });
344
+ const nextTable = this.deps.tableManager.getTable({
345
+ workbookName: this.opts.workbookName,
346
+ name: this.opts.tableName
347
+ });
207
348
  this.executeFootprint = {
208
- touchedCells: [],
349
+ touchedCells: buildTableTouchedCells(this.deps.workbookManager, [
350
+ this.previousTable,
351
+ nextTable
352
+ ]),
353
+ tableContextChangedCells: buildTableContextChangedCells(this.deps.workbookManager, [this.previousTable, nextTable]),
209
354
  resourceKeys: [resourceKey]
210
355
  };
211
356
  this.undoFootprint = this.executeFootprint;
@@ -271,7 +416,14 @@ class ResetTablesCommand {
271
416
  }
272
417
  }
273
418
  this.executeFootprint = {
274
- touchedCells: [],
419
+ touchedCells: buildTableTouchedCells(this.deps.workbookManager, [
420
+ ...Array.from(this.previousTables?.values() ?? []).flatMap((tables) => Array.from(tables.values())),
421
+ ...Array.from(this.newTables.values()).flatMap((tables) => Array.from(tables.values()))
422
+ ]),
423
+ tableContextChangedCells: buildTableContextChangedCells(this.deps.workbookManager, [
424
+ ...Array.from(this.previousTables?.values() ?? []).flatMap((tables) => Array.from(tables.values())),
425
+ ...Array.from(this.newTables.values()).flatMap((tables) => Array.from(tables.values()))
426
+ ]),
275
427
  resourceKeys: Array.from(resourceKeys)
276
428
  };
277
429
  this.undoFootprint = this.executeFootprint;
@@ -304,4 +456,4 @@ export {
304
456
  AddTableCommand
305
457
  };
306
458
 
307
- //# debugId=CC464FB94217B86D64756E2164756E21
459
+ //# debugId=C2645E9937E12DCB64756E2164756E21
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/core/commands/table-commands.ts"],
4
4
  "sourcesContent": [
5
- "/**\n * Table Commands - Commands that modify table definitions\n *\n * These commands all require re-evaluation after execution.\n */\n\nimport type { TableManager } from \"../managers/table-manager.mjs\";\nimport type { NamedExpressionManager } from \"../managers/named-expression-manager.mjs\";\nimport type { WorkbookManager } from \"../managers/workbook-manager.mjs\";\nimport type { SchemaManager } from \"../managers/schema-manager.mjs\";\nimport type {\n CellAddress,\n SerializedCellValue,\n SpreadsheetRangeEnd,\n TableDefinition,\n} from \"../types.mjs\";\nimport type {\n EngineCommand,\n EngineAction,\n MutationInvalidation,\n} from \"./types.mjs\";\nimport { ActionTypes, emptyMutationInvalidation } from \"./types.mjs\";\nimport { getTableResourceKey } from \"../resource-keys.mjs\";\n\n/**\n * Dependencies needed for table commands.\n */\nexport interface TableCommandDeps {\n tableManager: TableManager;\n namedExpressionManager: NamedExpressionManager;\n workbookManager: WorkbookManager;\n apiSchemaManager: SchemaManager;\n getCellValue: (cellAddress: CellAddress) => SerializedCellValue;\n renameTableInFormula: (\n formula: string,\n oldName: string,\n newName: string\n ) => string;\n}\n\n/**\n * Command to add a table.\n */\nexport class AddTableCommand implements EngineCommand {\n readonly requiresReevaluation = true;\n private executeFootprint = emptyMutationInvalidation();\n private undoFootprint = emptyMutationInvalidation();\n\n constructor(\n private deps: TableCommandDeps,\n private props: {\n tableName: string;\n sheetName: string;\n workbookName: string;\n start: string;\n numRows: SpreadsheetRangeEnd;\n numCols: number;\n }\n ) {}\n\n execute(): void {\n this.deps.tableManager.addTable({\n ...this.props,\n getCellValue: this.deps.getCellValue,\n });\n const resourceKey = getTableResourceKey({\n workbookName: this.props.workbookName,\n tableName: this.props.tableName,\n });\n this.executeFootprint = {\n touchedCells: [],\n resourceKeys: [resourceKey],\n };\n this.undoFootprint = this.executeFootprint;\n }\n\n undo(): void {\n this.deps.tableManager.removeTable({\n workbookName: this.props.workbookName,\n tableName: this.props.tableName,\n });\n }\n\n getInvalidationFootprint(phase: \"execute\" | \"undo\"): MutationInvalidation {\n return phase === \"execute\" ? this.executeFootprint : this.undoFootprint;\n }\n\n toAction(): EngineAction {\n return {\n type: ActionTypes.ADD_TABLE,\n payload: this.props,\n };\n }\n}\n\n/**\n * Command to remove a table.\n */\nexport class RemoveTableCommand implements EngineCommand {\n readonly requiresReevaluation = true;\n private removedTable: TableDefinition | undefined;\n private executeFootprint = emptyMutationInvalidation();\n private undoFootprint = emptyMutationInvalidation();\n\n constructor(\n private deps: TableCommandDeps,\n private opts: { tableName: string; workbookName: string }\n ) {}\n\n execute(): void {\n // Capture table before removal\n this.removedTable = this.deps.tableManager.getTable({\n workbookName: this.opts.workbookName,\n name: this.opts.tableName,\n });\n\n this.deps.tableManager.removeTable(this.opts);\n const resourceKey = getTableResourceKey({\n workbookName: this.opts.workbookName,\n tableName: this.opts.tableName,\n });\n this.executeFootprint = {\n touchedCells: [],\n resourceKeys: [resourceKey],\n };\n this.undoFootprint = this.executeFootprint;\n }\n\n undo(): void {\n if (!this.removedTable) return;\n\n // Recreate the table\n const { start, endRow, headers, sheetName } = this.removedTable;\n const startRef = `${String.fromCharCode(65 + start.colIndex)}${start.rowIndex + 1}`;\n\n this.deps.tableManager.addTable({\n workbookName: this.opts.workbookName,\n tableName: this.opts.tableName,\n sheetName,\n start: startRef,\n numRows: endRow,\n numCols: headers.size,\n getCellValue: this.deps.getCellValue,\n });\n }\n\n getInvalidationFootprint(phase: \"execute\" | \"undo\"): MutationInvalidation {\n return phase === \"execute\" ? this.executeFootprint : this.undoFootprint;\n }\n\n toAction(): EngineAction {\n return {\n type: ActionTypes.REMOVE_TABLE,\n payload: this.opts,\n };\n }\n}\n\n/**\n * Command to rename a table.\n */\nexport class RenameTableCommand implements EngineCommand {\n readonly requiresReevaluation = true;\n private executeFootprint = emptyMutationInvalidation();\n private undoFootprint = emptyMutationInvalidation();\n\n constructor(\n private deps: TableCommandDeps,\n private workbookName: string,\n private oldName: string,\n private newName: string\n ) {}\n\n execute(): void {\n this.deps.tableManager.renameTable(this.workbookName, {\n oldName: this.oldName,\n newName: this.newName,\n });\n\n // Update formulas in sheet cells\n const changedCells = this.deps.workbookManager.updateAllFormulas((formula) =>\n this.deps.renameTableInFormula(formula, this.oldName, this.newName)\n );\n\n // Update named expressions\n const changedNamedExpressions =\n this.deps.namedExpressionManager.updateAllNamedExpressions((formula) =>\n this.deps.renameTableInFormula(formula, this.oldName, this.newName)\n );\n\n // Update API schemas\n this.deps.apiSchemaManager.updateForTableRename(\n this.workbookName,\n this.oldName,\n this.newName\n );\n\n this.executeFootprint = {\n touchedCells: changedCells.map((address) => ({\n address,\n beforeKind: \"formula\" as const,\n afterKind: \"formula\" as const,\n })),\n resourceKeys: [\n getTableResourceKey({\n workbookName: this.workbookName,\n tableName: this.oldName,\n }),\n getTableResourceKey({\n workbookName: this.workbookName,\n tableName: this.newName,\n }),\n ...changedNamedExpressions,\n ],\n };\n }\n\n undo(): void {\n // Rename back\n this.deps.tableManager.renameTable(this.workbookName, {\n oldName: this.newName,\n newName: this.oldName,\n });\n\n // Update formulas back\n const changedCells = this.deps.workbookManager.updateAllFormulas((formula) =>\n this.deps.renameTableInFormula(formula, this.newName, this.oldName)\n );\n\n // Update named expressions back\n const changedNamedExpressions =\n this.deps.namedExpressionManager.updateAllNamedExpressions((formula) =>\n this.deps.renameTableInFormula(formula, this.newName, this.oldName)\n );\n\n // Update API schemas back\n this.deps.apiSchemaManager.updateForTableRename(\n this.workbookName,\n this.newName,\n this.oldName\n );\n\n this.undoFootprint = {\n touchedCells: changedCells.map((address) => ({\n address,\n beforeKind: \"formula\" as const,\n afterKind: \"formula\" as const,\n })),\n resourceKeys: [\n getTableResourceKey({\n workbookName: this.workbookName,\n tableName: this.oldName,\n }),\n getTableResourceKey({\n workbookName: this.workbookName,\n tableName: this.newName,\n }),\n ...changedNamedExpressions,\n ],\n };\n }\n\n getInvalidationFootprint(phase: \"execute\" | \"undo\"): MutationInvalidation {\n return phase === \"execute\" ? this.executeFootprint : this.undoFootprint;\n }\n\n toAction(): EngineAction {\n return {\n type: ActionTypes.RENAME_TABLE,\n payload: {\n workbookName: this.workbookName,\n oldName: this.oldName,\n newName: this.newName,\n },\n };\n }\n}\n\n/**\n * Command to update a table.\n */\nexport class UpdateTableCommand implements EngineCommand {\n readonly requiresReevaluation = true;\n private previousTable: TableDefinition | undefined;\n private executeFootprint = emptyMutationInvalidation();\n private undoFootprint = emptyMutationInvalidation();\n\n constructor(\n private deps: TableCommandDeps,\n private opts: {\n tableName: string;\n sheetName?: string;\n start?: string;\n numRows?: SpreadsheetRangeEnd;\n numCols?: number;\n workbookName: string;\n }\n ) {}\n\n execute(): void {\n // Capture previous table state\n this.previousTable = this.deps.tableManager.getTable({\n workbookName: this.opts.workbookName,\n name: this.opts.tableName,\n });\n\n this.deps.tableManager.updateTable({\n ...this.opts,\n getCellValue: this.deps.getCellValue,\n });\n const resourceKey = getTableResourceKey({\n workbookName: this.opts.workbookName,\n tableName: this.opts.tableName,\n });\n this.executeFootprint = {\n touchedCells: [],\n resourceKeys: [resourceKey],\n };\n this.undoFootprint = this.executeFootprint;\n }\n\n undo(): void {\n if (!this.previousTable) return;\n\n // Restore previous table state\n const { start, endRow, headers, sheetName } = this.previousTable;\n const startRef = `${String.fromCharCode(65 + start.colIndex)}${start.rowIndex + 1}`;\n\n this.deps.tableManager.updateTable({\n workbookName: this.opts.workbookName,\n tableName: this.opts.tableName,\n sheetName,\n start: startRef,\n numRows: endRow,\n numCols: headers.size,\n getCellValue: this.deps.getCellValue,\n });\n }\n\n getInvalidationFootprint(phase: \"execute\" | \"undo\"): MutationInvalidation {\n return phase === \"execute\" ? this.executeFootprint : this.undoFootprint;\n }\n\n toAction(): EngineAction {\n return {\n type: ActionTypes.UPDATE_TABLE,\n payload: this.opts,\n };\n }\n}\n\n/**\n * Command to reset all tables.\n */\nexport class ResetTablesCommand implements EngineCommand {\n readonly requiresReevaluation = true;\n private previousTables: Map<string, Map<string, TableDefinition>> | undefined;\n private executeFootprint = emptyMutationInvalidation();\n private undoFootprint = emptyMutationInvalidation();\n\n constructor(\n private deps: TableCommandDeps,\n private newTables: Map<string, Map<string, TableDefinition>>\n ) {}\n\n execute(): void {\n // Capture previous tables\n this.previousTables = new Map();\n for (const [workbookName, tables] of this.deps.tableManager.tables) {\n this.previousTables.set(workbookName, new Map(tables));\n }\n\n this.deps.tableManager.resetTables(this.newTables);\n const resourceKeys = new Set<string>();\n for (const [workbookName, tables] of this.previousTables ?? []) {\n for (const tableName of tables.keys()) {\n resourceKeys.add(\n getTableResourceKey({\n workbookName,\n tableName,\n })\n );\n }\n }\n for (const [workbookName, tables] of this.newTables) {\n for (const tableName of tables.keys()) {\n resourceKeys.add(\n getTableResourceKey({\n workbookName,\n tableName,\n })\n );\n }\n }\n this.executeFootprint = {\n touchedCells: [],\n resourceKeys: Array.from(resourceKeys),\n };\n this.undoFootprint = this.executeFootprint;\n }\n\n undo(): void {\n if (!this.previousTables) return;\n this.deps.tableManager.resetTables(this.previousTables);\n }\n\n getInvalidationFootprint(phase: \"execute\" | \"undo\"): MutationInvalidation {\n return phase === \"execute\" ? this.executeFootprint : this.undoFootprint;\n }\n\n toAction(): EngineAction {\n return {\n type: ActionTypes.RESET_TABLES,\n payload: {\n tables: Array.from(this.newTables.entries()).map(([wb, tables]) => [\n wb,\n Array.from(tables.entries()),\n ]),\n },\n };\n }\n}\n"
5
+ "/**\n * Table Commands - Commands that modify table definitions\n *\n * These commands all require re-evaluation after execution.\n */\n\nimport type { TableManager } from \"../managers/table-manager.mjs\";\nimport type { NamedExpressionManager } from \"../managers/named-expression-manager.mjs\";\nimport type { WorkbookManager } from \"../managers/workbook-manager.mjs\";\nimport type { SchemaManager } from \"../managers/schema-manager.mjs\";\nimport type {\n CellAddress,\n SerializedCellValue,\n SpreadsheetRangeEnd,\n TableDefinition,\n} from \"../types.mjs\";\nimport type {\n EngineCommand,\n EngineAction,\n MutationInvalidation,\n} from \"./types.mjs\";\nimport {\n ActionTypes,\n emptyMutationInvalidation,\n getSerializedCellValueKind,\n} from \"./types.mjs\";\nimport { getTableResourceKey } from \"../resource-keys.mjs\";\nimport { parseCellReference } from \"../utils.mjs\";\n\nfunction getAddressKey(address: CellAddress): string {\n return `${address.workbookName}:${address.sheetName}:${address.rowIndex}:${address.colIndex}`;\n}\n\nfunction collectTableFootprintCells(\n workbookManager: WorkbookManager,\n table: TableDefinition\n): Array<{\n address: CellAddress;\n content: SerializedCellValue | undefined;\n}> {\n const cells = new Map<\n string,\n {\n address: CellAddress;\n content: SerializedCellValue | undefined;\n }\n >();\n const sheet = workbookManager.getSheet({\n workbookName: table.workbookName,\n sheetName: table.sheetName,\n });\n if (!sheet) {\n return [];\n }\n\n const startColIndex = table.start.colIndex;\n const endColIndex = startColIndex + table.headers.size - 1;\n\n if (table.endRow.type === \"number\") {\n for (let rowIndex = table.start.rowIndex; rowIndex <= table.endRow.value; rowIndex++) {\n for (let colIndex = startColIndex; colIndex <= endColIndex; colIndex++) {\n const address = {\n workbookName: table.workbookName,\n sheetName: table.sheetName,\n rowIndex,\n colIndex,\n };\n cells.set(getAddressKey(address), {\n address,\n content: workbookManager.getCellContent(address),\n });\n }\n }\n return Array.from(cells.values());\n }\n\n for (const [ref, content] of sheet.content.entries()) {\n const { rowIndex, colIndex } = parseCellReference(ref);\n if (rowIndex < table.start.rowIndex) {\n continue;\n }\n if (colIndex < startColIndex || colIndex > endColIndex) {\n continue;\n }\n\n const address = {\n workbookName: table.workbookName,\n sheetName: table.sheetName,\n rowIndex,\n colIndex,\n };\n cells.set(getAddressKey(address), {\n address,\n content,\n });\n }\n\n return Array.from(cells.values());\n}\n\nfunction buildTableTouchedCells(\n workbookManager: WorkbookManager,\n tables: Array<TableDefinition | undefined>\n): MutationInvalidation[\"touchedCells\"] {\n const touchedCells = new Map<\n string,\n {\n address: CellAddress;\n beforeKind: ReturnType<typeof getSerializedCellValueKind>;\n afterKind: ReturnType<typeof getSerializedCellValueKind>;\n }\n >();\n\n for (const table of tables) {\n if (!table) {\n continue;\n }\n for (const cell of collectTableFootprintCells(workbookManager, table)) {\n touchedCells.set(getAddressKey(cell.address), {\n address: cell.address,\n beforeKind: getSerializedCellValueKind(cell.content),\n afterKind: getSerializedCellValueKind(cell.content),\n });\n }\n }\n\n return Array.from(touchedCells.values());\n}\n\nfunction buildTableContextChangedCells(\n workbookManager: WorkbookManager,\n tables: Array<TableDefinition | undefined>\n): CellAddress[] {\n const changedCells = new Map<string, CellAddress>();\n\n for (const table of tables) {\n if (!table) {\n continue;\n }\n for (const cell of collectTableFootprintCells(workbookManager, table)) {\n changedCells.set(getAddressKey(cell.address), cell.address);\n }\n }\n\n return Array.from(changedCells.values());\n}\n\nfunction mergeTouchedCells(\n ...groups: MutationInvalidation[\"touchedCells\"][]\n): MutationInvalidation[\"touchedCells\"] {\n const precedence = {\n empty: 0,\n scalar: 1,\n formula: 2,\n } as const;\n const merged = new Map<\n string,\n MutationInvalidation[\"touchedCells\"][number]\n >();\n\n for (const group of groups) {\n for (const touchedCell of group) {\n const key = getAddressKey(touchedCell.address);\n const existing = merged.get(key);\n if (!existing) {\n merged.set(key, touchedCell);\n continue;\n }\n\n merged.set(key, {\n address: touchedCell.address,\n beforeKind:\n precedence[touchedCell.beforeKind] >= precedence[existing.beforeKind]\n ? touchedCell.beforeKind\n : existing.beforeKind,\n afterKind:\n precedence[touchedCell.afterKind] >= precedence[existing.afterKind]\n ? touchedCell.afterKind\n : existing.afterKind,\n });\n }\n }\n\n return Array.from(merged.values());\n}\n\n/**\n * Dependencies needed for table commands.\n */\nexport interface TableCommandDeps {\n tableManager: TableManager;\n namedExpressionManager: NamedExpressionManager;\n workbookManager: WorkbookManager;\n apiSchemaManager: SchemaManager;\n getCellValue: (cellAddress: CellAddress) => SerializedCellValue;\n renameTableInFormula: (\n formula: string,\n oldName: string,\n newName: string\n ) => string;\n}\n\n/**\n * Command to add a table.\n */\nexport class AddTableCommand implements EngineCommand {\n readonly requiresReevaluation = true;\n private executeFootprint = emptyMutationInvalidation();\n private undoFootprint = emptyMutationInvalidation();\n\n constructor(\n private deps: TableCommandDeps,\n private props: {\n tableName: string;\n sheetName: string;\n workbookName: string;\n start: string;\n numRows: SpreadsheetRangeEnd;\n numCols: number;\n }\n ) {}\n\n execute(): void {\n const table = this.deps.tableManager.addTable({\n ...this.props,\n getCellValue: this.deps.getCellValue,\n });\n const resourceKey = getTableResourceKey({\n workbookName: this.props.workbookName,\n tableName: this.props.tableName,\n });\n this.executeFootprint = {\n touchedCells: buildTableTouchedCells(this.deps.workbookManager, [table]),\n tableContextChangedCells: buildTableContextChangedCells(\n this.deps.workbookManager,\n [table]\n ),\n resourceKeys: [resourceKey],\n };\n this.undoFootprint = this.executeFootprint;\n }\n\n undo(): void {\n this.deps.tableManager.removeTable({\n workbookName: this.props.workbookName,\n tableName: this.props.tableName,\n });\n }\n\n getInvalidationFootprint(phase: \"execute\" | \"undo\"): MutationInvalidation {\n return phase === \"execute\" ? this.executeFootprint : this.undoFootprint;\n }\n\n toAction(): EngineAction {\n return {\n type: ActionTypes.ADD_TABLE,\n payload: this.props,\n };\n }\n}\n\n/**\n * Command to remove a table.\n */\nexport class RemoveTableCommand implements EngineCommand {\n readonly requiresReevaluation = true;\n private removedTable: TableDefinition | undefined;\n private executeFootprint = emptyMutationInvalidation();\n private undoFootprint = emptyMutationInvalidation();\n\n constructor(\n private deps: TableCommandDeps,\n private opts: { tableName: string; workbookName: string }\n ) {}\n\n execute(): void {\n // Capture table before removal\n this.removedTable = this.deps.tableManager.getTable({\n workbookName: this.opts.workbookName,\n name: this.opts.tableName,\n });\n\n this.deps.tableManager.removeTable(this.opts);\n const resourceKey = getTableResourceKey({\n workbookName: this.opts.workbookName,\n tableName: this.opts.tableName,\n });\n this.executeFootprint = {\n touchedCells: buildTableTouchedCells(this.deps.workbookManager, [\n this.removedTable,\n ]),\n tableContextChangedCells: buildTableContextChangedCells(\n this.deps.workbookManager,\n [this.removedTable]\n ),\n resourceKeys: [resourceKey],\n };\n this.undoFootprint = this.executeFootprint;\n }\n\n undo(): void {\n if (!this.removedTable) return;\n\n // Recreate the table\n const { start, endRow, headers, sheetName } = this.removedTable;\n const startRef = `${String.fromCharCode(65 + start.colIndex)}${start.rowIndex + 1}`;\n\n this.deps.tableManager.addTable({\n workbookName: this.opts.workbookName,\n tableName: this.opts.tableName,\n sheetName,\n start: startRef,\n numRows: endRow,\n numCols: headers.size,\n getCellValue: this.deps.getCellValue,\n });\n }\n\n getInvalidationFootprint(phase: \"execute\" | \"undo\"): MutationInvalidation {\n return phase === \"execute\" ? this.executeFootprint : this.undoFootprint;\n }\n\n toAction(): EngineAction {\n return {\n type: ActionTypes.REMOVE_TABLE,\n payload: this.opts,\n };\n }\n}\n\n/**\n * Command to rename a table.\n */\nexport class RenameTableCommand implements EngineCommand {\n readonly requiresReevaluation = true;\n private executeFootprint = emptyMutationInvalidation();\n private undoFootprint = emptyMutationInvalidation();\n\n constructor(\n private deps: TableCommandDeps,\n private workbookName: string,\n private oldName: string,\n private newName: string\n ) {}\n\n execute(): void {\n const previousTable = this.deps.tableManager.getTable({\n workbookName: this.workbookName,\n name: this.oldName,\n });\n this.deps.tableManager.renameTable(this.workbookName, {\n oldName: this.oldName,\n newName: this.newName,\n });\n\n // Update formulas in sheet cells\n const changedCells = this.deps.workbookManager.updateAllFormulas((formula) =>\n this.deps.renameTableInFormula(formula, this.oldName, this.newName)\n );\n\n // Update named expressions\n const changedNamedExpressions =\n this.deps.namedExpressionManager.updateAllNamedExpressions((formula) =>\n this.deps.renameTableInFormula(formula, this.oldName, this.newName)\n );\n\n // Update API schemas\n this.deps.apiSchemaManager.updateForTableRename(\n this.workbookName,\n this.oldName,\n this.newName\n );\n const renamedTable = this.deps.tableManager.getTable({\n workbookName: this.workbookName,\n name: this.newName,\n });\n\n this.executeFootprint = {\n touchedCells: mergeTouchedCells(\n buildTableTouchedCells(this.deps.workbookManager, [\n previousTable,\n renamedTable,\n ]),\n changedCells.map((address) => ({\n address,\n beforeKind: \"formula\" as const,\n afterKind: \"formula\" as const,\n }))\n ),\n tableContextChangedCells: buildTableContextChangedCells(\n this.deps.workbookManager,\n [previousTable, renamedTable]\n ),\n resourceKeys: [\n getTableResourceKey({\n workbookName: this.workbookName,\n tableName: this.oldName,\n }),\n getTableResourceKey({\n workbookName: this.workbookName,\n tableName: this.newName,\n }),\n ...changedNamedExpressions,\n ],\n };\n }\n\n undo(): void {\n const currentTable = this.deps.tableManager.getTable({\n workbookName: this.workbookName,\n name: this.newName,\n });\n // Rename back\n this.deps.tableManager.renameTable(this.workbookName, {\n oldName: this.newName,\n newName: this.oldName,\n });\n\n // Update formulas back\n const changedCells = this.deps.workbookManager.updateAllFormulas((formula) =>\n this.deps.renameTableInFormula(formula, this.newName, this.oldName)\n );\n\n // Update named expressions back\n const changedNamedExpressions =\n this.deps.namedExpressionManager.updateAllNamedExpressions((formula) =>\n this.deps.renameTableInFormula(formula, this.newName, this.oldName)\n );\n\n // Update API schemas back\n this.deps.apiSchemaManager.updateForTableRename(\n this.workbookName,\n this.newName,\n this.oldName\n );\n const restoredTable = this.deps.tableManager.getTable({\n workbookName: this.workbookName,\n name: this.oldName,\n });\n\n this.undoFootprint = {\n touchedCells: mergeTouchedCells(\n buildTableTouchedCells(this.deps.workbookManager, [\n currentTable,\n restoredTable,\n ]),\n changedCells.map((address) => ({\n address,\n beforeKind: \"formula\" as const,\n afterKind: \"formula\" as const,\n }))\n ),\n tableContextChangedCells: buildTableContextChangedCells(\n this.deps.workbookManager,\n [currentTable, restoredTable]\n ),\n resourceKeys: [\n getTableResourceKey({\n workbookName: this.workbookName,\n tableName: this.oldName,\n }),\n getTableResourceKey({\n workbookName: this.workbookName,\n tableName: this.newName,\n }),\n ...changedNamedExpressions,\n ],\n };\n }\n\n getInvalidationFootprint(phase: \"execute\" | \"undo\"): MutationInvalidation {\n return phase === \"execute\" ? this.executeFootprint : this.undoFootprint;\n }\n\n toAction(): EngineAction {\n return {\n type: ActionTypes.RENAME_TABLE,\n payload: {\n workbookName: this.workbookName,\n oldName: this.oldName,\n newName: this.newName,\n },\n };\n }\n}\n\n/**\n * Command to update a table.\n */\nexport class UpdateTableCommand implements EngineCommand {\n readonly requiresReevaluation = true;\n private previousTable: TableDefinition | undefined;\n private executeFootprint = emptyMutationInvalidation();\n private undoFootprint = emptyMutationInvalidation();\n\n constructor(\n private deps: TableCommandDeps,\n private opts: {\n tableName: string;\n sheetName?: string;\n start?: string;\n numRows?: SpreadsheetRangeEnd;\n numCols?: number;\n workbookName: string;\n }\n ) {}\n\n execute(): void {\n // Capture previous table state\n this.previousTable = this.deps.tableManager.getTable({\n workbookName: this.opts.workbookName,\n name: this.opts.tableName,\n });\n\n this.deps.tableManager.updateTable({\n ...this.opts,\n getCellValue: this.deps.getCellValue,\n });\n const resourceKey = getTableResourceKey({\n workbookName: this.opts.workbookName,\n tableName: this.opts.tableName,\n });\n const nextTable = this.deps.tableManager.getTable({\n workbookName: this.opts.workbookName,\n name: this.opts.tableName,\n });\n this.executeFootprint = {\n touchedCells: buildTableTouchedCells(this.deps.workbookManager, [\n this.previousTable,\n nextTable,\n ]),\n tableContextChangedCells: buildTableContextChangedCells(\n this.deps.workbookManager,\n [this.previousTable, nextTable]\n ),\n resourceKeys: [resourceKey],\n };\n this.undoFootprint = this.executeFootprint;\n }\n\n undo(): void {\n if (!this.previousTable) return;\n\n // Restore previous table state\n const { start, endRow, headers, sheetName } = this.previousTable;\n const startRef = `${String.fromCharCode(65 + start.colIndex)}${start.rowIndex + 1}`;\n\n this.deps.tableManager.updateTable({\n workbookName: this.opts.workbookName,\n tableName: this.opts.tableName,\n sheetName,\n start: startRef,\n numRows: endRow,\n numCols: headers.size,\n getCellValue: this.deps.getCellValue,\n });\n }\n\n getInvalidationFootprint(phase: \"execute\" | \"undo\"): MutationInvalidation {\n return phase === \"execute\" ? this.executeFootprint : this.undoFootprint;\n }\n\n toAction(): EngineAction {\n return {\n type: ActionTypes.UPDATE_TABLE,\n payload: this.opts,\n };\n }\n}\n\n/**\n * Command to reset all tables.\n */\nexport class ResetTablesCommand implements EngineCommand {\n readonly requiresReevaluation = true;\n private previousTables: Map<string, Map<string, TableDefinition>> | undefined;\n private executeFootprint = emptyMutationInvalidation();\n private undoFootprint = emptyMutationInvalidation();\n\n constructor(\n private deps: TableCommandDeps,\n private newTables: Map<string, Map<string, TableDefinition>>\n ) {}\n\n execute(): void {\n // Capture previous tables\n this.previousTables = new Map();\n for (const [workbookName, tables] of this.deps.tableManager.tables) {\n this.previousTables.set(workbookName, new Map(tables));\n }\n\n this.deps.tableManager.resetTables(this.newTables);\n const resourceKeys = new Set<string>();\n for (const [workbookName, tables] of this.previousTables ?? []) {\n for (const tableName of tables.keys()) {\n resourceKeys.add(\n getTableResourceKey({\n workbookName,\n tableName,\n })\n );\n }\n }\n for (const [workbookName, tables] of this.newTables) {\n for (const tableName of tables.keys()) {\n resourceKeys.add(\n getTableResourceKey({\n workbookName,\n tableName,\n })\n );\n }\n }\n this.executeFootprint = {\n touchedCells: buildTableTouchedCells(this.deps.workbookManager, [\n ...Array.from(this.previousTables?.values() ?? []).flatMap((tables) =>\n Array.from(tables.values())\n ),\n ...Array.from(this.newTables.values()).flatMap((tables) =>\n Array.from(tables.values())\n ),\n ]),\n tableContextChangedCells: buildTableContextChangedCells(\n this.deps.workbookManager,\n [\n ...Array.from(this.previousTables?.values() ?? []).flatMap((tables) =>\n Array.from(tables.values())\n ),\n ...Array.from(this.newTables.values()).flatMap((tables) =>\n Array.from(tables.values())\n ),\n ]\n ),\n resourceKeys: Array.from(resourceKeys),\n };\n this.undoFootprint = this.executeFootprint;\n }\n\n undo(): void {\n if (!this.previousTables) return;\n this.deps.tableManager.resetTables(this.previousTables);\n }\n\n getInvalidationFootprint(phase: \"execute\" | \"undo\"): MutationInvalidation {\n return phase === \"execute\" ? this.executeFootprint : this.undoFootprint;\n }\n\n toAction(): EngineAction {\n return {\n type: ActionTypes.RESET_TABLES,\n payload: {\n tables: Array.from(this.newTables.entries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O,OAAO,CAAC,CAC5B;AAAA,QACA,GAAG,MAAM,KAAK,KAAK,UAAU,OAAO,CAAC,EAAE,QAAQ,CAAC,WAC9C,MAAM,KAAK,OAAO,OAAO,CAAC,CAC5B;AAAA,MACF,CACF;AAAA,MACA,cAAc,MAAM,KAAK,YAAY;AAAA,IACvC;AAAA,IACA,KAAK,gBAAgB,KAAK;AAAA;AAAA,EAG5B,IAAI,GAAS;AAAA,IACX,IAAI,CAAC,KAAK;AAAA,MAAgB;AAAA,IAC1B,KAAK,KAAK,aAAa,YAAY,KAAK,cAAc;AAAA;AAAA,EAGxD,wBAAwB,CAAC,OAAiD;AAAA,IACxE,OAAO,UAAU,YAAY,KAAK,mBAAmB,KAAK;AAAA;AAAA,EAG5D,QAAQ,GAAiB;AAAA,IACvB,OAAO;AAAA,MACL,MAAM,YAAY;AAAA,MAClB,SAAS;AAAA,QACP,QAAQ,MAAM,KAAK,KAAK,UAAU,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,YAAY;AAAA,UACjE;AAAA,UACA,MAAM,KAAK,OAAO,QAAQ,CAAC;AAAA,QAC7B,CAAC;AAAA,MACH;AAAA,IACF;AAAA;AAEJ;",
8
+ "debugId": "C2645E9937E12DCB64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/core/commands/types.ts"],
4
4
  "sourcesContent": [
5
- "/**\n * Command Pattern Types for FormulaEngine\n *\n * Commands encapsulate all mutating operations on the engine,\n * enabling undo/redo, schema validation with rollback, and action serialization.\n */\n\nimport type { CellAddress, RangeAddress, SerializedCellValue } from \"../types.mjs\";\n\nexport type CellContentKind = \"empty\" | \"scalar\" | \"formula\";\n\nexport type RemovedScope =\n | { type: \"workbook\"; workbookName: string }\n | { type: \"sheet\"; workbookName: string; sheetName: string };\n\nexport type MutationInvalidation = {\n touchedCells: Array<{\n address: CellAddress;\n beforeKind: CellContentKind;\n afterKind: CellContentKind;\n }>;\n resourceKeys: string[];\n removedScopes?: RemovedScope[];\n};\n\nexport function getSerializedCellValueKind(\n value: SerializedCellValue | undefined\n): CellContentKind {\n if (\n value === undefined ||\n (typeof value === \"string\" && value.length === 0)\n ) {\n return \"empty\";\n }\n if (typeof value === \"string\" && value.startsWith(\"=\")) {\n return \"formula\";\n }\n return \"scalar\";\n}\n\nexport function emptyMutationInvalidation(): MutationInvalidation {\n return {\n touchedCells: [],\n resourceKeys: [],\n };\n}\n\n/**\n * Serializable action representation of a command.\n * Used for persistence, collaboration, and changelog functionality.\n */\nexport interface EngineAction {\n type: string;\n payload: unknown;\n timestamp?: number;\n}\n\n/**\n * Base interface for all engine commands.\n */\nexport interface EngineCommand {\n /**\n * Whether this command affects cell values/formulas and requires re-evaluation.\n * Commands that only affect metadata or styles don't need re-evaluation.\n */\n readonly requiresReevaluation: boolean;\n\n /**\n * Returns the exact mutation footprint for the last execute/undo pass.\n */\n getInvalidationFootprint?(\n phase: \"execute\" | \"undo\"\n ): MutationInvalidation;\n\n /**\n * Execute the command (forward operation).\n */\n execute(): void;\n\n /**\n * Undo the command (reverse operation).\n */\n undo(): void;\n\n /**\n * Convert the command to a serializable action for persistence/collaboration.\n */\n toAction(): EngineAction;\n}\n\n/**\n * Options for command execution.\n */\nexport interface ExecuteOptions {\n /**\n * Whether to validate schema constraints after execution.\n * Only applies to commands that require re-evaluation.\n */\n validate?: boolean;\n\n /**\n * Whether to skip adding to undo stack (for internal use).\n */\n skipUndoStack?: boolean;\n\n /**\n * Whether to skip emitting update events.\n */\n skipEmitUpdate?: boolean;\n}\n\n/**\n * Result of schema validation.\n */\nexport interface SchemaValidationResult {\n valid: boolean;\n errors: SchemaValidationErrorInfo[];\n}\n\n/**\n * Information about a schema validation error.\n */\nexport interface SchemaValidationErrorInfo {\n message: string;\n cellAddress?: CellAddress;\n schemaNamespace?: string;\n columnName?: string;\n originalError?: Error;\n}\n\n/**\n * Action types for all commands.\n * Used for serialization and deserialization.\n */\nexport const ActionTypes = {\n // Content commands\n SET_CELL_CONTENT: \"SET_CELL_CONTENT\",\n SET_SHEET_CONTENT: \"SET_SHEET_CONTENT\",\n CLEAR_RANGE: \"CLEAR_RANGE\",\n PASTE_CELLS: \"PASTE_CELLS\",\n FILL_AREAS: \"FILL_AREAS\",\n MOVE_CELL: \"MOVE_CELL\",\n MOVE_RANGE: \"MOVE_RANGE\",\n AUTO_FILL: \"AUTO_FILL\",\n\n // Structure commands - Workbook\n ADD_WORKBOOK: \"ADD_WORKBOOK\",\n REMOVE_WORKBOOK: \"REMOVE_WORKBOOK\",\n RENAME_WORKBOOK: \"RENAME_WORKBOOK\",\n CLONE_WORKBOOK: \"CLONE_WORKBOOK\",\n\n // Structure commands - Sheet\n ADD_SHEET: \"ADD_SHEET\",\n REMOVE_SHEET: \"REMOVE_SHEET\",\n RENAME_SHEET: \"RENAME_SHEET\",\n\n // Table commands\n ADD_TABLE: \"ADD_TABLE\",\n REMOVE_TABLE: \"REMOVE_TABLE\",\n RENAME_TABLE: \"RENAME_TABLE\",\n UPDATE_TABLE: \"UPDATE_TABLE\",\n RESET_TABLES: \"RESET_TABLES\",\n\n // Named expression commands\n ADD_NAMED_EXPRESSION: \"ADD_NAMED_EXPRESSION\",\n REMOVE_NAMED_EXPRESSION: \"REMOVE_NAMED_EXPRESSION\",\n UPDATE_NAMED_EXPRESSION: \"UPDATE_NAMED_EXPRESSION\",\n RENAME_NAMED_EXPRESSION: \"RENAME_NAMED_EXPRESSION\",\n SET_NAMED_EXPRESSIONS: \"SET_NAMED_EXPRESSIONS\",\n\n // Metadata commands\n SET_CELL_METADATA: \"SET_CELL_METADATA\",\n SET_SHEET_METADATA: \"SET_SHEET_METADATA\",\n SET_WORKBOOK_METADATA: \"SET_WORKBOOK_METADATA\",\n\n // Style commands\n ADD_CONDITIONAL_STYLE: \"ADD_CONDITIONAL_STYLE\",\n REMOVE_CONDITIONAL_STYLE: \"REMOVE_CONDITIONAL_STYLE\",\n ADD_CELL_STYLE: \"ADD_CELL_STYLE\",\n REMOVE_CELL_STYLE: \"REMOVE_CELL_STYLE\",\n CLEAR_CELL_STYLES: \"CLEAR_CELL_STYLES\",\n\n // State commands\n RESET_TO_SERIALIZED: \"RESET_TO_SERIALIZED\",\n} as const;\n\nexport type ActionType = (typeof ActionTypes)[keyof typeof ActionTypes];\n"
5
+ "/**\n * Command Pattern Types for FormulaEngine\n *\n * Commands encapsulate all mutating operations on the engine,\n * enabling undo/redo, schema validation with rollback, and action serialization.\n */\n\nimport type { CellAddress, RangeAddress, SerializedCellValue } from \"../types.mjs\";\n\nexport type CellContentKind = \"empty\" | \"scalar\" | \"formula\";\n\nexport type RemovedScope =\n | { type: \"workbook\"; workbookName: string }\n | { type: \"sheet\"; workbookName: string; sheetName: string };\n\nexport type MutationInvalidation = {\n touchedCells: Array<{\n address: CellAddress;\n beforeKind: CellContentKind;\n afterKind: CellContentKind;\n }>;\n /**\n * Cells whose table membership or implicit current-row table context changed\n * without necessarily changing their formula text.\n */\n tableContextChangedCells?: CellAddress[];\n resourceKeys: string[];\n removedScopes?: RemovedScope[];\n};\n\nexport function getSerializedCellValueKind(\n value: SerializedCellValue | undefined\n): CellContentKind {\n if (\n value === undefined ||\n (typeof value === \"string\" && value.length === 0)\n ) {\n return \"empty\";\n }\n if (typeof value === \"string\" && value.startsWith(\"=\")) {\n return \"formula\";\n }\n return \"scalar\";\n}\n\nexport function emptyMutationInvalidation(): MutationInvalidation {\n return {\n touchedCells: [],\n resourceKeys: [],\n };\n}\n\n/**\n * Serializable action representation of a command.\n * Used for persistence, collaboration, and changelog functionality.\n */\nexport interface EngineAction {\n type: string;\n payload: unknown;\n timestamp?: number;\n}\n\n/**\n * Base interface for all engine commands.\n */\nexport interface EngineCommand {\n /**\n * Whether this command affects cell values/formulas and requires re-evaluation.\n * Commands that only affect metadata or styles don't need re-evaluation.\n */\n readonly requiresReevaluation: boolean;\n\n /**\n * Returns the exact mutation footprint for the last execute/undo pass.\n */\n getInvalidationFootprint?(\n phase: \"execute\" | \"undo\"\n ): MutationInvalidation;\n\n /**\n * Execute the command (forward operation).\n */\n execute(): void;\n\n /**\n * Undo the command (reverse operation).\n */\n undo(): void;\n\n /**\n * Convert the command to a serializable action for persistence/collaboration.\n */\n toAction(): EngineAction;\n}\n\n/**\n * Options for command execution.\n */\nexport interface ExecuteOptions {\n /**\n * Whether to validate schema constraints after execution.\n * Only applies to commands that require re-evaluation.\n */\n validate?: boolean;\n\n /**\n * Whether to skip adding to undo stack (for internal use).\n */\n skipUndoStack?: boolean;\n\n /**\n * Whether to skip emitting update events.\n */\n skipEmitUpdate?: boolean;\n}\n\n/**\n * Result of schema validation.\n */\nexport interface SchemaValidationResult {\n valid: boolean;\n errors: SchemaValidationErrorInfo[];\n}\n\n/**\n * Information about a schema validation error.\n */\nexport interface SchemaValidationErrorInfo {\n message: string;\n cellAddress?: CellAddress;\n schemaNamespace?: string;\n columnName?: string;\n originalError?: Error;\n}\n\n/**\n * Action types for all commands.\n * Used for serialization and deserialization.\n */\nexport const ActionTypes = {\n // Content commands\n SET_CELL_CONTENT: \"SET_CELL_CONTENT\",\n SET_SHEET_CONTENT: \"SET_SHEET_CONTENT\",\n CLEAR_RANGE: \"CLEAR_RANGE\",\n PASTE_CELLS: \"PASTE_CELLS\",\n FILL_AREAS: \"FILL_AREAS\",\n MOVE_CELL: \"MOVE_CELL\",\n MOVE_RANGE: \"MOVE_RANGE\",\n AUTO_FILL: \"AUTO_FILL\",\n\n // Structure commands - Workbook\n ADD_WORKBOOK: \"ADD_WORKBOOK\",\n REMOVE_WORKBOOK: \"REMOVE_WORKBOOK\",\n RENAME_WORKBOOK: \"RENAME_WORKBOOK\",\n CLONE_WORKBOOK: \"CLONE_WORKBOOK\",\n\n // Structure commands - Sheet\n ADD_SHEET: \"ADD_SHEET\",\n REMOVE_SHEET: \"REMOVE_SHEET\",\n RENAME_SHEET: \"RENAME_SHEET\",\n\n // Table commands\n ADD_TABLE: \"ADD_TABLE\",\n REMOVE_TABLE: \"REMOVE_TABLE\",\n RENAME_TABLE: \"RENAME_TABLE\",\n UPDATE_TABLE: \"UPDATE_TABLE\",\n RESET_TABLES: \"RESET_TABLES\",\n\n // Named expression commands\n ADD_NAMED_EXPRESSION: \"ADD_NAMED_EXPRESSION\",\n REMOVE_NAMED_EXPRESSION: \"REMOVE_NAMED_EXPRESSION\",\n UPDATE_NAMED_EXPRESSION: \"UPDATE_NAMED_EXPRESSION\",\n RENAME_NAMED_EXPRESSION: \"RENAME_NAMED_EXPRESSION\",\n SET_NAMED_EXPRESSIONS: \"SET_NAMED_EXPRESSIONS\",\n\n // Metadata commands\n SET_CELL_METADATA: \"SET_CELL_METADATA\",\n SET_SHEET_METADATA: \"SET_SHEET_METADATA\",\n SET_WORKBOOK_METADATA: \"SET_WORKBOOK_METADATA\",\n\n // Style commands\n ADD_CONDITIONAL_STYLE: \"ADD_CONDITIONAL_STYLE\",\n REMOVE_CONDITIONAL_STYLE: \"REMOVE_CONDITIONAL_STYLE\",\n ADD_CELL_STYLE: \"ADD_CELL_STYLE\",\n REMOVE_CELL_STYLE: \"REMOVE_CELL_STYLE\",\n CLEAR_CELL_STYLES: \"CLEAR_CELL_STYLES\",\n\n // State commands\n RESET_TO_SERIALIZED: \"RESET_TO_SERIALIZED\",\n} as const;\n\nexport type ActionType = (typeof ActionTypes)[keyof typeof ActionTypes];\n"
6
6
  ],
7
- "mappings": ";AAyBO,SAAS,0BAA0B,CACxC,OACiB;AAAA,EACjB,IACE,UAAU,aACT,OAAO,UAAU,YAAY,MAAM,WAAW,GAC/C;AAAA,IACA,OAAO;AAAA,EACT;AAAA,EACA,IAAI,OAAO,UAAU,YAAY,MAAM,WAAW,GAAG,GAAG;AAAA,IACtD,OAAO;AAAA,EACT;AAAA,EACA,OAAO;AAAA;AAGF,SAAS,yBAAyB,GAAyB;AAAA,EAChE,OAAO;AAAA,IACL,cAAc,CAAC;AAAA,IACf,cAAc,CAAC;AAAA,EACjB;AAAA;AA0FK,IAAM,cAAc;AAAA,E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BAAiB;AAAA,EACjB,gBAAgB;AAAA,EAGhB,WAAW;AAAA,EACX,cAAc;AAAA,EACd,cAAc;AAAA,EAGd,WAAW;AAAA,EACX,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EAGd,sBAAsB;AAAA,EACtB,yBAAyB;AAAA,EACzB,yBAAyB;AAAA,EACzB,yBAAyB;AAAA,EACzB,uBAAuB;AAAA,EAGvB,mBAAmB;AAAA,EACnB,oBAAoB;AAAA,EACpB,uBAAuB;AAAA,EAGvB,uBAAuB;AAAA,EACvB,0BAA0B;AAAA,EAC1B,gBAAgB;AAAA,EAChB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EAGnB,qBAAqB;AACvB;",
8
8
  "debugId": "85D9FD30A9DAB95B64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,5 +1,5 @@
1
1
  // src/core/engine-snapshot.ts
2
- var ENGINE_SNAPSHOT_VERSION = 3;
2
+ var ENGINE_SNAPSHOT_VERSION = 4;
3
3
  function getAstNodeSnapshotId(node) {
4
4
  return `${node.key}::${JSON.stringify(node.getContextDependency())}`;
5
5
  }
@@ -8,4 +8,4 @@ export {
8
8
  ENGINE_SNAPSHOT_VERSION
9
9
  };
10
10
 
11
- //# debugId=73CCFF3C522568BD64756E2164756E21
11
+ //# debugId=CE5DBCDE2F63792D64756E2164756E21
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/core/engine-snapshot.ts"],
4
4
  "sourcesContent": [
5
- "import type { ContextDependency } from \"../evaluator/evaluation-context.mjs\";\nimport type { DependencyNode } from \"./managers/dependency-node.mjs\";\nimport type {\n CellAddress,\n CellInRangeResult,\n CellValue,\n ConditionalStyle,\n DirectCellStyle,\n FormulaError,\n NamedExpression,\n RangeAddress,\n RelativeRange,\n SpreadsheetRange,\n TableDefinition,\n TrackedReference,\n Workbook,\n} from \"./types.mjs\";\n\nexport const ENGINE_SNAPSHOT_VERSION = 3 as const;\n\nexport type NodeSnapshotId = string;\n\nexport type NamedExpressionManagerSnapshot = {\n sheetExpressions: Map<string, Map<string, Map<string, NamedExpression>>>;\n workbookExpressions: Map<string, Map<string, NamedExpression>>;\n globalExpressions: Map<string, NamedExpression>;\n};\n\nexport type WorkbookManagerSnapshot = Map<string, Workbook>;\n\nexport type TableManagerSnapshot = Map<string, Map<string, TableDefinition>>;\n\nexport type StyleManagerSnapshot = {\n conditionalStyles: ConditionalStyle[];\n cellStyles: DirectCellStyle[];\n};\n\nexport type ReferenceManagerSnapshot = Map<string, TrackedReference>;\n\nexport type SerializedValueEvaluationResultSnapshot = {\n type: \"value\";\n result: CellValue;\n sourceCell?: CellAddress;\n};\n\nexport type SerializedErrorEvaluationResultSnapshot = {\n type: \"error\";\n err: FormulaError;\n message: string;\n errAddressId: NodeSnapshotId;\n sourceCell?: CellAddress;\n};\n\nexport type SerializedSingleEvaluationResultSnapshot =\n | SerializedValueEvaluationResultSnapshot\n | SerializedErrorEvaluationResultSnapshot;\n\nexport type SerializedCellInRangeResultSnapshot = {\n relativePos: CellInRangeResult[\"relativePos\"];\n result: SerializedSingleEvaluationResultSnapshot;\n};\n\nexport type SerializedEvaluateAllCellsResultSnapshot =\n | SerializedErrorEvaluationResultSnapshot\n | {\n type: \"values\";\n values: SerializedCellInRangeResultSnapshot[];\n };\n\nexport type SerializedMaterializedSpillSnapshot = {\n kind: \"materialized\";\n relativeSpillArea: RelativeRange;\n source: string;\n sourceCell?: CellAddress;\n sourceRange?: RangeAddress;\n values: SerializedCellInRangeResultSnapshot[];\n};\n\nexport type SerializedSourceRangeSpillSnapshot = {\n kind: \"source-range\";\n relativeSpillArea: RelativeRange;\n source: string;\n sourceCell?: CellAddress;\n sourceRange: RangeAddress;\n};\n\nexport type SerializedSpillResultSnapshot =\n | SerializedMaterializedSpillSnapshot\n | SerializedSourceRangeSpillSnapshot;\n\nexport type SerializedSpilledValuesEvaluationResultSnapshot = {\n type: \"spilled-values\";\n spill: SerializedSpillResultSnapshot;\n};\n\nexport type SerializedFunctionEvaluationResultSnapshot =\n | SerializedSingleEvaluationResultSnapshot\n | SerializedSpilledValuesEvaluationResultSnapshot;\n\nexport type SerializedSpillMetaEvaluationResultSnapshot =\n | SerializedErrorEvaluationResultSnapshot\n | SerializedSpilledValuesEvaluationResultSnapshot\n | {\n type: \"does-not-spill\";\n };\n\ntype SerializedBaseNodeSnapshot = {\n snapshotId: NodeSnapshotId;\n key: string;\n dependencies: NodeSnapshotId[];\n};\n\nexport type SerializedCellValueNodeSnapshot = SerializedBaseNodeSnapshot & {\n kind: \"cell-value\";\n evaluationResult: SerializedSingleEvaluationResultSnapshot;\n spillMetaSnapshotId?: NodeSnapshotId;\n};\n\nexport type SerializedSpillMetaNodeSnapshot = SerializedBaseNodeSnapshot & {\n kind: \"spill-meta\";\n evaluationResult: SerializedSpillMetaEvaluationResultSnapshot;\n};\n\nexport type SerializedEmptyCellNodeSnapshot = SerializedBaseNodeSnapshot & {\n kind: \"empty\";\n evaluationResult: SerializedSingleEvaluationResultSnapshot;\n};\n\nexport type SerializedRangeNodeSnapshot = SerializedBaseNodeSnapshot & {\n kind: \"range\";\n result: SerializedEvaluateAllCellsResultSnapshot;\n};\n\nexport type SerializedAstNodeSnapshot = SerializedBaseNodeSnapshot & {\n kind: \"ast\";\n contextDependency: ContextDependency;\n evaluationResult: SerializedFunctionEvaluationResultSnapshot;\n};\n\nexport type SerializedResourceNodeSnapshot = SerializedBaseNodeSnapshot & {\n kind: \"resource\";\n};\n\nexport type SerializedDependencyNodeSnapshot =\n | SerializedCellValueNodeSnapshot\n | SerializedSpillMetaNodeSnapshot\n | SerializedEmptyCellNodeSnapshot\n | SerializedRangeNodeSnapshot\n | SerializedAstNodeSnapshot\n | SerializedResourceNodeSnapshot;\n\nexport type DependencyManagerSnapshot = {\n nodes: SerializedDependencyNodeSnapshot[];\n spilledValues: Array<[string, { origin: CellAddress; spillOnto: SpreadsheetRange }]>;\n};\n\nexport type SerializedSCCSnapshot = {\n id: number;\n nodes: NodeSnapshotId[];\n evaluationOrder: NodeSnapshotId[];\n resolved: boolean;\n hardEdgeSCCs: NodeSnapshotId[][];\n};\n\nexport type SerializedEvaluationOrderSnapshot = {\n nodeKey: string;\n evaluationOrder: NodeSnapshotId[];\n hasCycle: boolean;\n cycleNodes?: NodeSnapshotId[];\n hash: string;\n};\n\nexport type CacheManagerSnapshot = {\n evaluationOrders: SerializedEvaluationOrderSnapshot[];\n sccs: Array<{\n hash: string;\n scc: SerializedSCCSnapshot;\n }>;\n};\n\nexport type EngineSnapshotV3 = {\n version: typeof ENGINE_SNAPSHOT_VERSION;\n managers: {\n workbook: WorkbookManagerSnapshot;\n namedExpression: NamedExpressionManagerSnapshot;\n table: TableManagerSnapshot;\n style: StyleManagerSnapshot;\n reference: ReferenceManagerSnapshot;\n dependency: DependencyManagerSnapshot;\n cache: CacheManagerSnapshot;\n };\n};\n\nexport type EngineSnapshotV2 = EngineSnapshotV3;\n\nexport function getAstNodeSnapshotId(\n node: DependencyNode & { getContextDependency(): ContextDependency }\n): NodeSnapshotId {\n return `${node.key}::${JSON.stringify(node.getContextDependency())}`;\n}\n"
5
+ "import type { ContextDependency } from \"../evaluator/evaluation-context.mjs\";\nimport type { DependencyNode } from \"./managers/dependency-node.mjs\";\nimport type {\n CellAddress,\n CellInRangeResult,\n CellValue,\n ConditionalStyle,\n DirectCellStyle,\n FormulaError,\n NamedExpression,\n RangeAddress,\n RelativeRange,\n SpreadsheetRange,\n TableDefinition,\n TrackedReference,\n Workbook,\n} from \"./types.mjs\";\n\nexport const ENGINE_SNAPSHOT_VERSION = 4 as const;\n\nexport type NodeSnapshotId = string;\n\nexport type NamedExpressionManagerSnapshot = {\n sheetExpressions: Map<string, Map<string, Map<string, NamedExpression>>>;\n workbookExpressions: Map<string, Map<string, NamedExpression>>;\n globalExpressions: Map<string, NamedExpression>;\n};\n\nexport type WorkbookManagerSnapshot = Map<string, Workbook>;\n\nexport type TableManagerSnapshot = Map<string, Map<string, TableDefinition>>;\n\nexport type StyleManagerSnapshot = {\n conditionalStyles: ConditionalStyle[];\n cellStyles: DirectCellStyle[];\n};\n\nexport type ReferenceManagerSnapshot = Map<string, TrackedReference>;\n\nexport type SerializedValueEvaluationResultSnapshot = {\n type: \"value\";\n result: CellValue;\n sourceCell?: CellAddress;\n};\n\nexport type SerializedErrorEvaluationResultSnapshot = {\n type: \"error\";\n err: FormulaError;\n message: string;\n errAddressId: NodeSnapshotId;\n sourceCell?: CellAddress;\n};\n\nexport type SerializedSingleEvaluationResultSnapshot =\n | SerializedValueEvaluationResultSnapshot\n | SerializedErrorEvaluationResultSnapshot;\n\nexport type SerializedCellInRangeResultSnapshot = {\n relativePos: CellInRangeResult[\"relativePos\"];\n result: SerializedSingleEvaluationResultSnapshot;\n};\n\nexport type SerializedEvaluateAllCellsResultSnapshot =\n | SerializedErrorEvaluationResultSnapshot\n | {\n type: \"values\";\n values: SerializedCellInRangeResultSnapshot[];\n };\n\nexport type SerializedMaterializedSpillSnapshot = {\n kind: \"materialized\";\n relativeSpillArea: RelativeRange;\n source: string;\n sourceCell?: CellAddress;\n sourceRange?: RangeAddress;\n values: SerializedCellInRangeResultSnapshot[];\n};\n\nexport type SerializedSourceRangeSpillSnapshot = {\n kind: \"source-range\";\n relativeSpillArea: RelativeRange;\n source: string;\n sourceCell?: CellAddress;\n sourceRange: RangeAddress;\n};\n\nexport type SerializedSpillResultSnapshot =\n | SerializedMaterializedSpillSnapshot\n | SerializedSourceRangeSpillSnapshot;\n\nexport type SerializedSpilledValuesEvaluationResultSnapshot = {\n type: \"spilled-values\";\n spill: SerializedSpillResultSnapshot;\n};\n\nexport type SerializedFunctionEvaluationResultSnapshot =\n | SerializedSingleEvaluationResultSnapshot\n | SerializedSpilledValuesEvaluationResultSnapshot;\n\nexport type SerializedSpillMetaEvaluationResultSnapshot =\n | SerializedErrorEvaluationResultSnapshot\n | SerializedSpilledValuesEvaluationResultSnapshot\n | {\n type: \"does-not-spill\";\n };\n\ntype SerializedBaseNodeSnapshot = {\n snapshotId: NodeSnapshotId;\n key: string;\n dependencies: NodeSnapshotId[];\n};\n\nexport type SerializedCellValueNodeSnapshot = SerializedBaseNodeSnapshot & {\n kind: \"cell-value\";\n evaluationResult: SerializedSingleEvaluationResultSnapshot;\n spillMetaSnapshotId?: NodeSnapshotId;\n};\n\nexport type SerializedSpillMetaNodeSnapshot = SerializedBaseNodeSnapshot & {\n kind: \"spill-meta\";\n evaluationResult: SerializedSpillMetaEvaluationResultSnapshot;\n};\n\nexport type SerializedEmptyCellNodeSnapshot = SerializedBaseNodeSnapshot & {\n kind: \"empty\";\n evaluationResult: SerializedSingleEvaluationResultSnapshot;\n};\n\nexport type SerializedRangeNodeSnapshot = SerializedBaseNodeSnapshot & {\n kind: \"range\";\n result: SerializedEvaluateAllCellsResultSnapshot;\n};\n\nexport type SerializedAstNodeSnapshot = SerializedBaseNodeSnapshot & {\n kind: \"ast\";\n contextDependency: ContextDependency;\n evaluationResult: SerializedFunctionEvaluationResultSnapshot;\n};\n\nexport type SerializedResourceNodeSnapshot = SerializedBaseNodeSnapshot & {\n kind: \"resource\";\n};\n\nexport type SerializedDependencyNodeSnapshot =\n | SerializedCellValueNodeSnapshot\n | SerializedSpillMetaNodeSnapshot\n | SerializedEmptyCellNodeSnapshot\n | SerializedRangeNodeSnapshot\n | SerializedAstNodeSnapshot\n | SerializedResourceNodeSnapshot;\n\nexport type DependencyManagerSnapshot = {\n nodes: SerializedDependencyNodeSnapshot[];\n spilledValues: Array<[string, { origin: CellAddress; spillOnto: SpreadsheetRange }]>;\n};\n\nexport type SerializedSCCSnapshot = {\n id: number;\n nodes: NodeSnapshotId[];\n evaluationOrder: NodeSnapshotId[];\n resolved: boolean;\n hardEdgeSCCs: NodeSnapshotId[][];\n};\n\nexport type SerializedEvaluationOrderSnapshot = {\n nodeKey: string;\n evaluationOrder: NodeSnapshotId[];\n hasCycle: boolean;\n cycleNodes?: NodeSnapshotId[];\n hash: string;\n};\n\nexport type CacheManagerSnapshot = {\n evaluationOrders: SerializedEvaluationOrderSnapshot[];\n sccs: Array<{\n hash: string;\n scc: SerializedSCCSnapshot;\n }>;\n};\n\ntype EngineSnapshotManagers = {\n workbook: WorkbookManagerSnapshot;\n namedExpression: NamedExpressionManagerSnapshot;\n table: TableManagerSnapshot;\n style: StyleManagerSnapshot;\n reference: ReferenceManagerSnapshot;\n dependency: DependencyManagerSnapshot;\n cache: CacheManagerSnapshot;\n};\n\nexport type EngineSnapshot = {\n version: typeof ENGINE_SNAPSHOT_VERSION;\n managers: EngineSnapshotManagers;\n};\n\nexport function getAstNodeSnapshotId(\n node: DependencyNode & { getContextDependency(): ContextDependency }\n): NodeSnapshotId {\n return `${node.key}::${JSON.stringify(node.getContextDependency())}`;\n}\n"
6
6
  ],
7
7
  "mappings": ";AAkBO,IAAM,0BAA0B;AAiLhC,SAAS,oBAAoB,CAClC,MACgB;AAAA,EAChB,OAAO,GAAG,KAAK,QAAQ,KAAK,UAAU,KAAK,qBAAqB,CAAC;AAAA;",
8
- "debugId": "73CCFF3C522568BD64756E2164756E21",
8
+ "debugId": "CE5DBCDE2F63792D64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -411,6 +411,18 @@ class FormulaEngine {
411
411
  }
412
412
  addSheet(opts) {
413
413
  this.commandExecutor.execute(new AddSheetCommand(this.getStructureCommandDeps(), opts), { validate: this.schemaManager.hasSchemas() });
414
+ const sheet = this.workbookManager.getSheet(opts);
415
+ if (!sheet) {
416
+ throw new Error(`Failed to create sheet '${opts.sheetName}'`);
417
+ }
418
+ return sheet;
419
+ }
420
+ createSheet(opts) {
421
+ const sheetName = opts.sheetName ?? this.workbookManager.getNextAvailableSheetName(opts.workbookName, opts.baseName);
422
+ return this.addSheet({
423
+ workbookName: opts.workbookName,
424
+ sheetName
425
+ });
414
426
  }
415
427
  removeSheet(opts) {
416
428
  this.commandExecutor.execute(new RemoveSheetCommand(this.getStructureCommandDeps(), opts), { validate: this.schemaManager.hasSchemas() });
@@ -424,6 +436,15 @@ class FormulaEngine {
424
436
  getSheets(workbookName) {
425
437
  return this.workbookManager.getSheets(workbookName);
426
438
  }
439
+ getOrderedSheets(workbookName) {
440
+ return this.workbookManager.getOrderedSheets(workbookName);
441
+ }
442
+ getOrderedSheetNames(workbookName) {
443
+ return this.workbookManager.getOrderedSheetNames(workbookName);
444
+ }
445
+ getNextAvailableSheetName(workbookName, baseName) {
446
+ return this.workbookManager.getNextAvailableSheetName(workbookName, baseName);
447
+ }
427
448
  getSheet({
428
449
  workbookName,
429
450
  sheetName
@@ -496,8 +517,8 @@ class FormulaEngine {
496
517
  }
497
518
  resetToSerializedEngine(data) {
498
519
  const deserialized = deserialize(data);
499
- if (!deserialized || typeof deserialized !== "object" || deserialized.version !== ENGINE_SNAPSHOT_VERSION || !deserialized.managers) {
500
- throw new Error("Unsupported serialized engine format. Expected EngineSnapshot version 3.");
520
+ if (!deserialized || typeof deserialized !== "object" || !("version" in deserialized) || deserialized.version !== ENGINE_SNAPSHOT_VERSION || !deserialized.managers) {
521
+ throw new Error(`Unsupported serialized engine format. Expected EngineSnapshot version ${ENGINE_SNAPSHOT_VERSION}.`);
501
522
  }
502
523
  this.workbookManager.restoreFromSnapshot(deserialized.managers.workbook);
503
524
  deserialized.managers.workbook.forEach((workbook) => {
@@ -576,4 +597,4 @@ export {
576
597
  FormulaEngine
577
598
  };
578
599
 
579
- //# debugId=C90097576B3FB6F664756E2164756E21
600
+ //# debugId=140E8246E7C976AF64756E2164756E21