@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.
Files changed (36) hide show
  1. package/dist/cjs/core/autofill-utils.cjs +68 -2
  2. package/dist/cjs/core/autofill-utils.cjs.map +3 -3
  3. package/dist/cjs/core/engine-snapshot.cjs +2 -2
  4. package/dist/cjs/core/engine-snapshot.cjs.map +3 -3
  5. package/dist/cjs/core/engine.cjs +89 -5
  6. package/dist/cjs/core/engine.cjs.map +3 -3
  7. package/dist/cjs/core/managers/copy-manager.cjs +163 -14
  8. package/dist/cjs/core/managers/copy-manager.cjs.map +3 -3
  9. package/dist/cjs/core/managers/named-expression-manager.cjs +18 -16
  10. package/dist/cjs/core/managers/named-expression-manager.cjs.map +3 -3
  11. package/dist/cjs/core/managers/range-metadata-manager.cjs +135 -0
  12. package/dist/cjs/core/managers/range-metadata-manager.cjs.map +10 -0
  13. package/dist/cjs/core/types.cjs.map +1 -1
  14. package/dist/cjs/package.json +1 -1
  15. package/dist/mjs/core/autofill-utils.mjs +68 -2
  16. package/dist/mjs/core/autofill-utils.mjs.map +3 -3
  17. package/dist/mjs/core/engine-snapshot.mjs +2 -2
  18. package/dist/mjs/core/engine-snapshot.mjs.map +3 -3
  19. package/dist/mjs/core/engine.mjs +89 -5
  20. package/dist/mjs/core/engine.mjs.map +3 -3
  21. package/dist/mjs/core/managers/copy-manager.mjs +163 -14
  22. package/dist/mjs/core/managers/copy-manager.mjs.map +3 -3
  23. package/dist/mjs/core/managers/named-expression-manager.mjs +18 -16
  24. package/dist/mjs/core/managers/named-expression-manager.mjs.map +3 -3
  25. package/dist/mjs/core/managers/range-metadata-manager.mjs +95 -0
  26. package/dist/mjs/core/managers/range-metadata-manager.mjs.map +10 -0
  27. package/dist/mjs/core/types.mjs.map +1 -1
  28. package/dist/mjs/package.json +1 -1
  29. package/dist/types/core/autofill-utils.d.ts +7 -1
  30. package/dist/types/core/engine-snapshot.d.ts +4 -2
  31. package/dist/types/core/engine.d.ts +34 -1
  32. package/dist/types/core/managers/copy-manager.d.ts +11 -1
  33. package/dist/types/core/managers/named-expression-manager.d.ts +1 -0
  34. package/dist/types/core/managers/range-metadata-manager.d.ts +22 -0
  35. package/dist/types/core/types.d.ts +19 -6
  36. package/package.json +1 -1
@@ -343,24 +343,21 @@ class NamedExpressionManager {
343
343
  };
344
344
  }
345
345
  resetNamedExpressions(namedExpressions) {
346
- this.setNamedExpressions({
347
- type: "global",
348
- expressions: namedExpressions.globalExpressions
346
+ this.globalExpressions.clear();
347
+ namedExpressions.globalExpressions.forEach((expression, name) => {
348
+ this.globalExpressions.set(name, expression);
349
349
  });
350
- namedExpressions.workbookExpressions.forEach((workbookExpressions, workbookName) => {
351
- this.setNamedExpressions({
352
- type: "workbook",
353
- expressions: workbookExpressions,
354
- workbookName
350
+ this.workbookExpressions.forEach((workbookExpressions, workbookName) => {
351
+ workbookExpressions.clear();
352
+ namedExpressions.workbookExpressions.get(workbookName)?.forEach((expression, name) => {
353
+ workbookExpressions.set(name, expression);
355
354
  });
356
355
  });
357
- namedExpressions.sheetExpressions.forEach((sheetExpressions, workbookName) => {
358
- sheetExpressions.forEach((sheetExpression, sheetName) => {
359
- this.setNamedExpressions({
360
- type: "sheet",
361
- expressions: sheetExpression,
362
- sheetName,
363
- workbookName
356
+ this.sheetExpressions.forEach((sheets, workbookName) => {
357
+ sheets.forEach((sheetExpressions, sheetName) => {
358
+ sheetExpressions.clear();
359
+ namedExpressions.sheetExpressions.get(workbookName)?.get(sheetName)?.forEach((expression, name) => {
360
+ sheetExpressions.set(name, expression);
364
361
  });
365
362
  });
366
363
  });
@@ -371,6 +368,11 @@ class NamedExpressionManager {
371
368
  restoreFromSnapshot(snapshot) {
372
369
  this.resetNamedExpressions(snapshot);
373
370
  }
371
+ clear() {
372
+ this.sheetExpressions.clear();
373
+ this.workbookExpressions.clear();
374
+ this.globalExpressions.clear();
375
+ }
374
376
  addSheet(opts) {
375
377
  const wbLevel = this.sheetExpressions.get(opts.workbookName);
376
378
  if (!wbLevel) {
@@ -428,4 +430,4 @@ export {
428
430
  NamedExpressionManager
429
431
  };
430
432
 
431
- //# debugId=76256477A2C9265564756E2164756E21
433
+ //# debugId=46203FEA0FF50E7E64756E2164756E21
@@ -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.mjs\";\nimport type { NamedExpressionManagerSnapshot } from \"../engine-snapshot.mjs\";\nimport { renameNamedExpressionInFormula } from \"../named-expression-renamer.mjs\";\nimport type { EventManager } from \"./event-manager.mjs\";\nimport type { NamedExpressionNode } from \"../../parser/ast.mjs\";\nimport type { EvaluationContext } from \"../../evaluator/evaluation-context.mjs\";\nimport { getNamedExpressionResourceKey } from \"../resource-keys.mjs\";\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.mjs\";\nimport type { NamedExpressionManagerSnapshot } from \"../engine-snapshot.mjs\";\nimport { renameNamedExpressionInFormula } from \"../named-expression-renamer.mjs\";\nimport type { EventManager } from \"./event-manager.mjs\";\nimport type { NamedExpressionNode } from \"../../parser/ast.mjs\";\nimport type { EvaluationContext } from \"../../evaluator/evaluation-context.mjs\";\nimport { getNamedExpressionResourceKey } from \"../resource-keys.mjs\";\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": ";AAMA;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,CAAC,cAAc;AAAA,MAC9B,MAAM,IAAI,MAAM,sBAAsB;AAAA,IACxC;AAAA,IAEA,IAAI,aAAa,cAAc;AAAA,MAC7B,IAAI,UAAU,KAAK,iBAAiB,IAAI,YAAY;AAAA,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BAAsB,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": "46203FEA0FF50E7E64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -0,0 +1,95 @@
1
+ // src/core/managers/range-metadata-manager.ts
2
+ import { isCellInRange } from "../utils.mjs";
3
+ import { rangesIntersect, subtractRange } from "../utils/range-utils.mjs";
4
+ var cloneArea = (area) => ({
5
+ workbookName: area.workbookName,
6
+ sheetName: area.sheetName,
7
+ range: {
8
+ start: { ...area.range.start },
9
+ end: {
10
+ col: { ...area.range.end.col },
11
+ row: { ...area.range.end.row }
12
+ }
13
+ }
14
+ });
15
+ var cloneEntry = (entry) => ({
16
+ id: entry.id,
17
+ areas: entry.areas.map(cloneArea),
18
+ metadata: entry.metadata
19
+ });
20
+
21
+ class RangeMetadataManager {
22
+ rangeMetadata = [];
23
+ addRangeMetadata(entry) {
24
+ const id = entry.id ?? crypto.randomUUID();
25
+ if (this.rangeMetadata.some((existing) => existing.id === id)) {
26
+ throw new Error(`Range metadata with id "${id}" already exists`);
27
+ }
28
+ this.rangeMetadata.push({
29
+ id,
30
+ areas: entry.areas.map(cloneArea),
31
+ metadata: entry.metadata
32
+ });
33
+ return id;
34
+ }
35
+ removeRangeMetadata(id) {
36
+ const beforeLength = this.rangeMetadata.length;
37
+ this.rangeMetadata = this.rangeMetadata.filter((entry) => entry.id !== id);
38
+ return this.rangeMetadata.length !== beforeLength;
39
+ }
40
+ getAllRangeMetadata() {
41
+ return this.rangeMetadata.map(cloneEntry);
42
+ }
43
+ getRangeMetadataForCell(cellAddress) {
44
+ return this.rangeMetadata.filter((entry) => entry.areas.some((area) => area.workbookName === cellAddress.workbookName && area.sheetName === cellAddress.sheetName && isCellInRange(cellAddress, area.range))).map(cloneEntry);
45
+ }
46
+ getRangeMetadataIntersectingWithRange(range) {
47
+ return this.rangeMetadata.filter((entry) => entry.areas.some((area) => area.workbookName === range.workbookName && area.sheetName === range.sheetName && rangesIntersect(area.range, range.range))).map(cloneEntry);
48
+ }
49
+ clearRangeMetadataInRange(range) {
50
+ this.rangeMetadata = this.rangeMetadata.map((entry) => ({
51
+ ...entry,
52
+ areas: entry.areas.flatMap((area) => {
53
+ if (area.workbookName !== range.workbookName || area.sheetName !== range.sheetName) {
54
+ return [area];
55
+ }
56
+ return subtractRange(area.range, range.range).map((remainingRange) => ({
57
+ ...area,
58
+ range: remainingRange
59
+ }));
60
+ })
61
+ })).filter((entry) => entry.areas.length > 0);
62
+ }
63
+ removeWorkbookRangeMetadata(workbookName) {
64
+ this.rangeMetadata = this.rangeMetadata.filter((entry) => !entry.areas.some((area) => area.workbookName === workbookName));
65
+ }
66
+ removeSheetRangeMetadata(workbookName, sheetName) {
67
+ this.rangeMetadata = this.rangeMetadata.filter((entry) => !entry.areas.some((area) => area.workbookName === workbookName && area.sheetName === sheetName));
68
+ }
69
+ updateWorkbookName(oldName, newName) {
70
+ this.rangeMetadata = this.rangeMetadata.map((entry) => ({
71
+ ...entry,
72
+ areas: entry.areas.map((area) => area.workbookName === oldName ? { ...area, workbookName: newName } : area)
73
+ }));
74
+ }
75
+ updateSheetName(workbookName, oldSheetName, newSheetName) {
76
+ this.rangeMetadata = this.rangeMetadata.map((entry) => ({
77
+ ...entry,
78
+ areas: entry.areas.map((area) => area.workbookName === workbookName && area.sheetName === oldSheetName ? { ...area, sheetName: newSheetName } : area)
79
+ }));
80
+ }
81
+ resetRangeMetadata(rangeMetadata) {
82
+ this.rangeMetadata = rangeMetadata ? rangeMetadata.map(cloneEntry) : [];
83
+ }
84
+ toSnapshot() {
85
+ return this.getAllRangeMetadata();
86
+ }
87
+ restoreFromSnapshot(snapshot) {
88
+ this.resetRangeMetadata(snapshot);
89
+ }
90
+ }
91
+ export {
92
+ RangeMetadataManager
93
+ };
94
+
95
+ //# debugId=7530C074EFE9F64464756E2164756E21
@@ -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.mjs\";\nimport type { RangeMetadataManagerSnapshot } from \"../engine-snapshot.mjs\";\nimport { isCellInRange } from \"../utils.mjs\";\nimport { rangesIntersect, subtractRange } from \"../utils/range-utils.mjs\";\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.resetRangeMetadata(snapshot as RangeMetadata<TMetadata>[]);\n }\n}\n"
6
+ ],
7
+ "mappings": ";AAYA;AACA;AAEA,IAAM,YAAY,CAAC,UAAsC;AAAA,EACvD,cAAc,KAAK;AAAA,EACnB,WAAW,KAAK;AAAA,EAChB,OAAO;AAAA,IACL,OAAO,KAAK,KAAK,MAAM,MAAM;AAAA,IAC7B,KAAK;AAAA,MACH,KAAK,KAAK,KAAK,MAAM,IAAI,IAAI;AAAA,MAC7B,KAAK,KAAK,KAAK,MAAM,IAAI,IAAI;AAAA,IAC/B;AAAA,EACF;AACF;AAEA,IAAM,aAAa,CACjB,WAC8B;AAAA,EAC9B,IAAI,MAAM;AAAA,EACV,OAAO,MAAM,MAAM,IAAI,SAAS;AAAA,EAChC,UAAU,MAAM;AAClB;AAAA;AAEO,MAAM,qBAA0C;AAAA,EAC7C,gBAA4C,CAAC;AAAA,EAErD,gBAAgB,CAAC,OAA8C;AAAA,IAC7D,MAAM,KAAK,MAAM,MAAM,OAAO,WAAW;AAAA,IACzC,IAAI,KAAK,cAAc,KAAK,CAAC,aAAa,SAAS,OAAO,EAAE,GAAG;AAAA,MAC7D,MAAM,IAAI,MAAM,2BAA2B,oBAAoB;AAAA,IACjE;AAAA,IAEA,KAAK,cAAc,KAAK;AAAA,MACtB;AAAA,MACA,OAAO,MAAM,MAAM,IAAI,SAAS;AAAA,MAChC,UAAU,MAAM;AAAA,IAClB,CAAC;AAAA,IAED,OAAO;AAAA;AAAA,EAGT,mBAAmB,CAAC,IAAqB;AAAA,IACvC,MAAM,eAAe,KAAK,cAAc;AAAA,IACxC,KAAK,gBAAgB,KAAK,cAAc,OA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EAGF,wBAAwB,CAAC,cAAsB,WAAyB;AAAA,IACtE,KAAK,gBAAgB,KAAK,cAAc,OACtC,CAAC,UACC,CAAC,MAAM,MAAM,KACX,CAAC,SACC,KAAK,iBAAiB,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": "7530C074EFE9F64464756E2164756E21",
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.mjs\";\nimport type { FormulaEvaluator } from \"../evaluator/formula-evaluator.mjs\";\nimport type { FunctionNode } from \"../parser/ast.mjs\";\nimport type { DependencyNode } from \"./managers/dependency-node.mjs\";\nimport type { LookupOrder } from \"./managers/range-eval-order-builder.mjs\";\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.mjs\";\nimport type { FormulaEvaluator } from \"../evaluator/formula-evaluator.mjs\";\nimport type { FunctionNode } from \"../parser/ast.mjs\";\nimport type { DependencyNode } from \"./managers/dependency-node.mjs\";\nimport type { LookupOrder } from \"./managers/range-eval-order-builder.mjs\";\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": "0E7C5AF634572D3964756E2164756E21",
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@ricsam/formula-engine",
3
- "version": "0.2.10",
3
+ "version": "0.2.12",
4
4
  "type": "module"
5
5
  }
@@ -5,10 +5,12 @@ import type { SpreadsheetRange } from "./types";
5
5
  import type { FillDirection } from "@ricsam/selection-manager";
6
6
  import type { WorkbookManager } from "./managers/workbook-manager";
7
7
  import type { StyleManager } from "./managers/style-manager";
8
+ import type { RangeMetadataManager } from "./managers/range-metadata-manager";
8
9
  export declare class AutoFill {
9
10
  private workbookManager;
10
11
  private styleManager;
11
- constructor(workbookManager: WorkbookManager, styleManager: StyleManager);
12
+ private rangeMetadataManager;
13
+ constructor(workbookManager: WorkbookManager, styleManager: StyleManager, rangeMetadataManager: RangeMetadataManager);
12
14
  /**
13
15
  * Converts a SpreadsheetRange to FiniteSpreadsheetRange, throwing an error if infinite
14
16
  */
@@ -37,4 +39,8 @@ export declare class AutoFill {
37
39
  * Copy metadata from seed range to fill range with pattern repetition
38
40
  */
39
41
  private fillMetadata;
42
+ /**
43
+ * Copy range metadata from seed range to fill range with pattern repetition.
44
+ */
45
+ private fillRangeMetadata;
40
46
  }
@@ -1,7 +1,7 @@
1
1
  import type { ContextDependency } from "../evaluator/evaluation-context";
2
2
  import type { DependencyNode } from "./managers/dependency-node";
3
- import type { CellAddress, CellInRangeResult, CellValue, ConditionalStyle, DirectCellStyle, FormulaError, NamedExpression, RangeAddress, RelativeRange, SpreadsheetRange, TableDefinition, TrackedReference, Workbook } from "./types";
4
- export declare const ENGINE_SNAPSHOT_VERSION: 4;
3
+ import type { CellAddress, CellInRangeResult, CellValue, ConditionalStyle, DirectCellStyle, FormulaError, NamedExpression, RangeAddress, RangeMetadata, RelativeRange, SpreadsheetRange, TableDefinition, TrackedReference, Workbook } from "./types";
4
+ export declare const ENGINE_SNAPSHOT_VERSION: 5;
5
5
  export type NodeSnapshotId = string;
6
6
  export type NamedExpressionManagerSnapshot = {
7
7
  sheetExpressions: Map<string, Map<string, Map<string, NamedExpression>>>;
@@ -14,6 +14,7 @@ export type StyleManagerSnapshot = {
14
14
  conditionalStyles: ConditionalStyle[];
15
15
  cellStyles: DirectCellStyle[];
16
16
  };
17
+ export type RangeMetadataManagerSnapshot = RangeMetadata[];
17
18
  export type ReferenceManagerSnapshot = Map<string, TrackedReference>;
18
19
  export type SerializedValueEvaluationResultSnapshot = {
19
20
  type: "value";
@@ -124,6 +125,7 @@ type EngineSnapshotManagers = {
124
125
  namedExpression: NamedExpressionManagerSnapshot;
125
126
  table: TableManagerSnapshot;
126
127
  style: StyleManagerSnapshot;
128
+ rangeMetadata: RangeMetadataManagerSnapshot;
127
129
  reference: ReferenceManagerSnapshot;
128
130
  dependency: DependencyManagerSnapshot;
129
131
  cache: CacheManagerSnapshot;
@@ -2,7 +2,7 @@
2
2
  * Main FormulaEngine class
3
3
  * Core API implementation for spreadsheet calculations
4
4
  */
5
- import { type CellAddress, type CellStyle, type ConditionalStyle, type CopyCellsOptions, type DirectCellStyle, type NamedExpression, type RangeAddress, type ReplaceChange, type ReplaceTarget, type SearchMatch, type SearchOptions, type SerializedCellValue, type Sheet, type SingleEvaluationResult, type SpreadsheetRange, type SpreadsheetRangeEnd, type TableDefinition } from "./types";
5
+ import { type CellAddress, type CellStyle, type ConditionalStyle, type CopyCellsOptions, type DirectCellStyle, type NamedExpression, type RangeAddress, type RangeMetadata, type RangeMetadataInput, type ReplaceChange, type ReplaceTarget, type SearchMatch, type SearchOptions, type SerializedCellValue, type Sheet, type SingleEvaluationResult, type SpreadsheetRange, type SpreadsheetRangeEnd, type TableDefinition } from "./types";
6
6
  import type { FillDirection } from "@ricsam/selection-manager";
7
7
  import { AutoFill } from "./autofill-utils";
8
8
  import { WorkbookManager } from "./managers/workbook-manager";
@@ -12,8 +12,10 @@ import { EventManager } from "./managers/event-manager";
12
12
  import { EvaluationManager } from "./managers/evaluation-manager";
13
13
  import { DependencyManager } from "./managers/dependency-manager";
14
14
  import { StyleManager } from "./managers/style-manager";
15
+ import { RangeMetadataManager } from "./managers/range-metadata-manager";
15
16
  type Metadata = {
16
17
  cell?: unknown;
18
+ range?: unknown;
17
19
  sheet?: unknown;
18
20
  workbook?: unknown;
19
21
  };
@@ -31,6 +33,7 @@ export declare class FormulaEngine<TMetadata extends Metadata = Metadata> {
31
33
  private autoFillManager;
32
34
  private dependencyManager;
33
35
  private styleManager;
36
+ private rangeMetadataManager;
34
37
  private copyManager;
35
38
  private referenceManager;
36
39
  /**
@@ -44,6 +47,7 @@ export declare class FormulaEngine<TMetadata extends Metadata = Metadata> {
44
47
  _autoFillManager: AutoFill;
45
48
  _dependencyManager: DependencyManager;
46
49
  _styleManager: StyleManager;
50
+ _rangeMetadataManager: RangeMetadataManager<MetadataType<TMetadata, "range">>;
47
51
  constructor();
48
52
  /**
49
53
  * Static factory method to build an empty engine
@@ -55,6 +59,7 @@ export declare class FormulaEngine<TMetadata extends Metadata = Metadata> {
55
59
  private getExistingSheetContent;
56
60
  private getWorkbookResourceKeys;
57
61
  private getSheetResourceKeys;
62
+ private assertNamedExpressionScopeExists;
58
63
  getCellEvaluationResult(cellAddress: CellAddress): SingleEvaluationResult | undefined;
59
64
  getCellValue(cellAddress: CellAddress, debug?: boolean): SerializedCellValue;
60
65
  /**
@@ -97,6 +102,32 @@ export declare class FormulaEngine<TMetadata extends Metadata = Metadata> {
97
102
  * Get metadata for a workbook
98
103
  */
99
104
  getWorkbookMetadata(workbookName: string): MetadataType<TMetadata, "workbook"> | undefined;
105
+ /**
106
+ * Add metadata attached to one or more ranges.
107
+ * Range metadata is arbitrary consumer-defined data that follows range
108
+ * copy/paste, autofill, workbook/sheet rename, and serialization flows.
109
+ */
110
+ addRangeMetadata(metadata: RangeMetadataInput<MetadataType<TMetadata, "range">>): string;
111
+ /**
112
+ * Remove a range metadata entry by id.
113
+ */
114
+ removeRangeMetadata(id: string): void;
115
+ /**
116
+ * Get all range metadata entries.
117
+ */
118
+ getAllRangeMetadata(): RangeMetadata<MetadataType<TMetadata, "range">>[];
119
+ /**
120
+ * Get range metadata entries that apply to a specific cell.
121
+ */
122
+ getRangeMetadataForCell(address: CellAddress): RangeMetadata<MetadataType<TMetadata, "range">>[];
123
+ /**
124
+ * Get range metadata entries intersecting with a range.
125
+ */
126
+ getRangeMetadataIntersectingWithRange(range: RangeAddress): RangeMetadata<MetadataType<TMetadata, "range">>[];
127
+ /**
128
+ * Clear range metadata from a range, preserving non-overlapping portions.
129
+ */
130
+ clearRangeMetadata(range: RangeAddress): void;
100
131
  /**
101
132
  * Create a tracked reference to a range
102
133
  * Returns a stable UUID that can be used to retrieve the address later
@@ -486,10 +517,12 @@ export declare class FormulaEngine<TMetadata extends Metadata = Metadata> {
486
517
  tables: Map<string, Map<string, TableDefinition>>;
487
518
  conditionalStyles: ConditionalStyle[];
488
519
  cellStyles: DirectCellStyle[];
520
+ rangeMetadata: RangeMetadata<MetadataType<TMetadata, "range">>[];
489
521
  references: Map<string, import("./types").TrackedReference>;
490
522
  };
491
523
  onUpdate(listener: () => void): () => void;
492
524
  private buildSerializedSnapshot;
525
+ private buildNamedExpressionSnapshot;
493
526
  serializeEngine(): string;
494
527
  resetToSerializedEngine(data: string): void;
495
528
  }
@@ -5,11 +5,13 @@ import type { CellAddress, CopyCellsOptions, RangeAddress } from "../types";
5
5
  import type { WorkbookManager } from "./workbook-manager";
6
6
  import type { EvaluationManager } from "./evaluation-manager";
7
7
  import type { StyleManager } from "./style-manager";
8
+ import type { RangeMetadataManager } from "./range-metadata-manager";
8
9
  export declare class CopyManager {
9
10
  private workbookManager;
10
11
  private evaluationManager;
11
12
  private styleManager;
12
- constructor(workbookManager: WorkbookManager, evaluationManager: EvaluationManager, styleManager: StyleManager);
13
+ private rangeMetadataManager;
14
+ constructor(workbookManager: WorkbookManager, evaluationManager: EvaluationManager, styleManager: StyleManager, rangeMetadataManager: RangeMetadataManager);
13
15
  /**
14
16
  * Normalize the include option to an array of parts to copy
15
17
  */
@@ -60,6 +62,7 @@ export declare class CopyManager {
60
62
  * Copy content from a cell snapshot to a target cell
61
63
  */
62
64
  private copyCellContentFromSnapshot;
65
+ private copyCellMetadataFromSnapshot;
63
66
  /**
64
67
  * Update all formula references when cells are cut (moved)
65
68
  */
@@ -77,6 +80,11 @@ export declare class CopyManager {
77
80
  * Clears existing cell styles in target range first (Excel behavior)
78
81
  */
79
82
  private copyFormatting;
83
+ private cloneMetadataValue;
84
+ private getRangeAddressFromBoundingBox;
85
+ private collectRangeMetadataCopies;
86
+ private applyRangeMetadataCopies;
87
+ private copyRangeMetadata;
80
88
  /**
81
89
  * Get bounding box for a set of cells
82
90
  */
@@ -123,6 +131,8 @@ export declare class CopyManager {
123
131
  * Adjust formula references by a specific row/column offset
124
132
  */
125
133
  private adjustFormulaWithOffset;
134
+ private copyCellMetadata;
135
+ private copyCellRangeMetadata;
126
136
  /**
127
137
  * Copy formatting from one cell to another
128
138
  * Clears existing cell styles at target (Excel behavior) before copying new ones
@@ -80,6 +80,7 @@ export declare class NamedExpressionManager {
80
80
  resetNamedExpressions(namedExpressions: ReturnType<typeof this.getNamedExpressions>): void;
81
81
  toSnapshot(): NamedExpressionManagerSnapshot;
82
82
  restoreFromSnapshot(snapshot: NamedExpressionManagerSnapshot): void;
83
+ clear(): void;
83
84
  /**
84
85
  * When adding a sheet, we need to initialize the new maps
85
86
  */