@univerjs/sheets-formula 0.22.0 → 0.22.1-insiders.20260516-8900c44
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 +13 -8
- package/lib/es/facade.js +5 -0
- package/lib/es/index.js +13 -8
- package/lib/facade.js +5 -0
- package/lib/index.js +13 -8
- 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
|
|
@@ -2296,7 +2301,7 @@ UpdateFormulaController = __decorate([
|
|
|
2296
2301
|
//#endregion
|
|
2297
2302
|
//#region package.json
|
|
2298
2303
|
var name = "@univerjs/sheets-formula";
|
|
2299
|
-
var version = "0.22.
|
|
2304
|
+
var version = "0.22.1-insiders.20260516-8900c44";
|
|
2300
2305
|
|
|
2301
2306
|
//#endregion
|
|
2302
2307
|
//#region src/common/plugin-name.ts
|
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
|
|
@@ -2295,7 +2300,7 @@ UpdateFormulaController = __decorate([
|
|
|
2295
2300
|
//#endregion
|
|
2296
2301
|
//#region package.json
|
|
2297
2302
|
var name = "@univerjs/sheets-formula";
|
|
2298
|
-
var version = "0.22.
|
|
2303
|
+
var version = "0.22.1-insiders.20260516-8900c44";
|
|
2299
2304
|
|
|
2300
2305
|
//#endregion
|
|
2301
2306
|
//#region src/common/plugin-name.ts
|
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
|
|
@@ -2295,7 +2300,7 @@ UpdateFormulaController = __decorate([
|
|
|
2295
2300
|
//#endregion
|
|
2296
2301
|
//#region package.json
|
|
2297
2302
|
var name = "@univerjs/sheets-formula";
|
|
2298
|
-
var version = "0.22.
|
|
2303
|
+
var version = "0.22.1-insiders.20260516-8900c44";
|
|
2299
2304
|
|
|
2300
2305
|
//#endregion
|
|
2301
2306
|
//#region src/common/plugin-name.ts
|
|
@@ -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)});
|