@univerjs/engine-formula 0.1.7 → 0.1.9
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/index.js +1 -1
- package/lib/es/index.js +2937 -2648
- package/lib/types/basics/common.d.ts +9 -8
- package/lib/types/commands/mutations/set-formula-calculation.mutation.d.ts +1 -2
- package/lib/types/controller/calculate.controller.d.ts +2 -2
- package/lib/types/controller/set-dependency.controller.d.ts +10 -0
- package/lib/types/controller/set-other-formula.controller.d.ts +3 -1
- package/lib/types/engine/analysis/__tests__/create-command-test-bed.d.ts +3 -3
- package/lib/types/engine/analysis/lexer-tree-builder.d.ts +6 -2
- package/lib/types/engine/ast-node/function-node.d.ts +6 -2
- package/lib/types/engine/ast-node/reference-node.d.ts +1 -0
- package/lib/types/engine/dependency/dependency-tree.d.ts +2 -0
- package/lib/types/engine/dependency/formula-dependency.d.ts +9 -1
- package/lib/types/engine/reference-object/base-reference-object.d.ts +16 -6
- package/lib/types/engine/utils/reference.d.ts +10 -1
- package/lib/types/engine/utils/sequence.d.ts +2 -1
- package/lib/types/engine/utils/value-object.d.ts +7 -0
- package/lib/types/engine/value-object/array-value-object.d.ts +2 -1
- package/lib/types/functions/__tests__/create-function-test-bed.d.ts +3 -3
- package/lib/types/functions/base-function.d.ts +12 -0
- package/lib/types/functions/information/iseven/iseven.d.ts +7 -0
- package/lib/types/functions/information/iseven/iseven.spec.d.ts +16 -0
- package/lib/types/functions/information/isodd/isodd.d.ts +7 -0
- package/lib/types/functions/information/isodd/isodd.spec.d.ts +16 -0
- package/lib/types/functions/lookup/indirect/index.d.ts +8 -0
- package/lib/types/functions/text/lower/__test__/index.spec.d.ts +16 -0
- package/lib/types/functions/text/lower/index.d.ts +7 -0
- package/lib/types/index.d.ts +2 -4
- package/lib/types/models/__tests__/create-command-test-bed.d.ts +1 -1
- package/lib/types/models/formula-data.model.d.ts +4 -10
- package/lib/types/models/utils/formula-data-util.d.ts +1 -1
- package/lib/types/plugin.d.ts +1 -1
- package/lib/types/services/current-data.service.d.ts +9 -5
- package/lib/types/services/defined-names.service.d.ts +2 -0
- package/lib/types/services/dependency-manager.service.d.ts +74 -0
- package/lib/types/services/runtime.service.d.ts +1 -5
- package/lib/umd/index.js +1 -1
- package/package.json +8 -8
- package/lib/types/commands/mutations/set-numfmt-formula-data.mutation.d.ts +0 -7
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IFormulaIdMap } from './utils/formula-data-util';
|
|
2
2
|
import { LexerTreeBuilder } from '../engine/analysis/lexer-tree-builder';
|
|
3
|
-
import { IArrayFormulaRangeType, IArrayFormulaUnitCellType, IFormulaData, IFormulaDataItem,
|
|
3
|
+
import { IArrayFormulaRangeType, IArrayFormulaUnitCellType, IFormulaData, IFormulaDataItem, IRuntimeUnitDataType, IUnitData, IUnitSheetNameMap } from '../basics/common';
|
|
4
4
|
import { ICellData, IObjectMatrixPrimitiveType, IRange, Nullable, Disposable, IUniverInstanceService, ObjectMatrix } from '@univerjs/core';
|
|
5
5
|
|
|
6
6
|
export interface IRangeChange {
|
|
@@ -8,13 +8,12 @@ export interface IRangeChange {
|
|
|
8
8
|
newCell: IRange;
|
|
9
9
|
}
|
|
10
10
|
export declare class FormulaDataModel extends Disposable {
|
|
11
|
-
private readonly
|
|
11
|
+
private readonly _univerInstanceService;
|
|
12
12
|
private readonly _lexerTreeBuilder;
|
|
13
13
|
private _formulaData;
|
|
14
14
|
private _arrayFormulaRange;
|
|
15
15
|
private _arrayFormulaCellData;
|
|
16
|
-
|
|
17
|
-
constructor(_currentUniverService: IUniverInstanceService, _lexerTreeBuilder: LexerTreeBuilder);
|
|
16
|
+
constructor(_univerInstanceService: IUniverInstanceService, _lexerTreeBuilder: LexerTreeBuilder);
|
|
18
17
|
clearPreviousArrayFormulaCellData(clearArrayFormulaCellData: IRuntimeUnitDataType): void;
|
|
19
18
|
mergeArrayFormulaCellData(unitData: IRuntimeUnitDataType): void;
|
|
20
19
|
getFormulaData(): IFormulaData;
|
|
@@ -23,10 +22,6 @@ export declare class FormulaDataModel extends Disposable {
|
|
|
23
22
|
setArrayFormulaRange(value: IArrayFormulaRangeType): void;
|
|
24
23
|
getArrayFormulaCellData(): IArrayFormulaUnitCellType;
|
|
25
24
|
setArrayFormulaCellData(value: IArrayFormulaUnitCellType): void;
|
|
26
|
-
getNumfmtItemMap(): INumfmtItemMap;
|
|
27
|
-
getNumfmtValue(unitId: string, sheetId: string, row: number, column: number): Nullable<string>;
|
|
28
|
-
setNumfmtItemMap(value: INumfmtItemMap): void;
|
|
29
|
-
updateNumfmtItemMap(value: INumfmtItemMap): void;
|
|
30
25
|
mergeArrayFormulaRange(formulaData: IArrayFormulaRangeType): void;
|
|
31
26
|
mergeFormulaData(formulaData: IFormulaData): void;
|
|
32
27
|
deleteArrayFormulaRange(unitId: string, sheetId: string, row: number, column: number): void;
|
|
@@ -38,9 +33,8 @@ export declare class FormulaDataModel extends Disposable {
|
|
|
38
33
|
updateFormulaData(unitId: string, sheetId: string, cellValue: IObjectMatrixPrimitiveType<Nullable<ICellData>>): IObjectMatrixPrimitiveType<IFormulaDataItem | null>;
|
|
39
34
|
updateArrayFormulaRange(unitId: string, sheetId: string, cellValue: IObjectMatrixPrimitiveType<Nullable<ICellData>>): void;
|
|
40
35
|
updateArrayFormulaCellData(unitId: string, sheetId: string, cellValue: IObjectMatrixPrimitiveType<Nullable<ICellData>>): void;
|
|
41
|
-
updateNumfmtData(unitId: string, sheetId: string, cellValue: IObjectMatrixPrimitiveType<Nullable<ICellData>>): void;
|
|
42
36
|
getFormulaItemBySId(sId: string, sheetId: string, unitId: string): Nullable<IFormulaDataItem>;
|
|
43
|
-
getFormulaDataItem(row: number, column: number, sheetId: string, unitId: string): IFormulaDataItem
|
|
37
|
+
getFormulaDataItem(row: number, column: number, sheetId: string, unitId: string): Nullable<IFormulaDataItem>;
|
|
44
38
|
getFormulaIdMap(unitId: string, sheetId: string): Map<string, IFormulaIdMap>;
|
|
45
39
|
}
|
|
46
40
|
export declare function initSheetFormulaData(formulaData: IFormulaData, unitId: string, sheetId: string, cellMatrix: ObjectMatrix<Nullable<ICellData>>): {
|
|
@@ -6,5 +6,5 @@ export interface IFormulaIdMap {
|
|
|
6
6
|
r: number;
|
|
7
7
|
c: number;
|
|
8
8
|
}
|
|
9
|
-
export declare function updateFormulaDataByCellValue(sheetFormulaDataMatrix: ObjectMatrix<IFormulaDataItem
|
|
9
|
+
export declare function updateFormulaDataByCellValue(sheetFormulaDataMatrix: ObjectMatrix<Nullable<IFormulaDataItem>>, newSheetFormulaDataMatrix: ObjectMatrix<IFormulaDataItem | null>, formulaIdMap: Map<string, IFormulaIdMap>, deleteFormulaIdMap: Map<string, string | IFormulaIdMap>, r: number, c: number, cell: Nullable<ICellData>): void;
|
|
10
10
|
export declare function clearArrayFormulaCellDataByCell(arrayFormulaRangeMatrix: ObjectMatrix<IRange>, arrayFormulaCellDataMatrix: ObjectMatrix<Nullable<ICellData>>, r: number, c: number): true | undefined;
|
package/lib/types/plugin.d.ts
CHANGED
|
@@ -10,9 +10,9 @@ interface IUniverFormulaEngine {
|
|
|
10
10
|
export declare class UniverFormulaEnginePlugin extends Plugin {
|
|
11
11
|
private _config;
|
|
12
12
|
protected _injector: Injector;
|
|
13
|
+
static pluginName: string;
|
|
13
14
|
constructor(_config: IUniverFormulaEngine, _injector: Injector);
|
|
14
15
|
onStarting(): void;
|
|
15
16
|
private _initialize;
|
|
16
|
-
onReady(): void;
|
|
17
17
|
}
|
|
18
18
|
export {};
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefinedNameMap, IDirtyUnitSheetNameMap, IFormulaData, IFormulaDatasetConfig,
|
|
1
|
+
import { IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefinedNameMap, IDirtyUnitSheetNameMap, IFormulaData, IFormulaDatasetConfig, IRuntimeUnitDataType, IUnitData, IUnitExcludedCell, IUnitSheetNameMap, IUnitStylesData } from '../basics/common';
|
|
2
2
|
import { IUnitRange, Nullable, Disposable, IUniverInstanceService } from '@univerjs/core';
|
|
3
3
|
|
|
4
4
|
export declare const DEFAULT_DOCUMENT_SUB_COMPONENT_ID = "__default_document_sub_component_id20231101__";
|
|
5
5
|
export interface IFormulaCurrentConfigService {
|
|
6
6
|
load(config: IFormulaDatasetConfig): void;
|
|
7
7
|
getUnitData(): IUnitData;
|
|
8
|
+
/**
|
|
9
|
+
* Get the unit styles data.
|
|
10
|
+
*/
|
|
11
|
+
getUnitStylesData(): IUnitStylesData;
|
|
8
12
|
getFormulaData(): IFormulaData;
|
|
9
13
|
getSheetNameMap(): IUnitSheetNameMap;
|
|
10
14
|
isForceCalculate(): boolean;
|
|
@@ -26,8 +30,9 @@ export interface IFormulaCurrentConfigService {
|
|
|
26
30
|
setExecuteSubUnitId(subUnitId: string): void;
|
|
27
31
|
}
|
|
28
32
|
export declare class FormulaCurrentConfigService extends Disposable implements IFormulaCurrentConfigService {
|
|
29
|
-
private readonly
|
|
33
|
+
private readonly _univerInstanceService;
|
|
30
34
|
private _unitData;
|
|
35
|
+
private _unitStylesData;
|
|
31
36
|
private _arrayFormulaCellData;
|
|
32
37
|
private _formulaData;
|
|
33
38
|
private _sheetNameMap;
|
|
@@ -35,14 +40,13 @@ export declare class FormulaCurrentConfigService extends Disposable implements I
|
|
|
35
40
|
private _dirtyRanges;
|
|
36
41
|
private _dirtyNameMap;
|
|
37
42
|
private _dirtyDefinedNameMap;
|
|
38
|
-
private _numfmtItemMap;
|
|
39
43
|
private _dirtyUnitFeatureMap;
|
|
40
44
|
private _dirtyUnitOtherFormulaMap;
|
|
41
45
|
private _excludedCell;
|
|
42
46
|
private _sheetIdToNameMap;
|
|
43
47
|
private _executeUnitId;
|
|
44
48
|
private _executeSubUnitId;
|
|
45
|
-
constructor(
|
|
49
|
+
constructor(_univerInstanceService: IUniverInstanceService);
|
|
46
50
|
dispose(): void;
|
|
47
51
|
getExecuteUnitId(): Nullable<string>;
|
|
48
52
|
getExecuteSubUnitId(): Nullable<string>;
|
|
@@ -50,6 +54,7 @@ export declare class FormulaCurrentConfigService extends Disposable implements I
|
|
|
50
54
|
setExecuteSubUnitId(subUnitId: string): void;
|
|
51
55
|
getExcludedRange(): Nullable<IUnitExcludedCell>;
|
|
52
56
|
getUnitData(): IUnitData;
|
|
57
|
+
getUnitStylesData(): IUnitStylesData;
|
|
53
58
|
getFormulaData(): IFormulaData;
|
|
54
59
|
getArrayFormulaCellData(): IRuntimeUnitDataType;
|
|
55
60
|
getSheetNameMap(): IUnitSheetNameMap;
|
|
@@ -57,7 +62,6 @@ export declare class FormulaCurrentConfigService extends Disposable implements I
|
|
|
57
62
|
getDirtyRanges(): IUnitRange[];
|
|
58
63
|
getDirtyNameMap(): IDirtyUnitSheetNameMap;
|
|
59
64
|
getDirtyDefinedNameMap(): IDirtyUnitSheetDefinedNameMap;
|
|
60
|
-
getNumfmtItemMap(): INumfmtItemMap;
|
|
61
65
|
getDirtyUnitFeatureMap(): IDirtyUnitFeatureMap;
|
|
62
66
|
getDirtyUnitOtherFormulaMap(): IDirtyUnitOtherFormulaMap;
|
|
63
67
|
getSheetName(unitId: string, sheetId: string): string;
|
|
@@ -25,6 +25,7 @@ export interface IDefinedNamesService {
|
|
|
25
25
|
getValueByName(unitId: string, name: string): Nullable<IDefinedNamesServiceParam>;
|
|
26
26
|
getValueById(unitId: string, id: string): Nullable<IDefinedNamesServiceParam>;
|
|
27
27
|
removeDefinedName(unitId: string, name: string): void;
|
|
28
|
+
removeUnitDefinedName(unitId: string): void;
|
|
28
29
|
hasDefinedName(unitId: string): boolean;
|
|
29
30
|
setCurrentRange(range: IUnitRange): void;
|
|
30
31
|
getCurrentRange(): IUnitRange;
|
|
@@ -52,6 +53,7 @@ export declare class DefinedNamesService extends Disposable implements IDefinedN
|
|
|
52
53
|
registerDefinedNames(unitId: string, params: IDefinedNameMapItem): void;
|
|
53
54
|
registerDefinedName(unitId: string, param: IDefinedNamesServiceParam): void;
|
|
54
55
|
removeDefinedName(unitId: string, id: string): void;
|
|
56
|
+
removeUnitDefinedName(unitId: string): void;
|
|
55
57
|
getDefinedNameMap(unitId: string): IDefinedNameMapItem;
|
|
56
58
|
getValueByName(unitId: string, name: string): IDefinedNamesServiceParam | null;
|
|
57
59
|
getValueById(unitId: string, id: string): IDefinedNamesServiceParam;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { FormulaDependencyTreeCache, FormulaDependencyTree } from '../engine/dependency/dependency-tree';
|
|
2
|
+
import { Nullable, Disposable, ObjectMatrix } from '@univerjs/core';
|
|
3
|
+
|
|
4
|
+
export interface IOtherFormulaDependencyParam {
|
|
5
|
+
[unitId: string]: Nullable<{
|
|
6
|
+
[sheetId: string]: {
|
|
7
|
+
[formulaId: string]: Nullable<FormulaDependencyTree>;
|
|
8
|
+
};
|
|
9
|
+
}>;
|
|
10
|
+
}
|
|
11
|
+
export interface IFormulaDependencyParam {
|
|
12
|
+
[unitId: string]: Nullable<{
|
|
13
|
+
[sheetId: string]: ObjectMatrix<Nullable<FormulaDependencyTree>>;
|
|
14
|
+
}>;
|
|
15
|
+
}
|
|
16
|
+
export interface IDependencyManagerService {
|
|
17
|
+
dispose(): void;
|
|
18
|
+
getAllTree(): FormulaDependencyTree[];
|
|
19
|
+
buildDependencyTree(shouldBeBuildTrees: FormulaDependencyTree[] | FormulaDependencyTreeCache): FormulaDependencyTree[];
|
|
20
|
+
clearDependencyForTree(shouldBeClearTree: Nullable<FormulaDependencyTree>): void;
|
|
21
|
+
reset(): void;
|
|
22
|
+
addOtherFormulaDependency(unitId: string, sheetId: string, formulaId: string, dependencyTree: FormulaDependencyTree): void;
|
|
23
|
+
removeOtherFormulaDependency(unitId: string, sheetId: string, formulaId: string[]): void;
|
|
24
|
+
hasOtherFormulaDependency(unitId: string, sheetId: string, formulaId: string): boolean;
|
|
25
|
+
addFeatureFormulaDependency(featureId: string, dependencyTree: FormulaDependencyTree): void;
|
|
26
|
+
removeFeatureFormulaDependency(featureId: string): void;
|
|
27
|
+
hasFeatureFormulaDependency(unitId: string, sheetId: string, featureId: string): boolean;
|
|
28
|
+
addFormulaDependency(unitId: string, sheetId: string, row: number, column: number, dependencyTree: FormulaDependencyTree): void;
|
|
29
|
+
removeFormulaDependency(unitId: string, sheetId: string, row: number, column: number): void;
|
|
30
|
+
hasFormulaDependency(unitId: string, sheetId: string, row: number, column: number): boolean;
|
|
31
|
+
clearFormulaDependency(unitId: string, sheetId: string): void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Passively marked as dirty, register the reference and execution actions of the feature plugin.
|
|
35
|
+
* After execution, a dirty area and calculated data will be returned,
|
|
36
|
+
* causing the formula to be marked dirty again,
|
|
37
|
+
* thereby completing the calculation of the entire dependency tree.
|
|
38
|
+
*/
|
|
39
|
+
export declare class DependencyManagerService extends Disposable implements IDependencyManagerService {
|
|
40
|
+
private _otherFormulaData;
|
|
41
|
+
private _featureFormulaData;
|
|
42
|
+
private _formulaData;
|
|
43
|
+
dispose(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Get all FormulaDependencyTree from _otherFormulaData, _featureFormulaData, _formulaData
|
|
46
|
+
* return FormulaDependencyTree[]
|
|
47
|
+
*/
|
|
48
|
+
getAllTree(): FormulaDependencyTree[];
|
|
49
|
+
buildDependencyTree(shouldBeBuildTrees: FormulaDependencyTree[] | FormulaDependencyTreeCache): FormulaDependencyTree[];
|
|
50
|
+
/**
|
|
51
|
+
* Build the dependency relationship between the trees.
|
|
52
|
+
* @param allTrees all FormulaDependencyTree
|
|
53
|
+
* @param shouldBeBuildTrees FormulaDependencyTree[] | FormulaDependencyTreeCache
|
|
54
|
+
*/
|
|
55
|
+
private _buildDependencyTree;
|
|
56
|
+
/**
|
|
57
|
+
* Clear the dependency relationship of the tree.
|
|
58
|
+
* establish the relationship between the parent and the child.
|
|
59
|
+
* @param shouldBeClearTree
|
|
60
|
+
*/
|
|
61
|
+
clearDependencyForTree(shouldBeClearTree: Nullable<FormulaDependencyTree>): void;
|
|
62
|
+
reset(): void;
|
|
63
|
+
addOtherFormulaDependency(unitId: string, sheetId: string, formulaId: string, dependencyTree: FormulaDependencyTree): void;
|
|
64
|
+
removeOtherFormulaDependency(unitId: string, sheetId: string, formulaIds: string[]): void;
|
|
65
|
+
hasOtherFormulaDependency(unitId: string, sheetId: string, formulaId: string): boolean;
|
|
66
|
+
addFeatureFormulaDependency(featureId: string, dependencyTree: FormulaDependencyTree): void;
|
|
67
|
+
removeFeatureFormulaDependency(featureId: string): void;
|
|
68
|
+
hasFeatureFormulaDependency(featureId: string): boolean;
|
|
69
|
+
addFormulaDependency(unitId: string, sheetId: string, row: number, column: number, dependencyTree: FormulaDependencyTree): void;
|
|
70
|
+
removeFormulaDependency(unitId: string, sheetId: string, row: number, column: number): void;
|
|
71
|
+
clearFormulaDependency(unitId: string, sheetId: string): void;
|
|
72
|
+
hasFormulaDependency(unitId: string, sheetId: string, row: number, column: number): boolean;
|
|
73
|
+
}
|
|
74
|
+
export declare const IDependencyManagerService: import('@wendellhu/redi').IdentifierDecorator<DependencyManagerService>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IFormulaCurrentConfigService } from './current-data.service';
|
|
2
2
|
import { FunctionVariantType } from '../engine/reference-object/base-reference-object';
|
|
3
3
|
import { BaseAstNode } from '../engine/ast-node/base-ast-node';
|
|
4
|
-
import { IArrayFormulaRangeType, IFeatureDirtyRangeType,
|
|
4
|
+
import { IArrayFormulaRangeType, IFeatureDirtyRangeType, IRuntimeOtherUnitDataType, IRuntimeUnitDataType } from '../basics/common';
|
|
5
5
|
import { Nullable, Disposable } from '@univerjs/core';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -36,7 +36,6 @@ export interface IAllRuntimeData {
|
|
|
36
36
|
functionsExecutedState: FormulaExecutedStateType;
|
|
37
37
|
arrayFormulaCellData: IRuntimeUnitDataType;
|
|
38
38
|
clearArrayFormulaCellData: IRuntimeUnitDataType;
|
|
39
|
-
numfmtItemMap: INumfmtItemMap;
|
|
40
39
|
runtimeFeatureRange: {
|
|
41
40
|
[featureId: string]: IFeatureDirtyRangeType;
|
|
42
41
|
};
|
|
@@ -112,7 +111,6 @@ export declare class FormulaRuntimeService extends Disposable implements IFormul
|
|
|
112
111
|
private _unitArrayFormulaRange;
|
|
113
112
|
private _runtimeArrayFormulaCellData;
|
|
114
113
|
private _runtimeClearArrayFormulaCellData;
|
|
115
|
-
private _numfmtItemMap;
|
|
116
114
|
private _runtimeFeatureRange;
|
|
117
115
|
private _runtimeFeatureCellData;
|
|
118
116
|
private _functionsExecutedState;
|
|
@@ -158,7 +156,6 @@ export declare class FormulaRuntimeService extends Disposable implements IFormul
|
|
|
158
156
|
setRuntimeData(functionVariant: FunctionVariantType): void;
|
|
159
157
|
getUnitData(): IRuntimeUnitDataType;
|
|
160
158
|
getUnitArrayFormula(): IArrayFormulaRangeType;
|
|
161
|
-
getNumfmtItemMap(): INumfmtItemMap;
|
|
162
159
|
getRuntimeOtherData(): IRuntimeOtherUnitDataType;
|
|
163
160
|
getRuntimeArrayFormulaCellData(): IRuntimeUnitDataType;
|
|
164
161
|
getRuntimeClearArrayFormulaCellData(): IRuntimeUnitDataType;
|
|
@@ -172,7 +169,6 @@ export declare class FormulaRuntimeService extends Disposable implements IFormul
|
|
|
172
169
|
setRuntimeFeatureCellData(featureId: string, featureData: IRuntimeUnitDataType): void;
|
|
173
170
|
getAllRuntimeData(): IAllRuntimeData;
|
|
174
171
|
getRuntimeState(): IExecutionInProgressParams;
|
|
175
|
-
private _objectValueToCellValue;
|
|
176
172
|
private _checkIfArrayFormulaRangeHasData;
|
|
177
173
|
private _isInArrayFormulaRange;
|
|
178
174
|
private _checkIfArrayFormulaExceeded;
|