@univerjs/sheets-formula 0.22.1 → 0.23.0-insiders.20260522-e8f2a3b
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 +5 -0
- package/lib/cjs/index.js +30 -12
- package/lib/es/facade.js +5 -0
- package/lib/es/index.js +30 -12
- package/lib/facade.js +5 -0
- package/lib/index.js +30 -12
- package/lib/types/controllers/trigger-calculation.controller.d.ts +3 -2
- package/lib/types/facade/f-formula.d.ts +1 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +8 -8
- package/LICENSE +0 -176
package/lib/cjs/facade.js
CHANGED
|
@@ -106,6 +106,7 @@ var FFormulaSheetsMixin = class extends _univerjs_engine_formula_facade.FFormula
|
|
|
106
106
|
if (command.id === _univerjs_engine_formula.SetFormulaCalculationResultMutation.id) {
|
|
107
107
|
setFormulaCalculationResult = true;
|
|
108
108
|
result = command.params;
|
|
109
|
+
applyFormulaCalculationResult = applyFormulaCalculationResult || !this._hasFormulaResultToApply(result);
|
|
109
110
|
}
|
|
110
111
|
if (command.id === _univerjs_sheets.SetRangeValuesMutation.id && (options === null || options === void 0 ? void 0 : options.applyFormulaCalculationResult)) applyFormulaCalculationResult = true;
|
|
111
112
|
if (!setFormulaCalculationResult || !applyFormulaCalculationResult) return;
|
|
@@ -114,6 +115,10 @@ var FFormulaSheetsMixin = class extends _univerjs_engine_formula_facade.FFormula
|
|
|
114
115
|
});
|
|
115
116
|
});
|
|
116
117
|
}
|
|
118
|
+
_hasFormulaResultToApply(result) {
|
|
119
|
+
const { unitData } = result;
|
|
120
|
+
return Object.values(unitData !== null && unitData !== void 0 ? unitData : {}).some((sheetData) => sheetData != null && Object.values(sheetData).some((cellData) => cellData != null));
|
|
121
|
+
}
|
|
117
122
|
onCalculationResultApplied() {
|
|
118
123
|
return new Promise((resolve, reject) => {
|
|
119
124
|
let started = false;
|
package/lib/cjs/index.js
CHANGED
|
@@ -513,9 +513,10 @@ let TriggerCalculationController = class TriggerCalculationController extends _u
|
|
|
513
513
|
this._totalCalculationTaskCount = 0;
|
|
514
514
|
this._emitProgress();
|
|
515
515
|
}
|
|
516
|
-
constructor(_commandService, _activeDirtyManagerService, _logService, _configService, _formulaDataModel, _localeService, _registerOtherFormulaService) {
|
|
516
|
+
constructor(_commandService, _univerInstanceService, _activeDirtyManagerService, _logService, _configService, _formulaDataModel, _localeService, _registerOtherFormulaService) {
|
|
517
517
|
super();
|
|
518
518
|
this._commandService = _commandService;
|
|
519
|
+
this._univerInstanceService = _univerInstanceService;
|
|
519
520
|
this._activeDirtyManagerService = _activeDirtyManagerService;
|
|
520
521
|
this._logService = _logService;
|
|
521
522
|
this._configService = _configService;
|
|
@@ -543,6 +544,9 @@ let TriggerCalculationController = class TriggerCalculationController extends _u
|
|
|
543
544
|
this._commandExecutedListener();
|
|
544
545
|
this._initialExecuteFormulaProcessListener();
|
|
545
546
|
this._initialExecuteFormula();
|
|
547
|
+
this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(_univerjs_core.UniverInstanceType.UNIVER_SHEET).subscribe(() => {
|
|
548
|
+
this._initialExecuteFormula();
|
|
549
|
+
}));
|
|
546
550
|
}
|
|
547
551
|
dispose() {
|
|
548
552
|
super.dispose();
|
|
@@ -786,12 +790,13 @@ let TriggerCalculationController = class TriggerCalculationController extends _u
|
|
|
786
790
|
};
|
|
787
791
|
TriggerCalculationController = __decorate([
|
|
788
792
|
__decorateParam(0, _univerjs_core.ICommandService),
|
|
789
|
-
__decorateParam(1,
|
|
790
|
-
__decorateParam(2,
|
|
791
|
-
__decorateParam(3, _univerjs_core.
|
|
792
|
-
__decorateParam(4,
|
|
793
|
-
__decorateParam(5, (0, _univerjs_core.Inject)(
|
|
794
|
-
__decorateParam(6, (0, _univerjs_core.Inject)(
|
|
793
|
+
__decorateParam(1, _univerjs_core.IUniverInstanceService),
|
|
794
|
+
__decorateParam(2, _univerjs_engine_formula.IActiveDirtyManagerService),
|
|
795
|
+
__decorateParam(3, _univerjs_core.ILogService),
|
|
796
|
+
__decorateParam(4, _univerjs_core.IConfigService),
|
|
797
|
+
__decorateParam(5, (0, _univerjs_core.Inject)(_univerjs_engine_formula.FormulaDataModel)),
|
|
798
|
+
__decorateParam(6, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService)),
|
|
799
|
+
__decorateParam(7, (0, _univerjs_core.Inject)(_univerjs_engine_formula.RegisterOtherFormulaService))
|
|
795
800
|
], TriggerCalculationController);
|
|
796
801
|
|
|
797
802
|
//#endregion
|
|
@@ -2036,7 +2041,18 @@ let UpdateFormulaController = class UpdateFormulaController extends _univerjs_co
|
|
|
2036
2041
|
const { subUnitId: sheetId, unitId, cellValue } = params;
|
|
2037
2042
|
if (cellValue == null) return;
|
|
2038
2043
|
const newSheetFormulaData = this._formulaDataModel.updateFormulaData(unitId, sheetId, cellValue);
|
|
2039
|
-
|
|
2044
|
+
const arrayFormulaCellDataChanged = this._formulaDataModel.updateArrayFormulaCellData(unitId, sheetId, cellValue);
|
|
2045
|
+
const arrayFormulaRangeChanged = this._formulaDataModel.updateArrayFormulaRange(unitId, sheetId, cellValue);
|
|
2046
|
+
if (Object.keys(newSheetFormulaData).length === 0) {
|
|
2047
|
+
if (arrayFormulaCellDataChanged || arrayFormulaRangeChanged) this._commandService.executeCommand(_univerjs_engine_formula.SetArrayFormulaDataMutation.id, {
|
|
2048
|
+
arrayFormulaRange: this._formulaDataModel.getArrayFormulaRange(),
|
|
2049
|
+
arrayFormulaCellData: this._formulaDataModel.getArrayFormulaCellData()
|
|
2050
|
+
}, {
|
|
2051
|
+
onlyLocal: true,
|
|
2052
|
+
remove: true
|
|
2053
|
+
});
|
|
2054
|
+
return;
|
|
2055
|
+
}
|
|
2040
2056
|
const newFormulaData = { [unitId]: { [sheetId]: newSheetFormulaData } };
|
|
2041
2057
|
this._commandService.executeCommand(_univerjs_sheets.SetRangeValuesMutation.id, {
|
|
2042
2058
|
unitId,
|
|
@@ -2046,8 +2062,6 @@ let UpdateFormulaController = class UpdateFormulaController extends _univerjs_co
|
|
|
2046
2062
|
onlyLocal: true,
|
|
2047
2063
|
fromFormula: true
|
|
2048
2064
|
});
|
|
2049
|
-
this._formulaDataModel.updateArrayFormulaCellData(unitId, sheetId, cellValue);
|
|
2050
|
-
this._formulaDataModel.updateArrayFormulaRange(unitId, sheetId, cellValue);
|
|
2051
2065
|
this._formulaDataModel.updateImageFormulaData(unitId, sheetId, cellValue);
|
|
2052
2066
|
this._commandService.executeCommand(_univerjs_engine_formula.SetFormulaDataMutation.id, { formulaData: newFormulaData }, { onlyLocal: true });
|
|
2053
2067
|
this._commandService.executeCommand(_univerjs_engine_formula.SetArrayFormulaDataMutation.id, {
|
|
@@ -2296,7 +2310,7 @@ UpdateFormulaController = __decorate([
|
|
|
2296
2310
|
//#endregion
|
|
2297
2311
|
//#region package.json
|
|
2298
2312
|
var name = "@univerjs/sheets-formula";
|
|
2299
|
-
var version = "0.
|
|
2313
|
+
var version = "0.23.0-insiders.20260522-e8f2a3b";
|
|
2300
2314
|
|
|
2301
2315
|
//#endregion
|
|
2302
2316
|
//#region src/common/plugin-name.ts
|
|
@@ -16035,7 +16049,11 @@ let FormulaRefRangeService = class FormulaRefRangeService extends _univerjs_core
|
|
|
16035
16049
|
const offsetRow = currentStartRow - originStartRow;
|
|
16036
16050
|
const offsetColumn = currentStartColumn - originStartColumn;
|
|
16037
16051
|
for (const range of effectedRanges.ranges) {
|
|
16038
|
-
const intersectedRange =
|
|
16052
|
+
const intersectedRange = [];
|
|
16053
|
+
for (const r of ranges) {
|
|
16054
|
+
const intersect = (0, _univerjs_core.getIntersectRange)(range, r);
|
|
16055
|
+
if (intersect) intersectedRange.push(intersect);
|
|
16056
|
+
}
|
|
16039
16057
|
if (intersectedRange.length > 0) intersectedRanges.push(...intersectedRange);
|
|
16040
16058
|
}
|
|
16041
16059
|
if (intersectedRanges.length > 0) matchedEffectedRanges.push(intersectedRanges.map((range) => ({
|
package/lib/es/facade.js
CHANGED
|
@@ -106,6 +106,7 @@ var FFormulaSheetsMixin = class extends FFormula {
|
|
|
106
106
|
if (command.id === SetFormulaCalculationResultMutation.id) {
|
|
107
107
|
setFormulaCalculationResult = true;
|
|
108
108
|
result = command.params;
|
|
109
|
+
applyFormulaCalculationResult = applyFormulaCalculationResult || !this._hasFormulaResultToApply(result);
|
|
109
110
|
}
|
|
110
111
|
if (command.id === SetRangeValuesMutation.id && (options === null || options === void 0 ? void 0 : options.applyFormulaCalculationResult)) applyFormulaCalculationResult = true;
|
|
111
112
|
if (!setFormulaCalculationResult || !applyFormulaCalculationResult) return;
|
|
@@ -114,6 +115,10 @@ var FFormulaSheetsMixin = class extends FFormula {
|
|
|
114
115
|
});
|
|
115
116
|
});
|
|
116
117
|
}
|
|
118
|
+
_hasFormulaResultToApply(result) {
|
|
119
|
+
const { unitData } = result;
|
|
120
|
+
return Object.values(unitData !== null && unitData !== void 0 ? unitData : {}).some((sheetData) => sheetData != null && Object.values(sheetData).some((cellData) => cellData != null));
|
|
121
|
+
}
|
|
117
122
|
onCalculationResultApplied() {
|
|
118
123
|
return new Promise((resolve, reject) => {
|
|
119
124
|
let started = false;
|
package/lib/es/index.js
CHANGED
|
@@ -512,9 +512,10 @@ let TriggerCalculationController = class TriggerCalculationController extends Di
|
|
|
512
512
|
this._totalCalculationTaskCount = 0;
|
|
513
513
|
this._emitProgress();
|
|
514
514
|
}
|
|
515
|
-
constructor(_commandService, _activeDirtyManagerService, _logService, _configService, _formulaDataModel, _localeService, _registerOtherFormulaService) {
|
|
515
|
+
constructor(_commandService, _univerInstanceService, _activeDirtyManagerService, _logService, _configService, _formulaDataModel, _localeService, _registerOtherFormulaService) {
|
|
516
516
|
super();
|
|
517
517
|
this._commandService = _commandService;
|
|
518
|
+
this._univerInstanceService = _univerInstanceService;
|
|
518
519
|
this._activeDirtyManagerService = _activeDirtyManagerService;
|
|
519
520
|
this._logService = _logService;
|
|
520
521
|
this._configService = _configService;
|
|
@@ -542,6 +543,9 @@ let TriggerCalculationController = class TriggerCalculationController extends Di
|
|
|
542
543
|
this._commandExecutedListener();
|
|
543
544
|
this._initialExecuteFormulaProcessListener();
|
|
544
545
|
this._initialExecuteFormula();
|
|
546
|
+
this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(UniverInstanceType.UNIVER_SHEET).subscribe(() => {
|
|
547
|
+
this._initialExecuteFormula();
|
|
548
|
+
}));
|
|
545
549
|
}
|
|
546
550
|
dispose() {
|
|
547
551
|
super.dispose();
|
|
@@ -785,12 +789,13 @@ let TriggerCalculationController = class TriggerCalculationController extends Di
|
|
|
785
789
|
};
|
|
786
790
|
TriggerCalculationController = __decorate([
|
|
787
791
|
__decorateParam(0, ICommandService),
|
|
788
|
-
__decorateParam(1,
|
|
789
|
-
__decorateParam(2,
|
|
790
|
-
__decorateParam(3,
|
|
791
|
-
__decorateParam(4,
|
|
792
|
-
__decorateParam(5, Inject(
|
|
793
|
-
__decorateParam(6, Inject(
|
|
792
|
+
__decorateParam(1, IUniverInstanceService),
|
|
793
|
+
__decorateParam(2, IActiveDirtyManagerService),
|
|
794
|
+
__decorateParam(3, ILogService),
|
|
795
|
+
__decorateParam(4, IConfigService),
|
|
796
|
+
__decorateParam(5, Inject(FormulaDataModel)),
|
|
797
|
+
__decorateParam(6, Inject(LocaleService)),
|
|
798
|
+
__decorateParam(7, Inject(RegisterOtherFormulaService))
|
|
794
799
|
], TriggerCalculationController);
|
|
795
800
|
|
|
796
801
|
//#endregion
|
|
@@ -2035,7 +2040,18 @@ let UpdateFormulaController = class UpdateFormulaController extends Disposable {
|
|
|
2035
2040
|
const { subUnitId: sheetId, unitId, cellValue } = params;
|
|
2036
2041
|
if (cellValue == null) return;
|
|
2037
2042
|
const newSheetFormulaData = this._formulaDataModel.updateFormulaData(unitId, sheetId, cellValue);
|
|
2038
|
-
|
|
2043
|
+
const arrayFormulaCellDataChanged = this._formulaDataModel.updateArrayFormulaCellData(unitId, sheetId, cellValue);
|
|
2044
|
+
const arrayFormulaRangeChanged = this._formulaDataModel.updateArrayFormulaRange(unitId, sheetId, cellValue);
|
|
2045
|
+
if (Object.keys(newSheetFormulaData).length === 0) {
|
|
2046
|
+
if (arrayFormulaCellDataChanged || arrayFormulaRangeChanged) this._commandService.executeCommand(SetArrayFormulaDataMutation.id, {
|
|
2047
|
+
arrayFormulaRange: this._formulaDataModel.getArrayFormulaRange(),
|
|
2048
|
+
arrayFormulaCellData: this._formulaDataModel.getArrayFormulaCellData()
|
|
2049
|
+
}, {
|
|
2050
|
+
onlyLocal: true,
|
|
2051
|
+
remove: true
|
|
2052
|
+
});
|
|
2053
|
+
return;
|
|
2054
|
+
}
|
|
2039
2055
|
const newFormulaData = { [unitId]: { [sheetId]: newSheetFormulaData } };
|
|
2040
2056
|
this._commandService.executeCommand(SetRangeValuesMutation.id, {
|
|
2041
2057
|
unitId,
|
|
@@ -2045,8 +2061,6 @@ let UpdateFormulaController = class UpdateFormulaController extends Disposable {
|
|
|
2045
2061
|
onlyLocal: true,
|
|
2046
2062
|
fromFormula: true
|
|
2047
2063
|
});
|
|
2048
|
-
this._formulaDataModel.updateArrayFormulaCellData(unitId, sheetId, cellValue);
|
|
2049
|
-
this._formulaDataModel.updateArrayFormulaRange(unitId, sheetId, cellValue);
|
|
2050
2064
|
this._formulaDataModel.updateImageFormulaData(unitId, sheetId, cellValue);
|
|
2051
2065
|
this._commandService.executeCommand(SetFormulaDataMutation.id, { formulaData: newFormulaData }, { onlyLocal: true });
|
|
2052
2066
|
this._commandService.executeCommand(SetArrayFormulaDataMutation.id, {
|
|
@@ -2295,7 +2309,7 @@ UpdateFormulaController = __decorate([
|
|
|
2295
2309
|
//#endregion
|
|
2296
2310
|
//#region package.json
|
|
2297
2311
|
var name = "@univerjs/sheets-formula";
|
|
2298
|
-
var version = "0.
|
|
2312
|
+
var version = "0.23.0-insiders.20260522-e8f2a3b";
|
|
2299
2313
|
|
|
2300
2314
|
//#endregion
|
|
2301
2315
|
//#region src/common/plugin-name.ts
|
|
@@ -16034,7 +16048,11 @@ let FormulaRefRangeService = class FormulaRefRangeService extends Disposable {
|
|
|
16034
16048
|
const offsetRow = currentStartRow - originStartRow;
|
|
16035
16049
|
const offsetColumn = currentStartColumn - originStartColumn;
|
|
16036
16050
|
for (const range of effectedRanges.ranges) {
|
|
16037
|
-
const intersectedRange =
|
|
16051
|
+
const intersectedRange = [];
|
|
16052
|
+
for (const r of ranges) {
|
|
16053
|
+
const intersect = getIntersectRange(range, r);
|
|
16054
|
+
if (intersect) intersectedRange.push(intersect);
|
|
16055
|
+
}
|
|
16038
16056
|
if (intersectedRange.length > 0) intersectedRanges.push(...intersectedRange);
|
|
16039
16057
|
}
|
|
16040
16058
|
if (intersectedRanges.length > 0) matchedEffectedRanges.push(intersectedRanges.map((range) => ({
|
package/lib/facade.js
CHANGED
|
@@ -106,6 +106,7 @@ var FFormulaSheetsMixin = class extends FFormula {
|
|
|
106
106
|
if (command.id === SetFormulaCalculationResultMutation.id) {
|
|
107
107
|
setFormulaCalculationResult = true;
|
|
108
108
|
result = command.params;
|
|
109
|
+
applyFormulaCalculationResult = applyFormulaCalculationResult || !this._hasFormulaResultToApply(result);
|
|
109
110
|
}
|
|
110
111
|
if (command.id === SetRangeValuesMutation.id && (options === null || options === void 0 ? void 0 : options.applyFormulaCalculationResult)) applyFormulaCalculationResult = true;
|
|
111
112
|
if (!setFormulaCalculationResult || !applyFormulaCalculationResult) return;
|
|
@@ -114,6 +115,10 @@ var FFormulaSheetsMixin = class extends FFormula {
|
|
|
114
115
|
});
|
|
115
116
|
});
|
|
116
117
|
}
|
|
118
|
+
_hasFormulaResultToApply(result) {
|
|
119
|
+
const { unitData } = result;
|
|
120
|
+
return Object.values(unitData !== null && unitData !== void 0 ? unitData : {}).some((sheetData) => sheetData != null && Object.values(sheetData).some((cellData) => cellData != null));
|
|
121
|
+
}
|
|
117
122
|
onCalculationResultApplied() {
|
|
118
123
|
return new Promise((resolve, reject) => {
|
|
119
124
|
let started = false;
|
package/lib/index.js
CHANGED
|
@@ -512,9 +512,10 @@ let TriggerCalculationController = class TriggerCalculationController extends Di
|
|
|
512
512
|
this._totalCalculationTaskCount = 0;
|
|
513
513
|
this._emitProgress();
|
|
514
514
|
}
|
|
515
|
-
constructor(_commandService, _activeDirtyManagerService, _logService, _configService, _formulaDataModel, _localeService, _registerOtherFormulaService) {
|
|
515
|
+
constructor(_commandService, _univerInstanceService, _activeDirtyManagerService, _logService, _configService, _formulaDataModel, _localeService, _registerOtherFormulaService) {
|
|
516
516
|
super();
|
|
517
517
|
this._commandService = _commandService;
|
|
518
|
+
this._univerInstanceService = _univerInstanceService;
|
|
518
519
|
this._activeDirtyManagerService = _activeDirtyManagerService;
|
|
519
520
|
this._logService = _logService;
|
|
520
521
|
this._configService = _configService;
|
|
@@ -542,6 +543,9 @@ let TriggerCalculationController = class TriggerCalculationController extends Di
|
|
|
542
543
|
this._commandExecutedListener();
|
|
543
544
|
this._initialExecuteFormulaProcessListener();
|
|
544
545
|
this._initialExecuteFormula();
|
|
546
|
+
this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(UniverInstanceType.UNIVER_SHEET).subscribe(() => {
|
|
547
|
+
this._initialExecuteFormula();
|
|
548
|
+
}));
|
|
545
549
|
}
|
|
546
550
|
dispose() {
|
|
547
551
|
super.dispose();
|
|
@@ -785,12 +789,13 @@ let TriggerCalculationController = class TriggerCalculationController extends Di
|
|
|
785
789
|
};
|
|
786
790
|
TriggerCalculationController = __decorate([
|
|
787
791
|
__decorateParam(0, ICommandService),
|
|
788
|
-
__decorateParam(1,
|
|
789
|
-
__decorateParam(2,
|
|
790
|
-
__decorateParam(3,
|
|
791
|
-
__decorateParam(4,
|
|
792
|
-
__decorateParam(5, Inject(
|
|
793
|
-
__decorateParam(6, Inject(
|
|
792
|
+
__decorateParam(1, IUniverInstanceService),
|
|
793
|
+
__decorateParam(2, IActiveDirtyManagerService),
|
|
794
|
+
__decorateParam(3, ILogService),
|
|
795
|
+
__decorateParam(4, IConfigService),
|
|
796
|
+
__decorateParam(5, Inject(FormulaDataModel)),
|
|
797
|
+
__decorateParam(6, Inject(LocaleService)),
|
|
798
|
+
__decorateParam(7, Inject(RegisterOtherFormulaService))
|
|
794
799
|
], TriggerCalculationController);
|
|
795
800
|
|
|
796
801
|
//#endregion
|
|
@@ -2035,7 +2040,18 @@ let UpdateFormulaController = class UpdateFormulaController extends Disposable {
|
|
|
2035
2040
|
const { subUnitId: sheetId, unitId, cellValue } = params;
|
|
2036
2041
|
if (cellValue == null) return;
|
|
2037
2042
|
const newSheetFormulaData = this._formulaDataModel.updateFormulaData(unitId, sheetId, cellValue);
|
|
2038
|
-
|
|
2043
|
+
const arrayFormulaCellDataChanged = this._formulaDataModel.updateArrayFormulaCellData(unitId, sheetId, cellValue);
|
|
2044
|
+
const arrayFormulaRangeChanged = this._formulaDataModel.updateArrayFormulaRange(unitId, sheetId, cellValue);
|
|
2045
|
+
if (Object.keys(newSheetFormulaData).length === 0) {
|
|
2046
|
+
if (arrayFormulaCellDataChanged || arrayFormulaRangeChanged) this._commandService.executeCommand(SetArrayFormulaDataMutation.id, {
|
|
2047
|
+
arrayFormulaRange: this._formulaDataModel.getArrayFormulaRange(),
|
|
2048
|
+
arrayFormulaCellData: this._formulaDataModel.getArrayFormulaCellData()
|
|
2049
|
+
}, {
|
|
2050
|
+
onlyLocal: true,
|
|
2051
|
+
remove: true
|
|
2052
|
+
});
|
|
2053
|
+
return;
|
|
2054
|
+
}
|
|
2039
2055
|
const newFormulaData = { [unitId]: { [sheetId]: newSheetFormulaData } };
|
|
2040
2056
|
this._commandService.executeCommand(SetRangeValuesMutation.id, {
|
|
2041
2057
|
unitId,
|
|
@@ -2045,8 +2061,6 @@ let UpdateFormulaController = class UpdateFormulaController extends Disposable {
|
|
|
2045
2061
|
onlyLocal: true,
|
|
2046
2062
|
fromFormula: true
|
|
2047
2063
|
});
|
|
2048
|
-
this._formulaDataModel.updateArrayFormulaCellData(unitId, sheetId, cellValue);
|
|
2049
|
-
this._formulaDataModel.updateArrayFormulaRange(unitId, sheetId, cellValue);
|
|
2050
2064
|
this._formulaDataModel.updateImageFormulaData(unitId, sheetId, cellValue);
|
|
2051
2065
|
this._commandService.executeCommand(SetFormulaDataMutation.id, { formulaData: newFormulaData }, { onlyLocal: true });
|
|
2052
2066
|
this._commandService.executeCommand(SetArrayFormulaDataMutation.id, {
|
|
@@ -2295,7 +2309,7 @@ UpdateFormulaController = __decorate([
|
|
|
2295
2309
|
//#endregion
|
|
2296
2310
|
//#region package.json
|
|
2297
2311
|
var name = "@univerjs/sheets-formula";
|
|
2298
|
-
var version = "0.
|
|
2312
|
+
var version = "0.23.0-insiders.20260522-e8f2a3b";
|
|
2299
2313
|
|
|
2300
2314
|
//#endregion
|
|
2301
2315
|
//#region src/common/plugin-name.ts
|
|
@@ -16034,7 +16048,11 @@ let FormulaRefRangeService = class FormulaRefRangeService extends Disposable {
|
|
|
16034
16048
|
const offsetRow = currentStartRow - originStartRow;
|
|
16035
16049
|
const offsetColumn = currentStartColumn - originStartColumn;
|
|
16036
16050
|
for (const range of effectedRanges.ranges) {
|
|
16037
|
-
const intersectedRange =
|
|
16051
|
+
const intersectedRange = [];
|
|
16052
|
+
for (const r of ranges) {
|
|
16053
|
+
const intersect = getIntersectRange(range, r);
|
|
16054
|
+
if (intersect) intersectedRange.push(intersect);
|
|
16055
|
+
}
|
|
16038
16056
|
if (intersectedRange.length > 0) intersectedRanges.push(...intersectedRange);
|
|
16039
16057
|
}
|
|
16040
16058
|
if (intersectedRanges.length > 0) matchedEffectedRanges.push(intersectedRanges.map((range) => ({
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Disposable, ICommandService, IConfigService, ILogService, LocaleService } from '@univerjs/core';
|
|
16
|
+
import { Disposable, ICommandService, IConfigService, ILogService, IUniverInstanceService, LocaleService } from '@univerjs/core';
|
|
17
17
|
import { FormulaDataModel, IActiveDirtyManagerService, RegisterOtherFormulaService } from '@univerjs/engine-formula';
|
|
18
18
|
/**
|
|
19
19
|
* This interface is for the progress bar to display the calculation progress.
|
|
@@ -28,6 +28,7 @@ export interface ICalculationProgress {
|
|
|
28
28
|
}
|
|
29
29
|
export declare class TriggerCalculationController extends Disposable {
|
|
30
30
|
private readonly _commandService;
|
|
31
|
+
private readonly _univerInstanceService;
|
|
31
32
|
private readonly _activeDirtyManagerService;
|
|
32
33
|
private readonly _logService;
|
|
33
34
|
private readonly _configService;
|
|
@@ -49,7 +50,7 @@ export declare class TriggerCalculationController extends Disposable {
|
|
|
49
50
|
private _calculateProgress;
|
|
50
51
|
private _completeProgress;
|
|
51
52
|
clearProgress(): void;
|
|
52
|
-
constructor(_commandService: ICommandService, _activeDirtyManagerService: IActiveDirtyManagerService, _logService: ILogService, _configService: IConfigService, _formulaDataModel: FormulaDataModel, _localeService: LocaleService, _registerOtherFormulaService: RegisterOtherFormulaService);
|
|
53
|
+
constructor(_commandService: ICommandService, _univerInstanceService: IUniverInstanceService, _activeDirtyManagerService: IActiveDirtyManagerService, _logService: ILogService, _configService: IConfigService, _formulaDataModel: FormulaDataModel, _localeService: LocaleService, _registerOtherFormulaService: RegisterOtherFormulaService);
|
|
53
54
|
dispose(): void;
|
|
54
55
|
private _getCalculationMode;
|
|
55
56
|
private _commandExecutedListener;
|
|
@@ -339,6 +339,7 @@ export declare class FFormulaSheetsMixin extends FFormula implements IFFormulaSh
|
|
|
339
339
|
registerAsyncFunction(name: string, func: IRegisterAsyncFunction): IDisposable;
|
|
340
340
|
registerAsyncFunction(name: string, func: IRegisterAsyncFunction, description: string): IDisposable;
|
|
341
341
|
calculationResultApplied(callback: (result: ISetFormulaCalculationResultMutation) => void): IDisposable;
|
|
342
|
+
private _hasFormulaResultToApply;
|
|
342
343
|
onCalculationResultApplied(): Promise<void>;
|
|
343
344
|
}
|
|
344
345
|
declare module '@univerjs/engine-formula/facade' {
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(require(`@univerjs/core`),require(`@univerjs/core/facade`),require(`@univerjs/engine-formula`),require(`@univerjs/sheets-formula`),require(`@univerjs/engine-formula/facade`),require(`@univerjs/sheets`),require(`@univerjs/sheets/facade`)):typeof define==`function`&&define.amd?define([`@univerjs/core`,`@univerjs/core/facade`,`@univerjs/engine-formula`,`@univerjs/sheets-formula`,`@univerjs/engine-formula/facade`,`@univerjs/sheets`,`@univerjs/sheets/facade`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCore,e.UniverCoreFacade,e.UniverEngineFormula,e.UniverSheetsFormula,e.UniverEngineFormulaFacade,e.UniverSheets,e.UniverSheetsFacade))})(this,function(e,t,n,r,i,a,o){var s=class extends t.FUniver{_initialize(){this._debouncedFormulaCalculation=(0,e.debounce)(()=>{this._commandService.executeCommand(n.SetTriggerFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})},10)}registerFunction(e){let t=this._injector.get(r.IRegisterFunctionService);t||(this._injector.add([r.IRegisterFunctionService,{useClass:r.RegisterFunctionService}]),t=this._injector.get(r.IRegisterFunctionService));let n=t.registerFunctions(e);return this._debouncedFormulaCalculation(),n}};t.FUniver.extend(s);var c=class extends i.FFormula{_initialize(){this._debouncedFormulaCalculation=(0,e.debounce)(()=>{this._commandService.executeCommand(n.SetTriggerFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})},10)}setInitialFormulaComputing(t){let n=this._injector.get(e.LifecycleService).stage,i=this._injector.get(e.ILogService),a=this._injector.get(e.IConfigService);n>e.LifecycleStages.Starting&&i.warn(`[FFormula]`,`CalculationMode is called after the Starting lifecycle and will take effect the next time the Univer Sheet is constructed. If you want it to take effect when the Univer Sheet is initialized this time, consider calling it before the Ready lifecycle or using configuration.`);let o=a.getConfig(r.PLUGIN_CONFIG_KEY_BASE);if(!o){a.setConfig(r.PLUGIN_CONFIG_KEY_BASE,{initialFormulaComputing:t});return}o.initialFormulaComputing=t}registerFunction(e,t,n){var i;let a=this._injector.get(r.IRegisterFunctionService);a||(this._injector.add([r.IRegisterFunctionService,{useClass:r.RegisterFunctionService}]),a=this._injector.get(r.IRegisterFunctionService));let o={name:e,func:t,description:typeof n==`string`?n:(i=n==null?void 0:n.description)==null?``:i,locales:typeof n==`object`?n.locales:void 0},s=a.registerFunction(o);return this._debouncedFormulaCalculation(),s}registerAsyncFunction(e,t,n){var i;let a=this._injector.get(r.IRegisterFunctionService);a||(this._injector.add([r.IRegisterFunctionService,{useClass:r.RegisterFunctionService}]),a=this._injector.get(r.IRegisterFunctionService));let o={name:e,func:t,description:typeof n==`string`?n:(i=n==null?void 0:n.description)==null?``:i,locales:typeof n==`object`?n.locales:void 0},s=a.registerAsyncFunction(o);return this._debouncedFormulaCalculation(),s}calculationResultApplied(e){let t=!1,r=!1,i=null;return this._commandService.onCommandExecuted((o,s)=>{o.id!==n.SetFormulaCalculationResultMutation.id&&o.id!==a.SetRangeValuesMutation.id||(o.id===n.SetFormulaCalculationResultMutation.id&&(t=!0,i=o.params),o.id===a.SetRangeValuesMutation.id&&s!=null&&s.applyFormulaCalculationResult&&(r=!0),!(!t||!r)&&requestIdleCallback(()=>{e(i)}))})}onCalculationResultApplied(){return new Promise((e,t)=>{let r=!1,i=!1,a=setTimeout(()=>{l(),t(Error(`Calculation end timeout`))},6e4),o=setTimeout(()=>{r||(l(),e())},500),s=this.calculationProcessing(t=>{let{stage:i,totalArrayFormulasToCalculate:a,totalFormulasToCalculate:s}=t;if(i===n.FormulaExecuteStageType.START_CALCULATION&&a+s===0){l(),e();return}r||(r=!0,clearTimeout(o))}),c=this.calculationResultApplied(()=>{i||(i=!0,l(),e())});function l(){clearTimeout(a),clearTimeout(o),s.dispose(),c.dispose()}})}};i.FFormula.extend(c);var l=class extends t.FEnum{get CalculationMode(){return r.CalculationMode}};t.FEnum.extend(l);var u=class extends o.FWorkbook{getAllFormulaError(){let e=[],t=this._workbook,r=t.getUnitId(),i=t.getSheets(),a=this._injector.get(n.FormulaDataModel).getArrayFormulaCellData();return i.forEach(t=>{var i;let o=t.getName(),s=t.getSheetId(),c=t.getCellMatrix(),l=(a==null||(i=a[r])==null?void 0:i[s])||{};c.forValue((t,r,i)=>{var a;if(!i)return;let s=(0,n.extractFormulaError)(i,!!(!(l==null||(a=l[t])==null)&&a[r]));s&&e.push({sheetName:o,row:t,column:r,formula:i.f||``,errorType:s})})}),e}};o.FWorkbook.extend(u);var d=class extends o.FRange{getFormulaError(){var e;let t=[],r=this._workbook.getUnitId(),i=this._worksheet.getSheetId(),a=this._worksheet.getName(),o=this._workbook.getSheetBySheetId(i);if(!o)return t;let s=this._injector.get(n.FormulaDataModel).getArrayFormulaCellData(),c=(s==null||(e=s[r])==null?void 0:e[i])||{},l=o.getCellMatrix(),{startRow:u,endRow:d,startColumn:f,endColumn:p}=this._range;for(let e=u;e<=d;e++)for(let r=f;r<=p;r++){var m;let i=l.getValue(e,r);if(!i)continue;let o=(0,n.extractFormulaError)(i,!!(!(c==null||(m=c[e])==null)&&m[r]));o&&t.push({sheetName:a,row:e,column:r,formula:i.f||``,errorType:o})}return t}};o.FRange.extend(d)});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(require(`@univerjs/core`),require(`@univerjs/core/facade`),require(`@univerjs/engine-formula`),require(`@univerjs/sheets-formula`),require(`@univerjs/engine-formula/facade`),require(`@univerjs/sheets`),require(`@univerjs/sheets/facade`)):typeof define==`function`&&define.amd?define([`@univerjs/core`,`@univerjs/core/facade`,`@univerjs/engine-formula`,`@univerjs/sheets-formula`,`@univerjs/engine-formula/facade`,`@univerjs/sheets`,`@univerjs/sheets/facade`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCore,e.UniverCoreFacade,e.UniverEngineFormula,e.UniverSheetsFormula,e.UniverEngineFormulaFacade,e.UniverSheets,e.UniverSheetsFacade))})(this,function(e,t,n,r,i,a,o){var s=class extends t.FUniver{_initialize(){this._debouncedFormulaCalculation=(0,e.debounce)(()=>{this._commandService.executeCommand(n.SetTriggerFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})},10)}registerFunction(e){let t=this._injector.get(r.IRegisterFunctionService);t||(this._injector.add([r.IRegisterFunctionService,{useClass:r.RegisterFunctionService}]),t=this._injector.get(r.IRegisterFunctionService));let n=t.registerFunctions(e);return this._debouncedFormulaCalculation(),n}};t.FUniver.extend(s);var c=class extends i.FFormula{_initialize(){this._debouncedFormulaCalculation=(0,e.debounce)(()=>{this._commandService.executeCommand(n.SetTriggerFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})},10)}setInitialFormulaComputing(t){let n=this._injector.get(e.LifecycleService).stage,i=this._injector.get(e.ILogService),a=this._injector.get(e.IConfigService);n>e.LifecycleStages.Starting&&i.warn(`[FFormula]`,`CalculationMode is called after the Starting lifecycle and will take effect the next time the Univer Sheet is constructed. If you want it to take effect when the Univer Sheet is initialized this time, consider calling it before the Ready lifecycle or using configuration.`);let o=a.getConfig(r.PLUGIN_CONFIG_KEY_BASE);if(!o){a.setConfig(r.PLUGIN_CONFIG_KEY_BASE,{initialFormulaComputing:t});return}o.initialFormulaComputing=t}registerFunction(e,t,n){var i;let a=this._injector.get(r.IRegisterFunctionService);a||(this._injector.add([r.IRegisterFunctionService,{useClass:r.RegisterFunctionService}]),a=this._injector.get(r.IRegisterFunctionService));let o={name:e,func:t,description:typeof n==`string`?n:(i=n==null?void 0:n.description)==null?``:i,locales:typeof n==`object`?n.locales:void 0},s=a.registerFunction(o);return this._debouncedFormulaCalculation(),s}registerAsyncFunction(e,t,n){var i;let a=this._injector.get(r.IRegisterFunctionService);a||(this._injector.add([r.IRegisterFunctionService,{useClass:r.RegisterFunctionService}]),a=this._injector.get(r.IRegisterFunctionService));let o={name:e,func:t,description:typeof n==`string`?n:(i=n==null?void 0:n.description)==null?``:i,locales:typeof n==`object`?n.locales:void 0},s=a.registerAsyncFunction(o);return this._debouncedFormulaCalculation(),s}calculationResultApplied(e){let t=!1,r=!1,i=null;return this._commandService.onCommandExecuted((o,s)=>{o.id!==n.SetFormulaCalculationResultMutation.id&&o.id!==a.SetRangeValuesMutation.id||(o.id===n.SetFormulaCalculationResultMutation.id&&(t=!0,i=o.params,r=r||!this._hasFormulaResultToApply(i)),o.id===a.SetRangeValuesMutation.id&&s!=null&&s.applyFormulaCalculationResult&&(r=!0),!(!t||!r)&&requestIdleCallback(()=>{e(i)}))})}_hasFormulaResultToApply(e){let{unitData:t}=e;return Object.values(t==null?{}:t).some(e=>e!=null&&Object.values(e).some(e=>e!=null))}onCalculationResultApplied(){return new Promise((e,t)=>{let r=!1,i=!1,a=setTimeout(()=>{l(),t(Error(`Calculation end timeout`))},6e4),o=setTimeout(()=>{r||(l(),e())},500),s=this.calculationProcessing(t=>{let{stage:i,totalArrayFormulasToCalculate:a,totalFormulasToCalculate:s}=t;if(i===n.FormulaExecuteStageType.START_CALCULATION&&a+s===0){l(),e();return}r||(r=!0,clearTimeout(o))}),c=this.calculationResultApplied(()=>{i||(i=!0,l(),e())});function l(){clearTimeout(a),clearTimeout(o),s.dispose(),c.dispose()}})}};i.FFormula.extend(c);var l=class extends t.FEnum{get CalculationMode(){return r.CalculationMode}};t.FEnum.extend(l);var u=class extends o.FWorkbook{getAllFormulaError(){let e=[],t=this._workbook,r=t.getUnitId(),i=t.getSheets(),a=this._injector.get(n.FormulaDataModel).getArrayFormulaCellData();return i.forEach(t=>{var i;let o=t.getName(),s=t.getSheetId(),c=t.getCellMatrix(),l=(a==null||(i=a[r])==null?void 0:i[s])||{};c.forValue((t,r,i)=>{var a;if(!i)return;let s=(0,n.extractFormulaError)(i,!!(!(l==null||(a=l[t])==null)&&a[r]));s&&e.push({sheetName:o,row:t,column:r,formula:i.f||``,errorType:s})})}),e}};o.FWorkbook.extend(u);var d=class extends o.FRange{getFormulaError(){var e;let t=[],r=this._workbook.getUnitId(),i=this._worksheet.getSheetId(),a=this._worksheet.getName(),o=this._workbook.getSheetBySheetId(i);if(!o)return t;let s=this._injector.get(n.FormulaDataModel).getArrayFormulaCellData(),c=(s==null||(e=s[r])==null?void 0:e[i])||{},l=o.getCellMatrix(),{startRow:u,endRow:d,startColumn:f,endColumn:p}=this._range;for(let e=u;e<=d;e++)for(let r=f;r<=p;r++){var m;let i=l.getValue(e,r);if(!i)continue;let o=(0,n.extractFormulaError)(i,!!(!(c==null||(m=c[e])==null)&&m[r]));o&&t.push({sheetName:a,row:e,column:r,formula:i.f||``,errorType:o})}return t}};o.FRange.extend(d)});
|