@univerjs/engine-formula 0.24.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { AbsoluteRefType, AsyncLock, BooleanNumber, BuildTextUtils, CellValueType, CommandType, DataStreamTreeTokenType, Disposable, DisposableCollection, ICommandService, IConfigService, IUniverInstanceService, Inject, Injector, LRUMap, LifecycleService, LocaleService, LocaleType, MAX_COLUMN_COUNT, MAX_ROW_COUNT, ObjectMatrix, Optional, Plugin, RANGE_TYPE, RTree, Rectangle, RichTextBuilder, Tools, UniverInstanceType, cellToRange, columnLabelToNumber, createIdentifier, generateRandomId, getNumfmtParseValueFilter, hashAlgorithm, isFormulaId, isFormulaString, isRealNum, isTextFormat, isValidRange, merge, moveRangeByOffset, numfmt, 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, LocaleService, LocaleType, MAX_COLUMN_COUNT, MAX_ROW_COUNT, ObjectMatrix, Optional, Plugin, RANGE_TYPE, RTree, Rectangle, RichTextBuilder, Tools, UniverInstanceType, cellToRange, columnLabelToNumber, createIdentifier, escapeRegExp, generateRandomId, getNumfmtParseValueFilter, hashAlgorithm, isFormulaId, isFormulaString, isNullCell, isRealNum, isTextFormat, isValidRange, merge, moveRangeByOffset, numfmt, requestImmediateMacroTask, sortRules, toDisposable, touchDependencies } from "@univerjs/core";
2
2
  import IntervalTree from "@flatten-js/interval-tree";
3
3
  import { BehaviorSubject, Observable, Subject, bufferWhen, combineLatest, distinctUntilChanged, filter, map, shareReplay, skip } from "rxjs";
4
4
  import Decimal from "decimal.js";
@@ -12,7 +12,7 @@ let BooleanValue = /* @__PURE__ */ function(BooleanValue) {
12
12
  }({});
13
13
 
14
14
  //#endregion
15
- //#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
15
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
16
16
  function _typeof(o) {
17
17
  "@babel/helpers - typeof";
18
18
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -23,7 +23,7 @@ function _typeof(o) {
23
23
  }
24
24
 
25
25
  //#endregion
26
- //#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
26
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
27
27
  function toPrimitive(t, r) {
28
28
  if ("object" != _typeof(t) || !t) return t;
29
29
  var e = t[Symbol.toPrimitive];
@@ -36,14 +36,14 @@ function toPrimitive(t, r) {
36
36
  }
37
37
 
38
38
  //#endregion
39
- //#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
39
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
40
40
  function toPropertyKey(t) {
41
41
  var i = toPrimitive(t, "string");
42
42
  return "symbol" == _typeof(i) ? i : i + "";
43
43
  }
44
44
 
45
45
  //#endregion
46
- //#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
46
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
47
47
  function _defineProperty(e, r, t) {
48
48
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
49
49
  value: t,
@@ -845,7 +845,7 @@ function getWeekDayByDateSerialNumber(dateSerialNumber) {
845
845
  let date = excelSerialToDate(dateSerialNumber);
846
846
  const leapDayDateTime = Date.UTC(1900, 1, 28);
847
847
  const dateTime = Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
848
- if (!isDate19000229 && dateTime <= leapDayDateTime) date = new Date(dateTime - perDayMilliseconds);
848
+ if (!isDate19000229 && dateTime <= leapDayDateTime) date = /* @__PURE__ */ new Date(dateTime - perDayMilliseconds);
849
849
  return date.getUTCDay();
850
850
  }
851
851
  function getTwoDateDaysByBasis(startDateSerialNumber, endDateSerialNumber, basis) {
@@ -1847,7 +1847,7 @@ function splitTableStructuredRef(ref) {
1847
1847
  }
1848
1848
 
1849
1849
  //#endregion
1850
- //#region \0@oxc-project+runtime@0.129.0/helpers/decorateParam.js
1850
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
1851
1851
  function __decorateParam(paramIndex, decorator) {
1852
1852
  return function(target, key) {
1853
1853
  decorator(target, key, paramIndex);
@@ -1855,7 +1855,7 @@ function __decorateParam(paramIndex, decorator) {
1855
1855
  }
1856
1856
 
1857
1857
  //#endregion
1858
- //#region \0@oxc-project+runtime@0.129.0/helpers/decorate.js
1858
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
1859
1859
  function __decorate(decorators, target, key, desc) {
1860
1860
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1861
1861
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -5363,6 +5363,7 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends Disp
5363
5363
  _defineProperty(this, "_dirtyRanges", []);
5364
5364
  _defineProperty(this, "_dirtyNameMap", {});
5365
5365
  _defineProperty(this, "_dirtyDefinedNameMap", {});
5366
+ _defineProperty(this, "_dirtySuperTableMap", {});
5366
5367
  _defineProperty(this, "_dirtyUnitFeatureMap", {});
5367
5368
  _defineProperty(this, "_dirtyUnitOtherFormulaMap", {});
5368
5369
  _defineProperty(this, "_excludedCell", void 0);
@@ -5382,6 +5383,7 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends Disp
5382
5383
  this._dirtyRanges = [];
5383
5384
  this._dirtyNameMap = {};
5384
5385
  this._dirtyDefinedNameMap = {};
5386
+ this._dirtySuperTableMap = {};
5385
5387
  this._dirtyUnitFeatureMap = {};
5386
5388
  this._dirtyUnitOtherFormulaMap = {};
5387
5389
  this._excludedCell = {};
@@ -5432,6 +5434,9 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends Disp
5432
5434
  getDirtyDefinedNameMap() {
5433
5435
  return this._dirtyDefinedNameMap;
5434
5436
  }
5437
+ getDirtySuperTableMap() {
5438
+ return this._dirtySuperTableMap;
5439
+ }
5435
5440
  getDirtyUnitFeatureMap() {
5436
5441
  return this._dirtyUnitFeatureMap;
5437
5442
  }
@@ -5497,6 +5502,7 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends Disp
5497
5502
  this._dirtyRanges = config.dirtyRanges;
5498
5503
  this._dirtyNameMap = config.dirtyNameMap;
5499
5504
  this._dirtyDefinedNameMap = config.dirtyDefinedNameMap;
5505
+ this._dirtySuperTableMap = config.dirtySuperTableMap || {};
5500
5506
  this._dirtyUnitFeatureMap = config.dirtyUnitFeatureMap;
5501
5507
  this._dirtyUnitOtherFormulaMap = config.dirtyUnitOtherFormulaMap;
5502
5508
  this._excludedCell = config.excludedCell;
@@ -5518,6 +5524,7 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends Disp
5518
5524
  dirtyRanges: this._dirtyRanges,
5519
5525
  dirtyNameMap: this._dirtyNameMap,
5520
5526
  dirtyDefinedNameMap: this._dirtyDefinedNameMap,
5527
+ dirtySuperTableMap: this._dirtySuperTableMap,
5521
5528
  dirtyUnitFeatureMap: this._dirtyUnitFeatureMap,
5522
5529
  dirtyUnitOtherFormulaMap: this._dirtyUnitOtherFormulaMap,
5523
5530
  clearDependencyTreeCache: this._clearDependencyTreeCache
@@ -5632,22 +5639,6 @@ Lexer = __decorate([
5632
5639
  __decorateParam(2, IFormulaCurrentConfigService)
5633
5640
  ], Lexer);
5634
5641
 
5635
- //#endregion
5636
- //#region src/basics/is-null-cell.ts
5637
- /**
5638
- * Examine if a cell is empty (null) in the formula-related modules. This is not
5639
- * interchangable with {@link isNullCell} from the core package, because for
5640
- * formulas, "custom" field is meaningless.
5641
- */
5642
- function isNullCellForFormula(cell) {
5643
- if (cell == null) return true;
5644
- const { v, f, si, p } = cell;
5645
- if (!(v == null || typeof v === "string" && v.length === 0)) return false;
5646
- if (f != null && f.length > 0 || si != null && si.length > 0) return false;
5647
- if (p != null) return false;
5648
- return true;
5649
- }
5650
-
5651
5642
  //#endregion
5652
5643
  //#region src/engine/utils/cell.ts
5653
5644
  function getCellValue(cell) {
@@ -5699,7 +5690,7 @@ function isWildcard(str) {
5699
5690
  return str.indexOf("*") > -1 || str.indexOf("?") > -1;
5700
5691
  }
5701
5692
  function isMatchWildcard(currentValue, value) {
5702
- const pattern = escapeRegExp(value).replace(/~?[*?]/g, (match) => {
5693
+ const pattern = escapeRegExpForWildcard(value).replace(/~?[*?]/g, (match) => {
5703
5694
  if (match.startsWith("~")) return `\\${match.substring(1)}`;
5704
5695
  if (match === "*") return ".*";
5705
5696
  if (match === "?") return ".";
@@ -5734,7 +5725,7 @@ function compareWithWildcard(currentValue, value, operator) {
5734
5725
  }
5735
5726
  return result;
5736
5727
  }
5737
- function escapeRegExp(str) {
5728
+ function escapeRegExpForWildcard(str) {
5738
5729
  return str.replace(/[.+^${}()|[\]\\]/g, "\\$&");
5739
5730
  }
5740
5731
  function getMatchModeValue(matchModeValue) {
@@ -5783,11 +5774,20 @@ const localeCurrencySymbolMap = new Map([
5783
5774
  [LocaleType.VI_VN, "₫"],
5784
5775
  [LocaleType.ZH_CN, "¥"],
5785
5776
  [LocaleType.ZH_TW, "NT$"],
5777
+ [LocaleType.ZH_HK, "HK$"],
5786
5778
  [LocaleType.FR_FR, "€"],
5787
5779
  [LocaleType.FA_IR, "﷼"],
5788
5780
  [LocaleType.KO_KR, "₩"],
5789
5781
  [LocaleType.ES_ES, "€"],
5790
- [LocaleType.CA_ES, "€"]
5782
+ [LocaleType.CA_ES, "€"],
5783
+ [LocaleType.SK_SK, "€"],
5784
+ [LocaleType.JA_JP, "¥"],
5785
+ [LocaleType.PT_BR, "R$"],
5786
+ [LocaleType.DE_DE, "€"],
5787
+ [LocaleType.IT_IT, "€"],
5788
+ [LocaleType.ID_ID, "Rp"],
5789
+ [LocaleType.PL_PL, "zł"],
5790
+ [LocaleType.AR_SA, "﷼"]
5791
5791
  ]);
5792
5792
  function getCurrencySymbol(locale) {
5793
5793
  return localeCurrencySymbolMap.get(locale) || "$";
@@ -8215,7 +8215,7 @@ var BaseReferenceObject = class extends ObjectClassType {
8215
8215
  if (r < 0 || c < 0) return callback(ErrorValueObject.create("#REF!"), r, c);
8216
8216
  const cell = this.getCellData(r, c);
8217
8217
  let result = false;
8218
- if (isNullCellForFormula(cell)) {
8218
+ if (isNullCell(cell)) {
8219
8219
  result = callback(null, r, c);
8220
8220
  continue;
8221
8221
  }
@@ -9662,10 +9662,10 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
9662
9662
  const currentCell = unitData === null || unitData === void 0 || (_unitData$formulaUnit = unitData[formulaUnitId]) === null || _unitData$formulaUnit === void 0 || (_unitData$formulaUnit = _unitData$formulaUnit[formulaSheetId]) === null || _unitData$formulaUnit === void 0 || (_unitData$formulaUnit = _unitData$formulaUnit.cellData) === null || _unitData$formulaUnit === void 0 ? void 0 : _unitData$formulaUnit.getValue(r, c);
9663
9663
  const featureCell = this._getRuntimeFeatureCellValue(r, c, formulaSheetId, formulaUnitId);
9664
9664
  const isPreviousCellOfCurrentArrayFormula = this._arrayCellHasData(arrayDataCell) && this._isInArrayFormulaRange(previousArrayFormulaRange, r, c) && (currentCell == null || this._isSameCellValue(currentCell, arrayDataCell));
9665
- const hasRuntimeCell = !isNullCellForFormula(cell);
9665
+ const hasRuntimeCell = !isNullCell(cell);
9666
9666
  const isInOtherArrayFormulaRange = this._isInOtherArrayFormulaRange(formulaUnitId, formulaSheetId, formulaRow, formulaColumn, r, c);
9667
- const currentCellBlocks = !isNullCellForFormula(currentCell) && !isPreviousCellOfCurrentArrayFormula;
9668
- const featureCellBlocks = !isNullCellForFormula(featureCell);
9667
+ const currentCellBlocks = !isNullCell(currentCell) && !isPreviousCellOfCurrentArrayFormula;
9668
+ const featureCellBlocks = !isNullCell(featureCell);
9669
9669
  if (hasRuntimeCell || isInOtherArrayFormulaRange || currentCellBlocks || featureCellBlocks) return true;
9670
9670
  }
9671
9671
  return false;
@@ -9938,9 +9938,11 @@ const COLUMN_LIKE_FUNCTION_NAMES = new Set(ALL_GROUPS.flatMap((g) => Object.valu
9938
9938
  //#region src/engine/utils/generate-ast-node.ts
9939
9939
  const FORMULA_CACHE_LRU_COUNT = 5e3;
9940
9940
  const FORMULA_AST_CACHE = new FormulaAstLRU(FORMULA_CACHE_LRU_COUNT);
9941
+ const DIRTY_DEFINED_NAME_SET_CACHE = /* @__PURE__ */ new WeakMap();
9942
+ const DIRTY_SUPER_TABLE_PATTERN_CACHE = /* @__PURE__ */ new WeakMap();
9941
9943
  function generateAstNode(unitId, formulaString, lexer, astTreeBuilder, currentConfigService) {
9942
9944
  let astNode = FORMULA_AST_CACHE.get(`${unitId}${formulaString}`);
9943
- const noCache = checkIsChangedByDefinedName(unitId, formulaString, currentConfigService);
9945
+ const noCache = checkIsChangedByDefinedName(unitId, formulaString, currentConfigService) || checkIsChangedBySuperTable(unitId, formulaString, currentConfigService);
9944
9946
  if (!noCache && astNode && !isDirtyDefinedForNode(astNode, currentConfigService)) return astNode;
9945
9947
  const lexerNode = lexer.treeBuilder(formulaString);
9946
9948
  if (ERROR_TYPE_SET.has(lexerNode)) return ErrorNode.create(lexerNode);
@@ -9955,14 +9957,37 @@ function generateAstNode(unitId, formulaString, lexer, astTreeBuilder, currentCo
9955
9957
  function checkIsChangedByDefinedName(unitId, formula, currentConfigService) {
9956
9958
  const unitDefinedNameMap = currentConfigService.getDirtyDefinedNameMap()[unitId];
9957
9959
  if (unitDefinedNameMap == null) return false;
9958
- const formulaText = normalizeFormulaText(formula);
9959
- const names = Object.keys(unitDefinedNameMap);
9960
- for (let i = 0, len = names.length; i < len; i++) if (normalizeFormulaText(names[i]) === formulaText) return true;
9961
- return false;
9960
+ return getNormalizedDirtyDefinedNameSet(unitDefinedNameMap).has(normalizeFormulaText(formula));
9962
9961
  }
9963
9962
  function normalizeFormulaText(formula) {
9964
9963
  return formula.startsWith("=") ? formula.slice(1) : formula;
9965
9964
  }
9965
+ function checkIsChangedBySuperTable(unitId, formula, currentConfigService) {
9966
+ var _currentConfigService, _tableReferencePatter;
9967
+ const getDirtySuperTableMap = (_currentConfigService = currentConfigService.getDirtySuperTableMap) === null || _currentConfigService === void 0 ? void 0 : _currentConfigService.bind(currentConfigService);
9968
+ const changedSuperTableMap = getDirtySuperTableMap === null || getDirtySuperTableMap === void 0 ? void 0 : getDirtySuperTableMap();
9969
+ const unitSuperTableMap = changedSuperTableMap === null || changedSuperTableMap === void 0 ? void 0 : changedSuperTableMap[unitId];
9970
+ if (unitSuperTableMap == null) return false;
9971
+ const tableReferencePattern = getDirtySuperTableReferencePattern(unitSuperTableMap);
9972
+ return (_tableReferencePatter = tableReferencePattern === null || tableReferencePattern === void 0 ? void 0 : tableReferencePattern.test(normalizeFormulaText(formula))) !== null && _tableReferencePatter !== void 0 ? _tableReferencePatter : false;
9973
+ }
9974
+ function getNormalizedDirtyDefinedNameSet(unitDefinedNameMap) {
9975
+ let normalizedNameSet = DIRTY_DEFINED_NAME_SET_CACHE.get(unitDefinedNameMap);
9976
+ if (normalizedNameSet == null) {
9977
+ normalizedNameSet = new Set(Object.keys(unitDefinedNameMap).map(normalizeFormulaText));
9978
+ DIRTY_DEFINED_NAME_SET_CACHE.set(unitDefinedNameMap, normalizedNameSet);
9979
+ }
9980
+ return normalizedNameSet;
9981
+ }
9982
+ function getDirtySuperTableReferencePattern(unitSuperTableMap) {
9983
+ let tableReferencePattern = DIRTY_SUPER_TABLE_PATTERN_CACHE.get(unitSuperTableMap);
9984
+ if (tableReferencePattern === void 0) {
9985
+ const escapedTableNames = Object.keys(unitSuperTableMap).filter((tableName) => tableName.length > 0).map(escapeRegExp);
9986
+ tableReferencePattern = escapedTableNames.length > 0 ? new RegExp(`(^|[^A-Za-z0-9_])(?:${escapedTableNames.join("|")})(\\s*\\[|$|[^A-Za-z0-9_])`, "i") : null;
9987
+ DIRTY_SUPER_TABLE_PATTERN_CACHE.set(unitSuperTableMap, tableReferencePattern);
9988
+ }
9989
+ return tableReferencePattern;
9990
+ }
9966
9991
  function isDirtyDefinedForNode(node, currentConfigService) {
9967
9992
  const definedNameMap = currentConfigService.getDirtyDefinedNameMap();
9968
9993
  const executeUnitId = currentConfigService.getExecuteUnitId();
@@ -11760,9 +11785,7 @@ var DependencyManagerBaseService = class extends Disposable {
11760
11785
  clearFormulaDependency(unitId, sheetId) {
11761
11786
  throw new Error("Method not implemented.");
11762
11787
  }
11763
- removeFormulaDependencyByDefinedName(unitId, definedName) {
11764
- throw new Error("Method not implemented.");
11765
- }
11788
+ removeFormulaDependencyByDefinedName(unitId, definedName) {}
11766
11789
  searchDependency(search, exceptTreeIds) {
11767
11790
  return this._dependencyRTreeCache.bulkSearch(search, exceptTreeIds);
11768
11791
  }
@@ -13871,7 +13894,7 @@ let CalculateController = class CalculateController extends Disposable {
13871
13894
  }));
13872
13895
  }
13873
13896
  async _calculate(formulaDirtyData) {
13874
- const { forceCalculation: forceCalculate = false, dirtyRanges = [], dirtyNameMap = {}, dirtyDefinedNameMap = {}, dirtyUnitFeatureMap = {}, dirtyUnitOtherFormulaMap = {}, clearDependencyTreeCache = {}, maxIteration = 1, rowData, isCalculateTreeModel = false } = formulaDirtyData;
13897
+ const { forceCalculation: forceCalculate = false, dirtyRanges = [], dirtyNameMap = {}, dirtyDefinedNameMap = {}, dirtySuperTableMap = {}, dirtyUnitFeatureMap = {}, dirtyUnitOtherFormulaMap = {}, clearDependencyTreeCache = {}, maxIteration = 1, rowData, isCalculateTreeModel = false } = formulaDirtyData;
13875
13898
  const formulaData = this._formulaDataModel.getFormulaData();
13876
13899
  const arrayFormulaCellData = this._formulaDataModel.getArrayFormulaCellData();
13877
13900
  const arrayFormulaRange = this._formulaDataModel.getArrayFormulaRange();
@@ -13883,6 +13906,7 @@ let CalculateController = class CalculateController extends Disposable {
13883
13906
  dirtyRanges,
13884
13907
  dirtyNameMap,
13885
13908
  dirtyDefinedNameMap,
13909
+ dirtySuperTableMap,
13886
13910
  dirtyUnitFeatureMap,
13887
13911
  dirtyUnitOtherFormulaMap,
13888
13912
  clearDependencyTreeCache,
@@ -24110,14 +24134,14 @@ function guessIsNaNorInfinity(guess, iterF) {
24110
24134
  const max = Number.MAX_VALUE;
24111
24135
  const min = -1;
24112
24136
  const step = 1.6;
24113
- let low = guess - .01 <= min ? min + g_Eps : guess - .01;
24137
+ let low = guess - .01 <= min ? -.9999999 : guess - .01;
24114
24138
  let high = guess + .01 >= max ? max - g_Eps : guess + .01;
24115
24139
  let xBegin;
24116
24140
  let xEnd;
24117
24141
  let currentIter = 0;
24118
24142
  if (guess <= min || guess >= max) return ErrorValueObject.create("#NUM!");
24119
24143
  for (let i = 0; i < nIM; i++) {
24120
- xBegin = low <= min ? min + g_Eps : low;
24144
+ xBegin = low <= min ? -.9999999 : low;
24121
24145
  xEnd = high >= max ? max - g_Eps : high;
24122
24146
  const x = iterF(xBegin);
24123
24147
  const y = iterF(xEnd);
@@ -32713,7 +32737,7 @@ var Roundbank = class extends BaseFunction {
32713
32737
  const integerPart = Math.floor(adjustedNum);
32714
32738
  const decimalPart = adjustedNum - integerPart;
32715
32739
  let result = Math.round(adjustedNum);
32716
- if (decimalPart > .5 - EPSILON && decimalPart < .5 + EPSILON) result = integerPart % 2 === 0 ? integerPart : integerPart + 1;
32740
+ if (decimalPart > .5 - EPSILON && decimalPart < .50000001) result = integerPart % 2 === 0 ? integerPart : integerPart + 1;
32717
32741
  return numDigits ? result / multiplier : result;
32718
32742
  }
32719
32743
  };
@@ -40031,10 +40055,7 @@ var Textsplit = class extends BaseFunction {
40031
40055
  if (valueObject.isNull()) value = "\\s";
40032
40056
  if (valueObject.isBoolean()) value = value ? "TRUE" : "FALSE";
40033
40057
  value += "";
40034
- return this._escapeRegExp(value);
40035
- }
40036
- _escapeRegExp(string) {
40037
- return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
40058
+ return escapeRegExp(value);
40038
40059
  }
40039
40060
  };
40040
40061
 
@@ -40417,7 +40438,7 @@ function getObjectValue(result, isUseStrip = false) {
40417
40438
  //#endregion
40418
40439
  //#region package.json
40419
40440
  var name = "@univerjs/engine-formula";
40420
- var version = "0.24.0";
40441
+ var version = "0.25.0";
40421
40442
 
40422
40443
  //#endregion
40423
40444
  //#region src/services/global-computing-status.service.ts
@@ -40475,7 +40496,7 @@ let ComputingStatusReporterController = class ComputingStatusReporterController
40475
40496
  const params = command.params;
40476
40497
  if (params.stageInfo) return observe.next(params.stageInfo.stage === 0 || params.stageInfo.stage === 8);
40477
40498
  });
40478
- }).pipe(distinctUntilChanged(), shareReplay()));
40499
+ }).pipe(distinctUntilChanged(), shareReplay({ refCount: true })));
40479
40500
  const disposables = new DisposableCollection();
40480
40501
  const subject = new BehaviorSubject(true);
40481
40502
  disposables.add(this._globalComputingSrv.pushComputingStatusSubject(subject));
@@ -85,9 +85,14 @@ export interface IDirtyUnitSheetNameMap {
85
85
  [sheetId: string]: string;
86
86
  }>;
87
87
  }
88
- export interface IDirtyUnitSheetDefinedNameMap {
88
+ export interface IDirtyUnitDefinedNameMap {
89
89
  [unitId: string]: Nullable<{
90
- [name: string]: string;
90
+ [definedName: string]: string;
91
+ }>;
92
+ }
93
+ export interface IDirtyUnitSuperTableMap {
94
+ [unitId: string]: Nullable<{
95
+ [tableName: string]: string;
91
96
  }>;
92
97
  }
93
98
  export interface IDirtyUnitFeatureMap {
@@ -213,7 +218,8 @@ export interface IFormulaDatasetConfig {
213
218
  forceCalculate: boolean;
214
219
  dirtyRanges: IUnitRange[];
215
220
  dirtyNameMap: IDirtyUnitSheetNameMap;
216
- dirtyDefinedNameMap: IDirtyUnitSheetNameMap;
221
+ dirtyDefinedNameMap: IDirtyUnitDefinedNameMap;
222
+ dirtySuperTableMap?: IDirtyUnitSuperTableMap;
217
223
  dirtyUnitFeatureMap: IDirtyUnitFeatureMap;
218
224
  dirtyUnitOtherFormulaMap: IDirtyUnitOtherFormulaMap;
219
225
  clearDependencyTreeCache?: IUnitSheetIdToNameMap;
@@ -21,6 +21,7 @@ export interface ISetSuperTableMutationSearchParam {
21
21
  tableName: string;
22
22
  }
23
23
  export interface ISetSuperTableMutationParam extends ISetSuperTableMutationSearchParam {
24
+ oldTableName?: string;
24
25
  reference: ISuperTable;
25
26
  }
26
27
  /**
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import type { Nullable } from '@univerjs/core';
17
- import type { IDirtyUnitSheetDefinedNameMap, IExprTreeNode, ISuperTable } from '../../basics/common';
17
+ import type { IDirtyUnitDefinedNameMap, IExprTreeNode, ISuperTable } from '../../basics/common';
18
18
  import type { IFunctionNames } from '../../basics/function';
19
19
  import type { IDefinedNamesServiceParam } from '../../services/defined-names.service';
20
20
  import type { ISequenceArray, ISequenceNode } from '../utils/sequence';
@@ -27,7 +27,7 @@ export declare const FormulaSequenceNodeCache: FormulaAstLRU<(string | ISequence
27
27
  interface IInjectDefinedNameParam {
28
28
  unitId: Nullable<string>;
29
29
  getValueByName(unitId: string, name: string): Nullable<IDefinedNamesServiceParam>;
30
- getDirtyDefinedNameMap(): IDirtyUnitSheetDefinedNameMap;
30
+ getDirtyDefinedNameMap(): IDirtyUnitDefinedNameMap;
31
31
  getSheetName: (unitId: string, sheetId: string) => string;
32
32
  }
33
33
  export declare class LexerTreeBuilder extends Disposable {
@@ -34,6 +34,5 @@ export declare function isWildcard(str: string): boolean;
34
34
  export declare function isMatchWildcard(currentValue: string, value: string): boolean;
35
35
  export declare function replaceWildcard(value: string): string;
36
36
  export declare function compareWithWildcard(currentValue: string, value: string, operator: compareToken): boolean;
37
- export declare function escapeRegExp(str: string): string;
38
37
  export declare function getMatchModeValue(matchModeValue: number): ArrayOrderSearchType;
39
38
  export declare function getSearchModeValue(searchModeValue: number): ArrayBinarySearchType;
@@ -118,12 +118,11 @@ export declare class FFormula extends FBase {
118
118
  */
119
119
  calculationEnd(callback: (functionsExecutedState: FormulaExecutedStateType) => void): IDisposable;
120
120
  /**
121
- * @deprecated Use `onCalculationEnd` instead.
121
+ * @deprecated Use `onCalculationResultApplied` instead.
122
122
  */
123
123
  whenComputingCompleteAsync(timeout?: number): Promise<boolean>;
124
124
  /**
125
- * Waits for the formula calculation to complete.
126
- * @returns {Promise<void>} This method returns a promise that resolves when the calculation is complete.
125
+ * @deprecated Use `onCalculationResultApplied` instead.
127
126
  */
128
127
  onCalculationEnd(): Promise<void>;
129
128
  /**
@@ -25,5 +25,4 @@ export declare class Textsplit extends BaseFunction {
25
25
  private _getResult;
26
26
  private _checkVariantsError;
27
27
  private _getRegExpStringValue;
28
- private _escapeRegExp;
29
28
  }
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export type { IArrayFormulaEmbeddedMap, IArrayFormulaRangeType, IArrayFormulaUnitCellType, IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefinedNameMap, IDirtyUnitSheetNameMap, IFeatureDirtyRangeType, IFormulaData, IFormulaDataItem, IFormulaDatasetConfig, IFormulaExecuteResultMap, IFormulaStringMap, IRuntimeImageFormulaDataType, IRuntimeUnitDataType, ISheetData, IUnitData, IUnitImageFormulaDataType, IUnitSheetNameMap, } from './basics/common';
16
+ export type { IArrayFormulaEmbeddedMap, IArrayFormulaRangeType, IArrayFormulaUnitCellType, IDirtyUnitDefinedNameMap, IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetNameMap, IDirtyUnitSuperTableMap, IFeatureDirtyRangeType, IFormulaData, IFormulaDataItem, IFormulaDatasetConfig, IFormulaExecuteResultMap, IFormulaStringMap, IRuntimeImageFormulaDataType, IRuntimeUnitDataType, ISheetData, IUnitData, IUnitImageFormulaDataType, IUnitSheetNameMap, } from './basics/common';
17
17
  export { BooleanValue } from './basics/common';
18
18
  export { type IOtherFormulaData } from './basics/common';
19
19
  export type { IExprTreeNode, ISuperTable, IUnitRowData } from './basics/common';
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import type { ICommandInfo, IUnitRange, Nullable } from '@univerjs/core';
17
- import type { IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefinedNameMap, IDirtyUnitSheetNameMap } from '../basics/common';
17
+ import type { IDirtyUnitDefinedNameMap, IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetNameMap, IDirtyUnitSuperTableMap } from '../basics/common';
18
18
  import { Disposable } from '@univerjs/core';
19
19
  export interface IDirtyConversionManagerParams {
20
20
  commandId: string;
@@ -22,7 +22,8 @@ export interface IDirtyConversionManagerParams {
22
22
  forceCalculation?: boolean;
23
23
  dirtyRanges?: IUnitRange[];
24
24
  dirtyNameMap?: IDirtyUnitSheetNameMap;
25
- dirtyDefinedNameMap?: IDirtyUnitSheetDefinedNameMap;
25
+ dirtyDefinedNameMap?: IDirtyUnitDefinedNameMap;
26
+ dirtySuperTableMap?: IDirtyUnitSuperTableMap;
26
27
  dirtyUnitFeatureMap?: IDirtyUnitFeatureMap;
27
28
  dirtyUnitOtherFormulaMap?: IDirtyUnitOtherFormulaMap;
28
29
  clearDependencyTreeCache?: IDirtyUnitSheetNameMap;
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import type { IUnitRange, LocaleType, Nullable } from '@univerjs/core';
17
- import type { IArrayFormulaRangeType, IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefinedNameMap, IDirtyUnitSheetNameMap, IFormulaData, IFormulaDatasetConfig, IRuntimeUnitDataType, IUnitData, IUnitExcludedCell, IUnitRowData, IUnitSheetIdToNameMap, IUnitSheetNameMap, IUnitStylesData } from '../basics/common';
17
+ import type { IArrayFormulaRangeType, IDirtyUnitDefinedNameMap, IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetNameMap, IDirtyUnitSuperTableMap, IFormulaData, IFormulaDatasetConfig, IRuntimeUnitDataType, IUnitData, IUnitExcludedCell, IUnitRowData, IUnitSheetIdToNameMap, IUnitSheetNameMap, IUnitStylesData } from '../basics/common';
18
18
  import { Disposable, IUniverInstanceService, LocaleService } from '@univerjs/core';
19
19
  import { FormulaDataModel } from '../models/formula-data.model';
20
20
  import { ISheetRowFilteredService } from './sheet-row-filtered.service';
@@ -22,7 +22,8 @@ export interface IFormulaDirtyData {
22
22
  forceCalculation: boolean;
23
23
  dirtyRanges: IUnitRange[];
24
24
  dirtyNameMap: IDirtyUnitSheetNameMap;
25
- dirtyDefinedNameMap: IDirtyUnitSheetDefinedNameMap;
25
+ dirtyDefinedNameMap: IDirtyUnitDefinedNameMap;
26
+ dirtySuperTableMap?: IDirtyUnitSuperTableMap;
26
27
  dirtyUnitFeatureMap: IDirtyUnitFeatureMap;
27
28
  dirtyUnitOtherFormulaMap: IDirtyUnitOtherFormulaMap;
28
29
  clearDependencyTreeCache: IDirtyUnitSheetNameMap;
@@ -42,7 +43,8 @@ export interface IFormulaCurrentConfigService {
42
43
  isForceCalculate(): boolean;
43
44
  getDirtyRanges(): IUnitRange[];
44
45
  getDirtyNameMap(): IDirtyUnitSheetNameMap;
45
- getDirtyDefinedNameMap(): IDirtyUnitSheetDefinedNameMap;
46
+ getDirtyDefinedNameMap(): IDirtyUnitDefinedNameMap;
47
+ getDirtySuperTableMap(): IDirtyUnitSuperTableMap;
46
48
  getDirtyUnitFeatureMap(): IDirtyUnitFeatureMap;
47
49
  registerUnitData(unitData: IUnitData): void;
48
50
  registerFormulaData(formulaData: IFormulaData): void;
@@ -90,6 +92,7 @@ export declare class FormulaCurrentConfigService extends Disposable implements I
90
92
  private _dirtyRanges;
91
93
  private _dirtyNameMap;
92
94
  private _dirtyDefinedNameMap;
95
+ private _dirtySuperTableMap;
93
96
  private _dirtyUnitFeatureMap;
94
97
  private _dirtyUnitOtherFormulaMap;
95
98
  private _excludedCell;
@@ -112,7 +115,8 @@ export declare class FormulaCurrentConfigService extends Disposable implements I
112
115
  isForceCalculate(): boolean;
113
116
  getDirtyRanges(): IUnitRange[];
114
117
  getDirtyNameMap(): IDirtyUnitSheetNameMap;
115
- getDirtyDefinedNameMap(): IDirtyUnitSheetDefinedNameMap;
118
+ getDirtyDefinedNameMap(): IDirtyUnitDefinedNameMap;
119
+ getDirtySuperTableMap(): IDirtyUnitSuperTableMap;
116
120
  getDirtyUnitFeatureMap(): IDirtyUnitFeatureMap;
117
121
  getDirtyUnitOtherFormulaMap(): IDirtyUnitOtherFormulaMap;
118
122
  getSheetName(unitId: string, sheetId: string): string;
package/lib/umd/facade.js CHANGED
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core/facade`),require(`@univerjs/core`),require(`@univerjs/engine-formula`),require(`rxjs`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core/facade`,`@univerjs/core`,`@univerjs/engine-formula`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverEngineFormulaFacade={},e.UniverCoreFacade,e.UniverCore,e.UniverEngineFormula,e.rxjs))})(this,function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function a(e,t){return function(n,r){t(n,r,e)}}function o(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let s=class extends t.FBase{constructor(e,t,n,r,i,a,o){super(),this._commandService=e,this._injector=t,this._lexerTreeBuilder=n,this._configService=r,this._functionService=i,this._definedNamesService=a,this._superTableService=o,this._initialize()}_initialize(){}get lexerTreeBuilder(){return this._lexerTreeBuilder}moveFormulaRefOffset(e,t,n,r){return this._lexerTreeBuilder.moveFormulaRefOffset(e,t,n,r)}sequenceNodesBuilder(e){return this._lexerTreeBuilder.sequenceNodesBuilder(e)||[]}executeCalculation(){this._commandService.executeCommand(r.SetTriggerFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})}stopCalculation(){this._commandService.executeCommand(r.SetFormulaCalculationStopMutation.id,{})}calculationStart(e){return this._commandService.onCommandExecuted(t=>{if(t.id===r.SetFormulaCalculationStartMutation.id){let n=t.params;e(n.forceCalculation)}})}calculationEnd(e){return this._commandService.onCommandExecuted(t=>{if(t.id!==r.SetFormulaCalculationNotificationMutation.id)return;let n=t.params;n.functionsExecutedState!==void 0&&e(n.functionsExecutedState)})}whenComputingCompleteAsync(e){let t=this._injector.get(r.GlobalComputingStatusService);return t.computingStatus?Promise.resolve(!0):(0,i.firstValueFrom)((0,i.race)(t.computingStatus$.pipe((0,i.filter)(e=>e)),(0,i.timer)(e==null?3e4:e).pipe((0,i.map)(()=>!1))))}onCalculationEnd(){return new Promise((e,t)=>{let n=setTimeout(()=>{t(Error(`Calculation end timeout`))},3e4),r=this.calculationEnd(()=>{clearTimeout(n),r.dispose(),e()})})}calculationProcessing(e){return this._commandService.onCommandExecuted(t=>{if(t.id!==r.SetFormulaCalculationNotificationMutation.id)return;let n=t.params;n.stageInfo!==void 0&&e(n.stageInfo)})}setMaxIteration(e){this._configService.setConfig(r.ENGINE_FORMULA_CYCLE_REFERENCE_COUNT,e)}executeFormulas(e,t=3e4){return new Promise((n,i)=>{let a=this._commandService.onCommandExecuted(e=>{if(e.id!==r.SetFormulaStringBatchCalculationResultMutation.id)return;let t=e.params;clearTimeout(o),a.dispose(),t.result==null?i(Error(`Formula batch calculation returned no result`)):n(t.result)}),o=setTimeout(()=>{a.dispose(),i(Error(`Formula batch calculation timeout`))},t);this._commandService.executeCommand(r.SetFormulaStringBatchCalculationMutation.id,{formulas:e},{onlyLocal:!0})})}getAllDependencyTrees(e=3e4){return new Promise((t,n)=>{let i=this._commandService.onCommandExecuted(e=>{if(e.id!==r.SetFormulaDependencyCalculationResultMutation.id)return;let n=e.params;clearTimeout(a),i.dispose(),n.result==null?t([]):t(n.result)}),a=setTimeout(()=>{i.dispose(),n(Error(`Formula dependency calculation timeout`))},e);this._commandService.executeCommand(r.SetFormulaDependencyCalculationMutation.id,void 0,{onlyLocal:!0})})}getCellDependencyTree(e,t=3e4){return new Promise((n,i)=>{let a=this._commandService.onCommandExecuted(e=>{if(e.id!==r.SetCellFormulaDependencyCalculationResultMutation.id)return;let t=e.params;clearTimeout(o),a.dispose(),n(t.result)}),o=setTimeout(()=>{a.dispose(),i(Error(`Cell dependency calculation timeout`))},t);this._commandService.executeCommand(r.SetCellFormulaDependencyCalculationMutation.id,e,{onlyLocal:!0})})}getRangeDependents(e,t=3e4){return new Promise((n,i)=>{let a=this._commandService.onCommandExecuted(e=>{if(e.id!==r.SetQueryFormulaDependencyResultMutation.id)return;let t=e.params;clearTimeout(o),a.dispose(),t.result==null?n([]):n(t.result)}),o=setTimeout(()=>{a.dispose(),i(Error(`Range dependents calculation timeout`))},t);this._commandService.executeCommand(r.SetQueryFormulaDependencyMutation.id,{unitRanges:e},{onlyLocal:!0})})}getInRangeFormulas(e,t=3e4){return new Promise((n,i)=>{let a=this._commandService.onCommandExecuted(e=>{if(e.id!==r.SetQueryFormulaDependencyResultMutation.id)return;let t=e.params;clearTimeout(o),a.dispose(),t.result==null?n([]):n(t.result)}),o=setTimeout(()=>{a.dispose(),i(Error(`In-range formulas calculation timeout`))},t);this._commandService.executeCommand(r.SetQueryFormulaDependencyMutation.id,{unitRanges:e,isInRange:!0},{onlyLocal:!0})})}setFormulaReturnDependencyTree(e){this._configService.setConfig(r.ENGINE_FORMULA_RETURN_DEPENDENCY_TREE,e)}getFormulaExpressTree(e,t){return this._lexerTreeBuilder.getFormulaExprTree(e,t,this._functionService.hasExecutor.bind(this._functionService),this._definedNamesService.getValueByName.bind(this._definedNamesService),this._superTableService.getTable.bind(this._superTableService))}getRangeDependentsAndInRangeFormulas(e,t=3e4){return new Promise((n,i)=>{let a=this._commandService.onCommandExecuted(e=>{if(e.id!==r.SetQueryFormulaDependencyAllResultMutation.id)return;let t=e.params;clearTimeout(o),a.dispose(),t.result==null?n({dependents:[],inRanges:[]}):n(t.result)}),o=setTimeout(()=>{a.dispose(),i(Error(`Range dependents calculation timeout`))},t);this._commandService.executeCommand(r.SetQueryFormulaDependencyAllMutation.id,{unitRanges:e},{onlyLocal:!0})})}};s=o([a(0,(0,n.Inject)(n.ICommandService)),a(1,(0,n.Inject)(n.Injector)),a(2,(0,n.Inject)(r.LexerTreeBuilder)),a(3,n.IConfigService),a(4,r.IFunctionService),a(5,r.IDefinedNamesService),a(6,r.ISuperTableService)],s);var c=class extends t.FUniver{getFormula(){return this._injector.createInstance(s)}};t.FUniver.extend(c),Object.defineProperty(e,`FFormula`,{enumerable:!0,get:function(){return s}})});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core/facade"),require("@univerjs/core"),require("@univerjs/engine-formula"),require("rxjs")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core/facade`,`@univerjs/core`,`@univerjs/engine-formula`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverEngineFormulaFacade={},e.UniverCoreFacade,e.UniverCore,e.UniverEngineFormula,e.rxjs))})(this,function(e,t,n,r,i){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function a(e,t){return function(n,r){t(n,r,e)}}function o(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let s=class extends t.FBase{constructor(e,t,n,r,i,a,o){super(),this._commandService=e,this._injector=t,this._lexerTreeBuilder=n,this._configService=r,this._functionService=i,this._definedNamesService=a,this._superTableService=o,this._initialize()}_initialize(){}get lexerTreeBuilder(){return this._lexerTreeBuilder}moveFormulaRefOffset(e,t,n,r){return this._lexerTreeBuilder.moveFormulaRefOffset(e,t,n,r)}sequenceNodesBuilder(e){return this._lexerTreeBuilder.sequenceNodesBuilder(e)||[]}executeCalculation(){this._commandService.executeCommand(r.SetTriggerFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})}stopCalculation(){this._commandService.executeCommand(r.SetFormulaCalculationStopMutation.id,{})}calculationStart(e){return this._commandService.onCommandExecuted(t=>{if(t.id===r.SetFormulaCalculationStartMutation.id){let n=t.params;e(n.forceCalculation)}})}calculationEnd(e){return this._commandService.onCommandExecuted(t=>{if(t.id!==r.SetFormulaCalculationNotificationMutation.id)return;let n=t.params;n.functionsExecutedState!==void 0&&e(n.functionsExecutedState)})}whenComputingCompleteAsync(e){let t=this._injector.get(r.GlobalComputingStatusService);return t.computingStatus?Promise.resolve(!0):(0,i.firstValueFrom)((0,i.race)(t.computingStatus$.pipe((0,i.filter)(e=>e)),(0,i.timer)(e==null?3e4:e).pipe((0,i.map)(()=>!1))))}onCalculationEnd(){return new Promise((e,t)=>{let n=setTimeout(()=>{t(Error(`Calculation end timeout`))},3e4),r=this.calculationEnd(()=>{clearTimeout(n),r.dispose(),e()})})}calculationProcessing(e){return this._commandService.onCommandExecuted(t=>{if(t.id!==r.SetFormulaCalculationNotificationMutation.id)return;let n=t.params;n.stageInfo!==void 0&&e(n.stageInfo)})}setMaxIteration(e){this._configService.setConfig(r.ENGINE_FORMULA_CYCLE_REFERENCE_COUNT,e)}executeFormulas(e,t=3e4){return new Promise((n,i)=>{let a=this._commandService.onCommandExecuted(e=>{if(e.id!==r.SetFormulaStringBatchCalculationResultMutation.id)return;let t=e.params;clearTimeout(o),a.dispose(),t.result==null?i(Error(`Formula batch calculation returned no result`)):n(t.result)}),o=setTimeout(()=>{a.dispose(),i(Error(`Formula batch calculation timeout`))},t);this._commandService.executeCommand(r.SetFormulaStringBatchCalculationMutation.id,{formulas:e},{onlyLocal:!0})})}getAllDependencyTrees(e=3e4){return new Promise((t,n)=>{let i=this._commandService.onCommandExecuted(e=>{if(e.id!==r.SetFormulaDependencyCalculationResultMutation.id)return;let n=e.params;clearTimeout(a),i.dispose(),n.result==null?t([]):t(n.result)}),a=setTimeout(()=>{i.dispose(),n(Error(`Formula dependency calculation timeout`))},e);this._commandService.executeCommand(r.SetFormulaDependencyCalculationMutation.id,void 0,{onlyLocal:!0})})}getCellDependencyTree(e,t=3e4){return new Promise((n,i)=>{let a=this._commandService.onCommandExecuted(e=>{if(e.id!==r.SetCellFormulaDependencyCalculationResultMutation.id)return;let t=e.params;clearTimeout(o),a.dispose(),n(t.result)}),o=setTimeout(()=>{a.dispose(),i(Error(`Cell dependency calculation timeout`))},t);this._commandService.executeCommand(r.SetCellFormulaDependencyCalculationMutation.id,e,{onlyLocal:!0})})}getRangeDependents(e,t=3e4){return new Promise((n,i)=>{let a=this._commandService.onCommandExecuted(e=>{if(e.id!==r.SetQueryFormulaDependencyResultMutation.id)return;let t=e.params;clearTimeout(o),a.dispose(),t.result==null?n([]):n(t.result)}),o=setTimeout(()=>{a.dispose(),i(Error(`Range dependents calculation timeout`))},t);this._commandService.executeCommand(r.SetQueryFormulaDependencyMutation.id,{unitRanges:e},{onlyLocal:!0})})}getInRangeFormulas(e,t=3e4){return new Promise((n,i)=>{let a=this._commandService.onCommandExecuted(e=>{if(e.id!==r.SetQueryFormulaDependencyResultMutation.id)return;let t=e.params;clearTimeout(o),a.dispose(),t.result==null?n([]):n(t.result)}),o=setTimeout(()=>{a.dispose(),i(Error(`In-range formulas calculation timeout`))},t);this._commandService.executeCommand(r.SetQueryFormulaDependencyMutation.id,{unitRanges:e,isInRange:!0},{onlyLocal:!0})})}setFormulaReturnDependencyTree(e){this._configService.setConfig(r.ENGINE_FORMULA_RETURN_DEPENDENCY_TREE,e)}getFormulaExpressTree(e,t){return this._lexerTreeBuilder.getFormulaExprTree(e,t,this._functionService.hasExecutor.bind(this._functionService),this._definedNamesService.getValueByName.bind(this._definedNamesService),this._superTableService.getTable.bind(this._superTableService))}getRangeDependentsAndInRangeFormulas(e,t=3e4){return new Promise((n,i)=>{let a=this._commandService.onCommandExecuted(e=>{if(e.id!==r.SetQueryFormulaDependencyAllResultMutation.id)return;let t=e.params;clearTimeout(o),a.dispose(),t.result==null?n({dependents:[],inRanges:[]}):n(t.result)}),o=setTimeout(()=>{a.dispose(),i(Error(`Range dependents calculation timeout`))},t);this._commandService.executeCommand(r.SetQueryFormulaDependencyAllMutation.id,{unitRanges:e},{onlyLocal:!0})})}};s=o([a(0,(0,n.Inject)(n.ICommandService)),a(1,(0,n.Inject)(n.Injector)),a(2,(0,n.Inject)(r.LexerTreeBuilder)),a(3,n.IConfigService),a(4,r.IFunctionService),a(5,r.IDefinedNamesService),a(6,r.ISuperTableService)],s);var c=class extends t.FUniver{getFormula(){return this._injector.createInstance(s)}};t.FUniver.extend(c),Object.defineProperty(e,"FFormula",{enumerable:!0,get:function(){return s}})});