@ricsam/formula-engine 0.2.8 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -3
- package/dist/cjs/core/engine.cjs +551 -166
- package/dist/cjs/core/engine.cjs.map +3 -3
- package/dist/cjs/core/managers/dependency-manager.cjs +151 -67
- package/dist/cjs/core/managers/dependency-manager.cjs.map +3 -3
- package/dist/cjs/core/managers/evaluation-manager.cjs.map +1 -1
- package/dist/cjs/core/managers/workbook-manager.cjs +197 -1
- package/dist/cjs/core/managers/workbook-manager.cjs.map +3 -3
- package/dist/cjs/core/mutation-invalidation.cjs +241 -0
- package/dist/cjs/core/mutation-invalidation.cjs.map +10 -0
- package/dist/cjs/core/types.cjs.map +2 -2
- package/dist/cjs/core/workbook-renamer.cjs.map +1 -1
- package/dist/cjs/evaluator/formula-evaluator.cjs +22 -48
- package/dist/cjs/evaluator/formula-evaluator.cjs.map +3 -3
- package/dist/cjs/functions/math/sum/summation-utils.cjs +2 -2
- package/dist/cjs/functions/math/sum/summation-utils.cjs.map +2 -2
- package/dist/cjs/lib.cjs +2 -13
- package/dist/cjs/lib.cjs.map +3 -3
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/parser/formatter.cjs +3 -4
- package/dist/cjs/parser/formatter.cjs.map +3 -3
- package/dist/cjs/parser/parser.cjs +24 -216
- package/dist/cjs/parser/parser.cjs.map +3 -3
- package/dist/mjs/core/engine.mjs +565 -207
- package/dist/mjs/core/engine.mjs.map +3 -3
- package/dist/mjs/core/managers/dependency-manager.mjs +151 -67
- package/dist/mjs/core/managers/dependency-manager.mjs.map +3 -3
- package/dist/mjs/core/managers/evaluation-manager.mjs.map +1 -1
- package/dist/mjs/core/managers/workbook-manager.mjs +197 -1
- package/dist/mjs/core/managers/workbook-manager.mjs.map +3 -3
- package/dist/mjs/core/mutation-invalidation.mjs +201 -0
- package/dist/mjs/core/mutation-invalidation.mjs.map +10 -0
- package/dist/mjs/core/types.mjs.map +2 -2
- package/dist/mjs/core/workbook-renamer.mjs.map +1 -1
- package/dist/mjs/evaluator/formula-evaluator.mjs +22 -48
- package/dist/mjs/evaluator/formula-evaluator.mjs.map +3 -3
- package/dist/mjs/functions/math/sum/summation-utils.mjs +2 -2
- package/dist/mjs/functions/math/sum/summation-utils.mjs.map +2 -2
- package/dist/mjs/lib.mjs +2 -13
- package/dist/mjs/lib.mjs.map +3 -3
- package/dist/mjs/package.json +1 -1
- package/dist/mjs/parser/formatter.mjs +3 -4
- package/dist/mjs/parser/formatter.mjs.map +3 -3
- package/dist/mjs/parser/parser.mjs +24 -216
- package/dist/mjs/parser/parser.mjs.map +3 -3
- package/dist/types/core/engine.d.ts +31 -135
- package/dist/types/core/managers/dependency-manager.d.ts +5 -1
- package/dist/types/core/managers/evaluation-manager.d.ts +1 -1
- package/dist/types/core/managers/workbook-manager.d.ts +23 -1
- package/dist/types/core/mutation-invalidation.d.ts +46 -0
- package/dist/types/core/types.d.ts +35 -0
- package/dist/types/lib.d.ts +0 -8
- package/dist/types/parser/parser.d.ts +4 -6
- package/package.json +1 -1
- package/dist/cjs/core/commands/command-executor.cjs +0 -149
- package/dist/cjs/core/commands/command-executor.cjs.map +0 -10
- package/dist/cjs/core/commands/content-commands.cjs +0 -857
- package/dist/cjs/core/commands/content-commands.cjs.map +0 -10
- package/dist/cjs/core/commands/metadata-commands.cjs +0 -160
- package/dist/cjs/core/commands/metadata-commands.cjs.map +0 -10
- package/dist/cjs/core/commands/named-expression-commands.cjs +0 -363
- package/dist/cjs/core/commands/named-expression-commands.cjs.map +0 -10
- package/dist/cjs/core/commands/structure-commands.cjs +0 -696
- package/dist/cjs/core/commands/structure-commands.cjs.map +0 -10
- package/dist/cjs/core/commands/style-commands.cjs +0 -229
- package/dist/cjs/core/commands/style-commands.cjs.map +0 -10
- package/dist/cjs/core/commands/table-commands.cjs +0 -495
- package/dist/cjs/core/commands/table-commands.cjs.map +0 -10
- package/dist/cjs/core/commands/types.cjs +0 -99
- package/dist/cjs/core/commands/types.cjs.map +0 -10
- package/dist/cjs/core/managers/schema-manager.cjs +0 -374
- package/dist/cjs/core/managers/schema-manager.cjs.map +0 -10
- package/dist/cjs/core/schema/cell-orm.cjs +0 -76
- package/dist/cjs/core/schema/cell-orm.cjs.map +0 -10
- package/dist/cjs/core/schema/grid-orm.cjs +0 -125
- package/dist/cjs/core/schema/grid-orm.cjs.map +0 -10
- package/dist/cjs/core/schema/schema-builder.cjs +0 -74
- package/dist/cjs/core/schema/schema-builder.cjs.map +0 -10
- package/dist/cjs/core/schema/schema-helpers.cjs +0 -200
- package/dist/cjs/core/schema/schema-helpers.cjs.map +0 -10
- package/dist/cjs/core/schema/schema.cjs +0 -91
- package/dist/cjs/core/schema/schema.cjs.map +0 -10
- package/dist/cjs/core/schema/table-orm.cjs +0 -189
- package/dist/cjs/core/schema/table-orm.cjs.map +0 -10
- package/dist/mjs/core/commands/command-executor.mjs +0 -109
- package/dist/mjs/core/commands/command-executor.mjs.map +0 -10
- package/dist/mjs/core/commands/content-commands.mjs +0 -821
- package/dist/mjs/core/commands/content-commands.mjs.map +0 -10
- package/dist/mjs/core/commands/metadata-commands.mjs +0 -120
- package/dist/mjs/core/commands/metadata-commands.mjs.map +0 -10
- package/dist/mjs/core/commands/named-expression-commands.mjs +0 -323
- package/dist/mjs/core/commands/named-expression-commands.mjs.map +0 -10
- package/dist/mjs/core/commands/structure-commands.mjs +0 -661
- package/dist/mjs/core/commands/structure-commands.mjs.map +0 -10
- package/dist/mjs/core/commands/style-commands.mjs +0 -189
- package/dist/mjs/core/commands/style-commands.mjs.map +0 -10
- package/dist/mjs/core/commands/table-commands.mjs +0 -459
- package/dist/mjs/core/commands/table-commands.mjs.map +0 -10
- package/dist/mjs/core/commands/types.mjs +0 -59
- package/dist/mjs/core/commands/types.mjs.map +0 -10
- package/dist/mjs/core/managers/schema-manager.mjs +0 -334
- package/dist/mjs/core/managers/schema-manager.mjs.map +0 -10
- package/dist/mjs/core/schema/cell-orm.mjs +0 -35
- package/dist/mjs/core/schema/cell-orm.mjs.map +0 -10
- package/dist/mjs/core/schema/grid-orm.mjs +0 -84
- package/dist/mjs/core/schema/grid-orm.mjs.map +0 -10
- package/dist/mjs/core/schema/schema-builder.mjs +0 -34
- package/dist/mjs/core/schema/schema-builder.mjs.map +0 -10
- package/dist/mjs/core/schema/schema-helpers.mjs +0 -160
- package/dist/mjs/core/schema/schema-helpers.mjs.map +0 -10
- package/dist/mjs/core/schema/schema.mjs +0 -51
- package/dist/mjs/core/schema/schema.mjs.map +0 -10
- package/dist/mjs/core/schema/table-orm.mjs +0 -156
- package/dist/mjs/core/schema/table-orm.mjs.map +0 -10
- package/dist/types/core/commands/command-executor.d.ts +0 -81
- package/dist/types/core/commands/content-commands.d.ts +0 -172
- package/dist/types/core/commands/metadata-commands.d.ts +0 -55
- package/dist/types/core/commands/named-expression-commands.d.ts +0 -130
- package/dist/types/core/commands/structure-commands.d.ts +0 -155
- package/dist/types/core/commands/style-commands.d.ts +0 -76
- package/dist/types/core/commands/table-commands.d.ts +0 -119
- package/dist/types/core/commands/types.d.ts +0 -143
- package/dist/types/core/managers/schema-manager.d.ts +0 -142
- package/dist/types/core/schema/cell-orm.d.ts +0 -33
- package/dist/types/core/schema/grid-orm.d.ts +0 -63
- package/dist/types/core/schema/schema-builder.d.ts +0 -16
- package/dist/types/core/schema/schema-helpers.d.ts +0 -49
- package/dist/types/core/schema/schema.d.ts +0 -167
- package/dist/types/core/schema/schema.type-test.d.ts +0 -1
- package/dist/types/core/schema/table-orm.d.ts +0 -46
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/core/commands/content-commands.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"/**\n * Content Commands - Commands that modify cell/sheet content\n *\n * These commands all require re-evaluation after execution.\n */\n\nimport type { WorkbookManager } from \"../managers/workbook-manager.mjs\";\nimport type { CopyManager } from \"../managers/copy-manager.mjs\";\nimport type {\n CellAddress,\n CopyCellsOptions,\n RangeAddress,\n SerializedCellValue,\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 { getCellReference, parseCellReference } from \"../utils.mjs\";\n\nfunction buildTouchedCells(\n cells: Array<{\n address: CellAddress;\n before: SerializedCellValue | undefined;\n after: SerializedCellValue | undefined;\n }>\n): MutationInvalidation[\"touchedCells\"] {\n const deduped = new Map<\n string,\n {\n address: CellAddress;\n beforeKind: ReturnType<typeof getSerializedCellValueKind>;\n afterKind: ReturnType<typeof getSerializedCellValueKind>;\n }\n >();\n\n for (const cell of cells) {\n deduped.set(`${cell.address.workbookName}:${cell.address.sheetName}:${getCellReference(cell.address)}`, {\n address: cell.address,\n beforeKind: getSerializedCellValueKind(cell.before),\n afterKind: getSerializedCellValueKind(cell.after),\n });\n }\n\n return Array.from(deduped.values());\n}\n\nfunction getAddressKey(address: CellAddress): string {\n return `${address.workbookName}:${address.sheetName}:${getCellReference(address)}`;\n}\n\nfunction captureCellContents(\n workbookManager: WorkbookManager,\n addresses: CellAddress[]\n): Map<string, SerializedCellValue | undefined> {\n const contents = new Map<string, SerializedCellValue | undefined>();\n for (const address of addresses) {\n contents.set(getAddressKey(address), workbookManager.getCellContent(address));\n }\n return contents;\n}\n\n/**\n * Command to set a single cell's content.\n */\nexport class SetCellContentCommand implements EngineCommand {\n readonly requiresReevaluation = true;\n private previousValue: SerializedCellValue | undefined;\n private hadPreviousValue = false;\n private executeFootprint = emptyMutationInvalidation();\n private undoFootprint = emptyMutationInvalidation();\n\n constructor(\n private workbookManager: WorkbookManager,\n private address: CellAddress,\n private newContent: SerializedCellValue\n ) {}\n\n execute(): void {\n // Capture previous value\n const sheet = this.workbookManager.getSheet({\n workbookName: this.address.workbookName,\n sheetName: this.address.sheetName,\n });\n if (sheet) {\n const key = getCellReference(this.address);\n this.hadPreviousValue = sheet.content.has(key);\n this.previousValue = sheet.content.get(key);\n }\n\n this.workbookManager.setCellContent(this.address, this.newContent);\n this.executeFootprint = {\n touchedCells: buildTouchedCells([\n {\n address: this.address,\n before: this.previousValue,\n after: this.newContent,\n },\n ]),\n resourceKeys: [],\n };\n this.undoFootprint = {\n touchedCells: buildTouchedCells([\n {\n address: this.address,\n before: this.newContent,\n after: this.hadPreviousValue ? this.previousValue : undefined,\n },\n ]),\n resourceKeys: [],\n };\n }\n\n undo(): void {\n if (this.hadPreviousValue) {\n this.workbookManager.setCellContent(this.address, this.previousValue);\n } else {\n this.workbookManager.setCellContent(this.address, undefined);\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.SET_CELL_CONTENT,\n payload: {\n address: this.address,\n content: this.newContent,\n },\n };\n }\n}\n\n/**\n * Command to set an entire sheet's content.\n */\nexport class SetSheetContentCommand implements EngineCommand {\n readonly requiresReevaluation = true;\n private previousContent: Map<string, SerializedCellValue> | undefined;\n private executeFootprint = emptyMutationInvalidation();\n private undoFootprint = emptyMutationInvalidation();\n\n constructor(\n private workbookManager: WorkbookManager,\n private opts: { workbookName: string; sheetName: string },\n private newContent: Map<string, SerializedCellValue>\n ) {}\n\n execute(): void {\n // Capture previous content\n const sheet = this.workbookManager.getSheet(this.opts);\n if (sheet) {\n this.previousContent = new Map(sheet.content);\n }\n\n this.workbookManager.setSheetContent(this.opts, this.newContent);\n const touchedKeys = new Set<string>([\n ...Array.from(this.previousContent?.keys() ?? []),\n ...Array.from(this.newContent.keys()),\n ]);\n const touchedCells = buildTouchedCells(\n Array.from(touchedKeys, (key) => ({\n address: {\n workbookName: this.opts.workbookName,\n sheetName: this.opts.sheetName,\n ...parseCellReference(key),\n },\n before: this.previousContent?.get(key),\n after: this.newContent.get(key),\n }))\n );\n this.executeFootprint = {\n touchedCells,\n resourceKeys: [],\n };\n this.undoFootprint = {\n touchedCells: buildTouchedCells(\n Array.from(touchedKeys, (key) => ({\n address: {\n workbookName: this.opts.workbookName,\n sheetName: this.opts.sheetName,\n ...parseCellReference(key),\n },\n before: this.newContent.get(key),\n after: this.previousContent?.get(key),\n }))\n ),\n resourceKeys: [],\n };\n }\n\n undo(): void {\n if (this.previousContent) {\n this.workbookManager.setSheetContent(this.opts, this.previousContent);\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.SET_SHEET_CONTENT,\n payload: {\n opts: this.opts,\n content: Array.from(this.newContent.entries()),\n },\n };\n }\n}\n\n/**\n * Command to clear a range of cells.\n */\nexport class ClearRangeCommand implements EngineCommand {\n readonly requiresReevaluation = true;\n private clearedCells: Map<string, SerializedCellValue> = new Map();\n private executeFootprint = emptyMutationInvalidation();\n private undoFootprint = emptyMutationInvalidation();\n\n constructor(\n private workbookManager: WorkbookManager,\n private address: RangeAddress\n ) {}\n\n execute(): void {\n this.clearedCells.clear();\n // Capture cells before clearing using the optimized iterator\n // This handles infinite ranges by only iterating over cells that actually exist\n try {\n for (const cellAddress of this.workbookManager.iterateCellsInRange(this.address)) {\n const key = getCellReference(cellAddress);\n const value = this.workbookManager.getCellContent(cellAddress);\n if (value !== undefined) {\n this.clearedCells.set(key, value);\n }\n }\n } catch {\n // Sheet doesn't exist, nothing to capture\n }\n\n this.workbookManager.clearSpreadsheetRange(this.address);\n this.executeFootprint = {\n touchedCells: buildTouchedCells(\n Array.from(this.clearedCells.entries(), ([key, before]) => ({\n address: {\n workbookName: this.address.workbookName,\n sheetName: this.address.sheetName,\n ...parseCellReference(key),\n },\n before,\n after: undefined,\n }))\n ),\n resourceKeys: [],\n };\n this.undoFootprint = {\n touchedCells: buildTouchedCells(\n Array.from(this.clearedCells.entries(), ([key, after]) => ({\n address: {\n workbookName: this.address.workbookName,\n sheetName: this.address.sheetName,\n ...parseCellReference(key),\n },\n before: undefined,\n after,\n }))\n ),\n resourceKeys: [],\n };\n }\n\n undo(): void {\n // Restore cleared cells\n for (const [key, value] of this.clearedCells) {\n const { colIndex, rowIndex } = parseCellReference(key);\n this.workbookManager.setCellContent(\n {\n workbookName: this.address.workbookName,\n sheetName: this.address.sheetName,\n colIndex,\n rowIndex,\n },\n value\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.CLEAR_RANGE,\n payload: {\n address: this.address,\n },\n };\n }\n}\n\n/**\n * Snapshot of a cell for undo purposes.\n */\ninterface CellSnapshot {\n address: CellAddress;\n content: SerializedCellValue | undefined;\n metadata: unknown | undefined;\n}\n\n/**\n * Command to paste cells.\n */\nexport class PasteCellsCommand implements EngineCommand {\n readonly requiresReevaluation = true;\n private targetSnapshots: CellSnapshot[] = [];\n private sourceSnapshots: CellSnapshot[] = [];\n private executeFootprint = emptyMutationInvalidation();\n private undoFootprint = emptyMutationInvalidation();\n private executedContents: Map<string, SerializedCellValue | undefined> =\n new Map();\n\n constructor(\n private workbookManager: WorkbookManager,\n private copyManager: CopyManager,\n private source: CellAddress[],\n private target: CellAddress,\n private options: CopyCellsOptions\n ) {}\n\n execute(): void {\n this.targetSnapshots = [];\n this.sourceSnapshots = [];\n this.executedContents.clear();\n // Calculate target cells and capture their state\n if (this.source.length > 0) {\n const firstSource = this.source[0]!;\n const colOffset = this.target.colIndex - firstSource.colIndex;\n const rowOffset = this.target.rowIndex - firstSource.rowIndex;\n\n // Capture target cells before paste\n for (const sourceCell of this.source) {\n const targetCell: CellAddress = {\n workbookName: this.target.workbookName,\n sheetName: this.target.sheetName,\n colIndex: sourceCell.colIndex + colOffset,\n rowIndex: sourceCell.rowIndex + rowOffset,\n };\n\n const sheet = this.workbookManager.getSheet({\n workbookName: targetCell.workbookName,\n sheetName: targetCell.sheetName,\n });\n\n if (sheet) {\n const key = getCellReference(targetCell);\n this.targetSnapshots.push({\n address: targetCell,\n content: sheet.content.get(key),\n metadata: sheet.metadata.get(key),\n });\n }\n }\n\n // If cut operation, capture source cells too\n if (this.options.cut) {\n for (const sourceCell of this.source) {\n const sheet = this.workbookManager.getSheet({\n workbookName: sourceCell.workbookName,\n sheetName: sourceCell.sheetName,\n });\n\n if (sheet) {\n const key = getCellReference(sourceCell);\n this.sourceSnapshots.push({\n address: sourceCell,\n content: sheet.content.get(key),\n metadata: sheet.metadata.get(key),\n });\n }\n }\n }\n }\n\n this.copyManager.pasteCells(this.source, this.target, this.options);\n const touchedAddresses = [\n ...this.targetSnapshots.map((snapshot) => snapshot.address),\n ...this.sourceSnapshots.map((snapshot) => snapshot.address),\n ];\n this.executedContents = captureCellContents(this.workbookManager, touchedAddresses);\n this.executeFootprint = {\n touchedCells: buildTouchedCells(\n touchedAddresses.map((address) => {\n const beforeSnapshot =\n this.targetSnapshots.find(\n (snapshot) =>\n snapshot.address.workbookName === address.workbookName &&\n snapshot.address.sheetName === address.sheetName &&\n snapshot.address.colIndex === address.colIndex &&\n snapshot.address.rowIndex === address.rowIndex\n ) ??\n this.sourceSnapshots.find(\n (snapshot) =>\n snapshot.address.workbookName === address.workbookName &&\n snapshot.address.sheetName === address.sheetName &&\n snapshot.address.colIndex === address.colIndex &&\n snapshot.address.rowIndex === address.rowIndex\n );\n return {\n address,\n before: beforeSnapshot?.content,\n after: this.executedContents.get(getAddressKey(address)),\n };\n })\n ),\n resourceKeys: [],\n };\n }\n\n undo(): void {\n // Restore target cells\n for (const snapshot of this.targetSnapshots) {\n this.workbookManager.setCellContent(snapshot.address, snapshot.content);\n if (snapshot.metadata !== undefined) {\n this.workbookManager.setCellMetadata(snapshot.address, snapshot.metadata);\n }\n }\n\n // Restore source cells if it was a cut operation\n if (this.options.cut) {\n for (const snapshot of this.sourceSnapshots) {\n this.workbookManager.setCellContent(snapshot.address, snapshot.content);\n if (snapshot.metadata !== undefined) {\n this.workbookManager.setCellMetadata(snapshot.address, snapshot.metadata);\n }\n }\n }\n\n const touchedAddresses = [\n ...this.targetSnapshots.map((snapshot) => snapshot.address),\n ...this.sourceSnapshots.map((snapshot) => snapshot.address),\n ];\n this.undoFootprint = {\n touchedCells: buildTouchedCells(\n touchedAddresses.map((address) => {\n return {\n address,\n before: this.executedContents.get(getAddressKey(address)),\n after: this.workbookManager.getCellContent(address),\n };\n })\n ),\n resourceKeys: [],\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.PASTE_CELLS,\n payload: {\n source: this.source,\n target: this.target,\n options: this.options,\n },\n };\n }\n}\n\n/**\n * Command to fill areas with a seed range.\n */\nexport class FillAreasCommand implements EngineCommand {\n readonly requiresReevaluation = true;\n private targetSnapshots: Map<string, CellSnapshot> = new Map();\n private executeFootprint = emptyMutationInvalidation();\n private undoFootprint = emptyMutationInvalidation();\n private executedContents: Map<string, SerializedCellValue | undefined> =\n new Map();\n\n constructor(\n private workbookManager: WorkbookManager,\n private copyManager: CopyManager,\n private seedRange: RangeAddress,\n private targetRanges: RangeAddress[],\n private options: CopyCellsOptions\n ) {}\n\n execute(): void {\n this.targetSnapshots.clear();\n this.executedContents.clear();\n // Capture all target cells before filling\n for (const targetRange of this.targetRanges) {\n const sheet = this.workbookManager.getSheet({\n workbookName: targetRange.workbookName,\n sheetName: targetRange.sheetName,\n });\n\n if (sheet) {\n const { start, end } = targetRange.range;\n const endCol = end.col.type === \"number\" ? end.col.value : start.col + 100;\n const endRow = end.row.type === \"number\" ? end.row.value : start.row + 100;\n\n for (let col = start.col; col <= endCol; col++) {\n for (let row = start.row; row <= endRow; row++) {\n const address: CellAddress = {\n workbookName: targetRange.workbookName,\n sheetName: targetRange.sheetName,\n colIndex: col,\n rowIndex: row,\n };\n const key = getCellReference(address);\n const fullKey = `${targetRange.workbookName}:${targetRange.sheetName}:${key}`;\n\n if (!this.targetSnapshots.has(fullKey)) {\n this.targetSnapshots.set(fullKey, {\n address,\n content: sheet.content.get(key),\n metadata: sheet.metadata.get(key),\n });\n }\n }\n }\n }\n }\n\n this.copyManager.fillAreas(this.seedRange, this.targetRanges, this.options);\n const touchedAddresses = Array.from(this.targetSnapshots.values()).map(\n (snapshot) => snapshot.address\n );\n this.executedContents = captureCellContents(this.workbookManager, touchedAddresses);\n this.executeFootprint = {\n touchedCells: buildTouchedCells(\n touchedAddresses.map((address) => ({\n address,\n before: this.targetSnapshots.get(getAddressKey(address))?.content,\n after: this.executedContents.get(getAddressKey(address)),\n }))\n ),\n resourceKeys: [],\n };\n }\n\n undo(): void {\n // Restore all target cells\n for (const snapshot of this.targetSnapshots.values()) {\n this.workbookManager.setCellContent(snapshot.address, snapshot.content);\n if (snapshot.metadata !== undefined) {\n this.workbookManager.setCellMetadata(snapshot.address, snapshot.metadata);\n }\n }\n\n const touchedAddresses = Array.from(this.targetSnapshots.values()).map(\n (snapshot) => snapshot.address\n );\n this.undoFootprint = {\n touchedCells: buildTouchedCells(\n touchedAddresses.map((address) => ({\n address,\n before: this.executedContents.get(getAddressKey(address)),\n after: this.workbookManager.getCellContent(address),\n }))\n ),\n resourceKeys: [],\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.FILL_AREAS,\n payload: {\n seedRange: this.seedRange,\n targetRanges: this.targetRanges,\n options: this.options,\n },\n };\n }\n}\n\n/**\n * Command to move a single cell.\n */\nexport class MoveCellCommand implements EngineCommand {\n readonly requiresReevaluation = true;\n private sourceSnapshot: CellSnapshot | undefined;\n private targetSnapshot: CellSnapshot | undefined;\n private executeFootprint = emptyMutationInvalidation();\n private undoFootprint = emptyMutationInvalidation();\n private executedContents: Map<string, SerializedCellValue | undefined> =\n new Map();\n\n constructor(\n private workbookManager: WorkbookManager,\n private copyManager: CopyManager,\n private source: CellAddress,\n private target: CellAddress\n ) {}\n\n execute(): void {\n this.sourceSnapshot = undefined;\n this.targetSnapshot = undefined;\n this.executedContents.clear();\n // Capture source cell\n const sourceSheet = this.workbookManager.getSheet({\n workbookName: this.source.workbookName,\n sheetName: this.source.sheetName,\n });\n\n if (sourceSheet) {\n const key = getCellReference(this.source);\n this.sourceSnapshot = {\n address: this.source,\n content: sourceSheet.content.get(key),\n metadata: sourceSheet.metadata.get(key),\n };\n }\n\n // Capture target cell\n const targetSheet = this.workbookManager.getSheet({\n workbookName: this.target.workbookName,\n sheetName: this.target.sheetName,\n });\n\n if (targetSheet) {\n const key = getCellReference(this.target);\n this.targetSnapshot = {\n address: this.target,\n content: targetSheet.content.get(key),\n metadata: targetSheet.metadata.get(key),\n };\n }\n\n // Execute the move via paste with cut option\n this.copyManager.pasteCells([this.source], this.target, {\n cut: true,\n type: \"formula\",\n include: \"all\",\n });\n const touchedAddresses = [this.source, this.target];\n this.executedContents = captureCellContents(this.workbookManager, touchedAddresses);\n this.executeFootprint = {\n touchedCells: buildTouchedCells(\n touchedAddresses.map((address) => ({\n address,\n before:\n this.sourceSnapshot?.address === address\n ? this.sourceSnapshot.content\n : this.targetSnapshot?.content,\n after: this.executedContents.get(getAddressKey(address)),\n }))\n ),\n resourceKeys: [],\n };\n }\n\n undo(): void {\n // Restore source cell\n if (this.sourceSnapshot) {\n this.workbookManager.setCellContent(\n this.sourceSnapshot.address,\n this.sourceSnapshot.content\n );\n if (this.sourceSnapshot.metadata !== undefined) {\n this.workbookManager.setCellMetadata(\n this.sourceSnapshot.address,\n this.sourceSnapshot.metadata\n );\n }\n }\n\n // Restore target cell\n if (this.targetSnapshot) {\n this.workbookManager.setCellContent(\n this.targetSnapshot.address,\n this.targetSnapshot.content\n );\n if (this.targetSnapshot.metadata !== undefined) {\n this.workbookManager.setCellMetadata(\n this.targetSnapshot.address,\n this.targetSnapshot.metadata\n );\n }\n }\n\n const touchedAddresses = [this.source, this.target];\n this.undoFootprint = {\n touchedCells: buildTouchedCells(\n touchedAddresses.map((address) => ({\n address,\n before: this.executedContents.get(getAddressKey(address)),\n after: this.workbookManager.getCellContent(address),\n }))\n ),\n resourceKeys: [],\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.MOVE_CELL,\n payload: {\n source: this.source,\n target: this.target,\n },\n };\n }\n}\n\n/**\n * Command to move a range of cells.\n */\nexport class MoveRangeCommand implements EngineCommand {\n readonly requiresReevaluation = true;\n private sourceSnapshots: CellSnapshot[] = [];\n private targetSnapshots: CellSnapshot[] = [];\n private executeFootprint = emptyMutationInvalidation();\n private undoFootprint = emptyMutationInvalidation();\n private executedContents: Map<string, SerializedCellValue | undefined> =\n new Map();\n\n constructor(\n private workbookManager: WorkbookManager,\n private copyManager: CopyManager,\n private sourceRange: RangeAddress,\n private target: CellAddress\n ) {}\n\n execute(): void {\n this.sourceSnapshots = [];\n this.targetSnapshots = [];\n this.executedContents.clear();\n // Expand source range to cells\n const sourceCells = this.copyManager.expandRangeToCells(this.sourceRange);\n\n // Capture source cells\n for (const cell of sourceCells) {\n const sheet = this.workbookManager.getSheet({\n workbookName: cell.workbookName,\n sheetName: cell.sheetName,\n });\n\n if (sheet) {\n const key = getCellReference(cell);\n this.sourceSnapshots.push({\n address: cell,\n content: sheet.content.get(key),\n metadata: sheet.metadata.get(key),\n });\n }\n }\n\n // Calculate and capture target cells\n if (sourceCells.length > 0) {\n const firstSource = sourceCells[0]!;\n const colOffset = this.target.colIndex - firstSource.colIndex;\n const rowOffset = this.target.rowIndex - firstSource.rowIndex;\n\n for (const sourceCell of sourceCells) {\n const targetCell: CellAddress = {\n workbookName: this.target.workbookName,\n sheetName: this.target.sheetName,\n colIndex: sourceCell.colIndex + colOffset,\n rowIndex: sourceCell.rowIndex + rowOffset,\n };\n\n const sheet = this.workbookManager.getSheet({\n workbookName: targetCell.workbookName,\n sheetName: targetCell.sheetName,\n });\n\n if (sheet) {\n const key = getCellReference(targetCell);\n this.targetSnapshots.push({\n address: targetCell,\n content: sheet.content.get(key),\n metadata: sheet.metadata.get(key),\n });\n }\n }\n }\n\n // Execute the move\n this.copyManager.pasteCells(sourceCells, this.target, {\n cut: true,\n type: \"formula\",\n include: \"all\",\n });\n const touchedAddresses = [\n ...this.sourceSnapshots.map((snapshot) => snapshot.address),\n ...this.targetSnapshots.map((snapshot) => snapshot.address),\n ];\n this.executedContents = captureCellContents(this.workbookManager, touchedAddresses);\n this.executeFootprint = {\n touchedCells: buildTouchedCells(\n touchedAddresses.map((address) => {\n const snapshot =\n this.sourceSnapshots.find(\n (candidate) => getAddressKey(candidate.address) === getAddressKey(address)\n ) ??\n this.targetSnapshots.find(\n (candidate) => getAddressKey(candidate.address) === getAddressKey(address)\n );\n return {\n address,\n before: snapshot?.content,\n after: this.executedContents.get(getAddressKey(address)),\n };\n })\n ),\n resourceKeys: [],\n };\n }\n\n undo(): void {\n // Restore source cells\n for (const snapshot of this.sourceSnapshots) {\n this.workbookManager.setCellContent(snapshot.address, snapshot.content);\n if (snapshot.metadata !== undefined) {\n this.workbookManager.setCellMetadata(snapshot.address, snapshot.metadata);\n }\n }\n\n // Restore target cells\n for (const snapshot of this.targetSnapshots) {\n this.workbookManager.setCellContent(snapshot.address, snapshot.content);\n if (snapshot.metadata !== undefined) {\n this.workbookManager.setCellMetadata(snapshot.address, snapshot.metadata);\n }\n }\n\n const touchedAddresses = [\n ...this.sourceSnapshots.map((snapshot) => snapshot.address),\n ...this.targetSnapshots.map((snapshot) => snapshot.address),\n ];\n this.undoFootprint = {\n touchedCells: buildTouchedCells(\n touchedAddresses.map((address) => ({\n address,\n before: this.executedContents.get(getAddressKey(address)),\n after: this.workbookManager.getCellContent(address),\n }))\n ),\n resourceKeys: [],\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.MOVE_RANGE,\n payload: {\n sourceRange: this.sourceRange,\n target: this.target,\n },\n };\n }\n}\n\n/**\n * Command to auto-fill ranges based on a seed pattern.\n * Captures the entire affected area for undo.\n */\nexport class AutoFillCommand implements EngineCommand {\n readonly requiresReevaluation = true;\n private previousContent: Map<string, SerializedCellValue> = new Map();\n private previousMetadata: Map<string, unknown> = new Map();\n private executeFootprint = emptyMutationInvalidation();\n private undoFootprint = emptyMutationInvalidation();\n private touchedAddresses: CellAddress[] = [];\n private executedContents: Map<string, SerializedCellValue | undefined> =\n new Map();\n\n constructor(\n private workbookManager: WorkbookManager,\n private styleManager: import(\"../managers/style-manager.mjs\").StyleManager,\n private autoFillManager: import(\"../autofill-utils.mjs\").AutoFill,\n private opts: { sheetName: string; workbookName: string },\n private seedRange: import(\"../types.mjs\").SpreadsheetRange,\n private fillRanges: import(\"../types.mjs\").SpreadsheetRange[],\n private direction: import(\"@ricsam/selection-manager\").FillDirection\n ) {}\n\n execute(): void {\n this.previousContent.clear();\n this.previousMetadata.clear();\n this.touchedAddresses = [];\n this.executedContents.clear();\n // Capture current content and metadata in fill ranges before modification\n for (const fillRange of this.fillRanges) {\n if (fillRange.end.col.type === \"infinity\" || fillRange.end.row.type === \"infinity\") {\n continue; // Skip infinite ranges\n }\n \n const startCol = fillRange.start.col;\n const startRow = fillRange.start.row;\n const endCol = fillRange.end.col.value;\n const endRow = fillRange.end.row.value;\n\n for (let row = startRow; row <= endRow; row++) {\n for (let col = startCol; col <= endCol; col++) {\n const key = getCellReference({ colIndex: col, rowIndex: row });\n const address = {\n workbookName: this.opts.workbookName,\n sheetName: this.opts.sheetName,\n colIndex: col,\n rowIndex: row,\n };\n this.touchedAddresses.push(address);\n \n const content = this.workbookManager.getCellContent(address);\n if (content !== undefined) {\n this.previousContent.set(key, content);\n }\n \n const metadata = this.workbookManager.getCellMetadata(address);\n if (metadata !== undefined) {\n this.previousMetadata.set(key, metadata);\n }\n }\n }\n }\n\n // Execute the auto-fill operation\n this.autoFillManager.fill(this.opts, this.seedRange, this.fillRanges, this.direction);\n this.executedContents = captureCellContents(this.workbookManager, this.touchedAddresses);\n this.executeFootprint = {\n touchedCells: buildTouchedCells(\n this.touchedAddresses.map((address) => {\n const key = getCellReference(address);\n return {\n address,\n before: this.previousContent.get(key),\n after: this.executedContents.get(getAddressKey(address)),\n };\n })\n ),\n resourceKeys: [],\n };\n }\n\n undo(): void {\n // Get current sheet content\n const currentContent = this.workbookManager.getSheetSerialized(this.opts);\n const newContent = new Map(currentContent);\n\n // Restore all fill range cells to their previous state\n for (const fillRange of this.fillRanges) {\n if (fillRange.end.col.type === \"infinity\" || fillRange.end.row.type === \"infinity\") {\n continue;\n }\n \n const startCol = fillRange.start.col;\n const startRow = fillRange.start.row;\n const endCol = fillRange.end.col.value;\n const endRow = fillRange.end.row.value;\n\n for (let row = startRow; row <= endRow; row++) {\n for (let col = startCol; col <= endCol; col++) {\n const key = getCellReference({ colIndex: col, rowIndex: row });\n const address = {\n workbookName: this.opts.workbookName,\n sheetName: this.opts.sheetName,\n colIndex: col,\n rowIndex: row,\n };\n \n // Restore content\n if (this.previousContent.has(key)) {\n newContent.set(key, this.previousContent.get(key)!);\n } else {\n newContent.delete(key);\n }\n \n // Restore metadata\n if (this.previousMetadata.has(key)) {\n this.workbookManager.setCellMetadata(address, this.previousMetadata.get(key));\n } else {\n this.workbookManager.setCellMetadata(address, undefined);\n }\n }\n }\n }\n\n // Apply restored content\n this.workbookManager.setSheetContent(this.opts, newContent);\n this.undoFootprint = {\n touchedCells: buildTouchedCells(\n this.touchedAddresses.map((address) => ({\n address,\n before: this.executedContents.get(getAddressKey(address)),\n after: this.workbookManager.getCellContent(address),\n }))\n ),\n resourceKeys: [],\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.AUTO_FILL,\n payload: {\n opts: this.opts,\n seedRange: this.seedRange,\n fillRanges: this.fillRanges,\n direction: this.direction,\n },\n };\n }\n}\n"
|
|
6
|
-
],
|
|
7
|
-
"mappings": ";AAmBA;AAAA;AAAA;AAAA;AAAA;AAKA;AAEA,SAAS,iBAAiB,CACxB,OAKsC;AAAA,EACtC,MAAM,UAAU,IAAI;AAAA,EASpB,WAAW,QAAQ,OAAO;AAAA,IACxB,QAAQ,IAAI,GAAG,KAAK,QAAQ,gBAAgB,KAAK,QAAQ,aAAa,iBAAiB,KAAK,OAAO,KAAK;AAAA,MACtG,SAAS,KAAK;AAAA,MACd,YAAY,2BAA2B,KAAK,MAAM;AAAA,MAClD,WAAW,2BAA2B,KAAK,KAAK;AAAA,IAClD,CAAC;AAAA,EACH;AAAA,EAEA,OAAO,MAAM,KAAK,QAAQ,OAAO,CAAC;AAAA;AAGpC,SAAS,aAAa,CAAC,SAA8B;AAAA,EACnD,OAAO,GAAG,QAAQ,gBAAgB,QAAQ,aAAa,iBAAiB,OAAO;AAAA;AAGjF,SAAS,mBAAmB,CAC1B,iBACA,WAC8C;AAAA,EAC9C,MAAM,WAAW,IAAI;AAAA,EACrB,WAAW,WAAW,WAAW;AAAA,IAC/B,SAAS,IAAI,cAAc,OAAO,GAAG,gBAAgB,eAAe,OAAO,CAAC;AAAA,EAC9E;AAAA,EACA,OAAO;AAAA;AAAA;AAMF,MAAM,sBAA+C;AAAA,EAQhD;AAAA,EACA;AAAA,EACA;AAAA,EATD,uBAAuB;AAAA,EACxB;AAAA,EACA,mBAAmB;AAAA,EACnB,mBAAmB,0BAA0B;AAAA,EAC7C,gBAAgB,0BAA0B;AAAA,EAElD,WAAW,CACD,iBACA,SACA,YAC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,OAAO,KAAK,gBAAgB,eAAe,OAAO;AAAA,MACpD,EAAE,CACJ;AAAA,MACA,cAAc,CAAC;AAAA,IACjB;AAAA;AAAA,EAGF,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,MAAM,KAAK;AAAA,QACX,WAAW,KAAK;AAAA,QAChB,YAAY,KAAK;AAAA,QACjB,WAAW,KAAK;AAAA,MAClB;AAAA,IACF;AAAA;AAEJ;",
|
|
8
|
-
"debugId": "827AAF04E7067A3964756E2164756E21",
|
|
9
|
-
"names": []
|
|
10
|
-
}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
// src/core/commands/metadata-commands.ts
|
|
2
|
-
import { ActionTypes } from "./types.mjs";
|
|
3
|
-
import { getCellReference } from "../utils.mjs";
|
|
4
|
-
|
|
5
|
-
class SetCellMetadataCommand {
|
|
6
|
-
workbookManager;
|
|
7
|
-
address;
|
|
8
|
-
newMetadata;
|
|
9
|
-
requiresReevaluation = false;
|
|
10
|
-
previousMetadata;
|
|
11
|
-
hadPreviousMetadata = false;
|
|
12
|
-
constructor(workbookManager, address, newMetadata) {
|
|
13
|
-
this.workbookManager = workbookManager;
|
|
14
|
-
this.address = address;
|
|
15
|
-
this.newMetadata = newMetadata;
|
|
16
|
-
}
|
|
17
|
-
execute() {
|
|
18
|
-
const sheet = this.workbookManager.getSheet({
|
|
19
|
-
workbookName: this.address.workbookName,
|
|
20
|
-
sheetName: this.address.sheetName
|
|
21
|
-
});
|
|
22
|
-
if (sheet) {
|
|
23
|
-
const key = getCellReference(this.address);
|
|
24
|
-
this.hadPreviousMetadata = sheet.metadata.has(key);
|
|
25
|
-
this.previousMetadata = sheet.metadata.get(key);
|
|
26
|
-
}
|
|
27
|
-
this.workbookManager.setCellMetadata(this.address, this.newMetadata);
|
|
28
|
-
}
|
|
29
|
-
undo() {
|
|
30
|
-
if (this.hadPreviousMetadata) {
|
|
31
|
-
this.workbookManager.setCellMetadata(this.address, this.previousMetadata);
|
|
32
|
-
} else {
|
|
33
|
-
this.workbookManager.setCellMetadata(this.address, undefined);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
toAction() {
|
|
37
|
-
return {
|
|
38
|
-
type: ActionTypes.SET_CELL_METADATA,
|
|
39
|
-
payload: {
|
|
40
|
-
address: this.address,
|
|
41
|
-
metadata: this.newMetadata
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
class SetSheetMetadataCommand {
|
|
48
|
-
workbookManager;
|
|
49
|
-
opts;
|
|
50
|
-
newMetadata;
|
|
51
|
-
requiresReevaluation = false;
|
|
52
|
-
previousMetadata;
|
|
53
|
-
constructor(workbookManager, opts, newMetadata) {
|
|
54
|
-
this.workbookManager = workbookManager;
|
|
55
|
-
this.opts = opts;
|
|
56
|
-
this.newMetadata = newMetadata;
|
|
57
|
-
}
|
|
58
|
-
execute() {
|
|
59
|
-
const sheet = this.workbookManager.getSheet(this.opts);
|
|
60
|
-
if (sheet) {
|
|
61
|
-
this.previousMetadata = sheet.sheetMetadata;
|
|
62
|
-
}
|
|
63
|
-
this.workbookManager.setSheetMetadata(this.opts, this.newMetadata);
|
|
64
|
-
}
|
|
65
|
-
undo() {
|
|
66
|
-
if (this.previousMetadata !== undefined) {
|
|
67
|
-
this.workbookManager.setSheetMetadata(this.opts, this.previousMetadata);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
toAction() {
|
|
71
|
-
return {
|
|
72
|
-
type: ActionTypes.SET_SHEET_METADATA,
|
|
73
|
-
payload: {
|
|
74
|
-
opts: this.opts,
|
|
75
|
-
metadata: this.newMetadata
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
class SetWorkbookMetadataCommand {
|
|
82
|
-
workbookManager;
|
|
83
|
-
workbookName;
|
|
84
|
-
newMetadata;
|
|
85
|
-
requiresReevaluation = false;
|
|
86
|
-
previousMetadata;
|
|
87
|
-
constructor(workbookManager, workbookName, newMetadata) {
|
|
88
|
-
this.workbookManager = workbookManager;
|
|
89
|
-
this.workbookName = workbookName;
|
|
90
|
-
this.newMetadata = newMetadata;
|
|
91
|
-
}
|
|
92
|
-
execute() {
|
|
93
|
-
const workbook = this.workbookManager.getWorkbooks().get(this.workbookName);
|
|
94
|
-
if (workbook) {
|
|
95
|
-
this.previousMetadata = workbook.workbookMetadata;
|
|
96
|
-
}
|
|
97
|
-
this.workbookManager.setWorkbookMetadata(this.workbookName, this.newMetadata);
|
|
98
|
-
}
|
|
99
|
-
undo() {
|
|
100
|
-
if (this.previousMetadata !== undefined) {
|
|
101
|
-
this.workbookManager.setWorkbookMetadata(this.workbookName, this.previousMetadata);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
toAction() {
|
|
105
|
-
return {
|
|
106
|
-
type: ActionTypes.SET_WORKBOOK_METADATA,
|
|
107
|
-
payload: {
|
|
108
|
-
workbookName: this.workbookName,
|
|
109
|
-
metadata: this.newMetadata
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
export {
|
|
115
|
-
SetWorkbookMetadataCommand,
|
|
116
|
-
SetSheetMetadataCommand,
|
|
117
|
-
SetCellMetadataCommand
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
//# debugId=ED39C4E46B26E88464756E2164756E21
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/core/commands/metadata-commands.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"/**\n * Metadata Commands - Commands that modify cell/sheet/workbook metadata\n *\n * These commands do NOT require re-evaluation after execution.\n * They only affect metadata, not cell values or formulas.\n */\n\nimport type { WorkbookManager } from \"../managers/workbook-manager.mjs\";\nimport type { CellAddress } from \"../types.mjs\";\nimport type { EngineCommand, EngineAction } from \"./types.mjs\";\nimport { ActionTypes } from \"./types.mjs\";\nimport { getCellReference } from \"../utils.mjs\";\n\n/**\n * Command to set cell metadata.\n */\nexport class SetCellMetadataCommand<TMetadata = unknown> implements EngineCommand {\n readonly requiresReevaluation = false;\n private previousMetadata: TMetadata | undefined;\n private hadPreviousMetadata = false;\n\n constructor(\n private workbookManager: WorkbookManager,\n private address: CellAddress,\n private newMetadata: TMetadata | undefined\n ) {}\n\n execute(): void {\n // Capture previous metadata\n const sheet = this.workbookManager.getSheet({\n workbookName: this.address.workbookName,\n sheetName: this.address.sheetName,\n });\n\n if (sheet) {\n const key = getCellReference(this.address);\n this.hadPreviousMetadata = sheet.metadata.has(key);\n this.previousMetadata = sheet.metadata.get(key) as TMetadata | undefined;\n }\n\n this.workbookManager.setCellMetadata(this.address, this.newMetadata);\n }\n\n undo(): void {\n if (this.hadPreviousMetadata) {\n this.workbookManager.setCellMetadata(this.address, this.previousMetadata);\n } else {\n this.workbookManager.setCellMetadata(this.address, undefined);\n }\n }\n\n toAction(): EngineAction {\n return {\n type: ActionTypes.SET_CELL_METADATA,\n payload: {\n address: this.address,\n metadata: this.newMetadata,\n },\n };\n }\n}\n\n/**\n * Command to set sheet metadata.\n */\nexport class SetSheetMetadataCommand<TMetadata = unknown> implements EngineCommand {\n readonly requiresReevaluation = false;\n private previousMetadata: TMetadata | undefined;\n\n constructor(\n private workbookManager: WorkbookManager,\n private opts: { workbookName: string; sheetName: string },\n private newMetadata: TMetadata\n ) {}\n\n execute(): void {\n // Capture previous metadata\n const sheet = this.workbookManager.getSheet(this.opts);\n if (sheet) {\n this.previousMetadata = sheet.sheetMetadata as TMetadata | undefined;\n }\n\n this.workbookManager.setSheetMetadata(this.opts, this.newMetadata);\n }\n\n undo(): void {\n if (this.previousMetadata !== undefined) {\n this.workbookManager.setSheetMetadata(this.opts, this.previousMetadata);\n }\n }\n\n toAction(): EngineAction {\n return {\n type: ActionTypes.SET_SHEET_METADATA,\n payload: {\n opts: this.opts,\n metadata: this.newMetadata,\n },\n };\n }\n}\n\n/**\n * Command to set workbook metadata.\n */\nexport class SetWorkbookMetadataCommand<TMetadata = unknown> implements EngineCommand {\n readonly requiresReevaluation = false;\n private previousMetadata: TMetadata | undefined;\n\n constructor(\n private workbookManager: WorkbookManager,\n private workbookName: string,\n private newMetadata: TMetadata\n ) {}\n\n execute(): void {\n // Capture previous metadata\n const workbook = this.workbookManager.getWorkbooks().get(this.workbookName);\n if (workbook) {\n this.previousMetadata = workbook.workbookMetadata as TMetadata | undefined;\n }\n\n this.workbookManager.setWorkbookMetadata(this.workbookName, this.newMetadata);\n }\n\n undo(): void {\n if (this.previousMetadata !== undefined) {\n this.workbookManager.setWorkbookMetadata(this.workbookName, this.previousMetadata);\n }\n }\n\n toAction(): EngineAction {\n return {\n type: ActionTypes.SET_WORKBOOK_METADATA,\n payload: {\n workbookName: this.workbookName,\n metadata: this.newMetadata,\n },\n };\n }\n}\n\n"
|
|
6
|
-
],
|
|
7
|
-
"mappings": ";AAUA;AACA;AAAA;AAKO,MAAM,uBAAqE;AAAA,EAMtE;AAAA,EACA;AAAA,EACA;AAAA,EAPD,uBAAuB;AAAA,EACxB;AAAA,EACA,sBAAsB;AAAA,EAE9B,WAAW,CACD,iBACA,SACA,aACR;AAAA,IAHQ;AAAA,IACA;AAAA,IACA;AAAA;AAAA,EAGV,OAAO,GAAS;AAAA,IAEd,MAAM,QAAQ,KAAK,gBAAgB,SAAS;AAAA,MAC1C,cAAc,KAAK,QAAQ;AAAA,MAC3B,WAAW,KAAK,QAAQ;AAAA,IAC1B,CAAC;AAAA,IAED,IAAI,OAAO;AAAA,MACT,MAAM,MAAM,iBAAiB,KAAK,OAAO;AAAA,MACzC,KAAK,sBAAsB,MAAM,SAAS,IAAI,GAAG;AAAA,MACjD,KAAK,mBAAmB,MAA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ND,uBAAuB;AAAA,EACxB;AAAA,EAER,WAAW,CACD,iBACA,cACA,aACR;AAAA,IAHQ;AAAA,IACA;AAAA,IACA;AAAA;AAAA,EAGV,OAAO,GAAS;AAAA,IAEd,MAAM,WAAW,KAAK,gBAAgB,aAAa,EAAE,IAAI,KAAK,YAAY;AAAA,IAC1E,IAAI,UAAU;AAAA,MACZ,KAAK,mBAAmB,SAAS;AAAA,IACnC;AAAA,IAEA,KAAK,gBAAgB,oBAAoB,KAAK,cAAc,KAAK,WAAW;AAAA;AAAA,EAG9E,IAAI,GAAS;AAAA,IACX,IAAI,KAAK,qBAAqB,WAAW;AAAA,MACvC,KAAK,gBAAgB,oBAAoB,KAAK,cAAc,KAAK,gBAAgB;AAAA,IACnF;AAAA;AAAA,EAGF,QAAQ,GAAiB;AAAA,IACvB,OAAO;AAAA,MACL,MAAM,YAAY;AAAA,MAClB,SAAS;AAAA,QACP,cAAc,KAAK;AAAA,QACnB,UAAU,KAAK;AAAA,MACjB;AAAA,IACF;AAAA;AAEJ;",
|
|
8
|
-
"debugId": "ED39C4E46B26E88464756E2164756E21",
|
|
9
|
-
"names": []
|
|
10
|
-
}
|
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
// src/core/commands/named-expression-commands.ts
|
|
2
|
-
import { ActionTypes, emptyMutationInvalidation } from "./types.mjs";
|
|
3
|
-
import { getNamedExpressionResourceKey } from "../resource-keys.mjs";
|
|
4
|
-
function optsToScope(opts) {
|
|
5
|
-
if (opts.sheetName && opts.workbookName) {
|
|
6
|
-
return {
|
|
7
|
-
name: opts.expressionName,
|
|
8
|
-
scope: {
|
|
9
|
-
type: "sheet",
|
|
10
|
-
workbookName: opts.workbookName,
|
|
11
|
-
sheetName: opts.sheetName
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
} else if (opts.workbookName) {
|
|
15
|
-
return {
|
|
16
|
-
name: opts.expressionName,
|
|
17
|
-
scope: { type: "workbook", workbookName: opts.workbookName }
|
|
18
|
-
};
|
|
19
|
-
} else {
|
|
20
|
-
return {
|
|
21
|
-
name: opts.expressionName,
|
|
22
|
-
scope: { type: "global" }
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function getNamedExpressionScopeResourceKeys(expressions, opts) {
|
|
27
|
-
return Array.from(new Set(Array.from(expressions, (expressionName) => getNamedExpressionResourceKey({
|
|
28
|
-
expressionName,
|
|
29
|
-
workbookName: opts.workbookName,
|
|
30
|
-
sheetName: opts.sheetName
|
|
31
|
-
}))));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
class AddNamedExpressionCommand {
|
|
35
|
-
deps;
|
|
36
|
-
opts;
|
|
37
|
-
requiresReevaluation = true;
|
|
38
|
-
executeFootprint = emptyMutationInvalidation();
|
|
39
|
-
undoFootprint = emptyMutationInvalidation();
|
|
40
|
-
constructor(deps, opts) {
|
|
41
|
-
this.deps = deps;
|
|
42
|
-
this.opts = opts;
|
|
43
|
-
}
|
|
44
|
-
execute() {
|
|
45
|
-
this.deps.namedExpressionManager.addNamedExpression(this.opts);
|
|
46
|
-
const resourceKey = getNamedExpressionResourceKey(this.opts);
|
|
47
|
-
this.executeFootprint = {
|
|
48
|
-
touchedCells: [],
|
|
49
|
-
resourceKeys: [resourceKey]
|
|
50
|
-
};
|
|
51
|
-
this.undoFootprint = {
|
|
52
|
-
touchedCells: [],
|
|
53
|
-
resourceKeys: [resourceKey]
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
undo() {
|
|
57
|
-
this.deps.namedExpressionManager.removeNamedExpression({
|
|
58
|
-
expressionName: this.opts.expressionName,
|
|
59
|
-
sheetName: this.opts.sheetName,
|
|
60
|
-
workbookName: this.opts.workbookName
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
getInvalidationFootprint(phase) {
|
|
64
|
-
return phase === "execute" ? this.executeFootprint : this.undoFootprint;
|
|
65
|
-
}
|
|
66
|
-
toAction() {
|
|
67
|
-
return {
|
|
68
|
-
type: ActionTypes.ADD_NAMED_EXPRESSION,
|
|
69
|
-
payload: this.opts
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
class RemoveNamedExpressionCommand {
|
|
75
|
-
deps;
|
|
76
|
-
opts;
|
|
77
|
-
requiresReevaluation = true;
|
|
78
|
-
removedExpression;
|
|
79
|
-
executeFootprint = emptyMutationInvalidation();
|
|
80
|
-
undoFootprint = emptyMutationInvalidation();
|
|
81
|
-
constructor(deps, opts) {
|
|
82
|
-
this.deps = deps;
|
|
83
|
-
this.opts = opts;
|
|
84
|
-
}
|
|
85
|
-
execute() {
|
|
86
|
-
this.removedExpression = this.deps.namedExpressionManager.getNamedExpression(optsToScope(this.opts));
|
|
87
|
-
this.deps.namedExpressionManager.removeNamedExpression(this.opts);
|
|
88
|
-
const resourceKey = getNamedExpressionResourceKey(this.opts);
|
|
89
|
-
this.executeFootprint = {
|
|
90
|
-
touchedCells: [],
|
|
91
|
-
resourceKeys: [resourceKey]
|
|
92
|
-
};
|
|
93
|
-
this.undoFootprint = {
|
|
94
|
-
touchedCells: [],
|
|
95
|
-
resourceKeys: [resourceKey]
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
undo() {
|
|
99
|
-
if (!this.removedExpression)
|
|
100
|
-
return;
|
|
101
|
-
this.deps.namedExpressionManager.addNamedExpression({
|
|
102
|
-
expressionName: this.removedExpression.name,
|
|
103
|
-
expression: this.removedExpression.expression,
|
|
104
|
-
sheetName: this.opts.sheetName,
|
|
105
|
-
workbookName: this.opts.workbookName
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
getInvalidationFootprint(phase) {
|
|
109
|
-
return phase === "execute" ? this.executeFootprint : this.undoFootprint;
|
|
110
|
-
}
|
|
111
|
-
toAction() {
|
|
112
|
-
return {
|
|
113
|
-
type: ActionTypes.REMOVE_NAMED_EXPRESSION,
|
|
114
|
-
payload: this.opts
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
class UpdateNamedExpressionCommand {
|
|
120
|
-
deps;
|
|
121
|
-
opts;
|
|
122
|
-
requiresReevaluation = true;
|
|
123
|
-
previousExpression;
|
|
124
|
-
executeFootprint = emptyMutationInvalidation();
|
|
125
|
-
undoFootprint = emptyMutationInvalidation();
|
|
126
|
-
constructor(deps, opts) {
|
|
127
|
-
this.deps = deps;
|
|
128
|
-
this.opts = opts;
|
|
129
|
-
}
|
|
130
|
-
execute() {
|
|
131
|
-
const existing = this.deps.namedExpressionManager.getNamedExpression(optsToScope(this.opts));
|
|
132
|
-
this.previousExpression = existing?.expression;
|
|
133
|
-
this.deps.namedExpressionManager.updateNamedExpression(this.opts);
|
|
134
|
-
const resourceKey = getNamedExpressionResourceKey(this.opts);
|
|
135
|
-
this.executeFootprint = {
|
|
136
|
-
touchedCells: [],
|
|
137
|
-
resourceKeys: [resourceKey]
|
|
138
|
-
};
|
|
139
|
-
this.undoFootprint = {
|
|
140
|
-
touchedCells: [],
|
|
141
|
-
resourceKeys: [resourceKey]
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
undo() {
|
|
145
|
-
if (this.previousExpression === undefined)
|
|
146
|
-
return;
|
|
147
|
-
this.deps.namedExpressionManager.updateNamedExpression({
|
|
148
|
-
expressionName: this.opts.expressionName,
|
|
149
|
-
expression: this.previousExpression,
|
|
150
|
-
sheetName: this.opts.sheetName,
|
|
151
|
-
workbookName: this.opts.workbookName
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
getInvalidationFootprint(phase) {
|
|
155
|
-
return phase === "execute" ? this.executeFootprint : this.undoFootprint;
|
|
156
|
-
}
|
|
157
|
-
toAction() {
|
|
158
|
-
return {
|
|
159
|
-
type: ActionTypes.UPDATE_NAMED_EXPRESSION,
|
|
160
|
-
payload: this.opts
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
class RenameNamedExpressionCommand {
|
|
166
|
-
deps;
|
|
167
|
-
opts;
|
|
168
|
-
requiresReevaluation = true;
|
|
169
|
-
executeFootprint = emptyMutationInvalidation();
|
|
170
|
-
undoFootprint = emptyMutationInvalidation();
|
|
171
|
-
constructor(deps, opts) {
|
|
172
|
-
this.deps = deps;
|
|
173
|
-
this.opts = opts;
|
|
174
|
-
}
|
|
175
|
-
execute() {
|
|
176
|
-
this.deps.namedExpressionManager.renameNamedExpression(this.opts);
|
|
177
|
-
const changedCells = this.deps.workbookManager.updateAllFormulas((formula) => this.deps.renameNamedExpressionInFormula(formula, this.opts.expressionName, this.opts.newName));
|
|
178
|
-
const changedNamedExpressions = this.deps.namedExpressionManager.updateAllNamedExpressions((formula) => this.deps.renameNamedExpressionInFormula(formula, this.opts.expressionName, this.opts.newName));
|
|
179
|
-
this.executeFootprint = {
|
|
180
|
-
touchedCells: changedCells.map((address) => ({
|
|
181
|
-
address,
|
|
182
|
-
beforeKind: "formula",
|
|
183
|
-
afterKind: "formula"
|
|
184
|
-
})),
|
|
185
|
-
resourceKeys: [
|
|
186
|
-
getNamedExpressionResourceKey({
|
|
187
|
-
expressionName: this.opts.expressionName,
|
|
188
|
-
workbookName: this.opts.workbookName,
|
|
189
|
-
sheetName: this.opts.sheetName
|
|
190
|
-
}),
|
|
191
|
-
getNamedExpressionResourceKey({
|
|
192
|
-
expressionName: this.opts.newName,
|
|
193
|
-
workbookName: this.opts.workbookName,
|
|
194
|
-
sheetName: this.opts.sheetName
|
|
195
|
-
}),
|
|
196
|
-
...changedNamedExpressions
|
|
197
|
-
]
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
undo() {
|
|
201
|
-
this.deps.namedExpressionManager.renameNamedExpression({
|
|
202
|
-
expressionName: this.opts.newName,
|
|
203
|
-
sheetName: this.opts.sheetName,
|
|
204
|
-
workbookName: this.opts.workbookName,
|
|
205
|
-
newName: this.opts.expressionName
|
|
206
|
-
});
|
|
207
|
-
const changedCells = this.deps.workbookManager.updateAllFormulas((formula) => this.deps.renameNamedExpressionInFormula(formula, this.opts.newName, this.opts.expressionName));
|
|
208
|
-
const changedNamedExpressions = this.deps.namedExpressionManager.updateAllNamedExpressions((formula) => this.deps.renameNamedExpressionInFormula(formula, this.opts.newName, this.opts.expressionName));
|
|
209
|
-
this.undoFootprint = {
|
|
210
|
-
touchedCells: changedCells.map((address) => ({
|
|
211
|
-
address,
|
|
212
|
-
beforeKind: "formula",
|
|
213
|
-
afterKind: "formula"
|
|
214
|
-
})),
|
|
215
|
-
resourceKeys: [
|
|
216
|
-
getNamedExpressionResourceKey({
|
|
217
|
-
expressionName: this.opts.expressionName,
|
|
218
|
-
workbookName: this.opts.workbookName,
|
|
219
|
-
sheetName: this.opts.sheetName
|
|
220
|
-
}),
|
|
221
|
-
getNamedExpressionResourceKey({
|
|
222
|
-
expressionName: this.opts.newName,
|
|
223
|
-
workbookName: this.opts.workbookName,
|
|
224
|
-
sheetName: this.opts.sheetName
|
|
225
|
-
}),
|
|
226
|
-
...changedNamedExpressions
|
|
227
|
-
]
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
getInvalidationFootprint(phase) {
|
|
231
|
-
return phase === "execute" ? this.executeFootprint : this.undoFootprint;
|
|
232
|
-
}
|
|
233
|
-
toAction() {
|
|
234
|
-
return {
|
|
235
|
-
type: ActionTypes.RENAME_NAMED_EXPRESSION,
|
|
236
|
-
payload: this.opts
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
class SetNamedExpressionsCommand {
|
|
242
|
-
deps;
|
|
243
|
-
opts;
|
|
244
|
-
requiresReevaluation = true;
|
|
245
|
-
previousExpressions;
|
|
246
|
-
executeFootprint = emptyMutationInvalidation();
|
|
247
|
-
undoFootprint = emptyMutationInvalidation();
|
|
248
|
-
constructor(deps, opts) {
|
|
249
|
-
this.deps = deps;
|
|
250
|
-
this.opts = opts;
|
|
251
|
-
}
|
|
252
|
-
execute() {
|
|
253
|
-
const allExpressions = this.deps.namedExpressionManager.getNamedExpressions();
|
|
254
|
-
if (this.opts.type === "global") {
|
|
255
|
-
this.previousExpressions = new Map(allExpressions.globalExpressions);
|
|
256
|
-
} else if (this.opts.type === "workbook") {
|
|
257
|
-
this.previousExpressions = new Map(allExpressions.workbookExpressions.get(this.opts.workbookName) || []);
|
|
258
|
-
} else if (this.opts.type === "sheet") {
|
|
259
|
-
const sheetExpressions = allExpressions.sheetExpressions.get(this.opts.workbookName)?.get(this.opts.sheetName);
|
|
260
|
-
this.previousExpressions = new Map(sheetExpressions || []);
|
|
261
|
-
}
|
|
262
|
-
this.deps.namedExpressionManager.setNamedExpressions(this.opts);
|
|
263
|
-
const scope = this.opts.type === "global" ? {} : this.opts.type === "workbook" ? { workbookName: this.opts.workbookName } : {
|
|
264
|
-
workbookName: this.opts.workbookName,
|
|
265
|
-
sheetName: this.opts.sheetName
|
|
266
|
-
};
|
|
267
|
-
this.executeFootprint = {
|
|
268
|
-
touchedCells: [],
|
|
269
|
-
resourceKeys: [
|
|
270
|
-
...getNamedExpressionScopeResourceKeys(this.previousExpressions?.keys() ?? [], scope),
|
|
271
|
-
...getNamedExpressionScopeResourceKeys(this.opts.expressions.keys(), scope)
|
|
272
|
-
]
|
|
273
|
-
};
|
|
274
|
-
this.undoFootprint = {
|
|
275
|
-
touchedCells: [],
|
|
276
|
-
resourceKeys: this.executeFootprint.resourceKeys
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
undo() {
|
|
280
|
-
if (!this.previousExpressions)
|
|
281
|
-
return;
|
|
282
|
-
if (this.opts.type === "global") {
|
|
283
|
-
this.deps.namedExpressionManager.setNamedExpressions({
|
|
284
|
-
type: "global",
|
|
285
|
-
expressions: this.previousExpressions
|
|
286
|
-
});
|
|
287
|
-
} else if (this.opts.type === "workbook") {
|
|
288
|
-
this.deps.namedExpressionManager.setNamedExpressions({
|
|
289
|
-
type: "workbook",
|
|
290
|
-
workbookName: this.opts.workbookName,
|
|
291
|
-
expressions: this.previousExpressions
|
|
292
|
-
});
|
|
293
|
-
} else if (this.opts.type === "sheet") {
|
|
294
|
-
this.deps.namedExpressionManager.setNamedExpressions({
|
|
295
|
-
type: "sheet",
|
|
296
|
-
workbookName: this.opts.workbookName,
|
|
297
|
-
sheetName: this.opts.sheetName,
|
|
298
|
-
expressions: this.previousExpressions
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
getInvalidationFootprint(phase) {
|
|
303
|
-
return phase === "execute" ? this.executeFootprint : this.undoFootprint;
|
|
304
|
-
}
|
|
305
|
-
toAction() {
|
|
306
|
-
return {
|
|
307
|
-
type: ActionTypes.SET_NAMED_EXPRESSIONS,
|
|
308
|
-
payload: {
|
|
309
|
-
...this.opts,
|
|
310
|
-
expressions: Array.from(this.opts.expressions.entries())
|
|
311
|
-
}
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
export {
|
|
316
|
-
UpdateNamedExpressionCommand,
|
|
317
|
-
SetNamedExpressionsCommand,
|
|
318
|
-
RenameNamedExpressionCommand,
|
|
319
|
-
RemoveNamedExpressionCommand,
|
|
320
|
-
AddNamedExpressionCommand
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
//# debugId=F6D9AAFD4062ABD164756E2164756E21
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/core/commands/named-expression-commands.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"/**\n * Named Expression Commands - Commands that modify named expressions\n *\n * These commands all require re-evaluation after execution.\n */\n\nimport type { NamedExpressionManager } from \"../managers/named-expression-manager.mjs\";\nimport type { WorkbookManager } from \"../managers/workbook-manager.mjs\";\nimport type { NamedExpression } from \"../types.mjs\";\nimport type {\n EngineCommand,\n EngineAction,\n MutationInvalidation,\n} from \"./types.mjs\";\nimport { ActionTypes, emptyMutationInvalidation } from \"./types.mjs\";\nimport { getNamedExpressionResourceKey } from \"../resource-keys.mjs\";\n\n/**\n * Dependencies needed for named expression commands.\n */\nexport interface NamedExpressionCommandDeps {\n namedExpressionManager: NamedExpressionManager;\n workbookManager: WorkbookManager;\n renameNamedExpressionInFormula: (\n formula: string,\n oldName: string,\n newName: string\n ) => string;\n}\n\n/**\n * Helper to convert opts to getNamedExpression format\n */\nfunction optsToScope(opts: {\n expressionName: string;\n sheetName?: string;\n workbookName?: string;\n}): {\n name: string;\n scope:\n | { type: \"global\" }\n | { type: \"workbook\"; workbookName: string }\n | { type: \"sheet\"; workbookName: string; sheetName: string };\n} {\n if (opts.sheetName && opts.workbookName) {\n return {\n name: opts.expressionName,\n scope: {\n type: \"sheet\",\n workbookName: opts.workbookName,\n sheetName: opts.sheetName,\n },\n };\n } else if (opts.workbookName) {\n return {\n name: opts.expressionName,\n scope: { type: \"workbook\", workbookName: opts.workbookName },\n };\n } else {\n return {\n name: opts.expressionName,\n scope: { type: \"global\" },\n };\n }\n}\n\nfunction getNamedExpressionScopeResourceKeys(\n expressions: Iterable<string>,\n opts: {\n workbookName?: string;\n sheetName?: string;\n }\n): string[] {\n return Array.from(\n new Set(\n Array.from(expressions, (expressionName) =>\n getNamedExpressionResourceKey({\n expressionName,\n workbookName: opts.workbookName,\n sheetName: opts.sheetName,\n })\n )\n )\n );\n}\n\n/**\n * Command to add a named expression.\n */\nexport class AddNamedExpressionCommand implements EngineCommand {\n readonly requiresReevaluation = true;\n private executeFootprint = emptyMutationInvalidation();\n private undoFootprint = emptyMutationInvalidation();\n\n constructor(\n private deps: NamedExpressionCommandDeps,\n private opts: {\n expression: string;\n expressionName: string;\n sheetName?: string;\n workbookName?: string;\n }\n ) {}\n\n execute(): void {\n this.deps.namedExpressionManager.addNamedExpression(this.opts);\n const resourceKey = getNamedExpressionResourceKey(this.opts);\n this.executeFootprint = {\n touchedCells: [],\n resourceKeys: [resourceKey],\n };\n this.undoFootprint = {\n touchedCells: [],\n resourceKeys: [resourceKey],\n };\n }\n\n undo(): void {\n this.deps.namedExpressionManager.removeNamedExpression({\n expressionName: this.opts.expressionName,\n sheetName: this.opts.sheetName,\n workbookName: this.opts.workbookName,\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_NAMED_EXPRESSION,\n payload: this.opts,\n };\n }\n}\n\n/**\n * Command to remove a named expression.\n */\nexport class RemoveNamedExpressionCommand implements EngineCommand {\n readonly requiresReevaluation = true;\n private removedExpression: NamedExpression | undefined;\n private executeFootprint = emptyMutationInvalidation();\n private undoFootprint = emptyMutationInvalidation();\n\n constructor(\n private deps: NamedExpressionCommandDeps,\n private opts: {\n expressionName: string;\n sheetName?: string;\n workbookName?: string;\n }\n ) {}\n\n execute(): void {\n // Capture expression before removal\n this.removedExpression = this.deps.namedExpressionManager.getNamedExpression(\n optsToScope(this.opts)\n );\n\n this.deps.namedExpressionManager.removeNamedExpression(this.opts);\n const resourceKey = getNamedExpressionResourceKey(this.opts);\n this.executeFootprint = {\n touchedCells: [],\n resourceKeys: [resourceKey],\n };\n this.undoFootprint = {\n touchedCells: [],\n resourceKeys: [resourceKey],\n };\n }\n\n undo(): void {\n if (!this.removedExpression) return;\n\n this.deps.namedExpressionManager.addNamedExpression({\n expressionName: this.removedExpression.name,\n expression: this.removedExpression.expression,\n sheetName: this.opts.sheetName,\n workbookName: this.opts.workbookName,\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_NAMED_EXPRESSION,\n payload: this.opts,\n };\n }\n}\n\n/**\n * Command to update a named expression.\n */\nexport class UpdateNamedExpressionCommand implements EngineCommand {\n readonly requiresReevaluation = true;\n private previousExpression: string | undefined;\n private executeFootprint = emptyMutationInvalidation();\n private undoFootprint = emptyMutationInvalidation();\n\n constructor(\n private deps: NamedExpressionCommandDeps,\n private opts: {\n expression: string;\n expressionName: string;\n sheetName?: string;\n workbookName?: string;\n }\n ) {}\n\n execute(): void {\n // Capture previous expression\n const existing = this.deps.namedExpressionManager.getNamedExpression(\n optsToScope(this.opts)\n );\n this.previousExpression = existing?.expression;\n\n this.deps.namedExpressionManager.updateNamedExpression(this.opts);\n const resourceKey = getNamedExpressionResourceKey(this.opts);\n this.executeFootprint = {\n touchedCells: [],\n resourceKeys: [resourceKey],\n };\n this.undoFootprint = {\n touchedCells: [],\n resourceKeys: [resourceKey],\n };\n }\n\n undo(): void {\n if (this.previousExpression === undefined) return;\n\n this.deps.namedExpressionManager.updateNamedExpression({\n expressionName: this.opts.expressionName,\n expression: this.previousExpression,\n sheetName: this.opts.sheetName,\n workbookName: this.opts.workbookName,\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_NAMED_EXPRESSION,\n payload: this.opts,\n };\n }\n}\n\n/**\n * Command to rename a named expression.\n */\nexport class RenameNamedExpressionCommand implements EngineCommand {\n readonly requiresReevaluation = true;\n private executeFootprint = emptyMutationInvalidation();\n private undoFootprint = emptyMutationInvalidation();\n\n constructor(\n private deps: NamedExpressionCommandDeps,\n private opts: {\n expressionName: string;\n sheetName?: string;\n workbookName?: string;\n newName: string;\n }\n ) {}\n\n execute(): void {\n this.deps.namedExpressionManager.renameNamedExpression(this.opts);\n\n // Update formulas in sheet cells\n const changedCells = this.deps.workbookManager.updateAllFormulas((formula) =>\n this.deps.renameNamedExpressionInFormula(\n formula,\n this.opts.expressionName,\n this.opts.newName\n )\n );\n\n // Update named expressions\n const changedNamedExpressions =\n this.deps.namedExpressionManager.updateAllNamedExpressions((formula) =>\n this.deps.renameNamedExpressionInFormula(\n formula,\n this.opts.expressionName,\n this.opts.newName\n )\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 getNamedExpressionResourceKey({\n expressionName: this.opts.expressionName,\n workbookName: this.opts.workbookName,\n sheetName: this.opts.sheetName,\n }),\n getNamedExpressionResourceKey({\n expressionName: this.opts.newName,\n workbookName: this.opts.workbookName,\n sheetName: this.opts.sheetName,\n }),\n ...changedNamedExpressions,\n ],\n };\n }\n\n undo(): void {\n // Rename back\n this.deps.namedExpressionManager.renameNamedExpression({\n expressionName: this.opts.newName,\n sheetName: this.opts.sheetName,\n workbookName: this.opts.workbookName,\n newName: this.opts.expressionName,\n });\n\n // Update formulas back\n const changedCells = this.deps.workbookManager.updateAllFormulas((formula) =>\n this.deps.renameNamedExpressionInFormula(\n formula,\n this.opts.newName,\n this.opts.expressionName\n )\n );\n\n // Update named expressions back\n const changedNamedExpressions =\n this.deps.namedExpressionManager.updateAllNamedExpressions((formula) =>\n this.deps.renameNamedExpressionInFormula(\n formula,\n this.opts.newName,\n this.opts.expressionName\n )\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 getNamedExpressionResourceKey({\n expressionName: this.opts.expressionName,\n workbookName: this.opts.workbookName,\n sheetName: this.opts.sheetName,\n }),\n getNamedExpressionResourceKey({\n expressionName: this.opts.newName,\n workbookName: this.opts.workbookName,\n sheetName: this.opts.sheetName,\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_NAMED_EXPRESSION,\n payload: this.opts,\n };\n }\n}\n\n/**\n * Options for setNamedExpressions command.\n */\ntype SetNamedExpressionsOpts = (\n | { type: \"global\" }\n | { type: \"sheet\"; sheetName: string; workbookName: string }\n | { type: \"workbook\"; workbookName: string }\n) & {\n expressions: Map<string, NamedExpression>;\n};\n\n/**\n * Command to set named expressions (replace all at a scope).\n */\nexport class SetNamedExpressionsCommand implements EngineCommand {\n readonly requiresReevaluation = true;\n private previousExpressions: Map<string, NamedExpression> | undefined;\n private executeFootprint = emptyMutationInvalidation();\n private undoFootprint = emptyMutationInvalidation();\n\n constructor(\n private deps: NamedExpressionCommandDeps,\n private opts: SetNamedExpressionsOpts\n ) {}\n\n execute(): void {\n // Capture previous expressions at this scope\n const allExpressions = this.deps.namedExpressionManager.getNamedExpressions();\n\n if (this.opts.type === \"global\") {\n this.previousExpressions = new Map(allExpressions.globalExpressions);\n } else if (this.opts.type === \"workbook\") {\n this.previousExpressions = new Map(\n allExpressions.workbookExpressions.get(this.opts.workbookName) || []\n );\n } else if (this.opts.type === \"sheet\") {\n const sheetExpressions = allExpressions.sheetExpressions\n .get(this.opts.workbookName)\n ?.get(this.opts.sheetName);\n this.previousExpressions = new Map(sheetExpressions || []);\n }\n\n this.deps.namedExpressionManager.setNamedExpressions(this.opts);\n const scope =\n this.opts.type === \"global\"\n ? {}\n : this.opts.type === \"workbook\"\n ? { workbookName: this.opts.workbookName }\n : {\n workbookName: this.opts.workbookName,\n sheetName: this.opts.sheetName,\n };\n this.executeFootprint = {\n touchedCells: [],\n resourceKeys: [\n ...getNamedExpressionScopeResourceKeys(\n this.previousExpressions?.keys() ?? [],\n scope\n ),\n ...getNamedExpressionScopeResourceKeys(this.opts.expressions.keys(), scope),\n ],\n };\n this.undoFootprint = {\n touchedCells: [],\n resourceKeys: this.executeFootprint.resourceKeys,\n };\n }\n\n undo(): void {\n if (!this.previousExpressions) return;\n\n // Restore previous expressions\n if (this.opts.type === \"global\") {\n this.deps.namedExpressionManager.setNamedExpressions({\n type: \"global\",\n expressions: this.previousExpressions,\n });\n } else if (this.opts.type === \"workbook\") {\n this.deps.namedExpressionManager.setNamedExpressions({\n type: \"workbook\",\n workbookName: this.opts.workbookName,\n expressions: this.previousExpressions,\n });\n } else if (this.opts.type === \"sheet\") {\n this.deps.namedExpressionManager.setNamedExpressions({\n type: \"sheet\",\n workbookName: this.opts.workbookName,\n sheetName: this.opts.sheetName,\n expressions: this.previousExpressions,\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.SET_NAMED_EXPRESSIONS,\n payload: {\n ...this.opts,\n expressions: Array.from(this.opts.expressions.entries()),\n },\n };\n }\n}\n"
|
|
6
|
-
],
|
|
7
|
-
"mappings": ";AAcA;AACA;AAkBA,SAAS,WAAW,CAAC,MAUnB;AAAA,EACA,IAAI,KAAK,aAAa,KAAK,cAAc;AAAA,IACvC,OAAO;AAAA,MACL,MAAM,KAAK;AAAA,MACX,OAAO;AAAA,QACL,MAAM;AAAA,QACN,cAAc,KAAK;AAAA,QACnB,WAAW,KAAK;AAAA,MAClB;AAAA,IACF;AAAA,EACF,EAAO,SAAI,KAAK,cAAc;AAAA,IAC5B,OAAO;AAAA,MACL,MAAM,KAAK;AAAA,MACX,OAAO,EAAE,MAAM,YAAY,cAAc,KAAK,aAAa;AAAA,IAC7D;AAAA,EACF,EAAO;AAAA,IACL,OAAO;AAAA,MACL,MAAM,KAAK;AAAA,MACX,OAAO,EAAE,MAAM,SAAS;AAAA,IAC1B;AAAA;AAAA;AAIJ,SAAS,mCAAmC,CAC1C,aACA,MAIU;AAAA,EACV,OAAO,MAAM,KACX,IAAI,IACF,MAAM,KAAK,aAAa,CAAC,mBACvB,8BAA8B;AAAA,IAC5B;AAAA,IACA,cAAc,KAAK;AAAA,IACnB,WAAW,KAAK;AAAA,EAClB,CAAC,CACH,CACF,CACF;AAAA;AAAA;AAMK,MAAM,0BAAmD;AAAA,EAMpD;AAAA,EACA;AAAA,EAND,uBAAuB;AAAA,EACxB,mBAAmB,0BAA0B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