@univerjs/engine-formula 0.13.0-insiders.20251218-2062647 → 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.
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +36 -218
- package/lib/es/index.js +3151 -3382
- package/lib/facade.js +36 -218
- package/lib/index.js +3151 -3382
- package/lib/types/basics/common.d.ts +0 -8
- package/lib/types/basics/match-token.d.ts +1 -1
- package/lib/types/commands/mutations/set-formula-calculation.mutation.d.ts +1 -10
- package/lib/types/controller/calculate.controller.d.ts +0 -1
- package/lib/types/controller/config.schema.d.ts +0 -1
- package/lib/types/engine/analysis/lexer-tree-builder.d.ts +1 -2
- package/lib/types/engine/ast-node/reference-node.d.ts +1 -0
- package/lib/types/engine/dependency/dependency-tree.d.ts +1 -11
- package/lib/types/engine/dependency/formula-dependency.d.ts +3 -8
- package/lib/types/engine/utils/reference.d.ts +0 -9
- package/lib/types/engine/utils/sequence.d.ts +1 -2
- package/lib/types/facade/f-formula.d.ts +2 -164
- package/lib/types/index.d.ts +5 -9
- package/lib/types/services/active-dirty-manager.service.d.ts +0 -1
- package/lib/types/services/calculate-formula.service.d.ts +1 -4
- package/lib/types/services/current-data.service.d.ts +0 -1
- package/lib/types/services/defined-names.service.d.ts +0 -1
- package/lib/types/services/runtime.service.d.ts +0 -7
- package/lib/types/services/super-table.service.d.ts +0 -4
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +3 -3
- package/lib/types/commands/mutations/formula.mutation.d.ts +0 -9
- package/lib/types/services/formula-common.d.ts +0 -18
- package/lib/types/services/register-other-formula.service.d.ts +0 -40
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ICellData, IColumnData, IObjectArrayPrimitiveType, IObjectMatrixPrimitiveType, IRange, IRowData, IUnitRange, Nullable, ObjectMatrix, Styles } from '@univerjs/core';
|
|
2
|
-
import { sequenceNodeType } from '../engine/utils/sequence';
|
|
3
2
|
import { IImageFormulaInfo } from '../engine/value-object/primitive-object';
|
|
4
3
|
export declare const ERROR_VALUE_OBJECT_CLASS_TYPE = "errorValueObject";
|
|
5
4
|
export declare const ASYNC_OBJECT_CLASS_TYPE = "asyncObject";
|
|
@@ -207,16 +206,9 @@ export interface IFormulaDatasetConfig {
|
|
|
207
206
|
unitStylesData?: IUnitStylesData;
|
|
208
207
|
unitSheetNameMap?: IUnitSheetNameMap;
|
|
209
208
|
maxIteration?: number;
|
|
210
|
-
isCalculateTreeModel?: boolean;
|
|
211
209
|
rowData?: IUnitRowData;
|
|
212
210
|
}
|
|
213
211
|
export declare enum ConcatenateType {
|
|
214
212
|
FRONT = 0,
|
|
215
213
|
BACK = 1
|
|
216
214
|
}
|
|
217
|
-
export interface IExprTreeNode {
|
|
218
|
-
value: string;
|
|
219
|
-
children: IExprTreeNode[];
|
|
220
|
-
startIndex: number;
|
|
221
|
-
type?: sequenceNodeType;
|
|
222
|
-
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { compareToken, matchToken, operatorToken, prefixToken, suffixToken } from './token';
|
|
2
|
-
export declare const FORMULA_LEXER_TOKENS: (operatorToken | suffixToken | compareToken |
|
|
2
|
+
export declare const FORMULA_LEXER_TOKENS: (operatorToken | suffixToken | compareToken | matchToken | prefixToken)[];
|
|
3
3
|
export declare function isFormulaLexerToken(str: string): boolean;
|
|
4
4
|
export declare function includeFormulaLexerToken(str: string): boolean;
|
|
5
5
|
export declare function normalizeSheetName(sheetName: string): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IExecutionOptions, IMutation, IUnitRange, Nullable } from '@univerjs/core';
|
|
2
2
|
import { IFormulaExecuteResultMap, IFormulaStringMap, IRuntimeOtherUnitDataType, IRuntimeUnitDataPrimitiveType } from '../../basics/common';
|
|
3
|
-
import { IFormulaDependencyTreeFullJson, IFormulaDependencyTreeJson
|
|
3
|
+
import { IFormulaDependencyTreeFullJson, IFormulaDependencyTreeJson } from '../../engine/dependency/dependency-tree';
|
|
4
4
|
import { IFormulaDirtyData } from '../../services/current-data.service';
|
|
5
5
|
import { FormulaExecutedStateType, IExecutionInProgressParams } from '../../services/runtime.service';
|
|
6
6
|
export interface ISetFormulaCalculationStartMutation extends IFormulaDirtyData {
|
|
@@ -34,18 +34,11 @@ export interface ISetQueryFormulaDependencyMutation {
|
|
|
34
34
|
export interface ISetQueryFormulaDependencyResultMutation {
|
|
35
35
|
result: IFormulaDependencyTreeJson[];
|
|
36
36
|
}
|
|
37
|
-
export interface ISetQueryFormulaDependencyAllMutation {
|
|
38
|
-
unitRanges: IUnitRange[];
|
|
39
|
-
}
|
|
40
|
-
export interface ISetQueryFormulaDependencyAllResultMutation {
|
|
41
|
-
result: IFormulaDependentsAndInRangeResults;
|
|
42
|
-
}
|
|
43
37
|
/**
|
|
44
38
|
* TODO: @DR-Univer
|
|
45
39
|
* Trigger the calculation of the formula and stop the formula
|
|
46
40
|
*/
|
|
47
41
|
export declare const SetFormulaCalculationStartMutation: IMutation<ISetFormulaCalculationStartMutation>;
|
|
48
|
-
export declare const SetTriggerFormulaCalculationStartMutation: IMutation<ISetFormulaCalculationStartMutation>;
|
|
49
42
|
export declare const SetFormulaStringBatchCalculationMutation: IMutation<ISetFormulaStringBatchCalculationMutation>;
|
|
50
43
|
export declare const SetFormulaStringBatchCalculationResultMutation: IMutation<ISetFormulaStringBatchCalculationResultMutation>;
|
|
51
44
|
export interface ISetFormulaCalculationStopMutation {
|
|
@@ -67,5 +60,3 @@ export declare const SetCellFormulaDependencyCalculationMutation: IMutation<ISet
|
|
|
67
60
|
export declare const SetCellFormulaDependencyCalculationResultMutation: IMutation<ISetCellFormulaDependencyCalculationResultMutation>;
|
|
68
61
|
export declare const SetQueryFormulaDependencyMutation: IMutation<ISetQueryFormulaDependencyMutation>;
|
|
69
62
|
export declare const SetQueryFormulaDependencyResultMutation: IMutation<ISetQueryFormulaDependencyResultMutation>;
|
|
70
|
-
export declare const SetQueryFormulaDependencyAllMutation: IMutation<ISetQueryFormulaDependencyAllMutation>;
|
|
71
|
-
export declare const SetQueryFormulaDependencyAllResultMutation: IMutation<ISetQueryFormulaDependencyAllResultMutation>;
|
|
@@ -10,7 +10,6 @@ export declare class CalculateController extends Disposable {
|
|
|
10
10
|
private _commandExecutedListener;
|
|
11
11
|
private _calculate;
|
|
12
12
|
private _queryFormulaDependencyJson;
|
|
13
|
-
private _queryFormulaDependencyAllJson;
|
|
14
13
|
private _generateAllDependencyTreeJson;
|
|
15
14
|
private _generateCellDependencyTreeJson;
|
|
16
15
|
private _calculateFormulaString;
|
|
@@ -4,7 +4,6 @@ import { BaseFunction } from '../functions/base-function';
|
|
|
4
4
|
export declare const ENGINE_FORMULA_PLUGIN_CONFIG_KEY = "engine-formula.config";
|
|
5
5
|
export declare const DEFAULT_CYCLE_REFERENCE_COUNT = 1;
|
|
6
6
|
export declare const ENGINE_FORMULA_CYCLE_REFERENCE_COUNT = "CYCLE_REFERENCE_COUNT";
|
|
7
|
-
export declare const ENGINE_FORMULA_RETURN_DEPENDENCY_TREE = "RETURN_DEPENDENCY_TREE";
|
|
8
7
|
export declare const configSymbol: unique symbol;
|
|
9
8
|
export interface IUniverEngineFormulaConfig {
|
|
10
9
|
notExecuteFormula?: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Nullable, AbsoluteRefType, Disposable } from '@univerjs/core';
|
|
2
|
-
import { IDirtyUnitSheetDefinedNameMap
|
|
2
|
+
import { IDirtyUnitSheetDefinedNameMap } from '../../basics/common';
|
|
3
3
|
import { IFunctionNames } from '../../basics/function';
|
|
4
4
|
import { IDefinedNamesServiceParam } from '../../services/defined-names.service';
|
|
5
5
|
import { ISequenceArray, ISequenceNode } from '../utils/sequence';
|
|
@@ -145,6 +145,5 @@ export declare class LexerTreeBuilder extends Disposable {
|
|
|
145
145
|
private _isScientificNotation;
|
|
146
146
|
private _addSequenceArray;
|
|
147
147
|
getNewFormulaWithPrefix(formulaString: string, hasFunction: (functionToken: IFunctionNames) => boolean): string | null;
|
|
148
|
-
getFormulaExprTree(formulaString: string, unitId: string, hasFunction: (functionToken: IFunctionNames) => boolean, getDefinedNameName: (unitId: string, name: string) => Nullable<IDefinedNamesServiceParam>, getTable: (unitId: string, tableName: string) => Nullable<ISuperTable>): IExprTreeNode | null;
|
|
149
148
|
}
|
|
150
149
|
export {};
|
|
@@ -36,6 +36,7 @@ export declare class ReferenceNodeFactory extends BaseAstNodeFactory {
|
|
|
36
36
|
private _getTableMap;
|
|
37
37
|
private _getNode;
|
|
38
38
|
private _getTableReferenceNode;
|
|
39
|
+
private _splitTableStructuredRef;
|
|
39
40
|
private _checkTokenIsTableReference;
|
|
40
41
|
private _checkParentIsUnionOperator;
|
|
41
42
|
}
|
|
@@ -15,7 +15,6 @@ export declare enum FormulaDependencyTreeType {
|
|
|
15
15
|
}
|
|
16
16
|
declare class FormulaDependencyTreeCalculator {
|
|
17
17
|
private _state;
|
|
18
|
-
type: FormulaDependencyTreeType;
|
|
19
18
|
resetState(): void;
|
|
20
19
|
setAdded(): void;
|
|
21
20
|
isAdded(): boolean;
|
|
@@ -78,6 +77,7 @@ export declare class FormulaDependencyTree extends FormulaDependencyTreeCalculat
|
|
|
78
77
|
featureDirtyRanges: IUnitRange[];
|
|
79
78
|
refOffsetX: number;
|
|
80
79
|
refOffsetY: number;
|
|
80
|
+
type: FormulaDependencyTreeType;
|
|
81
81
|
formulaId: Nullable<string>;
|
|
82
82
|
subUnitId: string;
|
|
83
83
|
unitId: string;
|
|
@@ -126,9 +126,6 @@ interface IFormulaDependencyTreeJsonBase {
|
|
|
126
126
|
refOffsetY: number;
|
|
127
127
|
rangeList: IUnitRange[];
|
|
128
128
|
refTreeId: number | undefined;
|
|
129
|
-
formulaId: Nullable<string>;
|
|
130
|
-
featureId: Nullable<string>;
|
|
131
|
-
type: Nullable<FormulaDependencyTreeType>;
|
|
132
129
|
}
|
|
133
130
|
export interface IFormulaDependencyTreeJson extends IFormulaDependencyTreeJsonBase {
|
|
134
131
|
children: number[];
|
|
@@ -138,10 +135,6 @@ export interface IFormulaDependencyTreeFullJson extends IFormulaDependencyTreeJs
|
|
|
138
135
|
children: IFormulaDependencyTreeJson[];
|
|
139
136
|
parents: IFormulaDependencyTreeJson[];
|
|
140
137
|
}
|
|
141
|
-
export interface IFormulaDependentsAndInRangeResults {
|
|
142
|
-
dependents: IFormulaDependencyTreeJson[];
|
|
143
|
-
inRanges: IFormulaDependencyTreeJson[];
|
|
144
|
-
}
|
|
145
138
|
export declare class FormulaDependencyTreeModel {
|
|
146
139
|
children: Set<FormulaDependencyTreeModel>;
|
|
147
140
|
parents: Set<FormulaDependencyTreeModel>;
|
|
@@ -155,9 +148,6 @@ export declare class FormulaDependencyTreeModel {
|
|
|
155
148
|
subUnitId: string;
|
|
156
149
|
rangeList: IUnitRange[];
|
|
157
150
|
refTreeId: number | undefined;
|
|
158
|
-
formulaId: Nullable<string>;
|
|
159
|
-
featureId: Nullable<string>;
|
|
160
|
-
type: Nullable<FormulaDependencyTreeType>;
|
|
161
151
|
constructor(tree: IFormulaDependencyTree);
|
|
162
152
|
toJson(): IFormulaDependencyTreeJson;
|
|
163
153
|
toFullJson(): IFormulaDependencyTreeFullJson;
|
|
@@ -4,7 +4,7 @@ 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, IFormulaDependencyTreeFullJson, IFormulaDependencyTreeJson,
|
|
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';
|
|
@@ -15,12 +15,11 @@ import { AstTreeBuilder } from '../analysis/parser';
|
|
|
15
15
|
import { Interpreter } from '../interpreter/interpreter';
|
|
16
16
|
export declare function generateRandomDependencyTreeId(dependencyManagerService: IDependencyManagerService): number;
|
|
17
17
|
export interface IFormulaDependencyGenerator {
|
|
18
|
-
generate(
|
|
18
|
+
generate(): Promise<IFormulaDependencyTree[]>;
|
|
19
19
|
getAllDependencyJson(): Promise<IFormulaDependencyTreeJson[]>;
|
|
20
20
|
getCellDependencyJson(unitId: string, sheetId: string, row: number, column: number): Promise<IFormulaDependencyTreeFullJson | undefined>;
|
|
21
21
|
getRangeDependents(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
22
22
|
getInRangeFormulas(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
23
|
-
getRangeDependentsAndInRangeFormulas(unitRanges: IUnitRange[]): Promise<IFormulaDependentsAndInRangeResults>;
|
|
24
23
|
}
|
|
25
24
|
export declare const IFormulaDependencyGenerator: import('@wendellhu/redi').IdentifierDecorator<IFormulaDependencyGenerator>;
|
|
26
25
|
export declare class FormulaDependencyGenerator extends Disposable {
|
|
@@ -37,7 +36,7 @@ export declare class FormulaDependencyGenerator extends Disposable {
|
|
|
37
36
|
protected _dependencyRTreeCacheForAddressFunction: RTree;
|
|
38
37
|
constructor(_currentConfigService: IFormulaCurrentConfigService, _runtimeService: IFormulaRuntimeService, _otherFormulaManagerService: IOtherFormulaManagerService, _featureCalculationManagerService: IFeatureCalculationManagerService, _interpreter: Interpreter, _astTreeBuilder: AstTreeBuilder, _lexer: Lexer, _dependencyManagerService: IDependencyManagerService, _lexerTreeBuilder: LexerTreeBuilder);
|
|
39
38
|
dispose(): void;
|
|
40
|
-
generate(
|
|
39
|
+
generate(): Promise<(FormulaDependencyTree | FormulaDependencyTreeVirtual)[]>;
|
|
41
40
|
private _dependencyFeatureCalculation;
|
|
42
41
|
private _clearFeatureCalculationNode;
|
|
43
42
|
/**
|
|
@@ -126,13 +125,9 @@ export declare class FormulaDependencyGenerator extends Disposable {
|
|
|
126
125
|
protected _getFormulaDependencyTreeModel(tree: IFormulaDependencyTree): FormulaDependencyTreeModel;
|
|
127
126
|
protected _endFormulaDependencyTreeModel(): void;
|
|
128
127
|
protected _startFormulaDependencyTreeModel(): void;
|
|
129
|
-
protected _getAllDependencyJson(treeList: IFormulaDependencyTree[]): IFormulaDependencyTreeJson[];
|
|
130
128
|
getAllDependencyJson(): Promise<IFormulaDependencyTreeJson[]>;
|
|
131
129
|
protected _setRealFormulaString(treeModel: FormulaDependencyTreeModel): void;
|
|
132
130
|
getCellDependencyJson(unitId: string, sheetId: string, row: number, column: number): Promise<IFormulaDependencyTreeFullJson | undefined>;
|
|
133
|
-
protected _getRangeDependents(unitRanges: IUnitRange[]): IFormulaDependencyTreeJson[];
|
|
134
131
|
getRangeDependents(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
135
|
-
protected _getInRangeFormulas(unitRanges: IUnitRange[], treeList: IFormulaDependencyTree[]): IFormulaDependencyTreeJson[];
|
|
136
132
|
getInRangeFormulas(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
137
|
-
getRangeDependentsAndInRangeFormulas(unitRanges: IUnitRange[]): Promise<IFormulaDependentsAndInRangeResults>;
|
|
138
133
|
}
|
|
@@ -85,12 +85,3 @@ export declare function quoteSheetName(name: string): string;
|
|
|
85
85
|
* @returns Unquoted name
|
|
86
86
|
*/
|
|
87
87
|
export declare function unquoteSheetName(name: string): string;
|
|
88
|
-
export declare function splitTableStructuredRef(ref: string): {
|
|
89
|
-
tableName: string;
|
|
90
|
-
struct: string;
|
|
91
|
-
columnStruct?: undefined;
|
|
92
|
-
} | {
|
|
93
|
-
tableName: string;
|
|
94
|
-
columnStruct: string;
|
|
95
|
-
struct?: undefined;
|
|
96
|
-
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IDisposable, IUnitRange, ICommandService, IConfigService, Injector } from '@univerjs/core';
|
|
2
|
-
import { FormulaExecutedStateType, IExecutionInProgressParams,
|
|
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.
|
|
@@ -10,10 +10,7 @@ export declare class FFormula extends FBase {
|
|
|
10
10
|
protected readonly _injector: Injector;
|
|
11
11
|
private _lexerTreeBuilder;
|
|
12
12
|
protected readonly _configService: IConfigService;
|
|
13
|
-
|
|
14
|
-
private readonly _definedNamesService;
|
|
15
|
-
private readonly _superTableService;
|
|
16
|
-
constructor(_commandService: ICommandService, _injector: Injector, _lexerTreeBuilder: LexerTreeBuilder, _configService: IConfigService, _functionService: IFunctionService, _definedNamesService: IDefinedNamesService, _superTableService: ISuperTableService);
|
|
13
|
+
constructor(_commandService: ICommandService, _injector: Injector, _lexerTreeBuilder: LexerTreeBuilder, _configService: IConfigService);
|
|
17
14
|
/**
|
|
18
15
|
* @ignore
|
|
19
16
|
*/
|
|
@@ -402,163 +399,4 @@ export declare class FFormula extends FBase {
|
|
|
402
399
|
* ```
|
|
403
400
|
*/
|
|
404
401
|
getInRangeFormulas(unitRanges: IUnitRange[], timeout?: number): Promise<IFormulaDependencyTreeJson[]>;
|
|
405
|
-
/**
|
|
406
|
-
* Enable or disable emitting formula dependency trees after each formula calculation.
|
|
407
|
-
*
|
|
408
|
-
* When enabled, the formula engine will emit the dependency trees produced by
|
|
409
|
-
* each completed formula calculation through the internal command system.
|
|
410
|
-
* Consumers can obtain the result by listening for the corresponding
|
|
411
|
-
* calculation-result command.
|
|
412
|
-
*
|
|
413
|
-
* When disabled, dependency trees will not be emitted.
|
|
414
|
-
*
|
|
415
|
-
* This option only controls whether dependency trees are exposed.
|
|
416
|
-
* It does not affect formula calculation behavior.
|
|
417
|
-
*
|
|
418
|
-
* @param {boolean} value
|
|
419
|
-
* Whether to emit formula dependency trees after calculation.
|
|
420
|
-
* - `true`: Emit dependency trees after each calculation.
|
|
421
|
-
* - `false`: Do not emit dependency trees (default behavior).
|
|
422
|
-
*
|
|
423
|
-
* @example
|
|
424
|
-
* ```ts
|
|
425
|
-
* const formulaEngine = univerAPI.getFormula();
|
|
426
|
-
*
|
|
427
|
-
* // Enable dependency tree emission
|
|
428
|
-
* formulaEngine.setFormulaReturnDependencyTree(true);
|
|
429
|
-
*
|
|
430
|
-
* // Listen for dependency trees produced by formula calculation
|
|
431
|
-
* const trees = await new Promise<IFormulaDependencyTreeJson[]>((resolve, reject) => {
|
|
432
|
-
* const timer = setTimeout(() => {
|
|
433
|
-
* disposable.dispose();
|
|
434
|
-
* reject(new Error('Timeout waiting for formula dependency trees'));
|
|
435
|
-
* }, 30_000);
|
|
436
|
-
*
|
|
437
|
-
* const disposable = commandService.onCommandExecuted((command) => {
|
|
438
|
-
* if (command.id !== SetFormulaDependencyCalculationResultMutation.id) {
|
|
439
|
-
* return;
|
|
440
|
-
* }
|
|
441
|
-
*
|
|
442
|
-
* clearTimeout(timer);
|
|
443
|
-
* disposable.dispose();
|
|
444
|
-
*
|
|
445
|
-
* const params = command.params as ISetFormulaDependencyCalculationResultMutation;
|
|
446
|
-
* resolve(params.result ?? []);
|
|
447
|
-
* });
|
|
448
|
-
* });
|
|
449
|
-
*
|
|
450
|
-
* console.log('Dependency trees:', trees);
|
|
451
|
-
* ```
|
|
452
|
-
*/
|
|
453
|
-
setFormulaReturnDependencyTree(value: boolean): void;
|
|
454
|
-
/**
|
|
455
|
-
* Parse a formula string and return its **formula expression tree**.
|
|
456
|
-
*
|
|
457
|
-
* This API analyzes the syntactic structure of a formula and builds an
|
|
458
|
-
* expression tree that reflects how the formula is composed (functions,
|
|
459
|
-
* operators, ranges, and nested expressions), without performing calculation
|
|
460
|
-
* or dependency evaluation.
|
|
461
|
-
*
|
|
462
|
-
* The returned tree is suitable for:
|
|
463
|
-
* - Formula structure visualization
|
|
464
|
-
* - Explaining complex formulas (e.g. LET / LAMBDA)
|
|
465
|
-
* - Debugging or inspecting formula composition
|
|
466
|
-
* - Building advanced formula tooling
|
|
467
|
-
*
|
|
468
|
-
* ---
|
|
469
|
-
*
|
|
470
|
-
* @example
|
|
471
|
-
* ```ts
|
|
472
|
-
* const formulaEngine = univerAPI.getFormula();
|
|
473
|
-
*
|
|
474
|
-
* const formula = '=LET(x,SUM(A1,B1,A1:B10),y,OFFSET(A1:B10,0,1),SUM(x,y)+x)+1';
|
|
475
|
-
*
|
|
476
|
-
* const exprTree = formulaEngine.getFormulaExpressTree(formula);
|
|
477
|
-
*
|
|
478
|
-
* console.log(exprTree);
|
|
479
|
-
* ```
|
|
480
|
-
*
|
|
481
|
-
* Example output (simplified):
|
|
482
|
-
*
|
|
483
|
-
* ```json
|
|
484
|
-
* {
|
|
485
|
-
* "value": "let(x,sum(A1,B1,A1:B10),y,offset(A1:B10,0,1),sum(x,y)+x)+1",
|
|
486
|
-
* "children": [
|
|
487
|
-
* {
|
|
488
|
-
* "value": "let(x,sum(A1,B1,A1:B10),y,offset(A1:B10,0,1),sum(x,y)+x)",
|
|
489
|
-
* "children": [
|
|
490
|
-
* {
|
|
491
|
-
* "value": "sum(A1,B1,A1:B10)",
|
|
492
|
-
* "children": [
|
|
493
|
-
* {
|
|
494
|
-
* "value": "A1:B10",
|
|
495
|
-
* "children": []
|
|
496
|
-
* }
|
|
497
|
-
* ]
|
|
498
|
-
* },
|
|
499
|
-
* {
|
|
500
|
-
* "value": "offset(A1:B10,0,1)",
|
|
501
|
-
* "children": [
|
|
502
|
-
* {
|
|
503
|
-
* "value": "A1:B10",
|
|
504
|
-
* "children": []
|
|
505
|
-
* }
|
|
506
|
-
* ]
|
|
507
|
-
* }
|
|
508
|
-
* ]
|
|
509
|
-
* }
|
|
510
|
-
* ]
|
|
511
|
-
* }
|
|
512
|
-
* ```
|
|
513
|
-
*
|
|
514
|
-
* @param formulaString The formula string to parse (with or without leading `=`)
|
|
515
|
-
* @returns A formula expression tree describing the hierarchical structure of the formula
|
|
516
|
-
*/
|
|
517
|
-
getFormulaExpressTree(formulaString: string, unitId: string): IExprTreeNode | null;
|
|
518
|
-
/**
|
|
519
|
-
* Retrieve **both**:
|
|
520
|
-
* 1) the full dependency trees of all formulas that **depend on** the specified ranges, and
|
|
521
|
-
* 2) the dependency trees of all formulas that **physically reside inside** the specified ranges.
|
|
522
|
-
*
|
|
523
|
-
* This is a convenience API that combines the behaviors of
|
|
524
|
-
* `getRangeDependents` and `getInRangeFormulas` into a single call.
|
|
525
|
-
*
|
|
526
|
-
* Internally, it triggers a local dependency-calculation command once and
|
|
527
|
-
* resolves when both result sets are available, avoiding duplicate
|
|
528
|
-
* calculations and event listeners.
|
|
529
|
-
*
|
|
530
|
-
* @param unitRanges An array of workbook/sheet ranges to query. Each range
|
|
531
|
-
* includes:
|
|
532
|
-
* - `unitId` The workbook ID.
|
|
533
|
-
* - `sheetId` The sheet ID.
|
|
534
|
-
* - `range` The zero-based row/column boundaries.
|
|
535
|
-
*
|
|
536
|
-
* @param {number} [timeout]
|
|
537
|
-
* Optional timeout in milliseconds. If the dependency calculation does
|
|
538
|
-
* not complete within this period, the promise will be rejected.
|
|
539
|
-
*
|
|
540
|
-
* @returns {Promise<IFormulaDependentsAndInRangeResults>}
|
|
541
|
-
* A promise that resolves with an object containing:
|
|
542
|
-
* - `dependents`: Dependency trees of all formulas that depend on the
|
|
543
|
-
* specified ranges (upstream consumers).
|
|
544
|
-
* - `inRanges`: Dependency trees of all formulas whose definitions
|
|
545
|
-
* are located inside the specified ranges.
|
|
546
|
-
*
|
|
547
|
-
* @example
|
|
548
|
-
* ```ts
|
|
549
|
-
* const formulaEngine = univerAPI.getFormula();
|
|
550
|
-
*
|
|
551
|
-
* const result = await formulaEngine.getRangeDependentsAndInRangeFormulas([
|
|
552
|
-
* {
|
|
553
|
-
* unitId: 'workbook1',
|
|
554
|
-
* sheetId: 'sheet1',
|
|
555
|
-
* range: { startRow: 0, endRow: 9, startColumn: 0, endColumn: 1 },
|
|
556
|
-
* },
|
|
557
|
-
* ]);
|
|
558
|
-
*
|
|
559
|
-
* console.log('Dependent formulas:', result.dependents);
|
|
560
|
-
* console.log('Formulas inside range:', result.inRanges);
|
|
561
|
-
* ```
|
|
562
|
-
*/
|
|
563
|
-
getRangeDependentsAndInRangeFormulas(unitRanges: IUnitRange[], timeout?: number): Promise<IFormulaDependentsAndInRangeResults>;
|
|
564
402
|
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
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
|
-
export
|
|
19
|
+
export { type IUnitRowData } from './basics/common';
|
|
20
20
|
export { isInDirtyRange } from './basics/dirty';
|
|
21
21
|
export { ERROR_TYPE_SET, ErrorType } from './basics/error-type';
|
|
22
22
|
export { type ISheetFormulaError } from './basics/error-type';
|
|
@@ -28,20 +28,19 @@ export { isReferenceString } from './basics/regex';
|
|
|
28
28
|
export { convertUnitDataToRuntime } from './basics/runtime';
|
|
29
29
|
export { compareToken, matchToken, OPERATOR_TOKEN_SET, operatorToken, prefixToken, SUFFIX_TOKEN_SET } from './basics/token';
|
|
30
30
|
export { DEFAULT_TOKEN_LAMBDA_FUNCTION_NAME, DEFAULT_TOKEN_LET_FUNCTION_NAME, DEFAULT_TOKEN_TYPE_LAMBDA_PARAMETER, DEFAULT_TOKEN_TYPE_PARAMETER, DEFAULT_TOKEN_TYPE_ROOT } from './basics/token-type';
|
|
31
|
-
export { OtherFormulaMarkDirty } from './commands/mutations/formula.mutation';
|
|
32
31
|
export { RegisterFunctionMutation } from './commands/mutations/register-function.mutation';
|
|
33
32
|
export { type ISetArrayFormulaDataMutationParams, SetArrayFormulaDataMutation } from './commands/mutations/set-array-formula-data.mutation';
|
|
34
33
|
export { type ISetDefinedNameMutationParam, type ISetDefinedNameMutationSearchParam, RemoveDefinedNameMutation, SetDefinedNameMutation } from './commands/mutations/set-defined-name.mutation';
|
|
35
34
|
export { SetDefinedNameMutationFactory } from './commands/mutations/set-defined-name.mutation';
|
|
36
35
|
export { RemoveFeatureCalculationMutation, SetFeatureCalculationMutation } from './commands/mutations/set-feature-calculation.mutation';
|
|
37
|
-
export { type ISetCellFormulaDependencyCalculationResultMutation, type ISetFormulaCalculationNotificationMutation, type ISetFormulaCalculationResultMutation, type ISetFormulaCalculationStartMutation, type ISetFormulaDependencyCalculationMutation, type ISetFormulaDependencyCalculationResultMutation, type ISetFormulaStringBatchCalculationResultMutation, type
|
|
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';
|
|
38
37
|
export { type ISetFormulaDataMutationParams, SetFormulaDataMutation } from './commands/mutations/set-formula-data.mutation';
|
|
39
38
|
export { type ISetImageFormulaDataMutationParams, SetImageFormulaDataMutation } from './commands/mutations/set-image-formula-data.mutation';
|
|
40
39
|
export { type IRemoveOtherFormulaMutationParams, type ISetOtherFormulaMutationParams, RemoveOtherFormulaMutation, SetOtherFormulaMutation } from './commands/mutations/set-other-formula.mutation';
|
|
41
40
|
export { RemoveSuperTableMutation, SetSuperTableMutation, SetSuperTableOptionMutation } from './commands/mutations/set-super-table.mutation';
|
|
42
41
|
export type { ISetSuperTableMutationParam, ISetSuperTableMutationSearchParam } from './commands/mutations/set-super-table.mutation';
|
|
43
42
|
export { CalculateController } from './controller/calculate.controller';
|
|
44
|
-
export { ENGINE_FORMULA_CYCLE_REFERENCE_COUNT, ENGINE_FORMULA_PLUGIN_CONFIG_KEY,
|
|
43
|
+
export { ENGINE_FORMULA_CYCLE_REFERENCE_COUNT, ENGINE_FORMULA_PLUGIN_CONFIG_KEY, type IUniverEngineFormulaConfig } from './controller/config.schema';
|
|
45
44
|
export { Lexer } from './engine/analysis/lexer';
|
|
46
45
|
export { LexerNode } from './engine/analysis/lexer-node';
|
|
47
46
|
export { LexerTreeBuilder } from './engine/analysis/lexer-tree-builder';
|
|
@@ -57,7 +56,7 @@ export { ReferenceNodeFactory } from './engine/ast-node/reference-node';
|
|
|
57
56
|
export { SuffixNodeFactory } from './engine/ast-node/suffix-node';
|
|
58
57
|
export { UnionNodeFactory } from './engine/ast-node/union-node';
|
|
59
58
|
export { ValueNodeFactory } from './engine/ast-node/value-node';
|
|
60
|
-
export { FormulaDependencyTree, FormulaDependencyTreeModel, type IFormulaDependencyTree, type IFormulaDependencyTreeFullJson, type IFormulaDependencyTreeJson
|
|
59
|
+
export { FormulaDependencyTree, FormulaDependencyTreeModel, type IFormulaDependencyTree, type IFormulaDependencyTreeFullJson, type IFormulaDependencyTreeJson } from './engine/dependency/dependency-tree';
|
|
61
60
|
export { FormulaDependencyTreeType } from './engine/dependency/dependency-tree';
|
|
62
61
|
export { FormulaDependencyTreeVirtual } from './engine/dependency/dependency-tree';
|
|
63
62
|
export { FormulaDependencyGenerator, IFormulaDependencyGenerator } from './engine/dependency/formula-dependency';
|
|
@@ -72,7 +71,7 @@ export { generateAstNode } from './engine/utils/generate-ast-node';
|
|
|
72
71
|
export { strip, stripErrorMargin } from './engine/utils/math-kit';
|
|
73
72
|
export { handleNumfmtInCell } from './engine/utils/numfmt-kit';
|
|
74
73
|
export { deserializeRangeForR1C1 } from './engine/utils/r1c1-reference';
|
|
75
|
-
export { deserializeRangeWithSheet, getAbsoluteRefTypeWithSingleString, getAbsoluteRefTypeWitString, getRangeWithRefsString, type IAbsoluteRefTypeForRange, isReferenceStrings, isReferenceStringWithEffectiveColumn, needsQuoting, quoteSheetName, serializeRange, serializeRangeToRefString, serializeRangeWithSheet, serializeRangeWithSpreadsheet, singleReferenceToGrid,
|
|
74
|
+
export { deserializeRangeWithSheet, getAbsoluteRefTypeWithSingleString, getAbsoluteRefTypeWitString, getRangeWithRefsString, type IAbsoluteRefTypeForRange, isReferenceStrings, isReferenceStringWithEffectiveColumn, needsQuoting, quoteSheetName, serializeRange, serializeRangeToRefString, serializeRangeWithSheet, serializeRangeWithSpreadsheet, singleReferenceToGrid, unquoteSheetName, } from './engine/utils/reference';
|
|
76
75
|
export { handleRefStringInfo } from './engine/utils/reference';
|
|
77
76
|
export { deserializeRangeWithSheetWithCache } from './engine/utils/reference-cache';
|
|
78
77
|
export { generateStringWithSequence, type ISequenceNode, sequenceNodeType } from './engine/utils/sequence';
|
|
@@ -130,14 +129,11 @@ export { DependencyManagerService } from './services/dependency-manager.service'
|
|
|
130
129
|
export { DependencyManagerBaseService } from './services/dependency-manager.service';
|
|
131
130
|
export { FeatureCalculationManagerService, IFeatureCalculationManagerService } from './services/feature-calculation-manager.service';
|
|
132
131
|
export type { IFeatureCalculationManagerParam } from './services/feature-calculation-manager.service';
|
|
133
|
-
export type { IFormulaInfo, IOtherFormulaResult } from './services/formula-common';
|
|
134
|
-
export { FormulaResultStatus } from './services/formula-common';
|
|
135
132
|
export { FunctionService } from './services/function.service';
|
|
136
133
|
export { IFunctionService } from './services/function.service';
|
|
137
134
|
export { GlobalComputingStatusService } from './services/global-computing-status.service';
|
|
138
135
|
export { HyperlinkEngineFormulaService, IHyperlinkEngineFormulaService } from './services/hyperlink-engine-formula.service';
|
|
139
136
|
export { IOtherFormulaManagerService, OtherFormulaManagerService } from './services/other-formula-manager.service';
|
|
140
|
-
export { OtherFormulaBizType, RegisterOtherFormulaService } from './services/register-other-formula.service';
|
|
141
137
|
export { FormulaExecutedStateType, FormulaExecuteStageType, FormulaRuntimeService, type IAllRuntimeData, type IExecutionInProgressParams, IFormulaRuntimeService } from './services/runtime.service';
|
|
142
138
|
export { ISheetRowFilteredService, SheetRowFilteredService } from './services/sheet-row-filtered.service';
|
|
143
139
|
export { ISuperTableService } from './services/super-table.service';
|
|
@@ -3,7 +3,6 @@ import { IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefined
|
|
|
3
3
|
export interface IDirtyConversionManagerParams {
|
|
4
4
|
commandId: string;
|
|
5
5
|
getDirtyData: (command: ICommandInfo) => {
|
|
6
|
-
forceCalculation?: boolean;
|
|
7
6
|
dirtyRanges?: IUnitRange[];
|
|
8
7
|
dirtyNameMap?: IDirtyUnitSheetNameMap;
|
|
9
8
|
dirtyDefinedNameMap?: IDirtyUnitSheetDefinedNameMap;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IUnitRange, Disposable, IConfigService } from '@univerjs/core';
|
|
2
2
|
import { Observable, Subject } from 'rxjs';
|
|
3
3
|
import { IFeatureDirtyRangeType, IFormulaDatasetConfig, IFormulaExecuteResultMap, IFormulaStringMap, IRuntimeUnitDataType, IUnitRowData } from '../basics/common';
|
|
4
|
-
import { IFormulaDependencyTreeFullJson, IFormulaDependencyTreeJson
|
|
4
|
+
import { IFormulaDependencyTreeFullJson, IFormulaDependencyTreeJson } from '../engine/dependency/dependency-tree';
|
|
5
5
|
import { FunctionVariantType } from '../engine/reference-object/base-reference-object';
|
|
6
6
|
import { IAllRuntimeData, IExecutionInProgressParams, IFormulaRuntimeService } from './runtime.service';
|
|
7
7
|
import { Lexer } from '../engine/analysis/lexer';
|
|
@@ -25,7 +25,6 @@ export interface ICalculateFormulaService {
|
|
|
25
25
|
getCellDependencyJson(unitId: string, sheetId: string, row: number, column: number, rowData?: IUnitRowData): Promise<IFormulaDependencyTreeFullJson | undefined>;
|
|
26
26
|
getRangeDependents(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
27
27
|
getInRangeFormulas(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
28
|
-
getDependentsAndInRangeFormulas(unitRanges: IUnitRange[]): Promise<IFormulaDependentsAndInRangeResults>;
|
|
29
28
|
}
|
|
30
29
|
export declare const ICalculateFormulaService: import('@wendellhu/redi').IdentifierDecorator<ICalculateFormulaService>;
|
|
31
30
|
export declare class CalculateFormulaService extends Disposable implements ICalculateFormulaService {
|
|
@@ -41,7 +40,6 @@ export declare class CalculateFormulaService extends Disposable implements ICalc
|
|
|
41
40
|
protected readonly _executionCompleteListener$: Subject<IAllRuntimeData>;
|
|
42
41
|
readonly executionCompleteListener$: Observable<IAllRuntimeData>;
|
|
43
42
|
private _executeLock;
|
|
44
|
-
protected _isCalculateTreeModel: boolean;
|
|
45
43
|
constructor(_configService: IConfigService, _lexer: Lexer, _currentConfigService: IFormulaCurrentConfigService, _runtimeService: IFormulaRuntimeService, _formulaDependencyGenerator: IFormulaDependencyGenerator, _interpreter: Interpreter, _astTreeBuilder: AstTreeBuilder);
|
|
46
44
|
dispose(): void;
|
|
47
45
|
/**
|
|
@@ -67,5 +65,4 @@ export declare class CalculateFormulaService extends Disposable implements ICalc
|
|
|
67
65
|
getCellDependencyJson(unitId: string, sheetId: string, row: number, column: number): Promise<IFormulaDependencyTreeFullJson | undefined>;
|
|
68
66
|
getRangeDependents(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
69
67
|
getInRangeFormulas(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
70
|
-
getDependentsAndInRangeFormulas(unitRanges: IUnitRange[]): Promise<IFormulaDependentsAndInRangeResults>;
|
|
71
68
|
}
|
|
@@ -11,7 +11,6 @@ export interface IFormulaDirtyData {
|
|
|
11
11
|
dirtyUnitOtherFormulaMap: IDirtyUnitOtherFormulaMap;
|
|
12
12
|
clearDependencyTreeCache: IDirtyUnitSheetNameMap;
|
|
13
13
|
maxIteration?: number;
|
|
14
|
-
isCalculateTreeModel?: boolean;
|
|
15
14
|
rowData?: IUnitRowData;
|
|
16
15
|
}
|
|
17
16
|
export interface IFormulaCurrentConfigService {
|
|
@@ -64,7 +64,6 @@ export declare class DefinedNamesService extends Disposable implements IDefinedN
|
|
|
64
64
|
getValueById(unitId: string, id: string): IDefinedNamesServiceParam;
|
|
65
65
|
hasDefinedName(unitId: string): boolean;
|
|
66
66
|
getAllDefinedNames(): IDefinedNameMap;
|
|
67
|
-
getDefinedNameByRefString(unitId: string, formulaOrRefString: string): IDefinedNamesServiceParam | undefined;
|
|
68
67
|
private _update;
|
|
69
68
|
private _updateCache;
|
|
70
69
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
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';
|
|
5
4
|
import { FunctionVariantType } from '../engine/reference-object/base-reference-object';
|
|
6
5
|
import { IFormulaCurrentConfigService } from './current-data.service';
|
|
7
6
|
import { IHyperlinkEngineFormulaService } from './hyperlink-engine-formula.service';
|
|
@@ -41,7 +40,6 @@ export interface IAllRuntimeData {
|
|
|
41
40
|
runtimeFeatureCellData: {
|
|
42
41
|
[featureId: string]: IRuntimeUnitDataType;
|
|
43
42
|
};
|
|
44
|
-
dependencyTreeModelData: IFormulaDependencyTreeJson[];
|
|
45
43
|
}
|
|
46
44
|
export interface IExecutionInProgressParams {
|
|
47
45
|
totalFormulasToCalculate: number;
|
|
@@ -102,8 +100,6 @@ export interface IFormulaRuntimeService {
|
|
|
102
100
|
setUnitArrayFormulaEmbeddedMap(): void;
|
|
103
101
|
clearArrayObjectCache(): void;
|
|
104
102
|
getRuntimeImageFormulaData(): IRuntimeImageFormulaDataType[];
|
|
105
|
-
setDependencyTreeModelData(data: IFormulaDependencyTreeJson[]): void;
|
|
106
|
-
getDependencyTreeModelData(): IFormulaDependencyTreeJson[];
|
|
107
103
|
}
|
|
108
104
|
export declare class FormulaRuntimeService extends Disposable implements IFormulaRuntimeService {
|
|
109
105
|
private readonly _currentConfigService;
|
|
@@ -133,7 +129,6 @@ export declare class FormulaRuntimeService extends Disposable implements IFormul
|
|
|
133
129
|
private _completedArrayFormulasCount;
|
|
134
130
|
private _formulaCycleIndex;
|
|
135
131
|
private _isCycleDependency;
|
|
136
|
-
private _dependencyTreeModelData;
|
|
137
132
|
constructor(_currentConfigService: IFormulaCurrentConfigService, _hyperlinkEngineFormulaService: IHyperlinkEngineFormulaService);
|
|
138
133
|
get currentRow(): number;
|
|
139
134
|
get currentColumn(): number;
|
|
@@ -187,8 +182,6 @@ export declare class FormulaRuntimeService extends Disposable implements IFormul
|
|
|
187
182
|
[featureId: string]: IRuntimeUnitDataType;
|
|
188
183
|
};
|
|
189
184
|
setRuntimeFeatureCellData(featureId: string, featureData: IRuntimeUnitDataType): void;
|
|
190
|
-
setDependencyTreeModelData(data: IFormulaDependencyTreeJson[]): void;
|
|
191
|
-
getDependencyTreeModelData(): IFormulaDependencyTreeJson[];
|
|
192
185
|
getRuntimeImageFormulaData(): IRuntimeImageFormulaDataType[];
|
|
193
186
|
getAllRuntimeData(): IAllRuntimeData;
|
|
194
187
|
getRuntimeState(): IExecutionInProgressParams;
|
|
@@ -12,8 +12,6 @@ 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;
|
|
17
15
|
}
|
|
18
16
|
export declare class SuperTableService extends Disposable implements ISuperTableService {
|
|
19
17
|
private _tableMap;
|
|
@@ -27,8 +25,6 @@ export declare class SuperTableService extends Disposable implements ISuperTable
|
|
|
27
25
|
getTableOptionMap(): Map<string, TableOptionType>;
|
|
28
26
|
registerTable(unitId: string, tableName: string, reference: ISuperTable): void;
|
|
29
27
|
registerTableOptionMap(tableOption: string, tableOptionType: TableOptionType): void;
|
|
30
|
-
getTable(unitId: string, tableName: string): Nullable<ISuperTable>;
|
|
31
|
-
hasTable(unitId: string, tableName: string): boolean;
|
|
32
28
|
private _update;
|
|
33
29
|
}
|
|
34
30
|
export declare const ISuperTableService: import('@wendellhu/redi').IdentifierDecorator<ISuperTableService>;
|
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"})}));
|