@univerjs/sheets-formula 1.0.0-rc.0 → 1.0.1

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/cjs/index.js CHANGED
@@ -70,7 +70,7 @@ const PLUGIN_CONFIG_KEY_MOBILE = "sheets-formula.mobile.config";
70
70
  const configSymbolMobile = Symbol(PLUGIN_CONFIG_KEY_MOBILE);
71
71
 
72
72
  //#endregion
73
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
73
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
74
74
  function __decorateParam(paramIndex, decorator) {
75
75
  return function(target, key) {
76
76
  decorator(target, key, paramIndex);
@@ -78,7 +78,7 @@ function __decorateParam(paramIndex, decorator) {
78
78
  }
79
79
 
80
80
  //#endregion
81
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
81
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
82
82
  function __decorate(decorators, target, key, desc) {
83
83
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
84
84
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -174,9 +174,7 @@ function directionToOffset(step, len, direction, location, sourceIndex) {
174
174
  case _univerjs_core.Direction.DOWN:
175
175
  offsetY = targetRows[sourceIndex] - sourceRows[sourceIndex];
176
176
  break;
177
- case _univerjs_core.Direction.LEFT:
178
- offsetX = -step * len;
179
- break;
177
+ case _univerjs_core.Direction.LEFT: offsetX = -step * len;
180
178
  }
181
179
  return {
182
180
  offsetX,
@@ -192,7 +190,7 @@ function getDataLength(copyDataPiece) {
192
190
  }
193
191
 
194
192
  //#endregion
195
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
193
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
196
194
  function _typeof(o) {
197
195
  "@babel/helpers - typeof";
198
196
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -203,7 +201,7 @@ function _typeof(o) {
203
201
  }
204
202
 
205
203
  //#endregion
206
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
204
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
207
205
  function toPrimitive(t, r) {
208
206
  if ("object" != _typeof(t) || !t) return t;
209
207
  var e = t[Symbol.toPrimitive];
@@ -216,14 +214,14 @@ function toPrimitive(t, r) {
216
214
  }
217
215
 
218
216
  //#endregion
219
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
217
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
220
218
  function toPropertyKey(t) {
221
219
  var i = toPrimitive(t, "string");
222
220
  return "symbol" == _typeof(i) ? i : i + "";
223
221
  }
224
222
 
225
223
  //#endregion
226
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
224
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
227
225
  function _defineProperty(e, r, t) {
228
226
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
229
227
  value: t,
@@ -262,10 +260,10 @@ let ImageFormulaCellInterceptorController = class ImageFormulaCellInterceptorCon
262
260
  const updateRuntimeImageFormulaData = await Promise.all(imageFormulaData.map((imageFormulaInfo) => {
263
261
  return this._getImageNatureSize(imageFormulaInfo);
264
262
  }));
265
- const unitImageFormulaData = {};
263
+ const unitImageFormulaData = Object.create(null);
266
264
  updateRuntimeImageFormulaData.forEach((imageFormulaInfo) => {
267
265
  const { unitId, sheetId, row, column, ...imageInfo } = imageFormulaInfo;
268
- if (!unitImageFormulaData[unitId]) unitImageFormulaData[unitId] = {};
266
+ if (!unitImageFormulaData[unitId]) unitImageFormulaData[unitId] = Object.create(null);
269
267
  if (!unitImageFormulaData[unitId][sheetId]) unitImageFormulaData[unitId][sheetId] = new _univerjs_core.ObjectMatrix();
270
268
  unitImageFormulaData[unitId][sheetId].setValue(row, column, imageInfo);
271
269
  });
@@ -512,9 +510,7 @@ let TriggerCalculationController = class TriggerCalculationController extends _u
512
510
  result = "Formula calculation succeeded";
513
511
  if (calculationProcessCount === 0 || calculationProcessCount === -1) result += `. Total time consumed: ${performance.now() - this._startExecutionTime} ms`;
514
512
  break;
515
- case _univerjs_engine_formula.FormulaExecutedStateType.INITIAL:
516
- result = "Waiting for calculation";
517
- break;
513
+ case _univerjs_engine_formula.FormulaExecutedStateType.INITIAL: result = "Waiting for calculation";
518
514
  }
519
515
  if (calculationProcessCount === 0 || calculationProcessCount === -1) {
520
516
  if (startDependencyTimer) {
@@ -793,8 +789,8 @@ function getFormulaReferenceRange(oldFormulaData, newFormulaData, formulaReferen
793
789
  * @returns
794
790
  */
795
791
  function refRangeFormula(oldFormulaData, newFormulaData, formulaReferenceMoveParam) {
796
- const redoFormulaData = {};
797
- const undoFormulaData = {};
792
+ const redoFormulaData = Object.create(null);
793
+ const undoFormulaData = Object.create(null);
798
794
  const { unitId: fromUnitId, sheetId: fromSheetId } = formulaReferenceMoveParam;
799
795
  const targetUnitId = formulaReferenceMoveParam.targetUnitId ?? fromUnitId;
800
796
  const targetSheetId = formulaReferenceMoveParam.targetSheetId ?? fromSheetId;
@@ -812,8 +808,8 @@ function refRangeFormula(oldFormulaData, newFormulaData, formulaReferenceMovePar
812
808
  else rangeList = processFormulaChanges(oldFormulaMatrix, newFormulaMatrix, formulaReferenceMoveParam);
813
809
  const sheetRedoFormulaData = getRedoFormulaData(rangeList, oldFormulaMatrix, newFormulaMatrix);
814
810
  const sheetUndoFormulaData = getUndoFormulaData(rangeList, oldFormulaMatrix);
815
- if (!redoFormulaData[unitId]) redoFormulaData[unitId] = {};
816
- if (!undoFormulaData[unitId]) undoFormulaData[unitId] = {};
811
+ if (!redoFormulaData[unitId]) redoFormulaData[unitId] = Object.create(null);
812
+ if (!undoFormulaData[unitId]) undoFormulaData[unitId] = Object.create(null);
817
813
  redoFormulaData[unitId][currentSheetId] = {
818
814
  ...redoFormulaData[unitId][currentSheetId],
819
815
  ...sheetRedoFormulaData
@@ -913,8 +909,6 @@ function handleInsertDelete(oldCell, formulaReferenceMoveParam) {
913
909
  case 10:
914
910
  newCell = handleRefInsertMoveRight(range, oldCell);
915
911
  isReverse = true;
916
- break;
917
- default: break;
918
912
  }
919
913
  return {
920
914
  newCell,
@@ -922,34 +916,37 @@ function handleInsertDelete(oldCell, formulaReferenceMoveParam) {
922
916
  };
923
917
  }
924
918
  function handleRefMoveRange$1(from, to, oldCell) {
925
- return (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleMoveRange)({
919
+ const operators = (0, _univerjs_sheets.handleMoveRange)({
926
920
  id: _univerjs_sheets.EffectRefRangId.MoveRangeCommandId,
927
921
  params: {
928
922
  toRange: to,
929
923
  fromRange: from
930
924
  }
931
- }, oldCell), oldCell);
925
+ }, oldCell);
926
+ return (0, _univerjs_sheets.runRefRangeMutations)(operators, oldCell);
932
927
  }
933
928
  function handleRefMoveRows$1(from, to, oldCell) {
934
- return (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleMoveRows)({
929
+ const operators = (0, _univerjs_sheets.handleMoveRows)({
935
930
  id: _univerjs_sheets.EffectRefRangId.MoveRowsCommandId,
936
931
  params: {
937
932
  toRange: to,
938
933
  fromRange: from
939
934
  }
940
- }, oldCell), oldCell);
935
+ }, oldCell);
936
+ return (0, _univerjs_sheets.runRefRangeMutations)(operators, oldCell);
941
937
  }
942
938
  function handleRefMoveCols$1(from, to, oldCell) {
943
- return (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleMoveCols)({
939
+ const operators = (0, _univerjs_sheets.handleMoveCols)({
944
940
  id: _univerjs_sheets.EffectRefRangId.MoveColsCommandId,
945
941
  params: {
946
942
  toRange: to,
947
943
  fromRange: from
948
944
  }
949
- }, oldCell), oldCell);
945
+ }, oldCell);
946
+ return (0, _univerjs_sheets.runRefRangeMutations)(operators, oldCell);
950
947
  }
951
948
  function handleRefInsertRow$1(range, oldCell) {
952
- return (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleInsertRow)({
949
+ const operators = (0, _univerjs_sheets.handleInsertRow)({
953
950
  id: _univerjs_sheets.EffectRefRangId.InsertRowCommandId,
954
951
  params: {
955
952
  range,
@@ -957,10 +954,11 @@ function handleRefInsertRow$1(range, oldCell) {
957
954
  subUnitId: "",
958
955
  direction: _univerjs_core.Direction.DOWN
959
956
  }
960
- }, oldCell), oldCell);
957
+ }, oldCell);
958
+ return (0, _univerjs_sheets.runRefRangeMutations)(operators, oldCell);
961
959
  }
962
960
  function handleRefInsertCol$1(range, oldCell) {
963
- return (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleInsertCol)({
961
+ const operators = (0, _univerjs_sheets.handleInsertCol)({
964
962
  id: _univerjs_sheets.EffectRefRangId.InsertColCommandId,
965
963
  params: {
966
964
  range,
@@ -968,43 +966,50 @@ function handleRefInsertCol$1(range, oldCell) {
968
966
  subUnitId: "",
969
967
  direction: _univerjs_core.Direction.RIGHT
970
968
  }
971
- }, oldCell), oldCell);
969
+ }, oldCell);
970
+ return (0, _univerjs_sheets.runRefRangeMutations)(operators, oldCell);
972
971
  }
973
972
  function handleRefRemoveRow$1(range, oldCell, rangeFilteredRows) {
974
- return (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleIRemoveRow)({
973
+ const operators = (0, _univerjs_sheets.handleIRemoveRow)({
975
974
  id: _univerjs_sheets.EffectRefRangId.RemoveRowCommandId,
976
975
  params: { range }
977
- }, oldCell, rangeFilteredRows), oldCell);
976
+ }, oldCell, rangeFilteredRows);
977
+ return (0, _univerjs_sheets.runRefRangeMutations)(operators, oldCell);
978
978
  }
979
979
  function handleRefRemoveCol$1(range, oldCell) {
980
- return (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleIRemoveCol)({
980
+ const operators = (0, _univerjs_sheets.handleIRemoveCol)({
981
981
  id: _univerjs_sheets.EffectRefRangId.RemoveColCommandId,
982
982
  params: { range }
983
- }, oldCell), oldCell);
983
+ }, oldCell);
984
+ return (0, _univerjs_sheets.runRefRangeMutations)(operators, oldCell);
984
985
  }
985
986
  function handleRefDeleteMoveLeft(range, oldCell) {
986
- return (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleDeleteRangeMoveLeft)({
987
+ const operators = (0, _univerjs_sheets.handleDeleteRangeMoveLeft)({
987
988
  id: _univerjs_sheets.EffectRefRangId.DeleteRangeMoveLeftCommandId,
988
989
  params: { range }
989
- }, oldCell), oldCell);
990
+ }, oldCell);
991
+ return (0, _univerjs_sheets.runRefRangeMutations)(operators, oldCell);
990
992
  }
991
993
  function handleRefDeleteMoveUp(range, oldCell) {
992
- return (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleDeleteRangeMoveUp)({
994
+ const operators = (0, _univerjs_sheets.handleDeleteRangeMoveUp)({
993
995
  id: _univerjs_sheets.EffectRefRangId.DeleteRangeMoveUpCommandId,
994
996
  params: { range }
995
- }, oldCell), oldCell);
997
+ }, oldCell);
998
+ return (0, _univerjs_sheets.runRefRangeMutations)(operators, oldCell);
996
999
  }
997
1000
  function handleRefInsertMoveDown(range, oldCell) {
998
- return (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleInsertRangeMoveDown)({
1001
+ const operators = (0, _univerjs_sheets.handleInsertRangeMoveDown)({
999
1002
  id: _univerjs_sheets.EffectRefRangId.InsertRangeMoveDownCommandId,
1000
1003
  params: { range }
1001
- }, oldCell), oldCell);
1004
+ }, oldCell);
1005
+ return (0, _univerjs_sheets.runRefRangeMutations)(operators, oldCell);
1002
1006
  }
1003
1007
  function handleRefInsertMoveRight(range, oldCell) {
1004
- return (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleInsertRangeMoveRight)({
1008
+ const operators = (0, _univerjs_sheets.handleInsertRangeMoveRight)({
1005
1009
  id: _univerjs_sheets.EffectRefRangId.InsertRangeMoveRightCommandId,
1006
1010
  params: { range }
1007
- }, oldCell), oldCell);
1011
+ }, oldCell);
1012
+ return (0, _univerjs_sheets.runRefRangeMutations)(operators, oldCell);
1008
1013
  }
1009
1014
  /**
1010
1015
  * Delete the old value at the old position on the match, and add the new value at the new position (the new value first checks whether the old position has offset content, if so, use the new offset content, if not, take the old value)
@@ -1157,13 +1162,14 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
1157
1162
  const moveEdge = checkMoveEdge(sequenceRange, from);
1158
1163
  const remainRange = (0, _univerjs_core.getIntersectRange)(sequenceRange, from);
1159
1164
  if (remainRange == null || moveEdge !== 4) return;
1160
- const result = (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleMoveRange)({
1165
+ const operators = (0, _univerjs_sheets.handleMoveRange)({
1161
1166
  id: _univerjs_sheets.EffectRefRangId.MoveRangeCommandId,
1162
1167
  params: {
1163
1168
  toRange: to,
1164
1169
  fromRange: from
1165
1170
  }
1166
- }, remainRange), remainRange);
1171
+ }, remainRange);
1172
+ const result = (0, _univerjs_sheets.runRefRangeMutations)(operators, remainRange);
1167
1173
  if (result == null) return _univerjs_engine_formula.ErrorType.REF;
1168
1174
  newRange = getMoveNewRange(moveEdge, result, from, to, sequenceRange, remainRange);
1169
1175
  } else if (type === 1) {
@@ -1178,13 +1184,14 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
1178
1184
  endColumn: sequenceRange.endColumn,
1179
1185
  rangeType: _univerjs_core.RANGE_TYPE.NORMAL
1180
1186
  };
1181
- const result = (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleMoveRows)({
1187
+ const operators = (0, _univerjs_sheets.handleMoveRows)({
1182
1188
  id: _univerjs_sheets.EffectRefRangId.MoveRowsCommandId,
1183
1189
  params: {
1184
1190
  toRange: to,
1185
1191
  fromRange: from
1186
1192
  }
1187
- }, remainRange), remainRange);
1193
+ }, remainRange);
1194
+ const result = (0, _univerjs_sheets.runRefRangeMutations)(operators, remainRange);
1188
1195
  if (result == null) return _univerjs_engine_formula.ErrorType.REF;
1189
1196
  newRange = getMoveNewRange(moveEdge, result, from, to, sequenceRange, remainRange);
1190
1197
  } else if (type === 2) {
@@ -1199,19 +1206,20 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
1199
1206
  endColumn: sequenceRange.endColumn,
1200
1207
  rangeType: _univerjs_core.RANGE_TYPE.NORMAL
1201
1208
  };
1202
- const result = (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleMoveCols)({
1209
+ const operators = (0, _univerjs_sheets.handleMoveCols)({
1203
1210
  id: _univerjs_sheets.EffectRefRangId.MoveColsCommandId,
1204
1211
  params: {
1205
1212
  toRange: to,
1206
1213
  fromRange: from
1207
1214
  }
1208
- }, remainRange), remainRange);
1215
+ }, remainRange);
1216
+ const result = (0, _univerjs_sheets.runRefRangeMutations)(operators, remainRange);
1209
1217
  if (result == null) return _univerjs_engine_formula.ErrorType.REF;
1210
1218
  newRange = getMoveNewRange(moveEdge, result, from, to, sequenceRange, remainRange);
1211
1219
  }
1212
1220
  if (range != null) {
1213
1221
  if (type === 3) {
1214
- const result = (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleInsertRow)({
1222
+ const operators = (0, _univerjs_sheets.handleInsertRow)({
1215
1223
  id: _univerjs_sheets.EffectRefRangId.InsertRowCommandId,
1216
1224
  params: {
1217
1225
  range,
@@ -1219,14 +1227,15 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
1219
1227
  subUnitId: "",
1220
1228
  direction: _univerjs_core.Direction.DOWN
1221
1229
  }
1222
- }, sequenceRange), sequenceRange);
1230
+ }, sequenceRange);
1231
+ const result = (0, _univerjs_sheets.runRefRangeMutations)(operators, sequenceRange);
1223
1232
  if (result == null) return;
1224
1233
  newRange = {
1225
1234
  ...sequenceRange,
1226
1235
  ...result
1227
1236
  };
1228
1237
  } else if (type === 4) {
1229
- const result = (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleInsertCol)({
1238
+ const operators = (0, _univerjs_sheets.handleInsertCol)({
1230
1239
  id: _univerjs_sheets.EffectRefRangId.InsertColCommandId,
1231
1240
  params: {
1232
1241
  range,
@@ -1234,67 +1243,74 @@ function getNewRangeByMoveParam(unitRangeWidthOffset, formulaReferenceMoveParam,
1234
1243
  subUnitId: "",
1235
1244
  direction: _univerjs_core.Direction.RIGHT
1236
1245
  }
1237
- }, sequenceRange), sequenceRange);
1246
+ }, sequenceRange);
1247
+ const result = (0, _univerjs_sheets.runRefRangeMutations)(operators, sequenceRange);
1238
1248
  if (result == null) return;
1239
1249
  newRange = {
1240
1250
  ...sequenceRange,
1241
1251
  ...result
1242
1252
  };
1243
1253
  } else if (type === 5) {
1244
- const result = (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleIRemoveRow)({
1254
+ const operators = (0, _univerjs_sheets.handleIRemoveRow)({
1245
1255
  id: _univerjs_sheets.EffectRefRangId.RemoveRowCommandId,
1246
1256
  params: { range }
1247
- }, sequenceRange, rangeFilteredRows), sequenceRange);
1257
+ }, sequenceRange, rangeFilteredRows);
1258
+ const result = (0, _univerjs_sheets.runRefRangeMutations)(operators, sequenceRange);
1248
1259
  if (result == null) return _univerjs_engine_formula.ErrorType.REF;
1249
1260
  newRange = {
1250
1261
  ...sequenceRange,
1251
1262
  ...result
1252
1263
  };
1253
1264
  } else if (type === 6) {
1254
- const result = (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleIRemoveCol)({
1265
+ const operators = (0, _univerjs_sheets.handleIRemoveCol)({
1255
1266
  id: _univerjs_sheets.EffectRefRangId.RemoveColCommandId,
1256
1267
  params: { range }
1257
- }, sequenceRange), sequenceRange);
1268
+ }, sequenceRange);
1269
+ const result = (0, _univerjs_sheets.runRefRangeMutations)(operators, sequenceRange);
1258
1270
  if (result == null) return _univerjs_engine_formula.ErrorType.REF;
1259
1271
  newRange = {
1260
1272
  ...sequenceRange,
1261
1273
  ...result
1262
1274
  };
1263
1275
  } else if (type === 7) {
1264
- const result = (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleDeleteRangeMoveLeft)({
1276
+ const operators = (0, _univerjs_sheets.handleDeleteRangeMoveLeft)({
1265
1277
  id: _univerjs_sheets.EffectRefRangId.DeleteRangeMoveLeftCommandId,
1266
1278
  params: { range }
1267
- }, sequenceRange), sequenceRange);
1279
+ }, sequenceRange);
1280
+ const result = (0, _univerjs_sheets.runRefRangeMutations)(operators, sequenceRange);
1268
1281
  if (result == null) return _univerjs_engine_formula.ErrorType.REF;
1269
1282
  newRange = {
1270
1283
  ...sequenceRange,
1271
1284
  ...result
1272
1285
  };
1273
1286
  } else if (type === 8) {
1274
- const result = (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleDeleteRangeMoveUp)({
1287
+ const operators = (0, _univerjs_sheets.handleDeleteRangeMoveUp)({
1275
1288
  id: _univerjs_sheets.EffectRefRangId.DeleteRangeMoveUpCommandId,
1276
1289
  params: { range }
1277
- }, sequenceRange), sequenceRange);
1290
+ }, sequenceRange);
1291
+ const result = (0, _univerjs_sheets.runRefRangeMutations)(operators, sequenceRange);
1278
1292
  if (result == null) return _univerjs_engine_formula.ErrorType.REF;
1279
1293
  newRange = {
1280
1294
  ...sequenceRange,
1281
1295
  ...result
1282
1296
  };
1283
1297
  } else if (type === 9) {
1284
- const result = (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleInsertRangeMoveDown)({
1298
+ const operators = (0, _univerjs_sheets.handleInsertRangeMoveDown)({
1285
1299
  id: _univerjs_sheets.EffectRefRangId.InsertRangeMoveDownCommandId,
1286
1300
  params: { range }
1287
- }, sequenceRange), sequenceRange);
1301
+ }, sequenceRange);
1302
+ const result = (0, _univerjs_sheets.runRefRangeMutations)(operators, sequenceRange);
1288
1303
  if (result == null) return;
1289
1304
  newRange = {
1290
1305
  ...sequenceRange,
1291
1306
  ...result
1292
1307
  };
1293
1308
  } else if (type === 10) {
1294
- const result = (0, _univerjs_sheets.runRefRangeMutations)((0, _univerjs_sheets.handleInsertRangeMoveRight)({
1309
+ const operators = (0, _univerjs_sheets.handleInsertRangeMoveRight)({
1295
1310
  id: _univerjs_sheets.EffectRefRangId.InsertRangeMoveRightCommandId,
1296
1311
  params: { range }
1297
- }, sequenceRange), sequenceRange);
1312
+ }, sequenceRange);
1313
+ const result = (0, _univerjs_sheets.runRefRangeMutations)(operators, sequenceRange);
1298
1314
  if (result == null) return;
1299
1315
  newRange = {
1300
1316
  ...sequenceRange,
@@ -1339,23 +1355,31 @@ function getMoveNewRange(moveEdge, result, from, to, origin, remain) {
1339
1355
  if (rangeType === _univerjs_core.RANGE_TYPE.ROW && originRangeType === _univerjs_core.RANGE_TYPE.ROW) return true;
1340
1356
  return startRow >= originStartRow && endRow <= originEndRow;
1341
1357
  }
1342
- if (moveEdge === 0) if (rowsCover()) if (startRow < originStartRow) newRange.startRow = startRow;
1343
- else if (startRow >= originEndRow) newRange.endRow -= fromEndRow + 1 - originStartRow;
1344
- else return;
1345
- else return;
1346
- else if (moveEdge === 1) if (rowsCover()) if (endRow > originEndRow) newRange.endRow = endRow;
1347
- else if (endRow <= originStartRow) newRange.startRow += originEndRow - fromStartRow + 1;
1348
- else return;
1349
- else return;
1350
- else if (moveEdge === 2) if (columnsCover()) if (startColumn < originStartColumn) newRange.startColumn = startColumn;
1351
- else if (startColumn >= originEndColumn) newRange.endColumn -= fromEndColumn + 1 - originStartColumn;
1352
- else return;
1353
- else return;
1354
- else if (moveEdge === 3) if (columnsCover()) if (endColumn > originEndColumn) newRange.endColumn = endColumn;
1355
- else if (endColumn <= originStartColumn) newRange.startColumn += originEndColumn - fromStartColumn + 1;
1356
- else return;
1357
- else return;
1358
- else if (moveEdge === 4) {
1358
+ if (moveEdge === 0) {
1359
+ if (rowsCover()) {
1360
+ if (startRow < originStartRow) newRange.startRow = startRow;
1361
+ else if (startRow >= originEndRow) newRange.endRow -= fromEndRow + 1 - originStartRow;
1362
+ else return;
1363
+ } else return;
1364
+ } else if (moveEdge === 1) {
1365
+ if (rowsCover()) {
1366
+ if (endRow > originEndRow) newRange.endRow = endRow;
1367
+ else if (endRow <= originStartRow) newRange.startRow += originEndRow - fromStartRow + 1;
1368
+ else return;
1369
+ } else return;
1370
+ } else if (moveEdge === 2) {
1371
+ if (columnsCover()) {
1372
+ if (startColumn < originStartColumn) newRange.startColumn = startColumn;
1373
+ else if (startColumn >= originEndColumn) newRange.endColumn -= fromEndColumn + 1 - originStartColumn;
1374
+ else return;
1375
+ } else return;
1376
+ } else if (moveEdge === 3) {
1377
+ if (columnsCover()) {
1378
+ if (endColumn > originEndColumn) newRange.endColumn = endColumn;
1379
+ else if (endColumn <= originStartColumn) newRange.startColumn += originEndColumn - fromStartColumn + 1;
1380
+ else return;
1381
+ } else return;
1382
+ } else if (moveEdge === 4) {
1359
1383
  newRange.startRow = startRow;
1360
1384
  newRange.startColumn = startColumn;
1361
1385
  newRange.endRow = endRow;
@@ -1515,9 +1539,7 @@ function getReferenceMoveParams(workbook, command) {
1515
1539
  result = handleRefRemoveSheetTableName(command, workbook);
1516
1540
  break;
1517
1541
  case REMOVE_SHEET_TABLE_COLUMN_AT_COMMAND_ID:
1518
- case REMOVE_SHEET_TABLE_COLUMN_COMMAND_ID:
1519
- result = handleRefRemoveSheetTableColumn(command, workbook);
1520
- break;
1542
+ case REMOVE_SHEET_TABLE_COLUMN_COMMAND_ID: result = handleRefRemoveSheetTableColumn(command, workbook);
1521
1543
  }
1522
1544
  return result;
1523
1545
  }
@@ -2008,7 +2030,7 @@ let UpdateFormulaController = class UpdateFormulaController extends _univerjs_co
2008
2030
  return;
2009
2031
  }
2010
2032
  const newFormulaData = { [unitId]: { [sheetId]: newSheetFormulaData } };
2011
- this._commandService.executeCommand(_univerjs_sheets.SetRangeValuesMutation.id, {
2033
+ this._commandService.syncExecuteCommand(_univerjs_sheets.SetRangeValuesMutation.id, {
2012
2034
  unitId,
2013
2035
  subUnitId: sheetId,
2014
2036
  cellValue: formulaDataToCellData(newSheetFormulaData, cellValue)
@@ -2028,7 +2050,8 @@ let UpdateFormulaController = class UpdateFormulaController extends _univerjs_co
2028
2050
  }
2029
2051
  _handleWorkbookDisposed(unitId, sheetId) {
2030
2052
  this._formulaDataModel.clearFormulaIdMap(unitId, sheetId);
2031
- const newFormulaData = removeFormulaData(this._formulaDataModel.getFormulaData(), unitId, sheetId);
2053
+ const formulaData = this._formulaDataModel.getFormulaData();
2054
+ const newFormulaData = removeFormulaData(formulaData, unitId, sheetId);
2032
2055
  const arrayFormulaRange = this._formulaDataModel.getArrayFormulaRange();
2033
2056
  const newArrayFormulaRange = removeFormulaData(arrayFormulaRange, unitId, sheetId);
2034
2057
  const arrayFormulaCellData = this._formulaDataModel.getArrayFormulaCellData();
@@ -2048,7 +2071,7 @@ let UpdateFormulaController = class UpdateFormulaController extends _univerjs_co
2048
2071
  this._commandService.executeCommand(_univerjs_engine_formula.SetFormulaDataMutation.id, { formulaData: newFormulaData }, { onlyLocal: true });
2049
2072
  }
2050
2073
  _handleWorkbookAdded(unit) {
2051
- const formulaData = {};
2074
+ const formulaData = Object.create(null);
2052
2075
  const unitId = unit.getUnitId();
2053
2076
  const newFormulaData = { [unitId]: {} };
2054
2077
  unit.getSheets().forEach((worksheet) => {
@@ -2069,11 +2092,11 @@ let UpdateFormulaController = class UpdateFormulaController extends _univerjs_co
2069
2092
  return {
2070
2093
  forceCalculation: calculationMode === 0,
2071
2094
  dirtyRanges: calculationMode === 1 ? this._formulaDataModel.getFormulaDirtyRanges() : [],
2072
- dirtyNameMap: {},
2073
- dirtyDefinedNameMap: {},
2074
- dirtyUnitFeatureMap: {},
2075
- dirtyUnitOtherFormulaMap: {},
2076
- clearDependencyTreeCache: {}
2095
+ dirtyNameMap: Object.create(null),
2096
+ dirtyDefinedNameMap: Object.create(null),
2097
+ dirtyUnitFeatureMap: Object.create(null),
2098
+ dirtyUnitOtherFormulaMap: Object.create(null),
2099
+ clearDependencyTreeCache: Object.create(null)
2077
2100
  };
2078
2101
  }
2079
2102
  _getUpdateFormula(command) {
@@ -2106,14 +2129,14 @@ let UpdateFormulaController = class UpdateFormulaController extends _univerjs_co
2106
2129
  if (!_univerjs_core.Tools.isDefine(formulaData)) return { newFormulaData: {} };
2107
2130
  const formulaDataKeys = Object.keys(formulaData);
2108
2131
  if (formulaDataKeys.length === 0) return { newFormulaData: {} };
2109
- const newFormulaData = {};
2132
+ const newFormulaData = Object.create(null);
2110
2133
  const { unitId: fromUnitId, sheetId: fromSheetId, sheetName: fromSheetName, targetUnitId, targetSheetId, type, from, to } = formulaReferenceMoveParam;
2111
2134
  const inCrossSheetCutRangeNewFormulas = [];
2112
2135
  for (const unitId of formulaDataKeys) {
2113
2136
  const sheetData = formulaData[unitId];
2114
2137
  if (sheetData == null) continue;
2115
2138
  const sheetDataKeys = Object.keys(sheetData);
2116
- if (!_univerjs_core.Tools.isDefine(newFormulaData[unitId])) newFormulaData[unitId] = {};
2139
+ if (!_univerjs_core.Tools.isDefine(newFormulaData[unitId])) newFormulaData[unitId] = Object.create(null);
2117
2140
  for (const sheetId of sheetDataKeys) {
2118
2141
  const matrixData = new _univerjs_core.ObjectMatrix(sheetData[sheetId] || {});
2119
2142
  const newFormulaDataItem = new _univerjs_core.ObjectMatrix();
@@ -2233,21 +2256,22 @@ let UpdateFormulaController = class UpdateFormulaController extends _univerjs_co
2233
2256
  }
2234
2257
  }
2235
2258
  }
2236
- if (!shouldModify)
2237
- /**
2238
- * If the operation is a move type, and the formula cell has si and is the same as the current shouldModifySi, unpack the si to f.
2239
- * Or the source formula cell is in the moved range.
2240
- * This is to ensure that the si formula can be recalculated correctly after the move.
2241
- */
2242
- if (si && [
2243
- 1,
2244
- 2,
2245
- 0
2246
- ].includes(type)) {
2247
- if (from && from.startRow <= row && row <= from.endRow && from.startColumn <= column && column <= from.endColumn) {
2248
- if ((x ?? 0) === 0 && (y ?? 0) === 0) shouldModifySi.push(si);
2249
- } else if (!shouldModifySi.includes(si)) return true;
2250
- } else return true;
2259
+ if (!shouldModify) {
2260
+ /**
2261
+ * If the operation is a move type, and the formula cell has si and is the same as the current shouldModifySi, unpack the si to f.
2262
+ * Or the source formula cell is in the moved range.
2263
+ * This is to ensure that the si formula can be recalculated correctly after the move.
2264
+ */
2265
+ if (si && [
2266
+ 1,
2267
+ 2,
2268
+ 0
2269
+ ].includes(type)) {
2270
+ if (from && from.startRow <= row && row <= from.endRow && from.startColumn <= column && column <= from.endColumn) {
2271
+ if ((x ?? 0) === 0 && (y ?? 0) === 0) shouldModifySi.push(si);
2272
+ } else if (!shouldModifySi.includes(si)) return true;
2273
+ } else return true;
2274
+ }
2251
2275
  if (inCrossSheetCutRange) {
2252
2276
  const newSequenceNodes = updateRefOffset(inCrossSheetCutRangeSequenceNodes, refChangeIds, x, y);
2253
2277
  inCrossSheetCutRangeNewFormulas.push({
@@ -2264,13 +2288,13 @@ let UpdateFormulaController = class UpdateFormulaController extends _univerjs_co
2264
2288
  }
2265
2289
  }
2266
2290
  if (inCrossSheetCutRangeNewFormulas.length > 0 && targetUnitId && targetSheetId) {
2267
- if (!newFormulaData[targetUnitId]) newFormulaData[targetUnitId] = {};
2268
- if (!newFormulaData[targetUnitId][targetSheetId]) newFormulaData[targetUnitId][targetSheetId] = {};
2291
+ if (!newFormulaData[targetUnitId]) newFormulaData[targetUnitId] = Object.create(null);
2292
+ if (!newFormulaData[targetUnitId][targetSheetId]) newFormulaData[targetUnitId][targetSheetId] = Object.create(null);
2269
2293
  for (const newFormula of inCrossSheetCutRangeNewFormulas) {
2270
2294
  const { fromRow, fromColumn, formulaString } = newFormula;
2271
2295
  const targetRow = fromRow + (((to === null || to === void 0 ? void 0 : to.startRow) ?? 0) - ((from === null || from === void 0 ? void 0 : from.startRow) ?? 0));
2272
2296
  const targetColumn = fromColumn + (((to === null || to === void 0 ? void 0 : to.startColumn) ?? 0) - ((from === null || from === void 0 ? void 0 : from.startColumn) ?? 0));
2273
- if (!newFormulaData[targetUnitId][targetSheetId][targetRow]) newFormulaData[targetUnitId][targetSheetId][targetRow] = {};
2297
+ if (!newFormulaData[targetUnitId][targetSheetId][targetRow]) newFormulaData[targetUnitId][targetSheetId][targetRow] = Object.create(null);
2274
2298
  newFormulaData[targetUnitId][targetSheetId][targetRow][targetColumn] = { f: formulaString };
2275
2299
  }
2276
2300
  }
@@ -2335,7 +2359,7 @@ function tableReferenceContainsColumn(columnStruct, columnNames) {
2335
2359
  //#endregion
2336
2360
  //#region package.json
2337
2361
  var name = "@univerjs/sheets-formula";
2338
- var version = "1.0.0-rc.0";
2362
+ var version = "1.0.1";
2339
2363
 
2340
2364
  //#endregion
2341
2365
  //#region src/common/plugin-name.ts
@@ -2600,16 +2624,16 @@ let ActiveDirtyController = class ActiveDirtyController extends _univerjs_core.D
2600
2624
  return dirtyRanges;
2601
2625
  }
2602
2626
  _getRemoveSheetMutation(params) {
2603
- const dirtyNameMap = {};
2627
+ const dirtyNameMap = Object.create(null);
2604
2628
  const { subUnitId: sheetId, unitId, subUnitName } = params;
2605
- if (dirtyNameMap[unitId] == null) dirtyNameMap[unitId] = {};
2629
+ if (dirtyNameMap[unitId] == null) dirtyNameMap[unitId] = Object.create(null);
2606
2630
  dirtyNameMap[unitId][sheetId] = subUnitName;
2607
2631
  return dirtyNameMap;
2608
2632
  }
2609
2633
  _getInsertSheetMutation(params) {
2610
- const dirtyNameMap = {};
2634
+ const dirtyNameMap = Object.create(null);
2611
2635
  const { sheet, unitId } = params;
2612
- if (dirtyNameMap[unitId] == null) dirtyNameMap[unitId] = {};
2636
+ if (dirtyNameMap[unitId] == null) dirtyNameMap[unitId] = Object.create(null);
2613
2637
  dirtyNameMap[unitId][sheet.id] = sheet.name;
2614
2638
  return dirtyNameMap;
2615
2639
  }
@@ -2711,6 +2735,9 @@ let ArrayFormulaCellInterceptorController = class ArrayFormulaCellInterceptorCon
2711
2735
  const cellData = arrayFormulaCellData === null || arrayFormulaCellData === void 0 || (_arrayFormulaCellData = arrayFormulaCellData[unitId]) === null || _arrayFormulaCellData === void 0 || (_arrayFormulaCellData = _arrayFormulaCellData[subUnitId]) === null || _arrayFormulaCellData === void 0 || (_arrayFormulaCellData = _arrayFormulaCellData[row]) === null || _arrayFormulaCellData === void 0 ? void 0 : _arrayFormulaCellData[col];
2712
2736
  if (cellData == null) return next(cell);
2713
2737
  if (!cell || cell === location.rawData) cell = { ...location.rawData };
2738
+ cell.v = cellData.v;
2739
+ cell.t = cellData.t;
2740
+ cell.isInArrayFormulaRange = true;
2714
2741
  if (cellData.v == null && cellData.t == null) {
2715
2742
  cell.v = 0;
2716
2743
  cell.t = _univerjs_core.CellValueType.NUMBER;
@@ -2720,8 +2747,6 @@ let ArrayFormulaCellInterceptorController = class ArrayFormulaCellInterceptorCon
2720
2747
  cell.v = (0, _univerjs_engine_formula.stripErrorMargin)(Number(cell.v));
2721
2748
  return next(cell);
2722
2749
  }
2723
- cell.v = cellData.v;
2724
- cell.t = cellData.t;
2725
2750
  return next(cell);
2726
2751
  }
2727
2752
  }));
@@ -2981,7 +3006,8 @@ let SuperTableController = class SuperTableController extends _univerjs_core.Dis
2981
3006
  const { tableName, reference } = param;
2982
3007
  if (!this._descriptionService.hasDescription(tableName)) {
2983
3008
  var _this$_univerInstance;
2984
- const refString = (0, _univerjs_engine_formula.serializeRangeWithSheet)(((_this$_univerInstance = this._univerInstanceService.getUnit(unitId)) === null || _this$_univerInstance === void 0 || (_this$_univerInstance = _this$_univerInstance.getSheetBySheetId(reference.sheetId)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getName()) || "", reference.range);
3009
+ const sheetName = ((_this$_univerInstance = this._univerInstanceService.getUnit(unitId)) === null || _this$_univerInstance === void 0 || (_this$_univerInstance = _this$_univerInstance.getSheetBySheetId(reference.sheetId)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getName()) || "";
3010
+ const refString = (0, _univerjs_engine_formula.serializeRangeWithSheet)(sheetName, reference.range);
2985
3011
  this._descriptionService.registerDescriptions([{
2986
3012
  functionName: tableName,
2987
3013
  description: refString,
@@ -3027,7 +3053,8 @@ let SuperTableController = class SuperTableController extends _univerjs_core.Dis
3027
3053
  this._preUnitId = unitId;
3028
3054
  superTables.forEach((table, tableName) => {
3029
3055
  var _this$_univerInstance2;
3030
- const refString = (0, _univerjs_engine_formula.serializeRangeWithSheet)(((_this$_univerInstance2 = this._univerInstanceService.getUnit(unitId)) === null || _this$_univerInstance2 === void 0 || (_this$_univerInstance2 = _this$_univerInstance2.getSheetBySheetId(table.sheetId)) === null || _this$_univerInstance2 === void 0 ? void 0 : _this$_univerInstance2.getName()) || "", table.range);
3056
+ const sheetName = ((_this$_univerInstance2 = this._univerInstanceService.getUnit(unitId)) === null || _this$_univerInstance2 === void 0 || (_this$_univerInstance2 = _this$_univerInstance2.getSheetBySheetId(table.sheetId)) === null || _this$_univerInstance2 === void 0 ? void 0 : _this$_univerInstance2.getName()) || "";
3057
+ const refString = (0, _univerjs_engine_formula.serializeRangeWithSheet)(sheetName, table.range);
3031
3058
  if (!this._descriptionService.hasDescription(tableName)) functionList.push({
3032
3059
  functionName: tableName,
3033
3060
  description: refString,
@@ -3107,7 +3134,9 @@ let FormulaRefRangeService = class FormulaRefRangeService extends _univerjs_core
3107
3134
  const newRange = (0, _univerjs_sheets.handleDefaultRangeChangeWithEffectRefCommands)(range, params);
3108
3135
  let newToken = "";
3109
3136
  if (newRange) {
3110
- const finalRange = (0, _univerjs_core.moveRangeByOffset)(range, newRange.startColumn - range.startColumn, newRange.startRow - range.startRow);
3137
+ const offsetX = newRange.startColumn - range.startColumn;
3138
+ const offsetY = newRange.startRow - range.startRow;
3139
+ const finalRange = (0, _univerjs_core.moveRangeByOffset)(range, offsetX, offsetY);
3111
3140
  if (rangeUnitId && rangeSheetName) newToken = (0, _univerjs_engine_formula.serializeRangeWithSpreadsheet)(rangeUnitId, rangeSheetName, finalRange);
3112
3141
  else if (rangeSheetName) newToken = (0, _univerjs_engine_formula.serializeRangeWithSheet)(rangeSheetName, finalRange);
3113
3142
  else newToken = (0, _univerjs_engine_formula.serializeRange)(finalRange);
@@ -3489,7 +3518,8 @@ function calculateFormula(inject, formulaString, unitId, sheetData) {
3489
3518
  });
3490
3519
  const lexerNode = lexer.treeBuilder(formulaString);
3491
3520
  const astNode = astTreeBuilder.parse(lexerNode);
3492
- return (0, _univerjs_engine_formula.getObjectValue)(interpreter.execute((0, _univerjs_engine_formula.generateExecuteAstNodeData)(astNode)));
3521
+ const result = interpreter.execute((0, _univerjs_engine_formula.generateExecuteAstNodeData)(astNode));
3522
+ return (0, _univerjs_engine_formula.getObjectValue)(result);
3493
3523
  }
3494
3524
 
3495
3525
  //#endregion