@univerjs/sheets-formula 1.0.0-alpha.7 → 1.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/facade.js CHANGED
@@ -1,38 +1,10 @@
1
1
  let _univerjs_core = require("@univerjs/core");
2
- let _univerjs_core_facade = require("@univerjs/core/facade");
3
2
  let _univerjs_engine_formula = require("@univerjs/engine-formula");
4
- let _univerjs_formula = require("@univerjs/formula");
5
- require("@univerjs/formula/facade");
6
3
  let _univerjs_engine_formula_facade = require("@univerjs/engine-formula/facade");
7
4
  let _univerjs_sheets_formula = require("@univerjs/sheets-formula");
5
+ let _univerjs_core_facade = require("@univerjs/core/facade");
8
6
  let _univerjs_sheets_facade = require("@univerjs/sheets/facade");
9
7
 
10
- //#region src/facade/f-univer.ts
11
- /**
12
- * @ignore
13
- */
14
- var FUniverSheetsFormulaMixin = class extends _univerjs_core_facade.FUniver {
15
- /**
16
- * Initialize the FUniver instance.
17
- * @ignore
18
- */
19
- _initialize() {
20
- this._debouncedFormulaCalculation = (0, _univerjs_core.debounce)(() => {
21
- this._commandService.executeCommand(_univerjs_engine_formula.SetTriggerFormulaCalculationStartMutation.id, {
22
- commands: [],
23
- forceCalculation: true
24
- }, { onlyLocal: true });
25
- }, 10);
26
- }
27
- registerFunction(config) {
28
- const functionsDisposable = this._injector.get(_univerjs_formula.IRegisterFunctionService).registerFunctions(config);
29
- this._debouncedFormulaCalculation();
30
- return functionsDisposable;
31
- }
32
- };
33
- _univerjs_core_facade.FUniver.extend(FUniverSheetsFormulaMixin);
34
-
35
- //#endregion
36
8
  //#region src/facade/f-formula.ts
37
9
  var FFormulaSheetsMixin = class extends _univerjs_engine_formula_facade.FFormula {
38
10
  /**
@@ -60,12 +32,11 @@ var FFormulaSheetsMixin = class extends _univerjs_engine_formula_facade.FFormula
60
32
  config.initialFormulaComputing = calculationMode;
61
33
  }
62
34
  registerFunction(name, func, options) {
63
- var _options$description;
64
- const registerFunctionService = this._injector.get(_univerjs_formula.IRegisterFunctionService);
35
+ const registerFunctionService = this._injector.get(_univerjs_engine_formula.IRegisterFunctionService);
65
36
  const params = {
66
37
  name,
67
38
  func,
68
- description: typeof options === "string" ? options : (_options$description = options === null || options === void 0 ? void 0 : options.description) !== null && _options$description !== void 0 ? _options$description : "",
39
+ description: typeof options === "string" ? options : (options === null || options === void 0 ? void 0 : options.description) ?? "",
69
40
  locales: typeof options === "object" ? options.locales : void 0
70
41
  };
71
42
  const functionsDisposable = registerFunctionService.registerFunction(params);
@@ -73,12 +44,11 @@ var FFormulaSheetsMixin = class extends _univerjs_engine_formula_facade.FFormula
73
44
  return functionsDisposable;
74
45
  }
75
46
  registerAsyncFunction(name, func, options) {
76
- var _options$description2;
77
- const registerFunctionService = this._injector.get(_univerjs_formula.IRegisterFunctionService);
47
+ const registerFunctionService = this._injector.get(_univerjs_engine_formula.IRegisterFunctionService);
78
48
  const params = {
79
49
  name,
80
50
  func,
81
- description: typeof options === "string" ? options : (_options$description2 = options === null || options === void 0 ? void 0 : options.description) !== null && _options$description2 !== void 0 ? _options$description2 : "",
51
+ description: typeof options === "string" ? options : (options === null || options === void 0 ? void 0 : options.description) ?? "",
82
52
  locales: typeof options === "object" ? options.locales : void 0
83
53
  };
84
54
  const functionsDisposable = registerFunctionService.registerAsyncFunction(params);
package/lib/cjs/index.js CHANGED
@@ -4,7 +4,6 @@ let _univerjs_sheets = require("@univerjs/sheets");
4
4
  let _univerjs_engine_formula = require("@univerjs/engine-formula");
5
5
  let _univerjs_docs = require("@univerjs/docs");
6
6
  let rxjs = require("rxjs");
7
- let _univerjs_formula = require("@univerjs/formula");
8
7
  let _univerjs_rpc = require("@univerjs/rpc");
9
8
 
10
9
  //#region src/commands/commands/insert-function.command.ts
@@ -30,7 +29,7 @@ const InsertFunctionCommand = {
30
29
  const { primary, formula } = item;
31
30
  cellMatrix.setValue(primary.row, primary.column, { f: formula });
32
31
  });
33
- const setRangeValuesParams = { value: cellMatrix.getData() };
32
+ const setRangeValuesParams = { value: cellMatrix.clone() };
34
33
  return commandService.executeCommand(_univerjs_sheets.SetRangeValuesCommand.id, setRangeValuesParams);
35
34
  }
36
35
  };
@@ -155,7 +154,7 @@ const PLUGIN_CONFIG_KEY_MOBILE = "sheets-formula.mobile.config";
155
154
  const configSymbolMobile = Symbol(PLUGIN_CONFIG_KEY_MOBILE);
156
155
 
157
156
  //#endregion
158
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
157
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
159
158
  function __decorateParam(paramIndex, decorator) {
160
159
  return function(target, key) {
161
160
  decorator(target, key, paramIndex);
@@ -163,7 +162,7 @@ function __decorateParam(paramIndex, decorator) {
163
162
  }
164
163
 
165
164
  //#endregion
166
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
165
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
167
166
  function __decorate(decorators, target, key, desc) {
168
167
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
169
168
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -277,7 +276,7 @@ function getDataLength(copyDataPiece) {
277
276
  }
278
277
 
279
278
  //#endregion
280
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
279
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
281
280
  function _typeof(o) {
282
281
  "@babel/helpers - typeof";
283
282
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -288,7 +287,7 @@ function _typeof(o) {
288
287
  }
289
288
 
290
289
  //#endregion
291
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
290
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
292
291
  function toPrimitive(t, r) {
293
292
  if ("object" != _typeof(t) || !t) return t;
294
293
  var e = t[Symbol.toPrimitive];
@@ -301,14 +300,14 @@ function toPrimitive(t, r) {
301
300
  }
302
301
 
303
302
  //#endregion
304
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
303
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
305
304
  function toPropertyKey(t) {
306
305
  var i = toPrimitive(t, "string");
307
306
  return "symbol" == _typeof(i) ? i : i + "";
308
307
  }
309
308
 
310
309
  //#endregion
311
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
310
+ //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
312
311
  function _defineProperty(e, r, t) {
313
312
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
314
313
  value: t,
@@ -502,7 +501,7 @@ let TriggerCalculationController = class TriggerCalculationController extends _u
502
501
  this._totalCalculationTaskCount = 0;
503
502
  this._emitProgress();
504
503
  }
505
- constructor(_commandService, _univerInstanceService, _logService, _configService, _formulaDataModel, _localeService, _registerOtherFormulaService) {
504
+ constructor(_commandService, _univerInstanceService, _logService, _configService, _formulaDataModel, _localeService) {
506
505
  super();
507
506
  this._commandService = _commandService;
508
507
  this._univerInstanceService = _univerInstanceService;
@@ -510,7 +509,6 @@ let TriggerCalculationController = class TriggerCalculationController extends _u
510
509
  this._configService = _configService;
511
510
  this._formulaDataModel = _formulaDataModel;
512
511
  this._localeService = _localeService;
513
- this._registerOtherFormulaService = _registerOtherFormulaService;
514
512
  _defineProperty(this, "_startExecutionTime", 0);
515
513
  _defineProperty(this, "_totalCalculationTaskCount", 0);
516
514
  _defineProperty(this, "_doneCalculationTaskCount", 0);
@@ -530,9 +528,8 @@ let TriggerCalculationController = class TriggerCalculationController extends _u
530
528
  this._progress$.complete();
531
529
  }
532
530
  _getCalculationMode() {
533
- var _config$initialFormul;
534
531
  const config = this._configService.getConfig(PLUGIN_CONFIG_KEY_BASE);
535
- return (_config$initialFormul = config === null || config === void 0 ? void 0 : config.initialFormulaComputing) !== null && _config$initialFormul !== void 0 ? _config$initialFormul : 1;
532
+ return (config === null || config === void 0 ? void 0 : config.initialFormulaComputing) ?? 1;
536
533
  }
537
534
  _commandExecutedListener() {
538
535
  this.disposeWithMe(this._commandService.beforeCommandExecuted((command) => {
@@ -620,9 +617,10 @@ let TriggerCalculationController = class TriggerCalculationController extends _u
620
617
  }
621
618
  _initialExecuteFormula() {
622
619
  const calculationMode = this._getCalculationMode();
623
- const params = this._getDirtyDataByCalculationMode(calculationMode);
624
- this._commandService.executeCommand(_univerjs_engine_formula.SetTriggerFormulaCalculationStartMutation.id, params, lo);
625
- this._registerOtherFormulaService.calculateStarted$.next(true);
620
+ if (calculationMode !== 2) {
621
+ const params = this._getDirtyDataByCalculationMode(calculationMode);
622
+ this._commandService.executeCommand(_univerjs_engine_formula.SetTriggerFormulaCalculationStartMutation.id, params, lo);
623
+ }
626
624
  }
627
625
  _getDirtyDataByCalculationMode(calculationMode) {
628
626
  return {
@@ -643,8 +641,7 @@ TriggerCalculationController = __decorate([
643
641
  __decorateParam(2, _univerjs_core.ILogService),
644
642
  __decorateParam(3, _univerjs_core.IConfigService),
645
643
  __decorateParam(4, (0, _univerjs_core.Inject)(_univerjs_engine_formula.FormulaDataModel)),
646
- __decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService)),
647
- __decorateParam(6, (0, _univerjs_core.Inject)(_univerjs_engine_formula.RegisterOtherFormulaService))
644
+ __decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService))
648
645
  ], TriggerCalculationController);
649
646
 
650
647
  //#endregion
@@ -658,7 +655,7 @@ function collectUnitQualifierFormulaPatches(workbook, oldName, newName) {
658
655
  const formula = (0, _univerjs_engine_formula.refactorFormulaUnitQualifier)(cell.f, oldName, newName);
659
656
  if (formula !== cell.f) updates.setValue(row, column, { f: formula });
660
657
  });
661
- const cellValue = updates.getData();
658
+ const cellValue = updates.clone();
662
659
  return Object.keys(cellValue).length > 0 ? [{
663
660
  unitId,
664
661
  subUnitId: sheet.getSheetId(),
@@ -696,8 +693,7 @@ let UnitQualifierRenameController = class UnitQualifierRenameController extends
696
693
  if (!sheet) continue;
697
694
  const undoCellValue = new _univerjs_core.ObjectMatrix();
698
695
  new _univerjs_core.ObjectMatrix(patch.cellValue).forValue((row, column) => {
699
- var _sheet$getCellRaw;
700
- undoCellValue.setValue(row, column, (_sheet$getCellRaw = sheet.getCellRaw(row, column)) !== null && _sheet$getCellRaw !== void 0 ? _sheet$getCellRaw : null);
696
+ undoCellValue.setValue(row, column, sheet.getCellRaw(row, column) ?? null);
701
697
  });
702
698
  redos.push({
703
699
  id: _univerjs_sheets.SetRangeValuesMutation.id,
@@ -707,12 +703,12 @@ let UnitQualifierRenameController = class UnitQualifierRenameController extends
707
703
  id: _univerjs_sheets.SetRangeValuesMutation.id,
708
704
  params: {
709
705
  ...patch,
710
- cellValue: undoCellValue.getData()
706
+ cellValue: undoCellValue.clone()
711
707
  }
712
708
  });
713
709
  }
714
710
  const definedNames = this._definedNamesService.getDefinedNameMap(workbook.getUnitId());
715
- for (const item of Object.values(definedNames !== null && definedNames !== void 0 ? definedNames : {})) {
711
+ for (const item of Object.values(definedNames ?? {})) {
716
712
  const formulaOrRefString = (0, _univerjs_engine_formula.refactorFormulaUnitQualifier)(item.formulaOrRefString, oldName, newName);
717
713
  if (formulaOrRefString !== item.formulaOrRefString) {
718
714
  redos.push({
@@ -881,12 +877,11 @@ function getFormulaReferenceRange(oldFormulaData, newFormulaData, formulaReferen
881
877
  * @returns
882
878
  */
883
879
  function refRangeFormula(oldFormulaData, newFormulaData, formulaReferenceMoveParam) {
884
- var _formulaReferenceMove, _formulaReferenceMove2;
885
880
  const redoFormulaData = {};
886
881
  const undoFormulaData = {};
887
882
  const { unitId: fromUnitId, sheetId: fromSheetId } = formulaReferenceMoveParam;
888
- const targetUnitId = (_formulaReferenceMove = formulaReferenceMoveParam.targetUnitId) !== null && _formulaReferenceMove !== void 0 ? _formulaReferenceMove : fromUnitId;
889
- const targetSheetId = (_formulaReferenceMove2 = formulaReferenceMoveParam.targetSheetId) !== null && _formulaReferenceMove2 !== void 0 ? _formulaReferenceMove2 : fromSheetId;
883
+ const targetUnitId = formulaReferenceMoveParam.targetUnitId ?? fromUnitId;
884
+ const targetSheetId = formulaReferenceMoveParam.targetSheetId ?? fromSheetId;
890
885
  const isCrossSheet = fromUnitId !== targetUnitId || fromSheetId !== targetSheetId;
891
886
  (/* @__PURE__ */ new Set([...Object.keys(oldFormulaData), ...Object.keys(newFormulaData)])).forEach((unitId) => {
892
887
  if (checkFormulaDataNull(oldFormulaData, unitId, fromSheetId)) return;
@@ -1111,8 +1106,7 @@ function getRedoFormulaData(rangeList, oldFormulaMatrix, newFormulaMatrix) {
1111
1106
  si: null
1112
1107
  });
1113
1108
  if (newCell) {
1114
- var _newFormulaMatrix$get;
1115
- const newValue = formulaDataItemToCellData((_newFormulaMatrix$get = newFormulaMatrix.getValue(oldCell.startRow, oldCell.startColumn)) !== null && _newFormulaMatrix$get !== void 0 ? _newFormulaMatrix$get : oldFormulaMatrix.getValue(oldCell.startRow, oldCell.startColumn));
1109
+ const newValue = formulaDataItemToCellData(newFormulaMatrix.getValue(oldCell.startRow, oldCell.startColumn) ?? oldFormulaMatrix.getValue(oldCell.startRow, oldCell.startColumn));
1116
1110
  redoFormulaData.setValue(newCell.startRow, newCell.startColumn, newValue);
1117
1111
  }
1118
1112
  }
@@ -1132,7 +1126,7 @@ function getUndoFormulaData(rangeList, oldFormulaMatrix) {
1132
1126
  undoFormulaData.setValue(oldCell.startRow, oldCell.startColumn, oldCellOldValue);
1133
1127
  if (newCell) {
1134
1128
  const newCellOldValue = formulaDataItemToCellData(oldFormulaMatrix.getValue(newCell.startRow, newCell.startColumn));
1135
- undoFormulaData.setValue(newCell.startRow, newCell.startColumn, newCellOldValue !== null && newCellOldValue !== void 0 ? newCellOldValue : {
1129
+ undoFormulaData.setValue(newCell.startRow, newCell.startColumn, newCellOldValue ?? {
1136
1130
  f: null,
1137
1131
  si: null
1138
1132
  });
@@ -1575,7 +1569,7 @@ function getReferenceMoveParams(workbook, command) {
1575
1569
  result = handleRefRemoveRow(command, workbook);
1576
1570
  break;
1577
1571
  case _univerjs_sheets.RemoveColCommand.id:
1578
- result = handleRefRemoveCol(command, workbook);
1572
+ result = handleRefRemoveCol(command);
1579
1573
  break;
1580
1574
  case _univerjs_sheets.DeleteRangeMoveUpCommand.id:
1581
1575
  result = handleRefDeleteRangeMoveUp(command, workbook);
@@ -1750,24 +1744,22 @@ function handleRefInsertRangeMoveDown(command, workbook) {
1750
1744
  };
1751
1745
  }
1752
1746
  function handleRefRemoveRow(command, workbook) {
1753
- var _workbook$getSheetByS3, _workbook$getSheetByS4;
1747
+ var _workbook$getSheetByS3;
1754
1748
  const { params } = command;
1755
1749
  if (!params) return null;
1756
- const { range } = params;
1757
- const { unitId, sheetId } = getCurrentSheetInfo(workbook);
1750
+ const { range, unitId, subUnitId: sheetId } = params;
1758
1751
  return {
1759
1752
  type: 5,
1760
1753
  range,
1761
1754
  unitId,
1762
1755
  sheetId,
1763
- rangeFilteredRows: (_workbook$getSheetByS3 = (_workbook$getSheetByS4 = workbook.getSheetBySheetId(sheetId)) === null || _workbook$getSheetByS4 === void 0 ? void 0 : _workbook$getSheetByS4.getRangeFilterRows(range)) !== null && _workbook$getSheetByS3 !== void 0 ? _workbook$getSheetByS3 : []
1756
+ rangeFilteredRows: ((_workbook$getSheetByS3 = workbook.getSheetBySheetId(sheetId)) === null || _workbook$getSheetByS3 === void 0 ? void 0 : _workbook$getSheetByS3.getRangeFilterRows(range)) ?? []
1764
1757
  };
1765
1758
  }
1766
- function handleRefRemoveCol(command, workbook) {
1759
+ function handleRefRemoveCol(command) {
1767
1760
  const { params } = command;
1768
1761
  if (!params) return null;
1769
- const { range } = params;
1770
- const { unitId, sheetId } = getCurrentSheetInfo(workbook);
1762
+ const { range, unitId, subUnitId: sheetId } = params;
1771
1763
  return {
1772
1764
  type: 6,
1773
1765
  range,
@@ -1931,7 +1923,7 @@ let UpdateDefinedNameController = class UpdateDefinedNameController extends _uni
1931
1923
  };
1932
1924
  if (result.type === 12) {
1933
1925
  var _this$_univerInstance;
1934
- result.oldUnitName = (_this$_univerInstance = this._univerInstanceService.getUnit(result.unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getName();
1926
+ result.oldUnitName = (_this$_univerInstance = this._univerInstanceService.getUnit(result.unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.name;
1935
1927
  }
1936
1928
  return this._getUpdateDefinedNameMutations(workbook, result);
1937
1929
  } }));
@@ -2138,7 +2130,6 @@ let UpdateFormulaController = class UpdateFormulaController extends _univerjs_co
2138
2130
  this._commandService.executeCommand(_univerjs_engine_formula.SetFormulaDataMutation.id, { formulaData: newFormulaData }, { onlyLocal: true });
2139
2131
  }
2140
2132
  _handleWorkbookAdded(unit) {
2141
- var _config$initialFormul;
2142
2133
  const formulaData = {};
2143
2134
  const unitId = unit.getUnitId();
2144
2135
  const newFormulaData = { [unitId]: {} };
@@ -2151,7 +2142,7 @@ let UpdateFormulaController = class UpdateFormulaController extends _univerjs_co
2151
2142
  });
2152
2143
  this._commandService.executeCommand(_univerjs_engine_formula.SetFormulaDataMutation.id, { formulaData: newFormulaData }, { onlyLocal: true });
2153
2144
  const config = this._configService.getConfig(PLUGIN_CONFIG_KEY_BASE);
2154
- const calculationMode = (_config$initialFormul = config === null || config === void 0 ? void 0 : config.initialFormulaComputing) !== null && _config$initialFormul !== void 0 ? _config$initialFormul : 1;
2145
+ const calculationMode = (config === null || config === void 0 ? void 0 : config.initialFormulaComputing) ?? 1;
2155
2146
  const params = this._getDirtyDataByCalculationMode(calculationMode);
2156
2147
  this._commandService.executeCommand(_univerjs_engine_formula.SetTriggerFormulaCalculationStartMutation.id, params, { onlyLocal: true });
2157
2148
  }
@@ -2294,7 +2285,7 @@ let UpdateFormulaController = class UpdateFormulaController extends _univerjs_co
2294
2285
  };
2295
2286
  shouldModify = true;
2296
2287
  refChangeIds.push(i);
2297
- if (si && (x !== null && x !== void 0 ? x : 0) === 0 && (y !== null && y !== void 0 ? y : 0) === 0) shouldModifySi.push(si);
2288
+ if (si && (x ?? 0) === 0 && (y ?? 0) === 0) shouldModifySi.push(si);
2298
2289
  }
2299
2290
  /**
2300
2291
  * If the reference sequence range is not affected by the move, and the move is a cross-worksheet cut operation, it may be necessary to rewrite the sheet name in the ref string after move, to make sure the ref still works after move.
@@ -2335,7 +2326,7 @@ let UpdateFormulaController = class UpdateFormulaController extends _univerjs_co
2335
2326
  0
2336
2327
  ].includes(type)) {
2337
2328
  if (from && from.startRow <= row && row <= from.endRow && from.startColumn <= column && column <= from.endColumn) {
2338
- if ((x !== null && x !== void 0 ? x : 0) === 0 && (y !== null && y !== void 0 ? y : 0) === 0) shouldModifySi.push(si);
2329
+ if ((x ?? 0) === 0 && (y ?? 0) === 0) shouldModifySi.push(si);
2339
2330
  } else if (!shouldModifySi.includes(si)) return true;
2340
2331
  } else return true;
2341
2332
  if (inCrossSheetCutRange) {
@@ -2350,17 +2341,16 @@ let UpdateFormulaController = class UpdateFormulaController extends _univerjs_co
2350
2341
  const newSequenceNodes = updateRefOffset(sequenceNodes, refChangeIds, x, y);
2351
2342
  newFormulaDataItem.setValue(row, column, { f: `=${(0, _univerjs_engine_formula.generateStringWithSequence)(newSequenceNodes)}` });
2352
2343
  });
2353
- if (newFormulaData[unitId]) newFormulaData[unitId][sheetId] = newFormulaDataItem.getData();
2344
+ if (newFormulaData[unitId]) newFormulaData[unitId][sheetId] = newFormulaDataItem.clone();
2354
2345
  }
2355
2346
  }
2356
2347
  if (inCrossSheetCutRangeNewFormulas.length > 0 && targetUnitId && targetSheetId) {
2357
2348
  if (!newFormulaData[targetUnitId]) newFormulaData[targetUnitId] = {};
2358
2349
  if (!newFormulaData[targetUnitId][targetSheetId]) newFormulaData[targetUnitId][targetSheetId] = {};
2359
2350
  for (const newFormula of inCrossSheetCutRangeNewFormulas) {
2360
- var _to$startRow, _from$startRow, _to$startColumn, _from$startColumn;
2361
2351
  const { fromRow, fromColumn, formulaString } = newFormula;
2362
- const targetRow = fromRow + (((_to$startRow = to === null || to === void 0 ? void 0 : to.startRow) !== null && _to$startRow !== void 0 ? _to$startRow : 0) - ((_from$startRow = from === null || from === void 0 ? void 0 : from.startRow) !== null && _from$startRow !== void 0 ? _from$startRow : 0));
2363
- const targetColumn = fromColumn + (((_to$startColumn = to === null || to === void 0 ? void 0 : to.startColumn) !== null && _to$startColumn !== void 0 ? _to$startColumn : 0) - ((_from$startColumn = from === null || from === void 0 ? void 0 : from.startColumn) !== null && _from$startColumn !== void 0 ? _from$startColumn : 0));
2352
+ const targetRow = fromRow + (((to === null || to === void 0 ? void 0 : to.startRow) ?? 0) - ((from === null || from === void 0 ? void 0 : from.startRow) ?? 0));
2353
+ const targetColumn = fromColumn + (((to === null || to === void 0 ? void 0 : to.startColumn) ?? 0) - ((from === null || from === void 0 ? void 0 : from.startColumn) ?? 0));
2364
2354
  if (!newFormulaData[targetUnitId][targetSheetId][targetRow]) newFormulaData[targetUnitId][targetSheetId][targetRow] = {};
2365
2355
  newFormulaData[targetUnitId][targetSheetId][targetRow][targetColumn] = { f: formulaString };
2366
2356
  }
@@ -2426,7 +2416,7 @@ function tableReferenceContainsColumn(columnStruct, columnNames) {
2426
2416
  //#endregion
2427
2417
  //#region package.json
2428
2418
  var name = "@univerjs/sheets-formula";
2429
- var version = "1.0.0-alpha.7";
2419
+ var version = "1.0.0-beta.0";
2430
2420
 
2431
2421
  //#endregion
2432
2422
  //#region src/common/plugin-name.ts
@@ -2582,12 +2572,6 @@ let ActiveDirtyController = class ActiveDirtyController extends _univerjs_core.D
2582
2572
  });
2583
2573
  }
2584
2574
  _initialSheet() {
2585
- this._activeDirtyManagerService.register(_univerjs_engine_formula.SetTriggerFormulaCalculationStartMutation.id, {
2586
- commandId: _univerjs_engine_formula.SetTriggerFormulaCalculationStartMutation.id,
2587
- getDirtyData: (command) => {
2588
- return { ...command.params };
2589
- }
2590
- });
2591
2575
  this._activeDirtyManagerService.register(_univerjs_sheets.RemoveSheetMutation.id, {
2592
2576
  commandId: _univerjs_sheets.RemoveSheetMutation.id,
2593
2577
  getDirtyData: (command) => {
@@ -2646,8 +2630,8 @@ let ActiveDirtyController = class ActiveDirtyController extends _univerjs_core.D
2646
2630
  _getMoveRowsMutationDirtyRange(params) {
2647
2631
  const { subUnitId: sheetId, unitId, sourceRange, targetRange } = params;
2648
2632
  const dirtyRanges = [];
2649
- const sourceMatrix = this._rangeToMatrix(sourceRange).getData();
2650
- const targetMatrix = this._rangeToMatrix(targetRange).getData();
2633
+ const sourceMatrix = this._rangeToMatrix(sourceRange).clone();
2634
+ const targetMatrix = this._rangeToMatrix(targetRange).clone();
2651
2635
  dirtyRanges.push(...this._getDirtyRangesByCellValue(unitId, sheetId, sourceMatrix));
2652
2636
  dirtyRanges.push(...this._getDirtyRangesByCellValue(unitId, sheetId, targetMatrix));
2653
2637
  dirtyRanges.push(...this._getDirtyRangesForArrayFormula(unitId, sheetId, targetMatrix));
@@ -2655,7 +2639,7 @@ let ActiveDirtyController = class ActiveDirtyController extends _univerjs_core.D
2655
2639
  }
2656
2640
  _getReorderRangeMutationDirtyRange(params) {
2657
2641
  const { unitId, subUnitId: sheetId, range } = params;
2658
- const matrix = this._rangeToMatrix(range).getData();
2642
+ const matrix = this._rangeToMatrix(range).clone();
2659
2643
  const dirtyRanges = [];
2660
2644
  dirtyRanges.push(...this._getDirtyRangesByCellValue(unitId, sheetId, matrix));
2661
2645
  dirtyRanges.push(...this._getDirtyRangesForArrayFormula(unitId, sheetId, matrix));
@@ -2664,7 +2648,7 @@ let ActiveDirtyController = class ActiveDirtyController extends _univerjs_core.D
2664
2648
  _getRemoveRowOrColumnMutation(params, isRow = true) {
2665
2649
  const { subUnitId: sheetId, unitId, range } = params;
2666
2650
  const dirtyRanges = [];
2667
- const workbook = this._univerInstanceService.getUniverSheetInstance(unitId);
2651
+ const workbook = this._univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_SHEET);
2668
2652
  const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getSheetBySheetId(sheetId);
2669
2653
  const rowCount = (worksheet === null || worksheet === void 0 ? void 0 : worksheet.getRowCount()) || 0;
2670
2654
  const columnCount = (worksheet === null || worksheet === void 0 ? void 0 : worksheet.getColumnCount()) || 0;
@@ -2682,7 +2666,7 @@ let ActiveDirtyController = class ActiveDirtyController extends _univerjs_core.D
2682
2666
  endRow: rowCount,
2683
2667
  endColumn
2684
2668
  });
2685
- const matrixData = matrix.getData();
2669
+ const matrixData = matrix.clone();
2686
2670
  dirtyRanges.push(...this._getDirtyRangesByCellValue(unitId, sheetId, matrixData));
2687
2671
  dirtyRanges.push(...this._getDirtyRangesForArrayFormula(unitId, sheetId, matrixData));
2688
2672
  return dirtyRanges;
@@ -2967,7 +2951,7 @@ let DefinedNameController = class DefinedNameController extends _univerjs_core.D
2967
2951
  }
2968
2952
  };
2969
2953
  DefinedNameController = __decorate([
2970
- __decorateParam(0, _univerjs_formula.IDescriptionService),
2954
+ __decorateParam(0, _univerjs_engine_formula.IDescriptionService),
2971
2955
  __decorateParam(1, _univerjs_engine_formula.IDefinedNamesService),
2972
2956
  __decorateParam(2, _univerjs_core.IUniverInstanceService),
2973
2957
  __decorateParam(3, _univerjs_core.ICommandService)
@@ -2994,11 +2978,7 @@ let FormulaController = class FormulaController extends _univerjs_core.Disposabl
2994
2978
  constructor(_commandService) {
2995
2979
  super();
2996
2980
  this._commandService = _commandService;
2997
- [
2998
- InsertFunctionCommand,
2999
- QuickSumCommand,
3000
- _univerjs_engine_formula.OtherFormulaMarkDirty
3001
- ].forEach((c) => this._commandService.registerCommand(c));
2981
+ [InsertFunctionCommand, QuickSumCommand].forEach((c) => this._commandService.registerCommand(c));
3002
2982
  }
3003
2983
  };
3004
2984
  FormulaController = __decorate([__decorateParam(0, _univerjs_core.ICommandService)], FormulaController);
@@ -3026,11 +3006,11 @@ let SheetFormulaCalculationResultApplyController = class SheetFormulaCalculation
3026
3006
  this._commandService = _commandService;
3027
3007
  this._sessionService = _sessionService;
3028
3008
  this.disposeWithMe(this._commandService.onCommandExecuted((command, options) => {
3029
- if (command.id === _univerjs_sheets.SetRangeValuesMutation.id && (options === null || options === void 0 ? void 0 : options.applyFormulaCalculationResult)) this._sessionService.markResultApplied(_univerjs_formula.FormulaResultApplicationType.SHEET);
3009
+ if (command.id === _univerjs_sheets.SetRangeValuesMutation.id && (options === null || options === void 0 ? void 0 : options.applyFormulaCalculationResult)) this._sessionService.markResultApplied(_univerjs_engine_formula.FormulaResultApplicationType.SHEET);
3030
3010
  }));
3031
3011
  }
3032
3012
  };
3033
- SheetFormulaCalculationResultApplyController = __decorate([__decorateParam(0, _univerjs_core.ICommandService), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_formula.FormulaCalculationSessionService))], SheetFormulaCalculationResultApplyController);
3013
+ SheetFormulaCalculationResultApplyController = __decorate([__decorateParam(0, _univerjs_core.ICommandService), __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_engine_formula.FormulaCalculationSessionService))], SheetFormulaCalculationResultApplyController);
3034
3014
 
3035
3015
  //#endregion
3036
3016
  //#region src/controllers/super-table.controller.ts
@@ -3153,7 +3133,7 @@ let SuperTableController = class SuperTableController extends _univerjs_core.Dis
3153
3133
  }
3154
3134
  };
3155
3135
  SuperTableController = __decorate([
3156
- __decorateParam(0, _univerjs_formula.IDescriptionService),
3136
+ __decorateParam(0, _univerjs_engine_formula.IDescriptionService),
3157
3137
  __decorateParam(1, _univerjs_core.IUniverInstanceService),
3158
3138
  __decorateParam(2, _univerjs_core.ICommandService),
3159
3139
  __decorateParam(3, _univerjs_engine_formula.ISuperTableService)
@@ -3537,7 +3517,7 @@ let UniverSheetsFormulaPlugin = class UniverSheetsFormulaPlugin extends _univerj
3537
3517
  dependencies.push([IRemoteRegisterFunctionService, { useFactory: () => (0, _univerjs_rpc.toModule)(rpcChannelService.requestChannel(RemoteRegisterFunctionServiceName)) }]);
3538
3518
  }
3539
3519
  dependencies.forEach((dependency) => j.add(dependency));
3540
- if ((_this$_config$descrip = this._config.description) === null || _this$_config$descrip === void 0 ? void 0 : _this$_config$descrip.length) this.disposeWithMe(j.get(_univerjs_formula.IDescriptionService).registerDescriptions(this._config.description));
3520
+ if ((_this$_config$descrip = this._config.description) === null || _this$_config$descrip === void 0 ? void 0 : _this$_config$descrip.length) this.disposeWithMe(j.get(_univerjs_engine_formula.IDescriptionService).registerDescriptions(this._config.description));
3541
3521
  }
3542
3522
  onReady() {
3543
3523
  (0, _univerjs_core.touchDependencies)(this._injector, [
@@ -3563,7 +3543,7 @@ _defineProperty(UniverSheetsFormulaPlugin, "packageName", name);
3563
3543
  _defineProperty(UniverSheetsFormulaPlugin, "version", version);
3564
3544
  _defineProperty(UniverSheetsFormulaPlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_SHEET);
3565
3545
  UniverSheetsFormulaPlugin = __decorate([
3566
- (0, _univerjs_core.DependentOn)(_univerjs_formula.UniverFormulaPlugin, _univerjs_sheets.UniverSheetsPlugin),
3546
+ (0, _univerjs_core.DependentOn)(_univerjs_engine_formula.UniverFormulaEnginePlugin, _univerjs_sheets.UniverSheetsPlugin),
3567
3547
  __decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
3568
3548
  __decorateParam(2, _univerjs_core.IConfigService)
3569
3549
  ], UniverSheetsFormulaPlugin);
package/lib/es/facade.js CHANGED
@@ -1,38 +1,10 @@
1
1
  import { IConfigService, ILogService, LifecycleService, LifecycleStages, debounce } from "@univerjs/core";
2
- import { FEnum, FUniver } from "@univerjs/core/facade";
3
- import { FormulaDataModel, SetTriggerFormulaCalculationStartMutation, extractFormulaError } from "@univerjs/engine-formula";
4
- import { IRegisterFunctionService } from "@univerjs/formula";
5
- import "@univerjs/formula/facade";
2
+ import { FormulaDataModel, IRegisterFunctionService, SetTriggerFormulaCalculationStartMutation, extractFormulaError } from "@univerjs/engine-formula";
6
3
  import { FFormula } from "@univerjs/engine-formula/facade";
7
4
  import { CalculationMode, PLUGIN_CONFIG_KEY_BASE } from "@univerjs/sheets-formula";
5
+ import { FEnum } from "@univerjs/core/facade";
8
6
  import { FRange, FWorkbook } from "@univerjs/sheets/facade";
9
7
 
10
- //#region src/facade/f-univer.ts
11
- /**
12
- * @ignore
13
- */
14
- var FUniverSheetsFormulaMixin = class extends FUniver {
15
- /**
16
- * Initialize the FUniver instance.
17
- * @ignore
18
- */
19
- _initialize() {
20
- this._debouncedFormulaCalculation = debounce(() => {
21
- this._commandService.executeCommand(SetTriggerFormulaCalculationStartMutation.id, {
22
- commands: [],
23
- forceCalculation: true
24
- }, { onlyLocal: true });
25
- }, 10);
26
- }
27
- registerFunction(config) {
28
- const functionsDisposable = this._injector.get(IRegisterFunctionService).registerFunctions(config);
29
- this._debouncedFormulaCalculation();
30
- return functionsDisposable;
31
- }
32
- };
33
- FUniver.extend(FUniverSheetsFormulaMixin);
34
-
35
- //#endregion
36
8
  //#region src/facade/f-formula.ts
37
9
  var FFormulaSheetsMixin = class extends FFormula {
38
10
  /**
@@ -60,12 +32,11 @@ var FFormulaSheetsMixin = class extends FFormula {
60
32
  config.initialFormulaComputing = calculationMode;
61
33
  }
62
34
  registerFunction(name, func, options) {
63
- var _options$description;
64
35
  const registerFunctionService = this._injector.get(IRegisterFunctionService);
65
36
  const params = {
66
37
  name,
67
38
  func,
68
- description: typeof options === "string" ? options : (_options$description = options === null || options === void 0 ? void 0 : options.description) !== null && _options$description !== void 0 ? _options$description : "",
39
+ description: typeof options === "string" ? options : (options === null || options === void 0 ? void 0 : options.description) ?? "",
69
40
  locales: typeof options === "object" ? options.locales : void 0
70
41
  };
71
42
  const functionsDisposable = registerFunctionService.registerFunction(params);
@@ -73,12 +44,11 @@ var FFormulaSheetsMixin = class extends FFormula {
73
44
  return functionsDisposable;
74
45
  }
75
46
  registerAsyncFunction(name, func, options) {
76
- var _options$description2;
77
47
  const registerFunctionService = this._injector.get(IRegisterFunctionService);
78
48
  const params = {
79
49
  name,
80
50
  func,
81
- description: typeof options === "string" ? options : (_options$description2 = options === null || options === void 0 ? void 0 : options.description) !== null && _options$description2 !== void 0 ? _options$description2 : "",
51
+ description: typeof options === "string" ? options : (options === null || options === void 0 ? void 0 : options.description) ?? "",
82
52
  locales: typeof options === "object" ? options.locales : void 0
83
53
  };
84
54
  const functionsDisposable = registerFunctionService.registerAsyncFunction(params);