@univerjs/engine-formula 0.25.1 → 0.25.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.
package/lib/index.js CHANGED
@@ -1456,11 +1456,11 @@ function isReferenceString(refString) {
1456
1456
  //#endregion
1457
1457
  //#region src/basics/runtime.ts
1458
1458
  function convertUnitDataToRuntime(unitData) {
1459
- const arrayFormulaCellData = {};
1459
+ const arrayFormulaCellData = Object.create(null);
1460
1460
  Object.keys(unitData).forEach((unitId) => {
1461
1461
  const sheetData = unitData[unitId];
1462
1462
  if (sheetData == null) return true;
1463
- if (arrayFormulaCellData[unitId] == null) arrayFormulaCellData[unitId] = {};
1463
+ if (arrayFormulaCellData[unitId] == null) arrayFormulaCellData[unitId] = Object.create(null);
1464
1464
  Object.keys(sheetData).forEach((sheetId) => {
1465
1465
  const cellData = sheetData[sheetId];
1466
1466
  arrayFormulaCellData[unitId][sheetId] = new ObjectMatrix(cellData);
@@ -1469,16 +1469,16 @@ function convertUnitDataToRuntime(unitData) {
1469
1469
  return arrayFormulaCellData;
1470
1470
  }
1471
1471
  function convertRuntimeToUnitData(unitData) {
1472
- const unitPrimitiveData = {};
1473
- for (const unitId in unitData) {
1472
+ const unitPrimitiveData = Object.create(null);
1473
+ for (const unitId of Object.keys(unitData)) {
1474
1474
  const sheetData = unitData[unitId];
1475
1475
  if (sheetData == null) continue;
1476
- if (unitPrimitiveData[unitId] == null) unitPrimitiveData[unitId] = {};
1477
- for (const sheetId in sheetData) {
1476
+ if (unitPrimitiveData[unitId] == null) unitPrimitiveData[unitId] = Object.create(null);
1477
+ for (const sheetId of Object.keys(sheetData)) {
1478
1478
  const cellData = sheetData[sheetId];
1479
- const primitiveData = {};
1479
+ const primitiveData = Object.create(null);
1480
1480
  cellData.forValue((row, column, value) => {
1481
- if (primitiveData[row] === void 0) primitiveData[row] = {};
1481
+ if (primitiveData[row] === void 0) primitiveData[row] = Object.create(null);
1482
1482
  primitiveData[row][column] = value;
1483
1483
  });
1484
1484
  unitPrimitiveData[unitId][sheetId] = primitiveData;
@@ -1486,6 +1486,12 @@ function convertRuntimeToUnitData(unitData) {
1486
1486
  }
1487
1487
  return unitPrimitiveData;
1488
1488
  }
1489
+ /** Copy the unit and sheet dictionaries without retaining inherited identifier keys. */
1490
+ function copyUnitData(data) {
1491
+ const result = Object.create(null);
1492
+ for (const unitId of Object.keys(data)) if (data[unitId] != null) result[unitId] = Object.assign(Object.create(null), data[unitId]);
1493
+ return result;
1494
+ }
1489
1495
 
1490
1496
  //#endregion
1491
1497
  //#region src/basics/token-type.ts
@@ -1869,8 +1875,8 @@ let DefinedNamesService = class DefinedNamesService extends Disposable {
1869
1875
  constructor(_univerInstanceService) {
1870
1876
  super();
1871
1877
  this._univerInstanceService = _univerInstanceService;
1872
- _defineProperty(this, "_definedNameMap", {});
1873
- _defineProperty(this, "_nameCacheMap", {});
1878
+ _defineProperty(this, "_definedNameMap", Object.create(null));
1879
+ _defineProperty(this, "_nameCacheMap", Object.create(null));
1874
1880
  _defineProperty(this, "_definedNamesIsEmpty", true);
1875
1881
  _defineProperty(this, "_update$", new Subject());
1876
1882
  _defineProperty(this, "update$", this._update$.asObservable());
@@ -1891,8 +1897,8 @@ let DefinedNamesService = class DefinedNamesService extends Disposable {
1891
1897
  }
1892
1898
  dispose() {
1893
1899
  super.dispose();
1894
- this._definedNameMap = {};
1895
- this._nameCacheMap = {};
1900
+ this._definedNameMap = Object.create(null);
1901
+ this._nameCacheMap = Object.create(null);
1896
1902
  this._update$.complete();
1897
1903
  this._currentRange$.complete();
1898
1904
  this._focusRange$.complete();
@@ -1921,7 +1927,7 @@ let DefinedNamesService = class DefinedNamesService extends Disposable {
1921
1927
  return serializeRange(this._currentRange.range);
1922
1928
  }
1923
1929
  registerDefinedNames(unitId, params) {
1924
- this._definedNameMap[unitId] = params;
1930
+ this._definedNameMap[unitId] = Object.assign(Object.create(null), params);
1925
1931
  this._updateCache(unitId);
1926
1932
  const definedNames = Object.values(params);
1927
1933
  this._update({
@@ -1932,7 +1938,7 @@ let DefinedNamesService = class DefinedNamesService extends Disposable {
1932
1938
  if (definedNames.length > 0) this._definedNamesIsEmpty = false;
1933
1939
  }
1934
1940
  registerDefinedName(unitId, param) {
1935
- if (this._definedNameMap[unitId] === void 0) this._definedNameMap[unitId] = {};
1941
+ if (this._definedNameMap[unitId] === void 0) this._definedNameMap[unitId] = Object.create(null);
1936
1942
  this._definedNameMap[unitId][param.id] = param;
1937
1943
  this._updateCache(unitId);
1938
1944
  this._update({
@@ -2013,7 +2019,7 @@ let DefinedNamesService = class DefinedNamesService extends Disposable {
2013
2019
  delete this._nameCacheMap[unitId];
2014
2020
  return;
2015
2021
  }
2016
- this._nameCacheMap[unitId] = {};
2022
+ this._nameCacheMap[unitId] = Object.create(null);
2017
2023
  for (const item of Object.values(nameMap)) this._nameCacheMap[unitId][item.name.toLowerCase()] = item;
2018
2024
  }
2019
2025
  _isDeepDefinedNameMapEmpty() {
@@ -4842,15 +4848,15 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
4842
4848
  super();
4843
4849
  this._univerInstanceService = _univerInstanceService;
4844
4850
  this._lexerTreeBuilder = _lexerTreeBuilder;
4845
- _defineProperty(this, "_arrayFormulaRange", {});
4846
- _defineProperty(this, "_arrayFormulaCellData", {});
4847
- _defineProperty(this, "_unitImageFormulaData", {});
4851
+ _defineProperty(this, "_arrayFormulaRange", Object.create(null));
4852
+ _defineProperty(this, "_arrayFormulaCellData", Object.create(null));
4853
+ _defineProperty(this, "_unitImageFormulaData", Object.create(null));
4848
4854
  }
4849
4855
  dispose() {
4850
4856
  super.dispose();
4851
- this._arrayFormulaRange = {};
4852
- this._arrayFormulaCellData = {};
4853
- this._unitImageFormulaData = {};
4857
+ this._arrayFormulaRange = Object.create(null);
4858
+ this._arrayFormulaCellData = Object.create(null);
4859
+ this._unitImageFormulaData = Object.create(null);
4854
4860
  }
4855
4861
  clearPreviousArrayFormulaCellData(clearArrayFormulaCellData) {
4856
4862
  Object.keys(clearArrayFormulaCellData).forEach((unitId) => {
@@ -4882,8 +4888,8 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
4882
4888
  Object.keys(unitData).forEach((unitId) => {
4883
4889
  const sheetData = unitData[unitId];
4884
4890
  if (sheetData == null) return true;
4885
- if (this._arrayFormulaRange[unitId] == null) this._arrayFormulaRange[unitId] = {};
4886
- if (this._arrayFormulaCellData[unitId] == null) this._arrayFormulaCellData[unitId] = {};
4891
+ if (this._arrayFormulaRange[unitId] == null) this._arrayFormulaRange[unitId] = Object.create(null);
4892
+ if (this._arrayFormulaCellData[unitId] == null) this._arrayFormulaCellData[unitId] = Object.create(null);
4887
4893
  Object.keys(sheetData).forEach((sheetId) => {
4888
4894
  var _this$_arrayFormulaRa2, _this$_arrayFormulaCe3;
4889
4895
  const cellMatrixData = sheetData[sheetId];
@@ -4907,12 +4913,12 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
4907
4913
  });
4908
4914
  }
4909
4915
  getFormulaData() {
4910
- const formulaData = {};
4916
+ const formulaData = Object.create(null);
4911
4917
  const allSheets = this._univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET);
4912
4918
  if (allSheets.length === 0) return formulaData;
4913
4919
  allSheets.forEach((workbook) => {
4914
4920
  const unitId = workbook.getUnitId();
4915
- formulaData[unitId] = {};
4921
+ formulaData[unitId] = Object.create(null);
4916
4922
  workbook.getSheets().forEach((worksheet) => {
4917
4923
  const cellMatrix = worksheet.getCellMatrix();
4918
4924
  initSheetFormulaData(formulaData, unitId, worksheet.getSheetId(), cellMatrix);
@@ -4921,10 +4927,10 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
4921
4927
  return formulaData;
4922
4928
  }
4923
4929
  getSheetFormulaData(unitId, sheetId) {
4924
- const formulaData = {};
4930
+ const formulaData = Object.create(null);
4925
4931
  const workbook = this._univerInstanceService.getUnit(unitId);
4926
4932
  if (workbook == null) return {};
4927
- formulaData[unitId] = {};
4933
+ formulaData[unitId] = Object.create(null);
4928
4934
  const worksheet = workbook.getSheetBySheetId(sheetId);
4929
4935
  if (worksheet == null) return {};
4930
4936
  initSheetFormulaData(formulaData, unitId, sheetId, worksheet.getCellMatrix());
@@ -4934,25 +4940,25 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
4934
4940
  return this._arrayFormulaRange;
4935
4941
  }
4936
4942
  setArrayFormulaRange(value) {
4937
- this._arrayFormulaRange = value;
4943
+ this._arrayFormulaRange = copyUnitData(value);
4938
4944
  }
4939
4945
  getArrayFormulaCellData() {
4940
4946
  return this._arrayFormulaCellData;
4941
4947
  }
4942
4948
  setArrayFormulaCellData(value) {
4943
- this._arrayFormulaCellData = value;
4949
+ this._arrayFormulaCellData = copyUnitData(value);
4944
4950
  }
4945
4951
  getUnitImageFormulaData() {
4946
4952
  return this._unitImageFormulaData;
4947
4953
  }
4948
4954
  setUnitImageFormulaData(value) {
4949
- this._unitImageFormulaData = value;
4955
+ this._unitImageFormulaData = copyUnitData(value);
4950
4956
  }
4951
4957
  mergeArrayFormulaRange(formulaData) {
4952
4958
  Object.keys(formulaData).forEach((unitId) => {
4953
4959
  const sheetData = formulaData[unitId];
4954
4960
  if (sheetData == null) return true;
4955
- if (!this._arrayFormulaRange[unitId]) this._arrayFormulaRange[unitId] = {};
4961
+ if (!this._arrayFormulaRange[unitId]) this._arrayFormulaRange[unitId] = Object.create(null);
4956
4962
  Object.keys(sheetData).forEach((sheetId) => {
4957
4963
  var _this$_arrayFormulaRa3;
4958
4964
  const arrayFormula = new ObjectMatrix(sheetData[sheetId]);
@@ -4970,7 +4976,7 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
4970
4976
  const unitId = unitIds[i];
4971
4977
  const sheetData = formulaData[unitId];
4972
4978
  if (!sheetData) continue;
4973
- if (!this._unitImageFormulaData[unitId]) this._unitImageFormulaData[unitId] = {};
4979
+ if (!this._unitImageFormulaData[unitId]) this._unitImageFormulaData[unitId] = Object.create(null);
4974
4980
  const sheetIds = Object.keys(sheetData);
4975
4981
  for (let j = 0; j < sheetIds.length; j++) {
4976
4982
  const sheetId = sheetIds[j];
@@ -4995,14 +5001,14 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
4995
5001
  }
4996
5002
  getCalculateData() {
4997
5003
  const unitAllSheet = this._univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET);
4998
- const allUnitData = {};
4999
- const unitStylesData = {};
5000
- const unitSheetNameMap = {};
5004
+ const allUnitData = Object.create(null);
5005
+ const unitStylesData = Object.create(null);
5006
+ const unitSheetNameMap = Object.create(null);
5001
5007
  for (const workbook of unitAllSheet) {
5002
5008
  const unitId = workbook.getUnitId();
5003
5009
  const sheets = workbook.getSheets();
5004
- const sheetData = {};
5005
- const sheetNameMap = {};
5010
+ const sheetData = Object.create(null);
5011
+ const sheetNameMap = Object.create(null);
5006
5012
  for (const sheet of sheets) {
5007
5013
  const sheetId = sheet.getSheetId();
5008
5014
  const sheetConfig = sheet.getConfig();
@@ -5034,17 +5040,17 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
5034
5040
  */
5035
5041
  getHiddenRowsFiltered() {
5036
5042
  const unitAllSheet = this._univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET);
5037
- const rowData = {};
5043
+ const rowData = Object.create(null);
5038
5044
  for (const workbook of unitAllSheet) {
5039
5045
  const unitId = workbook.getUnitId();
5040
5046
  const sheets = workbook.getSheets();
5041
- rowData[unitId] = {};
5047
+ rowData[unitId] = Object.create(null);
5042
5048
  for (const sheet of sheets) {
5043
5049
  const sheetId = sheet.getSheetId();
5044
- rowData[unitId][sheetId] = {};
5050
+ rowData[unitId][sheetId] = Object.create(null);
5045
5051
  const startRow = 0;
5046
5052
  const endRow = sheet.getRowCount() - 1;
5047
- const sheetRowData = {};
5053
+ const sheetRowData = Object.create(null);
5048
5054
  for (let i = startRow; i <= endRow; i++) if (!sheet.getRowVisible(i)) sheetRowData[i] = { hd: BooleanNumber.TRUE };
5049
5055
  rowData[unitId][sheetId] = sheetRowData;
5050
5056
  }
@@ -5056,9 +5062,9 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
5056
5062
  const formulaIdMap = this._getSheetFormulaIdMap(unitId, sheetId);
5057
5063
  const deleteFormulaIdMap = /* @__PURE__ */ new Map();
5058
5064
  const formulaData = this.getFormulaData();
5059
- if (formulaData[unitId] == null) formulaData[unitId] = {};
5065
+ if (formulaData[unitId] == null) formulaData[unitId] = Object.create(null);
5060
5066
  const workbookFormulaData = formulaData[unitId];
5061
- if (workbookFormulaData[sheetId] == null) workbookFormulaData[sheetId] = {};
5067
+ if (workbookFormulaData[sheetId] == null) workbookFormulaData[sheetId] = Object.create(null);
5062
5068
  const sheetFormulaDataMatrix = new ObjectMatrix(workbookFormulaData[sheetId] || {});
5063
5069
  const newSheetFormulaDataMatrix = new ObjectMatrix();
5064
5070
  cellMatrix.forValue((r, c, cell) => {
@@ -5204,7 +5210,7 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
5204
5210
  if (!sheet) continue;
5205
5211
  const sheetInstance = workbookInstance.getSheetBySheetId(sheetId);
5206
5212
  if (!sheetInstance) continue;
5207
- const columnRanges = {};
5213
+ const columnRanges = Object.create(null);
5208
5214
  for (const rowStr of Object.keys(sheet)) {
5209
5215
  const row = Number(rowStr);
5210
5216
  for (const columnStr in sheet[row]) {
@@ -5244,7 +5250,7 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
5244
5250
  return dirtyRanges;
5245
5251
  }
5246
5252
  _getSheetFormulaIdMap(unitId, sheetId) {
5247
- const formulaIdMap = {};
5253
+ const formulaIdMap = Object.create(null);
5248
5254
  const workbook = this._univerInstanceService.getUnit(unitId);
5249
5255
  if (workbook == null) return formulaIdMap;
5250
5256
  const worksheet = workbook.getSheetBySheetId(sheetId);
@@ -5263,10 +5269,16 @@ let FormulaDataModel = class FormulaDataModel extends Disposable {
5263
5269
  };
5264
5270
  FormulaDataModel = __decorate([__decorateParam(0, IUniverInstanceService), __decorateParam(1, Inject(LexerTreeBuilder))], FormulaDataModel);
5265
5271
  function initSheetFormulaData(formulaData, unitId, sheetId, cellMatrix) {
5266
- if (!formulaData[unitId]) formulaData[unitId] = {};
5267
- if (!formulaData[unitId][sheetId]) formulaData[unitId][sheetId] = {};
5272
+ const unitData = Object.assign(Object.create(null), Object.prototype.hasOwnProperty.call(formulaData, unitId) ? formulaData[unitId] : void 0);
5273
+ Object.defineProperty(formulaData, unitId, {
5274
+ value: unitData,
5275
+ writable: true,
5276
+ configurable: true,
5277
+ enumerable: true
5278
+ });
5279
+ if (!unitData[sheetId]) unitData[sheetId] = Object.create(null);
5268
5280
  const formulaIdMap = /* @__PURE__ */ new Map();
5269
- const sheetFormulaDataMatrix = new ObjectMatrix(formulaData[unitId][sheetId]);
5281
+ const sheetFormulaDataMatrix = new ObjectMatrix(unitData[sheetId]);
5270
5282
  cellMatrix.forValue((r, c, cell) => {
5271
5283
  const formulaString = (cell === null || cell === void 0 ? void 0 : cell.f) || "";
5272
5284
  const formulaId = (cell === null || cell === void 0 ? void 0 : cell.si) || "";
@@ -5352,42 +5364,42 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends Disp
5352
5364
  this._localeService = _localeService;
5353
5365
  this._formulaDataModel = _formulaDataModel;
5354
5366
  this._sheetRowFilteredService = _sheetRowFilteredService;
5355
- _defineProperty(this, "_unitData", {});
5356
- _defineProperty(this, "_unitStylesData", {});
5357
- _defineProperty(this, "_arrayFormulaCellData", {});
5358
- _defineProperty(this, "_arrayFormulaRange", {});
5359
- _defineProperty(this, "_formulaData", {});
5360
- _defineProperty(this, "_sheetNameMap", {});
5367
+ _defineProperty(this, "_unitData", Object.create(null));
5368
+ _defineProperty(this, "_unitStylesData", Object.create(null));
5369
+ _defineProperty(this, "_arrayFormulaCellData", Object.create(null));
5370
+ _defineProperty(this, "_arrayFormulaRange", Object.create(null));
5371
+ _defineProperty(this, "_formulaData", Object.create(null));
5372
+ _defineProperty(this, "_sheetNameMap", Object.create(null));
5361
5373
  _defineProperty(this, "_forceCalculate", false);
5362
- _defineProperty(this, "_clearDependencyTreeCache", {});
5374
+ _defineProperty(this, "_clearDependencyTreeCache", Object.create(null));
5363
5375
  _defineProperty(this, "_dirtyRanges", []);
5364
- _defineProperty(this, "_dirtyNameMap", {});
5365
- _defineProperty(this, "_dirtyDefinedNameMap", {});
5366
- _defineProperty(this, "_dirtySuperTableMap", {});
5367
- _defineProperty(this, "_dirtyUnitFeatureMap", {});
5368
- _defineProperty(this, "_dirtyUnitOtherFormulaMap", {});
5376
+ _defineProperty(this, "_dirtyNameMap", Object.create(null));
5377
+ _defineProperty(this, "_dirtyDefinedNameMap", Object.create(null));
5378
+ _defineProperty(this, "_dirtySuperTableMap", Object.create(null));
5379
+ _defineProperty(this, "_dirtyUnitFeatureMap", Object.create(null));
5380
+ _defineProperty(this, "_dirtyUnitOtherFormulaMap", Object.create(null));
5369
5381
  _defineProperty(this, "_excludedCell", void 0);
5370
- _defineProperty(this, "_sheetIdToNameMap", {});
5382
+ _defineProperty(this, "_sheetIdToNameMap", Object.create(null));
5371
5383
  _defineProperty(this, "_executeUnitId", "");
5372
5384
  _defineProperty(this, "_executeSubUnitId", "");
5373
5385
  }
5374
5386
  dispose() {
5375
5387
  super.dispose();
5376
- this._unitData = {};
5377
- this._unitStylesData = {};
5378
- this._arrayFormulaCellData = {};
5379
- this._arrayFormulaRange = {};
5380
- this._formulaData = {};
5381
- this._sheetNameMap = {};
5382
- this._clearDependencyTreeCache = {};
5388
+ this._unitData = Object.create(null);
5389
+ this._unitStylesData = Object.create(null);
5390
+ this._arrayFormulaCellData = Object.create(null);
5391
+ this._arrayFormulaRange = Object.create(null);
5392
+ this._formulaData = Object.create(null);
5393
+ this._sheetNameMap = Object.create(null);
5394
+ this._clearDependencyTreeCache = Object.create(null);
5383
5395
  this._dirtyRanges = [];
5384
- this._dirtyNameMap = {};
5385
- this._dirtyDefinedNameMap = {};
5386
- this._dirtySuperTableMap = {};
5387
- this._dirtyUnitFeatureMap = {};
5388
- this._dirtyUnitOtherFormulaMap = {};
5389
- this._excludedCell = {};
5390
- this._sheetIdToNameMap = {};
5396
+ this._dirtyNameMap = Object.create(null);
5397
+ this._dirtyDefinedNameMap = Object.create(null);
5398
+ this._dirtySuperTableMap = Object.create(null);
5399
+ this._dirtyUnitFeatureMap = Object.create(null);
5400
+ this._dirtyUnitOtherFormulaMap = Object.create(null);
5401
+ this._excludedCell = Object.create(null);
5402
+ this._sheetIdToNameMap = Object.create(null);
5391
5403
  }
5392
5404
  getExecuteUnitId() {
5393
5405
  return this._executeUnitId;
@@ -5448,7 +5460,7 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends Disp
5448
5460
  return this._sheetIdToNameMap[unitId][sheetId] || "";
5449
5461
  }
5450
5462
  setSheetNameMap(sheetIdToNameMap) {
5451
- this._sheetIdToNameMap = sheetIdToNameMap;
5463
+ this._sheetIdToNameMap = copyUnitData(sheetIdToNameMap);
5452
5464
  }
5453
5465
  getClearDependencyTreeCache() {
5454
5466
  return this._clearDependencyTreeCache;
@@ -5484,14 +5496,14 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends Disp
5484
5496
  }
5485
5497
  load(config) {
5486
5498
  if (config.allUnitData && config.unitSheetNameMap && config.unitStylesData) {
5487
- this._unitData = config.allUnitData;
5499
+ this._unitData = copyUnitData(config.allUnitData);
5488
5500
  this._unitStylesData = config.unitStylesData;
5489
- this._sheetNameMap = config.unitSheetNameMap;
5501
+ this._sheetNameMap = copyUnitData(config.unitSheetNameMap);
5490
5502
  } else {
5491
5503
  const { allUnitData, unitSheetNameMap, unitStylesData } = this._loadSheetData();
5492
- this._unitData = allUnitData;
5504
+ this._unitData = copyUnitData(allUnitData);
5493
5505
  this._unitStylesData = unitStylesData;
5494
- this._sheetNameMap = unitSheetNameMap;
5506
+ this._sheetNameMap = copyUnitData(unitSheetNameMap);
5495
5507
  }
5496
5508
  if (config.rowData) this._applyUnitRowData(config.rowData);
5497
5509
  this._formulaData = config.formulaData;
@@ -5510,9 +5522,9 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends Disp
5510
5522
  }
5511
5523
  loadDataLite(rowData) {
5512
5524
  const { allUnitData, unitSheetNameMap, unitStylesData } = this._loadSheetData();
5513
- this._unitData = allUnitData;
5525
+ this._unitData = copyUnitData(allUnitData);
5514
5526
  this._unitStylesData = unitStylesData;
5515
- this._sheetNameMap = unitSheetNameMap;
5527
+ this._sheetNameMap = copyUnitData(unitSheetNameMap);
5516
5528
  this._formulaData = this._formulaDataModel.getFormulaData();
5517
5529
  this._arrayFormulaCellData = convertUnitDataToRuntime(this._formulaDataModel.getArrayFormulaCellData());
5518
5530
  this._arrayFormulaRange = this._formulaDataModel.getArrayFormulaRange();
@@ -5536,28 +5548,28 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends Disp
5536
5548
  /**
5537
5549
  * Mark dirty for expansion of array formulas, need to clear the worksheet's dirty flag.
5538
5550
  */
5539
- this._dirtyNameMap = {};
5551
+ this._dirtyNameMap = Object.create(null);
5540
5552
  }
5541
5553
  registerUnitData(unitData) {
5542
- this._unitData = unitData;
5554
+ this._unitData = copyUnitData(unitData);
5543
5555
  }
5544
5556
  registerFormulaData(formulaData) {
5545
5557
  this._formulaData = formulaData;
5546
5558
  }
5547
5559
  registerSheetNameMap(sheetNameMap) {
5548
- this._sheetNameMap = sheetNameMap;
5560
+ this._sheetNameMap = copyUnitData(sheetNameMap);
5549
5561
  }
5550
5562
  _mergeNameMap(unitSheetNameMap, dirtyNameMap) {
5551
5563
  Object.keys(dirtyNameMap).forEach((unitId) => {
5552
5564
  if (dirtyNameMap[unitId]) Object.keys(dirtyNameMap[unitId]).forEach((sheetId) => {
5553
- if (unitSheetNameMap[unitId] == null) unitSheetNameMap[unitId] = {};
5565
+ if (unitSheetNameMap[unitId] == null) unitSheetNameMap[unitId] = Object.create(null);
5554
5566
  unitSheetNameMap[unitId][dirtyNameMap[unitId][sheetId]] = sheetId;
5555
5567
  });
5556
5568
  });
5557
- this._sheetIdToNameMap = {};
5569
+ this._sheetIdToNameMap = Object.create(null);
5558
5570
  Object.keys(unitSheetNameMap).forEach((unitId) => {
5559
5571
  Object.keys(unitSheetNameMap[unitId]).forEach((sheetName) => {
5560
- if (this._sheetIdToNameMap[unitId] == null) this._sheetIdToNameMap[unitId] = {};
5572
+ if (this._sheetIdToNameMap[unitId] == null) this._sheetIdToNameMap[unitId] = Object.create(null);
5561
5573
  this._sheetIdToNameMap[unitId][unitSheetNameMap[unitId][sheetName]] = sheetName;
5562
5574
  });
5563
5575
  });
@@ -5574,11 +5586,11 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends Disp
5574
5586
  * @param rowData
5575
5587
  */
5576
5588
  _applyUnitRowData(rowData) {
5577
- for (const unitId in rowData) {
5589
+ for (const unitId of Object.keys(rowData)) {
5578
5590
  if (rowData[unitId] == null) continue;
5579
- for (const sheetId in rowData[unitId]) {
5591
+ for (const sheetId of Object.keys(rowData[unitId])) {
5580
5592
  if (rowData[unitId][sheetId] == null) continue;
5581
- if (this._unitData[unitId] == null) this._unitData[unitId] = {};
5593
+ if (this._unitData[unitId] == null) this._unitData[unitId] = Object.create(null);
5582
5594
  if (this._unitData[unitId][sheetId] == null) this._unitData[unitId][sheetId] = {
5583
5595
  cellData: new ObjectMatrix({}),
5584
5596
  rowCount: 0,
@@ -9283,14 +9295,14 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
9283
9295
  _defineProperty(this, "_currentColumnCount", Number.NEGATIVE_INFINITY);
9284
9296
  _defineProperty(this, "_currentSubUnitId", "");
9285
9297
  _defineProperty(this, "_currentUnitId", "");
9286
- _defineProperty(this, "_runtimeData", {});
9287
- _defineProperty(this, "_runtimeOtherData", {});
9288
- _defineProperty(this, "_unitArrayFormulaRange", {});
9289
- _defineProperty(this, "_unitArrayFormulaEmbeddedMap", {});
9290
- _defineProperty(this, "_runtimeArrayFormulaCellData", {});
9291
- _defineProperty(this, "_runtimeClearArrayFormulaCellData", {});
9292
- _defineProperty(this, "_runtimeFeatureRange", {});
9293
- _defineProperty(this, "_runtimeFeatureCellData", {});
9298
+ _defineProperty(this, "_runtimeData", Object.create(null));
9299
+ _defineProperty(this, "_runtimeOtherData", Object.create(null));
9300
+ _defineProperty(this, "_unitArrayFormulaRange", Object.create(null));
9301
+ _defineProperty(this, "_unitArrayFormulaEmbeddedMap", Object.create(null));
9302
+ _defineProperty(this, "_runtimeArrayFormulaCellData", Object.create(null));
9303
+ _defineProperty(this, "_runtimeClearArrayFormulaCellData", Object.create(null));
9304
+ _defineProperty(this, "_runtimeFeatureRange", Object.create(null));
9305
+ _defineProperty(this, "_runtimeFeatureCellData", Object.create(null));
9294
9306
  _defineProperty(this, "_runtimeImageFormulaData", []);
9295
9307
  _defineProperty(this, "_functionsExecutedState", 0);
9296
9308
  _defineProperty(this, "_functionDefinitionPrivacyVar", /* @__PURE__ */ new Map());
@@ -9323,8 +9335,8 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
9323
9335
  dispose() {
9324
9336
  super.dispose();
9325
9337
  this.reset();
9326
- this._runtimeFeatureCellData = {};
9327
- this._runtimeFeatureRange = {};
9338
+ this._runtimeFeatureCellData = Object.create(null);
9339
+ this._runtimeFeatureRange = Object.create(null);
9328
9340
  this.clearReferenceAndNumberformatCache();
9329
9341
  }
9330
9342
  enableCycleDependency() {
@@ -9393,12 +9405,12 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
9393
9405
  }
9394
9406
  reset() {
9395
9407
  this._formulaExecuteStage = 0;
9396
- this._runtimeData = {};
9397
- this._runtimeOtherData = {};
9398
- this._unitArrayFormulaRange = {};
9399
- this._unitArrayFormulaEmbeddedMap = {};
9400
- this._runtimeArrayFormulaCellData = {};
9401
- this._runtimeClearArrayFormulaCellData = {};
9408
+ this._runtimeData = Object.create(null);
9409
+ this._runtimeOtherData = Object.create(null);
9410
+ this._unitArrayFormulaRange = Object.create(null);
9411
+ this._unitArrayFormulaEmbeddedMap = Object.create(null);
9412
+ this._runtimeArrayFormulaCellData = Object.create(null);
9413
+ this._runtimeClearArrayFormulaCellData = Object.create(null);
9402
9414
  this._runtimeImageFormulaData = [];
9403
9415
  this._functionDefinitionPrivacyVar.clear();
9404
9416
  this.markedAsInitialFunctionsExecuted();
@@ -9433,9 +9445,9 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
9433
9445
  setRuntimeOtherData(formulaId, x, y, functionVariant) {
9434
9446
  const subUnitId = this._currentSubUnitId;
9435
9447
  const unitId = this._currentUnitId;
9436
- if (this._runtimeOtherData[unitId] === void 0) this._runtimeOtherData[unitId] = {};
9448
+ if (this._runtimeOtherData[unitId] === void 0) this._runtimeOtherData[unitId] = Object.create(null);
9437
9449
  const unitData = this._runtimeOtherData[unitId];
9438
- if (unitData[subUnitId] === void 0 || unitData[subUnitId] === null) unitData[subUnitId] = {};
9450
+ if (unitData[subUnitId] === void 0 || unitData[subUnitId] === null) unitData[subUnitId] = Object.create(null);
9439
9451
  const subComponentData = unitData[subUnitId];
9440
9452
  let cellDatas = [];
9441
9453
  if (functionVariant.isReferenceObject() || functionVariant.isValueObject() && functionVariant.isArray()) {
@@ -9449,8 +9461,8 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
9449
9461
  cellDatas[row][column] = value;
9450
9462
  });
9451
9463
  } else cellDatas = [[this._getValueObjectOfRuntimeData(functionVariant)]];
9452
- if (subComponentData[formulaId] === void 0 || subComponentData[formulaId] === null) subComponentData[formulaId] = {};
9453
- if (subComponentData[formulaId][y] === void 0 || subComponentData[formulaId][y] === null) subComponentData[formulaId][y] = {};
9464
+ if (subComponentData[formulaId] === void 0 || subComponentData[formulaId] === null) subComponentData[formulaId] = Object.create(null);
9465
+ if (subComponentData[formulaId][y] === void 0 || subComponentData[formulaId][y] === null) subComponentData[formulaId][y] = Object.create(null);
9454
9466
  subComponentData[formulaId][y][x] = cellDatas;
9455
9467
  }
9456
9468
  setRuntimeData(functionVariant) {
@@ -9460,19 +9472,19 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
9460
9472
  const columnCount = this.currentColumnCount;
9461
9473
  const sheetId = this._currentSubUnitId;
9462
9474
  const unitId = this._currentUnitId;
9463
- if (this._runtimeData[unitId] == null) this._runtimeData[unitId] = {};
9475
+ if (this._runtimeData[unitId] == null) this._runtimeData[unitId] = Object.create(null);
9464
9476
  const unitData = this._runtimeData[unitId];
9465
9477
  if (unitData[sheetId] == null) unitData[sheetId] = new ObjectMatrix();
9466
9478
  const sheetData = unitData[sheetId];
9467
- if (this._unitArrayFormulaRange[unitId] == null) this._unitArrayFormulaRange[unitId] = {};
9479
+ if (this._unitArrayFormulaRange[unitId] == null) this._unitArrayFormulaRange[unitId] = Object.create(null);
9468
9480
  const arrayFormulaRange = this._unitArrayFormulaRange[unitId];
9469
- if (arrayFormulaRange[sheetId] === null || arrayFormulaRange[sheetId] === void 0) arrayFormulaRange[sheetId] = {};
9481
+ if (arrayFormulaRange[sheetId] === null || arrayFormulaRange[sheetId] === void 0) arrayFormulaRange[sheetId] = Object.create(null);
9470
9482
  const arrayData = new ObjectMatrix(arrayFormulaRange[sheetId]);
9471
- if (this._runtimeArrayFormulaCellData[unitId] === void 0) this._runtimeArrayFormulaCellData[unitId] = {};
9483
+ if (this._runtimeArrayFormulaCellData[unitId] === void 0) this._runtimeArrayFormulaCellData[unitId] = Object.create(null);
9472
9484
  const runtimeArrayFormulaCellData = this._runtimeArrayFormulaCellData[unitId];
9473
9485
  if (runtimeArrayFormulaCellData[sheetId] == null) runtimeArrayFormulaCellData[sheetId] = new ObjectMatrix();
9474
9486
  const runtimeArrayUnitData = runtimeArrayFormulaCellData[sheetId];
9475
- if (this._runtimeClearArrayFormulaCellData[unitId] === void 0) this._runtimeClearArrayFormulaCellData[unitId] = {};
9487
+ if (this._runtimeClearArrayFormulaCellData[unitId] === void 0) this._runtimeClearArrayFormulaCellData[unitId] = Object.create(null);
9476
9488
  const clearArrayFormulaCellData = this._runtimeClearArrayFormulaCellData[unitId];
9477
9489
  if (clearArrayFormulaCellData[sheetId] == null) clearArrayFormulaCellData[sheetId] = new ObjectMatrix();
9478
9490
  const clearArrayUnitData = clearArrayFormulaCellData[sheetId];
@@ -9585,9 +9597,9 @@ let FormulaRuntimeService = class FormulaRuntimeService extends Disposable {
9585
9597
  const rowIndex = this._currentRow;
9586
9598
  const columnIndex = this._currentColumn;
9587
9599
  const arrayFormulaEmbeddedMap = this._unitArrayFormulaEmbeddedMap;
9588
- if (arrayFormulaEmbeddedMap[unitId] == null) arrayFormulaEmbeddedMap[unitId] = {};
9589
- if (arrayFormulaEmbeddedMap[unitId][sheetId] == null) arrayFormulaEmbeddedMap[unitId][sheetId] = {};
9590
- if (arrayFormulaEmbeddedMap[unitId][sheetId][rowIndex] == null) arrayFormulaEmbeddedMap[unitId][sheetId][rowIndex] = {};
9600
+ if (arrayFormulaEmbeddedMap[unitId] == null) arrayFormulaEmbeddedMap[unitId] = Object.create(null);
9601
+ if (arrayFormulaEmbeddedMap[unitId][sheetId] == null) arrayFormulaEmbeddedMap[unitId][sheetId] = Object.create(null);
9602
+ if (arrayFormulaEmbeddedMap[unitId][sheetId][rowIndex] == null) arrayFormulaEmbeddedMap[unitId][sheetId][rowIndex] = Object.create(null);
9591
9603
  arrayFormulaEmbeddedMap[unitId][sheetId][rowIndex][columnIndex] = true;
9592
9604
  }
9593
9605
  getRuntimeOtherData() {
@@ -12200,11 +12212,11 @@ const IFeatureCalculationManagerService = createIdentifier("univer.formula.featu
12200
12212
  var OtherFormulaManagerService = class extends Disposable {
12201
12213
  constructor(..._args) {
12202
12214
  super(..._args);
12203
- _defineProperty(this, "_otherFormulaData", {});
12215
+ _defineProperty(this, "_otherFormulaData", Object.create(null));
12204
12216
  }
12205
12217
  dispose() {
12206
12218
  super.dispose();
12207
- this._otherFormulaData = {};
12219
+ this._otherFormulaData = Object.create(null);
12208
12220
  }
12209
12221
  remove(searchParam) {
12210
12222
  var _this$_otherFormulaDa;
@@ -12223,8 +12235,8 @@ var OtherFormulaManagerService = class extends Disposable {
12223
12235
  }
12224
12236
  register(insertParam) {
12225
12237
  const { unitId, subUnitId, formulaId, item } = insertParam;
12226
- if (!this._otherFormulaData[unitId]) this._otherFormulaData[unitId] = {};
12227
- if (!this._otherFormulaData[unitId][subUnitId]) this._otherFormulaData[unitId][subUnitId] = {};
12238
+ if (!this._otherFormulaData[unitId]) this._otherFormulaData[unitId] = Object.create(null);
12239
+ if (!this._otherFormulaData[unitId][subUnitId]) this._otherFormulaData[unitId][subUnitId] = Object.create(null);
12228
12240
  this._otherFormulaData[unitId][subUnitId][formulaId] = item;
12229
12241
  }
12230
12242
  batchRegister(formulaData) {
@@ -13627,7 +13639,7 @@ let CalculateFormulaService = class CalculateFormulaService extends Disposable {
13627
13639
  }
13628
13640
  _getArrayFormulaDirtyRangeAndExcludedRange(arrayFormulaRange, runtimeFeatureRange) {
13629
13641
  const dirtyRanges = [];
13630
- const excludedCell = {};
13642
+ const excludedCell = Object.create(null);
13631
13643
  Object.keys(arrayFormulaRange).forEach((unitId) => {
13632
13644
  const sheetArrayFormulaRange = arrayFormulaRange[unitId];
13633
13645
  if (sheetArrayFormulaRange == null) return true;
@@ -13643,7 +13655,7 @@ let CalculateFormulaService = class CalculateFormulaService extends Disposable {
13643
13655
  range
13644
13656
  });
13645
13657
  });
13646
- if (excludedCell[unitId] == null) excludedCell[unitId] = {};
13658
+ if (excludedCell[unitId] == null) excludedCell[unitId] = Object.create(null);
13647
13659
  excludedCell[unitId][sheetId] = newCellData;
13648
13660
  });
13649
13661
  });
@@ -13749,21 +13761,21 @@ let CalculateFormulaService = class CalculateFormulaService extends Disposable {
13749
13761
  this._currentConfigService.loadDataLite(rowData);
13750
13762
  const unitData = this._currentConfigService.getUnitData();
13751
13763
  this._runtimeService.reset();
13752
- const result = {};
13764
+ const result = Object.create(null);
13753
13765
  for (const unitId of Object.keys(formulas)) {
13754
13766
  const sheetFormulas = formulas[unitId];
13755
13767
  if (sheetFormulas == null) continue;
13756
- result[unitId] = {};
13768
+ result[unitId] = Object.create(null);
13757
13769
  for (const sheetId of Object.keys(sheetFormulas)) {
13758
13770
  var _unitData$unitId;
13759
13771
  const rowFormulas = sheetFormulas[sheetId];
13760
13772
  if (rowFormulas == null) continue;
13761
13773
  const sheetItem = (_unitData$unitId = unitData[unitId]) === null || _unitData$unitId === void 0 ? void 0 : _unitData$unitId[sheetId];
13762
13774
  if (sheetItem == null) continue;
13763
- result[unitId][sheetId] = {};
13775
+ result[unitId][sheetId] = Object.create(null);
13764
13776
  for (const rowString of Object.keys(rowFormulas)) {
13765
13777
  const row = Number.parseInt(rowString);
13766
- result[unitId][sheetId][row] = {};
13778
+ result[unitId][sheetId][row] = Object.create(null);
13767
13779
  const cellData = rowFormulas[row];
13768
13780
  if (!cellData) continue;
13769
13781
  for (const columnString of Object.keys(cellData)) {
@@ -40438,7 +40450,7 @@ function getObjectValue(result, isUseStrip = false) {
40438
40450
  //#endregion
40439
40451
  //#region package.json
40440
40452
  var name = "@univerjs/engine-formula";
40441
- var version = "0.25.1";
40453
+ var version = "0.25.2";
40442
40454
 
40443
40455
  //#endregion
40444
40456
  //#region src/services/global-computing-status.service.ts
@@ -13,6 +13,17 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import type { Nullable } from '@univerjs/core';
16
17
  import type { IArrayFormulaUnitCellType, IRuntimeUnitDataPrimitiveType, IRuntimeUnitDataType } from './common';
17
18
  export declare function convertUnitDataToRuntime(unitData: IArrayFormulaUnitCellType): IRuntimeUnitDataType;
18
19
  export declare function convertRuntimeToUnitData(unitData: IRuntimeUnitDataType): IRuntimeUnitDataPrimitiveType;
20
+ /** Copy the unit and sheet dictionaries without retaining inherited identifier keys. */
21
+ export declare function copyUnitData<T>(data: {
22
+ [unitId: string]: Nullable<{
23
+ [sheetId: string]: T;
24
+ }>;
25
+ }): {
26
+ [unitId: string]: {
27
+ [sheetId: string]: T;
28
+ };
29
+ };