@univerjs/sheets-formula 0.13.0-insiders.20251220-0a5ea4d → 0.13.0-insiders.20251223-857805c

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.
@@ -0,0 +1,9 @@
1
+ import { IMutation } from '@univerjs/core';
2
+ export interface IOtherFormulaMarkDirtyParams {
3
+ [unitId: string]: {
4
+ [sunUnitId: string]: {
5
+ [formulaId: string]: boolean;
6
+ };
7
+ };
8
+ }
9
+ export declare const OtherFormulaMarkDirty: IMutation<IOtherFormulaMarkDirtyParams>;
@@ -1,5 +1,6 @@
1
1
  import { Disposable, ICommandService, IConfigService, ILogService, LocaleService } from '@univerjs/core';
2
- import { FormulaDataModel, IActiveDirtyManagerService, RegisterOtherFormulaService } from '@univerjs/engine-formula';
2
+ import { FormulaDataModel, IActiveDirtyManagerService } from '@univerjs/engine-formula';
3
+ import { RegisterOtherFormulaService } from '../services/register-other-formula.service';
3
4
  /**
4
5
  * This interface is for the progress bar to display the calculation progress.
5
6
  */
@@ -27,6 +28,10 @@ export declare class TriggerCalculationController extends Disposable {
27
28
  private _doneCalculationTaskCount;
28
29
  private _executionInProgressParams;
29
30
  private _restartCalculation;
31
+ /**
32
+ * The mark of forced calculation. If a new mutation triggers dirty area calculation during the forced calculation process, forced calculation is still required.
33
+ */
34
+ private _forceCalculating;
30
35
  private readonly _progress$;
31
36
  readonly progress$: import('rxjs').Observable<ICalculationProgress>;
32
37
  private _emitProgress;
@@ -15,6 +15,7 @@
15
15
  */
16
16
  export { type IInsertFunction, type IInsertFunctionCommandParams, InsertFunctionCommand } from './commands/commands/insert-function.command';
17
17
  export { QuickSumCommand } from './commands/commands/quick-sum.command';
18
+ export { OtherFormulaMarkDirty } from './commands/mutations/formula.mutation';
18
19
  export { CalculationMode, PLUGIN_CONFIG_KEY_BASE } from './controllers/config.schema';
19
20
  export type { IUniverSheetsFormulaBaseConfig, IUniverSheetsFormulaRemoteConfig } from './controllers/config.schema';
20
21
  export { ImageFormulaCellInterceptorController } from './controllers/image-formula-cell-interceptor.controller';
@@ -24,10 +25,12 @@ export { UpdateFormulaController } from './controllers/update-formula.controller
24
25
  export { UniverRemoteSheetsFormulaPlugin, UniverSheetsFormulaPlugin } from './plugin';
25
26
  export { DescriptionService, IDescriptionService } from './services/description.service';
26
27
  export type { ISearchItem, ISearchItemWithType } from './services/description.service';
28
+ export type { IFormulaInfo, IOtherFormulaResult } from './services/formula-common';
27
29
  export { FormulaRefRangeService } from './services/formula-ref-range.service';
28
30
  export type { IRegisterAsyncFunction, IRegisterFunction, ISingleFunctionRegisterParams } from './services/register-function.service';
29
31
  export type { IRegisterFunctionParams, IUnregisterFunctionParams } from './services/register-function.service';
30
32
  export { RegisterFunctionService } from './services/register-function.service';
31
33
  export { IRegisterFunctionService } from './services/register-function.service';
34
+ export { RegisterOtherFormulaService } from './services/register-other-formula.service';
32
35
  export { IRemoteRegisterFunctionService, RemoteRegisterFunctionService } from './services/remote/remote-register-function.service';
33
36
  export { calculateFormula } from './util/calculate';
@@ -0,0 +1,18 @@
1
+ import { ICellData, IObjectMatrixPrimitiveType, Nullable } from '@univerjs/core';
2
+ export declare enum FormulaResultStatus {
3
+ NOT_REGISTER = 1,
4
+ SUCCESS = 2,
5
+ WAIT = 3,
6
+ ERROR = 4
7
+ }
8
+ export interface IOtherFormulaResult {
9
+ result?: IObjectMatrixPrimitiveType<Nullable<ICellData>[][]>;
10
+ status: FormulaResultStatus;
11
+ formulaId: string;
12
+ callbacks: Set<(value: IObjectMatrixPrimitiveType<Nullable<ICellData>[][]>) => void>;
13
+ extra?: Record<string, any>;
14
+ }
15
+ export interface IFormulaInfo {
16
+ id: string;
17
+ text: string;
18
+ }
@@ -0,0 +1,32 @@
1
+ import { IRange, Nullable, Disposable, ICommandService, LifecycleService } from '@univerjs/core';
2
+ import { IOtherFormulaResult } from './formula-common';
3
+ import { IActiveDirtyManagerService } from '@univerjs/engine-formula';
4
+ import { BehaviorSubject } from 'rxjs';
5
+ export declare class RegisterOtherFormulaService extends Disposable {
6
+ private readonly _commandService;
7
+ private _activeDirtyManagerService;
8
+ private readonly _lifecycleService;
9
+ private _formulaCacheMap;
10
+ private _formulaChangeWithRange$;
11
+ formulaChangeWithRange$: import('rxjs').Observable<{
12
+ unitId: string;
13
+ subUnitId: string;
14
+ formulaText: string;
15
+ formulaId: string;
16
+ ranges: IRange[];
17
+ }>;
18
+ private _formulaResult$;
19
+ formulaResult$: import('rxjs').Observable<Record<string, Record<string, IOtherFormulaResult[]>>>;
20
+ calculateStarted$: BehaviorSubject<boolean>;
21
+ constructor(_commandService: ICommandService, _activeDirtyManagerService: IActiveDirtyManagerService, _lifecycleService: LifecycleService);
22
+ dispose(): void;
23
+ private _ensureCacheMap;
24
+ private _createFormulaId;
25
+ private _initFormulaRegister;
26
+ private _initFormulaCalculationResultChange;
27
+ registerFormulaWithRange(unitId: string, subUnitId: string, formulaText: string, ranges?: IRange[], extra?: Record<string, any>): string;
28
+ deleteFormula(unitId: string, subUnitId: string, formulaIdList: string[]): void;
29
+ getFormulaValue(unitId: string, subUnitId: string, formulaId: string): Promise<Nullable<IOtherFormulaResult>>;
30
+ getFormulaValueSync(unitId: string, subUnitId: string, formulaId: string): Nullable<IOtherFormulaResult>;
31
+ markFormulaDirty(unitId: string, subUnitId: string, formulaId: string): void;
32
+ }
package/lib/umd/facade.js CHANGED
@@ -1 +1 @@
1
- (function(t,l){typeof exports=="object"&&typeof module<"u"?l(require("@univerjs/core"),require("@univerjs/core/facade"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula"),require("@univerjs/engine-formula/facade"),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/facade"],l):(t=typeof globalThis<"u"?globalThis:t||self,l(t.UniverCore,t.UniverCoreFacade,t.UniverEngineFormula,t.UniverSheetsFormula,t.UniverEngineFormulaFacade,t.UniverSheetsFacade))})(this,(function(t,l,d,i,x,m){"use strict";class k extends l.FUniver{_initialize(){this._debouncedFormulaCalculation=t.debounce(()=>{this._commandService.executeCommand(d.SetTriggerFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})},10)}registerFunction(n){let c=this._injector.get(i.IRegisterFunctionService);c||(this._injector.add([i.IRegisterFunctionService,{useClass:i.RegisterFunctionService}]),c=this._injector.get(i.IRegisterFunctionService));const e=c.registerFunctions(n);return this._debouncedFormulaCalculation(),e}}l.FUniver.extend(k);class R extends x.FFormula{_initialize(){this._debouncedFormulaCalculation=t.debounce(()=>{this._commandService.executeCommand(d.SetTriggerFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})},10)}setInitialFormulaComputing(n){const e=this._injector.get(t.LifecycleService).stage,o=this._injector.get(t.ILogService),s=this._injector.get(t.IConfigService);e>t.LifecycleStages.Starting&&o.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.");const r=s.getConfig(i.PLUGIN_CONFIG_KEY_BASE);if(!r){s.setConfig(i.PLUGIN_CONFIG_KEY_BASE,{initialFormulaComputing:n});return}r.initialFormulaComputing=n}registerFunction(n,c,e){var a;let o=this._injector.get(i.IRegisterFunctionService);o||(this._injector.add([i.IRegisterFunctionService,{useClass:i.RegisterFunctionService}]),o=this._injector.get(i.IRegisterFunctionService));const s={name:n,func:c,description:typeof e=="string"?e:(a=e==null?void 0:e.description)!=null?a:"",locales:typeof e=="object"?e.locales:void 0},r=o.registerFunction(s);return this._debouncedFormulaCalculation(),r}registerAsyncFunction(n,c,e){var a;let o=this._injector.get(i.IRegisterFunctionService);o||(this._injector.add([i.IRegisterFunctionService,{useClass:i.RegisterFunctionService}]),o=this._injector.get(i.IRegisterFunctionService));const s={name:n,func:c,description:typeof e=="string"?e:(a=e==null?void 0:e.description)!=null?a:"",locales:typeof e=="object"?e.locales:void 0},r=o.registerAsyncFunction(s);return this._debouncedFormulaCalculation(),r}}x.FFormula.extend(R);class b{get CalculationMode(){return i.CalculationMode}}l.FEnum.extend(b);class E extends m.FWorkbook{getAllFormulaError(){const n=[],c=this._workbook,e=c.getUnitId(),o=c.getSheets(),s=this._injector.get(d.FormulaDataModel).getArrayFormulaCellData();return o.forEach(r=>{var C;const a=r.getName(),j=r.getSheetId(),I=r.getCellMatrix(),F=((C=s==null?void 0:s[e])==null?void 0:C[j])||{};I.forValue((_,h,f)=>{var v;if(!f)return;const g=(v=F==null?void 0:F[_])==null?void 0:v[h],u=d.extractFormulaError(f,!!g);u&&n.push({sheetName:a,row:_,column:h,formula:f.f||"",errorType:u})})}),n}}m.FWorkbook.extend(E);class U extends m.FRange{getFormulaError(){var h,f;const n=[],c=this._workbook.getUnitId(),e=this._worksheet.getSheetId(),o=this._worksheet.getName(),s=this._workbook.getSheetBySheetId(e);if(!s)return n;const r=this._injector.get(d.FormulaDataModel).getArrayFormulaCellData(),a=((h=r==null?void 0:r[c])==null?void 0:h[e])||{},j=s.getCellMatrix(),{startRow:I,endRow:F,startColumn:C,endColumn:_}=this._range;for(let g=I;g<=F;g++)for(let u=C;u<=_;u++){const v=j.getValue(g,u);if(!v)continue;const M=(f=a==null?void 0:a[g])==null?void 0:f[u],y=d.extractFormulaError(v,!!M);y&&n.push({sheetName:o,row:g,column:u,formula:v.f||"",errorType:y})}return n}}m.FRange.extend(U)}));
1
+ (function(t,l){typeof exports=="object"&&typeof module<"u"?l(require("@univerjs/core"),require("@univerjs/core/facade"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula"),require("@univerjs/engine-formula/facade"),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/facade"],l):(t=typeof globalThis<"u"?globalThis:t||self,l(t.UniverCore,t.UniverCoreFacade,t.UniverEngineFormula,t.UniverSheetsFormula,t.UniverEngineFormulaFacade,t.UniverSheetsFacade))})(this,(function(t,l,g,i,x,m){"use strict";class k extends l.FUniver{_initialize(){this._debouncedFormulaCalculation=t.debounce(()=>{this._commandService.executeCommand(g.SetFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})},10)}registerFunction(n){let c=this._injector.get(i.IRegisterFunctionService);c||(this._injector.add([i.IRegisterFunctionService,{useClass:i.RegisterFunctionService}]),c=this._injector.get(i.IRegisterFunctionService));const e=c.registerFunctions(n);return this._debouncedFormulaCalculation(),e}}l.FUniver.extend(k);class R extends x.FFormula{_initialize(){this._debouncedFormulaCalculation=t.debounce(()=>{this._commandService.executeCommand(g.SetFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})},10)}setInitialFormulaComputing(n){const e=this._injector.get(t.LifecycleService).stage,o=this._injector.get(t.ILogService),s=this._injector.get(t.IConfigService);e>t.LifecycleStages.Starting&&o.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.");const r=s.getConfig(i.PLUGIN_CONFIG_KEY_BASE);if(!r){s.setConfig(i.PLUGIN_CONFIG_KEY_BASE,{initialFormulaComputing:n});return}r.initialFormulaComputing=n}registerFunction(n,c,e){var a;let o=this._injector.get(i.IRegisterFunctionService);o||(this._injector.add([i.IRegisterFunctionService,{useClass:i.RegisterFunctionService}]),o=this._injector.get(i.IRegisterFunctionService));const s={name:n,func:c,description:typeof e=="string"?e:(a=e==null?void 0:e.description)!=null?a:"",locales:typeof e=="object"?e.locales:void 0},r=o.registerFunction(s);return this._debouncedFormulaCalculation(),r}registerAsyncFunction(n,c,e){var a;let o=this._injector.get(i.IRegisterFunctionService);o||(this._injector.add([i.IRegisterFunctionService,{useClass:i.RegisterFunctionService}]),o=this._injector.get(i.IRegisterFunctionService));const s={name:n,func:c,description:typeof e=="string"?e:(a=e==null?void 0:e.description)!=null?a:"",locales:typeof e=="object"?e.locales:void 0},r=o.registerAsyncFunction(s);return this._debouncedFormulaCalculation(),r}}x.FFormula.extend(R);class b{get CalculationMode(){return i.CalculationMode}}l.FEnum.extend(b);class E extends m.FWorkbook{getAllFormulaError(){const n=[],c=this._workbook,e=c.getUnitId(),o=c.getSheets(),s=this._injector.get(g.FormulaDataModel).getArrayFormulaCellData();return o.forEach(r=>{var C;const a=r.getName(),j=r.getSheetId(),I=r.getCellMatrix(),F=((C=s==null?void 0:s[e])==null?void 0:C[j])||{};I.forValue((_,h,f)=>{var v;if(!f)return;const d=(v=F==null?void 0:F[_])==null?void 0:v[h],u=g.extractFormulaError(f,!!d);u&&n.push({sheetName:a,row:_,column:h,formula:f.f||"",errorType:u})})}),n}}m.FWorkbook.extend(E);class U extends m.FRange{getFormulaError(){var h,f;const n=[],c=this._workbook.getUnitId(),e=this._worksheet.getSheetId(),o=this._worksheet.getName(),s=this._workbook.getSheetBySheetId(e);if(!s)return n;const r=this._injector.get(g.FormulaDataModel).getArrayFormulaCellData(),a=((h=r==null?void 0:r[c])==null?void 0:h[e])||{},j=s.getCellMatrix(),{startRow:I,endRow:F,startColumn:C,endColumn:_}=this._range;for(let d=I;d<=F;d++)for(let u=C;u<=_;u++){const v=j.getValue(d,u);if(!v)continue;const M=(f=a==null?void 0:a[d])==null?void 0:f[u],y=g.extractFormulaError(v,!!M);y&&n.push({sheetName:o,row:d,column:u,formula:v.f||"",errorType:y})}return n}}m.FRange.extend(U)}));