@univerjs/engine-formula 0.12.4 → 0.13.0-insiders.20251215-64041bb
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 +516 -43
- package/lib/es/index.js +6671 -6293
- package/lib/facade.js +516 -43
- package/lib/index.js +6671 -6293
- package/lib/types/basics/common.d.ts +21 -0
- package/lib/types/basics/date.d.ts +0 -1
- package/lib/types/basics/match-token.d.ts +1 -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/controller/config.schema.d.ts +1 -0
- package/lib/types/engine/analysis/lexer-tree-builder.d.ts +2 -1
- package/lib/types/engine/ast-node/reference-node.d.ts +0 -1
- package/lib/types/engine/dependency/dependency-tree.d.ts +39 -0
- package/lib/types/engine/dependency/formula-dependency.d.ts +25 -4
- package/lib/types/engine/utils/reference.d.ts +9 -0
- package/lib/types/engine/utils/sequence.d.ts +2 -1
- package/lib/types/facade/f-formula.d.ts +372 -3
- package/lib/types/index.d.ts +6 -6
- package/lib/types/services/calculate-formula.service.d.ts +16 -4
- package/lib/types/services/current-data.service.d.ts +3 -0
- package/lib/types/services/defined-names.service.d.ts +1 -0
- package/lib/types/services/runtime.service.d.ts +7 -0
- package/lib/types/services/super-table.service.d.ts +2 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +6 -6
- package/LICENSE +0 -176
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ICellData, IColumnData, IObjectArrayPrimitiveType, IObjectMatrixPrimitiveType, IRange, IRowData, IUnitRange, Nullable, ObjectMatrix, Styles } from '@univerjs/core';
|
|
2
|
+
import { sequenceNodeType } from '../engine/utils/sequence';
|
|
2
3
|
import { IImageFormulaInfo } from '../engine/value-object/primitive-object';
|
|
3
4
|
export declare const ERROR_VALUE_OBJECT_CLASS_TYPE = "errorValueObject";
|
|
4
5
|
export declare const ASYNC_OBJECT_CLASS_TYPE = "asyncObject";
|
|
@@ -126,6 +127,20 @@ export interface IFormulaIdMap {
|
|
|
126
127
|
r: number;
|
|
127
128
|
c: number;
|
|
128
129
|
}
|
|
130
|
+
export interface IFormulaStringMap {
|
|
131
|
+
[unitId: string]: Nullable<{
|
|
132
|
+
[sheetId: string]: IObjectMatrixPrimitiveType<string[]>;
|
|
133
|
+
}>;
|
|
134
|
+
}
|
|
135
|
+
export interface IFormulaExecuteResultItem {
|
|
136
|
+
value: Nullable<number | string | boolean | Array<Array<number | string | boolean | null>>>;
|
|
137
|
+
formula: string;
|
|
138
|
+
}
|
|
139
|
+
export interface IFormulaExecuteResultMap {
|
|
140
|
+
[unitId: string]: Nullable<{
|
|
141
|
+
[sheetId: string]: IObjectMatrixPrimitiveType<IFormulaExecuteResultItem[]>;
|
|
142
|
+
}>;
|
|
143
|
+
}
|
|
129
144
|
export interface IFormulaIdMapData {
|
|
130
145
|
[unitId: string]: Nullable<{
|
|
131
146
|
[subUnitId: string]: Nullable<{
|
|
@@ -192,9 +207,15 @@ export interface IFormulaDatasetConfig {
|
|
|
192
207
|
unitStylesData?: IUnitStylesData;
|
|
193
208
|
unitSheetNameMap?: IUnitSheetNameMap;
|
|
194
209
|
maxIteration?: number;
|
|
210
|
+
isCalculateTreeModel?: boolean;
|
|
195
211
|
rowData?: IUnitRowData;
|
|
196
212
|
}
|
|
197
213
|
export declare enum ConcatenateType {
|
|
198
214
|
FRONT = 0,
|
|
199
215
|
BACK = 1
|
|
200
216
|
}
|
|
217
|
+
export interface IExprTreeNode {
|
|
218
|
+
value: string;
|
|
219
|
+
children: IExprTreeNode[];
|
|
220
|
+
type?: sequenceNodeType;
|
|
221
|
+
}
|
|
@@ -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,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 | prefixToken | matchToken)[];
|
|
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,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
|
}
|
|
@@ -4,6 +4,7 @@ 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";
|
|
7
8
|
export declare const configSymbol: unique symbol;
|
|
8
9
|
export interface IUniverEngineFormulaConfig {
|
|
9
10
|
notExecuteFormula?: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Nullable, AbsoluteRefType, Disposable } from '@univerjs/core';
|
|
2
|
-
import { IDirtyUnitSheetDefinedNameMap } from '../../basics/common';
|
|
2
|
+
import { IDirtyUnitSheetDefinedNameMap, IExprTreeNode, ISuperTable } 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,5 +145,6 @@ 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;
|
|
148
149
|
}
|
|
149
150
|
export {};
|
|
@@ -36,7 +36,6 @@ export declare class ReferenceNodeFactory extends BaseAstNodeFactory {
|
|
|
36
36
|
private _getTableMap;
|
|
37
37
|
private _getNode;
|
|
38
38
|
private _getTableReferenceNode;
|
|
39
|
-
private _splitTableStructuredRef;
|
|
40
39
|
private _checkTokenIsTableReference;
|
|
41
40
|
private _checkParentIsUnionOperator;
|
|
42
41
|
}
|
|
@@ -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
|
-
generate(): Promise<IFormulaDependencyTree[]>;
|
|
18
|
+
generate(isCalculateTreeModel?: boolean): 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,11 +31,12 @@ 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
|
-
generate(): Promise<(FormulaDependencyTree | FormulaDependencyTreeVirtual)[]>;
|
|
39
|
+
generate(isCalculateTreeModel?: boolean): Promise<(FormulaDependencyTree | FormulaDependencyTreeVirtual)[]>;
|
|
34
40
|
private _dependencyFeatureCalculation;
|
|
35
41
|
private _clearFeatureCalculationNode;
|
|
36
42
|
/**
|
|
@@ -110,4 +116,19 @@ 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
|
+
protected _getAllDependencyJson(treeList: IFormulaDependencyTree[]): IFormulaDependencyTreeJson[];
|
|
129
|
+
getAllDependencyJson(): Promise<IFormulaDependencyTreeJson[]>;
|
|
130
|
+
protected _setRealFormulaString(treeModel: FormulaDependencyTreeModel): void;
|
|
131
|
+
getCellDependencyJson(unitId: string, sheetId: string, row: number, column: number): Promise<IFormulaDependencyTreeFullJson | undefined>;
|
|
132
|
+
getRangeDependents(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
133
|
+
getInRangeFormulas(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
113
134
|
}
|
|
@@ -85,3 +85,12 @@ 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
|
+
};
|