@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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Main FormulaEngine class
|
|
3
3
|
* Core API implementation for spreadsheet calculations
|
|
4
4
|
*/
|
|
5
|
-
import { type CellAddress, type CellStyle, type ConditionalStyle, type CopyCellsOptions, type DirectCellStyle, type
|
|
5
|
+
import { type CellAddress, type CellStyle, type ConditionalStyle, type CopyCellsOptions, type DirectCellStyle, type NamedExpression, type RangeAddress, type ReplaceChange, type ReplaceTarget, type SearchMatch, type SearchOptions, type SerializedCellValue, type Sheet, type SingleEvaluationResult, type SpreadsheetRange, type SpreadsheetRangeEnd, type TableDefinition } from "./types";
|
|
6
6
|
import type { FillDirection } from "@ricsam/selection-manager";
|
|
7
7
|
import { AutoFill } from "./autofill-utils";
|
|
8
8
|
import { WorkbookManager } from "./managers/workbook-manager";
|
|
@@ -12,12 +12,6 @@ import { EventManager } from "./managers/event-manager";
|
|
|
12
12
|
import { EvaluationManager } from "./managers/evaluation-manager";
|
|
13
13
|
import { DependencyManager } from "./managers/dependency-manager";
|
|
14
14
|
import { StyleManager } from "./managers/style-manager";
|
|
15
|
-
import type { Schema, CreateSchema, SchemaDeclaration } from "./schema/schema";
|
|
16
|
-
import { TableOrm } from "./schema/table-orm";
|
|
17
|
-
import { CellOrm } from "./schema/cell-orm";
|
|
18
|
-
import { GridOrm } from "./schema/grid-orm";
|
|
19
|
-
import type { TableSchemaHeaders } from "./managers/schema-manager";
|
|
20
|
-
import { type EngineAction } from "./commands/types";
|
|
21
15
|
type Metadata = {
|
|
22
16
|
cell?: unknown;
|
|
23
17
|
sheet?: unknown;
|
|
@@ -26,11 +20,9 @@ type Metadata = {
|
|
|
26
20
|
type MetadataType<TMetadata extends Metadata, TKey extends keyof Metadata> = TMetadata[TKey];
|
|
27
21
|
/**
|
|
28
22
|
* Main FormulaEngine class
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
*/
|
|
33
|
-
export declare class FormulaEngine<TMetadata extends Metadata = Metadata, TCreateSchema extends CreateSchema<MetadataType<TMetadata, "cell">, Schema, SchemaDeclaration> | undefined = undefined> {
|
|
23
|
+
* @template TMetadata - Consumer-defined metadata shape with optional cell, sheet, and workbook entries.
|
|
24
|
+
*/
|
|
25
|
+
export declare class FormulaEngine<TMetadata extends Metadata = Metadata> {
|
|
34
26
|
private workbookManager;
|
|
35
27
|
private namedExpressionManager;
|
|
36
28
|
private tableManager;
|
|
@@ -41,10 +33,6 @@ export declare class FormulaEngine<TMetadata extends Metadata = Metadata, TCreat
|
|
|
41
33
|
private styleManager;
|
|
42
34
|
private copyManager;
|
|
43
35
|
private referenceManager;
|
|
44
|
-
private schemaManager;
|
|
45
|
-
private commandExecutor;
|
|
46
|
-
schema: TCreateSchema extends CreateSchema<MetadataType<TMetadata, "cell">, Schema, SchemaDeclaration> ? TCreateSchema["schema"] : undefined;
|
|
47
|
-
private schemaDeclaration;
|
|
48
36
|
/**
|
|
49
37
|
* Public access to the store manager for testing
|
|
50
38
|
*/
|
|
@@ -56,73 +44,17 @@ export declare class FormulaEngine<TMetadata extends Metadata = Metadata, TCreat
|
|
|
56
44
|
_autoFillManager: AutoFill;
|
|
57
45
|
_dependencyManager: DependencyManager;
|
|
58
46
|
_styleManager: StyleManager;
|
|
59
|
-
constructor(
|
|
47
|
+
constructor();
|
|
60
48
|
/**
|
|
61
49
|
* Static factory method to build an empty engine
|
|
62
|
-
* @template
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
* @param address - Table address (workbookName and tableName)
|
|
71
|
-
* @param headers - Table headers with parse functions
|
|
72
|
-
* @returns The TableOrm instance for immediate use
|
|
73
|
-
*/
|
|
74
|
-
addTableSchema<THeaders extends TableSchemaHeaders<MetadataType<TMetadata, "cell">>>(namespace: string, address: {
|
|
75
|
-
workbookName: string;
|
|
76
|
-
tableName: string;
|
|
77
|
-
}, headers: THeaders): TableOrm<{
|
|
78
|
-
[K in keyof THeaders]: ReturnType<THeaders[K]["parse"]>;
|
|
79
|
-
}>;
|
|
80
|
-
/**
|
|
81
|
-
* Add a cell schema at runtime
|
|
82
|
-
* @param namespace - Unique namespace for the schema
|
|
83
|
-
* @param cellAddress - Address of the cell
|
|
84
|
-
* @param parse - Parse function for the cell value
|
|
85
|
-
* @returns The CellOrm instance for immediate use
|
|
86
|
-
*/
|
|
87
|
-
addCellSchema<TValue>(namespace: string, cellAddress: CellAddress, parse: (value: unknown, metadata: MetadataType<TMetadata, "cell">) => TValue, write?: (value: TValue) => {
|
|
88
|
-
value: SerializedCellValue;
|
|
89
|
-
metadata?: MetadataType<TMetadata, "cell">;
|
|
90
|
-
}): CellOrm<TValue>;
|
|
91
|
-
/**
|
|
92
|
-
* Add a grid schema at runtime
|
|
93
|
-
* @param namespace - Unique namespace for the schema
|
|
94
|
-
* @param address - Grid address (workbookName and sheetName)
|
|
95
|
-
* @param range - Finite range of cells for the grid
|
|
96
|
-
* @param parse - Parse function for the cell values
|
|
97
|
-
* @param write - Write function for serializing values (optional for primitive types)
|
|
98
|
-
* @returns The GridOrm instance for immediate use
|
|
99
|
-
*/
|
|
100
|
-
addGridSchema<TValue>(namespace: string, address: {
|
|
101
|
-
workbookName: string;
|
|
102
|
-
sheetName: string;
|
|
103
|
-
}, range: FiniteSpreadsheetRange, parse: (value: unknown, metadata: MetadataType<TMetadata, "cell">) => TValue, write?: (value: TValue) => {
|
|
104
|
-
value: SerializedCellValue;
|
|
105
|
-
metadata?: MetadataType<TMetadata, "cell">;
|
|
106
|
-
}): GridOrm<TValue, MetadataType<TMetadata, "cell">>;
|
|
107
|
-
/**
|
|
108
|
-
* Remove a table schema at runtime.
|
|
109
|
-
* @param namespace - Namespace of the table schema to remove
|
|
110
|
-
* @returns true when a matching table schema was removed, false otherwise
|
|
111
|
-
*/
|
|
112
|
-
removeTableSchema(namespace: string): boolean;
|
|
113
|
-
/**
|
|
114
|
-
* Remove a cell schema at runtime.
|
|
115
|
-
* @param namespace - Namespace of the cell schema to remove
|
|
116
|
-
* @returns true when a matching cell schema was removed, false otherwise
|
|
117
|
-
*/
|
|
118
|
-
removeCellSchema(namespace: string): boolean;
|
|
119
|
-
/**
|
|
120
|
-
* Remove a grid schema at runtime.
|
|
121
|
-
* @param namespace - Namespace of the grid schema to remove
|
|
122
|
-
* @returns true when a matching grid schema was removed, false otherwise
|
|
123
|
-
*/
|
|
124
|
-
removeGridSchema(namespace: string): boolean;
|
|
125
|
-
private removeSchemaOfType;
|
|
50
|
+
* @template TMetadata - Consumer-defined metadata shape with optional cell, sheet, and workbook entries.
|
|
51
|
+
*/
|
|
52
|
+
static buildEmpty<TMetadata extends Metadata = Metadata>(): FormulaEngine<TMetadata>;
|
|
53
|
+
private emitMutation;
|
|
54
|
+
private emitUpdate;
|
|
55
|
+
private getExistingSheetContent;
|
|
56
|
+
private getWorkbookResourceKeys;
|
|
57
|
+
private getSheetResourceKeys;
|
|
126
58
|
getCellEvaluationResult(cellAddress: CellAddress): SingleEvaluationResult | undefined;
|
|
127
59
|
getCellValue(cellAddress: CellAddress, debug?: boolean): SerializedCellValue;
|
|
128
60
|
/**
|
|
@@ -260,6 +192,7 @@ export declare class FormulaEngine<TMetadata extends Metadata = Metadata, TCreat
|
|
|
260
192
|
tableName: string;
|
|
261
193
|
workbookName: string;
|
|
262
194
|
}): void;
|
|
195
|
+
private getAllTables;
|
|
263
196
|
/**
|
|
264
197
|
* Check if a table exists
|
|
265
198
|
*/
|
|
@@ -277,12 +210,6 @@ export declare class FormulaEngine<TMetadata extends Metadata = Metadata, TCreat
|
|
|
277
210
|
resetTables(tables: Map<string, Map<string, TableDefinition>>): void;
|
|
278
211
|
getTables(workbookName: string): Map<string, TableDefinition>;
|
|
279
212
|
isCellInTable(cellAddress: CellAddress): TableDefinition | undefined;
|
|
280
|
-
/**
|
|
281
|
-
* Get all data cells in a table (excluding header row).
|
|
282
|
-
* Since spills cannot enter tables (they get #SPILL! error), this only
|
|
283
|
-
* needs to return cells with direct content.
|
|
284
|
-
*/
|
|
285
|
-
private getTableDataCells;
|
|
286
213
|
/**
|
|
287
214
|
* Add a conditional style rule
|
|
288
215
|
*/
|
|
@@ -338,6 +265,9 @@ export declare class FormulaEngine<TMetadata extends Metadata = Metadata, TCreat
|
|
|
338
265
|
* Adjusts existing style ranges rather than deleting them entirely
|
|
339
266
|
*/
|
|
340
267
|
clearCellStyles(range: RangeAddress): void;
|
|
268
|
+
private getTopLeftCell;
|
|
269
|
+
private dedupeAddresses;
|
|
270
|
+
private getPasteTouchedAddresses;
|
|
341
271
|
/**
|
|
342
272
|
* Paste cells from source to target
|
|
343
273
|
*/
|
|
@@ -482,6 +412,20 @@ export declare class FormulaEngine<TMetadata extends Metadata = Metadata, TCreat
|
|
|
482
412
|
sheetName: string;
|
|
483
413
|
workbookName: string;
|
|
484
414
|
}): Map<string, SerializedCellValue>;
|
|
415
|
+
/**
|
|
416
|
+
* Search raw stored string content without evaluating cell values.
|
|
417
|
+
*/
|
|
418
|
+
search(query: string, options?: SearchOptions): SearchMatch[];
|
|
419
|
+
/**
|
|
420
|
+
* Replace one specific search occurrence inside one addressed cell.
|
|
421
|
+
*/
|
|
422
|
+
replace(query: string, replacement: string, target: ReplaceTarget, options?: {
|
|
423
|
+
caseSensitive?: boolean;
|
|
424
|
+
}): ReplaceChange;
|
|
425
|
+
/**
|
|
426
|
+
* Replace all matching raw string occurrences within the requested scope.
|
|
427
|
+
*/
|
|
428
|
+
replaceAll(query: string, replacement: string, options?: SearchOptions): ReplaceChange[];
|
|
485
429
|
addWorkbook(workbookName: string): void;
|
|
486
430
|
removeWorkbook(workbookName: string): void;
|
|
487
431
|
/**
|
|
@@ -499,7 +443,6 @@ export declare class FormulaEngine<TMetadata extends Metadata = Metadata, TCreat
|
|
|
499
443
|
* @param sheetName - The name of the sheet to set the content of
|
|
500
444
|
* @param content - A map of cell addresses to their serialized values
|
|
501
445
|
* @remarks This method is used to set the content of a sheet. It will re-evaluate all sheets to ensure all dependencies are resolved correctly.
|
|
502
|
-
* @throws SchemaIntegrityError if any evaluated cell value violates a schema constraint
|
|
503
446
|
*/
|
|
504
447
|
setSheetContent(opts: {
|
|
505
448
|
sheetName: string;
|
|
@@ -507,7 +450,6 @@ export declare class FormulaEngine<TMetadata extends Metadata = Metadata, TCreat
|
|
|
507
450
|
}, content: Map<string, SerializedCellValue>): void;
|
|
508
451
|
/**
|
|
509
452
|
* Set the content of a single cell.
|
|
510
|
-
* @throws SchemaIntegrityError if the evaluated value violates a schema constraint
|
|
511
453
|
*/
|
|
512
454
|
setCellContent(address: CellAddress, content: SerializedCellValue): void;
|
|
513
455
|
/**
|
|
@@ -550,51 +492,5 @@ export declare class FormulaEngine<TMetadata extends Metadata = Metadata, TCreat
|
|
|
550
492
|
private buildSerializedSnapshot;
|
|
551
493
|
serializeEngine(): string;
|
|
552
494
|
resetToSerializedEngine(data: string): void;
|
|
553
|
-
/**
|
|
554
|
-
* Undo the last command.
|
|
555
|
-
* @returns true if undo was performed, false if nothing to undo
|
|
556
|
-
*/
|
|
557
|
-
undo(): boolean;
|
|
558
|
-
/**
|
|
559
|
-
* Redo the last undone command.
|
|
560
|
-
* @returns true if redo was performed, false if nothing to redo
|
|
561
|
-
*/
|
|
562
|
-
redo(): boolean;
|
|
563
|
-
/**
|
|
564
|
-
* Check if undo is available.
|
|
565
|
-
*/
|
|
566
|
-
canUndo(): boolean;
|
|
567
|
-
/**
|
|
568
|
-
* Check if redo is available.
|
|
569
|
-
*/
|
|
570
|
-
canRedo(): boolean;
|
|
571
|
-
/**
|
|
572
|
-
* Get the action log for persistence/collaboration.
|
|
573
|
-
* Actions can be serialized and replayed to reconstruct state.
|
|
574
|
-
*/
|
|
575
|
-
getActionLog(): EngineAction[];
|
|
576
|
-
/**
|
|
577
|
-
* Clear the action log.
|
|
578
|
-
*/
|
|
579
|
-
clearActionLog(): void;
|
|
580
|
-
/**
|
|
581
|
-
* Clear undo/redo history.
|
|
582
|
-
*/
|
|
583
|
-
clearHistory(): void;
|
|
584
|
-
/**
|
|
585
|
-
* Get dependencies for structure commands.
|
|
586
|
-
* @internal
|
|
587
|
-
*/
|
|
588
|
-
private getStructureCommandDeps;
|
|
589
|
-
/**
|
|
590
|
-
* Get dependencies for table commands.
|
|
591
|
-
* @internal
|
|
592
|
-
*/
|
|
593
|
-
private getTableCommandDeps;
|
|
594
|
-
/**
|
|
595
|
-
* Get dependencies for named expression commands.
|
|
596
|
-
* @internal
|
|
597
|
-
*/
|
|
598
|
-
private getNamedExpressionCommandDeps;
|
|
599
495
|
}
|
|
600
496
|
export {};
|
|
@@ -12,7 +12,7 @@ import type { DependencyNode } from "./dependency-node";
|
|
|
12
12
|
import { WorkbookManager } from "./workbook-manager";
|
|
13
13
|
import { VirtualCellValueNode } from "../../evaluator/dependency-nodes/virtual-cell-value-node";
|
|
14
14
|
import type { EvaluationManager } from "./evaluation-manager";
|
|
15
|
-
import type { MutationInvalidation } from "../
|
|
15
|
+
import type { MutationInvalidation } from "../mutation-invalidation";
|
|
16
16
|
import { ResourceDependencyNode } from "../../evaluator/dependency-nodes/resource-dependency-node";
|
|
17
17
|
export interface DependencyTreeNode {
|
|
18
18
|
type: "cell" | "range" | "empty";
|
|
@@ -59,6 +59,10 @@ export declare class DependencyManager {
|
|
|
59
59
|
private coverageWatchersBySheet;
|
|
60
60
|
private frontierWatchersBySheet;
|
|
61
61
|
constructor(cacheManager: CacheManager, workbookManager: WorkbookManager);
|
|
62
|
+
private getSnapshotEligibilityState;
|
|
63
|
+
private logSnapshotRestoreWarning;
|
|
64
|
+
private getLogicalNodeSnapshotId;
|
|
65
|
+
private resetRestoredNodeToColdState;
|
|
62
66
|
private getSheetWatcherKey;
|
|
63
67
|
private addReverseEdge;
|
|
64
68
|
private removeReverseEdge;
|
|
@@ -11,7 +11,7 @@ import type { TableManager } from "./table-manager";
|
|
|
11
11
|
import type { DependencyNode } from "./dependency-node";
|
|
12
12
|
import { VirtualCellValueNode } from "../../evaluator/dependency-nodes/virtual-cell-value-node";
|
|
13
13
|
import type { NodeSnapshotId, SerializedEvaluateAllCellsResultSnapshot, SerializedFunctionEvaluationResultSnapshot, SerializedSingleEvaluationResultSnapshot, SerializedSpillMetaEvaluationResultSnapshot } from "../engine-snapshot";
|
|
14
|
-
import type { MutationInvalidation } from "../
|
|
14
|
+
import type { MutationInvalidation } from "../mutation-invalidation";
|
|
15
15
|
export declare class EvaluationManager {
|
|
16
16
|
private workbookManager;
|
|
17
17
|
private tableManager;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CellAddress, type SerializedCellValue, type Sheet, type Workbook } from "../types";
|
|
1
|
+
import { type CellAddress, type ReplaceChange, type ReplaceTarget, type SearchMatch, type SearchOptions, type SerializedCellValue, type Sheet, type Workbook } from "../types";
|
|
2
2
|
import type { WorkbookManagerSnapshot } from "../engine-snapshot";
|
|
3
3
|
import type { RangeAddress } from "../types";
|
|
4
4
|
interface IndexEntry {
|
|
@@ -11,6 +11,18 @@ export interface SheetIndexes {
|
|
|
11
11
|
cellsSortedByRow: IndexEntry[];
|
|
12
12
|
cellsSortedByCol: IndexEntry[];
|
|
13
13
|
}
|
|
14
|
+
type PreparedReplace = {
|
|
15
|
+
address: CellAddress;
|
|
16
|
+
beforeContent: string;
|
|
17
|
+
afterContent: string;
|
|
18
|
+
change: ReplaceChange;
|
|
19
|
+
};
|
|
20
|
+
type PreparedCellReplaceAll = {
|
|
21
|
+
address: CellAddress;
|
|
22
|
+
beforeContent: string;
|
|
23
|
+
afterContent: string;
|
|
24
|
+
changes: ReplaceChange[];
|
|
25
|
+
};
|
|
14
26
|
/**
|
|
15
27
|
* Utility class for binary search operations on IndexEntry arrays
|
|
16
28
|
*/
|
|
@@ -84,6 +96,16 @@ export declare class WorkbookManager {
|
|
|
84
96
|
workbookName: string;
|
|
85
97
|
sheetName: string;
|
|
86
98
|
}): Map<string, SerializedCellValue>;
|
|
99
|
+
private resolveSearchScope;
|
|
100
|
+
private getStringContentKind;
|
|
101
|
+
private findMatchesInString;
|
|
102
|
+
private buildSearchMatchesInScope;
|
|
103
|
+
search(query: string, options?: SearchOptions): SearchMatch[];
|
|
104
|
+
private buildReplacedContent;
|
|
105
|
+
prepareReplace(query: string, replacement: string, target: ReplaceTarget, options?: {
|
|
106
|
+
caseSensitive?: boolean;
|
|
107
|
+
}): PreparedReplace;
|
|
108
|
+
prepareReplaceAll(query: string, replacement: string, options?: SearchOptions): PreparedCellReplaceAll[];
|
|
87
109
|
/**
|
|
88
110
|
* Add a cell to the grouped indexes
|
|
89
111
|
*/
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { WorkbookManager } from "./managers/workbook-manager";
|
|
2
|
+
import type { CellAddress, RangeAddress, SerializedCellValue, TableDefinition } from "./types";
|
|
3
|
+
type CellContentKind = "empty" | "scalar" | "formula";
|
|
4
|
+
export type RemovedScope = {
|
|
5
|
+
type: "workbook";
|
|
6
|
+
workbookName: string;
|
|
7
|
+
} | {
|
|
8
|
+
type: "sheet";
|
|
9
|
+
workbookName: string;
|
|
10
|
+
sheetName: string;
|
|
11
|
+
};
|
|
12
|
+
export type MutationInvalidation = {
|
|
13
|
+
touchedCells: Array<{
|
|
14
|
+
address: CellAddress;
|
|
15
|
+
beforeKind: CellContentKind;
|
|
16
|
+
afterKind: CellContentKind;
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* Cells whose table membership or implicit current-row table context changed
|
|
20
|
+
* without necessarily changing their formula text.
|
|
21
|
+
*/
|
|
22
|
+
tableContextChangedCells?: CellAddress[];
|
|
23
|
+
resourceKeys: string[];
|
|
24
|
+
removedScopes?: RemovedScope[];
|
|
25
|
+
};
|
|
26
|
+
export declare function getMutationAddressKey(address: CellAddress): string;
|
|
27
|
+
export declare function buildTouchedCells(cells: Array<{
|
|
28
|
+
address: CellAddress;
|
|
29
|
+
before: SerializedCellValue | undefined;
|
|
30
|
+
after: SerializedCellValue | undefined;
|
|
31
|
+
}>): MutationInvalidation["touchedCells"];
|
|
32
|
+
export declare function buildFormulaTouchedCells(cells: CellAddress[]): MutationInvalidation["touchedCells"];
|
|
33
|
+
export declare function captureCellContents(workbookManager: WorkbookManager, addresses: CellAddress[]): Map<string, SerializedCellValue | undefined>;
|
|
34
|
+
export declare function buildSheetContentTouchedCells(opts: {
|
|
35
|
+
workbookName: string;
|
|
36
|
+
sheetName: string;
|
|
37
|
+
}, beforeContent: Map<string, SerializedCellValue> | undefined, afterContent: Map<string, SerializedCellValue>): MutationInvalidation["touchedCells"];
|
|
38
|
+
export declare function buildTableTouchedCells(workbookManager: WorkbookManager, tables: Array<TableDefinition | undefined>): MutationInvalidation["touchedCells"];
|
|
39
|
+
export declare function buildTableContextChangedCells(workbookManager: WorkbookManager, tables: Array<TableDefinition | undefined>): CellAddress[];
|
|
40
|
+
export declare function mergeTouchedCells(...groups: MutationInvalidation["touchedCells"][]): MutationInvalidation["touchedCells"];
|
|
41
|
+
export declare function getNamedExpressionScopeResourceKeys(expressions: Iterable<string>, opts: {
|
|
42
|
+
workbookName?: string;
|
|
43
|
+
sheetName?: string;
|
|
44
|
+
}): string[];
|
|
45
|
+
export declare function getFiniteRangeAddresses(address: RangeAddress): CellAddress[];
|
|
46
|
+
export {};
|
|
@@ -80,6 +80,41 @@ export type CellValue = CellNumber | CellString | CellBoolean | CellInfinity;
|
|
|
80
80
|
* any empty values are deleted from the sheet content
|
|
81
81
|
*/
|
|
82
82
|
export type SerializedCellValue = string | number | boolean | undefined;
|
|
83
|
+
export interface SearchOptions {
|
|
84
|
+
workbookName?: string;
|
|
85
|
+
sheetName?: string;
|
|
86
|
+
caseSensitive?: boolean;
|
|
87
|
+
}
|
|
88
|
+
export interface SearchMatch {
|
|
89
|
+
workbookName: string;
|
|
90
|
+
sheetName: string;
|
|
91
|
+
cellReference: string;
|
|
92
|
+
cellContent: string;
|
|
93
|
+
contentKind: "formula" | "text";
|
|
94
|
+
occurrenceIndex: number;
|
|
95
|
+
startIndex: number;
|
|
96
|
+
endIndexExclusive: number;
|
|
97
|
+
matchedText: string;
|
|
98
|
+
}
|
|
99
|
+
export interface ReplaceTarget {
|
|
100
|
+
workbookName: string;
|
|
101
|
+
sheetName: string;
|
|
102
|
+
cellReference: string;
|
|
103
|
+
occurrenceIndex: number;
|
|
104
|
+
}
|
|
105
|
+
export interface ReplaceChange {
|
|
106
|
+
workbookName: string;
|
|
107
|
+
sheetName: string;
|
|
108
|
+
cellReference: string;
|
|
109
|
+
contentKind: "formula" | "text";
|
|
110
|
+
occurrenceIndex: number;
|
|
111
|
+
startIndex: number;
|
|
112
|
+
endIndexExclusive: number;
|
|
113
|
+
matchedText: string;
|
|
114
|
+
replacementText: string;
|
|
115
|
+
beforeContent: string;
|
|
116
|
+
afterContent: string;
|
|
117
|
+
}
|
|
83
118
|
export interface NamedExpression {
|
|
84
119
|
name: string;
|
|
85
120
|
expression: string;
|
package/dist/types/lib.d.ts
CHANGED
|
@@ -2,11 +2,3 @@ export { FormulaEngine } from "./core/engine";
|
|
|
2
2
|
export * from "./core/types";
|
|
3
3
|
export * from "./core/utils";
|
|
4
4
|
export * from "./core/utils/color-utils";
|
|
5
|
-
export { defineSchema, defineHeader } from "./core/schema/schema";
|
|
6
|
-
export type { CreateSchema, SchemaDeclaration, Schema, TableSchemaDefinition, CellSchemaDefinition, TableOrmSchema, CellOrmSchema } from "./core/schema/schema";
|
|
7
|
-
export { TableOrm } from "./core/schema/table-orm";
|
|
8
|
-
export { CellOrm } from "./core/schema/cell-orm";
|
|
9
|
-
export { SchemaValidationError } from "./core/managers/schema-manager";
|
|
10
|
-
export type { ValidationResult } from "./core/managers/schema-manager";
|
|
11
|
-
export { SchemaIntegrityError } from "./core/commands/command-executor";
|
|
12
|
-
export type { EngineAction, EngineCommand } from "./core/commands/types";
|
|
@@ -21,13 +21,15 @@ export declare class Parser {
|
|
|
21
21
|
private input;
|
|
22
22
|
constructor(tokens: Token[], input?: string);
|
|
23
23
|
/**
|
|
24
|
-
* Look ahead to determine if this is a workbook reference
|
|
24
|
+
* Look ahead to determine if this is a workbook reference like
|
|
25
|
+
* [Workbook]!Table[...] or [Workbook]Sheet...
|
|
25
26
|
*/
|
|
26
27
|
private lookAheadForWorkbookReference;
|
|
27
28
|
/**
|
|
28
|
-
* Parse workbook reference like [Workbook]
|
|
29
|
+
* Parse workbook reference like [Workbook]!Table[Column] or [Workbook]Sheet!A1
|
|
29
30
|
*/
|
|
30
31
|
private parseWorkbookReference;
|
|
32
|
+
private parseWorkbookQualifiedTableReference;
|
|
31
33
|
/**
|
|
32
34
|
* Parse bare column reference like [Column] or [Column1:Column2]
|
|
33
35
|
*/
|
|
@@ -136,10 +138,6 @@ export declare class Parser {
|
|
|
136
138
|
* Parse a range reference with workbook name
|
|
137
139
|
*/
|
|
138
140
|
private parseRangeWithWorkbook;
|
|
139
|
-
/**
|
|
140
|
-
* Parse table reference with workbook and sheet name
|
|
141
|
-
*/
|
|
142
|
-
private parseTableReferenceWithWorkbookAndSheet;
|
|
143
141
|
/**
|
|
144
142
|
* Parse a range reference (including infinite ranges)
|
|
145
143
|
*/
|
package/package.json
CHANGED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
function __accessProp(key) {
|
|
6
|
-
return this[key];
|
|
7
|
-
}
|
|
8
|
-
var __toCommonJS = (from) => {
|
|
9
|
-
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
10
|
-
if (entry)
|
|
11
|
-
return entry;
|
|
12
|
-
entry = __defProp({}, "__esModule", { value: true });
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (var key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(entry, key))
|
|
16
|
-
__defProp(entry, key, {
|
|
17
|
-
get: __accessProp.bind(from, key),
|
|
18
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
__moduleCache.set(from, entry);
|
|
22
|
-
return entry;
|
|
23
|
-
};
|
|
24
|
-
var __moduleCache;
|
|
25
|
-
var __returnValue = (v) => v;
|
|
26
|
-
function __exportSetter(name, newValue) {
|
|
27
|
-
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
-
}
|
|
29
|
-
var __export = (target, all) => {
|
|
30
|
-
for (var name in all)
|
|
31
|
-
__defProp(target, name, {
|
|
32
|
-
get: all[name],
|
|
33
|
-
enumerable: true,
|
|
34
|
-
configurable: true,
|
|
35
|
-
set: __exportSetter.bind(all, name)
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// src/core/commands/command-executor.ts
|
|
40
|
-
var exports_command_executor = {};
|
|
41
|
-
__export(exports_command_executor, {
|
|
42
|
-
SchemaIntegrityError: () => SchemaIntegrityError,
|
|
43
|
-
CommandExecutor: () => CommandExecutor
|
|
44
|
-
});
|
|
45
|
-
module.exports = __toCommonJS(exports_command_executor);
|
|
46
|
-
var import_types = require("./types.cjs");
|
|
47
|
-
|
|
48
|
-
class SchemaIntegrityError extends Error {
|
|
49
|
-
errors;
|
|
50
|
-
constructor(errors) {
|
|
51
|
-
const messages = errors.map((e) => e.message).join("; ");
|
|
52
|
-
super(`Schema integrity violation: ${messages}`);
|
|
53
|
-
this.errors = errors;
|
|
54
|
-
this.name = "SchemaIntegrityError";
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
class CommandExecutor {
|
|
59
|
-
evaluationManager;
|
|
60
|
-
eventManager;
|
|
61
|
-
validateAllSchemas;
|
|
62
|
-
undoStack = [];
|
|
63
|
-
redoStack = [];
|
|
64
|
-
actionLog = [];
|
|
65
|
-
constructor(evaluationManager, eventManager, validateAllSchemas) {
|
|
66
|
-
this.evaluationManager = evaluationManager;
|
|
67
|
-
this.eventManager = eventManager;
|
|
68
|
-
this.validateAllSchemas = validateAllSchemas;
|
|
69
|
-
}
|
|
70
|
-
execute(command, options = {}) {
|
|
71
|
-
const {
|
|
72
|
-
validate = false,
|
|
73
|
-
skipUndoStack = false,
|
|
74
|
-
skipEmitUpdate = false
|
|
75
|
-
} = options;
|
|
76
|
-
command.execute();
|
|
77
|
-
if (command.requiresReevaluation) {
|
|
78
|
-
this.evaluationManager.invalidateFromMutation(command.getInvalidationFootprint?.("execute") ?? import_types.emptyMutationInvalidation());
|
|
79
|
-
if (validate) {
|
|
80
|
-
const validation = this.validateAllSchemas();
|
|
81
|
-
if (!validation.valid) {
|
|
82
|
-
command.undo();
|
|
83
|
-
this.evaluationManager.invalidateFromMutation(command.getInvalidationFootprint?.("undo") ?? import_types.emptyMutationInvalidation());
|
|
84
|
-
throw new SchemaIntegrityError(validation.errors);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
if (!skipUndoStack) {
|
|
89
|
-
this.undoStack.push(command);
|
|
90
|
-
this.redoStack = [];
|
|
91
|
-
}
|
|
92
|
-
const action = command.toAction();
|
|
93
|
-
action.timestamp = Date.now();
|
|
94
|
-
this.actionLog.push(action);
|
|
95
|
-
if (!skipEmitUpdate) {
|
|
96
|
-
this.eventManager.emitUpdate();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
undo() {
|
|
100
|
-
const command = this.undoStack.pop();
|
|
101
|
-
if (!command) {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
command.undo();
|
|
105
|
-
if (command.requiresReevaluation) {
|
|
106
|
-
this.evaluationManager.invalidateFromMutation(command.getInvalidationFootprint?.("undo") ?? import_types.emptyMutationInvalidation());
|
|
107
|
-
}
|
|
108
|
-
this.redoStack.push(command);
|
|
109
|
-
this.eventManager.emitUpdate();
|
|
110
|
-
return true;
|
|
111
|
-
}
|
|
112
|
-
redo() {
|
|
113
|
-
const command = this.redoStack.pop();
|
|
114
|
-
if (!command) {
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
command.execute();
|
|
118
|
-
if (command.requiresReevaluation) {
|
|
119
|
-
this.evaluationManager.invalidateFromMutation(command.getInvalidationFootprint?.("execute") ?? import_types.emptyMutationInvalidation());
|
|
120
|
-
}
|
|
121
|
-
this.undoStack.push(command);
|
|
122
|
-
this.eventManager.emitUpdate();
|
|
123
|
-
return true;
|
|
124
|
-
}
|
|
125
|
-
canUndo() {
|
|
126
|
-
return this.undoStack.length > 0;
|
|
127
|
-
}
|
|
128
|
-
canRedo() {
|
|
129
|
-
return this.redoStack.length > 0;
|
|
130
|
-
}
|
|
131
|
-
getActionLog() {
|
|
132
|
-
return [...this.actionLog];
|
|
133
|
-
}
|
|
134
|
-
clearActionLog() {
|
|
135
|
-
this.actionLog = [];
|
|
136
|
-
}
|
|
137
|
-
clearHistory() {
|
|
138
|
-
this.undoStack = [];
|
|
139
|
-
this.redoStack = [];
|
|
140
|
-
}
|
|
141
|
-
getUndoStackSize() {
|
|
142
|
-
return this.undoStack.length;
|
|
143
|
-
}
|
|
144
|
-
getRedoStackSize() {
|
|
145
|
-
return this.redoStack.length;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
//# debugId=43DC9858A49109E564756E2164756E21
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/core/commands/command-executor.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"/**\n * CommandExecutor - Executes commands with undo/redo support and schema validation\n *\n * Handles:\n * - Command execution with optional re-evaluation\n * - Schema validation after re-evaluation\n * - Automatic rollback on validation failure\n * - Undo/redo stacks\n * - Action serialization for persistence\n */\n\nimport type { SchemaDeclaration } from \"../schema/schema.cjs\";\nimport type { FormulaEngine } from \"../engine.cjs\";\nimport type { EvaluationManager } from \"../managers/evaluation-manager.cjs\";\nimport type { EventManager } from \"../managers/event-manager.cjs\";\nimport type { CellAddress, SerializedCellValue } from \"../types.cjs\";\nimport type {\n EngineCommand,\n EngineAction,\n ExecuteOptions,\n SchemaValidationResult,\n SchemaValidationErrorInfo,\n} from \"./types.cjs\";\nimport { emptyMutationInvalidation } from \"./types.cjs\";\n\n/**\n * Error thrown when schema integrity validation fails.\n * Contains all validation errors that occurred.\n */\nexport class SchemaIntegrityError extends Error {\n constructor(public errors: SchemaValidationErrorInfo[]) {\n const messages = errors.map((e) => e.message).join(\"; \");\n super(`Schema integrity violation: ${messages}`);\n this.name = \"SchemaIntegrityError\";\n }\n}\n\n/**\n * CommandExecutor manages command execution with validation and undo/redo support.\n */\nexport class CommandExecutor {\n private undoStack: EngineCommand[] = [];\n private redoStack: EngineCommand[] = [];\n private actionLog: EngineAction[] = [];\n\n constructor(\n private evaluationManager: EvaluationManager,\n private eventManager: EventManager,\n private validateAllSchemas: () => SchemaValidationResult\n ) {}\n\n /**\n * Execute a command with optional schema validation.\n *\n * @param command - The command to execute\n * @param options - Execution options\n * @throws SchemaIntegrityError if validation fails\n */\n execute(command: EngineCommand, options: ExecuteOptions = {}): void {\n const {\n validate = false,\n skipUndoStack = false,\n skipEmitUpdate = false,\n } = options;\n\n // Execute the command\n command.execute();\n\n // Re-evaluate if needed\n if (command.requiresReevaluation) {\n this.evaluationManager.invalidateFromMutation(\n command.getInvalidationFootprint?.(\"execute\") ??\n emptyMutationInvalidation()\n );\n\n // Validate schemas if requested\n if (validate) {\n const validation = this.validateAllSchemas();\n\n if (!validation.valid) {\n // Rollback: undo the command and re-evaluate\n command.undo();\n this.evaluationManager.invalidateFromMutation(\n command.getInvalidationFootprint?.(\"undo\") ??\n emptyMutationInvalidation()\n );\n throw new SchemaIntegrityError(validation.errors);\n }\n }\n }\n\n // Add to undo stack\n if (!skipUndoStack) {\n this.undoStack.push(command);\n // Clear redo stack on new action\n this.redoStack = [];\n }\n\n // Log the action\n const action = command.toAction();\n action.timestamp = Date.now();\n this.actionLog.push(action);\n\n // Emit update event\n if (!skipEmitUpdate) {\n this.eventManager.emitUpdate();\n }\n }\n\n /**\n * Undo the last command.\n *\n * @returns true if undo was performed, false if nothing to undo\n */\n undo(): boolean {\n const command = this.undoStack.pop();\n if (!command) {\n return false;\n }\n\n command.undo();\n\n if (command.requiresReevaluation) {\n this.evaluationManager.invalidateFromMutation(\n command.getInvalidationFootprint?.(\"undo\") ??\n emptyMutationInvalidation()\n );\n }\n\n this.redoStack.push(command);\n this.eventManager.emitUpdate();\n\n return true;\n }\n\n /**\n * Redo the last undone command.\n *\n * @returns true if redo was performed, false if nothing to redo\n */\n redo(): boolean {\n const command = this.redoStack.pop();\n if (!command) {\n return false;\n }\n\n command.execute();\n\n if (command.requiresReevaluation) {\n this.evaluationManager.invalidateFromMutation(\n command.getInvalidationFootprint?.(\"execute\") ??\n emptyMutationInvalidation()\n );\n }\n\n this.undoStack.push(command);\n this.eventManager.emitUpdate();\n\n return true;\n }\n\n /**\n * Check if undo is available.\n */\n canUndo(): boolean {\n return this.undoStack.length > 0;\n }\n\n /**\n * Check if redo is available.\n */\n canRedo(): boolean {\n return this.redoStack.length > 0;\n }\n\n /**\n * Get the action log for persistence/collaboration.\n */\n getActionLog(): EngineAction[] {\n return [...this.actionLog];\n }\n\n /**\n * Clear the action log.\n */\n clearActionLog(): void {\n this.actionLog = [];\n }\n\n /**\n * Clear undo/redo stacks.\n */\n clearHistory(): void {\n this.undoStack = [];\n this.redoStack = [];\n }\n\n /**\n * Get the number of commands in the undo stack.\n */\n getUndoStackSize(): number {\n return this.undoStack.length;\n }\n\n /**\n * Get the number of commands in the redo stack.\n */\n getRedoStackSize(): number {\n return this.redoStack.length;\n }\n}\n"
|
|
6
|
-
],
|
|
7
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuB0C,IAA1C;AAAA;AAMO,MAAM,6BAA6B,MAAM;AAAA,EAC3B;AAAA,EAAnB,WAAW,CAAQ,QAAqC;AAAA,IACtD,MAAM,WAAW,OAAO,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,IAAI;AAAA,IACvD,MAAM,+BAA+B,UAAU;AAAA,IAF9B;AAAA,IAGjB,KAAK,OAAO;AAAA;AAEhB;AAAA;AAKO,MAAM,gBAAgB;AAAA,EAMjB;AAAA,EACA;AAAA,EACA;AAAA,EAPF,YAA6B,CAAC;AAAA,EAC9B,YAA6B,CAAC;AAAA,EAC9B,YAA4B,CAAC;AAAA,EAErC,WAAW,CACD,mBACA,cACA,oBACR;AAAA,IAHQ;AAAA,IACA;AAAA,IACA;AAAA;AAAA,EAUV,OAAO,CAAC,SAAwB,UAA0B,CAAC,GAAS;AAAA,IAClE;AAAA,MACE,WAAW;AAAA,MACX,gBAAgB;AAAA,MAChB,iBAAiB;AAAA,QACf;AAAA,IAGJ,QAAQ,QAAQ;AAAA,IAGhB,IAAI,QAAQ,sBAAsB;AAAA,MAChC,KAAK,kBAAkB,uBACrB,QAAQ,2BAA2B,SAAS,KAC1C,uCAA0B,CAC9B;AAAA,MAGA,IAAI,UAAU;AAAA,QACZ,MAAM,aAAa,KAAK,mBAAmB;AAAA,QAE3C,IAAI,CAAC,WAAW,OAAO;AAAA,UAErB,QAAQ,KAAK;AAAA,UACb,KAAK,kBAAkB,uBACrB,QAAQ,2BAA2B,MAAM,KACvC,uCAA0B,CAC9B;AAAA,UACA,MAAM,IAAI,qBAAqB,WAAW,MAAM;AAAA,QAClD;AAAA,MACF;AAAA,IACF;AAAA,IAGA,IAAI,CAAC,eAAe;AAAA,MAClB,KAAK,UAAU,KAAK,OAAO;AAAA,MAE3B,KAAK,YAAY,CAAC;AAAA,IACpB;AAAA,IAGA,MAAM,SAAS,QAAQ,SAAS;AAAA,IAChC,OAAO,YAAY,KAAK,IAAI;AAAA,IAC5B,KAAK,UAAU,KAAK,MAAM;AAAA,IAG1B,IAAI,CAAC,gBAAgB;AAAA,MACnB,KAAK,aAAa,WAAW;AAAA,IAC/B;AAAA;AAAA,EAQF,IAAI,GAAY;AAAA,IACd,MAAM,UAAU,KAAK,UAAU,IAAI;AAAA,IACnC,IAAI,CAAC,SAAS;AAAA,MACZ,OAAO;AAAA,IACT;AAAA,IAEA,QAAQ,KAAK;AAAA,IAEb,IAAI,QAAQ,sBAAsB;AAAA,MAChC,KAAK,kBAAkB,uBACrB,QAAQ,2BAA2B,MAAM,KACvC,uCAA0B,CAC9B;AAAA,IACF;AAAA,IAEA,KAAK,UAAU,KAAK,OAAO;AAAA,IAC3B,KAAK,aAAa,WAAW;AAAA,IAE7B,OAAO;AAAA;AAAA,EAQT,IAAI,GAAY;AAAA,IACd,MAAM,UAAU,KAAK,UAAU,IAAI;AAAA,IACnC,IAAI,CAAC,SAAS;AAAA,MACZ,OAAO;AAAA,IACT;AAAA,IAEA,QAAQ,QAAQ;AAAA,IAEhB,IAAI,QAAQ,sBAAsB;AAAA,MAChC,KAAK,kBAAkB,uBACrB,QAAQ,2BAA2B,SAAS,KAC1C,uCAA0B,CAC9B;AAAA,IACF;AAAA,IAEA,KAAK,UAAU,KAAK,OAAO;AAAA,IAC3B,KAAK,aAAa,WAAW;AAAA,IAE7B,OAAO;AAAA;AAAA,EAMT,OAAO,GAAY;AAAA,IACjB,OAAO,KAAK,UAAU,SAAS;AAAA;AAAA,EAMjC,OAAO,GAAY;AAAA,IACjB,OAAO,KAAK,UAAU,SAAS;AAAA;AAAA,EAMjC,YAAY,GAAmB;AAAA,IAC7B,OAAO,CAAC,GAAG,KAAK,SAAS;AAAA;AAAA,EAM3B,cAAc,GAAS;AAAA,IACrB,KAAK,YAAY,CAAC;AAAA;AAAA,EAMpB,YAAY,GAAS;AAAA,IACnB,KAAK,YAAY,CAAC;AAAA,IAClB,KAAK,YAAY,CAAC;AAAA;AAAA,EAMpB,gBAAgB,GAAW;AAAA,IACzB,OAAO,KAAK,UAAU;AAAA;AAAA,EAMxB,gBAAgB,GAAW;AAAA,IACzB,OAAO,KAAK,UAAU;AAAA;AAE1B;",
|
|
8
|
-
"debugId": "43DC9858A49109E564756E2164756E21",
|
|
9
|
-
"names": []
|
|
10
|
-
}
|