@univerjs/engine-formula 1.0.0-beta.0 → 1.0.0-beta.2

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 (37) hide show
  1. package/lib/cjs/index.js +267 -151
  2. package/lib/cjs/locale/ca-ES.js +35 -35
  3. package/lib/cjs/locale/fr-FR.js +14 -14
  4. package/lib/cjs/locale/ko-KR.js +17 -17
  5. package/lib/cjs/locale/sk-SK.js +8 -8
  6. package/lib/cjs/locale/vi-VN.js +2 -2
  7. package/lib/es/index.js +270 -153
  8. package/lib/es/locale/ca-ES.js +35 -35
  9. package/lib/es/locale/fr-FR.js +14 -14
  10. package/lib/es/locale/ko-KR.js +17 -17
  11. package/lib/es/locale/sk-SK.js +8 -8
  12. package/lib/es/locale/vi-VN.js +2 -2
  13. package/lib/index.js +270 -153
  14. package/lib/locale/ca-ES.js +35 -35
  15. package/lib/locale/fr-FR.js +14 -14
  16. package/lib/locale/ko-KR.js +17 -17
  17. package/lib/locale/sk-SK.js +8 -8
  18. package/lib/locale/vi-VN.js +2 -2
  19. package/lib/types/basics/common.d.ts +2 -0
  20. package/lib/types/basics/regex.d.ts +4 -4
  21. package/lib/types/controllers/formula-calculation-trigger.controller.d.ts +1 -2
  22. package/lib/types/controllers/formula.controller.d.ts +1 -1
  23. package/lib/types/engine/value-object/array-value-object.d.ts +1 -1
  24. package/lib/types/functions/base-function.d.ts +2 -2
  25. package/lib/types/functions/logical/percentof/index.d.ts +5 -6
  26. package/lib/types/functions/lookup/xlookup/index.d.ts +4 -0
  27. package/lib/types/index.d.ts +0 -1
  28. package/lib/types/models/formula-data.model.d.ts +3 -1
  29. package/lib/types/services/register-other-formula.service.d.ts +3 -3
  30. package/lib/types/services/runtime.service.d.ts +2 -0
  31. package/lib/umd/index.js +4 -4
  32. package/lib/umd/locale/ca-ES.js +1 -1
  33. package/lib/umd/locale/fr-FR.js +2 -2
  34. package/lib/umd/locale/ko-KR.js +3 -3
  35. package/lib/umd/locale/sk-SK.js +1 -1
  36. package/lib/umd/locale/vi-VN.js +1 -1
  37. package/package.json +4 -4
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { AbsoluteRefType, AsyncLock, BooleanNumber, BuildTextUtils, CellValueType, CommandType, DataStreamTreeTokenType, Disposable, DisposableCollection, ICommandService, IConfigService, IUniverInstanceService, Inject, Injector, LRUMap, LifecycleService, LifecycleStages, LocaleService, LocaleType, MAX_COLUMN_COUNT, MAX_ROW_COUNT, ObjectMatrix, Optional, Plugin, RANGE_TYPE, RTree, Rectangle, RichTextBuilder, Styles, Tools, UniverInstanceType, cellToRange, columnLabelToNumber, createIdentifier, generateRandomId, getNumfmtParseValueFilter, hashAlgorithm, isFormulaId, isFormulaString, isNodeEnv, isNullCell, isRealNum, isTextFormat, isValidRange, merge, moveRangeByOffset, numfmt, regexp, requestImmediateMacroTask, sortRules, toDisposable, touchDependencies } from "@univerjs/core";
1
+ import { AbsoluteRefType, AsyncLock, BooleanNumber, BuildTextUtils, CellValueType, CommandType, DataStreamTreeTokenType, Disposable, DisposableCollection, ICommandService, IConfigService, IUniverInstanceService, Inject, Injector, LRUMap, LifecycleService, LifecycleStages, LocaleService, LocaleType, MAX_COLUMN_COUNT, MAX_ROW_COUNT, ObjectMatrix, Optional, Plugin, RANGE_TYPE, RTree, Rectangle, RichTextBuilder, Styles, Tools, UniverInstanceType, cellToRange, columnLabelToNumber, createBaseFormulaTableNameMap, createIdentifier, generateRandomId, getBaseFormulaTableName, getNumfmtParseValueFilter, hashAlgorithm, isFormulaId, isFormulaString, isNodeEnv, isNullCell, isRealNum, isTextFormat, isValidRange, merge, moveRangeByOffset, numfmt, regexp, requestImmediateMacroTask, sortRules, toDisposable, touchDependencies } from "@univerjs/core";
2
2
  import IntervalTree from "@flatten-js/interval-tree";
3
- import { BehaviorSubject, Observable, Subject, bufferWhen, combineLatest, distinctUntilChanged, filter, map, shareReplay, skip, take } from "rxjs";
3
+ import { BehaviorSubject, Observable, Subject, combineLatest, distinctUntilChanged, filter, map, shareReplay, take } from "rxjs";
4
4
  import Decimal from "decimal.js";
5
5
  import { DataSyncPrimaryController } from "@univerjs/rpc";
6
6
 
@@ -1447,7 +1447,8 @@ const TABLE_NAME_REGEX = "((?![~!@#$%^&*()+<>?:,./;’,。、‘:“《》
1447
1447
  const TABLE_TITLE_REGEX = "\\[#.+\\]\\s*?,\\s*?";
1448
1448
  const TABLE_CONTENT_REGEX = "\\[[^#]*#?\\]";
1449
1449
  const TABLE_MULTIPLE_COLUMN_REGEX = `${TABLE_CONTENT_REGEX}${RANGE_SYMBOL}${TABLE_CONTENT_REGEX}`;
1450
- const TABLE_UNIT_QUALIFIER_REGEX = `(?:(?:${UNIT_NAME_REGEX}|'(?:[^']|'')+'|[^\\s!\\[\\]]+)!)?(?:${UNIT_NAME_REGEX})?`;
1450
+ const TABLE_BRACKETED_UNIT_QUALIFIER_REGEX = "\\[(?:[^\\]]|\\]\\])+\\]";
1451
+ const TABLE_UNIT_QUALIFIER_REGEX = `(?:(?:${TABLE_BRACKETED_UNIT_QUALIFIER_REGEX}|'(?:[^']|'')+'|[^\\s!\\[\\]]+)!)?(?:${TABLE_BRACKETED_UNIT_QUALIFIER_REGEX})?`;
1451
1452
  const REFERENCE_TABLE_ALL_COLUMN_REGEX = `^${TABLE_UNIT_QUALIFIER_REGEX}${TABLE_NAME_REGEX}$`;
1452
1453
  const REFERENCE_TABLE_SINGLE_COLUMN_REGEX = `^${TABLE_UNIT_QUALIFIER_REGEX}${TABLE_NAME_REGEX}(${TABLE_CONTENT_REGEX}|\\[${TABLE_TITLE_REGEX}${TABLE_CONTENT_REGEX}\\])+$`;
1453
1454
  const REFERENCE_TABLE_MULTIPLE_COLUMN_REGEX = `^${TABLE_UNIT_QUALIFIER_REGEX}${TABLE_NAME_REGEX}(\\[${TABLE_MULTIPLE_COLUMN_REGEX}\\])?$|^${TABLE_UNIT_QUALIFIER_REGEX}${TABLE_NAME_REGEX}(\\[${TABLE_TITLE_REGEX}${TABLE_MULTIPLE_COLUMN_REGEX}\\])?$`;
@@ -1904,8 +1905,13 @@ function splitTableStructuredRef(ref) {
1904
1905
  }
1905
1906
  quoteOpen = !quoteOpen;
1906
1907
  } else if (!quoteOpen && char === "[") bracketDepth++;
1907
- else if (!quoteOpen && char === "]") bracketDepth--;
1908
- else if (!quoteOpen && bracketDepth === 0 && char === "!") {
1908
+ else if (!quoteOpen && char === "]") {
1909
+ if (bracketDepth > 0 && tableRef[i + 1] === "]") {
1910
+ i++;
1911
+ continue;
1912
+ }
1913
+ bracketDepth--;
1914
+ } else if (!quoteOpen && bracketDepth === 0 && char === "!") {
1909
1915
  qualifierEnd = i;
1910
1916
  break;
1911
1917
  }
@@ -1913,8 +1919,10 @@ function splitTableStructuredRef(ref) {
1913
1919
  if (qualifierEnd >= 0) {
1914
1920
  unitQualifier = tableRef.slice(0, qualifierEnd).trim();
1915
1921
  tableRef = tableRef.slice(qualifierEnd + 1);
1916
- if (unitQualifier.startsWith("'") && unitQualifier.endsWith("'")) unitQualifier = unitQualifier.slice(1, -1);
1917
- if (unitQualifier.startsWith("[") && unitQualifier.endsWith("]")) unitQualifier = unitQualifier.slice(1, -1);
1922
+ const isQuotedQualifier = unitQualifier.startsWith("'") && unitQualifier.endsWith("'");
1923
+ const isBracketedQualifier = !isQuotedQualifier && unitQualifier.startsWith("[") && unitQualifier.endsWith("]");
1924
+ if (isQuotedQualifier) unitQualifier = unitQualifier.slice(1, -1);
1925
+ else if (isBracketedQualifier) unitQualifier = unitQualifier.slice(1, -1).replaceAll("]]", "]");
1918
1926
  unitQualifier = unquoteSheetName(unitQualifier);
1919
1927
  } else if (tableRef.startsWith("[")) {
1920
1928
  const legacyQualifierEnd = tableRef.indexOf("]");
@@ -4992,12 +5000,14 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
4992
5000
  super();
4993
5001
  this._univerInstanceService = _univerInstanceService;
4994
5002
  this._lexerTreeBuilder = _lexerTreeBuilder;
5003
+ _defineProperty(this, "_formulaIdMapData", {});
4995
5004
  _defineProperty(this, "_arrayFormulaRange", {});
4996
5005
  _defineProperty(this, "_arrayFormulaCellData", {});
4997
5006
  _defineProperty(this, "_unitImageFormulaData", {});
4998
5007
  }
4999
5008
  dispose() {
5000
5009
  super.dispose();
5010
+ this._formulaIdMapData = {};
5001
5011
  this._arrayFormulaRange = {};
5002
5012
  this._arrayFormulaCellData = {};
5003
5013
  this._unitImageFormulaData = {};
@@ -5069,7 +5079,7 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
5069
5079
  const cellMatrix = worksheet.getCellMatrix();
5070
5080
  const sheetId = worksheet.getSheetId();
5071
5081
  this._initSheetArrayFormulaData(unitId, sheetId, cellMatrix);
5072
- initSheetFormulaData(formulaData, unitId, sheetId, cellMatrix);
5082
+ this.initSheetFormulaData(formulaData, unitId, sheetId, cellMatrix);
5073
5083
  }
5074
5084
  }
5075
5085
  const allBases = this._univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_BASE);
@@ -5079,9 +5089,11 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
5079
5089
  const unitId = base.getUnitId();
5080
5090
  formulaData[unitId] = {};
5081
5091
  const tables = Object.values(snapshot.tables);
5092
+ const formulaTableNames = createBaseFormulaTableNameMap(snapshot);
5082
5093
  for (let j = 0; j < tables.length; j++) {
5083
5094
  const table = tables[j];
5084
5095
  const tableFormulaData = {};
5096
+ const normalizedFormulaByFieldId = /* @__PURE__ */ new Map();
5085
5097
  const recordOrder = table.recordOrder;
5086
5098
  if (!recordOrder) {
5087
5099
  formulaData[unitId][table.id] = tableFormulaData;
@@ -5097,9 +5109,14 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
5097
5109
  if (!field || field.type !== "formula") continue;
5098
5110
  const formula = String(((_field$config = field.config) === null || _field$config === void 0 ? void 0 : _field$config.formula) ?? "").trim();
5099
5111
  if (!formula) continue;
5112
+ let normalizedFormula = normalizedFormulaByFieldId.get(field.id);
5113
+ if (normalizedFormula == null) {
5114
+ normalizedFormula = normalizeBaseFormulaForEngine(formula, table, snapshot, formulaTableNames);
5115
+ normalizedFormulaByFieldId.set(field.id, normalizedFormula);
5116
+ }
5100
5117
  tableFormulaData[row] ??= {};
5101
5118
  tableFormulaData[row][col] = {
5102
- f: normalizeBaseFormulaForEngine(formula, table, snapshot),
5119
+ f: normalizedFormula,
5103
5120
  si: field.id
5104
5121
  };
5105
5122
  }
@@ -5109,6 +5126,22 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
5109
5126
  }
5110
5127
  return formulaData;
5111
5128
  }
5129
+ initSheetFormulaData(formulaData, unitId, sheetId, cellMatrix) {
5130
+ const result = buildSheetFormulaData(formulaData, unitId, sheetId, cellMatrix);
5131
+ if (!this._formulaIdMapData[unitId]) this._formulaIdMapData[unitId] = {};
5132
+ this._formulaIdMapData[unitId][sheetId] = result.formulaIdMap;
5133
+ return result.formulaData;
5134
+ }
5135
+ clearFormulaIdMap(unitId, sheetId) {
5136
+ if (sheetId == null) {
5137
+ delete this._formulaIdMapData[unitId];
5138
+ return;
5139
+ }
5140
+ const unitFormulaIdMap = this._formulaIdMapData[unitId];
5141
+ if (!unitFormulaIdMap) return;
5142
+ delete unitFormulaIdMap[sheetId];
5143
+ if (Object.keys(unitFormulaIdMap).length === 0) delete this._formulaIdMapData[unitId];
5144
+ }
5112
5145
  getSheetFormulaData(unitId, sheetId) {
5113
5146
  const formulaData = {};
5114
5147
  const workbook = this._univerInstanceService.getUnit(unitId);
@@ -5118,7 +5151,7 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
5118
5151
  if (worksheet == null) return {};
5119
5152
  const cellMatrix = worksheet.getCellMatrix();
5120
5153
  this._initSheetArrayFormulaData(unitId, sheetId, cellMatrix);
5121
- initSheetFormulaData(formulaData, unitId, sheetId, cellMatrix);
5154
+ this.initSheetFormulaData(formulaData, unitId, sheetId, cellMatrix);
5122
5155
  return formulaData[unitId][sheetId];
5123
5156
  }
5124
5157
  getArrayFormulaRange() {
@@ -5227,6 +5260,7 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
5227
5260
  };
5228
5261
  const baseData = {};
5229
5262
  const tableNameMap = {};
5263
+ const formulaTableNames = createBaseFormulaTableNameMap(snapshot);
5230
5264
  for (const table of Object.values(snapshot.tables)) {
5231
5265
  var _table$recordOrder;
5232
5266
  baseData[table.id] = {
@@ -5236,7 +5270,7 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
5236
5270
  rowData: {},
5237
5271
  columnData: {}
5238
5272
  };
5239
- tableNameMap[table.name] = table.id;
5273
+ addEngineBaseTableNameMappings(tableNameMap, table, formulaTableNames);
5240
5274
  }
5241
5275
  allUnitData[unitId] = baseData;
5242
5276
  unitStylesData[unitId] = new Styles();
@@ -5306,8 +5340,7 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
5306
5340
  c
5307
5341
  };
5308
5342
  });
5309
- const formulaData = {};
5310
- initSheetFormulaData(formulaData, unitId, sheetId, sharedFormulaCellMatrix);
5343
+ const formulaData = buildSheetFormulaData({}, unitId, sheetId, sharedFormulaCellMatrix).formulaData;
5311
5344
  const deleteFormulaIdMap = /* @__PURE__ */ new Map();
5312
5345
  const sheetFormulaDataMatrix = new ObjectMatrix(((_formulaData$unitId = formulaData[unitId]) === null || _formulaData$unitId === void 0 ? void 0 : _formulaData$unitId[sheetId]) ?? {});
5313
5346
  cellMatrix.forValue((r, c, cell) => {
@@ -5428,16 +5461,18 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
5428
5461
  const { f, si } = cell;
5429
5462
  if (isFormulaString(f)) return f;
5430
5463
  if (isFormulaId(si)) {
5431
- let formulaString = null;
5432
- cellMatrix.forValue((r, c, cell) => {
5433
- if (cell == null) return true;
5434
- const { f, si: currentId } = cell;
5435
- if (isFormulaString(f) && si === currentId) {
5436
- formulaString = this._lexerTreeBuilder.moveFormulaRefOffset(f, column - c, row - r);
5437
- return false;
5438
- }
5439
- });
5440
- return formulaString;
5464
+ var _this$_formulaIdMapDa;
5465
+ let formulaIdMap = (_this$_formulaIdMapDa = this._formulaIdMapData[unitId]) === null || _this$_formulaIdMapDa === void 0 ? void 0 : _this$_formulaIdMapDa[sheetId];
5466
+ let formulaInfo = formulaIdMap === null || formulaIdMap === void 0 ? void 0 : formulaIdMap[String(si)];
5467
+ const masterCell = formulaInfo == null ? null : cellMatrix.getValue(formulaInfo.r, formulaInfo.c);
5468
+ if (formulaInfo == null || (masterCell === null || masterCell === void 0 ? void 0 : masterCell.si) !== si || (masterCell === null || masterCell === void 0 ? void 0 : masterCell.f) !== formulaInfo.f) {
5469
+ var _this$_formulaIdMapDa2;
5470
+ this.initSheetFormulaData({}, unitId, sheetId, cellMatrix);
5471
+ formulaIdMap = (_this$_formulaIdMapDa2 = this._formulaIdMapData[unitId]) === null || _this$_formulaIdMapDa2 === void 0 ? void 0 : _this$_formulaIdMapDa2[sheetId];
5472
+ formulaInfo = formulaIdMap === null || formulaIdMap === void 0 ? void 0 : formulaIdMap[String(si)];
5473
+ }
5474
+ if (!formulaInfo) return null;
5475
+ return this._lexerTreeBuilder.moveFormulaRefOffset(formulaInfo.f, column - formulaInfo.c, row - formulaInfo.r);
5441
5476
  }
5442
5477
  return null;
5443
5478
  }
@@ -5532,10 +5567,10 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
5532
5567
  }
5533
5568
  };
5534
5569
  FormulaDataModel = __decorate([__decorateParam(0, IUniverInstanceService), __decorateParam(1, Inject(LexerTreeBuilder))], FormulaDataModel);
5535
- function initSheetFormulaData(formulaData, unitId, sheetId, cellMatrix) {
5570
+ function buildSheetFormulaData(formulaData, unitId, sheetId, cellMatrix) {
5536
5571
  if (!formulaData[unitId]) formulaData[unitId] = {};
5537
5572
  if (!formulaData[unitId][sheetId]) formulaData[unitId][sheetId] = {};
5538
- const formulaIdMap = /* @__PURE__ */ new Map();
5573
+ const formulaIdMap = {};
5539
5574
  const sheetFormulaDataMatrix = new ObjectMatrix(formulaData[unitId][sheetId]);
5540
5575
  cellMatrix.forValue((r, c, cell) => {
5541
5576
  const formulaString = (cell === null || cell === void 0 ? void 0 : cell.f) || "";
@@ -5547,11 +5582,11 @@ function initSheetFormulaData(formulaData, unitId, sheetId, cellMatrix) {
5547
5582
  f: formulaString,
5548
5583
  si: formulaId
5549
5584
  });
5550
- formulaIdMap.set(formulaId, {
5585
+ formulaIdMap[formulaId] = {
5551
5586
  f: formulaString,
5552
5587
  r,
5553
5588
  c
5554
- });
5589
+ };
5555
5590
  } else if (checkFormulaString && !checkFormulaId) sheetFormulaDataMatrix.setValue(r, c, { f: formulaString });
5556
5591
  else if (!checkFormulaString && checkFormulaId) sheetFormulaDataMatrix.setValue(r, c, {
5557
5592
  f: "",
@@ -5562,7 +5597,7 @@ function initSheetFormulaData(formulaData, unitId, sheetId, cellMatrix) {
5562
5597
  const formulaString = (cell === null || cell === void 0 ? void 0 : cell.f) || "";
5563
5598
  const formulaId = (cell === null || cell === void 0 ? void 0 : cell.si) || "";
5564
5599
  if (isFormulaId(formulaId) && !isFormulaString(formulaString)) {
5565
- const formulaInfo = formulaIdMap.get(formulaId);
5600
+ const formulaInfo = formulaIdMap[formulaId];
5566
5601
  if (formulaInfo) {
5567
5602
  const x = c - formulaInfo.c;
5568
5603
  const y = r - formulaInfo.r;
@@ -5577,31 +5612,53 @@ function initSheetFormulaData(formulaData, unitId, sheetId, cellMatrix) {
5577
5612
  }
5578
5613
  });
5579
5614
  const newSheetFormulaData = sheetFormulaDataMatrix.getMatrix();
5580
- return { [unitId]: { [sheetId]: newSheetFormulaData } };
5615
+ return {
5616
+ formulaData: { [unitId]: { [sheetId]: newSheetFormulaData } },
5617
+ formulaIdMap
5618
+ };
5581
5619
  }
5582
5620
  const BASE_LEGACY_FIELD_REF_PATTERN = /\{([^}]+)\}/g;
5583
- const BASE_TABLE_FIELD_REF_PATTERN = /\b([A-Z_]\w*)\[([^\]]+)\]/gi;
5584
- const BASE_BRACKET_FIELD_REF_PATTERN = /(^|[^A-Za-z0-9_\]\[])\[([^\]]+)\]/g;
5621
+ const BASE_TABLE_SCOPED_FIELD_REF_PATTERN = /\b([A-Z_][\w.]*)\[\[\s*#(This Row|Data)\s*\],\s*\[([^\]]+)\]\]/gi;
5622
+ const BASE_TABLE_CURRENT_ROW_FIELD_REF_PATTERN = /\b([A-Z_][\w.]*)\[@\[([^\]]+)\]\]/gi;
5623
+ const BASE_TABLE_FIELD_REF_PATTERN = /\b([A-Z_][\w.]*)\[([^\[\]#]+)\]/gi;
5624
+ const BASE_SCOPED_FIELD_REF_PATTERN = /(^|[^\w\[])\[\[\s*#(This Row|Data)\s*\],\s*\[([^\]]+)\]\]/gi;
5625
+ const BASE_CURRENT_ROW_FIELD_REF_PATTERN = /(^|[^\w\[])\[@\[([^\]]+)\]\](?!\])/g;
5626
+ const BASE_BRACKET_FIELD_REF_PATTERN = /(^|[^\w\[])\[@?([^\[\]#]+)\](?!\])/g;
5585
5627
  const BASE_EXTERNAL_A1_REF_PATTERN = /(?:'\[[^\]]+\](?:[^']|'')+'|\[[^\]]+\][^\s'!]+)!\$?[A-Z]{1,3}\$?\d+(?::\$?[A-Z]{1,3}\$?\d+)?/gi;
5586
5628
  const BASE_EXTERNAL_STRUCTURED_REFERENCE_PREFIX = /(?:'((?:[^']|'')+)'|\[[^\]]+\]|[A-Za-z0-9_.-]+)![^\s!\[\]]+\[/g;
5587
- function normalizeBaseFormulaForEngine(formula, currentTable, snapshot) {
5629
+ function normalizeBaseFormulaForEngine(formula, currentTable, snapshot, formulaTableNames) {
5588
5630
  const refs = [];
5589
5631
  const hold = (ref) => {
5590
5632
  return `__BASE_FORMULA_REF_${refs.push(ref) - 1}__`;
5591
5633
  };
5592
- return protectBaseExternalReferences(formula, hold).replace(BASE_LEGACY_FIELD_REF_PATTERN, (_match, fieldName) => hold(createEngineThisRowRef(currentTable, fieldName, snapshot))).replace(BASE_TABLE_FIELD_REF_PATTERN, (_match, sourceTableName, fieldName) => {
5593
- const targetTable = resolveBaseFormulaTable(sourceTableName, currentTable, snapshot);
5594
- return targetTable ? hold(createEngineColumnRef(targetTable, fieldName, snapshot)) : `${sourceTableName}[${fieldName}]`;
5595
- }).replace(BASE_BRACKET_FIELD_REF_PATTERN, (_match, prefix, fieldName) => `${prefix}${hold(createEngineThisRowRef(currentTable, fieldName, snapshot))}`).replace(/__BASE_FORMULA_REF_(\d+)__/g, (_match, index) => refs[Number(index)] ?? "");
5634
+ return protectBaseFormulaParts(formula, hold).replace(BASE_LEGACY_FIELD_REF_PATTERN, (_match, fieldName) => hold(createEngineThisRowRef(currentTable, fieldName, formulaTableNames))).replace(BASE_TABLE_SCOPED_FIELD_REF_PATTERN, (_match, sourceTableName, scope, fieldName) => {
5635
+ const targetTable = resolveBaseFormulaTable(sourceTableName, currentTable, snapshot, formulaTableNames);
5636
+ if (!targetTable) return `${sourceTableName}[[#${scope}],[${fieldName}]]`;
5637
+ return hold(scope.toLowerCase() === "data" ? createEngineColumnRef(targetTable, fieldName, formulaTableNames) : createEngineThisRowRef(targetTable, fieldName, formulaTableNames));
5638
+ }).replace(BASE_TABLE_CURRENT_ROW_FIELD_REF_PATTERN, (_match, sourceTableName, fieldName) => {
5639
+ const targetTable = resolveBaseFormulaTable(sourceTableName, currentTable, snapshot, formulaTableNames);
5640
+ return targetTable ? hold(createEngineThisRowRef(targetTable, fieldName, formulaTableNames)) : `${sourceTableName}[@[${fieldName}]]`;
5641
+ }).replace(BASE_SCOPED_FIELD_REF_PATTERN, (_match, prefix, scope, fieldName) => `${prefix}${hold(scope.toLowerCase() === "data" ? createEngineColumnRef(currentTable, fieldName, formulaTableNames) : createEngineThisRowRef(currentTable, fieldName, formulaTableNames))}`).replace(BASE_CURRENT_ROW_FIELD_REF_PATTERN, (_match, prefix, fieldName) => `${prefix}${hold(createEngineThisRowRef(currentTable, fieldName, formulaTableNames))}`).replace(BASE_TABLE_FIELD_REF_PATTERN, (_match, sourceTableName, fieldName) => {
5642
+ const targetTable = resolveBaseFormulaTable(sourceTableName, currentTable, snapshot, formulaTableNames);
5643
+ if (targetTable) return hold(createEngineColumnRef(targetTable, fieldName, formulaTableNames));
5644
+ return `${sourceTableName}[${fieldName}]`;
5645
+ }).replace(BASE_BRACKET_FIELD_REF_PATTERN, (_match, prefix, fieldName) => `${prefix}${hold(createEngineThisRowRef(currentTable, fieldName, formulaTableNames))}`).replace(/__BASE_FORMULA_REF_(\d+)__/g, (_match, index) => refs[Number(index)] ?? "");
5596
5646
  }
5597
5647
  function protectBaseExternalReferences(formula, replace) {
5598
5648
  return protectBaseExternalStructuredReferences(formula.replace(BASE_EXTERNAL_A1_REF_PATTERN, (reference, offset) => isInsideBaseFormulaString(formula, offset) ? reference : replace(reference)), replace);
5599
5649
  }
5650
+ function protectBaseFormulaParts(formula, replace) {
5651
+ return protectBaseFormulaStrings(protectBaseExternalReferences(formula, replace), replace);
5652
+ }
5653
+ function protectBaseFormulaStrings(formula, replace) {
5654
+ return formula.replace(/"(?:""|[^"])*"/g, replace);
5655
+ }
5600
5656
  function protectBaseExternalStructuredReferences(formula, replace) {
5601
5657
  const spans = [];
5602
5658
  BASE_EXTERNAL_STRUCTURED_REFERENCE_PREFIX.lastIndex = 0;
5603
- let match;
5604
- while ((match = BASE_EXTERNAL_STRUCTURED_REFERENCE_PREFIX.exec(formula)) != null) {
5659
+ while (true) {
5660
+ const match = BASE_EXTERNAL_STRUCTURED_REFERENCE_PREFIX.exec(formula);
5661
+ if (match == null) break;
5605
5662
  if (isInsideBaseFormulaString(formula, match.index)) continue;
5606
5663
  const openBracket = BASE_EXTERNAL_STRUCTURED_REFERENCE_PREFIX.lastIndex - 1;
5607
5664
  let depth = 0;
@@ -5641,20 +5698,20 @@ function isInsideBaseFormulaString(formula, position) {
5641
5698
  }
5642
5699
  return inString;
5643
5700
  }
5644
- function createEngineThisRowRef(table, fieldName, snapshot) {
5645
- return `${getEngineBaseTableName(table, snapshot)}[[#This Row],[${fieldName}]]`;
5701
+ function createEngineThisRowRef(table, fieldName, formulaTableNames) {
5702
+ return `${formulaTableNames.get(table.id) ?? getBaseFormulaTableName(table, { tables: { [table.id]: table } })}[[#This Row],[${fieldName}]]`;
5646
5703
  }
5647
- function createEngineColumnRef(table, fieldName, snapshot) {
5648
- return `${getEngineBaseTableName(table, snapshot)}[[#Data],[${fieldName}]]`;
5704
+ function createEngineColumnRef(table, fieldName, formulaTableNames) {
5705
+ return `${formulaTableNames.get(table.id) ?? getBaseFormulaTableName(table, { tables: { [table.id]: table } })}[[#Data],[${fieldName}]]`;
5649
5706
  }
5650
- function getEngineBaseTableName(table, snapshot) {
5651
- const tables = Object.values(snapshot.tables);
5652
- let sameNameCount = 0;
5653
- for (let i = 0; i < tables.length; i++) if (tables[i].name === table.name) {
5654
- sameNameCount++;
5655
- if (sameNameCount > 1) break;
5656
- }
5657
- return sameNameCount === 1 ? table.name : table.id;
5707
+ function addEngineBaseTableNameMappings(tableNameMap, table, formulaTableNames) {
5708
+ tableNameMap[formulaTableNames.get(table.id) ?? table.name] = table.id;
5709
+ }
5710
+ function createStableExcelTableName(tableId) {
5711
+ return `_T_${Array.from(tableId, (character) => {
5712
+ var _character$codePointA;
5713
+ return /[A-Za-z0-9]/.test(character) ? character : `_x${((_character$codePointA = character.codePointAt(0)) === null || _character$codePointA === void 0 ? void 0 : _character$codePointA.toString(16)) ?? "0"}_`;
5714
+ }).join("")}`;
5658
5715
  }
5659
5716
  function buildBaseRuntimeCellData(table) {
5660
5717
  const cellData = { ...table.cellData };
@@ -5742,11 +5799,13 @@ function isArrayConstantFormula(formula) {
5742
5799
  function isBaseCellData(value) {
5743
5800
  return !!value && typeof value === "object" && (Object.prototype.hasOwnProperty.call(value, "v") || Object.prototype.hasOwnProperty.call(value, "t") || Object.prototype.hasOwnProperty.call(value, "p") || Object.prototype.hasOwnProperty.call(value, "f") || Object.prototype.hasOwnProperty.call(value, "si"));
5744
5801
  }
5745
- function resolveBaseFormulaTable(tableName, currentTable, snapshot) {
5746
- if (!tableName || tableName === "table" || tableName === currentTable.id || tableName === currentTable.name) return currentTable;
5747
- const byId = snapshot.tables[tableName];
5748
- if (byId) return byId;
5749
- const matches = Object.values(snapshot.tables).filter((table) => table.name === tableName);
5802
+ function resolveBaseFormulaTable(tableName, currentTable, snapshot, formulaTableNames) {
5803
+ if (!tableName) return currentTable;
5804
+ const normalizedName = tableName.toLowerCase();
5805
+ const matches = Object.values(snapshot.tables).filter((table) => {
5806
+ var _formulaTableNames$ge;
5807
+ return table.id.toLowerCase() === normalizedName || table.name.toLowerCase() === normalizedName || ((_formulaTableNames$ge = formulaTableNames.get(table.id)) === null || _formulaTableNames$ge === void 0 ? void 0 : _formulaTableNames$ge.toLowerCase()) === normalizedName || createStableExcelTableName(table.id).toLowerCase() === normalizedName;
5808
+ });
5750
5809
  return matches.length === 1 ? matches[0] : void 0;
5751
5810
  }
5752
5811
 
@@ -8130,11 +8189,16 @@ var ArrayValueObject = class ArrayValueObject extends BaseValueObject {
8130
8189
  * the sequential matching approach is only used for special matches in XLOOKUP and XMATCH.
8131
8190
  * For example, when match_mode is set to 1 and -1 for an exact match. If not found, it returns the next smaller item.
8132
8191
  */
8133
- orderSearch(valueObject, searchType = 1, isDesc = false, isFuzzyMatching = false) {
8192
+ orderSearch(valueObject, searchType = 1, isDesc = false, isFuzzyMatching = false, keepFirstNearest = false) {
8134
8193
  let result;
8135
8194
  let maxOrMin;
8136
8195
  let resultPosition;
8137
8196
  let maxOrMinPosition;
8197
+ const _isNearer = (itemValue, currentValue) => {
8198
+ const distance = itemValue.minus(valueObject).abs();
8199
+ const currentDistance = currentValue.minus(valueObject).abs();
8200
+ return keepFirstNearest ? distance.isLessThan(currentDistance).getValue() === true : distance.isLessThanOrEqual(currentDistance).getValue() === true;
8201
+ };
8138
8202
  const _handleMatch = (itemValue, row, column) => {
8139
8203
  if (itemValue == null || itemValue.isNull()) return true;
8140
8204
  let matchObject;
@@ -8151,7 +8215,7 @@ var ArrayValueObject = class ArrayValueObject extends BaseValueObject {
8151
8215
  }
8152
8216
  if (searchType === 2) {
8153
8217
  if (itemValue.isGreaterThan(valueObject).getValue() === true) {
8154
- if (maxOrMin == null || itemValue.minus(valueObject).abs().isLessThanOrEqual(maxOrMin.minus(valueObject).abs()).getValue() === true) {
8218
+ if (maxOrMin == null || _isNearer(itemValue, maxOrMin)) {
8155
8219
  maxOrMin = itemValue;
8156
8220
  maxOrMinPosition = {
8157
8221
  row,
@@ -8161,7 +8225,7 @@ var ArrayValueObject = class ArrayValueObject extends BaseValueObject {
8161
8225
  }
8162
8226
  } else if (searchType === 1) {
8163
8227
  if (itemValue.isLessThan(valueObject).getValue() === true) {
8164
- if (maxOrMin == null || itemValue.minus(valueObject).abs().isLessThanOrEqual(maxOrMin.minus(valueObject).abs()).getValue() === true) {
8228
+ if (maxOrMin == null || _isNearer(itemValue, maxOrMin)) {
8165
8229
  maxOrMin = itemValue;
8166
8230
  maxOrMinPosition = {
8167
8231
  row,
@@ -8664,11 +8728,12 @@ var ArrayValueObject = class ArrayValueObject extends BaseValueObject {
8664
8728
  const sheetId = this.getSheetId();
8665
8729
  const startRow = this.getCurrentRow();
8666
8730
  const startColumn = this.getCurrentColumn();
8731
+ const isWildcardComparison = batchOperatorType === 5 && valueObject.isString() && isWildcard(String(valueObject.getValue()));
8667
8732
  /**
8668
8733
  * If comparison operations are conducted for a single numerical value,
8669
8734
  * then retrieve the judgment from the inverted index. This enhances performance.
8670
8735
  */
8671
- if (batchOperatorType === 5 && this._useInvertedIndexCache) {
8736
+ if (batchOperatorType === 5 && this._useInvertedIndexCache && !isWildcardComparison) {
8672
8737
  const { rowsInCache, rowsNotInCache } = CELL_INVERTED_INDEX_CACHE.canUseCache(unitId, sheetId, column + startColumn, startRow, startRow + rowCount - 1);
8673
8738
  if (rowsInCache.length > 0) {
8674
8739
  if (operator === "=" && !(valueObject.isString() && isWildcard(valueObject.getValue()))) {
@@ -9056,6 +9121,7 @@ var BaseReferenceObject = class extends ObjectClassType {
9056
9121
  }
9057
9122
  setForcedSheetId(sheetNameMap) {
9058
9123
  var _sheetNameMap$this$ge;
9124
+ if (!this._forcedSheetName) return;
9059
9125
  this._forcedSheetId = (_sheetNameMap$this$ge = sheetNameMap[this.getUnitId()]) === null || _sheetNameMap$this$ge === void 0 ? void 0 : _sheetNameMap$this$ge[this._forcedSheetName];
9060
9126
  }
9061
9127
  setForcedSheetIdDirect(sheetId) {
@@ -9456,7 +9522,7 @@ var CellReferenceObject = class extends BaseReferenceObject {
9456
9522
  unionBy(referenceObject) {
9457
9523
  if (!referenceObject.isCell()) return ErrorValueObject.create("#REF!");
9458
9524
  const cellReferenceObject = referenceObject;
9459
- const newRangeData = this.unionRange(this.getRangeData(), cellReferenceObject.getRangeData());
9525
+ const newRangeData = this.unionRange(this.getRangePosition(), cellReferenceObject.getRangePosition());
9460
9526
  return this._createRange(newRangeData);
9461
9527
  }
9462
9528
  unionRange(rangeData1, rangeData2) {
@@ -9498,8 +9564,6 @@ var CellReferenceObject = class extends BaseReferenceObject {
9498
9564
  rangeReferenceObject.setArrayFormulaCellData(this.getArrayFormulaCellData());
9499
9565
  rangeReferenceObject.setRuntimeArrayFormulaCellData(this.getRuntimeArrayFormulaCellData());
9500
9566
  rangeReferenceObject.setRuntimeFeatureCellData(this.getRuntimeFeatureCellData());
9501
- const { x, y } = this.getRefOffset();
9502
- rangeReferenceObject.setRefOffset(x, y);
9503
9567
  const forceSheetId = this.getForcedSheetId();
9504
9568
  rangeReferenceObject.setForcedSheetName(this.getForcedSheetName());
9505
9569
  if (forceSheetId != null) rangeReferenceObject.setForcedSheetIdDirect(forceSheetId);
@@ -10255,6 +10319,9 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
10255
10319
  this._functionRefInfoOverrideStack.pop();
10256
10320
  };
10257
10321
  }
10322
+ hasFunctionRefInfoOverride() {
10323
+ return this._functionRefInfoOverrideStack.length > 0;
10324
+ }
10258
10325
  clearFunctionDefinitionPrivacyVar() {
10259
10326
  this._functionDefinitionPrivacyVar.clear();
10260
10327
  }
@@ -10711,7 +10778,7 @@ var PrefixNode = class extends BaseAstNode {
10711
10778
  if (value instanceof ArrayValueObject) return value.get(0, 0) ?? ErrorValueObject.create("#VALUE!");
10712
10779
  if (!value.isReferenceObject()) return value;
10713
10780
  const currentValue = value;
10714
- if (currentValue.isCell()) return ErrorValueObject.create("#VALUE!");
10781
+ if (currentValue.isCell()) return currentValue.getCellByPosition();
10715
10782
  if (this._preserveAtRangeForFormula2LookupArray()) return currentValue;
10716
10783
  const runtimeService = this._runtimeService;
10717
10784
  const currentRow = runtimeService.currentRow || 0;
@@ -10876,6 +10943,7 @@ var FunctionNode = class extends BaseAstNode {
10876
10943
  if (!this._functionExecutor.returnsLegacyArrayAsScalar || !isTopLevel || !result.isArray()) return result;
10877
10944
  const array = result;
10878
10945
  if (array.getRowCount() <= 1 && array.getColumnCount() <= 1) return result;
10946
+ if (this._runtimeService.hasFunctionRefInfoOverride() && (this._runtimeService.currentRowCount > 1 || this._runtimeService.currentColumnCount > 1)) return result;
10879
10947
  return array.getFirstCell();
10880
10948
  }
10881
10949
  /**
@@ -11797,6 +11865,7 @@ var TableReferenceObject = class extends BaseReferenceObject {
11797
11865
  const tableStartRow = range.startRow;
11798
11866
  const tableEndRow = range.endRow;
11799
11867
  const dataStartRow = tableStartRow + (this._tableData.showHeader === false ? 0 : 1);
11868
+ const dataEndRow = tableEndRow - (this._tableData.showFooter === true ? 1 : 0);
11800
11869
  let startRow = -1;
11801
11870
  let endRow = -1;
11802
11871
  switch (type) {
@@ -11806,7 +11875,7 @@ var TableReferenceObject = class extends BaseReferenceObject {
11806
11875
  break;
11807
11876
  case "#Data":
11808
11877
  startRow = dataStartRow;
11809
- endRow = tableEndRow;
11878
+ endRow = dataEndRow;
11810
11879
  break;
11811
11880
  case "#Headers":
11812
11881
  if (this._tableData.showHeader === false) {
@@ -11822,14 +11891,14 @@ var TableReferenceObject = class extends BaseReferenceObject {
11822
11891
  endRow = tableEndRow;
11823
11892
  break;
11824
11893
  case "#This Row": {
11825
- const r = this._resolveThisRow(tableStartRow, tableEndRow);
11894
+ const r = this._resolveThisRow(dataStartRow, dataEndRow);
11826
11895
  startRow = r;
11827
11896
  endRow = r;
11828
11897
  break;
11829
11898
  }
11830
11899
  default:
11831
11900
  startRow = dataStartRow;
11832
- endRow = tableEndRow;
11901
+ endRow = dataEndRow;
11833
11902
  break;
11834
11903
  }
11835
11904
  this.setRangeData({
@@ -11856,7 +11925,8 @@ var TableReferenceObject = class extends BaseReferenceObject {
11856
11925
  getCellData(row, column) {
11857
11926
  if (this._isCurrentRowForRange) {
11858
11927
  const { startRow, endRow } = this._tableData.range;
11859
- if (row < startRow || row > endRow) return { v: "#N/A" };
11928
+ const lastCurrentRow = endRow - (this._tableData.showFooter === true ? 1 : 0);
11929
+ if (row < startRow || row > lastCurrentRow) return { v: "#N/A" };
11860
11930
  }
11861
11931
  return super.getCellData(row, column);
11862
11932
  }
@@ -12061,9 +12131,9 @@ var TableReferenceObject = class extends BaseReferenceObject {
12061
12131
  return -1;
12062
12132
  }
12063
12133
  /** Resolve #This Row's row number; takes first data row (tableStartRow+1) when no context available */
12064
- _resolveThisRow(tableStartRow, tableEndRow) {
12134
+ _resolveThisRow(dataStartRow, dataEndRow) {
12065
12135
  this._isCurrentRowForRange = true;
12066
- return Math.min(tableStartRow + 1, tableEndRow);
12136
+ return Math.min(dataStartRow, dataEndRow);
12067
12137
  }
12068
12138
  };
12069
12139
 
@@ -15546,13 +15616,13 @@ let RegisterOtherFormulaService = class RegisterOtherFormulaService extends Disp
15546
15616
  this._activeDirtyManagerService = _activeDirtyManagerService;
15547
15617
  this._lifecycleService = _lifecycleService;
15548
15618
  _defineProperty(this, "_formulaCacheMap", /* @__PURE__ */ new Map());
15619
+ _defineProperty(this, "_mutationSyncHandler", void 0);
15549
15620
  _defineProperty(this, "_formulaChangeWithRange$", new Subject());
15550
15621
  _defineProperty(this, "formulaChangeWithRange$", this._formulaChangeWithRange$.asObservable());
15551
15622
  _defineProperty(this, "_formulaResult$", new Subject());
15552
15623
  _defineProperty(this, "formulaResult$", this._formulaResult$.asObservable());
15553
15624
  _defineProperty(this, "_otherFormulaResultApplied$", new Subject());
15554
15625
  _defineProperty(this, "otherFormulaResultApplied$", this._otherFormulaResultApplied$.asObservable());
15555
- _defineProperty(this, "calculateStarted$", new BehaviorSubject(false));
15556
15626
  this._initFormulaRegister();
15557
15627
  this._initFormulaCalculationResultChange();
15558
15628
  }
@@ -15561,7 +15631,6 @@ let RegisterOtherFormulaService = class RegisterOtherFormulaService extends Disp
15561
15631
  this._formulaChangeWithRange$.complete();
15562
15632
  this._formulaResult$.complete();
15563
15633
  this._otherFormulaResultApplied$.complete();
15564
- this.calculateStarted$.complete();
15565
15634
  }
15566
15635
  _ensureCacheMap(unitId, subUnitId) {
15567
15636
  let unitMap = this._formulaCacheMap.get(unitId);
@@ -15587,6 +15656,7 @@ let RegisterOtherFormulaService = class RegisterOtherFormulaService extends Disp
15587
15656
  }
15588
15657
  });
15589
15658
  const handleRegister = (option) => {
15659
+ var _this$_mutationSyncHa;
15590
15660
  const { unitId, subUnitId, formulaText, formulaId, ranges } = option;
15591
15661
  if (!this._ensureCacheMap(unitId, subUnitId).has(formulaId)) return;
15592
15662
  const params = {
@@ -15597,13 +15667,29 @@ let RegisterOtherFormulaService = class RegisterOtherFormulaService extends Disp
15597
15667
  ranges
15598
15668
  } }
15599
15669
  };
15600
- this._commandService.executeCommand(SetOtherFormulaMutation.id, params, { onlyLocal: true }).then(() => {
15670
+ const waitForMutationSync = (_this$_mutationSyncHa = this._mutationSyncHandler) === null || _this$_mutationSyncHa === void 0 ? void 0 : _this$_mutationSyncHa.call(this, unitId);
15671
+ this._commandService.executeCommand(SetOtherFormulaMutation.id, params, { onlyLocal: true }).then(async () => {
15672
+ if (this._disposed) return;
15673
+ await (waitForMutationSync === null || waitForMutationSync === void 0 ? void 0 : waitForMutationSync());
15601
15674
  if (this._disposed) return;
15602
15675
  this._commandService.executeCommand(OtherFormulaMarkDirty.id, { [unitId]: { [subUnitId]: { [formulaId]: true } } }, { onlyLocal: true });
15603
15676
  });
15604
15677
  };
15605
- this.disposeWithMe(this._formulaChangeWithRange$.pipe(bufferWhen(() => this.calculateStarted$.pipe(skip(1), filter((calculateStarted) => calculateStarted)))).subscribe((options) => options.forEach(handleRegister)));
15606
- this.disposeWithMe(this._formulaChangeWithRange$.pipe(filter(() => this.calculateStarted$.getValue())).subscribe(handleRegister));
15678
+ this.disposeWithMe(this._formulaChangeWithRange$.subscribe((option) => {
15679
+ if (this._commandService.hasCommand(SetOtherFormulaMutation.id) && this._commandService.hasCommand(OtherFormulaMarkDirty.id)) {
15680
+ handleRegister(option);
15681
+ return;
15682
+ }
15683
+ this._lifecycleService.onStage(LifecycleStages.Ready).then(() => {
15684
+ if (!this._disposed) handleRegister(option);
15685
+ });
15686
+ }));
15687
+ }
15688
+ setMutationSyncHandler(handler) {
15689
+ this._mutationSyncHandler = handler;
15690
+ return toDisposable(() => {
15691
+ if (this._mutationSyncHandler === handler) this._mutationSyncHandler = void 0;
15692
+ });
15607
15693
  }
15608
15694
  _initFormulaCalculationResultChange() {
15609
15695
  this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
@@ -15675,11 +15761,13 @@ let RegisterOtherFormulaService = class RegisterOtherFormulaService extends Disp
15675
15761
  return Object.fromEntries(Array.from(unitMap.entries(), ([subUnitId, formulas]) => [subUnitId, Object.fromEntries(Array.from(formulas.keys(), (formulaId) => [formulaId, true]))]));
15676
15762
  }
15677
15763
  deleteFormula(unitId, subUnitId, formulaIdList) {
15764
+ var _this$_mutationSyncHa2;
15678
15765
  const params = {
15679
15766
  unitId,
15680
15767
  subUnitId,
15681
15768
  formulaIdList
15682
15769
  };
15770
+ (_this$_mutationSyncHa2 = this._mutationSyncHandler) === null || _this$_mutationSyncHa2 === void 0 || _this$_mutationSyncHa2.call(this, unitId);
15683
15771
  this._commandService.executeCommand(RemoveOtherFormulaMutation.id, params, { onlyLocal: true });
15684
15772
  const cacheMap = this._ensureCacheMap(unitId, subUnitId);
15685
15773
  formulaIdList.forEach((id) => cacheMap.delete(id));
@@ -16568,8 +16656,8 @@ var BaseFunction = class {
16568
16656
  if (isFirst) return this._getOneFirstByRaw(resultArrayValue);
16569
16657
  return this._getOneLastByRaw(resultArrayValue);
16570
16658
  }
16571
- orderSearch(value, searchArray, resultArray, searchType = 1, isDesc = false) {
16572
- const position = searchArray.orderSearch(value, searchType, isDesc);
16659
+ orderSearch(value, searchArray, resultArray, searchType = 1, isDesc = false, keepFirstNearest = false) {
16660
+ const position = searchArray.orderSearch(value, searchType, isDesc, false, keepFirstNearest);
16573
16661
  if (position == null) return ErrorValueObject.create("#N/A");
16574
16662
  const resultValue = resultArray.get(position.row, position.column) || NullValueObject.create();
16575
16663
  if (resultValue.isNull()) return ErrorValueObject.create("#N/A");
@@ -16599,8 +16687,8 @@ var BaseFunction = class {
16599
16687
  if (axis === 0) return resultArray.slice([position.row, position.row + 1]);
16600
16688
  return resultArray.slice(void 0, [position.column, position.column + 1]);
16601
16689
  }
16602
- orderSearchExpand(value, searchArray, resultArray, searchType = 1, isDesc = false, axis = 0) {
16603
- const position = searchArray.orderSearch(value, searchType, isDesc);
16690
+ orderSearchExpand(value, searchArray, resultArray, searchType = 1, isDesc = false, axis = 0, keepFirstNearest = false) {
16691
+ const position = searchArray.orderSearch(value, searchType, isDesc, false, keepFirstNearest);
16604
16692
  if (position == null) return ErrorValueObject.create("#N/A");
16605
16693
  if (axis === 0) return resultArray.slice([position.row, position.row + 1]);
16606
16694
  return resultArray.slice(void 0, [position.column, position.column + 1]);
@@ -30400,20 +30488,72 @@ var Or = class extends BaseFunction {
30400
30488
  }
30401
30489
  };
30402
30490
 
30491
+ //#endregion
30492
+ //#region src/functions/math/sum/index.ts
30493
+ var Sum = class extends BaseFunction {
30494
+ constructor(..._args) {
30495
+ super(..._args);
30496
+ _defineProperty(this, "minParams", 1);
30497
+ _defineProperty(this, "maxParams", 255);
30498
+ }
30499
+ calculate(...variants) {
30500
+ let accumulatorAll = NumberValueObject.create(0);
30501
+ for (let i = 0; i < variants.length; i++) {
30502
+ let variant = variants[i];
30503
+ variant = this._legacyImplicitDerivedArray(variant);
30504
+ if (variant.isString()) variant = variant.convertToNumberObjectValue();
30505
+ if (variant.isError()) return variant;
30506
+ if (variant.isArray()) variant = variant.sum();
30507
+ if (variant.isError()) return variant;
30508
+ accumulatorAll = accumulatorAll.plus(variant);
30509
+ if (accumulatorAll.isError()) return accumulatorAll;
30510
+ }
30511
+ return accumulatorAll;
30512
+ }
30513
+ _legacyImplicitDerivedArray(variant) {
30514
+ if (!variant.isArray()) return variant;
30515
+ const array = variant;
30516
+ if (array.usesInvertedIndexCache() || !array.usesLegacyImplicitForAggregate()) return variant;
30517
+ const startRow = array.getCurrentRow();
30518
+ const startColumn = array.getCurrentColumn();
30519
+ if (startRow < 0 || startColumn < 0) return variant;
30520
+ const rowCount = array.getRowCount();
30521
+ const columnCount = array.getColumnCount();
30522
+ let rowIndex = -1;
30523
+ let columnIndex = -1;
30524
+ if (rowCount === 1) {
30525
+ rowIndex = 0;
30526
+ columnIndex = this.column - startColumn;
30527
+ } else if (columnCount === 1) {
30528
+ rowIndex = this.row - startRow;
30529
+ columnIndex = 0;
30530
+ } else {
30531
+ rowIndex = this.row - startRow;
30532
+ columnIndex = this.column - startColumn;
30533
+ }
30534
+ if (rowIndex < 0 || rowIndex >= rowCount || columnIndex < 0 || columnIndex >= columnCount) return variant;
30535
+ return array.get(rowIndex, columnIndex) || variant;
30536
+ }
30537
+ };
30538
+
30403
30539
  //#endregion
30404
30540
  //#region src/functions/logical/percentof/index.ts
30405
30541
  /**
30406
- * PERCENTOF is an Excel GROUPBY aggregator token. It is evaluated by GROUPBY's
30407
- * AST path, not as a standalone scalar function.
30542
+ * PERCENTOF is logically equivalent to SUM(dataSubset) / SUM(dataAll).
30543
+ * GROUPBY also consumes the function name as an aggregator token through its AST path.
30408
30544
  */
30409
- var Percentof = class extends BaseFunction {
30545
+ var Percentof = class extends Sum {
30410
30546
  constructor(..._args) {
30411
30547
  super(..._args);
30412
- _defineProperty(this, "minParams", 0);
30413
- _defineProperty(this, "maxParams", 0);
30548
+ _defineProperty(this, "minParams", 2);
30549
+ _defineProperty(this, "maxParams", 2);
30414
30550
  }
30415
- calculate(..._variants) {
30416
- return ErrorValueObject.create("#VALUE!");
30551
+ calculate(dataSubset, dataAll) {
30552
+ const subsetTotal = super.calculate(dataSubset);
30553
+ if (subsetTotal.isError()) return subsetTotal;
30554
+ const allTotal = super.calculate(dataAll);
30555
+ if (allTotal.isError()) return allTotal;
30556
+ return subsetTotal.divided(allTotal);
30417
30557
  }
30418
30558
  };
30419
30559
 
@@ -32981,8 +33121,8 @@ var Xlookup = class extends BaseFunction {
32981
33121
  return this.binarySearchExpand(value, searchArray, resultArray, axis, searchType, matchType);
32982
33122
  }
32983
33123
  if (matchModeValue === 2) return this.fuzzySearchExpand(value, searchArray, resultArray, searchModeValue !== -1, axis);
32984
- if (matchModeValue === -1 || matchModeValue === 1) return this.orderSearchExpand(value, searchArray, resultArray, matchModeValue === 1 ? 2 : 1, searchModeValue === -1, axis);
32985
- return this.equalSearchExpand(value, searchArray, resultArray, searchModeValue !== -1, axis);
33124
+ if (matchModeValue === -1 || matchModeValue === 1) return this.orderSearchExpand(value, searchArray, resultArray, matchModeValue === 1 ? 2 : 1, searchModeValue === -1, axis, true);
33125
+ return this._exactSearchExpand(value, searchArray, resultArray, searchModeValue !== -1, axis);
32986
33126
  }
32987
33127
  _handleSingleObject(value, searchArray, resultArray, matchModeValue, searchModeValue) {
32988
33128
  if ((searchModeValue === 2 || searchModeValue === -2) && matchModeValue !== 2) {
@@ -32991,8 +33131,38 @@ var Xlookup = class extends BaseFunction {
32991
33131
  return this.binarySearch(value, searchArray, resultArray, searchType, matchType);
32992
33132
  }
32993
33133
  if (matchModeValue === 2) return this.fuzzySearch(value, searchArray, resultArray, searchModeValue !== -1);
32994
- if (matchModeValue === -1 || matchModeValue === 1) return this.orderSearch(value, searchArray, resultArray, matchModeValue === 1 ? 2 : 1, searchModeValue === -1);
32995
- return this.equalSearch(value, searchArray, resultArray, searchModeValue !== -1);
33134
+ if (matchModeValue === -1 || matchModeValue === 1) return this.orderSearch(value, searchArray, resultArray, matchModeValue === 1 ? 2 : 1, searchModeValue === -1, true);
33135
+ return this._exactSearch(value, searchArray, resultArray, searchModeValue !== -1);
33136
+ }
33137
+ _exactSearch(value, searchArray, resultArray, isFirst) {
33138
+ const position = this._findExactPosition(value, searchArray, isFirst);
33139
+ if (position == null) return ErrorValueObject.create("#N/A");
33140
+ return resultArray.get(position.row, position.column) ?? ErrorValueObject.create("#N/A");
33141
+ }
33142
+ _exactSearchExpand(value, searchArray, resultArray, isFirst, axis) {
33143
+ const position = this._findExactPosition(value, searchArray, isFirst);
33144
+ if (position == null) return ErrorValueObject.create("#N/A");
33145
+ return axis === 0 ? resultArray.slice([position.row, position.row + 1]) ?? ErrorValueObject.create("#N/A") : resultArray.slice(void 0, [position.column, position.column + 1]) ?? ErrorValueObject.create("#N/A");
33146
+ }
33147
+ _findExactPosition(value, searchArray, isFirst) {
33148
+ let position;
33149
+ const find = (candidate, row, column) => {
33150
+ if (candidate != null && this._isExactMatch(candidate, value)) {
33151
+ position = {
33152
+ row,
33153
+ column
33154
+ };
33155
+ return false;
33156
+ }
33157
+ };
33158
+ if (isFirst) searchArray.iterator(find);
33159
+ else searchArray.iteratorReverse(find);
33160
+ return position;
33161
+ }
33162
+ _isExactMatch(candidate, value) {
33163
+ if (candidate.isError() || value.isError()) return candidate.isError() && value.isError() && candidate.getValue() === value.getValue();
33164
+ if (candidate.isNull() !== value.isNull() || candidate.isNumber() !== value.isNumber() || candidate.isString() !== value.isString() || candidate.isBoolean() !== value.isBoolean()) return false;
33165
+ return candidate.isEqual(value).getValue() === true;
32996
33166
  }
32997
33167
  _blankResultAsZero(value) {
32998
33168
  if (value.isNull()) return NumberValueObject.create(0);
@@ -35559,54 +35729,6 @@ var Subtotal = class extends BaseFunction {
35559
35729
  }
35560
35730
  };
35561
35731
 
35562
- //#endregion
35563
- //#region src/functions/math/sum/index.ts
35564
- var Sum = class extends BaseFunction {
35565
- constructor(..._args) {
35566
- super(..._args);
35567
- _defineProperty(this, "minParams", 1);
35568
- _defineProperty(this, "maxParams", 255);
35569
- }
35570
- calculate(...variants) {
35571
- let accumulatorAll = NumberValueObject.create(0);
35572
- for (let i = 0; i < variants.length; i++) {
35573
- let variant = variants[i];
35574
- variant = this._legacyImplicitDerivedArray(variant);
35575
- if (variant.isString()) variant = variant.convertToNumberObjectValue();
35576
- if (variant.isError()) return variant;
35577
- if (variant.isArray()) variant = variant.sum();
35578
- if (variant.isError()) return variant;
35579
- accumulatorAll = accumulatorAll.plus(variant);
35580
- if (accumulatorAll.isError()) return accumulatorAll;
35581
- }
35582
- return accumulatorAll;
35583
- }
35584
- _legacyImplicitDerivedArray(variant) {
35585
- if (!variant.isArray()) return variant;
35586
- const array = variant;
35587
- if (array.usesInvertedIndexCache() || !array.usesLegacyImplicitForAggregate()) return variant;
35588
- const startRow = array.getCurrentRow();
35589
- const startColumn = array.getCurrentColumn();
35590
- if (startRow < 0 || startColumn < 0) return variant;
35591
- const rowCount = array.getRowCount();
35592
- const columnCount = array.getColumnCount();
35593
- let rowIndex = -1;
35594
- let columnIndex = -1;
35595
- if (rowCount === 1) {
35596
- rowIndex = 0;
35597
- columnIndex = this.column - startColumn;
35598
- } else if (columnCount === 1) {
35599
- rowIndex = this.row - startRow;
35600
- columnIndex = 0;
35601
- } else {
35602
- rowIndex = this.row - startRow;
35603
- columnIndex = this.column - startColumn;
35604
- }
35605
- if (rowIndex < 0 || rowIndex >= rowCount || columnIndex < 0 || columnIndex >= columnCount) return variant;
35606
- return array.get(rowIndex, columnIndex) || variant;
35607
- }
35608
- };
35609
-
35610
35732
  //#endregion
35611
35733
  //#region src/functions/math/sumif/index.ts
35612
35734
  var Sumif = class extends BaseFunction {
@@ -42977,7 +43099,7 @@ function getObjectValue(result, isUseStrip = false) {
42977
43099
  //#endregion
42978
43100
  //#region package.json
42979
43101
  var name = "@univerjs/engine-formula";
42980
- var version = "1.0.0-beta.0";
43102
+ var version = "1.0.0-beta.2";
42981
43103
 
42982
43104
  //#endregion
42983
43105
  //#region src/services/global-computing-status.service.ts
@@ -43277,12 +43399,9 @@ function hasSameNestedKey(left, right) {
43277
43399
  * limitations under the License.
43278
43400
  */
43279
43401
  let FormulaCalculationTriggerController = class FormulaCalculationTriggerController extends Disposable {
43280
- constructor(formulaCalculationTriggerService, registerOtherFormulaService, lifecycleService) {
43402
+ constructor(formulaCalculationTriggerService, lifecycleService) {
43281
43403
  super();
43282
- const start = () => {
43283
- formulaCalculationTriggerService.start();
43284
- registerOtherFormulaService.calculateStarted$.next(true);
43285
- };
43404
+ const start = () => formulaCalculationTriggerService.start();
43286
43405
  if (isNodeEnv()) {
43287
43406
  start();
43288
43407
  return;
@@ -43290,11 +43409,7 @@ let FormulaCalculationTriggerController = class FormulaCalculationTriggerControl
43290
43409
  this.disposeWithMe(lifecycleService.lifecycle$.pipe(filter((stage) => stage >= LifecycleStages.Rendered), take(1)).subscribe(start));
43291
43410
  }
43292
43411
  };
43293
- FormulaCalculationTriggerController = __decorate([
43294
- __decorateParam(0, Inject(FormulaCalculationTriggerService)),
43295
- __decorateParam(1, Inject(RegisterOtherFormulaService)),
43296
- __decorateParam(2, Inject(LifecycleService))
43297
- ], FormulaCalculationTriggerController);
43412
+ FormulaCalculationTriggerController = __decorate([__decorateParam(0, Inject(FormulaCalculationTriggerService)), __decorateParam(1, Inject(LifecycleService))], FormulaCalculationTriggerController);
43298
43413
 
43299
43414
  //#endregion
43300
43415
  //#region src/controllers/formula.controller.ts
@@ -43317,10 +43432,12 @@ let FormulaController = class FormulaController extends Disposable {
43317
43432
  _syncOtherFormulaUnits() {
43318
43433
  const dataSyncPrimaryController = this._dataSyncPrimaryController;
43319
43434
  if (!dataSyncPrimaryController) return;
43320
- this.disposeWithMe(this._registerOtherFormulaService.formulaChangeWithRange$.subscribe(({ unitId }) => {
43321
- if (this._syncedOtherFormulaUnits.has(unitId)) return;
43322
- this._syncedOtherFormulaUnits.add(unitId);
43323
- this.disposeWithMe(dataSyncPrimaryController.syncUnitMutations(unitId));
43435
+ this.disposeWithMe(this._registerOtherFormulaService.setMutationSyncHandler((unitId) => {
43436
+ if (!this._syncedOtherFormulaUnits.has(unitId)) {
43437
+ this._syncedOtherFormulaUnits.add(unitId);
43438
+ this.disposeWithMe(dataSyncPrimaryController.syncUnitMutations(unitId));
43439
+ }
43440
+ return () => dataSyncPrimaryController.waitForPendingMutations();
43324
43441
  }));
43325
43442
  }
43326
43443
  _registerCommands() {
@@ -56690,4 +56807,4 @@ _defineProperty(UniverFormulaEnginePlugin, "version", version);
56690
56807
  UniverFormulaEnginePlugin = __decorate([__decorateParam(1, Inject(Injector)), __decorateParam(2, IConfigService)], UniverFormulaEnginePlugin);
56691
56808
 
56692
56809
  //#endregion
56693
- export { ALL_IMPLEMENTED_FUNCTIONS, ALL_IMPLEMENTED_FUNCTIONS_SET, ActiveDirtyManagerService, ArrayValueObject, AstRootNodeFactory, AstTreeBuilder, AsyncArrayObject, AsyncCustomFunction, AsyncObject, BaseFunction, BaseReferenceObject, BaseValueObject, BooleanValue, BooleanValueObject, CELL_INVERTED_INDEX_CACHE, CalculateController, CalculateFormulaService, CustomFunction, DEFAULT_CYCLE_REFERENCE_COUNT, DEFAULT_INTERVAL_COUNT, DEFAULT_TOKEN_LAMBDA_FUNCTION_NAME, DEFAULT_TOKEN_LET_FUNCTION_NAME, DEFAULT_TOKEN_TYPE_LAMBDA_PARAMETER, DEFAULT_TOKEN_TYPE_PARAMETER, DEFAULT_TOKEN_TYPE_ROOT, DefinedNamesService, DependencyManagerBaseService, DependencyManagerService, DescriptionService, ENGINE_FORMULA_CYCLE_REFERENCE_COUNT, ENGINE_FORMULA_PLUGIN_CONFIG_KEY, ENGINE_FORMULA_RETURN_DEPENDENCY_TREE, ERROR_TYPE_SET, ErrorType, ErrorValueObject, FORMULA_REF_TO_ARRAY_CACHE, FUNCTION_LIST, FUNCTION_LIST_ARRAY, FUNCTION_LIST_COMPATIBILITY, FUNCTION_LIST_CUBE, FUNCTION_LIST_DATABASE, FUNCTION_LIST_DATE, FUNCTION_LIST_ENGINEERING, FUNCTION_LIST_FINANCIAL, FUNCTION_LIST_INFORMATION, FUNCTION_LIST_LOGICAL, FUNCTION_LIST_LOOKUP, FUNCTION_LIST_MATH, FUNCTION_LIST_STATISTICAL, FUNCTION_LIST_TEXT, FUNCTION_LIST_UNIVER, FUNCTION_LIST_WEB, FUNCTION_NAMES_ARRAY, FUNCTION_NAMES_COMPATIBILITY, FUNCTION_NAMES_CUBE, FUNCTION_NAMES_DATABASE, FUNCTION_NAMES_DATE, FUNCTION_NAMES_ENGINEERING, FUNCTION_NAMES_FINANCIAL, FUNCTION_NAMES_INFORMATION, FUNCTION_NAMES_LOGICAL, FUNCTION_NAMES_LOOKUP, FUNCTION_NAMES_MATH, FUNCTION_NAMES_STATISTICAL, FUNCTION_NAMES_TEXT, FUNCTION_NAMES_UNIVER, FUNCTION_NAMES_WEB, FeatureCalculationManagerService, FormulaCalculationSessionController, FormulaCalculationSessionService, FormulaCalculationTriggerService, FormulaCurrentConfigService, FormulaDataModel, FormulaDependencyGenerator, FormulaDependencyTree, FormulaDependencyTreeModel, FormulaDependencyTreeType, FormulaDependencyTreeVirtual, FormulaExecuteStageType, FormulaExecutedStateType, FormulaResultApplicationType, FormulaResultStatus, FormulaRuntimeService, FormulaUnitReferenceResolver, FunctionNodeFactory, FunctionService, FunctionType, GlobalComputingStatusService, HyperlinkEngineFormulaService, IActiveDirtyManagerService, ICalculateFormulaService, IDefinedNamesService, IDependencyManagerService, IDescriptionService, IFeatureCalculationManagerService, IFormulaCurrentConfigService, IFormulaDependencyGenerator, IFormulaExternalReferenceDataLoader, IFormulaRuntimeService, IFormulaUnitReferenceResolver, IFunctionService, IHyperlinkEngineFormulaService, IOtherFormulaManagerService, IRegisterFunctionService, ISheetRowFilteredService, ISuperTableService, Interpreter, LambdaNodeFactory, LambdaParameterNodeFactory, LambdaValueObjectObject, Lexer, LexerNode, LexerTreeBuilder, NEW_EXCEL_FUNCTIONS, NoopFormulaExternalReferenceDataLoader, NullValueObject, NumberValueObject, OPERATOR_TOKEN_SET, OperatorNodeFactory, OtherFormulaBizType, OtherFormulaManagerService, OtherFormulaMarkDirty, PrefixNodeFactory, RangeReferenceObject, ReferenceNodeFactory, RegisterFunctionMutation, RegisterFunctionService, RegisterOtherFormulaService, RemoveDefinedNameMutation, RemoveFeatureCalculationMutation, RemoveOtherFormulaMutation, RemoveSuperTableMutation, SUFFIX_TOKEN_SET, SetArrayFormulaDataMutation, SetCellFormulaDependencyCalculationMutation, SetCellFormulaDependencyCalculationResultMutation, SetDefinedNameMutation, SetDefinedNameMutationFactory, SetFeatureCalculationMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation, SetFormulaDataMutation, SetFormulaDependencyCalculationMutation, SetFormulaDependencyCalculationResultMutation, SetFormulaStringBatchCalculationMutation, SetFormulaStringBatchCalculationResultMutation, SetImageFormulaDataMutation, SetOtherFormulaMutation, SetQueryFormulaDependencyAllMutation, SetQueryFormulaDependencyAllResultMutation, SetQueryFormulaDependencyMutation, SetQueryFormulaDependencyResultMutation, SetSuperTableMutation, SetSuperTableOptionMutation, SetTriggerFormulaCalculationStartMutation, SheetRowFilteredService, StringValueObject, SuffixNodeFactory, SuperTableActiveDirtyController, SuperTableService, UnionNodeFactory, UniverFormulaEnginePlugin, ValueNodeFactory, ValueObjectFactory, buildFormulaTextRuns, compareToken, convertUnitDataToRuntime, deserializeRangeForR1C1, deserializeRangeWithSheet, deserializeRangeWithSheetWithCache, excelDateSerial, extractFormulaError, findFormulaStructuredReferences, functionArray, functionCompatibility, functionCube, functionDatabase, functionDate, functionEngineering, functionFinancial, functionInformation, functionLogical, functionLookup, functionMath, functionMeta, functionStatistical, functionText, functionUniver, functionWeb, generateAstNode, generateExecuteAstNodeData, generateParam, generateRandomDependencyTreeId, generateStringWithSequence, getAbsoluteRefTypeWitString, getAbsoluteRefTypeWithSingleString, getFormulaHighlightDataStream, getFormulaReferenceIndex, getFormulaReplaceResult, getFormulaSequenceCharacterAtOffset, getFormulaSequenceNodeIndex, getFunctionName, getObjectValue, getRangeWithRefsString, handleNumfmtInCell, handleRefStringInfo, includeFormulaLexerToken, initSheetFormulaData, isFormulaLexerToken, isFormulaReferenceAddingContext, isFormulaReferenceAddingTextContext, isInDirtyRange, isReferenceString, isReferenceStringWithEffectiveColumn, isReferenceStrings, matchRefDrawToken, matchToken, needsQuoting, normalizeFormulaUnitName, normalizeSheetName, operatorToken, prefixToken, quoteSheetName, refactorFormulaUnitQualifier, resolveFormulaReferenceEditingContext, searchFormulaFunctions, sequenceNodeType, serializeRange, serializeRangeToRefString, serializeRangeWithSheet, serializeRangeWithSpreadsheet, singleReferenceToGrid, splitTableStructuredRef, strip, stripErrorMargin, unquoteSheetName };
56810
+ export { ALL_IMPLEMENTED_FUNCTIONS, ALL_IMPLEMENTED_FUNCTIONS_SET, ActiveDirtyManagerService, ArrayValueObject, AstRootNodeFactory, AstTreeBuilder, AsyncArrayObject, AsyncCustomFunction, AsyncObject, BaseFunction, BaseReferenceObject, BaseValueObject, BooleanValue, BooleanValueObject, CELL_INVERTED_INDEX_CACHE, CalculateController, CalculateFormulaService, CustomFunction, DEFAULT_CYCLE_REFERENCE_COUNT, DEFAULT_INTERVAL_COUNT, DEFAULT_TOKEN_LAMBDA_FUNCTION_NAME, DEFAULT_TOKEN_LET_FUNCTION_NAME, DEFAULT_TOKEN_TYPE_LAMBDA_PARAMETER, DEFAULT_TOKEN_TYPE_PARAMETER, DEFAULT_TOKEN_TYPE_ROOT, DefinedNamesService, DependencyManagerBaseService, DependencyManagerService, DescriptionService, ENGINE_FORMULA_CYCLE_REFERENCE_COUNT, ENGINE_FORMULA_PLUGIN_CONFIG_KEY, ENGINE_FORMULA_RETURN_DEPENDENCY_TREE, ERROR_TYPE_SET, ErrorType, ErrorValueObject, FORMULA_REF_TO_ARRAY_CACHE, FUNCTION_LIST, FUNCTION_LIST_ARRAY, FUNCTION_LIST_COMPATIBILITY, FUNCTION_LIST_CUBE, FUNCTION_LIST_DATABASE, FUNCTION_LIST_DATE, FUNCTION_LIST_ENGINEERING, FUNCTION_LIST_FINANCIAL, FUNCTION_LIST_INFORMATION, FUNCTION_LIST_LOGICAL, FUNCTION_LIST_LOOKUP, FUNCTION_LIST_MATH, FUNCTION_LIST_STATISTICAL, FUNCTION_LIST_TEXT, FUNCTION_LIST_UNIVER, FUNCTION_LIST_WEB, FUNCTION_NAMES_ARRAY, FUNCTION_NAMES_COMPATIBILITY, FUNCTION_NAMES_CUBE, FUNCTION_NAMES_DATABASE, FUNCTION_NAMES_DATE, FUNCTION_NAMES_ENGINEERING, FUNCTION_NAMES_FINANCIAL, FUNCTION_NAMES_INFORMATION, FUNCTION_NAMES_LOGICAL, FUNCTION_NAMES_LOOKUP, FUNCTION_NAMES_MATH, FUNCTION_NAMES_STATISTICAL, FUNCTION_NAMES_TEXT, FUNCTION_NAMES_UNIVER, FUNCTION_NAMES_WEB, FeatureCalculationManagerService, FormulaCalculationSessionController, FormulaCalculationSessionService, FormulaCalculationTriggerService, FormulaCurrentConfigService, FormulaDataModel, FormulaDependencyGenerator, FormulaDependencyTree, FormulaDependencyTreeModel, FormulaDependencyTreeType, FormulaDependencyTreeVirtual, FormulaExecuteStageType, FormulaExecutedStateType, FormulaResultApplicationType, FormulaResultStatus, FormulaRuntimeService, FormulaUnitReferenceResolver, FunctionNodeFactory, FunctionService, FunctionType, GlobalComputingStatusService, HyperlinkEngineFormulaService, IActiveDirtyManagerService, ICalculateFormulaService, IDefinedNamesService, IDependencyManagerService, IDescriptionService, IFeatureCalculationManagerService, IFormulaCurrentConfigService, IFormulaDependencyGenerator, IFormulaExternalReferenceDataLoader, IFormulaRuntimeService, IFormulaUnitReferenceResolver, IFunctionService, IHyperlinkEngineFormulaService, IOtherFormulaManagerService, IRegisterFunctionService, ISheetRowFilteredService, ISuperTableService, Interpreter, LambdaNodeFactory, LambdaParameterNodeFactory, LambdaValueObjectObject, Lexer, LexerNode, LexerTreeBuilder, NEW_EXCEL_FUNCTIONS, NoopFormulaExternalReferenceDataLoader, NullValueObject, NumberValueObject, OPERATOR_TOKEN_SET, OperatorNodeFactory, OtherFormulaBizType, OtherFormulaManagerService, OtherFormulaMarkDirty, PrefixNodeFactory, RangeReferenceObject, ReferenceNodeFactory, RegisterFunctionMutation, RegisterFunctionService, RegisterOtherFormulaService, RemoveDefinedNameMutation, RemoveFeatureCalculationMutation, RemoveOtherFormulaMutation, RemoveSuperTableMutation, SUFFIX_TOKEN_SET, SetArrayFormulaDataMutation, SetCellFormulaDependencyCalculationMutation, SetCellFormulaDependencyCalculationResultMutation, SetDefinedNameMutation, SetDefinedNameMutationFactory, SetFeatureCalculationMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation, SetFormulaDataMutation, SetFormulaDependencyCalculationMutation, SetFormulaDependencyCalculationResultMutation, SetFormulaStringBatchCalculationMutation, SetFormulaStringBatchCalculationResultMutation, SetImageFormulaDataMutation, SetOtherFormulaMutation, SetQueryFormulaDependencyAllMutation, SetQueryFormulaDependencyAllResultMutation, SetQueryFormulaDependencyMutation, SetQueryFormulaDependencyResultMutation, SetSuperTableMutation, SetSuperTableOptionMutation, SetTriggerFormulaCalculationStartMutation, SheetRowFilteredService, StringValueObject, SuffixNodeFactory, SuperTableActiveDirtyController, SuperTableService, UnionNodeFactory, UniverFormulaEnginePlugin, ValueNodeFactory, ValueObjectFactory, buildFormulaTextRuns, compareToken, convertUnitDataToRuntime, deserializeRangeForR1C1, deserializeRangeWithSheet, deserializeRangeWithSheetWithCache, excelDateSerial, extractFormulaError, findFormulaStructuredReferences, functionArray, functionCompatibility, functionCube, functionDatabase, functionDate, functionEngineering, functionFinancial, functionInformation, functionLogical, functionLookup, functionMath, functionMeta, functionStatistical, functionText, functionUniver, functionWeb, generateAstNode, generateExecuteAstNodeData, generateParam, generateRandomDependencyTreeId, generateStringWithSequence, getAbsoluteRefTypeWitString, getAbsoluteRefTypeWithSingleString, getFormulaHighlightDataStream, getFormulaReferenceIndex, getFormulaReplaceResult, getFormulaSequenceCharacterAtOffset, getFormulaSequenceNodeIndex, getFunctionName, getObjectValue, getRangeWithRefsString, handleNumfmtInCell, handleRefStringInfo, includeFormulaLexerToken, isFormulaLexerToken, isFormulaReferenceAddingContext, isFormulaReferenceAddingTextContext, isInDirtyRange, isReferenceString, isReferenceStringWithEffectiveColumn, isReferenceStrings, matchRefDrawToken, matchToken, needsQuoting, normalizeFormulaUnitName, normalizeSheetName, operatorToken, prefixToken, quoteSheetName, refactorFormulaUnitQualifier, resolveFormulaReferenceEditingContext, searchFormulaFunctions, sequenceNodeType, serializeRange, serializeRangeToRefString, serializeRangeWithSheet, serializeRangeWithSpreadsheet, singleReferenceToGrid, splitTableStructuredRef, strip, stripErrorMargin, unquoteSheetName };