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