@ricsam/formula-engine 0.0.18 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/core/engine.cjs +47 -37
- package/dist/cjs/core/engine.cjs.map +3 -3
- package/dist/cjs/core/managers/evaluation-manager.cjs +7 -1
- package/dist/cjs/core/managers/evaluation-manager.cjs.map +3 -3
- package/dist/cjs/core/managers/table-manager.cjs +21 -1
- package/dist/cjs/core/managers/table-manager.cjs.map +3 -3
- package/dist/cjs/lib.cjs +3 -3
- package/dist/cjs/lib.cjs.map +2 -2
- package/dist/cjs/package.json +1 -1
- package/dist/mjs/core/engine.mjs +28 -10
- package/dist/mjs/core/engine.mjs.map +3 -3
- package/dist/mjs/core/managers/evaluation-manager.mjs +7 -1
- package/dist/mjs/core/managers/evaluation-manager.mjs.map +3 -3
- package/dist/mjs/core/managers/table-manager.mjs +22 -2
- package/dist/mjs/core/managers/table-manager.mjs.map +3 -3
- package/dist/mjs/lib.mjs +2 -2
- package/dist/mjs/lib.mjs.map +2 -2
- package/dist/mjs/package.json +1 -1
- package/dist/types/core/engine.d.ts +3 -2
- package/dist/types/core/managers/table-manager.d.ts +6 -1
- package/dist/types/lib.d.ts +2 -2
- package/package.json +1 -1
- package/dist/cjs/core/commands/index.cjs +0 -95
- package/dist/cjs/core/commands/index.cjs.map +0 -10
- package/dist/mjs/core/commands/index.mjs +0 -87
- package/dist/mjs/core/commands/index.mjs.map +0 -10
- package/dist/types/core/commands/index.d.ts +0 -16
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/core/managers/evaluation-manager.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { flags } from \"../../debug/flags.cjs\";\nimport { AstEvaluationNode } from \"../../evaluator/dependency-nodes/ast-evaluation-node.cjs\";\nimport { CellValueNode } from \"../../evaluator/dependency-nodes/cell-value-node.cjs\";\nimport { EvaluationContext } from \"../../evaluator/evaluation-context.cjs\";\nimport {\n EvaluationError,\n SheetNotFoundError,\n} from \"../../evaluator/evaluation-error.cjs\";\nimport { RangeEvaluationNode } from \"../../evaluator/range-evaluation-node.cjs\";\nimport { normalizeSerializedCellValue } from \"../../parser/formatter.cjs\";\nimport { FormulaEvaluator } from \"../../evaluator/formula-evaluator.cjs\";\nimport {\n FormulaError,\n type CellAddress,\n type CellInRangeResult,\n type CellValue,\n type ErrorEvaluationResult,\n type EvaluateAllCellsResult,\n type EvaluationOrder,\n type FunctionEvaluationResult,\n type SerializedCellValue,\n type SingleEvaluationResult,\n type SpreadsheetRange,\n type TableDefinition,\n type ValueEvaluationResult,\n} from \"../types.cjs\";\nimport {\n captureEvaluationErrors,\n cellAddressToKey,\n checkRangeIntersection,\n getCellReference,\n isCellInRange,\n isRangeOneCell,\n keyToCellAddress,\n parseCellReference,\n} from \"../utils.cjs\";\nimport type { DependencyManager } from \"./dependency-manager.cjs\";\nimport type { WorkbookManager } from \"./workbook-manager.cjs\";\nimport { SpillMetaNode } from \"../../evaluator/dependency-nodes/spill-meta-node.cjs\";\nimport { EmptyCellEvaluationNode } from \"../../evaluator/dependency-nodes/empty-cell-evaluation-node.cjs\";\nimport type { TableManager } from \"./table-manager.cjs\";\nimport { parseFormula } from \"../../parser/parser.cjs\";\nimport type { DependencyNode } from \"./dependency-node.cjs\";\nimport { VirtualCellValueNode } from \"../../evaluator/dependency-nodes/virtual-cell-value-node.cjs\";\n\nexport class EvaluationManager {\n private isEvaluating = false;\n\n constructor(\n private workbookManager: WorkbookManager,\n private tableManager: TableManager,\n private formulaEvaluator: FormulaEvaluator,\n private dependencyManager: DependencyManager\n ) {}\n\n clearEvaluationCache(): void {\n this.dependencyManager.clearEvaluationCache();\n }\n\n evaluationResultToSerializedValue(\n evaluation: SingleEvaluationResult,\n cellAddress: CellAddress,\n debug?: boolean\n ): SerializedCellValue {\n if (\n evaluation.type !== \"error\" &&\n evaluation.type !== \"awaiting-evaluation\"\n ) {\n const value = evaluation.result;\n\n return value.type === \"infinity\"\n ? value.sign === \"positive\"\n ? \"INFINITY\"\n : \"-INFINITY\"\n : value.value;\n }\n\n if (evaluation.type === \"awaiting-evaluation\") {\n return (\n evaluation.errAddress.key +\n \" is awaiting evaluation of \" +\n evaluation.waitingFor.key\n );\n }\n\n if (debug) {\n const errAddress = evaluation.errAddress.key;\n if (errAddress === cellAddressToKey(cellAddress)) {\n return evaluation.err + \" \" + evaluation.message;\n }\n return (\n evaluation.err +\n \" in \" +\n evaluation.errAddress.key +\n \" \" +\n evaluation.message\n );\n }\n\n return evaluation.err;\n }\n\n evaluateEmptyCell(node: EmptyCellEvaluationNode): void {\n node.resetDirectDepsUpdated();\n\n if (node.resolved) {\n const result = node.evaluationResult;\n if (result && result.type !== \"awaiting-evaluation\") {\n return;\n }\n }\n\n const ctx = new EvaluationContext(\n this.tableManager,\n node,\n node.cellAddress\n );\n const inSpilled = this.dependencyManager.getSpillValue(node.cellAddress);\n\n if (inSpilled) {\n // if we are spilling then we can just add the spill origin as a dependency and evaluate the spilled value\n const spillTarget = this.dependencyManager.getSpilledAddress(\n node.cellAddress,\n inSpilled\n );\n const spillOriginKey = cellAddressToKey(inSpilled.origin).replace(\n /^[^:]+:/,\n \"spill-meta:\"\n );\n const spillMetaNode =\n this.dependencyManager.getSpillMetaNode(spillOriginKey);\n node.addDependency(spillMetaNode);\n const result = spillMetaNode.evaluationResult;\n if (result.type === \"spilled-values\") {\n // let's evaluate the spilled value to extract dependencies\n const evaluation = captureEvaluationErrors(spillMetaNode, () => {\n return result.evaluate(spillTarget.spillOffset, ctx);\n });\n node.setEvaluationResult(evaluation);\n }\n } else {\n // upgrade any frontier dependencies that spill into the range\n node.upgradeFrontierDependencies();\n\n const evaluationResult: SingleEvaluationResult = {\n type: \"value\",\n result: this.convertScalarValueToCellValue(\"\"),\n };\n // for now let's just store the empty value, the next time the cell is evaluated isSpilled will be true and the spilled value will be evaluated\n node.setEvaluationResult(evaluationResult);\n }\n }\n\n evaluateRangeNode(node: RangeEvaluationNode): void {\n if (node.resolved) {\n return;\n }\n\n node.resetDirectDepsUpdated();\n\n const result = captureEvaluationErrors(node, (): EvaluateAllCellsResult => {\n node.upgradeFrontierDependencies();\n\n const evalOrder = node.getRangeEvalOrder();\n\n const results: CellInRangeResult[] = [];\n\n for (const entry of evalOrder) {\n if (entry.type === \"value\") {\n const entryAddress = entry.address;\n const result = entry.node.evaluationResult;\n\n const relativePos = {\n x: entryAddress.colIndex - node.address.range.start.col,\n y: entryAddress.rowIndex - node.address.range.start.row,\n };\n\n results.push({ result: result, relativePos });\n } else if (\n entry.type === \"empty_cell\" ||\n entry.type === \"empty_range\"\n ) {\n for (const candidateNode of entry.candidates) {\n if (candidateNode.evaluationResult.type === \"spilled-values\") {\n const spillArea = candidateNode.evaluationResult.spillArea(\n candidateNode.cellAddress\n );\n if (entry.type === \"empty_range\") {\n const intersects = checkRangeIntersection(\n spillArea,\n entry.address.range\n );\n if (intersects) {\n // When a spilled range intersects with our target range, we need to evaluate\n // only the cells that fall within the intersection area.\n //\n // Example: If cell A10 contains a spilled range that covers A10:B11,\n // and our target range is B10:INFINITY, then we only want to evaluate\n // the intersection B10:B11 from the spilled range.\n //\n // The evaluateAllCells method expects the intersection to be passed\n // so it can limit evaluation to only the relevant cells.\n const ctx = new EvaluationContext(\n this.tableManager,\n node,\n candidateNode.cellAddress\n );\n const spilledResults =\n candidateNode.evaluationResult.evaluateAllCells.call(\n this.formulaEvaluator,\n {\n context: ctx,\n evaluate: candidateNode.evaluationResult.evaluate,\n intersection: entry.address.range,\n origin: candidateNode.cellAddress,\n lookupOrder: \"col-major\",\n }\n );\n\n if (spilledResults.type === \"values\") {\n results.push(...spilledResults.values);\n } else {\n return spilledResults;\n }\n }\n } else {\n const intersects = isCellInRange(entry.address, spillArea);\n if (intersects) {\n // When a spilled range intersects with our target range, we need to evaluate\n // only the cells that fall within the intersection area.\n //\n // Example: If cell A10 contains a spilled range that covers A10:B11,\n // and our target range is B10:INFINITY, then we only want to evaluate\n // the intersection B10:B11 from the spilled range.\n //\n // The evaluateAllCells method expects the intersection to be passed\n // so it can limit evaluation to only the relevant cells.\n\n const relativePos = {\n x:\n entry.address.colIndex -\n candidateNode.cellAddress.colIndex,\n y:\n entry.address.rowIndex -\n candidateNode.cellAddress.rowIndex,\n };\n const ctx = new EvaluationContext(\n this.tableManager,\n node,\n candidateNode.cellAddress\n );\n const spilledResult = candidateNode.evaluationResult.evaluate(\n relativePos,\n ctx\n );\n\n results.push({\n relativePos: {\n x: entry.address.colIndex - node.address.range.start.col,\n y: entry.address.rowIndex - node.address.range.start.row,\n },\n result: spilledResult,\n });\n }\n }\n }\n }\n }\n }\n\n return {\n type: \"values\",\n values: results,\n };\n });\n\n node.setResult(result);\n }\n\n evaluateCellNode(\n node: CellValueNode | SpillMetaNode | VirtualCellValueNode\n ): void {\n // Enable caching for resolved nodes\n if (node.resolved) {\n return;\n }\n\n node.resetDirectDepsUpdated();\n\n const ctx = new EvaluationContext(\n this.tableManager,\n node,\n node.cellAddress\n );\n\n if (node instanceof CellValueNode && node.spillMeta) {\n // we are evaluating a e.g. A1 in A1=SEQUENCE(10), where we want the value in the cell in A1, i.e. 1\n // As A1 is already pointing to a spill meta node, everything has been setup already,\n // we just need to evaluate the spill origin and assign the result to the currentDepNode\n const spillOrigin = node.spillMeta;\n if (spillOrigin.evaluationResult.type === \"spilled-values\") {\n const result = spillOrigin.evaluationResult.evaluate(\n { x: 0, y: 0 },\n ctx\n );\n node.setEvaluationResult(result);\n return;\n }\n }\n\n let content: SerializedCellValue;\n try {\n if (node instanceof VirtualCellValueNode) {\n content = node.cellValue;\n } else {\n content = this.workbookManager.getSerializedCellValue(node.cellAddress);\n }\n } catch (err) {\n const evaluationResult: ErrorEvaluationResult = {\n type: \"error\",\n err: FormulaError.ERROR,\n message: \"Syntax error\",\n errAddress: node,\n };\n node.setEvaluationResult(evaluationResult);\n return;\n }\n\n if (typeof content !== \"string\" || !content.startsWith(\"=\")) {\n if (node instanceof SpillMetaNode) {\n node.setEvaluationResult({\n type: \"does-not-spill\",\n });\n return;\n }\n // Static value cells cannot have frontier dependencies\n const result: ValueEvaluationResult = {\n type: \"value\",\n result: this.convertScalarValueToCellValue(content),\n };\n node.setEvaluationResult(result);\n return;\n }\n\n let evaluation: FunctionEvaluationResult = captureEvaluationErrors(\n node,\n () => this.formulaEvaluator.evaluateFormula(content.slice(1), ctx)\n );\n\n // the evaluated cell IS A spilling formula, e.g. if dependencyKey points to A1, then the formula is e.g. A1=SEQUENCE(10), or A1=A3:B5\n if (evaluation.type === \"spilled-values\") {\n const spillArea = evaluation.spillArea(node.cellAddress);\n\n if (!this.canSpill(node.cellAddress, spillArea)) {\n // Override evaluation with SPILL error, but continue execution to set up nodes\n evaluation = {\n type: \"error\",\n err: FormulaError.SPILL,\n message: \"Cannot spill - area is blocked\",\n errAddress: node,\n };\n } else {\n // Spill succeeds - register it\n this.dependencyManager.setSpilledValue(node.key, {\n spillOnto: spillArea,\n origin: node.cellAddress,\n });\n }\n\n // Set up spill meta node and evaluation results (even if spill failed)\n if (node instanceof SpillMetaNode) {\n // we have already setup an origin/spill meta node relationship,\n // so we are just reevaluating the spill meta node here\n node.setEvaluationResult(evaluation);\n } else {\n const spillMetaNode = this.dependencyManager.getSpillMetaNode(\n node.key.replace(/^[^:]+:/, \"spill-meta:\")\n );\n\n node.addDependency(spillMetaNode);\n node.setSpillMetaNode(spillMetaNode);\n spillMetaNode.setEvaluationResult(evaluation);\n\n if (evaluation.type === \"spilled-values\") {\n const originResult = evaluation.evaluate({ x: 0, y: 0 }, ctx);\n node.setEvaluationResult(originResult);\n } else {\n // Spill failed - set error on origin cell\n node.setEvaluationResult(evaluation);\n }\n }\n return;\n }\n\n if (evaluation.type === \"value\") {\n if (node instanceof SpillMetaNode) {\n node.setEvaluationResult({\n type: \"does-not-spill\",\n });\n return;\n } else {\n node.setEvaluationResult(evaluation);\n return;\n }\n }\n\n node.setEvaluationResult(evaluation);\n }\n\n evaluateDependencyNode(dependency: DependencyNode): void {\n if (dependency instanceof EmptyCellEvaluationNode) {\n this.evaluateEmptyCell(dependency);\n return;\n }\n if (dependency instanceof RangeEvaluationNode) {\n this.evaluateRangeNode(dependency);\n return;\n }\n if (\n dependency instanceof CellValueNode ||\n dependency instanceof VirtualCellValueNode\n ) {\n this.evaluateCellNode(dependency);\n return;\n }\n if (dependency instanceof AstEvaluationNode) {\n return;\n }\n if (dependency instanceof SpillMetaNode) {\n this.evaluateCellNode(dependency);\n return;\n }\n throw new Error(\"Invalid dependency: \" + (dependency as any).key);\n }\n\n /**\n * User exposed method to evaluate a formula\n */\n evaluateFormula(\n /**\n * formula for example\n */\n cellValue: SerializedCellValue,\n cellAddress: CellAddress\n ): SerializedCellValue {\n if (this.isEvaluating) {\n throw new Error(\"Evaluation in progress\");\n }\n\n const node = this.dependencyManager.getVirtualCellValueNode(\n cellAddress,\n cellValue\n );\n\n if (node.evaluationResult.type === \"awaiting-evaluation\") {\n this.evaluateCell(node);\n }\n\n const result = node.evaluationResult;\n\n return this.evaluationResultToSerializedValue(result, cellAddress);\n }\n\n /**\n * Evaluates a cell by building the evaluation order and evaluating the dependencies in order\n */\n evaluateCell(\n node: CellValueNode | EmptyCellEvaluationNode | VirtualCellValueNode\n ): void {\n if (this.isEvaluating) {\n throw new Error(\"Evaluation in progress\");\n }\n this.isEvaluating = true;\n\n let precalculatedPlan: EvaluationOrder | undefined;\n\n let requiresReRun = true;\n while (requiresReRun) {\n requiresReRun = false;\n\n // Use DependencyManager to build evaluation order\n const evaluationPlan =\n precalculatedPlan ?? this.dependencyManager.buildEvaluationOrder(node);\n\n if (evaluationPlan.hasCycle) {\n const evaluationResult: ErrorEvaluationResult = {\n type: \"error\",\n err: FormulaError.CYCLE,\n message: Array.from(evaluationPlan.cycleNodes ?? [])\n .map((node) => node.key)\n .join(\" -> \"),\n errAddress: node,\n };\n // cycle detected\n if (evaluationPlan.cycleNodes) {\n for (const node of evaluationPlan.cycleNodes) {\n if (!(node instanceof RangeEvaluationNode)) {\n node.setEvaluationResult(evaluationResult);\n }\n }\n }\n this.isEvaluating = false;\n }\n\n // Evaluate all dependencies in order\n const timeStart = performance.now();\n const durations: { duration: number; key: string }[] = [];\n let numResolved = 0;\n if (flags.isProfiling && evaluationPlan.evaluationOrder.size > -1) {\n // console.profile();\n }\n evaluationPlan.evaluationOrder.forEach((dependency) => {\n const start = performance.now();\n if (dependency.resolved) {\n numResolved++;\n }\n this.evaluateDependencyNode(dependency);\n\n const end = performance.now();\n if (flags.isProfiling && evaluationPlan.evaluationOrder.size > -1) {\n durations.push({ duration: end - start, key: dependency.key });\n }\n });\n if (flags.isProfiling && evaluationPlan.evaluationOrder.size > -1) {\n // console.profileEnd();\n }\n if (flags.isProfiling && evaluationPlan.evaluationOrder.size > -1) {\n const percentResolved = Math.round(\n (100 * numResolved) / evaluationPlan.evaluationOrder.size\n );\n const avgDuration =\n durations.reduce((a, b) => a + b.duration, 0) / durations.length || 0;\n console.log(\n `%c[Evaluation] %c${evaluationPlan.evaluationOrder.size} deps | %c${(\n performance.now() - timeStart\n ).toFixed(\n 1\n )}ms | %c${percentResolved}% resolved | %c${avgDuration.toFixed(\n 2\n )}ms avg`,\n \"color:#83aaff;font-weight:bold;\",\n \"color:#fff;font-weight:bold;\",\n \"color:#7fff9e\",\n \"color:#85baff\",\n \"color:#ffdfa3\"\n );\n }\n\n this.dependencyManager.markResolvedNodes(node);\n\n const nextEvaluationPlan =\n this.dependencyManager.buildEvaluationOrder(node);\n\n this.dependencyManager.updateResolvedSCCs(nextEvaluationPlan);\n\n precalculatedPlan = nextEvaluationPlan;\n\n // Check if new dependencies were discovered during evaluation\n if (nextEvaluationPlan.hash !== evaluationPlan.hash) {\n requiresReRun = true;\n } else {\n this.isEvaluating = false;\n return;\n }\n }\n this.isEvaluating = false;\n }\n\n convertScalarValueToCellValue(val: SerializedCellValue): CellValue {\n if (typeof val === \"number\") {\n return { type: \"number\", value: val };\n }\n if (typeof val === \"boolean\") {\n return { type: \"boolean\", value: val };\n }\n if (typeof val === \"undefined\") {\n return { type: \"string\", value: \"\" };\n }\n return { type: \"string\", value: val };\n }\n\n // todo optimize using workbook manager\n canSpill(spillCandidate: CellAddress, spillArea: SpreadsheetRange): boolean {\n const sheet = this.workbookManager.getSheet(spillCandidate);\n if (!sheet) {\n throw new SheetNotFoundError(spillCandidate.sheetName);\n }\n const cellId = getCellReference(spillCandidate);\n const content = sheet.content.get(cellId);\n if (!content) {\n throw new EvaluationError(FormulaError.REF, `Cell not found: ${cellId}`);\n }\n for (const spilledValue of this.dependencyManager.spilledValues) {\n if (\n spilledValue.origin.workbookName !== spillCandidate.workbookName ||\n spilledValue.origin.sheetName !== spillCandidate.sheetName\n ) {\n continue;\n }\n if (\n spilledValue.origin.colIndex === spillCandidate.colIndex &&\n spilledValue.origin.rowIndex === spillCandidate.rowIndex\n ) {\n // we are already have a spill, this one will be replaced\n continue;\n }\n\n if (checkRangeIntersection(spillArea, spilledValue.spillOnto)) {\n return false;\n }\n }\n // let's just check the raw data if there is something in the range\n for (const key of sheet.content.keys()) {\n const cellAddress = parseCellReference(key);\n const endCol = spillArea.end.col;\n const endRow = spillArea.end.row;\n\n if (\n cellAddress.colIndex === spillCandidate.colIndex &&\n cellAddress.rowIndex === spillCandidate.rowIndex\n ) {\n continue;\n }\n\n if (endCol.type === \"number\" && endRow.type === \"number\") {\n if (\n cellAddress.colIndex >= spillArea.start.col &&\n cellAddress.colIndex <= endCol.value &&\n cellAddress.rowIndex >= spillArea.start.row &&\n cellAddress.rowIndex <= endRow.value\n ) {\n if (\n normalizeSerializedCellValue(sheet.content.get(key)) !== undefined\n ) {\n // there is something in the range, so we can't spill\n return false;\n }\n }\n }\n }\n\n return true;\n }\n\n getCellEvaluationResult(\n cellAddress: CellAddress\n ): SingleEvaluationResult | undefined {\n if (this.isEvaluating) {\n throw new Error(\"Evaluation in progress\");\n }\n\n const nodeKey = cellAddressToKey(cellAddress);\n const node = this.dependencyManager.getCellValueOrEmptyCellNode(nodeKey);\n\n const sheet = this.workbookManager.getSheet(cellAddress);\n if (!sheet) {\n throw new SheetNotFoundError(cellAddress.sheetName);\n }\n\n if (node.evaluationResult.type === \"awaiting-evaluation\") {\n // if (cellAddressToKey(cellAddress).includes(\"G10\")) {\n // console.group(\"Evaluation of G10\");\n // flags.isProfiling = true;\n // console.time(\"Evaluation of G10\");\n // console.profile(\"Evaluation of G10\");\n // }\n this.evaluateCell(node);\n // if (flags.isProfiling) {\n // flags.isProfiling = false;\n // console.timeEnd(\"Evaluation of G10\");\n // console.profileEnd(\"Evaluation of G10\");\n // console.groupEnd();\n // }\n }\n\n const result = node.evaluationResult;\n\n return result;\n }\n}\n"
|
|
5
|
+
"import { flags } from \"../../debug/flags.cjs\";\nimport { AstEvaluationNode } from \"../../evaluator/dependency-nodes/ast-evaluation-node.cjs\";\nimport { CellValueNode } from \"../../evaluator/dependency-nodes/cell-value-node.cjs\";\nimport { EvaluationContext } from \"../../evaluator/evaluation-context.cjs\";\nimport {\n EvaluationError,\n SheetNotFoundError,\n} from \"../../evaluator/evaluation-error.cjs\";\nimport { RangeEvaluationNode } from \"../../evaluator/range-evaluation-node.cjs\";\nimport { normalizeSerializedCellValue } from \"../../parser/formatter.cjs\";\nimport { FormulaEvaluator } from \"../../evaluator/formula-evaluator.cjs\";\nimport {\n FormulaError,\n type CellAddress,\n type CellInRangeResult,\n type CellValue,\n type ErrorEvaluationResult,\n type EvaluateAllCellsResult,\n type EvaluationOrder,\n type FunctionEvaluationResult,\n type SerializedCellValue,\n type SingleEvaluationResult,\n type SpreadsheetRange,\n type TableDefinition,\n type ValueEvaluationResult,\n} from \"../types.cjs\";\nimport {\n captureEvaluationErrors,\n cellAddressToKey,\n checkRangeIntersection,\n getCellReference,\n isCellInRange,\n isRangeOneCell,\n keyToCellAddress,\n parseCellReference,\n} from \"../utils.cjs\";\nimport type { DependencyManager } from \"./dependency-manager.cjs\";\nimport type { WorkbookManager } from \"./workbook-manager.cjs\";\nimport { SpillMetaNode } from \"../../evaluator/dependency-nodes/spill-meta-node.cjs\";\nimport { EmptyCellEvaluationNode } from \"../../evaluator/dependency-nodes/empty-cell-evaluation-node.cjs\";\nimport type { TableManager } from \"./table-manager.cjs\";\nimport { parseFormula } from \"../../parser/parser.cjs\";\nimport type { DependencyNode } from \"./dependency-node.cjs\";\nimport { VirtualCellValueNode } from \"../../evaluator/dependency-nodes/virtual-cell-value-node.cjs\";\n\nexport class EvaluationManager {\n private isEvaluating = false;\n\n constructor(\n private workbookManager: WorkbookManager,\n private tableManager: TableManager,\n private formulaEvaluator: FormulaEvaluator,\n private dependencyManager: DependencyManager\n ) {}\n\n clearEvaluationCache(): void {\n this.dependencyManager.clearEvaluationCache();\n }\n\n evaluationResultToSerializedValue(\n evaluation: SingleEvaluationResult,\n cellAddress: CellAddress,\n debug?: boolean\n ): SerializedCellValue {\n if (\n evaluation.type !== \"error\" &&\n evaluation.type !== \"awaiting-evaluation\"\n ) {\n const value = evaluation.result;\n\n return value.type === \"infinity\"\n ? value.sign === \"positive\"\n ? \"INFINITY\"\n : \"-INFINITY\"\n : value.value;\n }\n\n if (evaluation.type === \"awaiting-evaluation\") {\n return (\n evaluation.errAddress.key +\n \" is awaiting evaluation of \" +\n evaluation.waitingFor.key\n );\n }\n\n if (debug) {\n const errAddress = evaluation.errAddress.key;\n if (errAddress === cellAddressToKey(cellAddress)) {\n return evaluation.err + \" \" + evaluation.message;\n }\n return (\n evaluation.err +\n \" in \" +\n evaluation.errAddress.key +\n \" \" +\n evaluation.message\n );\n }\n\n return evaluation.err;\n }\n\n evaluateEmptyCell(node: EmptyCellEvaluationNode): void {\n node.resetDirectDepsUpdated();\n\n if (node.resolved) {\n const result = node.evaluationResult;\n if (result && result.type !== \"awaiting-evaluation\") {\n return;\n }\n }\n\n const ctx = new EvaluationContext(\n this.tableManager,\n node,\n node.cellAddress\n );\n const inSpilled = this.dependencyManager.getSpillValue(node.cellAddress);\n\n if (inSpilled) {\n // if we are spilling then we can just add the spill origin as a dependency and evaluate the spilled value\n const spillTarget = this.dependencyManager.getSpilledAddress(\n node.cellAddress,\n inSpilled\n );\n const spillOriginKey = cellAddressToKey(inSpilled.origin).replace(\n /^[^:]+:/,\n \"spill-meta:\"\n );\n const spillMetaNode =\n this.dependencyManager.getSpillMetaNode(spillOriginKey);\n node.addDependency(spillMetaNode);\n const result = spillMetaNode.evaluationResult;\n if (result.type === \"spilled-values\") {\n // let's evaluate the spilled value to extract dependencies\n const evaluation = captureEvaluationErrors(spillMetaNode, () => {\n return result.evaluate(spillTarget.spillOffset, ctx);\n });\n node.setEvaluationResult(evaluation);\n }\n } else {\n // upgrade any frontier dependencies that spill into the range\n node.upgradeFrontierDependencies();\n\n const evaluationResult: SingleEvaluationResult = {\n type: \"value\",\n result: this.convertScalarValueToCellValue(\"\"),\n };\n // for now let's just store the empty value, the next time the cell is evaluated isSpilled will be true and the spilled value will be evaluated\n node.setEvaluationResult(evaluationResult);\n }\n }\n\n evaluateRangeNode(node: RangeEvaluationNode): void {\n if (node.resolved) {\n return;\n }\n\n node.resetDirectDepsUpdated();\n\n const result = captureEvaluationErrors(node, (): EvaluateAllCellsResult => {\n node.upgradeFrontierDependencies();\n\n const evalOrder = node.getRangeEvalOrder();\n\n const results: CellInRangeResult[] = [];\n\n for (const entry of evalOrder) {\n if (entry.type === \"value\") {\n const entryAddress = entry.address;\n const result = entry.node.evaluationResult;\n\n const relativePos = {\n x: entryAddress.colIndex - node.address.range.start.col,\n y: entryAddress.rowIndex - node.address.range.start.row,\n };\n\n results.push({ result: result, relativePos });\n } else if (\n entry.type === \"empty_cell\" ||\n entry.type === \"empty_range\"\n ) {\n for (const candidateNode of entry.candidates) {\n if (candidateNode.evaluationResult.type === \"spilled-values\") {\n const spillArea = candidateNode.evaluationResult.spillArea(\n candidateNode.cellAddress\n );\n if (entry.type === \"empty_range\") {\n const intersects = checkRangeIntersection(\n spillArea,\n entry.address.range\n );\n if (intersects) {\n // When a spilled range intersects with our target range, we need to evaluate\n // only the cells that fall within the intersection area.\n //\n // Example: If cell A10 contains a spilled range that covers A10:B11,\n // and our target range is B10:INFINITY, then we only want to evaluate\n // the intersection B10:B11 from the spilled range.\n //\n // The evaluateAllCells method expects the intersection to be passed\n // so it can limit evaluation to only the relevant cells.\n const ctx = new EvaluationContext(\n this.tableManager,\n node,\n candidateNode.cellAddress\n );\n const spilledResults =\n candidateNode.evaluationResult.evaluateAllCells.call(\n this.formulaEvaluator,\n {\n context: ctx,\n evaluate: candidateNode.evaluationResult.evaluate,\n intersection: entry.address.range,\n origin: candidateNode.cellAddress,\n lookupOrder: \"col-major\",\n }\n );\n\n if (spilledResults.type === \"values\") {\n results.push(...spilledResults.values);\n } else {\n return spilledResults;\n }\n }\n } else {\n const intersects = isCellInRange(entry.address, spillArea);\n if (intersects) {\n // When a spilled range intersects with our target range, we need to evaluate\n // only the cells that fall within the intersection area.\n //\n // Example: If cell A10 contains a spilled range that covers A10:B11,\n // and our target range is B10:INFINITY, then we only want to evaluate\n // the intersection B10:B11 from the spilled range.\n //\n // The evaluateAllCells method expects the intersection to be passed\n // so it can limit evaluation to only the relevant cells.\n\n const relativePos = {\n x:\n entry.address.colIndex -\n candidateNode.cellAddress.colIndex,\n y:\n entry.address.rowIndex -\n candidateNode.cellAddress.rowIndex,\n };\n const ctx = new EvaluationContext(\n this.tableManager,\n node,\n candidateNode.cellAddress\n );\n const spilledResult = candidateNode.evaluationResult.evaluate(\n relativePos,\n ctx\n );\n\n results.push({\n relativePos: {\n x: entry.address.colIndex - node.address.range.start.col,\n y: entry.address.rowIndex - node.address.range.start.row,\n },\n result: spilledResult,\n });\n }\n }\n }\n }\n }\n }\n\n return {\n type: \"values\",\n values: results,\n };\n });\n\n node.setResult(result);\n }\n\n evaluateCellNode(\n node: CellValueNode | SpillMetaNode | VirtualCellValueNode\n ): void {\n // Enable caching for resolved nodes\n if (node.resolved) {\n return;\n }\n\n node.resetDirectDepsUpdated();\n\n const ctx = new EvaluationContext(\n this.tableManager,\n node,\n node.cellAddress\n );\n\n if (node instanceof CellValueNode && node.spillMeta) {\n // we are evaluating a e.g. A1 in A1=SEQUENCE(10), where we want the value in the cell in A1, i.e. 1\n // As A1 is already pointing to a spill meta node, everything has been setup already,\n // we just need to evaluate the spill origin and assign the result to the currentDepNode\n const spillOrigin = node.spillMeta;\n if (spillOrigin.evaluationResult.type === \"spilled-values\") {\n const result = spillOrigin.evaluationResult.evaluate(\n { x: 0, y: 0 },\n ctx\n );\n node.setEvaluationResult(result);\n return;\n }\n }\n\n let content: SerializedCellValue;\n try {\n if (node instanceof VirtualCellValueNode) {\n content = node.cellValue;\n } else {\n content = this.workbookManager.getSerializedCellValue(node.cellAddress);\n }\n } catch (err) {\n const evaluationResult: ErrorEvaluationResult = {\n type: \"error\",\n err: FormulaError.ERROR,\n message: \"Syntax error\",\n errAddress: node,\n };\n node.setEvaluationResult(evaluationResult);\n return;\n }\n\n if (typeof content !== \"string\" || !content.startsWith(\"=\")) {\n if (node instanceof SpillMetaNode) {\n node.setEvaluationResult({\n type: \"does-not-spill\",\n });\n return;\n }\n // Static value cells cannot have frontier dependencies\n const result: ValueEvaluationResult = {\n type: \"value\",\n result: this.convertScalarValueToCellValue(content),\n };\n node.setEvaluationResult(result);\n return;\n }\n\n let evaluation: FunctionEvaluationResult = captureEvaluationErrors(\n node,\n () => this.formulaEvaluator.evaluateFormula(content.slice(1), ctx)\n );\n\n // the evaluated cell IS A spilling formula, e.g. if dependencyKey points to A1, then the formula is e.g. A1=SEQUENCE(10), or A1=A3:B5\n if (evaluation.type === \"spilled-values\") {\n const spillArea = evaluation.spillArea(node.cellAddress);\n\n if (!this.canSpill(node.cellAddress, spillArea)) {\n // Override evaluation with SPILL error, but continue execution to set up nodes\n evaluation = {\n type: \"error\",\n err: FormulaError.SPILL,\n message: \"Cannot spill - area is blocked\",\n errAddress: node,\n };\n } else {\n // Spill succeeds - register it\n this.dependencyManager.setSpilledValue(node.key, {\n spillOnto: spillArea,\n origin: node.cellAddress,\n });\n }\n\n // Set up spill meta node and evaluation results (even if spill failed)\n if (node instanceof SpillMetaNode) {\n // we have already setup an origin/spill meta node relationship,\n // so we are just reevaluating the spill meta node here\n node.setEvaluationResult(evaluation);\n } else {\n const spillMetaNode = this.dependencyManager.getSpillMetaNode(\n node.key.replace(/^[^:]+:/, \"spill-meta:\")\n );\n\n node.addDependency(spillMetaNode);\n node.setSpillMetaNode(spillMetaNode);\n spillMetaNode.setEvaluationResult(evaluation);\n\n if (evaluation.type === \"spilled-values\") {\n const originResult = evaluation.evaluate({ x: 0, y: 0 }, ctx);\n node.setEvaluationResult(originResult);\n } else {\n // Spill failed - set error on origin cell\n node.setEvaluationResult(evaluation);\n }\n }\n return;\n }\n\n if (evaluation.type === \"value\") {\n if (node instanceof SpillMetaNode) {\n node.setEvaluationResult({\n type: \"does-not-spill\",\n });\n return;\n } else {\n node.setEvaluationResult(evaluation);\n return;\n }\n }\n\n node.setEvaluationResult(evaluation);\n }\n\n evaluateDependencyNode(dependency: DependencyNode): void {\n if (dependency instanceof EmptyCellEvaluationNode) {\n this.evaluateEmptyCell(dependency);\n return;\n }\n if (dependency instanceof RangeEvaluationNode) {\n this.evaluateRangeNode(dependency);\n return;\n }\n if (\n dependency instanceof CellValueNode ||\n dependency instanceof VirtualCellValueNode\n ) {\n this.evaluateCellNode(dependency);\n return;\n }\n if (dependency instanceof AstEvaluationNode) {\n return;\n }\n if (dependency instanceof SpillMetaNode) {\n this.evaluateCellNode(dependency);\n return;\n }\n throw new Error(\"Invalid dependency: \" + (dependency as any).key);\n }\n\n /**\n * User exposed method to evaluate a formula\n */\n evaluateFormula(\n /**\n * formula for example\n */\n cellValue: SerializedCellValue,\n cellAddress: CellAddress\n ): SerializedCellValue {\n if (this.isEvaluating) {\n throw new Error(\"Evaluation in progress\");\n }\n\n const node = this.dependencyManager.getVirtualCellValueNode(\n cellAddress,\n cellValue\n );\n\n if (node.evaluationResult.type === \"awaiting-evaluation\") {\n this.evaluateCell(node);\n }\n\n const result = node.evaluationResult;\n\n return this.evaluationResultToSerializedValue(result, cellAddress);\n }\n\n /**\n * Evaluates a cell by building the evaluation order and evaluating the dependencies in order\n */\n evaluateCell(\n node: CellValueNode | EmptyCellEvaluationNode | VirtualCellValueNode\n ): void {\n if (this.isEvaluating) {\n throw new Error(\"Evaluation in progress\");\n }\n this.isEvaluating = true;\n\n let precalculatedPlan: EvaluationOrder | undefined;\n\n let requiresReRun = true;\n while (requiresReRun) {\n requiresReRun = false;\n\n // Use DependencyManager to build evaluation order\n const evaluationPlan =\n precalculatedPlan ?? this.dependencyManager.buildEvaluationOrder(node);\n\n if (evaluationPlan.hasCycle) {\n const evaluationResult: ErrorEvaluationResult = {\n type: \"error\",\n err: FormulaError.CYCLE,\n message: Array.from(evaluationPlan.cycleNodes ?? [])\n .map((node) => node.key)\n .join(\" -> \"),\n errAddress: node,\n };\n // cycle detected\n if (evaluationPlan.cycleNodes) {\n for (const node of evaluationPlan.cycleNodes) {\n if (!(node instanceof RangeEvaluationNode)) {\n node.setEvaluationResult(evaluationResult);\n }\n }\n }\n this.isEvaluating = false;\n }\n\n // Evaluate all dependencies in order\n const timeStart = performance.now();\n const durations: { duration: number; key: string }[] = [];\n let numResolved = 0;\n if (flags.isProfiling && evaluationPlan.evaluationOrder.size > -1) {\n // console.profile();\n }\n evaluationPlan.evaluationOrder.forEach((dependency) => {\n const start = performance.now();\n if (dependency.resolved) {\n numResolved++;\n }\n this.evaluateDependencyNode(dependency);\n\n const end = performance.now();\n if (flags.isProfiling && evaluationPlan.evaluationOrder.size > -1) {\n durations.push({ duration: end - start, key: dependency.key });\n }\n });\n if (flags.isProfiling && evaluationPlan.evaluationOrder.size > -1) {\n // console.profileEnd();\n }\n if (flags.isProfiling && evaluationPlan.evaluationOrder.size > -1) {\n const percentResolved = Math.round(\n (100 * numResolved) / evaluationPlan.evaluationOrder.size\n );\n const avgDuration =\n durations.reduce((a, b) => a + b.duration, 0) / durations.length || 0;\n console.log(\n `%c[Evaluation] %c${evaluationPlan.evaluationOrder.size} deps | %c${(\n performance.now() - timeStart\n ).toFixed(\n 1\n )}ms | %c${percentResolved}% resolved | %c${avgDuration.toFixed(\n 2\n )}ms avg`,\n \"color:#83aaff;font-weight:bold;\",\n \"color:#fff;font-weight:bold;\",\n \"color:#7fff9e\",\n \"color:#85baff\",\n \"color:#ffdfa3\"\n );\n }\n\n this.dependencyManager.markResolvedNodes(node);\n\n const nextEvaluationPlan =\n this.dependencyManager.buildEvaluationOrder(node);\n\n this.dependencyManager.updateResolvedSCCs(nextEvaluationPlan);\n\n precalculatedPlan = nextEvaluationPlan;\n\n // Check if new dependencies were discovered during evaluation\n if (nextEvaluationPlan.hash !== evaluationPlan.hash) {\n requiresReRun = true;\n } else {\n this.isEvaluating = false;\n return;\n }\n }\n this.isEvaluating = false;\n }\n\n convertScalarValueToCellValue(val: SerializedCellValue): CellValue {\n if (typeof val === \"number\") {\n return { type: \"number\", value: val };\n }\n if (typeof val === \"boolean\") {\n return { type: \"boolean\", value: val };\n }\n if (typeof val === \"undefined\") {\n return { type: \"string\", value: \"\" };\n }\n return { type: \"string\", value: val };\n }\n\n // todo optimize using workbook manager\n canSpill(spillCandidate: CellAddress, spillArea: SpreadsheetRange): boolean {\n // Check if the spill origin cell is inside a table - spilling formulas cannot exist in tables\n if (this.tableManager.isCellInTable(spillCandidate)) {\n return false;\n }\n\n // Check if the spill area would intersect with any table - formulas cannot spill into tables\n if (\n this.tableManager.doesRangeIntersectTable(\n spillCandidate.workbookName,\n spillCandidate.sheetName,\n spillArea\n )\n ) {\n return false;\n }\n\n const sheet = this.workbookManager.getSheet(spillCandidate);\n if (!sheet) {\n throw new SheetNotFoundError(spillCandidate.sheetName);\n }\n const cellId = getCellReference(spillCandidate);\n const content = sheet.content.get(cellId);\n if (!content) {\n throw new EvaluationError(FormulaError.REF, `Cell not found: ${cellId}`);\n }\n for (const spilledValue of this.dependencyManager.spilledValues) {\n if (\n spilledValue.origin.workbookName !== spillCandidate.workbookName ||\n spilledValue.origin.sheetName !== spillCandidate.sheetName\n ) {\n continue;\n }\n if (\n spilledValue.origin.colIndex === spillCandidate.colIndex &&\n spilledValue.origin.rowIndex === spillCandidate.rowIndex\n ) {\n // we are already have a spill, this one will be replaced\n continue;\n }\n\n if (checkRangeIntersection(spillArea, spilledValue.spillOnto)) {\n return false;\n }\n }\n // let's just check the raw data if there is something in the range\n for (const key of sheet.content.keys()) {\n const cellAddress = parseCellReference(key);\n const endCol = spillArea.end.col;\n const endRow = spillArea.end.row;\n\n if (\n cellAddress.colIndex === spillCandidate.colIndex &&\n cellAddress.rowIndex === spillCandidate.rowIndex\n ) {\n continue;\n }\n\n if (endCol.type === \"number\" && endRow.type === \"number\") {\n if (\n cellAddress.colIndex >= spillArea.start.col &&\n cellAddress.colIndex <= endCol.value &&\n cellAddress.rowIndex >= spillArea.start.row &&\n cellAddress.rowIndex <= endRow.value\n ) {\n if (\n normalizeSerializedCellValue(sheet.content.get(key)) !== undefined\n ) {\n // there is something in the range, so we can't spill\n return false;\n }\n }\n }\n }\n\n return true;\n }\n\n getCellEvaluationResult(\n cellAddress: CellAddress\n ): SingleEvaluationResult | undefined {\n if (this.isEvaluating) {\n throw new Error(\"Evaluation in progress\");\n }\n\n const nodeKey = cellAddressToKey(cellAddress);\n const node = this.dependencyManager.getCellValueOrEmptyCellNode(nodeKey);\n\n const sheet = this.workbookManager.getSheet(cellAddress);\n if (!sheet) {\n throw new SheetNotFoundError(cellAddress.sheetName);\n }\n\n if (node.evaluationResult.type === \"awaiting-evaluation\") {\n // if (cellAddressToKey(cellAddress).includes(\"G10\")) {\n // console.group(\"Evaluation of G10\");\n // flags.isProfiling = true;\n // console.time(\"Evaluation of G10\");\n // console.profile(\"Evaluation of G10\");\n // }\n this.evaluateCell(node);\n // if (flags.isProfiling) {\n // flags.isProfiling = false;\n // console.timeEnd(\"Evaluation of G10\");\n // console.profileEnd(\"Evaluation of G10\");\n // console.groupEnd();\n // }\n }\n\n const result = node.ev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
"debugId": "5440BFA176AF38B564756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -249,6 +249,26 @@ class TableManager {
|
|
|
249
249
|
}
|
|
250
250
|
return;
|
|
251
251
|
}
|
|
252
|
+
doesRangeIntersectTable(workbookName, sheetName, range) {
|
|
253
|
+
for (const table of this.getTables(workbookName).values()) {
|
|
254
|
+
if (table.sheetName !== sheetName) {
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
const { start, endRow, headers } = table;
|
|
258
|
+
const endColIndex = start.colIndex + headers.size - 1;
|
|
259
|
+
const tableRange = {
|
|
260
|
+
start: { col: start.colIndex, row: start.rowIndex },
|
|
261
|
+
end: {
|
|
262
|
+
col: { type: "number", value: endColIndex },
|
|
263
|
+
row: endRow
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
if (import_utils.checkRangeIntersection(range, tableRange)) {
|
|
267
|
+
return true;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
252
272
|
}
|
|
253
273
|
|
|
254
|
-
//# debugId=
|
|
274
|
+
//# debugId=CF0340C4E754B26764756E2164756E21
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/core/managers/table-manager.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import type {\n CellAddress,\n SerializedCellValue,\n SpreadsheetRangeEnd,\n TableDefinition,\n} from \"../types.cjs\";\nimport { getCellReference, parseCellReference } from \"../utils.cjs\";\nimport type { WorkbookManager } from \"./workbook-manager.cjs\";\n\nexport class TableManager {\n tables: Map<\n /**\n * workbook name -> table name -> table definition\n */\n string,\n Map<string, TableDefinition>\n > = new Map();\n private workbookManager: WorkbookManager;\n\n constructor(workbookManager: WorkbookManager) {\n this.workbookManager = workbookManager;\n }\n\n getTables(workbookName: string): Map<string, TableDefinition> {\n return this.tables.get(workbookName) ?? new Map();\n }\n\n getTable(opts: {\n workbookName: string;\n name: string;\n }): TableDefinition | undefined {\n return this.tables.get(opts.workbookName)?.get(opts.name);\n }\n\n makeTable({\n tableName,\n sheetName,\n workbookName,\n start,\n numRows,\n numCols,\n getCellValue,\n }: {\n tableName: string;\n sheetName: string;\n start: string;\n numRows: SpreadsheetRangeEnd;\n numCols: number;\n workbookName: string;\n getCellValue: (cellAddress: CellAddress) => SerializedCellValue;\n }): TableDefinition {\n const { rowIndex, colIndex } = parseCellReference(start);\n\n const headers = new Map<string, { name: string; index: number }>();\n for (let i = 0; i < numCols; i++) {\n const header = getCellValue({\n rowIndex,\n colIndex: colIndex + i,\n sheetName,\n workbookName,\n });\n\n if (header) {\n headers.set(String(header), { name: String(header), index: i });\n } else {\n headers.set(`Column ${i + 1}`, { name: `Column ${i + 1}`, index: i });\n }\n }\n\n const endRow: SpreadsheetRangeEnd =\n numRows.type === \"number\"\n ? { type: \"number\", value: rowIndex + numRows.value }\n : numRows;\n\n const table: TableDefinition = {\n name: tableName,\n sheetName,\n workbookName,\n start: {\n rowIndex,\n colIndex,\n },\n headers,\n endRow,\n };\n\n return table;\n }\n\n copyTable(\n from: {\n workbookName: string;\n tableName: string;\n },\n to: {\n workbookName: string;\n tableName: string;\n }\n ): void {\n const fromTable = this.getTable({\n workbookName: from.workbookName,\n name: from.tableName,\n });\n if (!fromTable) {\n throw new Error(\"Table not found\");\n }\n const wb = this.tables.get(to.workbookName);\n if (!wb) {\n throw new Error(\"Workbook not found\");\n }\n const newTable: TableDefinition = {\n ...fromTable,\n workbookName: to.workbookName,\n };\n wb.set(to.tableName, newTable);\n }\n\n addTable(props: {\n tableName: string;\n sheetName: string;\n start: string;\n numRows: SpreadsheetRangeEnd;\n numCols: number;\n workbookName: string;\n getCellValue: (cellAddress: CellAddress) => SerializedCellValue;\n }): TableDefinition {\n const tableName = props.tableName;\n const table = this.makeTable(props);\n\n let wb = this.tables.get(props.workbookName);\n if (!wb) {\n wb = new Map();\n this.tables.set(props.workbookName, wb);\n }\n\n wb.set(tableName, table);\n\n return table;\n }\n\n renameTable(\n workbookName: string,\n names: { oldName: string; newName: string }\n ): void {\n const wb = this.tables.get(workbookName);\n if (!wb) {\n throw new Error(\"Workbook not found\");\n }\n const table = wb.get(names.oldName);\n if (!table) {\n throw new Error(\"Table not found\");\n }\n table.name = names.newName;\n wb.set(names.newName, table);\n wb.delete(names.oldName);\n }\n\n updateTable({\n tableName,\n sheetName,\n start,\n numRows,\n numCols,\n workbookName,\n getCellValue,\n }: {\n tableName: string;\n sheetName?: string;\n start?: string;\n numRows?: SpreadsheetRangeEnd;\n workbookName: string;\n numCols?: number;\n getCellValue: (cellAddress: CellAddress) => SerializedCellValue;\n }): void {\n const wb = this.tables.get(workbookName);\n if (!wb) {\n throw new Error(\"Workbook not found\");\n }\n\n const table = wb.get(tableName);\n if (!table) {\n throw new Error(\"Table not found\");\n }\n\n const newStart = start ? parseCellReference(start) : table.start;\n\n let newNumRows: SpreadsheetRangeEnd;\n if (numRows) {\n newNumRows = numRows;\n } else {\n if (table.endRow.type === \"infinity\") {\n newNumRows = table.endRow;\n } else {\n newNumRows = {\n type: \"number\",\n value: table.endRow.value - newStart.rowIndex,\n };\n }\n }\n\n const newTable = this.makeTable({\n tableName,\n sheetName: sheetName ?? table.sheetName,\n workbookName: workbookName ?? table.workbookName,\n start: getCellReference(newStart),\n numRows: newNumRows,\n numCols: numCols ?? table.headers.size,\n getCellValue,\n });\n\n wb.set(tableName, newTable);\n }\n\n removeTable({\n tableName,\n workbookName,\n }: {\n tableName: string;\n workbookName: string;\n }): boolean {\n const wb = this.tables.get(workbookName);\n if (!wb) {\n return false;\n }\n const found = wb.delete(tableName);\n\n return found;\n }\n\n updateTablesForSheetRename(options: {\n sheetName: string;\n newSheetName: string;\n workbookName: string;\n }): void {\n // Update tables that belong to the renamed sheet\n const wb = this.tables.get(options.workbookName);\n if (!wb) {\n throw new Error(\"Workbook not found\");\n }\n\n wb.forEach((table) => {\n if (table.sheetName === options.sheetName) {\n table.sheetName = options.newSheetName;\n }\n });\n }\n\n updateTablesForWorkbookRename(options: {\n workbookName: string;\n newWorkbookName: string;\n }): void {\n const wb = this.tables.get(options.workbookName);\n if (!wb) {\n throw new Error(\"Workbook not found\");\n }\n this.tables.set(options.newWorkbookName, wb);\n this.tables.delete(options.workbookName);\n // Update tables that belong to the renamed sheet\n wb.forEach((table, tableName) => {\n if (table.workbookName === options.workbookName) {\n table.workbookName = options.newWorkbookName;\n }\n });\n }\n\n resetTables(newTables: Map<string, Map<string, TableDefinition>>): void {\n // Clear existing tables without breaking the Map reference\n this.tables.clear();\n\n // Repopulate with new tables\n newTables.forEach((table, workbookName) => {\n table.forEach((table, tableName) => {\n let wb = this.tables.get(workbookName);\n if (!wb) {\n wb = new Map();\n this.tables.set(workbookName, wb);\n }\n wb.set(tableName, table);\n });\n });\n }\n\n /**\n * When adding a workbook, we need to initialize the new maps\n */\n addWorkbook(workbookName: string) {\n this.tables.set(workbookName, new Map());\n }\n\n /**\n * When removing a workbook, we need to remove the maps\n */\n removeWorkbook(workbookName: string) {\n this.tables.delete(workbookName);\n }\n\n /**\n * When removing a sheet, we need to remove the tables that belong to the sheet\n */\n removeSheet(opts: { sheetName: string; workbookName: string }): void {\n // Remove tables that belong to the removed sheet\n const wb = this.tables.get(opts.workbookName);\n if (!wb) {\n throw new Error(\"Workbook not found\");\n }\n wb.forEach((table, tableName) => {\n if (table.sheetName === opts.sheetName) {\n wb.delete(tableName);\n }\n });\n }\n\n isCellInTable(cellAddress: CellAddress): TableDefinition | undefined {\n const { rowIndex, colIndex } = cellAddress;\n\n // Get all tables for this sheet\n\n for (const table of this.getTables(cellAddress.workbookName).values()) {\n // Check each table to see if the cell is within its bounds\n if (table.sheetName !== cellAddress.sheetName) {\n continue;\n }\n\n const { start, endRow, headers } = table;\n\n // Check row bounds\n const isInRowRange =\n endRow.type === \"infinity\"\n ? rowIndex >= start.rowIndex\n : rowIndex >= start.rowIndex && rowIndex <= endRow.value;\n\n // Check column bounds\n const endColIndex = start.colIndex + headers.size - 1;\n const isInColRange =\n colIndex >= start.colIndex && colIndex <= endColIndex;\n\n if (isInRowRange && isInColRange) {\n return table;\n }\n }\n\n return undefined;\n }\n}\n"
|
|
5
|
+
"import type {\n CellAddress,\n SerializedCellValue,\n SpreadsheetRange,\n SpreadsheetRangeEnd,\n TableDefinition,\n} from \"../types.cjs\";\nimport { checkRangeIntersection, getCellReference, parseCellReference } from \"../utils.cjs\";\nimport type { WorkbookManager } from \"./workbook-manager.cjs\";\n\nexport class TableManager {\n tables: Map<\n /**\n * workbook name -> table name -> table definition\n */\n string,\n Map<string, TableDefinition>\n > = new Map();\n private workbookManager: WorkbookManager;\n\n constructor(workbookManager: WorkbookManager) {\n this.workbookManager = workbookManager;\n }\n\n getTables(workbookName: string): Map<string, TableDefinition> {\n return this.tables.get(workbookName) ?? new Map();\n }\n\n getTable(opts: {\n workbookName: string;\n name: string;\n }): TableDefinition | undefined {\n return this.tables.get(opts.workbookName)?.get(opts.name);\n }\n\n makeTable({\n tableName,\n sheetName,\n workbookName,\n start,\n numRows,\n numCols,\n getCellValue,\n }: {\n tableName: string;\n sheetName: string;\n start: string;\n numRows: SpreadsheetRangeEnd;\n numCols: number;\n workbookName: string;\n getCellValue: (cellAddress: CellAddress) => SerializedCellValue;\n }): TableDefinition {\n const { rowIndex, colIndex } = parseCellReference(start);\n\n const headers = new Map<string, { name: string; index: number }>();\n for (let i = 0; i < numCols; i++) {\n const header = getCellValue({\n rowIndex,\n colIndex: colIndex + i,\n sheetName,\n workbookName,\n });\n\n if (header) {\n headers.set(String(header), { name: String(header), index: i });\n } else {\n headers.set(`Column ${i + 1}`, { name: `Column ${i + 1}`, index: i });\n }\n }\n\n const endRow: SpreadsheetRangeEnd =\n numRows.type === \"number\"\n ? { type: \"number\", value: rowIndex + numRows.value }\n : numRows;\n\n const table: TableDefinition = {\n name: tableName,\n sheetName,\n workbookName,\n start: {\n rowIndex,\n colIndex,\n },\n headers,\n endRow,\n };\n\n return table;\n }\n\n copyTable(\n from: {\n workbookName: string;\n tableName: string;\n },\n to: {\n workbookName: string;\n tableName: string;\n }\n ): void {\n const fromTable = this.getTable({\n workbookName: from.workbookName,\n name: from.tableName,\n });\n if (!fromTable) {\n throw new Error(\"Table not found\");\n }\n const wb = this.tables.get(to.workbookName);\n if (!wb) {\n throw new Error(\"Workbook not found\");\n }\n const newTable: TableDefinition = {\n ...fromTable,\n workbookName: to.workbookName,\n };\n wb.set(to.tableName, newTable);\n }\n\n addTable(props: {\n tableName: string;\n sheetName: string;\n start: string;\n numRows: SpreadsheetRangeEnd;\n numCols: number;\n workbookName: string;\n getCellValue: (cellAddress: CellAddress) => SerializedCellValue;\n }): TableDefinition {\n const tableName = props.tableName;\n const table = this.makeTable(props);\n\n let wb = this.tables.get(props.workbookName);\n if (!wb) {\n wb = new Map();\n this.tables.set(props.workbookName, wb);\n }\n\n wb.set(tableName, table);\n\n return table;\n }\n\n renameTable(\n workbookName: string,\n names: { oldName: string; newName: string }\n ): void {\n const wb = this.tables.get(workbookName);\n if (!wb) {\n throw new Error(\"Workbook not found\");\n }\n const table = wb.get(names.oldName);\n if (!table) {\n throw new Error(\"Table not found\");\n }\n table.name = names.newName;\n wb.set(names.newName, table);\n wb.delete(names.oldName);\n }\n\n updateTable({\n tableName,\n sheetName,\n start,\n numRows,\n numCols,\n workbookName,\n getCellValue,\n }: {\n tableName: string;\n sheetName?: string;\n start?: string;\n numRows?: SpreadsheetRangeEnd;\n workbookName: string;\n numCols?: number;\n getCellValue: (cellAddress: CellAddress) => SerializedCellValue;\n }): void {\n const wb = this.tables.get(workbookName);\n if (!wb) {\n throw new Error(\"Workbook not found\");\n }\n\n const table = wb.get(tableName);\n if (!table) {\n throw new Error(\"Table not found\");\n }\n\n const newStart = start ? parseCellReference(start) : table.start;\n\n let newNumRows: SpreadsheetRangeEnd;\n if (numRows) {\n newNumRows = numRows;\n } else {\n if (table.endRow.type === \"infinity\") {\n newNumRows = table.endRow;\n } else {\n newNumRows = {\n type: \"number\",\n value: table.endRow.value - newStart.rowIndex,\n };\n }\n }\n\n const newTable = this.makeTable({\n tableName,\n sheetName: sheetName ?? table.sheetName,\n workbookName: workbookName ?? table.workbookName,\n start: getCellReference(newStart),\n numRows: newNumRows,\n numCols: numCols ?? table.headers.size,\n getCellValue,\n });\n\n wb.set(tableName, newTable);\n }\n\n removeTable({\n tableName,\n workbookName,\n }: {\n tableName: string;\n workbookName: string;\n }): boolean {\n const wb = this.tables.get(workbookName);\n if (!wb) {\n return false;\n }\n const found = wb.delete(tableName);\n\n return found;\n }\n\n updateTablesForSheetRename(options: {\n sheetName: string;\n newSheetName: string;\n workbookName: string;\n }): void {\n // Update tables that belong to the renamed sheet\n const wb = this.tables.get(options.workbookName);\n if (!wb) {\n throw new Error(\"Workbook not found\");\n }\n\n wb.forEach((table) => {\n if (table.sheetName === options.sheetName) {\n table.sheetName = options.newSheetName;\n }\n });\n }\n\n updateTablesForWorkbookRename(options: {\n workbookName: string;\n newWorkbookName: string;\n }): void {\n const wb = this.tables.get(options.workbookName);\n if (!wb) {\n throw new Error(\"Workbook not found\");\n }\n this.tables.set(options.newWorkbookName, wb);\n this.tables.delete(options.workbookName);\n // Update tables that belong to the renamed sheet\n wb.forEach((table, tableName) => {\n if (table.workbookName === options.workbookName) {\n table.workbookName = options.newWorkbookName;\n }\n });\n }\n\n resetTables(newTables: Map<string, Map<string, TableDefinition>>): void {\n // Clear existing tables without breaking the Map reference\n this.tables.clear();\n\n // Repopulate with new tables\n newTables.forEach((table, workbookName) => {\n table.forEach((table, tableName) => {\n let wb = this.tables.get(workbookName);\n if (!wb) {\n wb = new Map();\n this.tables.set(workbookName, wb);\n }\n wb.set(tableName, table);\n });\n });\n }\n\n /**\n * When adding a workbook, we need to initialize the new maps\n */\n addWorkbook(workbookName: string) {\n this.tables.set(workbookName, new Map());\n }\n\n /**\n * When removing a workbook, we need to remove the maps\n */\n removeWorkbook(workbookName: string) {\n this.tables.delete(workbookName);\n }\n\n /**\n * When removing a sheet, we need to remove the tables that belong to the sheet\n */\n removeSheet(opts: { sheetName: string; workbookName: string }): void {\n // Remove tables that belong to the removed sheet\n const wb = this.tables.get(opts.workbookName);\n if (!wb) {\n throw new Error(\"Workbook not found\");\n }\n wb.forEach((table, tableName) => {\n if (table.sheetName === opts.sheetName) {\n wb.delete(tableName);\n }\n });\n }\n\n isCellInTable(cellAddress: CellAddress): TableDefinition | undefined {\n const { rowIndex, colIndex } = cellAddress;\n\n // Get all tables for this sheet\n\n for (const table of this.getTables(cellAddress.workbookName).values()) {\n // Check each table to see if the cell is within its bounds\n if (table.sheetName !== cellAddress.sheetName) {\n continue;\n }\n\n const { start, endRow, headers } = table;\n\n // Check row bounds\n const isInRowRange =\n endRow.type === \"infinity\"\n ? rowIndex >= start.rowIndex\n : rowIndex >= start.rowIndex && rowIndex <= endRow.value;\n\n // Check column bounds\n const endColIndex = start.colIndex + headers.size - 1;\n const isInColRange =\n colIndex >= start.colIndex && colIndex <= endColIndex;\n\n if (isInRowRange && isInColRange) {\n return table;\n }\n }\n\n return undefined;\n }\n\n /**\n * Check if a range intersects with any table in the given workbook/sheet.\n * Used to prevent spilling into tables (Excel behavior).\n */\n doesRangeIntersectTable(\n workbookName: string,\n sheetName: string,\n range: SpreadsheetRange\n ): boolean {\n for (const table of this.getTables(workbookName).values()) {\n if (table.sheetName !== sheetName) {\n continue;\n }\n\n // Build the table's range\n const { start, endRow, headers } = table;\n const endColIndex = start.colIndex + headers.size - 1;\n\n const tableRange: SpreadsheetRange = {\n start: { col: start.colIndex, row: start.rowIndex },\n end: {\n col: { type: \"number\", value: endColIndex },\n row: endRow,\n },\n };\n\n if (checkRangeIntersection(range, tableRange)) {\n return true;\n }\n }\n\n return false;\n }\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AA,MACT;AAAA,IACF;AAAA,IAEA,OAAO;AAAA;AAEX;",
|
|
8
|
+
"debugId": "CF0340C4E754B26764756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/dist/cjs/lib.cjs
CHANGED
|
@@ -50,7 +50,7 @@ __export(exports_lib, {
|
|
|
50
50
|
createApi: () => import_api.createApi,
|
|
51
51
|
TableOrm: () => import_table_orm.TableOrm,
|
|
52
52
|
SchemaValidationError: () => import_api_schema_manager.SchemaValidationError,
|
|
53
|
-
SchemaIntegrityError: () =>
|
|
53
|
+
SchemaIntegrityError: () => import_command_executor.SchemaIntegrityError,
|
|
54
54
|
FormulaEngine: () => import_engine.FormulaEngine,
|
|
55
55
|
CellOrm: () => import_cell_orm.CellOrm
|
|
56
56
|
});
|
|
@@ -63,6 +63,6 @@ var import_api = require("./core/api/api.cjs");
|
|
|
63
63
|
var import_table_orm = require("./core/api/table-orm.cjs");
|
|
64
64
|
var import_cell_orm = require("./core/api/cell-orm.cjs");
|
|
65
65
|
var import_api_schema_manager = require("./core/managers/api-schema-manager.cjs");
|
|
66
|
-
var
|
|
66
|
+
var import_command_executor = require("./core/commands/command-executor.cjs");
|
|
67
67
|
|
|
68
|
-
//# debugId=
|
|
68
|
+
//# debugId=D4C7FF28839214A564756E2164756E21
|
package/dist/cjs/lib.cjs.map
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"export { FormulaEngine } from \"./core/engine.cjs\";\nexport * from \"./core/types.cjs\";\nexport * from \"./core/utils.cjs\";\nexport * from \"./core/utils/color-utils.cjs\";\n\n// API Schema exports\nexport { defineApi, createApi } from \"./core/api/api.cjs\";\nexport type { CreateApi, Declaration, Api, TableApi, CellApi } from \"./core/api/api.cjs\";\nexport { TableOrm } from \"./core/api/table-orm.cjs\";\nexport { CellOrm } from \"./core/api/cell-orm.cjs\";\nexport { SchemaValidationError } from \"./core/managers/api-schema-manager.cjs\";\nexport type { ValidationResult } from \"./core/managers/api-schema-manager.cjs\";\n\n// Command Pattern exports\nexport { SchemaIntegrityError } from \"./core/commands.cjs\";\nexport type { EngineAction, EngineCommand } from \"./core/commands.cjs\";\n"
|
|
5
|
+
"export { FormulaEngine } from \"./core/engine.cjs\";\nexport * from \"./core/types.cjs\";\nexport * from \"./core/utils.cjs\";\nexport * from \"./core/utils/color-utils.cjs\";\n\n// API Schema exports\nexport { defineApi, createApi } from \"./core/api/api.cjs\";\nexport type { CreateApi, Declaration, Api, TableApi, CellApi } from \"./core/api/api.cjs\";\nexport { TableOrm } from \"./core/api/table-orm.cjs\";\nexport { CellOrm } from \"./core/api/cell-orm.cjs\";\nexport { SchemaValidationError } from \"./core/managers/api-schema-manager.cjs\";\nexport type { ValidationResult } from \"./core/managers/api-schema-manager.cjs\";\n\n// Command Pattern exports\nexport { SchemaIntegrityError } from \"./core/commands/command-executor.cjs\";\nexport type { EngineAction, EngineCommand } from \"./core/commands/types.cjs\";\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAA8B,IAA9B;AACA;AACA;AACA;AAGqC,IAArC;AAEyB,IAAzB;AACwB,IAAxB;AACsC,IAAtC;AAIqC,IAArC;",
|
|
8
|
-
"debugId": "
|
|
8
|
+
"debugId": "D4C7FF28839214A564756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/dist/cjs/package.json
CHANGED
package/dist/mjs/core/engine.mjs
CHANGED
|
@@ -16,10 +16,14 @@ import { DependencyManager } from "./managers/dependency-manager.mjs";
|
|
|
16
16
|
import { StyleManager } from "./managers/style-manager.mjs";
|
|
17
17
|
import { CopyManager } from "./managers/copy-manager.mjs";
|
|
18
18
|
import { ReferenceManager } from "./managers/reference-manager.mjs";
|
|
19
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
ApiSchemaManager
|
|
21
|
+
} from "./managers/api-schema-manager.mjs";
|
|
20
22
|
import { buildApiFromDeclaration } from "./api/api-builder.mjs";
|
|
21
23
|
import {
|
|
22
|
-
CommandExecutor
|
|
24
|
+
CommandExecutor
|
|
25
|
+
} from "./commands/command-executor.mjs";
|
|
26
|
+
import {
|
|
23
27
|
SetCellContentCommand,
|
|
24
28
|
SetSheetContentCommand,
|
|
25
29
|
ClearRangeCommand,
|
|
@@ -27,33 +31,43 @@ import {
|
|
|
27
31
|
FillAreasCommand,
|
|
28
32
|
MoveCellCommand,
|
|
29
33
|
MoveRangeCommand,
|
|
30
|
-
AutoFillCommand
|
|
34
|
+
AutoFillCommand
|
|
35
|
+
} from "./commands/content-commands.mjs";
|
|
36
|
+
import {
|
|
31
37
|
AddWorkbookCommand,
|
|
32
38
|
RemoveWorkbookCommand,
|
|
33
39
|
RenameWorkbookCommand,
|
|
34
40
|
CloneWorkbookCommand,
|
|
35
41
|
AddSheetCommand,
|
|
36
42
|
RemoveSheetCommand,
|
|
37
|
-
RenameSheetCommand
|
|
43
|
+
RenameSheetCommand
|
|
44
|
+
} from "./commands/structure-commands.mjs";
|
|
45
|
+
import {
|
|
38
46
|
AddTableCommand,
|
|
39
47
|
RemoveTableCommand,
|
|
40
48
|
RenameTableCommand,
|
|
41
49
|
UpdateTableCommand,
|
|
42
|
-
ResetTablesCommand
|
|
50
|
+
ResetTablesCommand
|
|
51
|
+
} from "./commands/table-commands.mjs";
|
|
52
|
+
import {
|
|
43
53
|
AddNamedExpressionCommand,
|
|
44
54
|
RemoveNamedExpressionCommand,
|
|
45
55
|
UpdateNamedExpressionCommand,
|
|
46
56
|
RenameNamedExpressionCommand,
|
|
47
|
-
SetNamedExpressionsCommand
|
|
57
|
+
SetNamedExpressionsCommand
|
|
58
|
+
} from "./commands/named-expression-commands.mjs";
|
|
59
|
+
import {
|
|
48
60
|
SetCellMetadataCommand,
|
|
49
61
|
SetSheetMetadataCommand,
|
|
50
|
-
SetWorkbookMetadataCommand
|
|
62
|
+
SetWorkbookMetadataCommand
|
|
63
|
+
} from "./commands/metadata-commands.mjs";
|
|
64
|
+
import {
|
|
51
65
|
AddConditionalStyleCommand,
|
|
52
66
|
RemoveConditionalStyleCommand,
|
|
53
67
|
AddCellStyleCommand,
|
|
54
68
|
RemoveCellStyleCommand,
|
|
55
69
|
ClearCellStylesCommand
|
|
56
|
-
} from "./commands.mjs";
|
|
70
|
+
} from "./commands/style-commands.mjs";
|
|
57
71
|
|
|
58
72
|
class FormulaEngine {
|
|
59
73
|
workbookManager;
|
|
@@ -171,7 +185,11 @@ class FormulaEngine {
|
|
|
171
185
|
this.commandExecutor.execute(new RemoveNamedExpressionCommand(this.getNamedExpressionCommandDeps(), opts), { validate: !!this.apiDeclaration });
|
|
172
186
|
}
|
|
173
187
|
hasNamedExpression(opts) {
|
|
174
|
-
const scope = opts.sheetName && opts.workbookName ? {
|
|
188
|
+
const scope = opts.sheetName && opts.workbookName ? {
|
|
189
|
+
type: "sheet",
|
|
190
|
+
workbookName: opts.workbookName,
|
|
191
|
+
sheetName: opts.sheetName
|
|
192
|
+
} : opts.workbookName ? { type: "workbook", workbookName: opts.workbookName } : { type: "global" };
|
|
175
193
|
return !!this.namedExpressionManager.getNamedExpression({
|
|
176
194
|
name: opts.expressionName,
|
|
177
195
|
scope
|
|
@@ -528,4 +546,4 @@ export {
|
|
|
528
546
|
FormulaEngine
|
|
529
547
|
};
|
|
530
548
|
|
|
531
|
-
//# debugId=
|
|
549
|
+
//# debugId=569EC0E589E33C2264756E2164756E21
|