@univerjs/engine-formula 0.12.4 → 0.13.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 +396 -43
- package/lib/es/index.js +6636 -6254
- package/lib/facade.js +396 -43
- package/lib/index.js +6636 -6254
- package/lib/types/basics/common.d.ts +14 -0
- package/lib/types/basics/date.d.ts +0 -1
- package/lib/types/commands/mutations/set-formula-calculation.mutation.d.ts +39 -2
- package/lib/types/controller/calculate.controller.d.ts +4 -0
- package/lib/types/engine/dependency/dependency-tree.d.ts +39 -0
- package/lib/types/engine/dependency/formula-dependency.d.ts +22 -2
- package/lib/types/facade/f-formula.d.ts +255 -2
- package/lib/types/index.d.ts +3 -3
- package/lib/types/services/calculate-formula.service.d.ts +15 -4
- package/lib/types/services/current-data.service.d.ts +2 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +6 -6
|
@@ -126,6 +126,20 @@ export interface IFormulaIdMap {
|
|
|
126
126
|
r: number;
|
|
127
127
|
c: number;
|
|
128
128
|
}
|
|
129
|
+
export interface IFormulaStringMap {
|
|
130
|
+
[unitId: string]: Nullable<{
|
|
131
|
+
[sheetId: string]: IObjectMatrixPrimitiveType<string[]>;
|
|
132
|
+
}>;
|
|
133
|
+
}
|
|
134
|
+
export interface IFormulaExecuteResultItem {
|
|
135
|
+
value: Nullable<number | string | boolean | Array<Array<number | string | boolean | null>>>;
|
|
136
|
+
formula: string;
|
|
137
|
+
}
|
|
138
|
+
export interface IFormulaExecuteResultMap {
|
|
139
|
+
[unitId: string]: Nullable<{
|
|
140
|
+
[sheetId: string]: IObjectMatrixPrimitiveType<IFormulaExecuteResultItem[]>;
|
|
141
|
+
}>;
|
|
142
|
+
}
|
|
129
143
|
export interface IFormulaIdMapData {
|
|
130
144
|
[unitId: string]: Nullable<{
|
|
131
145
|
[subUnitId: string]: Nullable<{
|
|
@@ -33,7 +33,6 @@ export declare function formatDateDefault(date: Date): string;
|
|
|
33
33
|
*/
|
|
34
34
|
export declare function isValidDateStr(dateStr: string): boolean;
|
|
35
35
|
export declare function parseFormattedDate(value: string): numfmt.ParseData | null;
|
|
36
|
-
export declare function parseFormattedValue(value: string): numfmt.ParseData | null;
|
|
37
36
|
export declare function parseFormattedTime(value: string): numfmt.ParseData | null;
|
|
38
37
|
export declare function isDate(format: string): boolean;
|
|
39
38
|
export declare function isValidWeekend(weekend: number | string): boolean;
|
|
@@ -1,15 +1,46 @@
|
|
|
1
|
-
import { IExecutionOptions, IMutation, Nullable } from '@univerjs/core';
|
|
2
|
-
import { IRuntimeOtherUnitDataType, IRuntimeUnitDataPrimitiveType } from '../../basics/common';
|
|
1
|
+
import { IExecutionOptions, IMutation, IUnitRange, Nullable } from '@univerjs/core';
|
|
2
|
+
import { IFormulaExecuteResultMap, IFormulaStringMap, IRuntimeOtherUnitDataType, IRuntimeUnitDataPrimitiveType } from '../../basics/common';
|
|
3
|
+
import { IFormulaDependencyTreeFullJson, IFormulaDependencyTreeJson } from '../../engine/dependency/dependency-tree';
|
|
3
4
|
import { IFormulaDirtyData } from '../../services/current-data.service';
|
|
4
5
|
import { FormulaExecutedStateType, IExecutionInProgressParams } from '../../services/runtime.service';
|
|
5
6
|
export interface ISetFormulaCalculationStartMutation extends IFormulaDirtyData {
|
|
6
7
|
options: Nullable<IExecutionOptions>;
|
|
7
8
|
}
|
|
9
|
+
export interface ISetFormulaStringBatchCalculationMutation {
|
|
10
|
+
formulas: IFormulaStringMap;
|
|
11
|
+
}
|
|
12
|
+
export interface ISetFormulaStringBatchCalculationResultMutation {
|
|
13
|
+
result: IFormulaExecuteResultMap;
|
|
14
|
+
}
|
|
15
|
+
export interface ISetFormulaStringBatchCalculationResultMutation {
|
|
16
|
+
result: IFormulaExecuteResultMap;
|
|
17
|
+
}
|
|
18
|
+
export interface ISetFormulaDependencyCalculationMutation {
|
|
19
|
+
unitId: string;
|
|
20
|
+
sheetId: string;
|
|
21
|
+
row: number;
|
|
22
|
+
column: number;
|
|
23
|
+
}
|
|
24
|
+
export interface ISetFormulaDependencyCalculationResultMutation {
|
|
25
|
+
result: IFormulaDependencyTreeJson[];
|
|
26
|
+
}
|
|
27
|
+
export interface ISetCellFormulaDependencyCalculationResultMutation {
|
|
28
|
+
result: IFormulaDependencyTreeFullJson | undefined;
|
|
29
|
+
}
|
|
30
|
+
export interface ISetQueryFormulaDependencyMutation {
|
|
31
|
+
unitRanges: IUnitRange[];
|
|
32
|
+
isInRange?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface ISetQueryFormulaDependencyResultMutation {
|
|
35
|
+
result: IFormulaDependencyTreeJson[];
|
|
36
|
+
}
|
|
8
37
|
/**
|
|
9
38
|
* TODO: @DR-Univer
|
|
10
39
|
* Trigger the calculation of the formula and stop the formula
|
|
11
40
|
*/
|
|
12
41
|
export declare const SetFormulaCalculationStartMutation: IMutation<ISetFormulaCalculationStartMutation>;
|
|
42
|
+
export declare const SetFormulaStringBatchCalculationMutation: IMutation<ISetFormulaStringBatchCalculationMutation>;
|
|
43
|
+
export declare const SetFormulaStringBatchCalculationResultMutation: IMutation<ISetFormulaStringBatchCalculationResultMutation>;
|
|
13
44
|
export interface ISetFormulaCalculationStopMutation {
|
|
14
45
|
}
|
|
15
46
|
export declare const SetFormulaCalculationStopMutation: IMutation<ISetFormulaCalculationStopMutation>;
|
|
@@ -23,3 +54,9 @@ export interface ISetFormulaCalculationResultMutation {
|
|
|
23
54
|
unitOtherData: IRuntimeOtherUnitDataType;
|
|
24
55
|
}
|
|
25
56
|
export declare const SetFormulaCalculationResultMutation: IMutation<ISetFormulaCalculationResultMutation>;
|
|
57
|
+
export declare const SetFormulaDependencyCalculationMutation: IMutation<{}>;
|
|
58
|
+
export declare const SetFormulaDependencyCalculationResultMutation: IMutation<ISetFormulaDependencyCalculationResultMutation>;
|
|
59
|
+
export declare const SetCellFormulaDependencyCalculationMutation: IMutation<ISetFormulaDependencyCalculationMutation>;
|
|
60
|
+
export declare const SetCellFormulaDependencyCalculationResultMutation: IMutation<ISetCellFormulaDependencyCalculationResultMutation>;
|
|
61
|
+
export declare const SetQueryFormulaDependencyMutation: IMutation<ISetQueryFormulaDependencyMutation>;
|
|
62
|
+
export declare const SetQueryFormulaDependencyResultMutation: IMutation<ISetQueryFormulaDependencyResultMutation>;
|
|
@@ -9,6 +9,10 @@ export declare class CalculateController extends Disposable {
|
|
|
9
9
|
private _initialize;
|
|
10
10
|
private _commandExecutedListener;
|
|
11
11
|
private _calculate;
|
|
12
|
+
private _queryFormulaDependencyJson;
|
|
13
|
+
private _generateAllDependencyTreeJson;
|
|
14
|
+
private _generateCellDependencyTreeJson;
|
|
15
|
+
private _calculateFormulaString;
|
|
12
16
|
private _initialExecuteFormulaListener;
|
|
13
17
|
private _applyResult;
|
|
14
18
|
}
|
|
@@ -115,4 +115,43 @@ export declare class FormulaDependencyTree extends FormulaDependencyTreeCalculat
|
|
|
115
115
|
shouldBePushRangeList(): boolean;
|
|
116
116
|
toRTreeItem(): IUnitRange[];
|
|
117
117
|
}
|
|
118
|
+
interface IFormulaDependencyTreeJsonBase {
|
|
119
|
+
treeId: number;
|
|
120
|
+
formula: string;
|
|
121
|
+
row: number;
|
|
122
|
+
column: number;
|
|
123
|
+
unitId: string;
|
|
124
|
+
subUnitId: string;
|
|
125
|
+
refOffsetX: number;
|
|
126
|
+
refOffsetY: number;
|
|
127
|
+
rangeList: IUnitRange[];
|
|
128
|
+
refTreeId: number | undefined;
|
|
129
|
+
}
|
|
130
|
+
export interface IFormulaDependencyTreeJson extends IFormulaDependencyTreeJsonBase {
|
|
131
|
+
children: number[];
|
|
132
|
+
parents: number[];
|
|
133
|
+
}
|
|
134
|
+
export interface IFormulaDependencyTreeFullJson extends IFormulaDependencyTreeJsonBase {
|
|
135
|
+
children: IFormulaDependencyTreeJson[];
|
|
136
|
+
parents: IFormulaDependencyTreeJson[];
|
|
137
|
+
}
|
|
138
|
+
export declare class FormulaDependencyTreeModel {
|
|
139
|
+
children: Set<FormulaDependencyTreeModel>;
|
|
140
|
+
parents: Set<FormulaDependencyTreeModel>;
|
|
141
|
+
treeId: number;
|
|
142
|
+
formula: string;
|
|
143
|
+
refOffsetX: number;
|
|
144
|
+
refOffsetY: number;
|
|
145
|
+
row: number;
|
|
146
|
+
column: number;
|
|
147
|
+
unitId: string;
|
|
148
|
+
subUnitId: string;
|
|
149
|
+
rangeList: IUnitRange[];
|
|
150
|
+
refTreeId: number | undefined;
|
|
151
|
+
constructor(tree: IFormulaDependencyTree);
|
|
152
|
+
toJson(): IFormulaDependencyTreeJson;
|
|
153
|
+
toFullJson(): IFormulaDependencyTreeFullJson;
|
|
154
|
+
addParent(parent: FormulaDependencyTreeModel): void;
|
|
155
|
+
addChild(child: FormulaDependencyTreeModel): void;
|
|
156
|
+
}
|
|
118
157
|
export {};
|
|
@@ -4,17 +4,22 @@ import { IFeatureCalculationManagerParam, IFeatureCalculationManagerService } fr
|
|
|
4
4
|
import { FunctionNode } from '../ast-node';
|
|
5
5
|
import { BaseAstNode } from '../ast-node/base-ast-node';
|
|
6
6
|
import { IExecuteAstNodeData } from '../utils/ast-node-tool';
|
|
7
|
-
import { IFormulaDependencyTree, FormulaDependencyTree, FormulaDependencyTreeVirtual } from './dependency-tree';
|
|
7
|
+
import { IFormulaDependencyTree, IFormulaDependencyTreeFullJson, IFormulaDependencyTreeJson, FormulaDependencyTree, FormulaDependencyTreeModel, FormulaDependencyTreeVirtual } from './dependency-tree';
|
|
8
8
|
import { IFormulaCurrentConfigService } from '../../services/current-data.service';
|
|
9
9
|
import { IDependencyManagerService } from '../../services/dependency-manager.service';
|
|
10
10
|
import { IOtherFormulaManagerService } from '../../services/other-formula-manager.service';
|
|
11
11
|
import { IFormulaRuntimeService } from '../../services/runtime.service';
|
|
12
12
|
import { Lexer } from '../analysis/lexer';
|
|
13
|
+
import { LexerTreeBuilder } from '../analysis/lexer-tree-builder';
|
|
13
14
|
import { AstTreeBuilder } from '../analysis/parser';
|
|
14
15
|
import { Interpreter } from '../interpreter/interpreter';
|
|
15
16
|
export declare function generateRandomDependencyTreeId(dependencyManagerService: IDependencyManagerService): number;
|
|
16
17
|
export interface IFormulaDependencyGenerator {
|
|
17
18
|
generate(): Promise<IFormulaDependencyTree[]>;
|
|
19
|
+
getAllDependencyJson(): Promise<IFormulaDependencyTreeJson[]>;
|
|
20
|
+
getCellDependencyJson(unitId: string, sheetId: string, row: number, column: number): Promise<IFormulaDependencyTreeFullJson | undefined>;
|
|
21
|
+
getRangeDependents(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
22
|
+
getInRangeFormulas(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
18
23
|
}
|
|
19
24
|
export declare const IFormulaDependencyGenerator: import('@wendellhu/redi').IdentifierDecorator<IFormulaDependencyGenerator>;
|
|
20
25
|
export declare class FormulaDependencyGenerator extends Disposable {
|
|
@@ -26,9 +31,10 @@ export declare class FormulaDependencyGenerator extends Disposable {
|
|
|
26
31
|
protected readonly _astTreeBuilder: AstTreeBuilder;
|
|
27
32
|
protected readonly _lexer: Lexer;
|
|
28
33
|
protected readonly _dependencyManagerService: IDependencyManagerService;
|
|
34
|
+
protected readonly _lexerTreeBuilder: LexerTreeBuilder;
|
|
29
35
|
private _updateRangeFlattenCache;
|
|
30
36
|
protected _dependencyRTreeCacheForAddressFunction: RTree;
|
|
31
|
-
constructor(_currentConfigService: IFormulaCurrentConfigService, _runtimeService: IFormulaRuntimeService, _otherFormulaManagerService: IOtherFormulaManagerService, _featureCalculationManagerService: IFeatureCalculationManagerService, _interpreter: Interpreter, _astTreeBuilder: AstTreeBuilder, _lexer: Lexer, _dependencyManagerService: IDependencyManagerService);
|
|
37
|
+
constructor(_currentConfigService: IFormulaCurrentConfigService, _runtimeService: IFormulaRuntimeService, _otherFormulaManagerService: IOtherFormulaManagerService, _featureCalculationManagerService: IFeatureCalculationManagerService, _interpreter: Interpreter, _astTreeBuilder: AstTreeBuilder, _lexer: Lexer, _dependencyManagerService: IDependencyManagerService, _lexerTreeBuilder: LexerTreeBuilder);
|
|
32
38
|
dispose(): void;
|
|
33
39
|
generate(): Promise<(FormulaDependencyTree | FormulaDependencyTreeVirtual)[]>;
|
|
34
40
|
private _dependencyFeatureCalculation;
|
|
@@ -110,4 +116,18 @@ export declare class FormulaDependencyGenerator extends Disposable {
|
|
|
110
116
|
* @param treeList
|
|
111
117
|
*/
|
|
112
118
|
protected _calculateRunList(treeList: IFormulaDependencyTree[]): (FormulaDependencyTree | FormulaDependencyTreeVirtual)[];
|
|
119
|
+
protected _initializeGenerateTreeList(): Promise<IFormulaDependencyTree[]>;
|
|
120
|
+
protected _getAllTreeList(): Promise<IFormulaDependencyTree[]>;
|
|
121
|
+
protected _formulaDependencyTreeModel: Map<number, FormulaDependencyTreeModel>;
|
|
122
|
+
protected _getTreeModel(treeId: number): FormulaDependencyTreeModel;
|
|
123
|
+
protected _getDependencyTreeParenIds(tree: IFormulaDependencyTree): Set<number>;
|
|
124
|
+
protected _getDependencyTreeChildrenIds(tree: IFormulaDependencyTree): Set<number>;
|
|
125
|
+
protected _getFormulaDependencyTreeModel(tree: IFormulaDependencyTree): FormulaDependencyTreeModel;
|
|
126
|
+
protected _endFormulaDependencyTreeModel(): void;
|
|
127
|
+
protected _startFormulaDependencyTreeModel(): void;
|
|
128
|
+
getAllDependencyJson(): Promise<IFormulaDependencyTreeJson[]>;
|
|
129
|
+
protected _setRealFormulaString(treeModel: FormulaDependencyTreeModel): void;
|
|
130
|
+
getCellDependencyJson(unitId: string, sheetId: string, row: number, column: number): Promise<IFormulaDependencyTreeFullJson | undefined>;
|
|
131
|
+
getRangeDependents(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
132
|
+
getInRangeFormulas(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
113
133
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IDisposable, ICommandService, IConfigService, Injector } from '@univerjs/core';
|
|
2
|
-
import { FormulaExecutedStateType, IExecutionInProgressParams, ISequenceNode, LexerTreeBuilder } from '@univerjs/engine-formula';
|
|
1
|
+
import { IDisposable, IUnitRange, ICommandService, IConfigService, Injector } from '@univerjs/core';
|
|
2
|
+
import { FormulaExecutedStateType, IExecutionInProgressParams, IFormulaDependencyTreeFullJson, IFormulaDependencyTreeJson, IFormulaExecuteResultMap, IFormulaStringMap, ISequenceNode, ISetFormulaCalculationResultMutation, LexerTreeBuilder } from '@univerjs/engine-formula';
|
|
3
3
|
import { FBase } from '@univerjs/core/facade';
|
|
4
4
|
/**
|
|
5
5
|
* This interface class provides methods to modify the behavior of the operation formula.
|
|
@@ -146,4 +146,257 @@ export declare class FFormula extends FBase {
|
|
|
146
146
|
* ```
|
|
147
147
|
*/
|
|
148
148
|
setMaxIteration(maxIteration: number): void;
|
|
149
|
+
/**
|
|
150
|
+
* Listens for the moment when formula-calculation results are applied.
|
|
151
|
+
*
|
|
152
|
+
* This event fires after the engine completes a calculation cycle and
|
|
153
|
+
* dispatches a `SetFormulaCalculationResultMutation`.
|
|
154
|
+
* The callback is invoked during an idle frame to avoid blocking UI updates.
|
|
155
|
+
*
|
|
156
|
+
* @param {Function} callback - A function called with the calculation result payload
|
|
157
|
+
* once the result-application mutation is emitted.
|
|
158
|
+
* @returns {IDisposable} A disposable used to unsubscribe from the event.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```ts
|
|
162
|
+
* const formulaEngine = univerAPI.getFormula();
|
|
163
|
+
*
|
|
164
|
+
* const dispose = formulaEngine.calculationResultApplied((result) => {
|
|
165
|
+
* console.log('Calculation results applied:', result);
|
|
166
|
+
* });
|
|
167
|
+
*
|
|
168
|
+
* // Later…
|
|
169
|
+
* dispose.dispose();
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
calculationResultApplied(callback: (result: ISetFormulaCalculationResultMutation) => void): IDisposable;
|
|
173
|
+
/**
|
|
174
|
+
* Waits for formula-calculation results to be applied.
|
|
175
|
+
*
|
|
176
|
+
* This method resolves under three conditions:
|
|
177
|
+
* 1. A real calculation runs and the engine emits a "calculation started" signal,
|
|
178
|
+
* followed by a "calculation result applied" signal.
|
|
179
|
+
* 2. No calculation actually starts within 500 ms — the method assumes there is
|
|
180
|
+
* nothing to wait for and resolves automatically.
|
|
181
|
+
* 3. A global 30 s timeout triggers, in which case the promise rejects.
|
|
182
|
+
*
|
|
183
|
+
* The API internally listens to both “calculation in progress” events and
|
|
184
|
+
* “calculation result applied” events, ensuring it behaves correctly whether
|
|
185
|
+
* formulas are recalculated or skipped due to cache/state.
|
|
186
|
+
*
|
|
187
|
+
* @returns {Promise<void>} A promise that resolves when calculation results are applied
|
|
188
|
+
* or when no calculation occurs within the start-detection window.
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```ts
|
|
192
|
+
* const formulaEngine = univerAPI.getFormula();
|
|
193
|
+
*
|
|
194
|
+
* // Wait for formula updates to apply before reading values.
|
|
195
|
+
* await formulaEngine.onCalculationResultApplied();
|
|
196
|
+
*
|
|
197
|
+
* const value = sheet.getRange("C24").getValue();
|
|
198
|
+
* console.log("Updated value:", value);
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
onCalculationResultApplied(): Promise<void>;
|
|
202
|
+
/**
|
|
203
|
+
* Execute a batch of formulas asynchronously and receive computed results.
|
|
204
|
+
*
|
|
205
|
+
* Each formula cell is represented as a string array:
|
|
206
|
+
* [fullFormula, ...subFormulas]
|
|
207
|
+
*
|
|
208
|
+
* Where:
|
|
209
|
+
* - fullFormula (index 0) is the complete formula expression written in the cell.
|
|
210
|
+
* Example: "=SUM(A1:A10) + SQRT(D7)".
|
|
211
|
+
*
|
|
212
|
+
* - subFormulas (index 1+) are **optional decomposed expressions** extracted from
|
|
213
|
+
* the full formula. Each of them can be independently computed by the formula engine.
|
|
214
|
+
*
|
|
215
|
+
* These sub-expressions can include:
|
|
216
|
+
* - Single-cell references: "A2", "B2", "C5"
|
|
217
|
+
* - Range references: "A1:A10"
|
|
218
|
+
* - Function calls: "SQRT(D7)", "ABS(A2-B2)"
|
|
219
|
+
* - Any sub-formula that was parsed out of the original formula and can be
|
|
220
|
+
* evaluated on its own.
|
|
221
|
+
*
|
|
222
|
+
* The batch execution engine may use these sub-formulas for dependency resolution,
|
|
223
|
+
* incremental computation, or performance optimizations.
|
|
224
|
+
*
|
|
225
|
+
* @param {IFormulaStringMap} formulas
|
|
226
|
+
* Nested structure (unit → sheet → row → column) describing formulas and
|
|
227
|
+
* their decomposed sub-expressions.
|
|
228
|
+
*
|
|
229
|
+
* @param {number} [timeout]
|
|
230
|
+
* Optional timeout in milliseconds. If no result is received within this
|
|
231
|
+
* period, the promise will be rejected.
|
|
232
|
+
*
|
|
233
|
+
* @returns {Promise<IFormulaExecuteResultMap>}
|
|
234
|
+
* A promise that resolves with the computed value map mirroring
|
|
235
|
+
* the input structure.
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* ```ts
|
|
239
|
+
* const formulaEngine = univerAPI.getFormula();
|
|
240
|
+
* const formulas = {
|
|
241
|
+
* Book1: {
|
|
242
|
+
* Sheet1: {
|
|
243
|
+
* 2: {
|
|
244
|
+
* 3: [
|
|
245
|
+
* // Full formula:
|
|
246
|
+
* "=SUM(A1:A10) + SQRT(D7)",
|
|
247
|
+
*
|
|
248
|
+
* // Decomposed sub-formulas (each one can be evaluated independently):
|
|
249
|
+
* "SUM(A1:A10)", // sub-formula 1
|
|
250
|
+
* "SQRT(D7)", // sub-formula 2
|
|
251
|
+
* "A1:A10", // range reference
|
|
252
|
+
* "D7", // single-cell reference
|
|
253
|
+
* ],
|
|
254
|
+
* },
|
|
255
|
+
* 4: {
|
|
256
|
+
* 5: [
|
|
257
|
+
* "=A2 + B2 + SQRT(C5)",
|
|
258
|
+
* "A2",
|
|
259
|
+
* "B2",
|
|
260
|
+
* "SQRT(C5)",
|
|
261
|
+
* ],
|
|
262
|
+
* }
|
|
263
|
+
* },
|
|
264
|
+
* },
|
|
265
|
+
* };
|
|
266
|
+
*
|
|
267
|
+
* const result = await formulaEngine.executeFormulas(formulas);
|
|
268
|
+
* console.log(result);
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
executeFormulas(formulas: IFormulaStringMap, timeout?: number): Promise<IFormulaExecuteResultMap>;
|
|
272
|
+
/**
|
|
273
|
+
* Retrieve all formula dependency trees that were produced during the latest
|
|
274
|
+
* dependency-analysis run. This triggers a local dependency-calculation command
|
|
275
|
+
* and returns the complete set of dependency trees once the calculation finishes.
|
|
276
|
+
*
|
|
277
|
+
* @param {number} [timeout]
|
|
278
|
+
* Optional timeout in milliseconds. If no result is received within this
|
|
279
|
+
* period, the promise will be rejected.
|
|
280
|
+
*
|
|
281
|
+
* @returns {Promise<IFormulaDependencyTreeJson[]>}
|
|
282
|
+
* A promise that resolves with the array of dependency trees.
|
|
283
|
+
*
|
|
284
|
+
* @example
|
|
285
|
+
* ```ts
|
|
286
|
+
* const formulaEngine = univerAPI.getFormula();
|
|
287
|
+
*
|
|
288
|
+
* // Fetch all dependency trees generated for the current workbook.
|
|
289
|
+
* const trees = await formulaEngine.getAllDependencyTrees();
|
|
290
|
+
* console.log('All dependency trees:', trees);
|
|
291
|
+
* ```
|
|
292
|
+
*/
|
|
293
|
+
getAllDependencyTrees(timeout?: number): Promise<IFormulaDependencyTreeJson[]>;
|
|
294
|
+
/**
|
|
295
|
+
* Retrieve the dependency tree of a specific cell. This triggers a local
|
|
296
|
+
* dependency-calculation command for the given unit, sheet, and cell location,
|
|
297
|
+
* and returns the computed dependency tree when the calculation is completed.
|
|
298
|
+
*
|
|
299
|
+
* @param param The target cell location:
|
|
300
|
+
* - `unitId` The workbook ID.
|
|
301
|
+
* - `sheetId` The sheet ID.
|
|
302
|
+
* - `row` The zero-based row index.
|
|
303
|
+
* - `column` The zero-based column index.
|
|
304
|
+
*
|
|
305
|
+
* @param {number} [timeout]
|
|
306
|
+
* Optional timeout in milliseconds. If no result is received within this
|
|
307
|
+
* period, the promise will be rejected.
|
|
308
|
+
*
|
|
309
|
+
* @returns {Promise<IFormulaDependencyTreeFullJson | undefined>}
|
|
310
|
+
* A promise that resolves with the dependency tree or `undefined`
|
|
311
|
+
* if no tree exists for that cell.
|
|
312
|
+
*
|
|
313
|
+
* @example
|
|
314
|
+
* ```ts
|
|
315
|
+
* const formulaEngine = univerAPI.getFormula();
|
|
316
|
+
*
|
|
317
|
+
* // Query the dependency tree for cell B2 in a specific sheet.
|
|
318
|
+
* const tree = await formulaEngine.getCellDependencyTree({
|
|
319
|
+
* unitId: 'workbook1',
|
|
320
|
+
* sheetId: 'sheet1',
|
|
321
|
+
* row: 1,
|
|
322
|
+
* column: 1,
|
|
323
|
+
* });
|
|
324
|
+
*
|
|
325
|
+
* console.log('Cell dependency tree:', tree);
|
|
326
|
+
* ```
|
|
327
|
+
*/
|
|
328
|
+
getCellDependencyTree(param: {
|
|
329
|
+
unitId: string;
|
|
330
|
+
sheetId: string;
|
|
331
|
+
row: number;
|
|
332
|
+
column: number;
|
|
333
|
+
}, timeout?: number): Promise<IFormulaDependencyTreeFullJson | undefined>;
|
|
334
|
+
/**
|
|
335
|
+
* Retrieve the full dependency trees for all formulas that *depend on* the
|
|
336
|
+
* specified ranges. This triggers a local dependency-calculation command and
|
|
337
|
+
* resolves once the calculation completes.
|
|
338
|
+
*
|
|
339
|
+
* @param unitRanges An array of workbook/sheet ranges to query. Each range
|
|
340
|
+
* includes:
|
|
341
|
+
* - `unitId` The workbook ID.
|
|
342
|
+
* - `sheetId` The sheet ID.
|
|
343
|
+
* - `range` The row/column boundaries.
|
|
344
|
+
*
|
|
345
|
+
* @param {number} [timeout]
|
|
346
|
+
* Optional timeout in milliseconds. If no result is received within this
|
|
347
|
+
* period, the promise will be rejected.
|
|
348
|
+
*
|
|
349
|
+
* @returns {Promise<IFormulaDependencyTreeJson[]>}
|
|
350
|
+
* A promise that resolves with an array of `IFormulaDependencyTreeJson`
|
|
351
|
+
* representing formulas and their relationships within the dependency graph.
|
|
352
|
+
*
|
|
353
|
+
* @example
|
|
354
|
+
* ```ts
|
|
355
|
+
* const formulaEngine = univerAPI.getFormula();
|
|
356
|
+
*
|
|
357
|
+
* // Query all formulas that depend on A1:B10 in Sheet1.
|
|
358
|
+
* const dependents = await formulaEngine.getRangeDependents([
|
|
359
|
+
* { unitId: 'workbook1', sheetId: 'sheet1', range: { startRow: 0, endRow: 9, startColumn: 0, endColumn: 1 } }
|
|
360
|
+
* ]);
|
|
361
|
+
*
|
|
362
|
+
* console.log('Dependent formulas:', dependents);
|
|
363
|
+
* ```
|
|
364
|
+
*/
|
|
365
|
+
getRangeDependents(unitRanges: IUnitRange[], timeout?: number): Promise<IFormulaDependencyTreeJson[]>;
|
|
366
|
+
/**
|
|
367
|
+
* Retrieve the dependency trees of all formulas *inside* the specified ranges.
|
|
368
|
+
* Unlike `getRangeDependents`, this API only returns formulas whose definitions
|
|
369
|
+
* physically reside within the queried ranges.
|
|
370
|
+
*
|
|
371
|
+
* Internally this triggers the same dependency-calculation command but with
|
|
372
|
+
* `isInRange = true`, and the promise resolves when the results are ready.
|
|
373
|
+
*
|
|
374
|
+
* @param unitRanges An array of workbook/sheet ranges defining the lookup
|
|
375
|
+
* boundaries:
|
|
376
|
+
* - `unitId` The workbook ID.
|
|
377
|
+
* - `sheetId` The sheet ID.
|
|
378
|
+
* - `range` The zero-based grid range.
|
|
379
|
+
*
|
|
380
|
+
* @param {number} [timeout]
|
|
381
|
+
* Optional timeout in milliseconds. If no result is received within this
|
|
382
|
+
* period, the promise will be rejected.
|
|
383
|
+
*
|
|
384
|
+
* @returns {Promise<IFormulaDependencyTreeJson[]>}
|
|
385
|
+
* A promise that resolves with an array of `IFormulaDependencyTreeJson`
|
|
386
|
+
* describing every formula found in the provided ranges along with
|
|
387
|
+
* their parent/child relationships.
|
|
388
|
+
*
|
|
389
|
+
* @example
|
|
390
|
+
* ```ts
|
|
391
|
+
* const formulaEngine = univerAPI.getFormula();
|
|
392
|
+
*
|
|
393
|
+
* // Query all formulas that lie within A1:D20 in Sheet1.
|
|
394
|
+
* const formulasInRange = await formulaEngine.getInRangeFormulas([
|
|
395
|
+
* { unitId: 'workbook1', sheetId: 'sheet1', range: { startRow: 0, endRow: 19, startColumn: 0, endColumn: 3 } }
|
|
396
|
+
* ]);
|
|
397
|
+
*
|
|
398
|
+
* console.log('Formulas inside range:', formulasInRange);
|
|
399
|
+
* ```
|
|
400
|
+
*/
|
|
401
|
+
getInRangeFormulas(unitRanges: IUnitRange[], timeout?: number): Promise<IFormulaDependencyTreeJson[]>;
|
|
149
402
|
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -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
|
-
export type { IArrayFormulaEmbeddedMap, IArrayFormulaRangeType, IArrayFormulaUnitCellType, IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefinedNameMap, IDirtyUnitSheetNameMap, IFeatureDirtyRangeType, IFormulaData, IFormulaDataItem, IFormulaDatasetConfig, IRuntimeImageFormulaDataType, IRuntimeUnitDataType, ISheetData, IUnitData, IUnitImageFormulaDataType, IUnitSheetNameMap, } from './basics/common';
|
|
16
|
+
export type { IArrayFormulaEmbeddedMap, IArrayFormulaRangeType, IArrayFormulaUnitCellType, IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefinedNameMap, IDirtyUnitSheetNameMap, IFeatureDirtyRangeType, IFormulaData, IFormulaDataItem, IFormulaDatasetConfig, IFormulaExecuteResultMap, IFormulaStringMap, IRuntimeImageFormulaDataType, IRuntimeUnitDataType, ISheetData, IUnitData, IUnitImageFormulaDataType, IUnitSheetNameMap, } from './basics/common';
|
|
17
17
|
export { BooleanValue } from './basics/common';
|
|
18
18
|
export { type IOtherFormulaData } from './basics/common';
|
|
19
19
|
export { type IUnitRowData } from './basics/common';
|
|
@@ -33,7 +33,7 @@ export { type ISetArrayFormulaDataMutationParams, SetArrayFormulaDataMutation }
|
|
|
33
33
|
export { type ISetDefinedNameMutationParam, type ISetDefinedNameMutationSearchParam, RemoveDefinedNameMutation, SetDefinedNameMutation } from './commands/mutations/set-defined-name.mutation';
|
|
34
34
|
export { SetDefinedNameMutationFactory } from './commands/mutations/set-defined-name.mutation';
|
|
35
35
|
export { RemoveFeatureCalculationMutation, SetFeatureCalculationMutation } from './commands/mutations/set-feature-calculation.mutation';
|
|
36
|
-
export { type ISetFormulaCalculationNotificationMutation, type ISetFormulaCalculationResultMutation, type ISetFormulaCalculationStartMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation, } from './commands/mutations/set-formula-calculation.mutation';
|
|
36
|
+
export { type ISetCellFormulaDependencyCalculationResultMutation, type ISetFormulaCalculationNotificationMutation, type ISetFormulaCalculationResultMutation, type ISetFormulaCalculationStartMutation, type ISetFormulaDependencyCalculationMutation, type ISetFormulaDependencyCalculationResultMutation, type ISetFormulaStringBatchCalculationResultMutation, type ISetQueryFormulaDependencyResultMutation, SetCellFormulaDependencyCalculationMutation, SetCellFormulaDependencyCalculationResultMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation, SetFormulaDependencyCalculationMutation, SetFormulaDependencyCalculationResultMutation, SetFormulaStringBatchCalculationMutation, SetFormulaStringBatchCalculationResultMutation, SetQueryFormulaDependencyMutation, SetQueryFormulaDependencyResultMutation, } from './commands/mutations/set-formula-calculation.mutation';
|
|
37
37
|
export { type ISetFormulaDataMutationParams, SetFormulaDataMutation } from './commands/mutations/set-formula-data.mutation';
|
|
38
38
|
export { type ISetImageFormulaDataMutationParams, SetImageFormulaDataMutation } from './commands/mutations/set-image-formula-data.mutation';
|
|
39
39
|
export { type IRemoveOtherFormulaMutationParams, type ISetOtherFormulaMutationParams, RemoveOtherFormulaMutation, SetOtherFormulaMutation } from './commands/mutations/set-other-formula.mutation';
|
|
@@ -56,7 +56,7 @@ export { ReferenceNodeFactory } from './engine/ast-node/reference-node';
|
|
|
56
56
|
export { SuffixNodeFactory } from './engine/ast-node/suffix-node';
|
|
57
57
|
export { UnionNodeFactory } from './engine/ast-node/union-node';
|
|
58
58
|
export { ValueNodeFactory } from './engine/ast-node/value-node';
|
|
59
|
-
export { FormulaDependencyTree, type IFormulaDependencyTree } from './engine/dependency/dependency-tree';
|
|
59
|
+
export { FormulaDependencyTree, FormulaDependencyTreeModel, type IFormulaDependencyTree, type IFormulaDependencyTreeFullJson, type IFormulaDependencyTreeJson } from './engine/dependency/dependency-tree';
|
|
60
60
|
export { FormulaDependencyTreeType } from './engine/dependency/dependency-tree';
|
|
61
61
|
export { FormulaDependencyTreeVirtual } from './engine/dependency/dependency-tree';
|
|
62
62
|
export { FormulaDependencyGenerator, IFormulaDependencyGenerator } from './engine/dependency/formula-dependency';
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { IUnitRange, Disposable, IConfigService } from '@univerjs/core';
|
|
1
2
|
import { Observable, Subject } from 'rxjs';
|
|
2
|
-
import { IFeatureDirtyRangeType, IFormulaDatasetConfig, IRuntimeUnitDataType } from '../basics/common';
|
|
3
|
+
import { IFeatureDirtyRangeType, IFormulaDatasetConfig, IFormulaExecuteResultMap, IFormulaStringMap, IRuntimeUnitDataType, IUnitRowData } from '../basics/common';
|
|
4
|
+
import { IFormulaDependencyTreeFullJson, IFormulaDependencyTreeJson } from '../engine/dependency/dependency-tree';
|
|
5
|
+
import { FunctionVariantType } from '../engine/reference-object/base-reference-object';
|
|
3
6
|
import { IAllRuntimeData, IExecutionInProgressParams, IFormulaRuntimeService } from './runtime.service';
|
|
4
|
-
import { Disposable, IConfigService } from '@univerjs/core';
|
|
5
7
|
import { Lexer } from '../engine/analysis/lexer';
|
|
6
8
|
import { AstTreeBuilder } from '../engine/analysis/parser';
|
|
7
|
-
import { ErrorNode } from '../engine/ast-node/base-ast-node';
|
|
8
9
|
import { IFormulaDependencyGenerator } from '../engine/dependency/formula-dependency';
|
|
9
10
|
import { Interpreter } from '../engine/interpreter/interpreter';
|
|
10
11
|
import { IFormulaCurrentConfigService } from './current-data.service';
|
|
@@ -19,6 +20,11 @@ export interface ICalculateFormulaService {
|
|
|
19
20
|
execute(formulaDatasetConfig: IFormulaDatasetConfig): Promise<void>;
|
|
20
21
|
stopFormulaExecution(): void;
|
|
21
22
|
calculate(formulaString: string, transformSuffix?: boolean): void;
|
|
23
|
+
executeFormulas(formulas: IFormulaStringMap, rowData?: IUnitRowData): Promise<IFormulaExecuteResultMap>;
|
|
24
|
+
getAllDependencyJson(rowData?: IUnitRowData): Promise<IFormulaDependencyTreeJson[]>;
|
|
25
|
+
getCellDependencyJson(unitId: string, sheetId: string, row: number, column: number, rowData?: IUnitRowData): Promise<IFormulaDependencyTreeFullJson | undefined>;
|
|
26
|
+
getRangeDependents(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
27
|
+
getInRangeFormulas(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
22
28
|
}
|
|
23
29
|
export declare const ICalculateFormulaService: import('@wendellhu/redi').IdentifierDecorator<ICalculateFormulaService>;
|
|
24
30
|
export declare class CalculateFormulaService extends Disposable implements ICalculateFormulaService {
|
|
@@ -53,5 +59,10 @@ export declare class CalculateFormulaService extends Disposable implements ICalc
|
|
|
53
59
|
private _executeStep;
|
|
54
60
|
private _getArrayFormulaDirtyRangeAndExcludedRange;
|
|
55
61
|
protected _apply(isArrayFormulaState?: boolean): Promise<IAllRuntimeData | undefined>;
|
|
56
|
-
|
|
62
|
+
executeFormulas(formulas: IFormulaStringMap, rowData?: IUnitRowData): Promise<IFormulaExecuteResultMap>;
|
|
63
|
+
calculate(formulaString: string): Promise<FunctionVariantType | undefined>;
|
|
64
|
+
getAllDependencyJson(): Promise<IFormulaDependencyTreeJson[]>;
|
|
65
|
+
getCellDependencyJson(unitId: string, sheetId: string, row: number, column: number): Promise<IFormulaDependencyTreeFullJson | undefined>;
|
|
66
|
+
getRangeDependents(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
67
|
+
getInRangeFormulas(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
57
68
|
}
|
|
@@ -55,6 +55,7 @@ export interface IFormulaCurrentConfigService {
|
|
|
55
55
|
};
|
|
56
56
|
getFilteredOutRows(unitId: string, sheetId: string, startRow: number, endRow: number): number[];
|
|
57
57
|
setSheetNameMap(sheetIdToNameMap: IUnitSheetIdToNameMap): void;
|
|
58
|
+
loadDataLite(rowData?: IUnitRowData): void;
|
|
58
59
|
}
|
|
59
60
|
export declare class FormulaCurrentConfigService extends Disposable implements IFormulaCurrentConfigService {
|
|
60
61
|
private readonly _univerInstanceService;
|
|
@@ -113,6 +114,7 @@ export declare class FormulaCurrentConfigService extends Disposable implements I
|
|
|
113
114
|
};
|
|
114
115
|
getFilteredOutRows(unitId: string, sheetId: string, startRow: number, endRow: number): number[];
|
|
115
116
|
load(config: IFormulaDatasetConfig): void;
|
|
117
|
+
loadDataLite(rowData?: IUnitRowData): void;
|
|
116
118
|
getDirtyData(): IFormulaDirtyData;
|
|
117
119
|
loadDirtyRangesAndExcludedCell(dirtyRanges: IUnitRange[], excludedCell?: IUnitExcludedCell): void;
|
|
118
120
|
registerUnitData(unitData: IUnitData): void;
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(s,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):(s=typeof globalThis<"u"?globalThis:s||self,l(s.UniverEngineFormulaFacade={},s.UniverCoreFacade,s.UniverCore,s.UniverEngineFormula,s.rxjs))})(this,(function(s,l,d,n,p){"use strict";var S=Object.getOwnPropertyDescriptor,v=(m,e,i,t)=>{for(var r=t>1?void 0:t?S(e,i):e,o=m.length-1,a;o>=0;o--)(a=m[o])&&(r=a(r)||r);return r},f=(m,e)=>(i,t)=>e(i,t,m);s.FFormula=class extends l.FBase{constructor(e,i,t,r){super(),this._commandService=e,this._injector=i,this._lexerTreeBuilder=t,this._configService=r,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.SetFormulaCalculationStartMutation.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):p.firstValueFrom(p.race(i.computingStatus$.pipe(p.filter(t=>t)),p.timer(e!=null?e:3e4).pipe(p.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(()=>{C(),i(new Error("Calculation end timeout"))},3e4),a=setTimeout(()=>{t||(C(),e())},500),u=this.calculationProcessing(()=>{t||(t=!0,clearTimeout(a))}),c=this.calculationResultApplied(()=>{r||(r=!0,C(),e())});function C(){clearTimeout(o),clearTimeout(a),u.dispose(),c.dispose()}})}executeFormulas(e,i=3e4){return new Promise((t,r)=>{const o=this._commandService.onCommandExecuted(u=>{if(u.id!==n.SetFormulaStringBatchCalculationResultMutation.id)return;const c=u.params;clearTimeout(a),o.dispose(),c.result!=null?t(c.result):r(new Error("Formula batch calculation returned no result"))}),a=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(a=>{if(a.id!==n.SetFormulaDependencyCalculationResultMutation.id)return;const u=a.params;clearTimeout(o),r.dispose(),u.result!=null?i(u.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(u=>{if(u.id!==n.SetCellFormulaDependencyCalculationResultMutation.id)return;const c=u.params;clearTimeout(a),o.dispose(),t(c.result)}),a=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(u=>{if(u.id!==n.SetQueryFormulaDependencyResultMutation.id)return;const c=u.params;clearTimeout(a),o.dispose(),c.result!=null?t(c.result):t([])}),a=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(u=>{if(u.id!==n.SetQueryFormulaDependencyResultMutation.id)return;const c=u.params;clearTimeout(a),o.dispose(),c.result!=null?t(c.result):t([])}),a=setTimeout(()=>{o.dispose(),r(new Error("In-range formulas calculation timeout"))},i);this._commandService.executeCommand(n.SetQueryFormulaDependencyMutation.id,{unitRanges:e,isInRange:!0},{onlyLocal:!0})})}},s.FFormula=v([f(0,d.Inject(d.ICommandService)),f(1,d.Inject(d.Injector)),f(2,d.Inject(n.LexerTreeBuilder)),f(3,d.IConfigService)],s.FFormula);class h extends l.FUniver{getFormula(){return this._injector.createInstance(s.FFormula)}}l.FUniver.extend(h),Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})}));
|