@ricsam/formula-engine 0.2.10 → 0.2.12
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/autofill-utils.cjs +68 -2
- package/dist/cjs/core/autofill-utils.cjs.map +3 -3
- package/dist/cjs/core/engine-snapshot.cjs +2 -2
- package/dist/cjs/core/engine-snapshot.cjs.map +3 -3
- package/dist/cjs/core/engine.cjs +89 -5
- package/dist/cjs/core/engine.cjs.map +3 -3
- package/dist/cjs/core/managers/copy-manager.cjs +163 -14
- package/dist/cjs/core/managers/copy-manager.cjs.map +3 -3
- package/dist/cjs/core/managers/named-expression-manager.cjs +18 -16
- package/dist/cjs/core/managers/named-expression-manager.cjs.map +3 -3
- package/dist/cjs/core/managers/range-metadata-manager.cjs +135 -0
- package/dist/cjs/core/managers/range-metadata-manager.cjs.map +10 -0
- package/dist/cjs/core/types.cjs.map +1 -1
- package/dist/cjs/package.json +1 -1
- package/dist/mjs/core/autofill-utils.mjs +68 -2
- package/dist/mjs/core/autofill-utils.mjs.map +3 -3
- package/dist/mjs/core/engine-snapshot.mjs +2 -2
- package/dist/mjs/core/engine-snapshot.mjs.map +3 -3
- package/dist/mjs/core/engine.mjs +89 -5
- package/dist/mjs/core/engine.mjs.map +3 -3
- package/dist/mjs/core/managers/copy-manager.mjs +163 -14
- package/dist/mjs/core/managers/copy-manager.mjs.map +3 -3
- package/dist/mjs/core/managers/named-expression-manager.mjs +18 -16
- package/dist/mjs/core/managers/named-expression-manager.mjs.map +3 -3
- package/dist/mjs/core/managers/range-metadata-manager.mjs +95 -0
- package/dist/mjs/core/managers/range-metadata-manager.mjs.map +10 -0
- package/dist/mjs/core/types.mjs.map +1 -1
- package/dist/mjs/package.json +1 -1
- package/dist/types/core/autofill-utils.d.ts +7 -1
- package/dist/types/core/engine-snapshot.d.ts +4 -2
- package/dist/types/core/engine.d.ts +34 -1
- package/dist/types/core/managers/copy-manager.d.ts +11 -1
- package/dist/types/core/managers/named-expression-manager.d.ts +1 -0
- package/dist/types/core/managers/range-metadata-manager.d.ts +22 -0
- package/dist/types/core/types.d.ts +19 -6
- package/package.json +1 -1
|
@@ -386,24 +386,21 @@ class NamedExpressionManager {
|
|
|
386
386
|
};
|
|
387
387
|
}
|
|
388
388
|
resetNamedExpressions(namedExpressions) {
|
|
389
|
-
this.
|
|
390
|
-
|
|
391
|
-
|
|
389
|
+
this.globalExpressions.clear();
|
|
390
|
+
namedExpressions.globalExpressions.forEach((expression, name) => {
|
|
391
|
+
this.globalExpressions.set(name, expression);
|
|
392
392
|
});
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
workbookName
|
|
393
|
+
this.workbookExpressions.forEach((workbookExpressions, workbookName) => {
|
|
394
|
+
workbookExpressions.clear();
|
|
395
|
+
namedExpressions.workbookExpressions.get(workbookName)?.forEach((expression, name) => {
|
|
396
|
+
workbookExpressions.set(name, expression);
|
|
398
397
|
});
|
|
399
398
|
});
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
sheetName,
|
|
406
|
-
workbookName
|
|
399
|
+
this.sheetExpressions.forEach((sheets, workbookName) => {
|
|
400
|
+
sheets.forEach((sheetExpressions, sheetName) => {
|
|
401
|
+
sheetExpressions.clear();
|
|
402
|
+
namedExpressions.sheetExpressions.get(workbookName)?.get(sheetName)?.forEach((expression, name) => {
|
|
403
|
+
sheetExpressions.set(name, expression);
|
|
407
404
|
});
|
|
408
405
|
});
|
|
409
406
|
});
|
|
@@ -414,6 +411,11 @@ class NamedExpressionManager {
|
|
|
414
411
|
restoreFromSnapshot(snapshot) {
|
|
415
412
|
this.resetNamedExpressions(snapshot);
|
|
416
413
|
}
|
|
414
|
+
clear() {
|
|
415
|
+
this.sheetExpressions.clear();
|
|
416
|
+
this.workbookExpressions.clear();
|
|
417
|
+
this.globalExpressions.clear();
|
|
418
|
+
}
|
|
417
419
|
addSheet(opts) {
|
|
418
420
|
const wbLevel = this.sheetExpressions.get(opts.workbookName);
|
|
419
421
|
if (!wbLevel) {
|
|
@@ -468,4 +470,4 @@ class NamedExpressionManager {
|
|
|
468
470
|
}
|
|
469
471
|
}
|
|
470
472
|
|
|
471
|
-
//# debugId=
|
|
473
|
+
//# debugId=12CD3A3339CF2D3264756E2164756E21
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/core/managers/named-expression-manager.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import type { NamedExpression } from \"../types.cjs\";\nimport type { NamedExpressionManagerSnapshot } from \"../engine-snapshot.cjs\";\nimport { renameNamedExpressionInFormula } from \"../named-expression-renamer.cjs\";\nimport type { EventManager } from \"./event-manager.cjs\";\nimport type { NamedExpressionNode } from \"../../parser/ast.cjs\";\nimport type { EvaluationContext } from \"../../evaluator/evaluation-context.cjs\";\nimport { getNamedExpressionResourceKey } from \"../resource-keys.cjs\";\n\nexport class NamedExpressionManager {\n sheetExpressions: Map<string, Map<string, Map<string, NamedExpression>>> =\n new Map();\n workbookExpressions: Map<string, Map<string, NamedExpression>> = new Map();\n globalExpressions: Map<string, NamedExpression> = new Map();\n\n addNamedExpression({\n expression,\n expressionName,\n sheetName,\n workbookName,\n }: {\n expression: string;\n expressionName: string;\n sheetName?: string;\n workbookName?: string;\n }): void {\n const namedExpression: NamedExpression = {\n name: expressionName,\n expression,\n };\n\n if (sheetName && !workbookName) {\n throw new Error(\"Missing workbookName\");\n }\n\n if (sheetName && workbookName) {\n let wbLevel = this.sheetExpressions.get(workbookName);\n if (!wbLevel) {\n wbLevel = new Map();\n this.sheetExpressions.set(workbookName, wbLevel);\n }\n\n let sheetLevel = wbLevel.get(sheetName);\n if (!sheetLevel) {\n sheetLevel = new Map();\n wbLevel.set(sheetName, sheetLevel);\n }\n\n sheetLevel.set(expressionName, namedExpression);\n } else if (workbookName) {\n let workbookNamedExpressions = this.workbookExpressions.get(workbookName);\n if (!workbookNamedExpressions) {\n workbookNamedExpressions = new Map();\n this.workbookExpressions.set(workbookName, workbookNamedExpressions);\n }\n\n workbookNamedExpressions.set(expressionName, namedExpression);\n } else {\n this.globalExpressions.set(expressionName, namedExpression);\n }\n }\n\n removeNamedExpression({\n expressionName,\n sheetName,\n workbookName,\n }: {\n expressionName: string;\n sheetName?: string;\n workbookName?: string;\n }): boolean {\n let found = false;\n\n if (sheetName && !workbookName) {\n throw new Error(\"Missing workbookName\");\n }\n\n if (sheetName && workbookName) {\n const wbLevel = this.sheetExpressions.get(workbookName);\n if (wbLevel) {\n const sheetLevel = wbLevel.get(sheetName);\n if (sheetLevel) {\n found = sheetLevel.delete(expressionName);\n }\n }\n } else if (workbookName) {\n const workbookNamedExpressions =\n this.workbookExpressions.get(workbookName);\n if (workbookNamedExpressions) {\n found = workbookNamedExpressions.delete(expressionName);\n }\n } else {\n found = this.globalExpressions.delete(expressionName);\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 }): void {\n // Check if the named expression exists\n let exists = false;\n\n if (sheetName && !workbookName) {\n throw new Error(\"Missing workbookName\");\n }\n\n if (sheetName && workbookName) {\n const wbLevel = this.sheetExpressions.get(workbookName);\n if (wbLevel) {\n const sheetLevel = wbLevel.get(sheetName);\n if (sheetLevel) {\n exists = sheetLevel.has(expressionName);\n }\n }\n } else if (workbookName) {\n const workbookNamedExpressions =\n this.workbookExpressions.get(workbookName);\n if (workbookNamedExpressions) {\n exists = workbookNamedExpressions.has(expressionName);\n }\n } else {\n exists = this.globalExpressions.has(expressionName);\n }\n\n if (!exists) {\n throw new Error(`Named expression '${expressionName}' does not exist`);\n }\n\n // Update is the same as add for existing expressions\n this.addNamedExpression({\n expression,\n expressionName,\n sheetName,\n workbookName,\n });\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 }): boolean {\n // Check if the named expression exists\n let targetMap: Map<string, NamedExpression> | undefined;\n if (sheetName && !workbookName) {\n throw new Error(\"Missing workbookName\");\n }\n\n let isGlobal = false;\n\n if (sheetName && workbookName) {\n const wbLevel = this.sheetExpressions.get(workbookName);\n if (wbLevel) {\n const sheetLevel = wbLevel.get(sheetName);\n if (sheetLevel) {\n targetMap = sheetLevel;\n }\n }\n } else if (workbookName) {\n targetMap = this.workbookExpressions.get(workbookName);\n } else {\n targetMap = this.globalExpressions;\n isGlobal = true;\n }\n\n if (!targetMap || !targetMap.has(expressionName)) {\n throw new Error(`Named expression '${expressionName}' does not exist`);\n }\n\n // Check if the new name already exists\n if (targetMap.has(newName)) {\n throw new Error(`Named expression '${newName}' already exists`);\n }\n\n // Get the expression to rename\n const namedExpression = targetMap.get(expressionName)!;\n\n // Update the name and re-add with new name\n const updatedExpression = { ...namedExpression, name: newName };\n targetMap.set(newName, updatedExpression);\n targetMap.delete(expressionName);\n\n return true;\n }\n\n updateAllNamedExpressions(\n updateCallback: (formula: string) => string\n ): string[] {\n const changed = new Set<string>();\n\n const update = (\n map: Map<string, NamedExpression>,\n opts: { workbookName?: string; sheetName?: string }\n ) => {\n map.forEach((namedExpr, name) => {\n // Don't update the expression we're renaming\n const updatedExpression = updateCallback(namedExpr.expression);\n\n if (updatedExpression !== namedExpr.expression) {\n map.set(name, {\n ...namedExpr,\n expression: updatedExpression,\n });\n changed.add(\n getNamedExpressionResourceKey({\n expressionName: name,\n workbookName: opts.workbookName,\n sheetName: opts.sheetName,\n })\n );\n }\n });\n };\n\n update(this.globalExpressions, {});\n\n this.workbookExpressions.forEach((workbookLevel, workbookName) => {\n update(workbookLevel, { workbookName });\n });\n\n this.sheetExpressions.forEach((wbLevel, workbookName) => {\n wbLevel.forEach((sheetLevel, sheetName) => {\n update(sheetLevel, { workbookName, sheetName });\n });\n });\n\n return Array.from(changed);\n }\n\n /**\n * Replace all named expressions\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 let map: Map<string, NamedExpression> | undefined;\n\n if (opts.type === \"sheet\") {\n map = this.sheetExpressions.get(opts.workbookName)?.get(opts.sheetName);\n } else if (opts.type === \"workbook\") {\n map = this.workbookExpressions.get(opts.workbookName);\n } else {\n map = this.globalExpressions;\n }\n\n if (!map) {\n throw new Error(\"Invalid options: \" + JSON.stringify(opts));\n }\n\n map.clear();\n\n opts.expressions.forEach((expression, name) => {\n map.set(name, expression);\n });\n }\n\n getNamedExpression(depNode: {\n name: string;\n scope:\n | {\n type: \"global\";\n }\n | {\n type: \"workbook\";\n workbookName: string;\n }\n | {\n type: \"sheet\";\n workbookName: string;\n sheetName: string;\n };\n }): NamedExpression | undefined {\n if (depNode.scope.type === \"global\") {\n return this.globalExpressions.get(depNode.name);\n }\n if (depNode.scope.type === \"workbook\") {\n return this.workbookExpressions\n .get(depNode.scope.workbookName)\n ?.get(depNode.name);\n }\n if (depNode.scope.type === \"sheet\") {\n return this.sheetExpressions\n .get(depNode.scope.workbookName)\n ?.get(depNode.scope.sheetName)\n ?.get(depNode.name);\n }\n return undefined;\n }\n\n resolveNamedExpressionWithScope(\n namedExpression: Pick<\n NamedExpressionNode,\n \"name\" | \"sheetName\" | \"workbookName\"\n >,\n context: EvaluationContext\n ):\n | {\n expression: string;\n scope:\n | { type: \"global\" }\n | { type: \"workbook\"; workbookName: string }\n | { type: \"sheet\"; workbookName: string; sheetName: string };\n }\n | undefined {\n // scenario 1: no sheetName nor workbookName\n if (!namedExpression.sheetName && !namedExpression.workbookName) {\n /**\n * the result of this formula will differ based on in which sheet and workbook we are\n * evaluating it in.\n */\n context.addContextDependency(\"sheet\", \"workbook\");\n\n // step 1, check if there is a named expression in the sheet scope\n const expression = this.sheetExpressions\n .get(context.cellAddress.workbookName)\n ?.get(context.cellAddress.sheetName)\n ?.get(namedExpression.name);\n if (expression) {\n return {\n expression: expression.expression,\n scope: {\n type: \"sheet\",\n workbookName: context.cellAddress.workbookName,\n sheetName: context.cellAddress.sheetName,\n },\n };\n } else {\n // step 2, check if there is a named expression in the workbook scope\n const expression = this.workbookExpressions\n .get(context.cellAddress.workbookName)\n ?.get(namedExpression.name);\n if (expression) {\n return {\n expression: expression.expression,\n scope: {\n type: \"workbook\",\n workbookName: context.cellAddress.workbookName,\n },\n };\n } else {\n // step 3, check if there is a named expression in the global scope\n const expression = this.globalExpressions.get(namedExpression.name);\n if (expression) {\n return {\n expression: expression.expression,\n scope: {\n type: \"global\",\n },\n };\n }\n }\n }\n }\n\n // scenario 2: we only have a workbookName - a bit weird, but could happen\n if (namedExpression.workbookName && !namedExpression.sheetName) {\n // special case: if workbook is the current workbook, we should just resolve the named expression according to scenario 1\n if (\n namedExpression.workbookName ===\n context.cellAddress.workbookName\n ) {\n return this.resolveNamedExpressionWithScope(\n {\n name: namedExpression.name,\n },\n context\n );\n }\n\n const expression = this.workbookExpressions\n .get(namedExpression.workbookName)\n ?.get(namedExpression.name);\n if (expression) {\n // step 1, check if there is a named expression in the workbook scope\n return {\n expression: expression.expression,\n scope: {\n type: \"workbook\",\n workbookName: namedExpression.workbookName,\n },\n };\n } else {\n // step 2, check if there is a named expression in the global scope\n const expression = this.globalExpressions.get(namedExpression.name);\n if (expression) {\n return {\n expression: expression.expression,\n scope: {\n type: \"global\",\n },\n };\n }\n }\n }\n\n // scenario 3: we only have a sheetName\n if (namedExpression.sheetName && !namedExpression.workbookName) {\n const expression = this.sheetExpressions\n .get(context.cellAddress.workbookName)\n ?.get(namedExpression.sheetName)\n ?.get(namedExpression.name);\n /**\n * the result of this formula will differ based on in which workbook we are\n * evaluating it in.\n */\n context.addContextDependency(\"workbook\");\n if (expression) {\n // step 1, check if there is a named expression in the current workbook against the sheet name\n return {\n expression: expression.expression,\n scope: {\n type: \"sheet\",\n workbookName: context.cellAddress.workbookName,\n sheetName: namedExpression.sheetName,\n },\n };\n } else {\n // step 2, check if there is a named expression in the current workbook has a workbook scoped named expression\n const expression = this.workbookExpressions\n .get(context.cellAddress.workbookName)\n ?.get(namedExpression.name);\n if (expression) {\n return {\n expression: expression.expression,\n scope: {\n type: \"workbook\",\n workbookName: context.cellAddress.workbookName,\n },\n };\n } else {\n // step 3, check if there is a named expression in the global scope\n const expression = this.globalExpressions.get(namedExpression.name);\n if (expression) {\n return {\n expression: expression.expression,\n scope: {\n type: \"global\",\n },\n };\n }\n }\n }\n }\n\n // scenario 4: we have both sheetName and workbookName\n if (namedExpression.sheetName && namedExpression.workbookName) {\n const expression = this.sheetExpressions\n .get(namedExpression.workbookName)\n ?.get(namedExpression.sheetName)\n ?.get(namedExpression.name);\n if (expression) {\n // step 1, check if there is a named expression the the sheet scope\n return {\n expression: expression.expression,\n scope: {\n type: \"sheet\",\n workbookName: namedExpression.workbookName,\n sheetName: namedExpression.sheetName,\n },\n };\n } else {\n // step 2, check if there is a named expression in the workbook scope\n const expression = this.workbookExpressions\n .get(namedExpression.workbookName)\n ?.get(namedExpression.name);\n if (expression) {\n return {\n expression: expression.expression,\n scope: {\n type: \"workbook\",\n workbookName: namedExpression.workbookName,\n },\n };\n } else {\n // step 3, check if there is a named expression in the global scope\n const expression = this.globalExpressions.get(namedExpression.name);\n if (expression) {\n return {\n expression: expression.expression,\n scope: {\n type: \"global\",\n },\n };\n }\n }\n }\n }\n }\n\n resolveNamedExpression(\n namedExpression: Pick<\n NamedExpressionNode,\n \"name\" | \"sheetName\" | \"workbookName\"\n >,\n context: EvaluationContext\n ): string | undefined {\n return this.resolveNamedExpressionWithScope(namedExpression, context)\n ?.expression;\n }\n\n getNamedExpressions() {\n return {\n sheetExpressions: this.sheetExpressions,\n workbookExpressions: this.workbookExpressions,\n globalExpressions: this.globalExpressions,\n };\n }\n\n resetNamedExpressions(\n namedExpressions: ReturnType<typeof this.getNamedExpressions>\n ) {\n this.setNamedExpressions({\n type: \"global\",\n expressions: namedExpressions.globalExpressions,\n });\n\n namedExpressions.workbookExpressions.forEach(\n (workbookExpressions, workbookName) => {\n this.setNamedExpressions({\n type: \"workbook\",\n expressions: workbookExpressions,\n workbookName,\n });\n }\n );\n\n namedExpressions.sheetExpressions.forEach(\n (sheetExpressions, workbookName) => {\n sheetExpressions.forEach((sheetExpression, sheetName) => {\n this.setNamedExpressions({\n type: \"sheet\",\n expressions: sheetExpression,\n sheetName,\n workbookName,\n });\n });\n }\n );\n }\n\n toSnapshot(): NamedExpressionManagerSnapshot {\n return this.getNamedExpressions();\n }\n\n restoreFromSnapshot(snapshot: NamedExpressionManagerSnapshot) {\n this.resetNamedExpressions(snapshot);\n }\n\n /**\n * When adding a sheet, we need to initialize the new maps\n */\n addSheet(opts: { workbookName: string; sheetName: string }) {\n const wbLevel = this.sheetExpressions.get(opts.workbookName);\n if (!wbLevel) {\n throw new Error(\"Workbook not found\");\n }\n const sheetLevel = wbLevel.get(opts.sheetName);\n if (sheetLevel) {\n throw new Error(\"Sheet already exists\");\n }\n wbLevel.set(opts.sheetName, new Map());\n }\n\n /**\n * When adding a workbook, we need to initialize the new maps\n */\n addWorkbook(workbookName: string) {\n this.sheetExpressions.set(workbookName, new Map());\n this.workbookExpressions.set(workbookName, new Map());\n }\n\n /**\n * When removing a workbook, we need to remove the workbook from the sheet level\n */\n removeWorkbook(workbookName: string) {\n this.sheetExpressions.delete(workbookName);\n this.workbookExpressions.delete(workbookName);\n }\n\n /**\n * When removing a sheet, we need to remove the sheet from the workbook level\n */\n removeSheet(opts: { workbookName: string; sheetName: string }) {\n const wbLevel = this.sheetExpressions.get(opts.workbookName);\n if (!wbLevel) {\n throw new Error(\"Workbook not found\");\n }\n wbLevel.delete(opts.sheetName);\n }\n\n /**\n * Rename a sheet's named expressions, mainly used when renaming a sheet\n */\n renameSheet(options: {\n sheetName: string;\n newSheetName: string;\n workbookName: string;\n }): void {\n const wbLevel = this.sheetExpressions.get(options.workbookName);\n if (!wbLevel) {\n throw new Error(\"Workbook not found\");\n }\n const sheetLevel = wbLevel.get(options.sheetName);\n if (!sheetLevel) {\n throw new Error(\"Sheet not found\");\n }\n wbLevel.set(options.newSheetName, sheetLevel);\n wbLevel.delete(options.sheetName);\n }\n\n renameWorkbook(opts: { workbookName: string; newWorkbookName: string }) {\n const wbLevel = this.sheetExpressions.get(opts.workbookName);\n if (!wbLevel) {\n throw new Error(\"Workbook not found\");\n }\n this.sheetExpressions.set(opts.newWorkbookName, wbLevel);\n this.sheetExpressions.delete(opts.workbookName);\n\n const wbScopedExpressions = this.workbookExpressions.get(opts.workbookName);\n if (!wbScopedExpressions) {\n throw new Error(\"Workbook not found\");\n }\n this.workbookExpressions.set(opts.newWorkbookName, wbScopedExpressions);\n this.workbookExpressions.delete(opts.workbookName);\n }\n}\n"
|
|
5
|
+
"import type { NamedExpression } from \"../types.cjs\";\nimport type { NamedExpressionManagerSnapshot } from \"../engine-snapshot.cjs\";\nimport { renameNamedExpressionInFormula } from \"../named-expression-renamer.cjs\";\nimport type { EventManager } from \"./event-manager.cjs\";\nimport type { NamedExpressionNode } from \"../../parser/ast.cjs\";\nimport type { EvaluationContext } from \"../../evaluator/evaluation-context.cjs\";\nimport { getNamedExpressionResourceKey } from \"../resource-keys.cjs\";\n\nexport class NamedExpressionManager {\n sheetExpressions: Map<string, Map<string, Map<string, NamedExpression>>> =\n new Map();\n workbookExpressions: Map<string, Map<string, NamedExpression>> = new Map();\n globalExpressions: Map<string, NamedExpression> = new Map();\n\n addNamedExpression({\n expression,\n expressionName,\n sheetName,\n workbookName,\n }: {\n expression: string;\n expressionName: string;\n sheetName?: string;\n workbookName?: string;\n }): void {\n const namedExpression: NamedExpression = {\n name: expressionName,\n expression,\n };\n\n if (sheetName && !workbookName) {\n throw new Error(\"Missing workbookName\");\n }\n\n if (sheetName && workbookName) {\n let wbLevel = this.sheetExpressions.get(workbookName);\n if (!wbLevel) {\n wbLevel = new Map();\n this.sheetExpressions.set(workbookName, wbLevel);\n }\n\n let sheetLevel = wbLevel.get(sheetName);\n if (!sheetLevel) {\n sheetLevel = new Map();\n wbLevel.set(sheetName, sheetLevel);\n }\n\n sheetLevel.set(expressionName, namedExpression);\n } else if (workbookName) {\n let workbookNamedExpressions = this.workbookExpressions.get(workbookName);\n if (!workbookNamedExpressions) {\n workbookNamedExpressions = new Map();\n this.workbookExpressions.set(workbookName, workbookNamedExpressions);\n }\n\n workbookNamedExpressions.set(expressionName, namedExpression);\n } else {\n this.globalExpressions.set(expressionName, namedExpression);\n }\n }\n\n removeNamedExpression({\n expressionName,\n sheetName,\n workbookName,\n }: {\n expressionName: string;\n sheetName?: string;\n workbookName?: string;\n }): boolean {\n let found = false;\n\n if (sheetName && !workbookName) {\n throw new Error(\"Missing workbookName\");\n }\n\n if (sheetName && workbookName) {\n const wbLevel = this.sheetExpressions.get(workbookName);\n if (wbLevel) {\n const sheetLevel = wbLevel.get(sheetName);\n if (sheetLevel) {\n found = sheetLevel.delete(expressionName);\n }\n }\n } else if (workbookName) {\n const workbookNamedExpressions =\n this.workbookExpressions.get(workbookName);\n if (workbookNamedExpressions) {\n found = workbookNamedExpressions.delete(expressionName);\n }\n } else {\n found = this.globalExpressions.delete(expressionName);\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 }): void {\n // Check if the named expression exists\n let exists = false;\n\n if (sheetName && !workbookName) {\n throw new Error(\"Missing workbookName\");\n }\n\n if (sheetName && workbookName) {\n const wbLevel = this.sheetExpressions.get(workbookName);\n if (wbLevel) {\n const sheetLevel = wbLevel.get(sheetName);\n if (sheetLevel) {\n exists = sheetLevel.has(expressionName);\n }\n }\n } else if (workbookName) {\n const workbookNamedExpressions =\n this.workbookExpressions.get(workbookName);\n if (workbookNamedExpressions) {\n exists = workbookNamedExpressions.has(expressionName);\n }\n } else {\n exists = this.globalExpressions.has(expressionName);\n }\n\n if (!exists) {\n throw new Error(`Named expression '${expressionName}' does not exist`);\n }\n\n // Update is the same as add for existing expressions\n this.addNamedExpression({\n expression,\n expressionName,\n sheetName,\n workbookName,\n });\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 }): boolean {\n // Check if the named expression exists\n let targetMap: Map<string, NamedExpression> | undefined;\n if (sheetName && !workbookName) {\n throw new Error(\"Missing workbookName\");\n }\n\n let isGlobal = false;\n\n if (sheetName && workbookName) {\n const wbLevel = this.sheetExpressions.get(workbookName);\n if (wbLevel) {\n const sheetLevel = wbLevel.get(sheetName);\n if (sheetLevel) {\n targetMap = sheetLevel;\n }\n }\n } else if (workbookName) {\n targetMap = this.workbookExpressions.get(workbookName);\n } else {\n targetMap = this.globalExpressions;\n isGlobal = true;\n }\n\n if (!targetMap || !targetMap.has(expressionName)) {\n throw new Error(`Named expression '${expressionName}' does not exist`);\n }\n\n // Check if the new name already exists\n if (targetMap.has(newName)) {\n throw new Error(`Named expression '${newName}' already exists`);\n }\n\n // Get the expression to rename\n const namedExpression = targetMap.get(expressionName)!;\n\n // Update the name and re-add with new name\n const updatedExpression = { ...namedExpression, name: newName };\n targetMap.set(newName, updatedExpression);\n targetMap.delete(expressionName);\n\n return true;\n }\n\n updateAllNamedExpressions(\n updateCallback: (formula: string) => string\n ): string[] {\n const changed = new Set<string>();\n\n const update = (\n map: Map<string, NamedExpression>,\n opts: { workbookName?: string; sheetName?: string }\n ) => {\n map.forEach((namedExpr, name) => {\n // Don't update the expression we're renaming\n const updatedExpression = updateCallback(namedExpr.expression);\n\n if (updatedExpression !== namedExpr.expression) {\n map.set(name, {\n ...namedExpr,\n expression: updatedExpression,\n });\n changed.add(\n getNamedExpressionResourceKey({\n expressionName: name,\n workbookName: opts.workbookName,\n sheetName: opts.sheetName,\n })\n );\n }\n });\n };\n\n update(this.globalExpressions, {});\n\n this.workbookExpressions.forEach((workbookLevel, workbookName) => {\n update(workbookLevel, { workbookName });\n });\n\n this.sheetExpressions.forEach((wbLevel, workbookName) => {\n wbLevel.forEach((sheetLevel, sheetName) => {\n update(sheetLevel, { workbookName, sheetName });\n });\n });\n\n return Array.from(changed);\n }\n\n /**\n * Replace all named expressions\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 let map: Map<string, NamedExpression> | undefined;\n\n if (opts.type === \"sheet\") {\n map = this.sheetExpressions.get(opts.workbookName)?.get(opts.sheetName);\n } else if (opts.type === \"workbook\") {\n map = this.workbookExpressions.get(opts.workbookName);\n } else {\n map = this.globalExpressions;\n }\n\n if (!map) {\n throw new Error(\"Invalid options: \" + JSON.stringify(opts));\n }\n\n map.clear();\n\n opts.expressions.forEach((expression, name) => {\n map.set(name, expression);\n });\n }\n\n getNamedExpression(depNode: {\n name: string;\n scope:\n | {\n type: \"global\";\n }\n | {\n type: \"workbook\";\n workbookName: string;\n }\n | {\n type: \"sheet\";\n workbookName: string;\n sheetName: string;\n };\n }): NamedExpression | undefined {\n if (depNode.scope.type === \"global\") {\n return this.globalExpressions.get(depNode.name);\n }\n if (depNode.scope.type === \"workbook\") {\n return this.workbookExpressions\n .get(depNode.scope.workbookName)\n ?.get(depNode.name);\n }\n if (depNode.scope.type === \"sheet\") {\n return this.sheetExpressions\n .get(depNode.scope.workbookName)\n ?.get(depNode.scope.sheetName)\n ?.get(depNode.name);\n }\n return undefined;\n }\n\n resolveNamedExpressionWithScope(\n namedExpression: Pick<\n NamedExpressionNode,\n \"name\" | \"sheetName\" | \"workbookName\"\n >,\n context: EvaluationContext\n ):\n | {\n expression: string;\n scope:\n | { type: \"global\" }\n | { type: \"workbook\"; workbookName: string }\n | { type: \"sheet\"; workbookName: string; sheetName: string };\n }\n | undefined {\n // scenario 1: no sheetName nor workbookName\n if (!namedExpression.sheetName && !namedExpression.workbookName) {\n /**\n * the result of this formula will differ based on in which sheet and workbook we are\n * evaluating it in.\n */\n context.addContextDependency(\"sheet\", \"workbook\");\n\n // step 1, check if there is a named expression in the sheet scope\n const expression = this.sheetExpressions\n .get(context.cellAddress.workbookName)\n ?.get(context.cellAddress.sheetName)\n ?.get(namedExpression.name);\n if (expression) {\n return {\n expression: expression.expression,\n scope: {\n type: \"sheet\",\n workbookName: context.cellAddress.workbookName,\n sheetName: context.cellAddress.sheetName,\n },\n };\n } else {\n // step 2, check if there is a named expression in the workbook scope\n const expression = this.workbookExpressions\n .get(context.cellAddress.workbookName)\n ?.get(namedExpression.name);\n if (expression) {\n return {\n expression: expression.expression,\n scope: {\n type: \"workbook\",\n workbookName: context.cellAddress.workbookName,\n },\n };\n } else {\n // step 3, check if there is a named expression in the global scope\n const expression = this.globalExpressions.get(namedExpression.name);\n if (expression) {\n return {\n expression: expression.expression,\n scope: {\n type: \"global\",\n },\n };\n }\n }\n }\n }\n\n // scenario 2: we only have a workbookName - a bit weird, but could happen\n if (namedExpression.workbookName && !namedExpression.sheetName) {\n // special case: if workbook is the current workbook, we should just resolve the named expression according to scenario 1\n if (\n namedExpression.workbookName ===\n context.cellAddress.workbookName\n ) {\n return this.resolveNamedExpressionWithScope(\n {\n name: namedExpression.name,\n },\n context\n );\n }\n\n const expression = this.workbookExpressions\n .get(namedExpression.workbookName)\n ?.get(namedExpression.name);\n if (expression) {\n // step 1, check if there is a named expression in the workbook scope\n return {\n expression: expression.expression,\n scope: {\n type: \"workbook\",\n workbookName: namedExpression.workbookName,\n },\n };\n } else {\n // step 2, check if there is a named expression in the global scope\n const expression = this.globalExpressions.get(namedExpression.name);\n if (expression) {\n return {\n expression: expression.expression,\n scope: {\n type: \"global\",\n },\n };\n }\n }\n }\n\n // scenario 3: we only have a sheetName\n if (namedExpression.sheetName && !namedExpression.workbookName) {\n const expression = this.sheetExpressions\n .get(context.cellAddress.workbookName)\n ?.get(namedExpression.sheetName)\n ?.get(namedExpression.name);\n /**\n * the result of this formula will differ based on in which workbook we are\n * evaluating it in.\n */\n context.addContextDependency(\"workbook\");\n if (expression) {\n // step 1, check if there is a named expression in the current workbook against the sheet name\n return {\n expression: expression.expression,\n scope: {\n type: \"sheet\",\n workbookName: context.cellAddress.workbookName,\n sheetName: namedExpression.sheetName,\n },\n };\n } else {\n // step 2, check if there is a named expression in the current workbook has a workbook scoped named expression\n const expression = this.workbookExpressions\n .get(context.cellAddress.workbookName)\n ?.get(namedExpression.name);\n if (expression) {\n return {\n expression: expression.expression,\n scope: {\n type: \"workbook\",\n workbookName: context.cellAddress.workbookName,\n },\n };\n } else {\n // step 3, check if there is a named expression in the global scope\n const expression = this.globalExpressions.get(namedExpression.name);\n if (expression) {\n return {\n expression: expression.expression,\n scope: {\n type: \"global\",\n },\n };\n }\n }\n }\n }\n\n // scenario 4: we have both sheetName and workbookName\n if (namedExpression.sheetName && namedExpression.workbookName) {\n const expression = this.sheetExpressions\n .get(namedExpression.workbookName)\n ?.get(namedExpression.sheetName)\n ?.get(namedExpression.name);\n if (expression) {\n // step 1, check if there is a named expression the the sheet scope\n return {\n expression: expression.expression,\n scope: {\n type: \"sheet\",\n workbookName: namedExpression.workbookName,\n sheetName: namedExpression.sheetName,\n },\n };\n } else {\n // step 2, check if there is a named expression in the workbook scope\n const expression = this.workbookExpressions\n .get(namedExpression.workbookName)\n ?.get(namedExpression.name);\n if (expression) {\n return {\n expression: expression.expression,\n scope: {\n type: \"workbook\",\n workbookName: namedExpression.workbookName,\n },\n };\n } else {\n // step 3, check if there is a named expression in the global scope\n const expression = this.globalExpressions.get(namedExpression.name);\n if (expression) {\n return {\n expression: expression.expression,\n scope: {\n type: \"global\",\n },\n };\n }\n }\n }\n }\n }\n\n resolveNamedExpression(\n namedExpression: Pick<\n NamedExpressionNode,\n \"name\" | \"sheetName\" | \"workbookName\"\n >,\n context: EvaluationContext\n ): string | undefined {\n return this.resolveNamedExpressionWithScope(namedExpression, context)\n ?.expression;\n }\n\n getNamedExpressions() {\n return {\n sheetExpressions: this.sheetExpressions,\n workbookExpressions: this.workbookExpressions,\n globalExpressions: this.globalExpressions,\n };\n }\n\n resetNamedExpressions(\n namedExpressions: ReturnType<typeof this.getNamedExpressions>\n ) {\n this.globalExpressions.clear();\n namedExpressions.globalExpressions.forEach((expression, name) => {\n this.globalExpressions.set(name, expression);\n });\n\n this.workbookExpressions.forEach((workbookExpressions, workbookName) => {\n workbookExpressions.clear();\n namedExpressions.workbookExpressions\n .get(workbookName)\n ?.forEach((expression, name) => {\n workbookExpressions.set(name, expression);\n });\n });\n\n this.sheetExpressions.forEach((sheets, workbookName) => {\n sheets.forEach((sheetExpressions, sheetName) => {\n sheetExpressions.clear();\n namedExpressions.sheetExpressions\n .get(workbookName)\n ?.get(sheetName)\n ?.forEach((expression, name) => {\n sheetExpressions.set(name, expression);\n });\n });\n });\n }\n\n toSnapshot(): NamedExpressionManagerSnapshot {\n return this.getNamedExpressions();\n }\n\n restoreFromSnapshot(snapshot: NamedExpressionManagerSnapshot) {\n this.resetNamedExpressions(snapshot);\n }\n\n clear() {\n this.sheetExpressions.clear();\n this.workbookExpressions.clear();\n this.globalExpressions.clear();\n }\n\n /**\n * When adding a sheet, we need to initialize the new maps\n */\n addSheet(opts: { workbookName: string; sheetName: string }) {\n const wbLevel = this.sheetExpressions.get(opts.workbookName);\n if (!wbLevel) {\n throw new Error(\"Workbook not found\");\n }\n const sheetLevel = wbLevel.get(opts.sheetName);\n if (sheetLevel) {\n throw new Error(\"Sheet already exists\");\n }\n wbLevel.set(opts.sheetName, new Map());\n }\n\n /**\n * When adding a workbook, we need to initialize the new maps\n */\n addWorkbook(workbookName: string) {\n this.sheetExpressions.set(workbookName, new Map());\n this.workbookExpressions.set(workbookName, new Map());\n }\n\n /**\n * When removing a workbook, we need to remove the workbook from the sheet level\n */\n removeWorkbook(workbookName: string) {\n this.sheetExpressions.delete(workbookName);\n this.workbookExpressions.delete(workbookName);\n }\n\n /**\n * When removing a sheet, we need to remove the sheet from the workbook level\n */\n removeSheet(opts: { workbookName: string; sheetName: string }) {\n const wbLevel = this.sheetExpressions.get(opts.workbookName);\n if (!wbLevel) {\n throw new Error(\"Workbook not found\");\n }\n wbLevel.delete(opts.sheetName);\n }\n\n /**\n * Rename a sheet's named expressions, mainly used when renaming a sheet\n */\n renameSheet(options: {\n sheetName: string;\n newSheetName: string;\n workbookName: string;\n }): void {\n const wbLevel = this.sheetExpressions.get(options.workbookName);\n if (!wbLevel) {\n throw new Error(\"Workbook not found\");\n }\n const sheetLevel = wbLevel.get(options.sheetName);\n if (!sheetLevel) {\n throw new Error(\"Sheet not found\");\n }\n wbLevel.set(options.newSheetName, sheetLevel);\n wbLevel.delete(options.sheetName);\n }\n\n renameWorkbook(opts: { workbookName: string; newWorkbookName: string }) {\n const wbLevel = this.sheetExpressions.get(opts.workbookName);\n if (!wbLevel) {\n throw new Error(\"Workbook not found\");\n }\n this.sheetExpressions.set(opts.newWorkbookName, wbLevel);\n this.sheetExpressions.delete(opts.workbookName);\n\n const wbScopedExpressions = this.workbookExpressions.get(opts.workbookName);\n if (!wbScopedExpressions) {\n throw new Error(\"Workbook not found\");\n }\n this.workbookExpressions.set(opts.newWorkbookName, wbScopedExpressions);\n this.workbookExpressions.delete(opts.workbookName);\n }\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAM8C,IAA9C;AAAA;AAEO,MAAM,uBAAuB;AAAA,EAClC,mBACE,IAAI;AAAA,EACN,sBAAiE,IAAI;AAAA,EACrE,oBAAkD,IAAI;AAAA,EAEtD,kBAAkB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,KAMO;AAAA,IACP,MAAM,kBAAmC;AAAA,MACvC,MAAM;AAAA,MACN;AAAA,IACF;AAAA,IAEA,IAAI,aAAa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UAAU;AAAA,IAC5C,QAAQ,OAAO,QAAQ,SAAS;AAAA;AAAA,EAGlC,cAAc,CAAC,MAAyD;AAAA,IACtE,MAAM,UAAU,KAAK,iBAAiB,IAAI,KAAK,YAAY;AAAA,IAC3D,IAAI,CAAC,SAAS;AAAA,MACZ,MAAM,IAAI,MAAM,oBAAoB;AAAA,IACtC;AAAA,IACA,KAAK,iBAAiB,IAAI,KAAK,iBAAiB,OAAO;AAAA,IACvD,KAAK,iBAAiB,OAAO,KAAK,YAAY;AAAA,IAE9C,MAAM,sBAAsB,KAAK,oBAAoB,IAAI,KAAK,YAAY;AAAA,IAC1E,IAAI,CAAC,qBAAqB;AAAA,MACxB,MAAM,IAAI,MAAM,oBAAoB;AAAA,IACtC;AAAA,IACA,KAAK,oBAAoB,IAAI,KAAK,iBAAiB,mBAAmB;AAAA,IACtE,KAAK,oBAAoB,OAAO,KAAK,YAAY;AAAA;AAErD;",
|
|
8
|
+
"debugId": "12CD3A3339CF2D3264756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
8
|
+
var __toCommonJS = (from) => {
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
10
|
+
if (entry)
|
|
11
|
+
return entry;
|
|
12
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
__moduleCache.set(from, entry);
|
|
22
|
+
return entry;
|
|
23
|
+
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
29
|
+
var __export = (target, all) => {
|
|
30
|
+
for (var name in all)
|
|
31
|
+
__defProp(target, name, {
|
|
32
|
+
get: all[name],
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// src/core/managers/range-metadata-manager.ts
|
|
40
|
+
var exports_range_metadata_manager = {};
|
|
41
|
+
__export(exports_range_metadata_manager, {
|
|
42
|
+
RangeMetadataManager: () => RangeMetadataManager
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(exports_range_metadata_manager);
|
|
45
|
+
var import_utils = require("../utils.cjs");
|
|
46
|
+
var import_range_utils = require("../utils/range-utils.cjs");
|
|
47
|
+
var cloneArea = (area) => ({
|
|
48
|
+
workbookName: area.workbookName,
|
|
49
|
+
sheetName: area.sheetName,
|
|
50
|
+
range: {
|
|
51
|
+
start: { ...area.range.start },
|
|
52
|
+
end: {
|
|
53
|
+
col: { ...area.range.end.col },
|
|
54
|
+
row: { ...area.range.end.row }
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
var cloneEntry = (entry) => ({
|
|
59
|
+
id: entry.id,
|
|
60
|
+
areas: entry.areas.map(cloneArea),
|
|
61
|
+
metadata: entry.metadata
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
class RangeMetadataManager {
|
|
65
|
+
rangeMetadata = [];
|
|
66
|
+
addRangeMetadata(entry) {
|
|
67
|
+
const id = entry.id ?? crypto.randomUUID();
|
|
68
|
+
if (this.rangeMetadata.some((existing) => existing.id === id)) {
|
|
69
|
+
throw new Error(`Range metadata with id "${id}" already exists`);
|
|
70
|
+
}
|
|
71
|
+
this.rangeMetadata.push({
|
|
72
|
+
id,
|
|
73
|
+
areas: entry.areas.map(cloneArea),
|
|
74
|
+
metadata: entry.metadata
|
|
75
|
+
});
|
|
76
|
+
return id;
|
|
77
|
+
}
|
|
78
|
+
removeRangeMetadata(id) {
|
|
79
|
+
const beforeLength = this.rangeMetadata.length;
|
|
80
|
+
this.rangeMetadata = this.rangeMetadata.filter((entry) => entry.id !== id);
|
|
81
|
+
return this.rangeMetadata.length !== beforeLength;
|
|
82
|
+
}
|
|
83
|
+
getAllRangeMetadata() {
|
|
84
|
+
return this.rangeMetadata.map(cloneEntry);
|
|
85
|
+
}
|
|
86
|
+
getRangeMetadataForCell(cellAddress) {
|
|
87
|
+
return this.rangeMetadata.filter((entry) => entry.areas.some((area) => area.workbookName === cellAddress.workbookName && area.sheetName === cellAddress.sheetName && import_utils.isCellInRange(cellAddress, area.range))).map(cloneEntry);
|
|
88
|
+
}
|
|
89
|
+
getRangeMetadataIntersectingWithRange(range) {
|
|
90
|
+
return this.rangeMetadata.filter((entry) => entry.areas.some((area) => area.workbookName === range.workbookName && area.sheetName === range.sheetName && import_range_utils.rangesIntersect(area.range, range.range))).map(cloneEntry);
|
|
91
|
+
}
|
|
92
|
+
clearRangeMetadataInRange(range) {
|
|
93
|
+
this.rangeMetadata = this.rangeMetadata.map((entry) => ({
|
|
94
|
+
...entry,
|
|
95
|
+
areas: entry.areas.flatMap((area) => {
|
|
96
|
+
if (area.workbookName !== range.workbookName || area.sheetName !== range.sheetName) {
|
|
97
|
+
return [area];
|
|
98
|
+
}
|
|
99
|
+
return import_range_utils.subtractRange(area.range, range.range).map((remainingRange) => ({
|
|
100
|
+
...area,
|
|
101
|
+
range: remainingRange
|
|
102
|
+
}));
|
|
103
|
+
})
|
|
104
|
+
})).filter((entry) => entry.areas.length > 0);
|
|
105
|
+
}
|
|
106
|
+
removeWorkbookRangeMetadata(workbookName) {
|
|
107
|
+
this.rangeMetadata = this.rangeMetadata.filter((entry) => !entry.areas.some((area) => area.workbookName === workbookName));
|
|
108
|
+
}
|
|
109
|
+
removeSheetRangeMetadata(workbookName, sheetName) {
|
|
110
|
+
this.rangeMetadata = this.rangeMetadata.filter((entry) => !entry.areas.some((area) => area.workbookName === workbookName && area.sheetName === sheetName));
|
|
111
|
+
}
|
|
112
|
+
updateWorkbookName(oldName, newName) {
|
|
113
|
+
this.rangeMetadata = this.rangeMetadata.map((entry) => ({
|
|
114
|
+
...entry,
|
|
115
|
+
areas: entry.areas.map((area) => area.workbookName === oldName ? { ...area, workbookName: newName } : area)
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
updateSheetName(workbookName, oldSheetName, newSheetName) {
|
|
119
|
+
this.rangeMetadata = this.rangeMetadata.map((entry) => ({
|
|
120
|
+
...entry,
|
|
121
|
+
areas: entry.areas.map((area) => area.workbookName === workbookName && area.sheetName === oldSheetName ? { ...area, sheetName: newSheetName } : area)
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
resetRangeMetadata(rangeMetadata) {
|
|
125
|
+
this.rangeMetadata = rangeMetadata ? rangeMetadata.map(cloneEntry) : [];
|
|
126
|
+
}
|
|
127
|
+
toSnapshot() {
|
|
128
|
+
return this.getAllRangeMetadata();
|
|
129
|
+
}
|
|
130
|
+
restoreFromSnapshot(snapshot) {
|
|
131
|
+
this.resetRangeMetadata(snapshot);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
//# debugId=ABB55529B9C3BEF664756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/core/managers/range-metadata-manager.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * RangeMetadataManager - Manages arbitrary consumer-defined metadata attached\n * to ranges rather than individual cells.\n */\n\nimport type {\n CellAddress,\n RangeAddress,\n RangeMetadata,\n RangeMetadataInput,\n} from \"../types.cjs\";\nimport type { RangeMetadataManagerSnapshot } from \"../engine-snapshot.cjs\";\nimport { isCellInRange } from \"../utils.cjs\";\nimport { rangesIntersect, subtractRange } from \"../utils/range-utils.cjs\";\n\nconst cloneArea = (area: RangeAddress): RangeAddress => ({\n workbookName: area.workbookName,\n sheetName: area.sheetName,\n range: {\n start: { ...area.range.start },\n end: {\n col: { ...area.range.end.col },\n row: { ...area.range.end.row },\n },\n },\n});\n\nconst cloneEntry = <TMetadata>(\n entry: RangeMetadata<TMetadata>\n): RangeMetadata<TMetadata> => ({\n id: entry.id,\n areas: entry.areas.map(cloneArea),\n metadata: entry.metadata,\n});\n\nexport class RangeMetadataManager<TMetadata = unknown> {\n private rangeMetadata: RangeMetadata<TMetadata>[] = [];\n\n addRangeMetadata(entry: RangeMetadataInput<TMetadata>): string {\n const id = entry.id ?? crypto.randomUUID();\n if (this.rangeMetadata.some((existing) => existing.id === id)) {\n throw new Error(`Range metadata with id \"${id}\" already exists`);\n }\n\n this.rangeMetadata.push({\n id,\n areas: entry.areas.map(cloneArea),\n metadata: entry.metadata,\n });\n\n return id;\n }\n\n removeRangeMetadata(id: string): boolean {\n const beforeLength = this.rangeMetadata.length;\n this.rangeMetadata = this.rangeMetadata.filter((entry) => entry.id !== id);\n return this.rangeMetadata.length !== beforeLength;\n }\n\n getAllRangeMetadata(): RangeMetadata<TMetadata>[] {\n return this.rangeMetadata.map(cloneEntry);\n }\n\n getRangeMetadataForCell(cellAddress: CellAddress): RangeMetadata<TMetadata>[] {\n return this.rangeMetadata\n .filter((entry) =>\n entry.areas.some(\n (area) =>\n area.workbookName === cellAddress.workbookName &&\n area.sheetName === cellAddress.sheetName &&\n isCellInRange(cellAddress, area.range)\n )\n )\n .map(cloneEntry);\n }\n\n getRangeMetadataIntersectingWithRange(\n range: RangeAddress\n ): RangeMetadata<TMetadata>[] {\n return this.rangeMetadata\n .filter((entry) =>\n entry.areas.some(\n (area) =>\n area.workbookName === range.workbookName &&\n area.sheetName === range.sheetName &&\n rangesIntersect(area.range, range.range)\n )\n )\n .map(cloneEntry);\n }\n\n clearRangeMetadataInRange(range: RangeAddress): void {\n this.rangeMetadata = this.rangeMetadata\n .map((entry) => ({\n ...entry,\n areas: entry.areas.flatMap((area) => {\n if (\n area.workbookName !== range.workbookName ||\n area.sheetName !== range.sheetName\n ) {\n return [area];\n }\n\n return subtractRange(area.range, range.range).map((remainingRange) => ({\n ...area,\n range: remainingRange,\n }));\n }),\n }))\n .filter((entry) => entry.areas.length > 0);\n }\n\n removeWorkbookRangeMetadata(workbookName: string): void {\n this.rangeMetadata = this.rangeMetadata.filter(\n (entry) => !entry.areas.some((area) => area.workbookName === workbookName)\n );\n }\n\n removeSheetRangeMetadata(workbookName: string, sheetName: string): void {\n this.rangeMetadata = this.rangeMetadata.filter(\n (entry) =>\n !entry.areas.some(\n (area) =>\n area.workbookName === workbookName && area.sheetName === sheetName\n )\n );\n }\n\n updateWorkbookName(oldName: string, newName: string): void {\n this.rangeMetadata = this.rangeMetadata.map((entry) => ({\n ...entry,\n areas: entry.areas.map((area) =>\n area.workbookName === oldName ? { ...area, workbookName: newName } : area\n ),\n }));\n }\n\n updateSheetName(\n workbookName: string,\n oldSheetName: string,\n newSheetName: string\n ): void {\n this.rangeMetadata = this.rangeMetadata.map((entry) => ({\n ...entry,\n areas: entry.areas.map((area) =>\n area.workbookName === workbookName && area.sheetName === oldSheetName\n ? { ...area, sheetName: newSheetName }\n : area\n ),\n }));\n }\n\n resetRangeMetadata(rangeMetadata?: RangeMetadata<TMetadata>[]): void {\n this.rangeMetadata = rangeMetadata ? rangeMetadata.map(cloneEntry) : [];\n }\n\n toSnapshot(): RangeMetadataManagerSnapshot {\n return this.getAllRangeMetadata();\n }\n\n restoreFromSnapshot(snapshot: RangeMetadataManagerSnapshot): void {\n this.resetRangeMetad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iB,gBAAgB,KAAK,cAAc,SAC7D,CACJ;AAAA;AAAA,EAGF,kBAAkB,CAAC,SAAiB,SAAuB;AAAA,IACzD,KAAK,gBAAgB,KAAK,cAAc,IAAI,CAAC,WAAW;AAAA,SACnD;AAAA,MACH,OAAO,MAAM,MAAM,IAAI,CAAC,SACtB,KAAK,iBAAiB,UAAU,KAAK,MAAM,cAAc,QAAQ,IAAI,IACvE;AAAA,IACF,EAAE;AAAA;AAAA,EAGJ,eAAe,CACb,cACA,cACA,cACM;AAAA,IACN,KAAK,gBAAgB,KAAK,cAAc,IAAI,CAAC,WAAW;AAAA,SACnD;AAAA,MACH,OAAO,MAAM,MAAM,IAAI,CAAC,SACtB,KAAK,iBAAiB,gBAAgB,KAAK,cAAc,eACrD,KAAK,MAAM,WAAW,aAAa,IACnC,IACN;AAAA,IACF,EAAE;AAAA;AAAA,EAGJ,kBAAkB,CAAC,eAAkD;AAAA,IACnE,KAAK,gBAAgB,gBAAgB,cAAc,IAAI,UAAU,IAAI,CAAC;AAAA;AAAA,EAGxE,UAAU,GAAiC;AAAA,IACzC,OAAO,KAAK,oBAAoB;AAAA;AAAA,EAGlC,mBAAmB,CAAC,UAA8C;AAAA,IAChE,KAAK,mBAAmB,QAAsC;AAAA;AAElE;",
|
|
8
|
+
"debugId": "ABB55529B9C3BEF664756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/core/types.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * Core type definitions for FormulaEngine\n * This file contains all fundamental types used throughout the engine\n */\n\nimport type { EvaluationContext } from \"../evaluator/evaluation-context.cjs\";\nimport type { FormulaEvaluator } from \"../evaluator/formula-evaluator.cjs\";\nimport type { FunctionNode } from \"../parser/ast.cjs\";\nimport type { DependencyNode } from \"./managers/dependency-node.cjs\";\nimport type { LookupOrder } from \"./managers/range-eval-order-builder.cjs\";\n\n// Cell addressing types\nexport interface CellAddress {\n sheetName: string;\n workbookName: string;\n colIndex: number;\n rowIndex: number;\n}\n\nexport interface RangeAddress {\n sheetName: string;\n workbookName: string;\n range: SpreadsheetRange;\n}\n\nexport interface LocalCellAddress {\n colIndex: number;\n rowIndex: number;\n}\n\nexport type ArethmeticEvaluator = (\n left: CellValue,\n right: CellValue,\n context: EvaluationContext\n) => CellValue | ErrorEvaluationResult;\n\nexport type PositiveInfinity = {\n type: \"infinity\";\n sign: \"positive\";\n};\n\nexport type CellInfinity = {\n type: \"infinity\";\n sign: \"positive\" | \"negative\";\n};\n\nexport type CellNumber = {\n type: \"number\";\n value: number;\n};\n\nexport type SpreadsheetRangeEnd = CellNumber | PositiveInfinity;\n\nexport type SpreadsheetRange = {\n start: {\n col: number;\n row: number;\n };\n end: {\n col: SpreadsheetRangeEnd;\n row: SpreadsheetRangeEnd;\n };\n};\n\nexport type RelativeRange = {\n start: {\n col: number;\n row: number;\n };\n width: SpreadsheetRangeEnd;\n height: SpreadsheetRangeEnd;\n};\n\nexport type FiniteSpreadsheetRange = {\n start: {\n col: number;\n row: number;\n };\n end: {\n col: number;\n row: number;\n };\n};\n\nexport type CellString = {\n type: \"string\";\n value: string;\n};\n\nexport type CellBoolean = {\n type: \"boolean\";\n value: boolean;\n};\n\n// Cell value types\nexport type CellValue = CellNumber | CellString | CellBoolean | CellInfinity;\n/**\n * undefined and \"\" are considered empty values\n * undefineds are converted to \"\" in the engine\n *\n * any empty values are deleted from the sheet content\n */\nexport type SerializedCellValue = string | number | boolean | undefined;\n\nexport interface SearchOptions {\n workbookName?: string;\n sheetName?: string;\n caseSensitive?: boolean;\n}\n\nexport interface SearchMatch {\n workbookName: string;\n sheetName: string;\n cellReference: string;\n cellContent: string;\n contentKind: \"formula\" | \"text\";\n occurrenceIndex: number;\n startIndex: number;\n endIndexExclusive: number;\n matchedText: string;\n}\n\nexport interface ReplaceTarget {\n workbookName: string;\n sheetName: string;\n cellReference: string;\n occurrenceIndex: number;\n}\n\nexport interface ReplaceChange {\n workbookName: string;\n sheetName: string;\n cellReference: string;\n contentKind: \"formula\" | \"text\";\n occurrenceIndex: number;\n startIndex: number;\n endIndexExclusive: number;\n matchedText: string;\n replacementText: string;\n beforeContent: string;\n afterContent: string;\n}\n\n// Named expressions\nexport interface NamedExpression {\n name: string;\n expression: string;\n}\n\nexport interface TableDefinition {\n name: string;\n start: {\n rowIndex: number;\n colIndex: number;\n };\n headers: Map<string, { name: string; index: number }>;\n endRow: SpreadsheetRangeEnd;\n sheetName: string;\n workbookName: string;\n}\n\n// Formula errors\nexport enum FormulaError {\n DIV0 = \"#DIV/0!\",\n NA = \"#N/A\",\n NAME = \"#NAME?\",\n NUM = \"#NUM!\",\n REF = \"#REF!\",\n VALUE = \"#VALUE!\",\n CYCLE = \"#CYCLE!\",\n ERROR = \"#ERROR!\",\n SPILL = \"#SPILL!\",\n}\n\n// Sheet structure\nexport interface Sheet<TCellMetadata = unknown, TSheetMetadata = unknown> {\n name: string;\n index: number; // 0-based index of the sheet\n content: Map<string, SerializedCellValue>;\n /**\n * Cell metadata - arbitrary consumer-defined data per cell\n * Examples: rich text content, links, comments, custom app data\n * The engine stores and copies this data but doesn't interpret it\n * Keyed by cell reference (e.g., \"A1\")\n */\n metadata: Map<string, TCellMetadata>;\n /**\n * Sheet-level metadata - arbitrary consumer-defined data for the entire sheet\n * Examples: text boxes, drawings, frozen panes, print settings\n * The engine stores and copies this data but doesn't interpret it\n */\n sheetMetadata: TSheetMetadata;\n}\n\nexport interface Workbook<\n TCellMetadata = unknown,\n TSheetMetadata = unknown,\n TWorkbookMetadata = unknown\n> {\n name: string;\n sheets: Map<string, Sheet<TCellMetadata, TSheetMetadata>>;\n /**\n * Workbook-level metadata - arbitrary consumer-defined data for the entire workbook\n * Examples: themes, custom ribbons, document properties, workbook settings\n * The engine stores and copies this data but doesn't interpret it\n */\n workbookMetadata: TWorkbookMetadata;\n}\n\n/**\n * Tracked reference - a stable reference to a range that updates automatically\n * when workbooks/sheets are renamed and becomes invalid when they're deleted\n */\nexport interface TrackedReference {\n id: string; // UUID\n address: RangeAddress; // The range being tracked\n isValid: boolean; // False if sheet/workbook deleted\n}\n\nexport type ValueEvaluationResult = {\n type: \"value\";\n result: CellValue;\n /**\n * If the terminating evaluation result is a reference (see evaluateReference)\n * then we store information about the source cell for context dependent functions like CELL\n */\n sourceCell?: CellAddress;\n};\n\nexport type AwaitingEvaluationResult = {\n type: \"awaiting-evaluation\";\n waitingFor: DependencyNode;\n errAddress: DependencyNode;\n /**\n * If the terminating evaluation result is a reference (see evaluateReference)\n * then we store information about the source cell for context dependent functions like CELL\n */\n sourceCell?: CellAddress;\n};\n\nexport type DoesNotSpillResult = {\n type: \"does-not-spill\";\n};\n\nexport type ErrorEvaluationResult =\n | {\n type: \"error\";\n err: FormulaError;\n errAddress: DependencyNode;\n message: string;\n /**\n * If the terminating evaluation result is a reference (see evaluateReference)\n * then we store information about the source cell for context dependent functions like CELL\n */\n sourceCell?: CellAddress;\n }\n | AwaitingEvaluationResult;\n\nexport type SingleEvaluationResult =\n | ValueEvaluationResult\n | ErrorEvaluationResult;\n\nexport type SpilledValuesEvaluator = (\n spillOffset: { x: number; y: number },\n context: EvaluationContext\n) => SingleEvaluationResult;\n\nexport type SpilledValuesEvaluationResult = {\n type: \"spilled-values\";\n\n /**\n * When a raw range is evaluated, we will add it to the sourceRange so it can be used e.g. for context dependent functions\n */\n sourceRange?: RangeAddress;\n\n /**\n * If the terminating evaluation result is a reference (see evaluateReference)\n * then we store information about the source cell for context dependent functions like CELL\n * sourceCell will only be defined on a spilledValue when a single value is looked up,\n */\n sourceCell?: CellAddress;\n\n spillArea: (origin: CellAddress) => SpreadsheetRange;\n /**\n * for debugging we add a source string to denote where the spilled values were created\n */\n source: string;\n evaluate: SpilledValuesEvaluator;\n /**\n * evaluateAllCells evaluates all non-empty cells in the spilled range.\n * Because a spilled range can be open-ended, we need to have logic for which cells we should evaluate.\n * e.g. when evaluating a range such as D:D only the cells in the current sheet residing in\n * column D should be evaluated and cells producing spilled values that spill onto D:D.\n *\n * In order to evaluate spilled cells in D:D the range evaluateAllCells need to get all cells in the\n * the intersection of the spilled range and D:D, for that reason evaluateAllCells gets an intersection parameter,\n * where the intersection is relative to the origin.\n *\n * #### Producers:\n * In e.g. SEQUENCE and evaluateRange we have logic for which cells in a spilled range we should evaluate,\n *\n * #### Nesting:\n * e.g. evaluation of scalar operators where we want to nest e.g. `5 * right.evaluate()`\n * can be implemented by calling\n * ```ts\n * const vals = child.evaluateAllCells.call(this, options);\n * return vals.map(val => ({ ...val, result: 5 * val.result }));\n * ```\n *\n * #### Consumers:\n * Only functions that need access to all spilled values in a range end up calling evaluateAllCells, e.g.\n * SUM, MIN, MAX, MATCH. Other types of functions like INDEX doesn't need to evaluate all cells in a range,\n * but does a lookup into a spilled range using the evaluate method.\n *\n */\n evaluateAllCells: (\n this: FormulaEvaluator,\n options: {\n /**\n * an intersection relative to the origin\n */\n intersection?: SpreadsheetRange;\n evaluate: SpilledValuesEvaluator;\n context: EvaluationContext;\n /**\n * origin is the cell address that the spilled range is spilled from\n * e.g. in A3=B2:B4 the origin is A3\n */\n origin: CellAddress;\n\n lookupOrder: LookupOrder;\n }\n ) => EvaluateAllCellsResult;\n};\n\nexport type EvaluateAllCellsResult =\n | ErrorEvaluationResult\n | {\n type: \"values\";\n values: CellInRangeResult[];\n };\n\nexport type CellInRangeResult = {\n result: SingleEvaluationResult;\n relativePos: { x: number; y: number };\n};\n\nexport type FunctionEvaluationResult =\n | SingleEvaluationResult\n | SpilledValuesEvaluationResult;\n\nexport type SpilledValue = {\n /**\n * spillOnto is the range that the spilled value is spilled onto\n */\n spillOnto: SpreadsheetRange;\n /**\n * origin is the cell address that the spilled value is spilled from\n */\n origin: CellAddress;\n};\n\n/**\n * Function definition\n */\nexport interface FunctionDefinition {\n name: string;\n evaluate: (\n this: FormulaEvaluator,\n node: FunctionNode,\n context: EvaluationContext\n ) => FunctionEvaluationResult;\n aliases?: string[];\n}\n\n/**\n * Evaluation result\n */\nexport type EvaluationResult = {\n dependencies: Set<string>;\n} & FunctionEvaluationResult;\n\nexport type SCC = {\n id: number;\n nodes: Set<DependencyNode>; // All nodes considering soft + hard edges\n evaluationOrder: DependencyNode[]; // Flat topologically ordered list\n resolved: boolean;\n hardEdgeSCCs: Set<DependencyNode>[]; // SCCs formed by only hard edges (regular dependencies)\n};\n\nexport type SCCDAG = {\n sccList: SCC[];\n sccGraph: Map<number, Set<number>>; // Adjacency list of SCC dependencies\n};\n\nexport type EvaluationOrder = {\n evaluationOrder: Set<DependencyNode>;\n hasCycle: boolean;\n cycleNodes?: Set<DependencyNode>;\n hash: string;\n sccDAG?: SCCDAG;\n};\n\n// Conditional Styling types\nexport interface LCHColor {\n l: number; // Lightness: 0-100\n c: number; // Chroma: 0-150+\n h: number; // Hue: 0-360\n}\n\nexport interface FormulaStyleCondition {\n type: \"formula\";\n formula: string;\n color: LCHColor;\n}\n\nexport interface GradientStyleCondition {\n type: \"gradient\";\n min:\n | { type: \"lowest_value\"; color: LCHColor }\n | { type: \"number\"; color: LCHColor; valueFormula: string };\n max:\n | { type: \"highest_value\"; color: LCHColor }\n | { type: \"number\"; color: LCHColor; valueFormula: string };\n}\n\nexport type StyleCondition = FormulaStyleCondition | GradientStyleCondition;\n\nexport interface ConditionalStyle {\n areas: RangeAddress[];\n condition: StyleCondition;\n}\n\nexport interface DirectCellStyle {\n areas: RangeAddress[];\n style: CellStyle;\n}\n\nexport interface CellStyle {\n backgroundColor?: string; // Hex color format\n color?: string; // Text color in hex format\n fontSize?: number; // Font size in pixels\n bold?: boolean;\n italic?: boolean;\n underline?: boolean;\n}\n\nexport interface CopyCellsOptions {\n /**\n * Whether this is a cut operation (clears source cells after copying)\n * @default false\n */\n cut?: boolean;\n /**\n * What to include in the copy operation.\n * - Use 'all' as shorthand for ['content', 'style', 'metadata']\n * - Use array for fine-grained control over what to copy:\n * - ['content'] - copy only values/formulas\n * - ['style'] - copy only formatting\n * - ['metadata'] - copy only metadata (rich text, links, etc.)\n * - ['content', 'style'] - copy content and formatting\n * - ['content', 'metadata'] - copy content and metadata\n * - ['style', 'metadata'] - copy formatting and metadata\n * - ['content', 'style', 'metadata'] - same as 'all'\n * @default 'all'\n */\n include?: \"all\" | (\"content\" | \"style\" | \"metadata\")[];\n /**\n * The type of the content to copy\n * value: Copy the value from the source to the target,\n * e.g. if the cell has the formula =123 + 123 then the value is 246\n * formula: Copy the formula from the source to the target,\n * e.g. if the cell has the formula =123 + 123 then the formula is =123 + 123 is copied\n * @default 'formula'\n */\n type?: \"value\" | \"formula\";\n}\n"
|
|
5
|
+
"/**\n * Core type definitions for FormulaEngine\n * This file contains all fundamental types used throughout the engine\n */\n\nimport type { EvaluationContext } from \"../evaluator/evaluation-context.cjs\";\nimport type { FormulaEvaluator } from \"../evaluator/formula-evaluator.cjs\";\nimport type { FunctionNode } from \"../parser/ast.cjs\";\nimport type { DependencyNode } from \"./managers/dependency-node.cjs\";\nimport type { LookupOrder } from \"./managers/range-eval-order-builder.cjs\";\n\n// Cell addressing types\nexport interface CellAddress {\n sheetName: string;\n workbookName: string;\n colIndex: number;\n rowIndex: number;\n}\n\nexport interface RangeAddress {\n sheetName: string;\n workbookName: string;\n range: SpreadsheetRange;\n}\n\nexport interface LocalCellAddress {\n colIndex: number;\n rowIndex: number;\n}\n\nexport type ArethmeticEvaluator = (\n left: CellValue,\n right: CellValue,\n context: EvaluationContext\n) => CellValue | ErrorEvaluationResult;\n\nexport type PositiveInfinity = {\n type: \"infinity\";\n sign: \"positive\";\n};\n\nexport type CellInfinity = {\n type: \"infinity\";\n sign: \"positive\" | \"negative\";\n};\n\nexport type CellNumber = {\n type: \"number\";\n value: number;\n};\n\nexport type SpreadsheetRangeEnd = CellNumber | PositiveInfinity;\n\nexport type SpreadsheetRange = {\n start: {\n col: number;\n row: number;\n };\n end: {\n col: SpreadsheetRangeEnd;\n row: SpreadsheetRangeEnd;\n };\n};\n\nexport type RelativeRange = {\n start: {\n col: number;\n row: number;\n };\n width: SpreadsheetRangeEnd;\n height: SpreadsheetRangeEnd;\n};\n\nexport type FiniteSpreadsheetRange = {\n start: {\n col: number;\n row: number;\n };\n end: {\n col: number;\n row: number;\n };\n};\n\nexport type CellString = {\n type: \"string\";\n value: string;\n};\n\nexport type CellBoolean = {\n type: \"boolean\";\n value: boolean;\n};\n\n// Cell value types\nexport type CellValue = CellNumber | CellString | CellBoolean | CellInfinity;\n/**\n * undefined and \"\" are considered empty values\n * undefineds are converted to \"\" in the engine\n *\n * any empty values are deleted from the sheet content\n */\nexport type SerializedCellValue = string | number | boolean | undefined;\n\nexport interface SearchOptions {\n workbookName?: string;\n sheetName?: string;\n caseSensitive?: boolean;\n}\n\nexport interface SearchMatch {\n workbookName: string;\n sheetName: string;\n cellReference: string;\n cellContent: string;\n contentKind: \"formula\" | \"text\";\n occurrenceIndex: number;\n startIndex: number;\n endIndexExclusive: number;\n matchedText: string;\n}\n\nexport interface ReplaceTarget {\n workbookName: string;\n sheetName: string;\n cellReference: string;\n occurrenceIndex: number;\n}\n\nexport interface ReplaceChange {\n workbookName: string;\n sheetName: string;\n cellReference: string;\n contentKind: \"formula\" | \"text\";\n occurrenceIndex: number;\n startIndex: number;\n endIndexExclusive: number;\n matchedText: string;\n replacementText: string;\n beforeContent: string;\n afterContent: string;\n}\n\n// Named expressions\nexport interface NamedExpression {\n name: string;\n expression: string;\n}\n\nexport interface TableDefinition {\n name: string;\n start: {\n rowIndex: number;\n colIndex: number;\n };\n headers: Map<string, { name: string; index: number }>;\n endRow: SpreadsheetRangeEnd;\n sheetName: string;\n workbookName: string;\n}\n\n// Formula errors\nexport enum FormulaError {\n DIV0 = \"#DIV/0!\",\n NA = \"#N/A\",\n NAME = \"#NAME?\",\n NUM = \"#NUM!\",\n REF = \"#REF!\",\n VALUE = \"#VALUE!\",\n CYCLE = \"#CYCLE!\",\n ERROR = \"#ERROR!\",\n SPILL = \"#SPILL!\",\n}\n\n// Sheet structure\nexport interface Sheet<TCellMetadata = unknown, TSheetMetadata = unknown> {\n name: string;\n index: number; // 0-based index of the sheet\n content: Map<string, SerializedCellValue>;\n /**\n * Cell metadata - arbitrary consumer-defined data per cell\n * Examples: rich text content, links, comments, custom app data\n * The engine stores and copies this data but doesn't interpret it\n * Keyed by cell reference (e.g., \"A1\")\n */\n metadata: Map<string, TCellMetadata>;\n /**\n * Sheet-level metadata - arbitrary consumer-defined data for the entire sheet\n * Examples: text boxes, drawings, frozen panes, print settings\n * The engine stores and copies this data but doesn't interpret it\n */\n sheetMetadata: TSheetMetadata;\n}\n\nexport interface Workbook<\n TCellMetadata = unknown,\n TSheetMetadata = unknown,\n TWorkbookMetadata = unknown\n> {\n name: string;\n sheets: Map<string, Sheet<TCellMetadata, TSheetMetadata>>;\n /**\n * Workbook-level metadata - arbitrary consumer-defined data for the entire workbook\n * Examples: themes, custom ribbons, document properties, workbook settings\n * The engine stores and copies this data but doesn't interpret it\n */\n workbookMetadata: TWorkbookMetadata;\n}\n\n/**\n * Tracked reference - a stable reference to a range that updates automatically\n * when workbooks/sheets are renamed and becomes invalid when they're deleted\n */\nexport interface TrackedReference {\n id: string; // UUID\n address: RangeAddress; // The range being tracked\n isValid: boolean; // False if sheet/workbook deleted\n}\n\nexport type ValueEvaluationResult = {\n type: \"value\";\n result: CellValue;\n /**\n * If the terminating evaluation result is a reference (see evaluateReference)\n * then we store information about the source cell for context dependent functions like CELL\n */\n sourceCell?: CellAddress;\n};\n\nexport type AwaitingEvaluationResult = {\n type: \"awaiting-evaluation\";\n waitingFor: DependencyNode;\n errAddress: DependencyNode;\n /**\n * If the terminating evaluation result is a reference (see evaluateReference)\n * then we store information about the source cell for context dependent functions like CELL\n */\n sourceCell?: CellAddress;\n};\n\nexport type DoesNotSpillResult = {\n type: \"does-not-spill\";\n};\n\nexport type ErrorEvaluationResult =\n | {\n type: \"error\";\n err: FormulaError;\n errAddress: DependencyNode;\n message: string;\n /**\n * If the terminating evaluation result is a reference (see evaluateReference)\n * then we store information about the source cell for context dependent functions like CELL\n */\n sourceCell?: CellAddress;\n }\n | AwaitingEvaluationResult;\n\nexport type SingleEvaluationResult =\n | ValueEvaluationResult\n | ErrorEvaluationResult;\n\nexport type SpilledValuesEvaluator = (\n spillOffset: { x: number; y: number },\n context: EvaluationContext\n) => SingleEvaluationResult;\n\nexport type SpilledValuesEvaluationResult = {\n type: \"spilled-values\";\n\n /**\n * When a raw range is evaluated, we will add it to the sourceRange so it can be used e.g. for context dependent functions\n */\n sourceRange?: RangeAddress;\n\n /**\n * If the terminating evaluation result is a reference (see evaluateReference)\n * then we store information about the source cell for context dependent functions like CELL\n * sourceCell will only be defined on a spilledValue when a single value is looked up,\n */\n sourceCell?: CellAddress;\n\n spillArea: (origin: CellAddress) => SpreadsheetRange;\n /**\n * for debugging we add a source string to denote where the spilled values were created\n */\n source: string;\n evaluate: SpilledValuesEvaluator;\n /**\n * evaluateAllCells evaluates all non-empty cells in the spilled range.\n * Because a spilled range can be open-ended, we need to have logic for which cells we should evaluate.\n * e.g. when evaluating a range such as D:D only the cells in the current sheet residing in\n * column D should be evaluated and cells producing spilled values that spill onto D:D.\n *\n * In order to evaluate spilled cells in D:D the range evaluateAllCells need to get all cells in the\n * the intersection of the spilled range and D:D, for that reason evaluateAllCells gets an intersection parameter,\n * where the intersection is relative to the origin.\n *\n * #### Producers:\n * In e.g. SEQUENCE and evaluateRange we have logic for which cells in a spilled range we should evaluate,\n *\n * #### Nesting:\n * e.g. evaluation of scalar operators where we want to nest e.g. `5 * right.evaluate()`\n * can be implemented by calling\n * ```ts\n * const vals = child.evaluateAllCells.call(this, options);\n * return vals.map(val => ({ ...val, result: 5 * val.result }));\n * ```\n *\n * #### Consumers:\n * Only functions that need access to all spilled values in a range end up calling evaluateAllCells, e.g.\n * SUM, MIN, MAX, MATCH. Other types of functions like INDEX doesn't need to evaluate all cells in a range,\n * but does a lookup into a spilled range using the evaluate method.\n *\n */\n evaluateAllCells: (\n this: FormulaEvaluator,\n options: {\n /**\n * an intersection relative to the origin\n */\n intersection?: SpreadsheetRange;\n evaluate: SpilledValuesEvaluator;\n context: EvaluationContext;\n /**\n * origin is the cell address that the spilled range is spilled from\n * e.g. in A3=B2:B4 the origin is A3\n */\n origin: CellAddress;\n\n lookupOrder: LookupOrder;\n }\n ) => EvaluateAllCellsResult;\n};\n\nexport type EvaluateAllCellsResult =\n | ErrorEvaluationResult\n | {\n type: \"values\";\n values: CellInRangeResult[];\n };\n\nexport type CellInRangeResult = {\n result: SingleEvaluationResult;\n relativePos: { x: number; y: number };\n};\n\nexport type FunctionEvaluationResult =\n | SingleEvaluationResult\n | SpilledValuesEvaluationResult;\n\nexport type SpilledValue = {\n /**\n * spillOnto is the range that the spilled value is spilled onto\n */\n spillOnto: SpreadsheetRange;\n /**\n * origin is the cell address that the spilled value is spilled from\n */\n origin: CellAddress;\n};\n\n/**\n * Function definition\n */\nexport interface FunctionDefinition {\n name: string;\n evaluate: (\n this: FormulaEvaluator,\n node: FunctionNode,\n context: EvaluationContext\n ) => FunctionEvaluationResult;\n aliases?: string[];\n}\n\n/**\n * Evaluation result\n */\nexport type EvaluationResult = {\n dependencies: Set<string>;\n} & FunctionEvaluationResult;\n\nexport type SCC = {\n id: number;\n nodes: Set<DependencyNode>; // All nodes considering soft + hard edges\n evaluationOrder: DependencyNode[]; // Flat topologically ordered list\n resolved: boolean;\n hardEdgeSCCs: Set<DependencyNode>[]; // SCCs formed by only hard edges (regular dependencies)\n};\n\nexport type SCCDAG = {\n sccList: SCC[];\n sccGraph: Map<number, Set<number>>; // Adjacency list of SCC dependencies\n};\n\nexport type EvaluationOrder = {\n evaluationOrder: Set<DependencyNode>;\n hasCycle: boolean;\n cycleNodes?: Set<DependencyNode>;\n hash: string;\n sccDAG?: SCCDAG;\n};\n\n// Conditional Styling types\nexport interface LCHColor {\n l: number; // Lightness: 0-100\n c: number; // Chroma: 0-150+\n h: number; // Hue: 0-360\n}\n\nexport interface FormulaStyleCondition {\n type: \"formula\";\n formula: string;\n color: LCHColor;\n}\n\nexport interface GradientStyleCondition {\n type: \"gradient\";\n min:\n | { type: \"lowest_value\"; color: LCHColor }\n | { type: \"number\"; color: LCHColor; valueFormula: string };\n max:\n | { type: \"highest_value\"; color: LCHColor }\n | { type: \"number\"; color: LCHColor; valueFormula: string };\n}\n\nexport type StyleCondition = FormulaStyleCondition | GradientStyleCondition;\n\nexport interface ConditionalStyle {\n areas: RangeAddress[];\n condition: StyleCondition;\n}\n\nexport interface DirectCellStyle {\n areas: RangeAddress[];\n style: CellStyle;\n}\n\nexport interface RangeMetadata<TMetadata = unknown> {\n id: string;\n areas: RangeAddress[];\n metadata: TMetadata;\n}\n\nexport interface RangeMetadataInput<TMetadata = unknown> {\n id?: string;\n areas: RangeAddress[];\n metadata: TMetadata;\n}\n\nexport interface CellStyle {\n backgroundColor?: string; // Hex color format\n color?: string; // Text color in hex format\n fontSize?: number; // Font size in pixels\n bold?: boolean;\n italic?: boolean;\n underline?: boolean;\n wrapText?: boolean;\n}\n\nexport type CopyCellsIncludePart =\n | \"content\"\n | \"style\"\n | \"cellMetadata\"\n | \"rangeMetadata\";\n\nexport interface CopyCellsOptions {\n /**\n * Whether this is a cut operation (clears source cells after copying)\n * @default false\n */\n cut?: boolean;\n /**\n * What to include in the copy operation.\n * - Use 'all' as shorthand for ['content', 'style', 'cellMetadata', 'rangeMetadata']\n * - Use array for fine-grained control over what to copy:\n * - ['content'] - copy only values/formulas\n * - ['style'] - copy only formatting\n * - ['cellMetadata'] - copy only cell metadata (rich text, links, etc.)\n * - ['rangeMetadata'] - copy only range metadata\n * - ['content', 'style'] - copy content and formatting\n * - ['content', 'cellMetadata'] - copy content and cell metadata\n * - ['style', 'rangeMetadata'] - copy formatting and range metadata\n * - ['content', 'style', 'cellMetadata', 'rangeMetadata'] - same as 'all'\n * @default 'all'\n */\n include?: \"all\" | CopyCellsIncludePart[];\n /**\n * The type of the content to copy\n * value: Copy the value from the source to the target,\n * e.g. if the cell has the formula =123 + 123 then the value is 246\n * formula: Copy the formula from the source to the target,\n * e.g. if the cell has the formula =123 + 123 then the formula is =123 + 123 is copied\n * @default 'formula'\n */\n type?: \"value\" | \"formula\";\n}\n"
|
|
6
6
|
],
|
|
7
7
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkKO,IAAK;AAAA,CAAL,CAAK,kBAAL;AAAA,EACL,wBAAO;AAAA,EACP,sBAAK;AAAA,EACL,wBAAO;AAAA,EACP,uBAAM;AAAA,EACN,uBAAM;AAAA,EACN,yBAAQ;AAAA,EACR,yBAAQ;AAAA,EACR,yBAAQ;AAAA,EACR,yBAAQ;AAAA,GATE;",
|
|
8
8
|
"debugId": "5EC6531CF2E47C8764756E2164756E21",
|
package/dist/cjs/package.json
CHANGED
|
@@ -8,9 +8,11 @@ import { intersectRanges } from "./utils/range-utils.mjs";
|
|
|
8
8
|
class AutoFill {
|
|
9
9
|
workbookManager;
|
|
10
10
|
styleManager;
|
|
11
|
-
|
|
11
|
+
rangeMetadataManager;
|
|
12
|
+
constructor(workbookManager, styleManager, rangeMetadataManager) {
|
|
12
13
|
this.workbookManager = workbookManager;
|
|
13
14
|
this.styleManager = styleManager;
|
|
15
|
+
this.rangeMetadataManager = rangeMetadataManager;
|
|
14
16
|
}
|
|
15
17
|
toFiniteRange(range) {
|
|
16
18
|
if (range.end.col.type === "infinity" || range.end.row.type === "infinity") {
|
|
@@ -62,6 +64,7 @@ class AutoFill {
|
|
|
62
64
|
this.workbookManager.setSheetContent(opts, newContent);
|
|
63
65
|
this.fillStyles(opts, finiteSeedRange, finiteFillRange, direction);
|
|
64
66
|
this.fillMetadata(opts, finiteSeedRange, finiteFillRange, direction);
|
|
67
|
+
this.fillRangeMetadata(opts, finiteSeedRange, finiteFillRange, direction);
|
|
65
68
|
}
|
|
66
69
|
getSeedCells(opts, seedRange) {
|
|
67
70
|
const cells = [];
|
|
@@ -406,9 +409,72 @@ class AutoFill {
|
|
|
406
409
|
}
|
|
407
410
|
}
|
|
408
411
|
}
|
|
412
|
+
fillRangeMetadata(opts, seedRange, fillRange, direction) {
|
|
413
|
+
const fillRangeAddress = {
|
|
414
|
+
workbookName: opts.workbookName,
|
|
415
|
+
sheetName: opts.sheetName,
|
|
416
|
+
range: {
|
|
417
|
+
start: { col: fillRange.start.col, row: fillRange.start.row },
|
|
418
|
+
end: {
|
|
419
|
+
col: { type: "number", value: fillRange.end.col },
|
|
420
|
+
row: { type: "number", value: fillRange.end.row }
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
this.rangeMetadataManager.clearRangeMetadataInRange(fillRangeAddress);
|
|
425
|
+
const seedWidth = seedRange.end.col - seedRange.start.col + 1;
|
|
426
|
+
const seedHeight = seedRange.end.row - seedRange.start.row + 1;
|
|
427
|
+
const allRangeMetadata = this.rangeMetadataManager.getAllRangeMetadata();
|
|
428
|
+
for (let row = fillRange.start.row;row <= fillRange.end.row; row++) {
|
|
429
|
+
for (let col = fillRange.start.col;col <= fillRange.end.col; col++) {
|
|
430
|
+
let seedCol;
|
|
431
|
+
let seedRow;
|
|
432
|
+
if (direction === "down" || direction === "up") {
|
|
433
|
+
seedCol = seedRange.start.col + (col - fillRange.start.col) % seedWidth;
|
|
434
|
+
seedRow = seedRange.start.row + (row - fillRange.start.row) % seedHeight;
|
|
435
|
+
} else {
|
|
436
|
+
seedRow = seedRange.start.row + (row - fillRange.start.row) % seedHeight;
|
|
437
|
+
seedCol = seedRange.start.col + (col - fillRange.start.col) % seedWidth;
|
|
438
|
+
}
|
|
439
|
+
const sourceCellRange = {
|
|
440
|
+
start: { col: seedCol, row: seedRow },
|
|
441
|
+
end: {
|
|
442
|
+
col: { type: "number", value: seedCol },
|
|
443
|
+
row: { type: "number", value: seedRow }
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
const targetCellRange = {
|
|
447
|
+
workbookName: opts.workbookName,
|
|
448
|
+
sheetName: opts.sheetName,
|
|
449
|
+
range: {
|
|
450
|
+
start: { col, row },
|
|
451
|
+
end: {
|
|
452
|
+
col: { type: "number", value: col },
|
|
453
|
+
row: { type: "number", value: row }
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
for (const entry of allRangeMetadata) {
|
|
458
|
+
for (const area of entry.areas) {
|
|
459
|
+
if (area.workbookName !== opts.workbookName || area.sheetName !== opts.sheetName) {
|
|
460
|
+
continue;
|
|
461
|
+
}
|
|
462
|
+
const intersection = intersectRanges(area.range, sourceCellRange);
|
|
463
|
+
if (!intersection) {
|
|
464
|
+
continue;
|
|
465
|
+
}
|
|
466
|
+
this.rangeMetadataManager.addRangeMetadata({
|
|
467
|
+
areas: [targetCellRange],
|
|
468
|
+
metadata: entry.metadata
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}
|
|
409
475
|
}
|
|
410
476
|
export {
|
|
411
477
|
AutoFill
|
|
412
478
|
};
|
|
413
479
|
|
|
414
|
-
//# debugId=
|
|
480
|
+
//# debugId=8E208D0BC4A4FCCD64756E2164756E21
|