@univerjs/engine-formula 0.13.0 → 0.14.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 +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +218 -36
- package/lib/es/index.js +3382 -3151
- package/lib/facade.js +218 -36
- package/lib/index.js +3382 -3151
- package/lib/types/basics/common.d.ts +8 -0
- package/lib/types/basics/match-token.d.ts +1 -1
- package/lib/types/commands/mutations/formula.mutation.d.ts +9 -0
- package/lib/types/commands/mutations/set-formula-calculation.mutation.d.ts +10 -1
- package/lib/types/controller/calculate.controller.d.ts +1 -0
- package/lib/types/controller/config.schema.d.ts +1 -0
- package/lib/types/engine/analysis/lexer-tree-builder.d.ts +2 -1
- package/lib/types/engine/ast-node/reference-node.d.ts +0 -1
- package/lib/types/engine/dependency/dependency-tree.d.ts +11 -1
- package/lib/types/engine/dependency/formula-dependency.d.ts +8 -3
- package/lib/types/engine/utils/reference.d.ts +9 -0
- package/lib/types/engine/utils/sequence.d.ts +2 -1
- package/lib/types/facade/f-formula.d.ts +164 -2
- package/lib/types/index.d.ts +9 -5
- package/lib/types/services/active-dirty-manager.service.d.ts +1 -0
- package/lib/types/services/calculate-formula.service.d.ts +4 -1
- package/lib/types/services/current-data.service.d.ts +1 -0
- package/lib/types/services/defined-names.service.d.ts +1 -0
- package/lib/types/services/formula-common.d.ts +18 -0
- package/lib/types/services/register-other-formula.service.d.ts +40 -0
- package/lib/types/services/runtime.service.d.ts +7 -0
- package/lib/types/services/super-table.service.d.ts +4 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +4 -4
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Nullable, Disposable } from '@univerjs/core';
|
|
2
2
|
import { IArrayFormulaEmbeddedMap, IArrayFormulaRangeType, IFeatureDirtyRangeType, IRuntimeImageFormulaDataType, IRuntimeOtherUnitDataType, IRuntimeUnitDataType } from '../basics/common';
|
|
3
3
|
import { BaseAstNode } from '../engine/ast-node/base-ast-node';
|
|
4
|
+
import { IFormulaDependencyTreeJson } from '../engine/dependency/dependency-tree';
|
|
4
5
|
import { FunctionVariantType } from '../engine/reference-object/base-reference-object';
|
|
5
6
|
import { IFormulaCurrentConfigService } from './current-data.service';
|
|
6
7
|
import { IHyperlinkEngineFormulaService } from './hyperlink-engine-formula.service';
|
|
@@ -40,6 +41,7 @@ export interface IAllRuntimeData {
|
|
|
40
41
|
runtimeFeatureCellData: {
|
|
41
42
|
[featureId: string]: IRuntimeUnitDataType;
|
|
42
43
|
};
|
|
44
|
+
dependencyTreeModelData: IFormulaDependencyTreeJson[];
|
|
43
45
|
}
|
|
44
46
|
export interface IExecutionInProgressParams {
|
|
45
47
|
totalFormulasToCalculate: number;
|
|
@@ -100,6 +102,8 @@ export interface IFormulaRuntimeService {
|
|
|
100
102
|
setUnitArrayFormulaEmbeddedMap(): void;
|
|
101
103
|
clearArrayObjectCache(): void;
|
|
102
104
|
getRuntimeImageFormulaData(): IRuntimeImageFormulaDataType[];
|
|
105
|
+
setDependencyTreeModelData(data: IFormulaDependencyTreeJson[]): void;
|
|
106
|
+
getDependencyTreeModelData(): IFormulaDependencyTreeJson[];
|
|
103
107
|
}
|
|
104
108
|
export declare class FormulaRuntimeService extends Disposable implements IFormulaRuntimeService {
|
|
105
109
|
private readonly _currentConfigService;
|
|
@@ -129,6 +133,7 @@ export declare class FormulaRuntimeService extends Disposable implements IFormul
|
|
|
129
133
|
private _completedArrayFormulasCount;
|
|
130
134
|
private _formulaCycleIndex;
|
|
131
135
|
private _isCycleDependency;
|
|
136
|
+
private _dependencyTreeModelData;
|
|
132
137
|
constructor(_currentConfigService: IFormulaCurrentConfigService, _hyperlinkEngineFormulaService: IHyperlinkEngineFormulaService);
|
|
133
138
|
get currentRow(): number;
|
|
134
139
|
get currentColumn(): number;
|
|
@@ -182,6 +187,8 @@ export declare class FormulaRuntimeService extends Disposable implements IFormul
|
|
|
182
187
|
[featureId: string]: IRuntimeUnitDataType;
|
|
183
188
|
};
|
|
184
189
|
setRuntimeFeatureCellData(featureId: string, featureData: IRuntimeUnitDataType): void;
|
|
190
|
+
setDependencyTreeModelData(data: IFormulaDependencyTreeJson[]): void;
|
|
191
|
+
getDependencyTreeModelData(): IFormulaDependencyTreeJson[];
|
|
185
192
|
getRuntimeImageFormulaData(): IRuntimeImageFormulaDataType[];
|
|
186
193
|
getAllRuntimeData(): IAllRuntimeData;
|
|
187
194
|
getRuntimeState(): IExecutionInProgressParams;
|
|
@@ -12,6 +12,8 @@ export interface ISuperTableService {
|
|
|
12
12
|
registerTableOptionMap(tableOption: string, tableOptionType: TableOptionType): void;
|
|
13
13
|
remove(unitId: string, tableName: string): void;
|
|
14
14
|
update$: Observable<unknown>;
|
|
15
|
+
getTable(unitId: string, tableName: string): Nullable<ISuperTable>;
|
|
16
|
+
hasTable(unitId: string, tableName: string): boolean;
|
|
15
17
|
}
|
|
16
18
|
export declare class SuperTableService extends Disposable implements ISuperTableService {
|
|
17
19
|
private _tableMap;
|
|
@@ -25,6 +27,8 @@ export declare class SuperTableService extends Disposable implements ISuperTable
|
|
|
25
27
|
getTableOptionMap(): Map<string, TableOptionType>;
|
|
26
28
|
registerTable(unitId: string, tableName: string, reference: ISuperTable): void;
|
|
27
29
|
registerTableOptionMap(tableOption: string, tableOptionType: TableOptionType): void;
|
|
30
|
+
getTable(unitId: string, tableName: string): Nullable<ISuperTable>;
|
|
31
|
+
hasTable(unitId: string, tableName: string): boolean;
|
|
28
32
|
private _update;
|
|
29
33
|
}
|
|
30
34
|
export declare const ISuperTableService: import('@wendellhu/redi').IdentifierDecorator<ISuperTableService>;
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(c,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("@univerjs/core/facade"),require("@univerjs/core"),require("@univerjs/engine-formula"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core/facade","@univerjs/core","@univerjs/engine-formula","rxjs"],l):(c=typeof globalThis<"u"?globalThis:c||self,l(c.UniverEngineFormulaFacade={},c.UniverCoreFacade,c.UniverCore,c.UniverEngineFormula,c.rxjs))})(this,(function(c,l,m,n,f){"use strict";var v=Object.getOwnPropertyDescriptor,C=(p,e,i,t)=>{for(var r=t>1?void 0:t?v(e,i):e,o=p.length-1,s;o>=0;o--)(s=p[o])&&(r=s(r)||r);return r},d=(p,e)=>(i,t)=>e(i,t,p);c.FFormula=class extends l.FBase{constructor(e,i,t,r,o,s,a){super(),this._commandService=e,this._injector=i,this._lexerTreeBuilder=t,this._configService=r,this._functionService=o,this._definedNamesService=s,this._superTableService=a,this._initialize()}_initialize(){}get lexerTreeBuilder(){return this._lexerTreeBuilder}moveFormulaRefOffset(e,i,t,r){return this._lexerTreeBuilder.moveFormulaRefOffset(e,i,t,r)}sequenceNodesBuilder(e){return this._lexerTreeBuilder.sequenceNodesBuilder(e)||[]}executeCalculation(){this._commandService.executeCommand(n.SetTriggerFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})}stopCalculation(){this._commandService.executeCommand(n.SetFormulaCalculationStopMutation.id,{})}calculationStart(e){return this._commandService.onCommandExecuted(i=>{if(i.id===n.SetFormulaCalculationStartMutation.id){const t=i.params;e(t.forceCalculation)}})}calculationEnd(e){return this._commandService.onCommandExecuted(i=>{if(i.id!==n.SetFormulaCalculationNotificationMutation.id)return;const t=i.params;t.functionsExecutedState!==void 0&&e(t.functionsExecutedState)})}whenComputingCompleteAsync(e){const i=this._injector.get(n.GlobalComputingStatusService);return i.computingStatus?Promise.resolve(!0):f.firstValueFrom(f.race(i.computingStatus$.pipe(f.filter(t=>t)),f.timer(e!=null?e:3e4).pipe(f.map(()=>!1))))}onCalculationEnd(){return new Promise((e,i)=>{const t=setTimeout(()=>{i(new Error("Calculation end timeout"))},3e4),r=this.calculationEnd(()=>{clearTimeout(t),r.dispose(),e()})})}calculationProcessing(e){return this._commandService.onCommandExecuted(i=>{if(i.id!==n.SetFormulaCalculationNotificationMutation.id)return;const t=i.params;t.stageInfo!==void 0&&e(t.stageInfo)})}setMaxIteration(e){this._configService.setConfig(n.ENGINE_FORMULA_CYCLE_REFERENCE_COUNT,e)}calculationResultApplied(e){return this._commandService.onCommandExecuted(i=>{if(i.id!==n.SetFormulaCalculationResultMutation.id)return;const t=i.params;t!==void 0&&requestIdleCallback(()=>{e(t)})})}onCalculationResultApplied(){return new Promise((e,i)=>{let t=!1,r=!1;const o=setTimeout(()=>{S(),i(new Error("Calculation end timeout"))},3e4),s=setTimeout(()=>{t||(S(),e())},500),a=this.calculationProcessing(()=>{t||(t=!0,clearTimeout(s))}),u=this.calculationResultApplied(()=>{r||(r=!0,S(),e())});function S(){clearTimeout(o),clearTimeout(s),a.dispose(),u.dispose()}})}executeFormulas(e,i=3e4){return new Promise((t,r)=>{const o=this._commandService.onCommandExecuted(a=>{if(a.id!==n.SetFormulaStringBatchCalculationResultMutation.id)return;const u=a.params;clearTimeout(s),o.dispose(),u.result!=null?t(u.result):r(new Error("Formula batch calculation returned no result"))}),s=setTimeout(()=>{o.dispose(),r(new Error("Formula batch calculation timeout"))},i);this._commandService.executeCommand(n.SetFormulaStringBatchCalculationMutation.id,{formulas:e},{onlyLocal:!0})})}getAllDependencyTrees(e=3e4){return new Promise((i,t)=>{const r=this._commandService.onCommandExecuted(s=>{if(s.id!==n.SetFormulaDependencyCalculationResultMutation.id)return;const a=s.params;clearTimeout(o),r.dispose(),a.result!=null?i(a.result):i([])}),o=setTimeout(()=>{r.dispose(),t(new Error("Formula dependency calculation timeout"))},e);this._commandService.executeCommand(n.SetFormulaDependencyCalculationMutation.id,void 0,{onlyLocal:!0})})}getCellDependencyTree(e,i=3e4){return new Promise((t,r)=>{const o=this._commandService.onCommandExecuted(a=>{if(a.id!==n.SetCellFormulaDependencyCalculationResultMutation.id)return;const u=a.params;clearTimeout(s),o.dispose(),t(u.result)}),s=setTimeout(()=>{o.dispose(),r(new Error("Cell dependency calculation timeout"))},i);this._commandService.executeCommand(n.SetCellFormulaDependencyCalculationMutation.id,e,{onlyLocal:!0})})}getRangeDependents(e,i=3e4){return new Promise((t,r)=>{const o=this._commandService.onCommandExecuted(a=>{if(a.id!==n.SetQueryFormulaDependencyResultMutation.id)return;const u=a.params;clearTimeout(s),o.dispose(),u.result!=null?t(u.result):t([])}),s=setTimeout(()=>{o.dispose(),r(new Error("Range dependents calculation timeout"))},i);this._commandService.executeCommand(n.SetQueryFormulaDependencyMutation.id,{unitRanges:e},{onlyLocal:!0})})}getInRangeFormulas(e,i=3e4){return new Promise((t,r)=>{const o=this._commandService.onCommandExecuted(a=>{if(a.id!==n.SetQueryFormulaDependencyResultMutation.id)return;const u=a.params;clearTimeout(s),o.dispose(),u.result!=null?t(u.result):t([])}),s=setTimeout(()=>{o.dispose(),r(new Error("In-range formulas calculation timeout"))},i);this._commandService.executeCommand(n.SetQueryFormulaDependencyMutation.id,{unitRanges:e,isInRange:!0},{onlyLocal:!0})})}setFormulaReturnDependencyTree(e){this._configService.setConfig(n.ENGINE_FORMULA_RETURN_DEPENDENCY_TREE,e)}getFormulaExpressTree(e,i){return this._lexerTreeBuilder.getFormulaExprTree(e,i,this._functionService.hasExecutor.bind(this._functionService),this._definedNamesService.getValueByName.bind(this._definedNamesService),this._superTableService.getTable.bind(this._superTableService))}getRangeDependentsAndInRangeFormulas(e,i=3e4){return new Promise((t,r)=>{const o=this._commandService.onCommandExecuted(a=>{if(a.id!==n.SetQueryFormulaDependencyAllResultMutation.id)return;const u=a.params;clearTimeout(s),o.dispose(),u.result!=null?t(u.result):t({dependents:[],inRanges:[]})}),s=setTimeout(()=>{o.dispose(),r(new Error("Range dependents calculation timeout"))},i);this._commandService.executeCommand(n.SetQueryFormulaDependencyAllMutation.id,{unitRanges:e},{onlyLocal:!0})})}},c.FFormula=C([d(0,m.Inject(m.ICommandService)),d(1,m.Inject(m.Injector)),d(2,m.Inject(n.LexerTreeBuilder)),d(3,m.IConfigService),d(4,n.IFunctionService),d(5,n.IDefinedNamesService),d(6,n.ISuperTableService)],c.FFormula);class h extends l.FUniver{getFormula(){return this._injector.createInstance(c.FFormula)}}l.FUniver.extend(h),Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
|