@ricsam/formula-engine 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/cjs/core/engine.cjs +62 -2
  2. package/dist/cjs/core/engine.cjs.map +3 -3
  3. package/dist/cjs/core/managers/dependency-manager.cjs +32 -39
  4. package/dist/cjs/core/managers/dependency-manager.cjs.map +3 -3
  5. package/dist/cjs/core/managers/evaluation-manager.cjs +31 -34
  6. package/dist/cjs/core/managers/evaluation-manager.cjs.map +3 -3
  7. package/dist/cjs/core/managers/style-manager.cjs +341 -0
  8. package/dist/cjs/core/managers/style-manager.cjs.map +10 -0
  9. package/dist/cjs/core/types.cjs.map +1 -1
  10. package/dist/cjs/core/utils/color-utils.cjs +137 -0
  11. package/dist/cjs/core/utils/color-utils.cjs.map +10 -0
  12. package/dist/cjs/evaluator/dependency-nodes/virtual-cell-value-node.cjs +55 -0
  13. package/dist/cjs/evaluator/dependency-nodes/virtual-cell-value-node.cjs.map +10 -0
  14. package/dist/cjs/evaluator/formula-evaluator.cjs +3 -3
  15. package/dist/cjs/evaluator/formula-evaluator.cjs.map +3 -3
  16. package/dist/cjs/functions/{index.cjs → function-registry.cjs} +5 -5
  17. package/dist/cjs/functions/{index.cjs.map → function-registry.cjs.map} +2 -2
  18. package/dist/cjs/package.json +1 -1
  19. package/dist/mjs/core/engine.mjs +62 -2
  20. package/dist/mjs/core/engine.mjs.map +3 -3
  21. package/dist/mjs/core/managers/dependency-manager.mjs +37 -41
  22. package/dist/mjs/core/managers/dependency-manager.mjs.map +3 -3
  23. package/dist/mjs/core/managers/evaluation-manager.mjs +31 -34
  24. package/dist/mjs/core/managers/evaluation-manager.mjs.map +3 -3
  25. package/dist/mjs/core/managers/style-manager.mjs +315 -0
  26. package/dist/mjs/core/managers/style-manager.mjs.map +10 -0
  27. package/dist/mjs/core/types.mjs.map +1 -1
  28. package/dist/mjs/core/utils/color-utils.mjs +107 -0
  29. package/dist/mjs/core/utils/color-utils.mjs.map +10 -0
  30. package/dist/mjs/evaluator/dependency-nodes/virtual-cell-value-node.mjs +25 -0
  31. package/dist/mjs/evaluator/dependency-nodes/virtual-cell-value-node.mjs.map +10 -0
  32. package/dist/mjs/evaluator/formula-evaluator.mjs +2 -2
  33. package/dist/mjs/evaluator/formula-evaluator.mjs.map +2 -2
  34. package/dist/mjs/functions/{index.mjs → function-registry.mjs} +2 -2
  35. package/dist/mjs/functions/{index.mjs.map → function-registry.mjs.map} +2 -2
  36. package/dist/mjs/package.json +1 -1
  37. package/dist/types/core/engine.d.ts +39 -1
  38. package/dist/types/core/managers/dependency-manager.d.ts +8 -7
  39. package/dist/types/core/managers/evaluation-manager.d.ts +13 -3
  40. package/dist/types/core/managers/style-manager.d.ts +92 -0
  41. package/dist/types/core/types.d.ts +42 -0
  42. package/dist/types/core/utils/color-utils.d.ts +32 -0
  43. package/dist/types/evaluator/dependency-nodes/virtual-cell-value-node.d.ts +11 -0
  44. package/package.json +1 -1
  45. /package/dist/types/functions/{index.d.ts → function-registry.d.ts} +0 -0
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/core/engine.ts"],
4
4
  "sourcesContent": [
5
- "/**\n * Main FormulaEngine class\n * Core API implementation for spreadsheet calculations\n */\n\nimport {\n type CellAddress,\n type NamedExpression,\n type RangeAddress,\n type SerializedCellValue,\n type SingleEvaluationResult,\n type SpreadsheetRange,\n type SpreadsheetRangeEnd,\n type TableDefinition,\n} from \"./types.mjs\";\n\nimport type { FillDirection } from \"@ricsam/selection-manager\";\nimport { FormulaEvaluator } from \"../evaluator/formula-evaluator.mjs\";\nimport { AutoFill } from \"./autofill-utils.mjs\";\nimport { WorkbookManager } from \"./managers/workbook-manager.mjs\";\nimport { deserialize, serialize } from \"./map-serializer.mjs\";\nimport { renameNamedExpressionInFormula } from \"./named-expression-renamer.mjs\";\nimport { renameSheetInFormula } from \"./sheet-renamer.mjs\";\nimport { renameTableInFormula } from \"./table-renamer.mjs\";\nimport { renameWorkbookInFormula } from \"./workbook-renamer.mjs\";\nimport { cellAddressToKey, keyToCellAddress } from \"./utils.mjs\";\nimport { CacheManager } from \"./managers/cache-manager.mjs\";\nimport { NamedExpressionManager } from \"./managers/named-expression-manager.mjs\";\nimport { TableManager } from \"./managers/table-manager.mjs\";\nimport { EventManager } from \"./managers/event-manager.mjs\";\nimport { EvaluationManager } from \"./managers/evaluation-manager.mjs\";\nimport { DependencyManager } from \"./managers/dependency-manager.mjs\";\n\n/**\n * Main FormulaEngine class\n */\nexport class FormulaEngine {\n private workbookManager: WorkbookManager;\n private namedExpressionManager: NamedExpressionManager;\n private tableManager: TableManager;\n private eventManager: EventManager;\n private evaluationManager: EvaluationManager;\n private autoFillManager: AutoFill;\n private dependencyManager: DependencyManager;\n\n /**\n * Public access to the store manager for testing\n */\n public _workbookManager: WorkbookManager;\n public _namedExpressionManager: NamedExpressionManager;\n public _tableManager: TableManager;\n public _eventManager: EventManager;\n public _evaluationManager: EvaluationManager;\n public _autoFillManager: AutoFill;\n public _dependencyManager: DependencyManager;\n\n constructor() {\n this.eventManager = new EventManager();\n this.workbookManager = new WorkbookManager();\n this.namedExpressionManager = new NamedExpressionManager();\n this.tableManager = new TableManager(this.workbookManager);\n const cacheManager = new CacheManager();\n this.dependencyManager = new DependencyManager(\n cacheManager,\n this.workbookManager\n );\n\n const formulaEvaluator = new FormulaEvaluator(\n this.tableManager,\n this.dependencyManager,\n this.namedExpressionManager,\n );\n\n this.evaluationManager = new EvaluationManager(\n this.workbookManager,\n this.tableManager,\n formulaEvaluator,\n this.dependencyManager\n );\n\n this.autoFillManager = new AutoFill(this.workbookManager, this);\n\n this._workbookManager = this.workbookManager;\n this._namedExpressionManager = this.namedExpressionManager;\n this._tableManager = this.tableManager;\n this._eventManager = this.eventManager;\n this._evaluationManager = this.evaluationManager;\n this._autoFillManager = this.autoFillManager;\n this._dependencyManager = this.dependencyManager;\n }\n\n /**\n * Static factory method to build an empty engine\n */\n static buildEmpty(): FormulaEngine {\n return new FormulaEngine();\n }\n\n //#region Cell\n getCellEvaluationResult(\n cellAddress: CellAddress\n ): SingleEvaluationResult | undefined {\n return this.evaluationManager.getCellEvaluationResult(cellAddress);\n }\n\n getCellValue(cellAddress: CellAddress, debug?: boolean): SerializedCellValue {\n const result = this.getCellEvaluationResult(cellAddress);\n if (!result) {\n return \"\";\n }\n\n return this.evaluationManager.evaluationResultToSerializedValue(\n result,\n cellAddress,\n debug\n );\n }\n\n getCellDependents(\n address: CellAddress | SpreadsheetRange\n ): (SpreadsheetRange | CellAddress)[] {\n throw new Error(\"Not implemented\");\n }\n\n getCellPrecedents(\n address: CellAddress | SpreadsheetRange\n ): (SpreadsheetRange | CellAddress)[] {\n throw new Error(\"Not implemented\");\n }\n\n //#endregion\n\n //#region Named Expressions\n addNamedExpression({\n expression,\n expressionName,\n sheetName,\n workbookName,\n }: {\n expression: string;\n expressionName: string;\n sheetName?: string;\n workbookName?: string;\n }) {\n this.namedExpressionManager.addNamedExpression({\n expression,\n expressionName,\n sheetName,\n workbookName,\n });\n\n // Re-evaluate all sheets since named expressions can be referenced from anywhere\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n\n removeNamedExpression({\n expressionName,\n sheetName,\n workbookName,\n }: {\n expressionName: string;\n sheetName?: string;\n workbookName?: string;\n }) {\n const found = this.namedExpressionManager.removeNamedExpression({\n expressionName,\n sheetName,\n workbookName,\n });\n\n if (found) {\n // Re-evaluate all sheets since named expressions can be referenced from anywhere\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n\n return found;\n }\n\n updateNamedExpression({\n expression,\n expressionName,\n sheetName,\n workbookName,\n }: {\n expression: string;\n expressionName: string;\n sheetName?: string;\n workbookName?: string;\n }) {\n this.namedExpressionManager.updateNamedExpression({\n expression,\n expressionName,\n sheetName,\n workbookName,\n });\n\n // Re-evaluate all sheets since named expressions can be referenced from anywhere\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n\n renameNamedExpression({\n expressionName,\n sheetName,\n workbookName,\n newName,\n }: {\n expressionName: string;\n sheetName?: string;\n workbookName?: string;\n newName: string;\n }) {\n const result = this.namedExpressionManager.renameNamedExpression({\n expressionName,\n sheetName,\n workbookName,\n newName,\n });\n\n // Update all formulas that reference this named expression in sheet cells\n this.workbookManager.updateAllFormulas((formula) =>\n renameNamedExpressionInFormula(formula, expressionName, newName)\n );\n\n // Update named expressions that reference this named expression\n this.namedExpressionManager.updateAllNamedExpressions((formula) =>\n renameNamedExpressionInFormula(formula, expressionName, newName)\n );\n\n // Re-evaluate all sheets since named expressions can be referenced from anywhere\n this.reevaluate();\n this.eventManager.emitUpdate();\n\n return result;\n }\n\n setNamedExpressions(\n opts: (\n | {\n type: \"global\";\n }\n | {\n type: \"sheet\";\n sheetName: string;\n workbookName: string;\n }\n | {\n type: \"workbook\";\n workbookName: string;\n }\n ) & {\n expressions: Map<string, NamedExpression>;\n }\n ) {\n this.namedExpressionManager.setNamedExpressions(opts);\n\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n //#endregion\n\n //#region Tables\n addTable(props: {\n tableName: string;\n sheetName: string;\n workbookName: string;\n start: string;\n numRows: SpreadsheetRangeEnd;\n numCols: number;\n }) {\n const table = this.tableManager.addTable({\n ...props,\n getCellValue: (cellAddress: CellAddress) =>\n this.getCellValue(cellAddress),\n });\n\n // Re-evaluate all sheets since structured references might depend on this table\n this.reevaluate();\n this.eventManager.emitUpdate();\n\n return table;\n }\n\n renameTable(\n workbookName: string,\n names: { oldName: string; newName: string }\n ) {\n this.tableManager.renameTable(workbookName, names);\n\n // Update all formulas that reference this table in sheet cells\n this.workbookManager.updateAllFormulas((formula) =>\n renameTableInFormula(formula, names.oldName, names.newName)\n );\n\n // Update named expressions that reference this table\n this.namedExpressionManager.updateAllNamedExpressions((formula) =>\n renameTableInFormula(formula, names.oldName, names.newName)\n );\n\n // Re-evaluate all sheets since structured references might depend on this table\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n\n updateTable(opts: {\n tableName: string;\n sheetName?: string;\n start?: string;\n numRows?: SpreadsheetRangeEnd;\n numCols?: number;\n workbookName: string;\n }) {\n this.tableManager.updateTable({\n ...opts,\n getCellValue: (cellAddress: CellAddress) =>\n this.getCellValue(cellAddress),\n });\n\n // Re-evaluate all sheets since structured references might depend on this table\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n\n removeTable(opts: { tableName: string; workbookName: string }) {\n const found = this.tableManager.removeTable(opts);\n\n if (found) {\n // Re-evaluate all sheets since structured references might depend on this table\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n\n return found;\n }\n\n resetTables(tables: Map<string, Map<string, TableDefinition>>) {\n this.tableManager.resetTables(tables);\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n\n getTables(workbookName: string) {\n return this.tableManager.getTables(workbookName);\n }\n\n isCellInTable(cellAddress: CellAddress): TableDefinition | undefined {\n return this.tableManager.isCellInTable(cellAddress);\n }\n\n //#endregion\n\n //#region Sheets\n addSheet(opts: { workbookName: string; sheetName: string }) {\n const newSheet = this.workbookManager.addSheet(opts);\n const wbLevel = this.namedExpressionManager.addSheet(opts);\n this.reevaluate();\n this.eventManager.emitUpdate();\n return newSheet;\n }\n\n removeSheet(opts: { workbookName: string; sheetName: string }) {\n const sheet = this.workbookManager.removeSheet(opts);\n\n // Clean up related data\n this.namedExpressionManager.removeSheet(opts);\n this.tableManager.removeSheet(opts);\n\n // Add engine-specific logic: re-evaluate since references might be affected\n this.reevaluate();\n this.eventManager.emitUpdate();\n\n return sheet;\n }\n\n renameSheet(opts: {\n sheetName: string;\n newSheetName: string;\n workbookName: string;\n }) {\n const sheet = this.workbookManager.renameSheet(opts);\n\n // Update scoped named expressions\n this.namedExpressionManager.renameSheet(opts);\n\n // Update tables that belong to the renamed sheet\n this.tableManager.updateTablesForSheetRename(opts);\n\n // Update all formulas that reference this sheet\n this.workbookManager.updateAllFormulas((formula) =>\n renameSheetInFormula({\n formula,\n oldSheetName: opts.sheetName,\n newSheetName: opts.newSheetName,\n })\n );\n\n // Add engine-specific logic: re-evaluate since references might be affected\n this.reevaluate();\n this.eventManager.emitUpdate();\n\n return sheet;\n }\n\n getSheets(workbookName: string) {\n return this.workbookManager.getSheets(workbookName);\n }\n\n getSheet({\n workbookName,\n sheetName,\n }: {\n workbookName: string;\n sheetName: string;\n }) {\n return this.workbookManager.getSheet({ workbookName, sheetName });\n }\n\n getSheetSerialized(opts: {\n sheetName: string;\n workbookName: string;\n }): Map<string, SerializedCellValue> {\n return this.workbookManager.getSheetSerialized(opts);\n }\n\n //#endregion\n\n //#region Workbook\n addWorkbook(workbookName: string) {\n this.workbookManager.addWorkbook(workbookName);\n this.namedExpressionManager.addWorkbook(workbookName);\n this.tableManager.addWorkbook(workbookName);\n\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n\n removeWorkbook(workbookName: string) {\n this.workbookManager.removeWorkbook(workbookName);\n this.namedExpressionManager.removeWorkbook(workbookName);\n this.tableManager.removeWorkbook(workbookName);\n\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n\n cloneWorkbook(fromWorkbookName: string, toWorkbookName: string) {\n // Check if source workbook exists\n const sourceWorkbook = this.workbookManager\n .getWorkbooks()\n .get(fromWorkbookName);\n if (!sourceWorkbook) {\n throw new Error(`Source workbook \"${fromWorkbookName}\" not found`);\n }\n\n // Check if target workbook name already exists\n if (this.workbookManager.getWorkbooks().has(toWorkbookName)) {\n throw new Error(`Target workbook \"${toWorkbookName}\" already exists`);\n }\n\n // Create new workbook\n this.addWorkbook(toWorkbookName);\n\n // Clone all sheets from source workbook\n for (const [sheetName, sheet] of sourceWorkbook.sheets) {\n // Add sheet to target workbook\n this.addSheet({\n workbookName: toWorkbookName,\n sheetName: sheetName,\n });\n\n // Copy all cell content using setSheetContent for efficiency\n this.setSheetContent(\n {\n workbookName: toWorkbookName,\n sheetName: sheetName,\n },\n new Map(sheet.content)\n );\n }\n\n // Clone workbook-scoped named expressions\n const sourceWorkbookExpressions = this.namedExpressionManager\n .getNamedExpressions()\n .workbookExpressions.get(fromWorkbookName);\n if (sourceWorkbookExpressions) {\n for (const [name, expression] of sourceWorkbookExpressions) {\n this.addNamedExpression({\n expressionName: name,\n expression: expression.expression,\n workbookName: toWorkbookName,\n });\n }\n }\n\n // Clone sheet-scoped named expressions\n const sourceSheetExpressions = this.namedExpressionManager\n .getNamedExpressions()\n .sheetExpressions.get(fromWorkbookName);\n if (sourceSheetExpressions) {\n for (const [sheetName, sheetExpressions] of sourceSheetExpressions) {\n for (const [name, expression] of sheetExpressions) {\n this.addNamedExpression({\n expressionName: name,\n expression: expression.expression,\n workbookName: toWorkbookName,\n sheetName: sheetName,\n });\n }\n }\n }\n\n // Clone tables\n const sourceTables = this.tableManager.tables.get(fromWorkbookName);\n if (sourceTables) {\n for (const [tableName, table] of sourceTables) {\n this.tableManager.copyTable(\n {\n workbookName: fromWorkbookName,\n tableName: tableName,\n },\n {\n workbookName: toWorkbookName,\n tableName: tableName,\n }\n );\n }\n }\n\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n\n renameWorkbook(opts: { workbookName: string; newWorkbookName: string }) {\n this.workbookManager.renameWorkbook(opts);\n\n // Update scoped named expressions\n this.namedExpressionManager.renameWorkbook(opts);\n\n // Update tables that belong to the renamed sheet\n this.tableManager.updateTablesForWorkbookRename(opts);\n\n // Update all formulas that reference this workbook\n this.workbookManager.updateAllFormulas((formula) =>\n renameWorkbookInFormula({\n formula,\n oldWorkbookName: opts.workbookName,\n newWorkbookName: opts.newWorkbookName,\n })\n );\n\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n\n getWorkbooks() {\n return this.workbookManager.getWorkbooks();\n }\n //#endregion\n\n //#region CRUD Operations\n /**\n * Overrides the content of a sheet.\n * @param sheetName - The name of the sheet to set the content of\n * @param content - A map of cell addresses to their serialized values\n * @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.\n */\n setSheetContent(\n opts: { sheetName: string; workbookName: string },\n content: Map<string, SerializedCellValue>\n ) {\n this.workbookManager.setSheetContent(opts, content);\n\n // Re-evaluate all sheets to ensure all dependencies are resolved correctly\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n\n setCellContent(address: CellAddress, content: SerializedCellValue) {\n this.workbookManager.setCellContent(address, content);\n\n // Re-evaluate all sheets to ensure all dependencies are resolved correctly\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n //#endregion\n\n //#region Evaluation\n\n /**\n * Re-evaluates all sheets to ensure all dependencies are resolved correctly\n *\n * but just clears the evaluation cache\n */\n reevaluate() {\n this.evaluationManager.clearEvaluationCache();\n }\n //#endregion\n\n //#region Auto-fill\n /**\n * Auto-fills the fillRange based on the seedRange and the direction.\n */\n autoFill(\n opts: { sheetName: string; workbookName: string },\n /**\n * The user's original selection that defines the pattern/series.\n */\n seedRange: SpreadsheetRange,\n /**\n * the new cells populated by the drag, excluding the seed\n */\n fillRange: SpreadsheetRange,\n /**\n * The direction of the fill.\n */\n direction: FillDirection\n ) {\n this.autoFillManager.fill(opts, seedRange, fillRange, direction);\n }\n\n /**\n * Removes the content in the spreadsheet that is inside the range.\n */\n clearSpreadsheetRange(address: RangeAddress) {\n this.workbookManager.clearSpreadsheetRange(address);\n\n // Re-evaluate all sheets to ensure all dependencies are resolved correctly\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n //#endregion\n\n //#region State - UI library integration\n getState() {\n return {\n workbooks: this.workbookManager.getWorkbooks(),\n namedExpressions: this.namedExpressionManager.getNamedExpressions(),\n tables: this.tableManager.tables,\n };\n }\n\n onUpdate(listener: () => void) {\n return this.eventManager.onUpdate(listener);\n }\n\n serializeEngine(): string {\n return serialize(this.getState());\n }\n\n resetToSerializedEngine(data: string) {\n const deserialized = deserialize(data) as ReturnType<typeof this.getState>;\n\n this.workbookManager.resetWorkbooks(deserialized.workbooks);\n\n deserialized.workbooks.forEach((workbook) => {\n this.namedExpressionManager.addWorkbook(workbook.name);\n this.tableManager.addWorkbook(workbook.name);\n workbook.sheets.forEach((sheet) => {\n this.namedExpressionManager.addSheet({\n workbookName: workbook.name,\n sheetName: sheet.name,\n });\n });\n });\n\n this.namedExpressionManager.resetNamedExpressions(\n deserialized.namedExpressions\n );\n this.tableManager.resetTables(deserialized.tables);\n\n // Re-evaluate all sheets to ensure all dependencies are resolved correctly\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n //#endregion\n}\n"
5
+ "/**\n * Main FormulaEngine class\n * Core API implementation for spreadsheet calculations\n */\n\nimport {\n type CellAddress,\n type CellStyle,\n type ConditionalStyle,\n type DirectCellStyle,\n type NamedExpression,\n type RangeAddress,\n type SerializedCellValue,\n type SingleEvaluationResult,\n type SpreadsheetRange,\n type SpreadsheetRangeEnd,\n type TableDefinition,\n} from \"./types.mjs\";\n\nimport type { FillDirection } from \"@ricsam/selection-manager\";\nimport { FormulaEvaluator } from \"../evaluator/formula-evaluator.mjs\";\nimport { AutoFill } from \"./autofill-utils.mjs\";\nimport { WorkbookManager } from \"./managers/workbook-manager.mjs\";\nimport { deserialize, serialize } from \"./map-serializer.mjs\";\nimport { renameNamedExpressionInFormula } from \"./named-expression-renamer.mjs\";\nimport { renameSheetInFormula } from \"./sheet-renamer.mjs\";\nimport { renameTableInFormula } from \"./table-renamer.mjs\";\nimport { renameWorkbookInFormula } from \"./workbook-renamer.mjs\";\nimport { cellAddressToKey, keyToCellAddress } from \"./utils.mjs\";\nimport { CacheManager } from \"./managers/cache-manager.mjs\";\nimport { NamedExpressionManager } from \"./managers/named-expression-manager.mjs\";\nimport { TableManager } from \"./managers/table-manager.mjs\";\nimport { EventManager } from \"./managers/event-manager.mjs\";\nimport { EvaluationManager } from \"./managers/evaluation-manager.mjs\";\nimport { DependencyManager } from \"./managers/dependency-manager.mjs\";\nimport { StyleManager } from \"./managers/style-manager.mjs\";\n\n/**\n * Main FormulaEngine class\n */\nexport class FormulaEngine {\n private workbookManager: WorkbookManager;\n private namedExpressionManager: NamedExpressionManager;\n private tableManager: TableManager;\n private eventManager: EventManager;\n private evaluationManager: EvaluationManager;\n private autoFillManager: AutoFill;\n private dependencyManager: DependencyManager;\n private styleManager: StyleManager;\n\n /**\n * Public access to the store manager for testing\n */\n public _workbookManager: WorkbookManager;\n public _namedExpressionManager: NamedExpressionManager;\n public _tableManager: TableManager;\n public _eventManager: EventManager;\n public _evaluationManager: EvaluationManager;\n public _autoFillManager: AutoFill;\n public _dependencyManager: DependencyManager;\n public _styleManager: StyleManager;\n\n constructor() {\n this.eventManager = new EventManager();\n this.workbookManager = new WorkbookManager();\n this.namedExpressionManager = new NamedExpressionManager();\n this.tableManager = new TableManager(this.workbookManager);\n const cacheManager = new CacheManager();\n this.dependencyManager = new DependencyManager(\n cacheManager,\n this.workbookManager\n );\n\n const formulaEvaluator = new FormulaEvaluator(\n this.tableManager,\n this.dependencyManager,\n this.namedExpressionManager,\n );\n\n this.evaluationManager = new EvaluationManager(\n this.workbookManager,\n this.tableManager,\n formulaEvaluator,\n this.dependencyManager\n );\n\n this.styleManager = new StyleManager(\n this.workbookManager,\n this.evaluationManager\n );\n\n this.autoFillManager = new AutoFill(this.workbookManager, this);\n\n this._workbookManager = this.workbookManager;\n this._namedExpressionManager = this.namedExpressionManager;\n this._tableManager = this.tableManager;\n this._eventManager = this.eventManager;\n this._evaluationManager = this.evaluationManager;\n this._autoFillManager = this.autoFillManager;\n this._dependencyManager = this.dependencyManager;\n this._styleManager = this.styleManager;\n }\n\n /**\n * Static factory method to build an empty engine\n */\n static buildEmpty(): FormulaEngine {\n return new FormulaEngine();\n }\n\n //#region Cell\n getCellEvaluationResult(\n cellAddress: CellAddress\n ): SingleEvaluationResult | undefined {\n return this.evaluationManager.getCellEvaluationResult(cellAddress);\n }\n\n getCellValue(cellAddress: CellAddress, debug?: boolean): SerializedCellValue {\n const result = this.getCellEvaluationResult(cellAddress);\n if (!result) {\n return \"\";\n }\n\n return this.evaluationManager.evaluationResultToSerializedValue(\n result,\n cellAddress,\n debug\n );\n }\n\n evaluateFormula(\n /**\n * formula without the leading = sign\n */\n formula: string, cellAddress: CellAddress): SerializedCellValue {\n return this.evaluationManager.evaluateFormula(formula, cellAddress);\n }\n\n getCellDependents(\n address: CellAddress | SpreadsheetRange\n ): (SpreadsheetRange | CellAddress)[] {\n throw new Error(\"Not implemented\");\n }\n\n getCellPrecedents(\n address: CellAddress | SpreadsheetRange\n ): (SpreadsheetRange | CellAddress)[] {\n throw new Error(\"Not implemented\");\n }\n\n //#endregion\n\n //#region Named Expressions\n addNamedExpression({\n expression,\n expressionName,\n sheetName,\n workbookName,\n }: {\n expression: string;\n expressionName: string;\n sheetName?: string;\n workbookName?: string;\n }) {\n this.namedExpressionManager.addNamedExpression({\n expression,\n expressionName,\n sheetName,\n workbookName,\n });\n\n // Re-evaluate all sheets since named expressions can be referenced from anywhere\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n\n removeNamedExpression({\n expressionName,\n sheetName,\n workbookName,\n }: {\n expressionName: string;\n sheetName?: string;\n workbookName?: string;\n }) {\n const found = this.namedExpressionManager.removeNamedExpression({\n expressionName,\n sheetName,\n workbookName,\n });\n\n if (found) {\n // Re-evaluate all sheets since named expressions can be referenced from anywhere\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n\n return found;\n }\n\n updateNamedExpression({\n expression,\n expressionName,\n sheetName,\n workbookName,\n }: {\n expression: string;\n expressionName: string;\n sheetName?: string;\n workbookName?: string;\n }) {\n this.namedExpressionManager.updateNamedExpression({\n expression,\n expressionName,\n sheetName,\n workbookName,\n });\n\n // Re-evaluate all sheets since named expressions can be referenced from anywhere\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n\n renameNamedExpression({\n expressionName,\n sheetName,\n workbookName,\n newName,\n }: {\n expressionName: string;\n sheetName?: string;\n workbookName?: string;\n newName: string;\n }) {\n const result = this.namedExpressionManager.renameNamedExpression({\n expressionName,\n sheetName,\n workbookName,\n newName,\n });\n\n // Update all formulas that reference this named expression in sheet cells\n this.workbookManager.updateAllFormulas((formula) =>\n renameNamedExpressionInFormula(formula, expressionName, newName)\n );\n\n // Update named expressions that reference this named expression\n this.namedExpressionManager.updateAllNamedExpressions((formula) =>\n renameNamedExpressionInFormula(formula, expressionName, newName)\n );\n\n // Re-evaluate all sheets since named expressions can be referenced from anywhere\n this.reevaluate();\n this.eventManager.emitUpdate();\n\n return result;\n }\n\n setNamedExpressions(\n opts: (\n | {\n type: \"global\";\n }\n | {\n type: \"sheet\";\n sheetName: string;\n workbookName: string;\n }\n | {\n type: \"workbook\";\n workbookName: string;\n }\n ) & {\n expressions: Map<string, NamedExpression>;\n }\n ) {\n this.namedExpressionManager.setNamedExpressions(opts);\n\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n //#endregion\n\n //#region Tables\n addTable(props: {\n tableName: string;\n sheetName: string;\n workbookName: string;\n start: string;\n numRows: SpreadsheetRangeEnd;\n numCols: number;\n }) {\n const table = this.tableManager.addTable({\n ...props,\n getCellValue: (cellAddress: CellAddress) =>\n this.getCellValue(cellAddress),\n });\n\n // Re-evaluate all sheets since structured references might depend on this table\n this.reevaluate();\n this.eventManager.emitUpdate();\n\n return table;\n }\n\n renameTable(\n workbookName: string,\n names: { oldName: string; newName: string }\n ) {\n this.tableManager.renameTable(workbookName, names);\n\n // Update all formulas that reference this table in sheet cells\n this.workbookManager.updateAllFormulas((formula) =>\n renameTableInFormula(formula, names.oldName, names.newName)\n );\n\n // Update named expressions that reference this table\n this.namedExpressionManager.updateAllNamedExpressions((formula) =>\n renameTableInFormula(formula, names.oldName, names.newName)\n );\n\n // Re-evaluate all sheets since structured references might depend on this table\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n\n updateTable(opts: {\n tableName: string;\n sheetName?: string;\n start?: string;\n numRows?: SpreadsheetRangeEnd;\n numCols?: number;\n workbookName: string;\n }) {\n this.tableManager.updateTable({\n ...opts,\n getCellValue: (cellAddress: CellAddress) =>\n this.getCellValue(cellAddress),\n });\n\n // Re-evaluate all sheets since structured references might depend on this table\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n\n removeTable(opts: { tableName: string; workbookName: string }) {\n const found = this.tableManager.removeTable(opts);\n\n if (found) {\n // Re-evaluate all sheets since structured references might depend on this table\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n\n return found;\n }\n\n resetTables(tables: Map<string, Map<string, TableDefinition>>) {\n this.tableManager.resetTables(tables);\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n\n getTables(workbookName: string) {\n return this.tableManager.getTables(workbookName);\n }\n\n isCellInTable(cellAddress: CellAddress): TableDefinition | undefined {\n return this.tableManager.isCellInTable(cellAddress);\n }\n\n //#endregion\n\n //#region Conditional Styling\n /**\n * Add a conditional style rule\n */\n addConditionalStyle(style: ConditionalStyle): void {\n this.styleManager.addConditionalStyle(style);\n this.eventManager.emitUpdate();\n }\n\n /**\n * Remove a conditional style rule by index\n */\n removeConditionalStyle(workbookName: string, index: number): boolean {\n const removed = this.styleManager.removeConditionalStyle(workbookName, index);\n if (removed) {\n this.eventManager.emitUpdate();\n }\n return removed;\n }\n\n /**\n * Get all conditional styles for a workbook\n */\n getConditionalStyles(workbookName: string): ConditionalStyle[] {\n return this.styleManager.getConditionalStyles(workbookName);\n }\n\n /**\n * Get the computed style for a specific cell\n */\n getCellStyle(cellAddress: CellAddress): CellStyle | undefined {\n return this.styleManager.getCellStyle(cellAddress);\n }\n\n /**\n * Add a direct cell style rule\n */\n addCellStyle(style: DirectCellStyle): void {\n this.styleManager.addCellStyle(style);\n this.eventManager.emitUpdate();\n }\n\n /**\n * Remove a direct cell style rule by index\n */\n removeCellStyle(workbookName: string, index: number): boolean {\n const removed = this.styleManager.removeCellStyle(workbookName, index);\n if (removed) {\n this.eventManager.emitUpdate();\n }\n return removed;\n }\n\n /**\n * Get all direct cell styles for a workbook\n */\n getCellStyles(workbookName: string): DirectCellStyle[] {\n return this.styleManager.getCellStyles(workbookName);\n }\n\n //#endregion\n\n //#region Sheets\n addSheet(opts: { workbookName: string; sheetName: string }) {\n const newSheet = this.workbookManager.addSheet(opts);\n const wbLevel = this.namedExpressionManager.addSheet(opts);\n this.reevaluate();\n this.eventManager.emitUpdate();\n return newSheet;\n }\n\n removeSheet(opts: { workbookName: string; sheetName: string }) {\n const sheet = this.workbookManager.removeSheet(opts);\n\n // Clean up related data\n this.namedExpressionManager.removeSheet(opts);\n this.tableManager.removeSheet(opts);\n this.styleManager.removeSheetStyles(opts.workbookName, opts.sheetName);\n\n // Add engine-specific logic: re-evaluate since references might be affected\n this.reevaluate();\n this.eventManager.emitUpdate();\n\n return sheet;\n }\n\n renameSheet(opts: {\n sheetName: string;\n newSheetName: string;\n workbookName: string;\n }) {\n const sheet = this.workbookManager.renameSheet(opts);\n\n // Update scoped named expressions\n this.namedExpressionManager.renameSheet(opts);\n\n // Update tables that belong to the renamed sheet\n this.tableManager.updateTablesForSheetRename(opts);\n\n // Update conditional styles that reference this sheet\n this.styleManager.updateSheetName(\n opts.workbookName,\n opts.sheetName,\n opts.newSheetName\n );\n\n // Update all formulas that reference this sheet\n this.workbookManager.updateAllFormulas((formula) =>\n renameSheetInFormula({\n formula,\n oldSheetName: opts.sheetName,\n newSheetName: opts.newSheetName,\n })\n );\n\n // Add engine-specific logic: re-evaluate since references might be affected\n this.reevaluate();\n this.eventManager.emitUpdate();\n\n return sheet;\n }\n\n getSheets(workbookName: string) {\n return this.workbookManager.getSheets(workbookName);\n }\n\n getSheet({\n workbookName,\n sheetName,\n }: {\n workbookName: string;\n sheetName: string;\n }) {\n return this.workbookManager.getSheet({ workbookName, sheetName });\n }\n\n getSheetSerialized(opts: {\n sheetName: string;\n workbookName: string;\n }): Map<string, SerializedCellValue> {\n return this.workbookManager.getSheetSerialized(opts);\n }\n\n //#endregion\n\n //#region Workbook\n addWorkbook(workbookName: string) {\n this.workbookManager.addWorkbook(workbookName);\n this.namedExpressionManager.addWorkbook(workbookName);\n this.tableManager.addWorkbook(workbookName);\n\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n\n removeWorkbook(workbookName: string) {\n this.workbookManager.removeWorkbook(workbookName);\n this.namedExpressionManager.removeWorkbook(workbookName);\n this.tableManager.removeWorkbook(workbookName);\n this.styleManager.removeWorkbookStyles(workbookName);\n\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n\n cloneWorkbook(fromWorkbookName: string, toWorkbookName: string) {\n // Check if source workbook exists\n const sourceWorkbook = this.workbookManager\n .getWorkbooks()\n .get(fromWorkbookName);\n if (!sourceWorkbook) {\n throw new Error(`Source workbook \"${fromWorkbookName}\" not found`);\n }\n\n // Check if target workbook name already exists\n if (this.workbookManager.getWorkbooks().has(toWorkbookName)) {\n throw new Error(`Target workbook \"${toWorkbookName}\" already exists`);\n }\n\n // Create new workbook\n this.addWorkbook(toWorkbookName);\n\n // Clone all sheets from source workbook\n for (const [sheetName, sheet] of sourceWorkbook.sheets) {\n // Add sheet to target workbook\n this.addSheet({\n workbookName: toWorkbookName,\n sheetName: sheetName,\n });\n\n // Copy all cell content using setSheetContent for efficiency\n this.setSheetContent(\n {\n workbookName: toWorkbookName,\n sheetName: sheetName,\n },\n new Map(sheet.content)\n );\n }\n\n // Clone workbook-scoped named expressions\n const sourceWorkbookExpressions = this.namedExpressionManager\n .getNamedExpressions()\n .workbookExpressions.get(fromWorkbookName);\n if (sourceWorkbookExpressions) {\n for (const [name, expression] of sourceWorkbookExpressions) {\n this.addNamedExpression({\n expressionName: name,\n expression: expression.expression,\n workbookName: toWorkbookName,\n });\n }\n }\n\n // Clone sheet-scoped named expressions\n const sourceSheetExpressions = this.namedExpressionManager\n .getNamedExpressions()\n .sheetExpressions.get(fromWorkbookName);\n if (sourceSheetExpressions) {\n for (const [sheetName, sheetExpressions] of sourceSheetExpressions) {\n for (const [name, expression] of sheetExpressions) {\n this.addNamedExpression({\n expressionName: name,\n expression: expression.expression,\n workbookName: toWorkbookName,\n sheetName: sheetName,\n });\n }\n }\n }\n\n // Clone tables\n const sourceTables = this.tableManager.tables.get(fromWorkbookName);\n if (sourceTables) {\n for (const [tableName, table] of sourceTables) {\n this.tableManager.copyTable(\n {\n workbookName: fromWorkbookName,\n tableName: tableName,\n },\n {\n workbookName: toWorkbookName,\n tableName: tableName,\n }\n );\n }\n }\n\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n\n renameWorkbook(opts: { workbookName: string; newWorkbookName: string }) {\n this.workbookManager.renameWorkbook(opts);\n\n // Update scoped named expressions\n this.namedExpressionManager.renameWorkbook(opts);\n\n // Update tables that belong to the renamed sheet\n this.tableManager.updateTablesForWorkbookRename(opts);\n\n // Update conditional styles that reference this workbook\n this.styleManager.updateWorkbookName(\n opts.workbookName,\n opts.newWorkbookName\n );\n\n // Update all formulas that reference this workbook\n this.workbookManager.updateAllFormulas((formula) =>\n renameWorkbookInFormula({\n formula,\n oldWorkbookName: opts.workbookName,\n newWorkbookName: opts.newWorkbookName,\n })\n );\n\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n\n getWorkbooks() {\n return this.workbookManager.getWorkbooks();\n }\n //#endregion\n\n //#region CRUD Operations\n /**\n * Overrides the content of a sheet.\n * @param sheetName - The name of the sheet to set the content of\n * @param content - A map of cell addresses to their serialized values\n * @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.\n */\n setSheetContent(\n opts: { sheetName: string; workbookName: string },\n content: Map<string, SerializedCellValue>\n ) {\n this.workbookManager.setSheetContent(opts, content);\n\n // Re-evaluate all sheets to ensure all dependencies are resolved correctly\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n\n setCellContent(address: CellAddress, content: SerializedCellValue) {\n this.workbookManager.setCellContent(address, content);\n\n // Re-evaluate all sheets to ensure all dependencies are resolved correctly\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n //#endregion\n\n //#region Evaluation\n\n /**\n * Re-evaluates all sheets to ensure all dependencies are resolved correctly\n *\n * but just clears the evaluation cache\n */\n reevaluate() {\n this.evaluationManager.clearEvaluationCache();\n }\n //#endregion\n\n //#region Auto-fill\n /**\n * Auto-fills the fillRange based on the seedRange and the direction.\n */\n autoFill(\n opts: { sheetName: string; workbookName: string },\n /**\n * The user's original selection that defines the pattern/series.\n */\n seedRange: SpreadsheetRange,\n /**\n * the new cells populated by the drag, excluding the seed\n */\n fillRange: SpreadsheetRange,\n /**\n * The direction of the fill.\n */\n direction: FillDirection\n ) {\n this.autoFillManager.fill(opts, seedRange, fillRange, direction);\n }\n\n /**\n * Removes the content in the spreadsheet that is inside the range.\n */\n clearSpreadsheetRange(address: RangeAddress) {\n this.workbookManager.clearSpreadsheetRange(address);\n\n // Re-evaluate all sheets to ensure all dependencies are resolved correctly\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n //#endregion\n\n //#region State - UI library integration\n getState() {\n return {\n workbooks: this.workbookManager.getWorkbooks(),\n namedExpressions: this.namedExpressionManager.getNamedExpressions(),\n tables: this.tableManager.tables,\n conditionalStyles: this.styleManager.getAllConditionalStyles(),\n cellStyles: this.styleManager.getAllCellStyles(),\n };\n }\n\n onUpdate(listener: () => void) {\n return this.eventManager.onUpdate(listener);\n }\n\n serializeEngine(): string {\n return serialize(this.getState());\n }\n\n resetToSerializedEngine(data: string) {\n const deserialized = deserialize(data) as ReturnType<typeof this.getState>;\n\n this.workbookManager.resetWorkbooks(deserialized.workbooks);\n\n deserialized.workbooks.forEach((workbook) => {\n this.namedExpressionManager.addWorkbook(workbook.name);\n this.tableManager.addWorkbook(workbook.name);\n workbook.sheets.forEach((sheet) => {\n this.namedExpressionManager.addSheet({\n workbookName: workbook.name,\n sheetName: sheet.name,\n });\n });\n });\n\n this.namedExpressionManager.resetNamedExpressions(\n deserialized.namedExpressions\n );\n this.tableManager.resetTables(deserialized.tables);\n \n // Reset styles if present\n // Handle backward compatibility: if conditionalStyles is a Map, convert it\n let conditionalStylesArray: ConditionalStyle[] | undefined;\n let cellStylesArray: DirectCellStyle[] | undefined;\n \n if (deserialized.conditionalStyles) {\n if (deserialized.conditionalStyles instanceof Map) {\n // Old format: Map<string, ConditionalStyle[]>\n conditionalStylesArray = Array.from(deserialized.conditionalStyles.values()).flat();\n } else if (Array.isArray(deserialized.conditionalStyles)) {\n // New format: ConditionalStyle[]\n conditionalStylesArray = deserialized.conditionalStyles;\n }\n }\n \n if (deserialized.cellStyles) {\n if (Array.isArray(deserialized.cellStyles)) {\n cellStylesArray = deserialized.cellStyles;\n }\n }\n \n this.styleManager.resetStyles(conditionalStylesArray, cellStylesArray);\n\n // Re-evaluate all sheets to ensure all dependencies are resolved correctly\n this.reevaluate();\n this.eventManager.emitUpdate();\n }\n //#endregion\n}\n"
6
6
  ],
7
- "mappings": ";AAiBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAA;AAKO,MAAM,cAAc;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAKD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEP,WAAW,GAAG;AAAA,IACZ,KAAK,eAAe,IAAI;AAAA,IACxB,KAAK,kBAAkB,IAAI;AAAA,IAC3B,KAAK,yBAAyB,IAAI;AAAA,IAClC,KAAK,eAAe,IAAI,aAAa,KAAK,eAAe;AAAA,IACzD,MAAM,eAAe,IAAI;AAAA,IACzB,KAAK,oBAAoB,IAAI,kBAC3B,cACA,KAAK,eACP;AAAA,IAEA,MAAM,mBAAmB,IAAI,iBAC3B,KAAK,cACL,KAAK,mBACL,KAAK,sBACP;AAAA,IAEA,KAAK,oBAAoB,IAAI,kBAC3B,KAAK,iBACL,KAAK,cACL,kBACA,KAAK,iBACP;AAAA,IAEA,KAAK,kBAAkB,IAAI,SAAS,KAAK,iBAAiB,IAAI;AAAA,IAE9D,KAAK,mBAAmB,KAAK;AAAA,IAC7B,KAAK,0BAA0B,KAAK;AAAA,IACpC,KAAK,gBAAgB,KAAK;AAAA,IAC1B,KAAK,gBAAg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,IAAI,aAAa,mBAAmB;AAAA,MAClC,IAAI,aAAa,6BAA6B,KAAK;AAAA,QAEjD,yBAAyB,MAAM,KAAK,aAAa,kBAAkB,OAAO,CAAC,EAAE,KAAK;AAAA,MACpF,EAAO,SAAI,MAAM,QAAQ,aAAa,iBAAiB,GAAG;AAAA,QAExD,yBAAyB,aAAa;AAAA,MACxC;AAAA,IACF;AAAA,IAEA,IAAI,aAAa,YAAY;AAAA,MAC3B,IAAI,MAAM,QAAQ,aAAa,UAAU,GAAG;AAAA,QAC1C,kBAAkB,aAAa;AAAA,MACjC;AAAA,IACF;AAAA,IAEA,KAAK,aAAa,YAAY,wBAAwB,eAAe;AAAA,IAGrE,KAAK,WAAW;AAAA,IAChB,KAAK,aAAa,WAAW;AAAA;AAGjC;",
8
+ "debugId": "E903EB04E40DB1E764756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -3,20 +3,26 @@ import {
3
3
  eligibleKeysForContext,
4
4
  getContextDependencyKey
5
5
  } from "../../evaluator/evaluation-context.mjs";
6
- import { isCellInRange, keyToCellAddress } from "../utils.mjs";
6
+ import { cellAddressToKey, isCellInRange, keyToCellAddress } from "../utils.mjs";
7
7
  import { AstEvaluationNode } from "../../evaluator/dependency-nodes/ast-evaluation-node.mjs";
8
8
  import { CellValueNode } from "../../evaluator/dependency-nodes/cell-value-node.mjs";
9
9
  import { EmptyCellEvaluationNode } from "../../evaluator/dependency-nodes/empty-cell-evaluation-node.mjs";
10
10
  import { SpillMetaNode } from "../../evaluator/dependency-nodes/spill-meta-node.mjs";
11
11
  import { RangeEvaluationNode } from "../../evaluator/range-evaluation-node.mjs";
12
- import { astToString } from "../../parser/formatter.mjs";
12
+ import {
13
+ astToString,
14
+ normalizeSerializedCellValue
15
+ } from "../../parser/formatter.mjs";
16
+ import { VirtualCellValueNode } from "../../evaluator/dependency-nodes/virtual-cell-value-node.mjs";
17
+ import { parseFormula } from "../../parser/parser.mjs";
13
18
 
14
19
  class DependencyManager {
15
20
  cacheManager;
16
21
  workbookManager;
17
- evaluatedNodes = new Map;
22
+ cellNodes = new Map;
18
23
  spillMetaNodes = new Map;
19
24
  emptyCells = new Map;
25
+ virtualCellValueNodes = new Map;
20
26
  _spilledValues = new Map;
21
27
  ranges = new Map;
22
28
  constructor(cacheManager, workbookManager) {
@@ -70,8 +76,9 @@ class DependencyManager {
70
76
  }
71
77
  clearEvaluationCache() {
72
78
  this.cacheManager.clear();
73
- this.evaluatedNodes.clear();
79
+ this.cellNodes.clear();
74
80
  this.emptyCells.clear();
81
+ this.virtualCellValueNodes.clear();
75
82
  this.asts.clear();
76
83
  this.spillMetaNodes.clear();
77
84
  this.ranges.clear();
@@ -109,12 +116,12 @@ class DependencyManager {
109
116
  if (!nodeKey.startsWith("cell-value:")) {
110
117
  throw new Error("Invalid cell value node key: " + nodeKey);
111
118
  }
112
- if (!this.evaluatedNodes.has(nodeKey)) {
119
+ if (!this.cellNodes.has(nodeKey)) {
113
120
  const node = new CellValueNode(nodeKey);
114
- this.evaluatedNodes.set(nodeKey, node);
121
+ this.cellNodes.set(nodeKey, node);
115
122
  return node;
116
123
  }
117
- return this.evaluatedNodes.get(nodeKey);
124
+ return this.cellNodes.get(nodeKey);
118
125
  }
119
126
  getCellValueOrEmptyCellNode(nodeKey) {
120
127
  const cellAddress = keyToCellAddress(nodeKey);
@@ -134,38 +141,30 @@ class DependencyManager {
134
141
  }
135
142
  return this.getSpillMetaNode(spillMetaKey);
136
143
  }
137
- lookupCellNode(nodeKey, types) {
138
- const cellAddress = keyToCellAddress(nodeKey);
139
- const emptyKey = nodeKey.replace(/^[^:]+:/, "empty:");
140
- const cellValueKey = nodeKey.replace(/^[^:]+:/, "cell-value:");
141
- const cellValueNode = this.evaluatedNodes.get(cellValueKey);
142
- const cellMetaKey = nodeKey.replace(/^[^:]+:/, "cell-meta:");
143
- const cellMetaNode = this.evaluatedNodes.get(cellMetaKey);
144
- if (this.workbookManager.isCellEmpty(cellAddress)) {
145
- if (types.includes("empty")) {
146
- return [this.getEmptyCellNode(emptyKey)];
147
- } else {
148
- return [];
149
- }
150
- }
151
- const results = [];
152
- if (types.includes("cell")) {
153
- if (cellValueNode) {
154
- results.push(cellValueNode);
155
- } else {
156
- results.push(this.getCellValueNode(cellValueKey));
157
- }
144
+ getVirtualCellValueNode(cellAddress, cellValue) {
145
+ let nodeKey = cellAddressToKey(cellAddress).replace(/^[^:]+:/, "virtual:");
146
+ nodeKey += ":";
147
+ const normalizedCellValue = normalizeSerializedCellValue(cellValue);
148
+ if (typeof normalizedCellValue === "string" && normalizedCellValue.startsWith("=")) {
149
+ const ast = parseFormula(normalizedCellValue.slice(1));
150
+ nodeKey += "ast:" + astToString(ast);
151
+ } else if (typeof normalizedCellValue === "string" && normalizedCellValue !== "") {
152
+ nodeKey += "string:" + normalizedCellValue;
153
+ } else if (typeof normalizedCellValue === "number") {
154
+ nodeKey += "number:" + normalizedCellValue;
155
+ } else if (typeof normalizedCellValue === "boolean") {
156
+ nodeKey += "boolean:" + normalizedCellValue;
157
+ } else if (normalizedCellValue === undefined) {
158
+ nodeKey += "string:";
159
+ } else {
160
+ throw new Error("Invalid cell value: " + normalizedCellValue);
158
161
  }
159
- if (this.workbookManager.isFormulaCell(cellAddress)) {
160
- if (types.includes("spill-meta")) {
161
- if (cellMetaNode) {
162
- results.push(cellMetaNode);
163
- } else {
164
- results.push(this.getSpillMetaNode(cellValueKey));
165
- }
166
- }
162
+ if (!this.virtualCellValueNodes.has(nodeKey)) {
163
+ const node = new VirtualCellValueNode(nodeKey, cellAddress, cellValue);
164
+ this.virtualCellValueNodes.set(nodeKey, node);
165
+ return node;
167
166
  }
168
- return results;
167
+ return this.virtualCellValueNodes.get(nodeKey);
169
168
  }
170
169
  getRangeNode(rangeKey) {
171
170
  if (!rangeKey.startsWith("range:")) {
@@ -210,9 +209,6 @@ class DependencyManager {
210
209
  });
211
210
  }
212
211
  }
213
- getEvaluatedNodes() {
214
- return this.evaluatedNodes;
215
- }
216
212
  getTransitiveDepsForEvalOrder(node, visited = new Set) {
217
213
  if (visited.has(node)) {
218
214
  return new Set;
@@ -590,4 +586,4 @@ export {
590
586
  DependencyManager
591
587
  };
592
588
 
593
- //# debugId=D7506DA764271C7364756E2164756E21
589
+ //# debugId=E85B3068E2F7410364756E2164756E21
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/core/managers/dependency-manager.ts"],
4
4
  "sourcesContent": [
5
- "import {\n eligibleKeysForContext,\n getContextDependencyKey,\n type ContextDependency,\n} from \"../../evaluator/evaluation-context.mjs\";\nimport {\n type CellAddress,\n type EvaluationOrder,\n type SpilledValue,\n} from \"../types.mjs\";\nimport { isCellInRange, keyToCellAddress } from \"../utils.mjs\";\n\nimport { AstEvaluationNode } from \"../../evaluator/dependency-nodes/ast-evaluation-node.mjs\";\nimport { CellValueNode } from \"../../evaluator/dependency-nodes/cell-value-node.mjs\";\nimport { EmptyCellEvaluationNode } from \"../../evaluator/dependency-nodes/empty-cell-evaluation-node.mjs\";\nimport { SpillMetaNode } from \"../../evaluator/dependency-nodes/spill-meta-node.mjs\";\nimport { RangeEvaluationNode } from \"../../evaluator/range-evaluation-node.mjs\";\nimport type { ASTNode } from \"../../parser/ast.mjs\";\nimport { astToString } from \"../../parser/formatter.mjs\";\nimport { CacheManager } from \"./cache-manager.mjs\";\nimport type {\n CellNodeKeyDictionary,\n CellNodeType,\n DependencyNode,\n} from \"./dependency-node.mjs\";\nimport { WorkbookManager } from \"./workbook-manager.mjs\";\n\nexport interface DependencyTreeNode {\n type: \"cell\" | \"range\" | \"empty\";\n circular?: boolean;\n key: string;\n directDepsUpdated?: boolean;\n resolved?: boolean;\n canResolve: boolean;\n resultType:\n | \"awaiting-evaluation\"\n | \"spilled-values\"\n | \"value\"\n | \"range\"\n | \"error\"\n | \"does-not-spill\";\n deps?: DependencyTreeNode[];\n frontierDependencies?: DependencyTreeNode[];\n self?: boolean;\n _debug?: {\n rawFrontierDependencies?: string[];\n discardedFrontierDependencies?: string[];\n activeFrontierDependencies?: string[];\n };\n}\n\n/**\n * The DependencyManager is responsible for storing the evaluated values and their dependencies.\n */\nexport class DependencyManager {\n /**\n * The dependency graph\n */\n private evaluatedNodes: Map<\n /**\n * key is the cell key, from cellAddressToKey\n */\n string,\n CellValueNode\n > = new Map();\n\n private spillMetaNodes: Map<string, SpillMetaNode> = new Map();\n\n private emptyCells: Map<string, EmptyCellEvaluationNode> = new Map();\n\n /**\n * registry of spilled values\n */\n private _spilledValues: Map<\n /**\n * key is the dependency node key, from dependencyNodeToKey for the origin cell\n */\n string,\n SpilledValue\n > = new Map();\n\n /**\n * Key is workbook:sheetName:rangeKey, e.g. Workbook1:Sheet1:A1:D10, from rangeAddressToKey\n */\n private ranges: Map<string, RangeEvaluationNode> = new Map();\n\n constructor(\n private cacheManager: CacheManager,\n private workbookManager: WorkbookManager\n ) {}\n\n public get spilledValues(): IterableIterator<SpilledValue> {\n return this._spilledValues.values();\n }\n\n isSpillOrigin(cellAddress: CellAddress): boolean {\n for (const spilledValue of this._spilledValues.values()) {\n if (\n spilledValue.origin.sheetName !== cellAddress.sheetName ||\n spilledValue.origin.workbookName !== cellAddress.workbookName\n ) {\n continue;\n }\n if (\n spilledValue.origin.colIndex === cellAddress.colIndex &&\n spilledValue.origin.rowIndex === cellAddress.rowIndex\n ) {\n return true;\n }\n }\n return false;\n }\n\n getSpillValue(cellAddress: CellAddress): SpilledValue | undefined {\n for (const spilledValue of this._spilledValues.values()) {\n if (\n spilledValue.origin.sheetName !== cellAddress.sheetName ||\n spilledValue.origin.workbookName !== cellAddress.workbookName\n ) {\n continue;\n }\n if (\n spilledValue.origin.colIndex === cellAddress.colIndex &&\n spilledValue.origin.rowIndex === cellAddress.rowIndex\n ) {\n return undefined;\n }\n if (isCellInRange(cellAddress, spilledValue.spillOnto)) {\n return spilledValue;\n }\n }\n return undefined;\n }\n\n getSpilledAddress(\n cellAddress: CellAddress,\n /**\n * if the spilled value is already available, we can use it to get the source address\n */\n passedSpilledValue?: SpilledValue\n ): { address: CellAddress; spillOffset: { x: number; y: number } } {\n const spilledValue = passedSpilledValue ?? this.getSpillValue(cellAddress);\n if (!spilledValue) {\n throw new Error(\"Cell is not spilled\");\n }\n const offsetLeft = cellAddress.colIndex - spilledValue.origin.colIndex;\n const offsetTop = cellAddress.rowIndex - spilledValue.origin.rowIndex;\n const address: CellAddress = {\n ...cellAddress,\n colIndex: spilledValue.origin.colIndex + offsetLeft,\n rowIndex: spilledValue.origin.rowIndex + offsetTop,\n };\n if (offsetLeft === 0 && offsetTop === 0) {\n throw new Error(\n \"Spilled value is the same as the cell address! The origin has a pre-calculated value that can be used\"\n );\n }\n return { address, spillOffset: { x: offsetLeft, y: offsetTop } };\n }\n\n clearEvaluationCache(): void {\n this.cacheManager.clear();\n this.evaluatedNodes.clear();\n this.emptyCells.clear();\n this.asts.clear();\n this.spillMetaNodes.clear();\n this.ranges.clear();\n this._spilledValues.clear();\n }\n\n setSpilledValue(nodeKey: string, spilledValue: SpilledValue): void {\n this._spilledValues.set(nodeKey.replace(/^[^:]+:/, \"\"), spilledValue);\n }\n\n getSpilledValue(nodeKey: string): SpilledValue | undefined {\n return this._spilledValues.get(nodeKey.replace(/^[^:]+:/, \"\"));\n }\n\n getEmptyCellNode(nodeKey: string): EmptyCellEvaluationNode {\n if (!nodeKey.startsWith(\"empty:\")) {\n throw new Error(\"Invalid empty cell node key: \" + nodeKey);\n }\n if (!this.emptyCells.has(nodeKey)) {\n const node = new EmptyCellEvaluationNode(\n nodeKey,\n this,\n this.workbookManager\n );\n this.emptyCells.set(nodeKey, node);\n return node;\n }\n return this.emptyCells.get(nodeKey)!;\n }\n\n getSpillMetaNode(nodeKey: string): SpillMetaNode {\n if (!nodeKey.startsWith(\"spill-meta:\")) {\n throw new Error(\"Invalid spill meta node key: \" + nodeKey);\n }\n if (!this.spillMetaNodes.has(nodeKey)) {\n const node = new SpillMetaNode(nodeKey);\n this.spillMetaNodes.set(nodeKey, node);\n return node;\n }\n return this.spillMetaNodes.get(nodeKey)!;\n }\n\n getCellValueNode(nodeKey: string): CellValueNode {\n if (!nodeKey.startsWith(\"cell-value:\")) {\n throw new Error(\"Invalid cell value node key: \" + nodeKey);\n }\n if (!this.evaluatedNodes.has(nodeKey)) {\n const node = new CellValueNode(nodeKey);\n this.evaluatedNodes.set(nodeKey, node);\n return node;\n }\n return this.evaluatedNodes.get(nodeKey)!;\n }\n\n getCellValueOrEmptyCellNode(\n nodeKey: string\n ): CellValueNode | EmptyCellEvaluationNode {\n const cellAddress = keyToCellAddress(nodeKey);\n\n const emptyKey = nodeKey.replace(/^[^:]+:/, \"empty:\");\n const cellValueKey = nodeKey.replace(/^[^:]+:/, \"cell-value:\");\n\n if (this.workbookManager.isCellEmpty(cellAddress)) {\n return this.getEmptyCellNode(emptyKey);\n }\n\n return this.getCellValueNode(cellValueKey);\n }\n\n getSpillMetaOrEmptySpillMetaNode(\n nodeKey: string\n ): SpillMetaNode | EmptyCellEvaluationNode {\n const cellAddress = keyToCellAddress(nodeKey);\n\n const emptyKey = nodeKey.replace(/^[^:]+:/, \"empty:\");\n const spillMetaKey = nodeKey.replace(/^[^:]+:/, \"spill-meta:\");\n\n if (this.workbookManager.isCellEmpty(cellAddress)) {\n return this.getEmptyCellNode(emptyKey);\n }\n\n return this.getSpillMetaNode(spillMetaKey);\n }\n\n lookupCellNode<T extends CellNodeType>(\n nodeKey: string,\n types: T[]\n ): CellNodeKeyDictionary[T][] {\n const cellAddress = keyToCellAddress(nodeKey);\n\n const emptyKey = nodeKey.replace(/^[^:]+:/, \"empty:\");\n const cellValueKey = nodeKey.replace(/^[^:]+:/, \"cell-value:\");\n const cellValueNode = this.evaluatedNodes.get(cellValueKey);\n const cellMetaKey = nodeKey.replace(/^[^:]+:/, \"cell-meta:\");\n const cellMetaNode = this.evaluatedNodes.get(cellMetaKey);\n\n if (this.workbookManager.isCellEmpty(cellAddress)) {\n if ((types as string[]).includes(\"empty\")) {\n return [this.getEmptyCellNode(emptyKey) as any];\n } else {\n return [];\n }\n }\n\n const results: any[] = [];\n\n if ((types as string[]).includes(\"cell\")) {\n if (cellValueNode) {\n results.push(cellValueNode);\n } else {\n results.push(this.getCellValueNode(cellValueKey));\n }\n }\n\n if (this.workbookManager.isFormulaCell(cellAddress)) {\n if ((types as string[]).includes(\"spill-meta\")) {\n if (cellMetaNode) {\n results.push(cellMetaNode);\n } else {\n results.push(this.getSpillMetaNode(cellValueKey));\n }\n }\n }\n\n return results;\n }\n\n getRangeNode(rangeKey: string): RangeEvaluationNode {\n if (!rangeKey.startsWith(\"range:\")) {\n throw new Error(\"Invalid range node key: \" + rangeKey);\n }\n if (!this.ranges.has(rangeKey)) {\n const node = new RangeEvaluationNode(\n rangeKey,\n this,\n this.workbookManager\n );\n this.ranges.set(rangeKey, node);\n return node;\n }\n return this.ranges.get(rangeKey)!;\n }\n\n asts: Map<\n /**\n * ast key\n */\n string,\n {\n entries: Map<\n /**\n * context dependency key\n */\n string,\n {\n evalNode: AstEvaluationNode;\n contextDependency: ContextDependency;\n }\n >;\n }\n > = new Map();\n\n getAstNode(\n ast: ASTNode,\n currentContext: Omit<Required<ContextDependency>, \"tableName\"> & {\n tableName?: string;\n }\n ): AstEvaluationNode {\n const astKey = `ast:${astToString(ast)}`; // cache normalize this later\n const astEntries = this.asts.get(astKey);\n\n const keys = eligibleKeysForContext(currentContext);\n\n for (const key of keys) {\n const astEntry = astEntries?.entries.get(key);\n if (astEntry) {\n return astEntry.evalNode;\n }\n }\n\n // if any of the ast entries match the current context, then we can return the ast node\n // otherwise we have to evalute the ast node to understand if it is context dependent\n // and later it will be saved using saveAstNode\n // if (astEntries) {\n // for (const entry of astEntries.entries.values()) {\n // // e.g. we have a row dependent ast dependency, dependent on row 1, and the current context dependency has rowIndex 1\n // // then we will get a match\n // const matches = Object.entries(entry.contextDependency).every(\n // ([key, value]) => {\n // if (typeof value === \"undefined\") {\n // return true;\n // }\n // return currentContext[key as keyof ContextDependency] === value;\n // }\n // );\n // if (matches) {\n // return entry.evalNode;\n // }\n // }\n // }\n\n // by default the ast node is cell specific\n // but later, setContextDependency is called with a more open context dependency\n const node = new AstEvaluationNode(ast, currentContext);\n // initially we store it as a cell, sheet, workbook and table dependent node\n // but later, once resolved, we can store it under a looser dependency key, e.g. only sheet, workbook and table dependent\n this.saveAstNode(node, currentContext);\n return node;\n }\n\n /**\n * Once an AST node is evaluated, we know if it is context dependent\n * and will thus save it under the correct cache key according to its\n * contextDependency\n *\n * only resolved ast nodes can be saved\n */\n private saveAstNode(\n ast: AstEvaluationNode,\n contextDependency: ContextDependency\n ) {\n const astKey = ast.key;\n const contextDependencyKey = getContextDependencyKey(contextDependency);\n const astEntries = this.asts.get(astKey);\n\n if (astEntries) {\n // if we don't already have an entry, then let's add it\n astEntries.entries.set(contextDependencyKey, {\n evalNode: ast,\n contextDependency,\n });\n } else {\n this.asts.set(astKey, {\n entries: new Map([\n [contextDependencyKey, { evalNode: ast, contextDependency }],\n ]),\n });\n }\n }\n\n getEvaluatedNodes(): Map<string, CellValueNode> {\n return this.evaluatedNodes;\n }\n\n //#region dependency graph methods\n\n /**\n * Get transitive dependencies and transitive frontier dependencies\n * This is only used by buildEvaluationOrder, so we'll optimize it there\n */\n getTransitiveDepsForEvalOrder(\n node: DependencyNode,\n visited: Set<DependencyNode> = new Set()\n ): Set<DependencyNode> {\n // Prevent infinite recursion\n if (visited.has(node)) {\n return new Set();\n }\n\n // If the node is resolved, then we don't need to evaluate it\n if (node && node.resolved) {\n return new Set();\n }\n\n // Mark this node as visited for cycle detection\n visited.add(node);\n\n const allNodes = new Set<DependencyNode>();\n allNodes.add(node);\n\n // Get direct dependencies (regular + frontier)\n const directDeps = node.getDependencies();\n\n // Recursively get transitive dependencies for each direct dependency\n for (const dep of directDeps) {\n if (!visited.has(dep)) {\n const depTransitiveDeps = this.getTransitiveDepsForEvalOrder(\n dep,\n visited\n );\n for (const transitiveDep of depTransitiveDeps) {\n allNodes.add(transitiveDep);\n }\n }\n }\n\n // Remove this node from visited set for other branches\n visited.delete(node);\n\n return allNodes;\n }\n\n /**\n * Build evaluation order for a cell using SCC-based condensation DAG approach\n *\n * Algorithm:\n * 1. Discover all transitive dependencies (skipping resolved nodes)\n * 2. Find SCCs using Tarjan's algorithm\n * 3. Create condensation DAG from SCCs\n * 4. Topologically sort the condensation DAG using Kahn's algorithm\n * 5. For each SCC, create internal evaluation order with cycle breaking\n * 6. Join the sorted SCC evaluation orders to create final evaluation order\n */\n buildEvaluationOrder(\n node: CellValueNode | EmptyCellEvaluationNode\n ): EvaluationOrder {\n if (node.resolved && this.cacheManager.getEvaluationOrder(node.key)) {\n return this.cacheManager.getEvaluationOrder(node.key)!;\n }\n\n // Phase 1: Discover all transitive dependencies (skipping resolved nodes)\n const allNodes = new Map<string, DependencyNode>();\n const visitedForDiscovery = new Set<DependencyNode>();\n\n const discoverNodes = (currentNode: DependencyNode) => {\n if (currentNode && currentNode.resolved) {\n return;\n }\n\n if (!allNodes.has(currentNode.key)) {\n allNodes.set(currentNode.key, currentNode);\n }\n\n if (visitedForDiscovery.has(currentNode)) {\n return;\n }\n\n visitedForDiscovery.add(currentNode);\n\n const allDeps = currentNode.getAllDependencies();\n for (const dep of allDeps) {\n discoverNodes(dep);\n }\n };\n\n discoverNodes(node);\n\n if (allNodes.size === 0 && node && node.resolved) {\n const result: EvaluationOrder = {\n evaluationOrder: new Set([node]),\n hasCycle: false,\n hash: this.computeHash(new Set([node])),\n };\n\n if (node && node.resolved) {\n this.cacheManager.setEvaluationOrder(node.key, result);\n }\n\n return result;\n }\n\n // Phase 2: Find SCCs using Tarjan's algorithm\n // Build SCCs considering ALL dependencies (soft + hard edges)\n const sccs = this.findSCCs(allNodes, true);\n\n // Phase 3: Create condensation DAG and check for cached SCCs\n const nodeToSCCId = new Map<DependencyNode, number>();\n const sccList: import(\"../types.mjs\").SCC[] = [];\n\n for (let i = 0; i < sccs.length; i++) {\n const sccNodes = sccs[i]!;\n\n // Check if all nodes in this SCC are resolved\n const allResolved = Array.from(sccNodes).every((n) => n.resolved);\n\n // Create SCC hash for caching\n const sccHash = Array.from(sccNodes)\n .map((n) => n.key)\n .sort()\n .join(\"|\");\n\n // Try to get cached SCC if it's resolved\n let scc: import(\"../types.mjs\").SCC;\n const cachedSCC = allResolved\n ? this.cacheManager.getSCC(sccHash)\n : undefined;\n\n if (cachedSCC) {\n scc = cachedSCC;\n } else {\n // Build evaluation order for this SCC with cycle breaking\n const sccEvalOrder = this.buildSCCEvaluationOrder(sccNodes);\n\n // Find hard-edge SCCs within this soft-edge SCC\n // Hard-edge SCCs are formed by only regular dependencies\n const hardEdgeSCCs = this.findSCCs(\n new Map(Array.from(sccNodes).map((n) => [n.key, n])),\n false // Use only hard edges (regular dependencies)\n );\n\n scc = {\n id: i,\n nodes: sccNodes,\n evaluationOrder: sccEvalOrder,\n resolved: allResolved,\n hardEdgeSCCs,\n };\n\n // Cache if resolved\n if (allResolved) {\n this.cacheManager.setSCC(sccHash, scc);\n }\n }\n\n sccList.push(scc);\n\n for (const n of sccNodes) {\n nodeToSCCId.set(n, i);\n }\n }\n\n // Build SCC dependency graph\n // Edge from A to B means A depends on B, so B must be evaluated before A\n const sccGraph = new Map<number, Set<number>>();\n for (let i = 0; i < sccList.length; i++) {\n sccGraph.set(i, new Set());\n }\n\n for (const [_, n] of allNodes) {\n const nSCCId = nodeToSCCId.get(n)!;\n // Use ALL dependencies (regular + frontier) for the condensation DAG\n // This ensures proper evaluation order even with frontier dependencies\n const deps = n.getAllDependencies();\n\n for (const dep of deps) {\n if (!allNodes.has(dep.key)) continue;\n\n const depSCCId = nodeToSCCId.get(dep)!;\n // n depends on dep, so dep's SCC must come before n's SCC\n // Add edge from dep's SCC to n's SCC\n if (nSCCId !== depSCCId) {\n sccGraph.get(depSCCId)!.add(nSCCId);\n }\n }\n }\n\n // Phase 4: Topologically sort SCCs using Kahn's algorithm\n const inDegree = new Map<number, number>();\n for (let i = 0; i < sccList.length; i++) {\n inDegree.set(i, 0);\n }\n\n for (const [_, deps] of sccGraph) {\n for (const toId of deps) {\n inDegree.set(toId, inDegree.get(toId)! + 1);\n }\n }\n\n const queue: number[] = [];\n for (let i = 0; i < sccList.length; i++) {\n if (inDegree.get(i) === 0) {\n queue.push(i);\n }\n }\n\n const sortedSCCIds: number[] = [];\n while (queue.length > 0) {\n const sccId = queue.shift()!;\n sortedSCCIds.push(sccId);\n\n const deps = sccGraph.get(sccId)!;\n for (const depId of deps) {\n const newInDegree = inDegree.get(depId)! - 1;\n inDegree.set(depId, newInDegree);\n if (newInDegree === 0) {\n queue.push(depId);\n }\n }\n }\n\n // Phase 5: Join evaluation orders from sorted SCCs\n const evaluationOrderArray: DependencyNode[] = [];\n for (const sccId of sortedSCCIds) {\n const scc = sccList[sccId]!;\n evaluationOrderArray.push(...scc.evaluationOrder);\n }\n\n const evaluationOrder = new Set(evaluationOrderArray);\n\n // Identify cycle nodes from hard-edge SCCs\n const cycleNodes = new Set<DependencyNode>();\n for (const scc of sccList) {\n for (const hardEdgeSCC of scc.hardEdgeSCCs) {\n // A hard-edge SCC with multiple nodes or a self-loop indicates a real cycle\n if (hardEdgeSCC.size > 1) {\n for (const n of hardEdgeSCC) {\n cycleNodes.add(n);\n }\n } else if (hardEdgeSCC.size === 1) {\n const node = Array.from(hardEdgeSCC)[0]!;\n if (node.getDependencies().has(node)) {\n cycleNodes.add(node);\n }\n }\n }\n }\n\n const hasCycle = cycleNodes.size > 0;\n const result: EvaluationOrder = {\n evaluationOrder,\n hasCycle,\n ...(hasCycle && { cycleNodes }),\n hash: this.computeGraphHash(allNodes, sccList),\n sccDAG: {\n sccList,\n sccGraph,\n },\n };\n\n if (node && node.resolved) {\n this.cacheManager.setEvaluationOrder(node.key, result);\n }\n\n return result;\n }\n\n /**\n * Find strongly connected components using Tarjan's algorithm\n * @param nodes - Map of nodes to analyze\n * @param includeFrontier - If true, use getAllDependencies(); if false, use getDependencies()\n * @returns Array of SCCs (each SCC is a Set of nodes)\n */\n private findSCCs(\n nodes: Map<string, DependencyNode>,\n includeFrontier: boolean\n ): Set<DependencyNode>[] {\n const index = new Map<DependencyNode, number>();\n const lowlink = new Map<DependencyNode, number>();\n const onStack = new Set<DependencyNode>();\n const stack: DependencyNode[] = [];\n const sccs: Set<DependencyNode>[] = [];\n let currentIndex = 0;\n\n const strongConnect = (v: DependencyNode) => {\n index.set(v, currentIndex);\n lowlink.set(v, currentIndex);\n currentIndex++;\n stack.push(v);\n onStack.add(v);\n\n // Use either all dependencies or just regular dependencies\n const successors = includeFrontier\n ? v.getAllDependencies()\n : v.getDependencies();\n\n for (const w of successors) {\n if (!nodes.has(w.key)) {\n continue;\n }\n\n if (!index.has(w)) {\n strongConnect(w);\n lowlink.set(v, Math.min(lowlink.get(v)!, lowlink.get(w)!));\n } else if (onStack.has(w)) {\n lowlink.set(v, Math.min(lowlink.get(v)!, index.get(w)!));\n }\n }\n\n if (lowlink.get(v) === index.get(v)) {\n const scc = new Set<DependencyNode>();\n let w: DependencyNode;\n do {\n w = stack.pop()!;\n onStack.delete(w);\n scc.add(w);\n } while (w !== v);\n\n sccs.push(scc);\n }\n };\n\n for (const [_, n] of nodes) {\n if (!index.has(n)) {\n strongConnect(n);\n }\n }\n\n return sccs;\n }\n\n /**\n * Build evaluation order within a single SCC using DFS with cycle breaking\n * Uses all dependencies (including frontier) for proper evaluation ordering\n */\n private buildSCCEvaluationOrder(\n sccNodes: Set<DependencyNode>\n ): DependencyNode[] {\n const visited = new Set<DependencyNode>();\n const visiting = new Set<DependencyNode>();\n const result: DependencyNode[] = [];\n\n const dfs = (n: DependencyNode) => {\n if (visited.has(n)) {\n return;\n }\n\n if (visiting.has(n)) {\n // Cycle detected (from any edge type), break it\n return;\n }\n\n visiting.add(n);\n\n // Use all dependencies for evaluation ordering (regular + frontier)\n const deps = n.getAllDependencies();\n for (const dep of deps) {\n if (sccNodes.has(dep) && !visited.has(dep)) {\n dfs(dep);\n }\n }\n\n visiting.delete(n);\n visited.add(n);\n result.push(n);\n };\n\n // Sort nodes by key for deterministic ordering\n const sortedNodes = Array.from(sccNodes).sort((a, b) =>\n a.key.localeCompare(b.key)\n );\n\n for (const n of sortedNodes) {\n if (!visited.has(n)) {\n dfs(n);\n }\n }\n\n return result;\n }\n\n /**\n * Compute hash representing the graph structure including SCC information\n */\n private computeGraphHash(\n allNodes: Map<string, DependencyNode>,\n sccList: import(\"../types.mjs\").SCC[]\n ): string {\n const parts: string[] = [];\n\n // Hash nodes and their dependencies\n for (const [key, node] of Array.from(allNodes.entries()).sort()) {\n const deps = Array.from(node.getAllDependencies())\n .map((d) => d.key)\n .sort()\n .join(\",\");\n parts.push(`${key}:[${deps}]`);\n }\n\n // Add SCC structure\n for (const scc of sccList) {\n const nodeKeys = Array.from(scc.nodes)\n .map((n) => n.key)\n .sort()\n .join(\",\");\n parts.push(`SCC${scc.id}:{${nodeKeys}}`);\n }\n\n return parts.join(\"|\");\n }\n\n /**\n * Compute a hash representing the current state of evaluated nodes\n * This hash changes when dependencies, frontier dependencies, or discarded frontier dependencies change\n */\n private computeHash(allNodes: Set<DependencyNode>): string {\n const nodeStates: string[] = [];\n\n for (const node of Array.from(allNodes).sort()) {\n if (node) {\n const deps = Array.from(node.getDependencies() || [])\n .map((dep) => dep.key)\n .sort()\n .join(\",\");\n\n // Handle frontier dependencies (Map<string, Set<string>>)\n const frontierDeps: string = Array.from(node.getFrontierDependencies())\n .map((dep) => dep.key)\n .sort()\n .join(\";\");\n\n const nodeState = `${node.key}:{deps:[${deps}],frontier:[${frontierDeps}]}`;\n nodeStates.push(nodeState);\n }\n }\n\n return nodeStates.join(\"|\");\n }\n\n /**\n * Get a hierarchical dependency tree for a node\n */\n getDependencyTree(node: DependencyNode): DependencyTreeNode {\n const visited = new Set<DependencyNode>();\n\n const nodeToType = (node: DependencyNode): \"cell\" | \"range\" | \"empty\" => {\n if (node instanceof RangeEvaluationNode) {\n return \"range\";\n }\n if (node instanceof EmptyCellEvaluationNode) {\n return \"empty\";\n }\n return \"cell\";\n };\n\n const buildTree = (\n node: DependencyNode,\n isSelf = false\n ): DependencyTreeNode => {\n const cellRef: string = node.toString();\n\n // Handle self-reference to avoid infinite recursion\n if (isSelf) {\n return {\n type: nodeToType(node),\n resultType:\n node instanceof RangeEvaluationNode\n ? \"range\"\n : node.evaluationResult\n ? node.evaluationResult.type\n : \"awaiting-evaluation\",\n canResolve: node.canResolve(),\n key: cellRef,\n directDepsUpdated: node.directDepsUpdated,\n resolved: node.resolved,\n self: true,\n circular: true,\n };\n }\n\n // Avoid infinite recursion for circular dependencies\n if (visited.has(node)) {\n return {\n type: nodeToType(node),\n resultType:\n node instanceof RangeEvaluationNode\n ? \"range\"\n : node.evaluationResult\n ? node.evaluationResult.type\n : \"awaiting-evaluation\",\n canResolve: node.canResolve(),\n key: cellRef,\n directDepsUpdated: node.directDepsUpdated,\n resolved: node.resolved,\n circular: true,\n };\n }\n\n visited.add(node);\n\n const directDeps = Array.from(node.getDependencies());\n let frontierDeps = Array.from(node.getFrontierDependencies());\n\n // Get regular dependencies\n const deps: DependencyTreeNode[] = directDeps.map((dep) =>\n buildTree(dep, dep.key === node.key)\n );\n\n const frontierDependencies: DependencyTreeNode[] = frontierDeps.map(\n (dep) => buildTree(dep, false)\n );\n\n visited.delete(node);\n\n const result: DependencyTreeNode = {\n type: nodeToType(node),\n resultType:\n node instanceof RangeEvaluationNode\n ? \"range\"\n : node.evaluationResult\n ? node.evaluationResult.type\n : \"awaiting-evaluation\",\n canResolve: node.canResolve(),\n key: cellRef,\n directDepsUpdated: node.directDepsUpdated,\n resolved: node.resolved,\n };\n\n // Only include deps and frontierDependencies if they have content\n if (deps.length > 0) {\n result.deps = deps;\n }\n if (frontierDependencies.length > 0) {\n result.frontierDependencies = frontierDependencies;\n }\n\n return result;\n };\n\n return buildTree(node);\n }\n //#endregion\n\n markResolvedNodes(node: DependencyNode): void {\n // Track visited nodes to avoid infinite loops in circular dependencies\n const visited = new Set<DependencyNode>();\n visited.add(node); // Don't revisit the current cell\n\n const areTransitiveDepsResolved = (nodes: Set<DependencyNode>): boolean => {\n let canResolve = true;\n for (const node of nodes) {\n if (visited.has(node) || node.resolved) {\n continue;\n }\n visited.add(node);\n\n // Check the node's dependencies to not cause cycles with frontier dependencies\n const directDeps = node.getDependencies();\n\n const a = areTransitiveDepsResolved(directDeps);\n const b = node.canResolve();\n\n if (!a || !b) {\n canResolve = false;\n }\n if (a && b) {\n node.resolve();\n // if an ast node is resolved, it will get removed from the dependency graph\n // and thus never reach evaluateNode in formula evaluator\n // so we need to save it here. The latest context dependency is the correct one.\n if (node instanceof AstEvaluationNode) {\n this.saveAstNode(node, node.getContextDependency());\n }\n }\n }\n return canResolve;\n };\n\n if (\n areTransitiveDepsResolved(node.getDependencies()) &&\n node.canResolve()\n ) {\n node.resolve();\n if (node instanceof AstEvaluationNode) {\n this.saveAstNode(node, node.getContextDependency());\n }\n }\n }\n\n /**\n * Update SCCs in cache to mark them as resolved if all their nodes are resolved\n */\n public updateResolvedSCCs(evalOrder: EvaluationOrder): void {\n if (!evalOrder.sccDAG) {\n return;\n }\n\n // Check each SCC and update cache if all nodes are resolved\n for (const scc of evalOrder.sccDAG.sccList) {\n const allResolved = Array.from(scc.nodes).every((n) => n.resolved);\n\n if (allResolved && !scc.resolved) {\n // Create updated SCC with resolved flag\n const updatedSCC: import(\"../types.mjs\").SCC = {\n ...scc,\n resolved: true,\n };\n\n // Update cache\n const sccHash = Array.from(scc.nodes)\n .map((n) => n.key)\n .sort()\n .join(\"|\");\n\n this.cacheManager.setSCC(sccHash, updatedSCC);\n }\n }\n }\n}\n"
5
+ "import {\n eligibleKeysForContext,\n getContextDependencyKey,\n type ContextDependency,\n} from \"../../evaluator/evaluation-context.mjs\";\nimport {\n type CellAddress,\n type EvaluationOrder,\n type SerializedCellValue,\n type SpilledValue,\n} from \"../types.mjs\";\nimport { cellAddressToKey, isCellInRange, keyToCellAddress } from \"../utils.mjs\";\n\nimport { AstEvaluationNode } from \"../../evaluator/dependency-nodes/ast-evaluation-node.mjs\";\nimport { CellValueNode } from \"../../evaluator/dependency-nodes/cell-value-node.mjs\";\nimport { EmptyCellEvaluationNode } from \"../../evaluator/dependency-nodes/empty-cell-evaluation-node.mjs\";\nimport { SpillMetaNode } from \"../../evaluator/dependency-nodes/spill-meta-node.mjs\";\nimport { RangeEvaluationNode } from \"../../evaluator/range-evaluation-node.mjs\";\nimport type { ASTNode } from \"../../parser/ast.mjs\";\nimport {\n astToString,\n normalizeSerializedCellValue,\n} from \"../../parser/formatter.mjs\";\nimport { CacheManager } from \"./cache-manager.mjs\";\nimport type {\n CellNodeKeyDictionary,\n CellNodeType,\n DependencyNode,\n} from \"./dependency-node.mjs\";\nimport { WorkbookManager } from \"./workbook-manager.mjs\";\nimport { VirtualCellValueNode } from \"../../evaluator/dependency-nodes/virtual-cell-value-node.mjs\";\nimport { parseFormula } from \"../../parser/parser.mjs\";\n\nexport interface DependencyTreeNode {\n type: \"cell\" | \"range\" | \"empty\";\n circular?: boolean;\n key: string;\n directDepsUpdated?: boolean;\n resolved?: boolean;\n canResolve: boolean;\n resultType:\n | \"awaiting-evaluation\"\n | \"spilled-values\"\n | \"value\"\n | \"range\"\n | \"error\"\n | \"does-not-spill\";\n deps?: DependencyTreeNode[];\n frontierDependencies?: DependencyTreeNode[];\n self?: boolean;\n _debug?: {\n rawFrontierDependencies?: string[];\n discardedFrontierDependencies?: string[];\n activeFrontierDependencies?: string[];\n };\n}\n\n/**\n * The DependencyManager is responsible for storing the evaluated values and their dependencies.\n */\nexport class DependencyManager {\n /**\n * The dependency graph AKA cellNodes\n */\n private cellNodes: Map<\n /**\n * key is the cell key, from cellAddressToKey\n */\n string,\n CellValueNode\n > = new Map();\n\n private spillMetaNodes: Map<string, SpillMetaNode> = new Map();\n\n private emptyCells: Map<string, EmptyCellEvaluationNode> = new Map();\n\n private virtualCellValueNodes: Map<string, VirtualCellValueNode> = new Map();\n\n /**\n * registry of spilled values\n */\n private _spilledValues: Map<\n /**\n * key is the dependency node key, from dependencyNodeToKey for the origin cell\n */\n string,\n SpilledValue\n > = new Map();\n\n /**\n * Key is workbook:sheetName:rangeKey, e.g. Workbook1:Sheet1:A1:D10, from rangeAddressToKey\n */\n private ranges: Map<string, RangeEvaluationNode> = new Map();\n\n constructor(\n private cacheManager: CacheManager,\n private workbookManager: WorkbookManager\n ) {}\n\n public get spilledValues(): IterableIterator<SpilledValue> {\n return this._spilledValues.values();\n }\n\n isSpillOrigin(cellAddress: CellAddress): boolean {\n for (const spilledValue of this._spilledValues.values()) {\n if (\n spilledValue.origin.sheetName !== cellAddress.sheetName ||\n spilledValue.origin.workbookName !== cellAddress.workbookName\n ) {\n continue;\n }\n if (\n spilledValue.origin.colIndex === cellAddress.colIndex &&\n spilledValue.origin.rowIndex === cellAddress.rowIndex\n ) {\n return true;\n }\n }\n return false;\n }\n\n getSpillValue(cellAddress: CellAddress): SpilledValue | undefined {\n for (const spilledValue of this._spilledValues.values()) {\n if (\n spilledValue.origin.sheetName !== cellAddress.sheetName ||\n spilledValue.origin.workbookName !== cellAddress.workbookName\n ) {\n continue;\n }\n if (\n spilledValue.origin.colIndex === cellAddress.colIndex &&\n spilledValue.origin.rowIndex === cellAddress.rowIndex\n ) {\n return undefined;\n }\n if (isCellInRange(cellAddress, spilledValue.spillOnto)) {\n return spilledValue;\n }\n }\n return undefined;\n }\n\n getSpilledAddress(\n cellAddress: CellAddress,\n /**\n * if the spilled value is already available, we can use it to get the source address\n */\n passedSpilledValue?: SpilledValue\n ): { address: CellAddress; spillOffset: { x: number; y: number } } {\n const spilledValue = passedSpilledValue ?? this.getSpillValue(cellAddress);\n if (!spilledValue) {\n throw new Error(\"Cell is not spilled\");\n }\n const offsetLeft = cellAddress.colIndex - spilledValue.origin.colIndex;\n const offsetTop = cellAddress.rowIndex - spilledValue.origin.rowIndex;\n const address: CellAddress = {\n ...cellAddress,\n colIndex: spilledValue.origin.colIndex + offsetLeft,\n rowIndex: spilledValue.origin.rowIndex + offsetTop,\n };\n if (offsetLeft === 0 && offsetTop === 0) {\n throw new Error(\n \"Spilled value is the same as the cell address! The origin has a pre-calculated value that can be used\"\n );\n }\n return { address, spillOffset: { x: offsetLeft, y: offsetTop } };\n }\n\n clearEvaluationCache(): void {\n this.cacheManager.clear();\n this.cellNodes.clear();\n this.emptyCells.clear();\n this.virtualCellValueNodes.clear();\n this.asts.clear();\n this.spillMetaNodes.clear();\n this.ranges.clear();\n this._spilledValues.clear();\n }\n\n setSpilledValue(nodeKey: string, spilledValue: SpilledValue): void {\n this._spilledValues.set(nodeKey.replace(/^[^:]+:/, \"\"), spilledValue);\n }\n\n getSpilledValue(nodeKey: string): SpilledValue | undefined {\n return this._spilledValues.get(nodeKey.replace(/^[^:]+:/, \"\"));\n }\n\n getEmptyCellNode(nodeKey: string): EmptyCellEvaluationNode {\n if (!nodeKey.startsWith(\"empty:\")) {\n throw new Error(\"Invalid empty cell node key: \" + nodeKey);\n }\n if (!this.emptyCells.has(nodeKey)) {\n const node = new EmptyCellEvaluationNode(\n nodeKey,\n this,\n this.workbookManager\n );\n this.emptyCells.set(nodeKey, node);\n return node;\n }\n return this.emptyCells.get(nodeKey)!;\n }\n\n getSpillMetaNode(nodeKey: string): SpillMetaNode {\n if (!nodeKey.startsWith(\"spill-meta:\")) {\n throw new Error(\"Invalid spill meta node key: \" + nodeKey);\n }\n if (!this.spillMetaNodes.has(nodeKey)) {\n const node = new SpillMetaNode(nodeKey);\n this.spillMetaNodes.set(nodeKey, node);\n return node;\n }\n return this.spillMetaNodes.get(nodeKey)!;\n }\n\n getCellValueNode(nodeKey: string): CellValueNode {\n if (!nodeKey.startsWith(\"cell-value:\")) {\n throw new Error(\"Invalid cell value node key: \" + nodeKey);\n }\n if (!this.cellNodes.has(nodeKey)) {\n const node = new CellValueNode(nodeKey);\n this.cellNodes.set(nodeKey, node);\n return node;\n }\n return this.cellNodes.get(nodeKey)!;\n }\n\n getCellValueOrEmptyCellNode(\n nodeKey: string\n ): CellValueNode | EmptyCellEvaluationNode {\n const cellAddress = keyToCellAddress(nodeKey);\n\n const emptyKey = nodeKey.replace(/^[^:]+:/, \"empty:\");\n const cellValueKey = nodeKey.replace(/^[^:]+:/, \"cell-value:\");\n\n if (this.workbookManager.isCellEmpty(cellAddress)) {\n return this.getEmptyCellNode(emptyKey);\n }\n\n return this.getCellValueNode(cellValueKey);\n }\n\n getSpillMetaOrEmptySpillMetaNode(\n nodeKey: string\n ): SpillMetaNode | EmptyCellEvaluationNode {\n const cellAddress = keyToCellAddress(nodeKey);\n\n const emptyKey = nodeKey.replace(/^[^:]+:/, \"empty:\");\n const spillMetaKey = nodeKey.replace(/^[^:]+:/, \"spill-meta:\");\n\n if (this.workbookManager.isCellEmpty(cellAddress)) {\n return this.getEmptyCellNode(emptyKey);\n }\n\n return this.getSpillMetaNode(spillMetaKey);\n }\n\n getVirtualCellValueNode(\n cellAddress: CellAddress,\n cellValue: SerializedCellValue\n ): VirtualCellValueNode {\n let nodeKey = cellAddressToKey(cellAddress).replace(/^[^:]+:/, \"virtual:\");\n nodeKey += \":\";\n const normalizedCellValue = normalizeSerializedCellValue(cellValue);\n\n if (\n typeof normalizedCellValue === \"string\" &&\n normalizedCellValue.startsWith(\"=\")\n ) {\n const ast = parseFormula(normalizedCellValue.slice(1));\n nodeKey += \"ast:\" + astToString(ast);\n } else if (\n typeof normalizedCellValue === \"string\" &&\n normalizedCellValue !== \"\"\n ) {\n nodeKey += \"string:\" + normalizedCellValue;\n } else if (typeof normalizedCellValue === \"number\") {\n nodeKey += \"number:\" + normalizedCellValue;\n } else if (typeof normalizedCellValue === \"boolean\") {\n nodeKey += \"boolean:\" + normalizedCellValue;\n } else if (normalizedCellValue === undefined) {\n nodeKey += \"string:\";\n } else {\n throw new Error(\"Invalid cell value: \" + normalizedCellValue);\n }\n\n if (!this.virtualCellValueNodes.has(nodeKey)) {\n const node = new VirtualCellValueNode(nodeKey, cellAddress, cellValue);\n this.virtualCellValueNodes.set(nodeKey, node);\n return node;\n }\n return this.virtualCellValueNodes.get(nodeKey)!;\n }\n\n getRangeNode(rangeKey: string): RangeEvaluationNode {\n if (!rangeKey.startsWith(\"range:\")) {\n throw new Error(\"Invalid range node key: \" + rangeKey);\n }\n if (!this.ranges.has(rangeKey)) {\n const node = new RangeEvaluationNode(\n rangeKey,\n this,\n this.workbookManager\n );\n this.ranges.set(rangeKey, node);\n return node;\n }\n return this.ranges.get(rangeKey)!;\n }\n\n asts: Map<\n /**\n * ast key\n */\n string,\n {\n entries: Map<\n /**\n * context dependency key\n */\n string,\n {\n evalNode: AstEvaluationNode;\n contextDependency: ContextDependency;\n }\n >;\n }\n > = new Map();\n\n getAstNode(\n ast: ASTNode,\n currentContext: Omit<Required<ContextDependency>, \"tableName\"> & {\n tableName?: string;\n }\n ): AstEvaluationNode {\n const astKey = `ast:${astToString(ast)}`; // cache normalize this later\n const astEntries = this.asts.get(astKey);\n\n // if any of the ast entries match the current context, then we can return the ast node\n // otherwise we have to evalute the ast node to understand if it is context dependent\n // and later it will be saved using saveAstNode\n // eligibleKeysForContext returns keys ordered from most-specific to least-specific\n const keys = eligibleKeysForContext(currentContext);\n\n for (const key of keys) {\n const astEntry = astEntries?.entries.get(key);\n if (astEntry) {\n return astEntry.evalNode;\n }\n }\n\n // by default the ast node is cell specific\n // but later, setContextDependency is called with a more open context dependency\n const node = new AstEvaluationNode(ast, currentContext);\n // initially we store it as a cell, sheet, workbook and table dependent node\n // but later, once resolved, we can store it under a looser dependency key, e.g. only sheet, workbook and table dependent\n this.saveAstNode(node, currentContext);\n return node;\n }\n\n /**\n * Once an AST node is evaluated, we know if it is context dependent\n * and will thus save it under the correct cache key according to its\n * contextDependency\n *\n * only resolved ast nodes can be saved\n */\n private saveAstNode(\n ast: AstEvaluationNode,\n contextDependency: ContextDependency\n ) {\n const astKey = ast.key;\n const contextDependencyKey = getContextDependencyKey(contextDependency);\n const astEntries = this.asts.get(astKey);\n\n if (astEntries) {\n // if we don't already have an entry, then let's add it\n astEntries.entries.set(contextDependencyKey, {\n evalNode: ast,\n contextDependency,\n });\n } else {\n this.asts.set(astKey, {\n entries: new Map([\n [contextDependencyKey, { evalNode: ast, contextDependency }],\n ]),\n });\n }\n }\n\n //#region dependency graph methods\n\n /**\n * Get transitive dependencies and transitive frontier dependencies\n * This is only used by buildEvaluationOrder, so we'll optimize it there\n */\n getTransitiveDepsForEvalOrder(\n node: DependencyNode,\n visited: Set<DependencyNode> = new Set()\n ): Set<DependencyNode> {\n // Prevent infinite recursion\n if (visited.has(node)) {\n return new Set();\n }\n\n // If the node is resolved, then we don't need to evaluate it\n if (node && node.resolved) {\n return new Set();\n }\n\n // Mark this node as visited for cycle detection\n visited.add(node);\n\n const allNodes = new Set<DependencyNode>();\n allNodes.add(node);\n\n // Get direct dependencies (regular + frontier)\n const directDeps = node.getDependencies();\n\n // Recursively get transitive dependencies for each direct dependency\n for (const dep of directDeps) {\n if (!visited.has(dep)) {\n const depTransitiveDeps = this.getTransitiveDepsForEvalOrder(\n dep,\n visited\n );\n for (const transitiveDep of depTransitiveDeps) {\n allNodes.add(transitiveDep);\n }\n }\n }\n\n // Remove this node from visited set for other branches\n visited.delete(node);\n\n return allNodes;\n }\n\n /**\n * Build evaluation order for a cell using SCC-based condensation DAG approach\n *\n * Algorithm:\n * 1. Discover all transitive dependencies (skipping resolved nodes)\n * 2. Find SCCs using Tarjan's algorithm\n * 3. Create condensation DAG from SCCs\n * 4. Topologically sort the condensation DAG using Kahn's algorithm\n * 5. For each SCC, create internal evaluation order with cycle breaking\n * 6. Join the sorted SCC evaluation orders to create final evaluation order\n */\n buildEvaluationOrder(\n node: CellValueNode | EmptyCellEvaluationNode | VirtualCellValueNode\n ): EvaluationOrder {\n if (node.resolved && this.cacheManager.getEvaluationOrder(node.key)) {\n return this.cacheManager.getEvaluationOrder(node.key)!;\n }\n\n // Phase 1: Discover all transitive dependencies (skipping resolved nodes)\n const allNodes = new Map<string, DependencyNode>();\n const visitedForDiscovery = new Set<DependencyNode>();\n\n const discoverNodes = (currentNode: DependencyNode) => {\n if (currentNode && currentNode.resolved) {\n return;\n }\n\n if (!allNodes.has(currentNode.key)) {\n allNodes.set(currentNode.key, currentNode);\n }\n\n if (visitedForDiscovery.has(currentNode)) {\n return;\n }\n\n visitedForDiscovery.add(currentNode);\n\n const allDeps = currentNode.getAllDependencies();\n for (const dep of allDeps) {\n discoverNodes(dep);\n }\n };\n\n discoverNodes(node);\n\n if (allNodes.size === 0 && node && node.resolved) {\n const result: EvaluationOrder = {\n evaluationOrder: new Set([node]),\n hasCycle: false,\n hash: this.computeHash(new Set([node])),\n };\n\n if (node && node.resolved) {\n this.cacheManager.setEvaluationOrder(node.key, result);\n }\n\n return result;\n }\n\n // Phase 2: Find SCCs using Tarjan's algorithm\n // Build SCCs considering ALL dependencies (soft + hard edges)\n const sccs = this.findSCCs(allNodes, true);\n\n // Phase 3: Create condensation DAG and check for cached SCCs\n const nodeToSCCId = new Map<DependencyNode, number>();\n const sccList: import(\"../types.mjs\").SCC[] = [];\n\n for (let i = 0; i < sccs.length; i++) {\n const sccNodes = sccs[i]!;\n\n // Check if all nodes in this SCC are resolved\n const allResolved = Array.from(sccNodes).every((n) => n.resolved);\n\n // Create SCC hash for caching\n const sccHash = Array.from(sccNodes)\n .map((n) => n.key)\n .sort()\n .join(\"|\");\n\n // Try to get cached SCC if it's resolved\n let scc: import(\"../types.mjs\").SCC;\n const cachedSCC = allResolved\n ? this.cacheManager.getSCC(sccHash)\n : undefined;\n\n if (cachedSCC) {\n scc = cachedSCC;\n } else {\n // Build evaluation order for this SCC with cycle breaking\n const sccEvalOrder = this.buildSCCEvaluationOrder(sccNodes);\n\n // Find hard-edge SCCs within this soft-edge SCC\n // Hard-edge SCCs are formed by only regular dependencies\n const hardEdgeSCCs = this.findSCCs(\n new Map(Array.from(sccNodes).map((n) => [n.key, n])),\n false // Use only hard edges (regular dependencies)\n );\n\n scc = {\n id: i,\n nodes: sccNodes,\n evaluationOrder: sccEvalOrder,\n resolved: allResolved,\n hardEdgeSCCs,\n };\n\n // Cache if resolved\n if (allResolved) {\n this.cacheManager.setSCC(sccHash, scc);\n }\n }\n\n sccList.push(scc);\n\n for (const n of sccNodes) {\n nodeToSCCId.set(n, i);\n }\n }\n\n // Build SCC dependency graph\n // Edge from A to B means A depends on B, so B must be evaluated before A\n const sccGraph = new Map<number, Set<number>>();\n for (let i = 0; i < sccList.length; i++) {\n sccGraph.set(i, new Set());\n }\n\n for (const [_, n] of allNodes) {\n const nSCCId = nodeToSCCId.get(n)!;\n // Use ALL dependencies (regular + frontier) for the condensation DAG\n // This ensures proper evaluation order even with frontier dependencies\n const deps = n.getAllDependencies();\n\n for (const dep of deps) {\n if (!allNodes.has(dep.key)) continue;\n\n const depSCCId = nodeToSCCId.get(dep)!;\n // n depends on dep, so dep's SCC must come before n's SCC\n // Add edge from dep's SCC to n's SCC\n if (nSCCId !== depSCCId) {\n sccGraph.get(depSCCId)!.add(nSCCId);\n }\n }\n }\n\n // Phase 4: Topologically sort SCCs using Kahn's algorithm\n const inDegree = new Map<number, number>();\n for (let i = 0; i < sccList.length; i++) {\n inDegree.set(i, 0);\n }\n\n for (const [_, deps] of sccGraph) {\n for (const toId of deps) {\n inDegree.set(toId, inDegree.get(toId)! + 1);\n }\n }\n\n const queue: number[] = [];\n for (let i = 0; i < sccList.length; i++) {\n if (inDegree.get(i) === 0) {\n queue.push(i);\n }\n }\n\n const sortedSCCIds: number[] = [];\n while (queue.length > 0) {\n const sccId = queue.shift()!;\n sortedSCCIds.push(sccId);\n\n const deps = sccGraph.get(sccId)!;\n for (const depId of deps) {\n const newInDegree = inDegree.get(depId)! - 1;\n inDegree.set(depId, newInDegree);\n if (newInDegree === 0) {\n queue.push(depId);\n }\n }\n }\n\n // Phase 5: Join evaluation orders from sorted SCCs\n const evaluationOrderArray: DependencyNode[] = [];\n for (const sccId of sortedSCCIds) {\n const scc = sccList[sccId]!;\n evaluationOrderArray.push(...scc.evaluationOrder);\n }\n\n const evaluationOrder = new Set(evaluationOrderArray);\n\n // Identify cycle nodes from hard-edge SCCs\n const cycleNodes = new Set<DependencyNode>();\n for (const scc of sccList) {\n for (const hardEdgeSCC of scc.hardEdgeSCCs) {\n // A hard-edge SCC with multiple nodes or a self-loop indicates a real cycle\n if (hardEdgeSCC.size > 1) {\n for (const n of hardEdgeSCC) {\n cycleNodes.add(n);\n }\n } else if (hardEdgeSCC.size === 1) {\n const node = Array.from(hardEdgeSCC)[0]!;\n if (node.getDependencies().has(node)) {\n cycleNodes.add(node);\n }\n }\n }\n }\n\n const hasCycle = cycleNodes.size > 0;\n const result: EvaluationOrder = {\n evaluationOrder,\n hasCycle,\n ...(hasCycle && { cycleNodes }),\n hash: this.computeGraphHash(allNodes, sccList),\n sccDAG: {\n sccList,\n sccGraph,\n },\n };\n\n if (node && node.resolved) {\n this.cacheManager.setEvaluationOrder(node.key, result);\n }\n\n return result;\n }\n\n /**\n * Find strongly connected components using Tarjan's algorithm\n * @param nodes - Map of nodes to analyze\n * @param includeFrontier - If true, use getAllDependencies(); if false, use getDependencies()\n * @returns Array of SCCs (each SCC is a Set of nodes)\n */\n private findSCCs(\n nodes: Map<string, DependencyNode>,\n includeFrontier: boolean\n ): Set<DependencyNode>[] {\n const index = new Map<DependencyNode, number>();\n const lowlink = new Map<DependencyNode, number>();\n const onStack = new Set<DependencyNode>();\n const stack: DependencyNode[] = [];\n const sccs: Set<DependencyNode>[] = [];\n let currentIndex = 0;\n\n const strongConnect = (v: DependencyNode) => {\n index.set(v, currentIndex);\n lowlink.set(v, currentIndex);\n currentIndex++;\n stack.push(v);\n onStack.add(v);\n\n // Use either all dependencies or just regular dependencies\n const successors = includeFrontier\n ? v.getAllDependencies()\n : v.getDependencies();\n\n for (const w of successors) {\n if (!nodes.has(w.key)) {\n continue;\n }\n\n if (!index.has(w)) {\n strongConnect(w);\n lowlink.set(v, Math.min(lowlink.get(v)!, lowlink.get(w)!));\n } else if (onStack.has(w)) {\n lowlink.set(v, Math.min(lowlink.get(v)!, index.get(w)!));\n }\n }\n\n if (lowlink.get(v) === index.get(v)) {\n const scc = new Set<DependencyNode>();\n let w: DependencyNode;\n do {\n w = stack.pop()!;\n onStack.delete(w);\n scc.add(w);\n } while (w !== v);\n\n sccs.push(scc);\n }\n };\n\n for (const [_, n] of nodes) {\n if (!index.has(n)) {\n strongConnect(n);\n }\n }\n\n return sccs;\n }\n\n /**\n * Build evaluation order within a single SCC using DFS with cycle breaking\n * Uses all dependencies (including frontier) for proper evaluation ordering\n */\n private buildSCCEvaluationOrder(\n sccNodes: Set<DependencyNode>\n ): DependencyNode[] {\n const visited = new Set<DependencyNode>();\n const visiting = new Set<DependencyNode>();\n const result: DependencyNode[] = [];\n\n const dfs = (n: DependencyNode) => {\n if (visited.has(n)) {\n return;\n }\n\n if (visiting.has(n)) {\n // Cycle detected (from any edge type), break it\n return;\n }\n\n visiting.add(n);\n\n // Use all dependencies for evaluation ordering (regular + frontier)\n const deps = n.getAllDependencies();\n for (const dep of deps) {\n if (sccNodes.has(dep) && !visited.has(dep)) {\n dfs(dep);\n }\n }\n\n visiting.delete(n);\n visited.add(n);\n result.push(n);\n };\n\n // Sort nodes by key for deterministic ordering\n const sortedNodes = Array.from(sccNodes).sort((a, b) =>\n a.key.localeCompare(b.key)\n );\n\n for (const n of sortedNodes) {\n if (!visited.has(n)) {\n dfs(n);\n }\n }\n\n return result;\n }\n\n /**\n * Compute hash representing the graph structure including SCC information\n */\n private computeGraphHash(\n allNodes: Map<string, DependencyNode>,\n sccList: import(\"../types.mjs\").SCC[]\n ): string {\n const parts: string[] = [];\n\n // Hash nodes and their dependencies\n for (const [key, node] of Array.from(allNodes.entries()).sort()) {\n const deps = Array.from(node.getAllDependencies())\n .map((d) => d.key)\n .sort()\n .join(\",\");\n parts.push(`${key}:[${deps}]`);\n }\n\n // Add SCC structure\n for (const scc of sccList) {\n const nodeKeys = Array.from(scc.nodes)\n .map((n) => n.key)\n .sort()\n .join(\",\");\n parts.push(`SCC${scc.id}:{${nodeKeys}}`);\n }\n\n return parts.join(\"|\");\n }\n\n /**\n * Compute a hash representing the current state of evaluated nodes\n * This hash changes when dependencies, frontier dependencies, or discarded frontier dependencies change\n */\n private computeHash(allNodes: Set<DependencyNode>): string {\n const nodeStates: string[] = [];\n\n for (const node of Array.from(allNodes).sort()) {\n if (node) {\n const deps = Array.from(node.getDependencies() || [])\n .map((dep) => dep.key)\n .sort()\n .join(\",\");\n\n // Handle frontier dependencies (Map<string, Set<string>>)\n const frontierDeps: string = Array.from(node.getFrontierDependencies())\n .map((dep) => dep.key)\n .sort()\n .join(\";\");\n\n const nodeState = `${node.key}:{deps:[${deps}],frontier:[${frontierDeps}]}`;\n nodeStates.push(nodeState);\n }\n }\n\n return nodeStates.join(\"|\");\n }\n\n /**\n * Get a hierarchical dependency tree for a node\n */\n getDependencyTree(node: DependencyNode): DependencyTreeNode {\n const visited = new Set<DependencyNode>();\n\n const nodeToType = (node: DependencyNode): \"cell\" | \"range\" | \"empty\" => {\n if (node instanceof RangeEvaluationNode) {\n return \"range\";\n }\n if (node instanceof EmptyCellEvaluationNode) {\n return \"empty\";\n }\n return \"cell\";\n };\n\n const buildTree = (\n node: DependencyNode,\n isSelf = false\n ): DependencyTreeNode => {\n const cellRef: string = node.toString();\n\n // Handle self-reference to avoid infinite recursion\n if (isSelf) {\n return {\n type: nodeToType(node),\n resultType:\n node instanceof RangeEvaluationNode\n ? \"range\"\n : node.evaluationResult\n ? node.evaluationResult.type\n : \"awaiting-evaluation\",\n canResolve: node.canResolve(),\n key: cellRef,\n directDepsUpdated: node.directDepsUpdated,\n resolved: node.resolved,\n self: true,\n circular: true,\n };\n }\n\n // Avoid infinite recursion for circular dependencies\n if (visited.has(node)) {\n return {\n type: nodeToType(node),\n resultType:\n node instanceof RangeEvaluationNode\n ? \"range\"\n : node.evaluationResult\n ? node.evaluationResult.type\n : \"awaiting-evaluation\",\n canResolve: node.canResolve(),\n key: cellRef,\n directDepsUpdated: node.directDepsUpdated,\n resolved: node.resolved,\n circular: true,\n };\n }\n\n visited.add(node);\n\n const directDeps = Array.from(node.getDependencies());\n let frontierDeps = Array.from(node.getFrontierDependencies());\n\n // Get regular dependencies\n const deps: DependencyTreeNode[] = directDeps.map((dep) =>\n buildTree(dep, dep.key === node.key)\n );\n\n const frontierDependencies: DependencyTreeNode[] = frontierDeps.map(\n (dep) => buildTree(dep, false)\n );\n\n visited.delete(node);\n\n const result: DependencyTreeNode = {\n type: nodeToType(node),\n resultType:\n node instanceof RangeEvaluationNode\n ? \"range\"\n : node.evaluationResult\n ? node.evaluationResult.type\n : \"awaiting-evaluation\",\n canResolve: node.canResolve(),\n key: cellRef,\n directDepsUpdated: node.directDepsUpdated,\n resolved: node.resolved,\n };\n\n // Only include deps and frontierDependencies if they have content\n if (deps.length > 0) {\n result.deps = deps;\n }\n if (frontierDependencies.length > 0) {\n result.frontierDependencies = frontierDependencies;\n }\n\n return result;\n };\n\n return buildTree(node);\n }\n //#endregion\n\n markResolvedNodes(node: DependencyNode): void {\n // Track visited nodes to avoid infinite loops in circular dependencies\n const visited = new Set<DependencyNode>();\n visited.add(node); // Don't revisit the current cell\n\n const areTransitiveDepsResolved = (nodes: Set<DependencyNode>): boolean => {\n let canResolve = true;\n for (const node of nodes) {\n if (visited.has(node) || node.resolved) {\n continue;\n }\n visited.add(node);\n\n // Check the node's dependencies to not cause cycles with frontier dependencies\n const directDeps = node.getDependencies();\n\n const a = areTransitiveDepsResolved(directDeps);\n const b = node.canResolve();\n\n if (!a || !b) {\n canResolve = false;\n }\n if (a && b) {\n node.resolve();\n // if an ast node is resolved, it will get removed from the dependency graph\n // and thus never reach evaluateNode in formula evaluator\n // so we need to save it here. The latest context dependency is the correct one.\n if (node instanceof AstEvaluationNode) {\n this.saveAstNode(node, node.getContextDependency());\n }\n }\n }\n return canResolve;\n };\n\n if (\n areTransitiveDepsResolved(node.getDependencies()) &&\n node.canResolve()\n ) {\n node.resolve();\n if (node instanceof AstEvaluationNode) {\n this.saveAstNode(node, node.getContextDependency());\n }\n }\n }\n\n /**\n * Update SCCs in cache to mark them as resolved if all their nodes are resolved\n */\n public updateResolvedSCCs(evalOrder: EvaluationOrder): void {\n if (!evalOrder.sccDAG) {\n return;\n }\n\n // Check each SCC and update cache if all nodes are resolved\n for (const scc of evalOrder.sccDAG.sccList) {\n const allResolved = Array.from(scc.nodes).every((n) => n.resolved);\n\n if (allResolved && !scc.resolved) {\n // Create updated SCC with resolved flag\n const updatedSCC: import(\"../types.mjs\").SCC = {\n ...scc,\n resolved: true,\n };\n\n // Update cache\n const sccHash = Array.from(scc.nodes)\n .map((n) => n.key)\n .sort()\n .join(\"|\");\n\n this.cacheManager.setSCC(sccHash, updatedSCC);\n }\n }\n }\n}\n"
6
6
  ],
7
- "mappings": ";AAAA;AAAA;AAAA;AAAA;AAUA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAAA;AAoCO,MAAM,kBAAkB;AAAA,EAiCnB;AAAA,EACA;AAAA,EA9BF,iBAMJ,IAAI;AAAA,EAEA,iBAA6C,IAAI;AAAA,EAEjD,aAAmD,IAAI;AAAA,EAKvD,iBAMJ,IAAI;AAAA,EAKA,SAA2C,IAAI;AAAA,EAEvD,WAAW,CACD,cACA,iBACR;AAAA,IAFQ;AAAA,IACA;AAAA;AAAA,MAGC,aAAa,GAAmC;AAAA,IACzD,OAAO,KAAK,eAAe,OAAO;AAAA;AAAA,EAGpC,aAAa,CAAC,aAAmC;AAAA,IAC/C,WAAW,gBAAgB,KAAK,eAAe,OAAO,GAAG;AAAA,MACvD,IACE,aAAa,OAAO,cAAc,YAAY,aAC9C,aAAa,OAAO,iBAAiB,YAAY,cACjD;AAAA,QACA;AAAA,MACF;AAAA,MACA,IACE,aAAa,OAAO,aAAa,YAAY,YAC7C,aAAa,OAAO,aAAa,YAAY,UAC7C;AAAA,QACA,OAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,OAAO;AAAA;AAAA,EAGT,aAAa,CAAC,aAAoD;AAAA,IAChE,WAAW,gBAAgB,KAAK,eAAe,OAAO,GAAG;AAAA,MACvD,IACE,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