@univerjs/engine-formula 0.12.3-nightly.202512060617 → 0.12.4-experimental.20251208-c4b8a44
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 +184 -38
- package/lib/es/index.js +5521 -5212
- package/lib/facade.js +184 -38
- package/lib/index.js +5521 -5212
- 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 +29 -1
- package/lib/types/controller/calculate.controller.d.ts +3 -0
- package/lib/types/engine/dependency/dependency-tree.d.ts +39 -0
- package/lib/types/engine/dependency/formula-dependency.d.ts +17 -2
- package/lib/types/facade/f-formula.d.ts +128 -1
- package/lib/types/index.d.ts +3 -3
- package/lib/types/services/calculate-formula.service.d.ts +10 -3
- package/lib/types/services/current-data.service.d.ts +3 -1
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +4 -4
|
@@ -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,39 @@
|
|
|
1
1
|
import { IExecutionOptions, IMutation, Nullable } from '@univerjs/core';
|
|
2
|
-
import { IRuntimeOtherUnitDataType, IRuntimeUnitDataPrimitiveType } from '../../basics/common';
|
|
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
|
+
}
|
|
8
30
|
/**
|
|
9
31
|
* TODO: @DR-Univer
|
|
10
32
|
* Trigger the calculation of the formula and stop the formula
|
|
11
33
|
*/
|
|
12
34
|
export declare const SetFormulaCalculationStartMutation: IMutation<ISetFormulaCalculationStartMutation>;
|
|
35
|
+
export declare const SetFormulaStringBatchCalculationMutation: IMutation<ISetFormulaStringBatchCalculationMutation>;
|
|
36
|
+
export declare const SetFormulaStringBatchCalculationResultMutation: IMutation<ISetFormulaStringBatchCalculationResultMutation>;
|
|
13
37
|
export interface ISetFormulaCalculationStopMutation {
|
|
14
38
|
}
|
|
15
39
|
export declare const SetFormulaCalculationStopMutation: IMutation<ISetFormulaCalculationStopMutation>;
|
|
@@ -23,3 +47,7 @@ export interface ISetFormulaCalculationResultMutation {
|
|
|
23
47
|
unitOtherData: IRuntimeOtherUnitDataType;
|
|
24
48
|
}
|
|
25
49
|
export declare const SetFormulaCalculationResultMutation: IMutation<ISetFormulaCalculationResultMutation>;
|
|
50
|
+
export declare const SetFormulaDependencyCalculationMutation: IMutation<{}>;
|
|
51
|
+
export declare const SetFormulaDependencyCalculationResultMutation: IMutation<ISetFormulaDependencyCalculationResultMutation>;
|
|
52
|
+
export declare const SetCellFormulaDependencyCalculationMutation: IMutation<ISetFormulaDependencyCalculationMutation>;
|
|
53
|
+
export declare const SetCellFormulaDependencyCalculationResultMutation: IMutation<ISetCellFormulaDependencyCalculationResultMutation>;
|
|
@@ -9,6 +9,9 @@ export declare class CalculateController extends Disposable {
|
|
|
9
9
|
private _initialize;
|
|
10
10
|
private _commandExecutedListener;
|
|
11
11
|
private _calculate;
|
|
12
|
+
private _generateAllDependencyTreeJson;
|
|
13
|
+
private _generateCellDependencyTreeJson;
|
|
14
|
+
private _calculateFormulaString;
|
|
12
15
|
private _initialExecuteFormulaListener;
|
|
13
16
|
private _applyResult;
|
|
14
17
|
}
|
|
@@ -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,20 @@ 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>;
|
|
18
21
|
}
|
|
19
22
|
export declare const IFormulaDependencyGenerator: import('@wendellhu/redi').IdentifierDecorator<IFormulaDependencyGenerator>;
|
|
20
23
|
export declare class FormulaDependencyGenerator extends Disposable {
|
|
@@ -26,9 +29,10 @@ export declare class FormulaDependencyGenerator extends Disposable {
|
|
|
26
29
|
protected readonly _astTreeBuilder: AstTreeBuilder;
|
|
27
30
|
protected readonly _lexer: Lexer;
|
|
28
31
|
protected readonly _dependencyManagerService: IDependencyManagerService;
|
|
32
|
+
protected readonly _lexerTreeBuilder: LexerTreeBuilder;
|
|
29
33
|
private _updateRangeFlattenCache;
|
|
30
34
|
protected _dependencyRTreeCacheForAddressFunction: RTree;
|
|
31
|
-
constructor(_currentConfigService: IFormulaCurrentConfigService, _runtimeService: IFormulaRuntimeService, _otherFormulaManagerService: IOtherFormulaManagerService, _featureCalculationManagerService: IFeatureCalculationManagerService, _interpreter: Interpreter, _astTreeBuilder: AstTreeBuilder, _lexer: Lexer, _dependencyManagerService: IDependencyManagerService);
|
|
35
|
+
constructor(_currentConfigService: IFormulaCurrentConfigService, _runtimeService: IFormulaRuntimeService, _otherFormulaManagerService: IOtherFormulaManagerService, _featureCalculationManagerService: IFeatureCalculationManagerService, _interpreter: Interpreter, _astTreeBuilder: AstTreeBuilder, _lexer: Lexer, _dependencyManagerService: IDependencyManagerService, _lexerTreeBuilder: LexerTreeBuilder);
|
|
32
36
|
dispose(): void;
|
|
33
37
|
generate(): Promise<(FormulaDependencyTree | FormulaDependencyTreeVirtual)[]>;
|
|
34
38
|
private _dependencyFeatureCalculation;
|
|
@@ -110,4 +114,15 @@ export declare class FormulaDependencyGenerator extends Disposable {
|
|
|
110
114
|
* @param treeList
|
|
111
115
|
*/
|
|
112
116
|
protected _calculateRunList(treeList: IFormulaDependencyTree[]): (FormulaDependencyTree | FormulaDependencyTreeVirtual)[];
|
|
117
|
+
protected _initializeGenerateTreeList(): Promise<IFormulaDependencyTree[]>;
|
|
118
|
+
protected _getAllTreeList(): Promise<IFormulaDependencyTree[]>;
|
|
119
|
+
protected _formulaDependencyTreeModel: Map<number, FormulaDependencyTreeModel>;
|
|
120
|
+
protected _getTreeModel(treeId: number): FormulaDependencyTreeModel;
|
|
121
|
+
protected _getDependencyTreeParenIds(tree: IFormulaDependencyTree): Set<number>;
|
|
122
|
+
protected _getDependencyTreeChildrenIds(tree: IFormulaDependencyTree): Set<number>;
|
|
123
|
+
protected _getFormulaDependencyTreeModel(tree: IFormulaDependencyTree): FormulaDependencyTreeModel;
|
|
124
|
+
protected _endFormulaDependencyTreeModel(): void;
|
|
125
|
+
protected _startFormulaDependencyTreeModel(): void;
|
|
126
|
+
getAllDependencyJson(): Promise<IFormulaDependencyTreeJson[]>;
|
|
127
|
+
getCellDependencyJson(unitId: string, sheetId: string, row: number, column: number): Promise<IFormulaDependencyTreeFullJson | undefined>;
|
|
113
128
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IDisposable, ICommandService, IConfigService, Injector } from '@univerjs/core';
|
|
2
|
-
import { FormulaExecutedStateType, IExecutionInProgressParams, ISequenceNode, LexerTreeBuilder } from '@univerjs/engine-formula';
|
|
2
|
+
import { FormulaExecutedStateType, IExecutionInProgressParams, IFormulaDependencyTreeFullJson, IFormulaDependencyTreeJson, IFormulaExecuteResultMap, IFormulaStringMap, ISequenceNode, 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,131 @@ export declare class FFormula extends FBase {
|
|
|
146
146
|
* ```
|
|
147
147
|
*/
|
|
148
148
|
setMaxIteration(maxIteration: number): void;
|
|
149
|
+
/**
|
|
150
|
+
* Execute a batch of formulas asynchronously and receive computed results.
|
|
151
|
+
*
|
|
152
|
+
* Each formula cell is represented as a string array:
|
|
153
|
+
* [fullFormula, ...subFormulas]
|
|
154
|
+
*
|
|
155
|
+
* Where:
|
|
156
|
+
* - fullFormula (index 0) is the complete formula expression written in the cell.
|
|
157
|
+
* Example: "=SUM(A1:A10) + SQRT(D7)".
|
|
158
|
+
*
|
|
159
|
+
* - subFormulas (index 1+) are **optional decomposed expressions** extracted from
|
|
160
|
+
* the full formula. Each of them can be independently computed by the formula engine.
|
|
161
|
+
*
|
|
162
|
+
* These sub-expressions can include:
|
|
163
|
+
* - Single-cell references: "A2", "B2", "C5"
|
|
164
|
+
* - Range references: "A1:A10"
|
|
165
|
+
* - Function calls: "SQRT(D7)", "ABS(A2-B2)"
|
|
166
|
+
* - Any sub-formula that was parsed out of the original formula and can be
|
|
167
|
+
* evaluated on its own.
|
|
168
|
+
*
|
|
169
|
+
* The batch execution engine may use these sub-formulas for dependency resolution,
|
|
170
|
+
* incremental computation, or performance optimizations.
|
|
171
|
+
*
|
|
172
|
+
* @param {IFormulaStringMap} formulas
|
|
173
|
+
* Nested structure (unit → sheet → row → column) describing formulas and
|
|
174
|
+
* their decomposed sub-expressions.
|
|
175
|
+
*
|
|
176
|
+
* @param {(result: IFormulaExecuteResultMap) => void} callback
|
|
177
|
+
* Receives the computed value map mirroring the input structure.
|
|
178
|
+
*
|
|
179
|
+
* @returns {IDisposable}
|
|
180
|
+
* A disposer to stop listening for batch results.
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```ts
|
|
184
|
+
* const formulaEngine = univerAPI.getFormula();
|
|
185
|
+
* const formulas = {
|
|
186
|
+
* Book1: {
|
|
187
|
+
* Sheet1: {
|
|
188
|
+
* 2: {
|
|
189
|
+
* 3: [
|
|
190
|
+
* // Full formula:
|
|
191
|
+
* "=SUM(A1:A10) + SQRT(D7)",
|
|
192
|
+
*
|
|
193
|
+
* // Decomposed sub-formulas (each one can be evaluated independently):
|
|
194
|
+
* "SUM(A1:A10)", // sub-formula 1
|
|
195
|
+
* "SQRT(D7)", // sub-formula 2
|
|
196
|
+
* "A1:A10", // range reference
|
|
197
|
+
* "D7", // single-cell reference
|
|
198
|
+
* ],
|
|
199
|
+
* },
|
|
200
|
+
* 4: {
|
|
201
|
+
* 5: [
|
|
202
|
+
* "=A2 + B2 + SQRT(C5)",
|
|
203
|
+
* "A2",
|
|
204
|
+
* "B2",
|
|
205
|
+
* "SQRT(C5)",
|
|
206
|
+
* ],
|
|
207
|
+
* }
|
|
208
|
+
* },
|
|
209
|
+
* },
|
|
210
|
+
* };
|
|
211
|
+
*
|
|
212
|
+
* const disposer = formulaEngine.executeFormulas(formulas, (result) => {
|
|
213
|
+
* console.log(result);
|
|
214
|
+
* });
|
|
215
|
+
*
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
executeFormulas(formulas: IFormulaStringMap, callback: (result: IFormulaExecuteResultMap) => void): void;
|
|
219
|
+
/**
|
|
220
|
+
* Retrieve all formula dependency trees that were produced during the latest
|
|
221
|
+
* dependency-analysis run. This triggers a local dependency-calculation command
|
|
222
|
+
* and returns the complete set of dependency trees once the calculation finishes.
|
|
223
|
+
*
|
|
224
|
+
* @param callback A function invoked with the resulting array of dependency trees.
|
|
225
|
+
*
|
|
226
|
+
* @returns {IDisposable} An object that disposes the internal event listener.
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* ```ts
|
|
230
|
+
* const formulaEngine = univerAPI.getFormula();
|
|
231
|
+
*
|
|
232
|
+
* // Fetch all dependency trees generated for the current workbook.
|
|
233
|
+
* const disposable = formulaEngine.getAllDependencyTrees((trees) => {
|
|
234
|
+
* console.log('All dependency trees:', trees);
|
|
235
|
+
* });
|
|
236
|
+
*
|
|
237
|
+
* ```
|
|
238
|
+
*/
|
|
239
|
+
getAllDependencyTrees(callback: (result: IFormulaDependencyTreeJson[]) => void): void;
|
|
240
|
+
/**
|
|
241
|
+
* Retrieve the dependency tree of a specific cell. This triggers a local
|
|
242
|
+
* dependency-calculation command for the given unit, sheet, and cell location,
|
|
243
|
+
* and returns the computed dependency tree when the calculation is completed.
|
|
244
|
+
*
|
|
245
|
+
* @param param The target cell location:
|
|
246
|
+
* - `unitId` The workbook ID.
|
|
247
|
+
* - `sheetId` The sheet ID.
|
|
248
|
+
* - `row` The zero-based row index.
|
|
249
|
+
* - `column` The zero-based column index.
|
|
250
|
+
*
|
|
251
|
+
* @param callback A function invoked with the resulting dependency tree or
|
|
252
|
+
* `undefined` if no dependency tree exists for that cell.
|
|
253
|
+
*
|
|
254
|
+
* @returns {IDisposable} An object that disposes the internal event listener.
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```ts
|
|
258
|
+
* const formulaEngine = univerAPI.getFormula();
|
|
259
|
+
*
|
|
260
|
+
* // Query the dependency tree for cell B2 in a specific sheet.
|
|
261
|
+
* const disposable = formulaEngine.getCellDependencyTree(
|
|
262
|
+
* { unitId: 'workbook1', sheetId: 'sheet1', row: 1, column: 1 },
|
|
263
|
+
* (tree) => {
|
|
264
|
+
* console.log('Cell dependency tree:', tree);
|
|
265
|
+
* }
|
|
266
|
+
* );
|
|
267
|
+
*
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
getCellDependencyTree(param: {
|
|
271
|
+
unitId: string;
|
|
272
|
+
sheetId: string;
|
|
273
|
+
row: number;
|
|
274
|
+
column: number;
|
|
275
|
+
}, callback: (result: IFormulaDependencyTreeFullJson | undefined) => void): void;
|
|
149
276
|
}
|
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, SetCellFormulaDependencyCalculationMutation, SetCellFormulaDependencyCalculationResultMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation, SetFormulaDependencyCalculationMutation, SetFormulaDependencyCalculationResultMutation, SetFormulaStringBatchCalculationMutation, SetFormulaStringBatchCalculationResultMutation, } 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
1
|
import { Observable, Subject } from 'rxjs';
|
|
2
|
-
import { IFeatureDirtyRangeType, IFormulaDatasetConfig, IRuntimeUnitDataType } from '../basics/common';
|
|
2
|
+
import { IArrayFormulaRangeType, IArrayFormulaUnitCellType, IFeatureDirtyRangeType, IFormulaData, IFormulaDatasetConfig, IFormulaExecuteResultMap, IFormulaStringMap, IRuntimeUnitDataType, IUnitRowData } from '../basics/common';
|
|
3
|
+
import { IFormulaDependencyTreeFullJson, IFormulaDependencyTreeJson } from '../engine/dependency/dependency-tree';
|
|
4
|
+
import { FunctionVariantType } from '../engine/reference-object/base-reference-object';
|
|
3
5
|
import { IAllRuntimeData, IExecutionInProgressParams, IFormulaRuntimeService } from './runtime.service';
|
|
4
6
|
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,9 @@ 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, formulaData: IFormulaData, arrayFormulaCellData: IArrayFormulaUnitCellType, arrayFormulaRange: IArrayFormulaRangeType, rowData: IUnitRowData): Promise<IFormulaExecuteResultMap>;
|
|
24
|
+
getAllDependencyJson(): Promise<IFormulaDependencyTreeJson[]>;
|
|
25
|
+
getCellDependencyJson(unitId: string, sheetId: string, row: number, column: number): Promise<IFormulaDependencyTreeFullJson | undefined>;
|
|
22
26
|
}
|
|
23
27
|
export declare const ICalculateFormulaService: import('@wendellhu/redi').IdentifierDecorator<ICalculateFormulaService>;
|
|
24
28
|
export declare class CalculateFormulaService extends Disposable implements ICalculateFormulaService {
|
|
@@ -53,5 +57,8 @@ export declare class CalculateFormulaService extends Disposable implements ICalc
|
|
|
53
57
|
private _executeStep;
|
|
54
58
|
private _getArrayFormulaDirtyRangeAndExcludedRange;
|
|
55
59
|
protected _apply(isArrayFormulaState?: boolean): Promise<IAllRuntimeData | undefined>;
|
|
56
|
-
|
|
60
|
+
executeFormulas(formulas: IFormulaStringMap, formulaData: IFormulaData, arrayFormulaCellData: IArrayFormulaUnitCellType, arrayFormulaRange: IArrayFormulaRangeType, rowData?: IUnitRowData): Promise<IFormulaExecuteResultMap>;
|
|
61
|
+
calculate(formulaString: string): Promise<FunctionVariantType | undefined>;
|
|
62
|
+
getAllDependencyJson(): Promise<IFormulaDependencyTreeJson[]>;
|
|
63
|
+
getCellDependencyJson(unitId: string, sheetId: string, row: number, column: number): Promise<IFormulaDependencyTreeFullJson | undefined>;
|
|
57
64
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IUnitRange, LocaleType, Nullable, Disposable, IUniverInstanceService, LocaleService } from '@univerjs/core';
|
|
2
|
-
import { IArrayFormulaRangeType, IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefinedNameMap, IDirtyUnitSheetNameMap, IFormulaData, IFormulaDatasetConfig, IRuntimeUnitDataType, IUnitData, IUnitExcludedCell, IUnitRowData, IUnitSheetIdToNameMap, IUnitSheetNameMap, IUnitStylesData } from '../basics/common';
|
|
2
|
+
import { IArrayFormulaRangeType, IArrayFormulaUnitCellType, IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefinedNameMap, IDirtyUnitSheetNameMap, IFormulaData, IFormulaDatasetConfig, IRuntimeUnitDataType, IUnitData, IUnitExcludedCell, IUnitRowData, IUnitSheetIdToNameMap, IUnitSheetNameMap, IUnitStylesData } from '../basics/common';
|
|
3
3
|
import { FormulaDataModel } from '../models/formula-data.model';
|
|
4
4
|
import { ISheetRowFilteredService } from './sheet-row-filtered.service';
|
|
5
5
|
export interface IFormulaDirtyData {
|
|
@@ -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(formulaData: IFormulaData, arrayFormulaCellData: IArrayFormulaUnitCellType, arrayFormulaRange: IArrayFormulaRangeType, 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(formulaData: IFormulaData, arrayFormulaCellData: IArrayFormulaUnitCellType, arrayFormulaRange: IArrayFormulaRangeType, 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(a,u){typeof exports=="object"&&typeof module<"u"?u(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"],u):(a=typeof globalThis<"u"?globalThis:a||self,u(a.UniverEngineFormulaFacade={},a.UniverCoreFacade,a.UniverCore,a.UniverEngineFormula,a.rxjs))})(this,(function(a,u,c,n,l){"use strict";var f=Object.getOwnPropertyDescriptor,p=(s,e,t,i)=>{for(var r=i>1?void 0:i?f(e,t):e,o=s.length-1,m;o>=0;o--)(m=s[o])&&(r=m(r)||r);return r},d=(s,e)=>(t,i)=>e(t,i,s);a.FFormula=class extends u.FBase{constructor(e,t,i,r){super(),this._commandService=e,this._injector=t,this._lexerTreeBuilder=i,this._configService=r,this._initialize()}_initialize(){}get lexerTreeBuilder(){return this._lexerTreeBuilder}moveFormulaRefOffset(e,t,i,r){return this._lexerTreeBuilder.moveFormulaRefOffset(e,t,i,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(t=>{if(t.id===n.SetFormulaCalculationStartMutation.id){const i=t.params;e(i.forceCalculation)}})}calculationEnd(e){return this._commandService.onCommandExecuted(t=>{if(t.id!==n.SetFormulaCalculationNotificationMutation.id)return;const i=t.params;i.functionsExecutedState!==void 0&&e(i.functionsExecutedState)})}whenComputingCompleteAsync(e){const t=this._injector.get(n.GlobalComputingStatusService);return t.computingStatus?Promise.resolve(!0):l.firstValueFrom(l.race(t.computingStatus$.pipe(l.filter(i=>i)),l.timer(e!=null?e:3e4).pipe(l.map(()=>!1))))}onCalculationEnd(){return new Promise((e,t)=>{const i=setTimeout(()=>{t(new Error("Calculation end timeout"))},3e4),r=this.calculationEnd(()=>{clearTimeout(i),r.dispose(),e()})})}calculationProcessing(e){return this._commandService.onCommandExecuted(t=>{if(t.id!==n.SetFormulaCalculationNotificationMutation.id)return;const i=t.params;i.stageInfo!==void 0&&e(i.stageInfo)})}setMaxIteration(e){this._configService.setConfig(n.ENGINE_FORMULA_CYCLE_REFERENCE_COUNT,e)}executeFormulas(e,t){this._commandService.executeCommand(n.SetFormulaStringBatchCalculationMutation.id,{formulas:e},{onlyLocal:!0});const i=this._commandService.onCommandExecuted(r=>{if(r.id!==n.SetFormulaStringBatchCalculationResultMutation.id)return;const o=r.params;o.result!=null&&t(o.result),i.dispose()})}getAllDependencyTrees(e){this._commandService.executeCommand(n.SetFormulaDependencyCalculationMutation.id,void 0,{onlyLocal:!0});const t=this._commandService.onCommandExecuted(i=>{if(i.id!==n.SetFormulaDependencyCalculationResultMutation.id)return;const r=i.params;r.result!=null&&e(r.result),t.dispose()})}getCellDependencyTree(e,t){this._commandService.executeCommand(n.SetCellFormulaDependencyCalculationMutation.id,e,{onlyLocal:!0});const i=this._commandService.onCommandExecuted(r=>{if(r.id!==n.SetCellFormulaDependencyCalculationResultMutation.id)return;const o=r.params;o.result!==void 0&&t(o.result),i.dispose()})}},a.FFormula=p([d(0,c.Inject(c.ICommandService)),d(1,c.Inject(c.Injector)),d(2,c.Inject(n.LexerTreeBuilder)),d(3,c.IConfigService)],a.FFormula);class v extends u.FUniver{getFormula(){return this._injector.createInstance(a.FFormula)}}u.FUniver.extend(v),Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
|