@univerjs/engine-formula 0.1.2 → 0.1.3
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 +3698 -3516
- package/lib/types/basics/common.d.ts +6 -4
- package/lib/types/basics/match-token.d.ts +5 -0
- package/lib/types/basics/runtime.d.ts +2 -1
- package/lib/types/basics/token-type.d.ts +1 -0
- package/lib/types/basics/token.d.ts +1 -0
- package/lib/types/commands/mutations/set-formula-calculation.mutation.d.ts +2 -2
- package/lib/types/engine/analysis/lexer-tree-builder.d.ts +5 -1
- package/lib/types/engine/analysis/parser.d.ts +0 -1
- package/lib/types/engine/ast-node/reference-node.d.ts +3 -3
- package/lib/types/engine/utils/ast-node-tool.d.ts +18 -0
- package/lib/types/engine/utils/compare.d.ts +1 -0
- package/lib/types/engine/utils/prefixHandler.d.ts +24 -0
- package/lib/types/engine/utils/r1c1-reference.d.ts +2 -3
- package/lib/types/engine/utils/reference.d.ts +3 -8
- package/lib/types/engine/value-object/base-value-object.d.ts +1 -0
- package/lib/types/engine/value-object/cube-value-object.d.ts +29 -0
- package/lib/types/functions/meta/cube/index.d.ts +20 -0
- package/lib/types/functions/meta/function-map.d.ts +2 -2
- package/lib/types/functions/meta/function-names.d.ts +2 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/umd/index.js +1 -1
- package/package.json +7 -7
|
@@ -48,6 +48,11 @@ export interface IRuntimeUnitDataType {
|
|
|
48
48
|
[sheetId: string]: ObjectMatrix<Nullable<ICellData>>;
|
|
49
49
|
}>;
|
|
50
50
|
}
|
|
51
|
+
export interface IRuntimeUnitDataPrimitiveType {
|
|
52
|
+
[unitId: string]: Nullable<{
|
|
53
|
+
[sheetId: string]: IObjectMatrixPrimitiveType<Nullable<ICellData>>;
|
|
54
|
+
}>;
|
|
55
|
+
}
|
|
51
56
|
export interface IRuntimeOtherUnitDataType {
|
|
52
57
|
[unitId: string]: Nullable<{
|
|
53
58
|
[sheetId: string]: Nullable<{
|
|
@@ -82,10 +87,7 @@ export interface IFeatureDirtyRangeType {
|
|
|
82
87
|
[sheetId: string]: IRange[];
|
|
83
88
|
}>;
|
|
84
89
|
}
|
|
85
|
-
export interface IArrayFormulaUnitCellType {
|
|
86
|
-
[unitId: string]: Nullable<{
|
|
87
|
-
[sheetId: string]: IObjectMatrixPrimitiveType<Nullable<ICellData>>;
|
|
88
|
-
}>;
|
|
90
|
+
export interface IArrayFormulaUnitCellType extends IRuntimeUnitDataPrimitiveType {
|
|
89
91
|
}
|
|
90
92
|
export interface IFormulaData {
|
|
91
93
|
[unitId: string]: Nullable<{
|
|
@@ -18,3 +18,8 @@ export declare const FORMULA_LEXER_TOKENS: (operatorToken | suffixToken | compar
|
|
|
18
18
|
export declare function isFormulaLexerToken(str: string): boolean;
|
|
19
19
|
export declare function includeFormulaLexerToken(str: string): boolean;
|
|
20
20
|
export declare function normalizeSheetName(sheetName: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Determine whether the character is a token keyword for the formula engine.
|
|
23
|
+
* @param char
|
|
24
|
+
*/
|
|
25
|
+
export declare function matchRefDrawToken(char: string): boolean;
|
|
@@ -13,5 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type { IArrayFormulaUnitCellType, IRuntimeUnitDataType } from './common';
|
|
16
|
+
import type { IArrayFormulaUnitCellType, IRuntimeUnitDataPrimitiveType, IRuntimeUnitDataType } from './common';
|
|
17
17
|
export declare function convertUnitDataToRuntime(unitData: IArrayFormulaUnitCellType): IRuntimeUnitDataType;
|
|
18
|
+
export declare function convertRuntimeToUnitData(unitData: IRuntimeUnitDataType): IRuntimeUnitDataPrimitiveType;
|
|
@@ -20,3 +20,4 @@ export declare const DEFAULT_TOKEN_TYPE_LAMBDA_RUNTIME_PARAMETER = "LR_1";
|
|
|
20
20
|
export declare const DEFAULT_TOKEN_TYPE_LAMBDA_OMIT_PARAMETER = "LO_1";
|
|
21
21
|
export declare const DEFAULT_TOKEN_LET_FUNCTION_NAME = "LET";
|
|
22
22
|
export declare const DEFAULT_TOKEN_LAMBDA_FUNCTION_NAME = "LAMBDA";
|
|
23
|
+
export declare const DEFAULT_TOKEN_CUBE_FUNCTION_NAME = "CUBE";
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { IExecutionOptions, IMutation, IUnitRange, Nullable } from '@univerjs/core';
|
|
17
|
-
import type { IDirtyUnitFeatureMap, IDirtyUnitSheetNameMap, INumfmtItemMap, IRuntimeOtherUnitDataType,
|
|
17
|
+
import type { IDirtyUnitFeatureMap, IDirtyUnitSheetNameMap, INumfmtItemMap, IRuntimeOtherUnitDataType, IRuntimeUnitDataPrimitiveType } from '../../basics/common';
|
|
18
18
|
import type { FormulaExecutedStateType, IExecutionInProgressParams } from '../../services/runtime.service';
|
|
19
19
|
export interface ISetFormulaCalculationStartMutation {
|
|
20
20
|
dirtyRanges: IUnitRange[];
|
|
@@ -38,7 +38,7 @@ export interface ISetFormulaCalculationNotificationMutation {
|
|
|
38
38
|
}
|
|
39
39
|
export declare const SetFormulaCalculationNotificationMutation: IMutation<ISetFormulaCalculationNotificationMutation>;
|
|
40
40
|
export interface ISetFormulaCalculationResultMutation {
|
|
41
|
-
unitData:
|
|
41
|
+
unitData: IRuntimeUnitDataPrimitiveType;
|
|
42
42
|
unitOtherData: IRuntimeOtherUnitDataType;
|
|
43
43
|
}
|
|
44
44
|
export declare const SetFormulaCalculationResultMutation: IMutation<ISetFormulaCalculationResultMutation>;
|
|
@@ -52,7 +52,6 @@ export declare class LexerTreeBuilder extends Disposable {
|
|
|
52
52
|
/**
|
|
53
53
|
* Estimate the number of right brackets that need to be automatically added to the end of the formula.
|
|
54
54
|
* @param formulaString
|
|
55
|
-
* @returns
|
|
56
55
|
*/
|
|
57
56
|
checkIfAddBracket(formulaString: string): number;
|
|
58
57
|
sequenceNodesBuilder(formulaString: string): (string | ISequenceNode)[] | undefined;
|
|
@@ -72,6 +71,10 @@ export declare class LexerTreeBuilder extends Disposable {
|
|
|
72
71
|
hasDefinedName: boolean;
|
|
73
72
|
}): ErrorType.VALUE | LexerNode | (string | LexerNode)[] | undefined;
|
|
74
73
|
private _suffixExpressionHandler;
|
|
74
|
+
private _checkCloseBracket;
|
|
75
|
+
private _checkOpenBracket;
|
|
76
|
+
private _checkOperator;
|
|
77
|
+
private _deletePlusForPreNode;
|
|
75
78
|
private _resetCurrentLexerNode;
|
|
76
79
|
private _resetSegment;
|
|
77
80
|
private _openBracket;
|
|
@@ -79,6 +82,7 @@ export declare class LexerTreeBuilder extends Disposable {
|
|
|
79
82
|
private _openSquareBracket;
|
|
80
83
|
private _closeSquareBracket;
|
|
81
84
|
private _getCurrentBracket;
|
|
85
|
+
private _changeCurrentBracket;
|
|
82
86
|
private _openBraces;
|
|
83
87
|
private _closeBraces;
|
|
84
88
|
private _openSingleQuotation;
|
|
@@ -48,7 +48,6 @@ export declare class AstTreeBuilder extends Disposable {
|
|
|
48
48
|
parse(lexerNode: LexerNode, refOffsetX?: number, refOffsetY?: number): Nullable<BaseAstNode>;
|
|
49
49
|
private _lambdaParameterHandler;
|
|
50
50
|
private _changeLetToLambda;
|
|
51
|
-
private _getTopParent;
|
|
52
51
|
private _parse;
|
|
53
52
|
private _checkAstNode;
|
|
54
53
|
private _initializeAstNode;
|
|
@@ -18,9 +18,9 @@ import { Injector } from '@wendellhu/redi';
|
|
|
18
18
|
import { IDefinedNamesService } from '../../services/defined-names.service';
|
|
19
19
|
import { IFormulaRuntimeService } from '../../services/runtime.service';
|
|
20
20
|
import { ISuperTableService } from '../../services/super-table.service';
|
|
21
|
-
import { Lexer } from '../analysis/lexer';
|
|
22
21
|
import { LexerNode } from '../analysis/lexer-node';
|
|
23
22
|
import type { BaseReferenceObject } from '../reference-object/base-reference-object';
|
|
23
|
+
import { IFunctionService } from '../../services/function.service';
|
|
24
24
|
import { BaseAstNode } from './base-ast-node';
|
|
25
25
|
import { BaseAstNodeFactory } from './base-ast-node-factory';
|
|
26
26
|
import { NodeType } from './node-type';
|
|
@@ -37,9 +37,9 @@ export declare class ReferenceNodeFactory extends BaseAstNodeFactory {
|
|
|
37
37
|
private readonly _definedNamesService;
|
|
38
38
|
private readonly _superTableService;
|
|
39
39
|
private readonly _formulaRuntimeService;
|
|
40
|
-
private readonly
|
|
40
|
+
private readonly _functionService;
|
|
41
41
|
private readonly _injector;
|
|
42
|
-
constructor(_definedNamesService: IDefinedNamesService, _superTableService: ISuperTableService, _formulaRuntimeService: IFormulaRuntimeService,
|
|
42
|
+
constructor(_definedNamesService: IDefinedNamesService, _superTableService: ISuperTableService, _formulaRuntimeService: IFormulaRuntimeService, _functionService: IFunctionService, _injector: Injector);
|
|
43
43
|
get zIndex(): number;
|
|
44
44
|
checkAndCreateNodeType(param: LexerNode | string): ReferenceNode | undefined;
|
|
45
45
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { Nullable } from '@univerjs/core';
|
|
17
|
+
import type { BaseAstNode } from '../ast-node/base-ast-node';
|
|
18
|
+
export declare function getAstNodeTopParent(node: BaseAstNode): Nullable<BaseAstNode>;
|
|
@@ -28,3 +28,4 @@ export declare function isWildcard(str: string): boolean;
|
|
|
28
28
|
export declare function isMatchWildcard(currentValue: string, value: string): boolean;
|
|
29
29
|
export declare function replaceWildcard(value: string): string;
|
|
30
30
|
export declare function compareWithWildcard(currentValue: string, value: string, operator: compareToken): boolean;
|
|
31
|
+
export declare function escapeRegExp(str: string): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { Injector } from '@wendellhu/redi';
|
|
17
|
+
import type { Nullable } from '@univerjs/core';
|
|
18
|
+
import type { IFunctionService } from '../../services/function.service';
|
|
19
|
+
import { PrefixNode } from '../ast-node/prefix-node';
|
|
20
|
+
export declare function prefixHandler(tokenTrim: string, functionService: IFunctionService, injector: Injector): {
|
|
21
|
+
tokenTrim: string;
|
|
22
|
+
minusPrefixNode: Nullable<PrefixNode>;
|
|
23
|
+
atPrefixNode: Nullable<PrefixNode>;
|
|
24
|
+
};
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
export declare function deserializeRangeForR1C1(refString: string, currentRow?: number, currentColumn?: number): IGridRangeName;
|
|
16
|
+
import type { IRange, IUnitRangeName } from '@univerjs/core';
|
|
17
|
+
export declare function deserializeRangeForR1C1(refString: string, currentRow?: number, currentColumn?: number): IUnitRangeName;
|
|
19
18
|
export declare function serializeRangeToR1C1(range: IRange): string;
|
|
@@ -13,13 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type { IRange } from '@univerjs/core';
|
|
16
|
+
import type { IRange, IUnitRangeName } from '@univerjs/core';
|
|
17
17
|
import { AbsoluteRefType } from '@univerjs/core';
|
|
18
|
-
export interface IGridRangeName {
|
|
19
|
-
unitId: string;
|
|
20
|
-
sheetName: string;
|
|
21
|
-
range: IRange;
|
|
22
|
-
}
|
|
23
18
|
export interface IAbsoluteRefTypeForRange {
|
|
24
19
|
startAbsoluteRefType: AbsoluteRefType;
|
|
25
20
|
endAbsoluteRefType?: AbsoluteRefType;
|
|
@@ -52,13 +47,13 @@ export declare function serializeRangeWithSheet(sheetName: string, range: IRange
|
|
|
52
47
|
* @param range
|
|
53
48
|
*/
|
|
54
49
|
export declare function serializeRangeWithSpreadsheet(unit: string, sheetName: string, range: IRange): string;
|
|
55
|
-
export declare function serializeRangeToRefString(gridRangeName:
|
|
50
|
+
export declare function serializeRangeToRefString(gridRangeName: IUnitRangeName): string;
|
|
56
51
|
export declare function handleRefStringInfo(refString: string): {
|
|
57
52
|
refBody: string;
|
|
58
53
|
sheetName: string;
|
|
59
54
|
unitId: string;
|
|
60
55
|
};
|
|
61
|
-
export declare function deserializeRangeWithSheet(refString: string):
|
|
56
|
+
export declare function deserializeRangeWithSheet(refString: string): IUnitRangeName;
|
|
62
57
|
/**
|
|
63
58
|
* Determine whether the sheet name needs to be wrapped in quotes
|
|
64
59
|
* Excel will quote the worksheet name if any of the following is true:
|
|
@@ -46,6 +46,7 @@ export declare class BaseValueObject extends ObjectClassType {
|
|
|
46
46
|
getArrayValue(): BaseValueObject[][];
|
|
47
47
|
setValue(value: string | number | boolean): void;
|
|
48
48
|
setArrayValue(value: BaseValueObject[][]): void;
|
|
49
|
+
isCube(): boolean;
|
|
49
50
|
isArray(): boolean;
|
|
50
51
|
isString(): boolean;
|
|
51
52
|
isNumber(): boolean;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { ArrayValueObject } from './array-value-object';
|
|
17
|
+
import { BaseValueObject } from './base-value-object';
|
|
18
|
+
import { NumberValueObject } from './primitive-object';
|
|
19
|
+
export declare class CubeValueObject extends BaseValueObject {
|
|
20
|
+
isCube(): boolean;
|
|
21
|
+
private _values;
|
|
22
|
+
constructor(values: ArrayValueObject[]);
|
|
23
|
+
sum(): NumberValueObject;
|
|
24
|
+
max(): NumberValueObject;
|
|
25
|
+
min(): NumberValueObject;
|
|
26
|
+
count(): NumberValueObject;
|
|
27
|
+
countA(): NumberValueObject;
|
|
28
|
+
countBlank(): NumberValueObject;
|
|
29
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { BaseValueObject } from '../../../engine/value-object/base-value-object';
|
|
17
|
+
import { BaseFunction } from '../../base-function';
|
|
18
|
+
export declare class Cube extends BaseFunction {
|
|
19
|
+
calculate(...variants: BaseValueObject[]): BaseValueObject;
|
|
20
|
+
}
|
|
@@ -13,6 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
16
|
+
import { Cube } from './cube';
|
|
17
17
|
import { FUNCTION_NAMES_META } from './function-names';
|
|
18
|
-
export declare const functionMeta: (FUNCTION_NAMES_META | typeof
|
|
18
|
+
export declare const functionMeta: (FUNCTION_NAMES_META | typeof Cube)[][];
|
package/lib/types/index.d.ts
CHANGED
|
@@ -88,3 +88,4 @@ export { FormulaExecutedStateType, type IAllRuntimeData } from './services/runti
|
|
|
88
88
|
export { SetNumfmtFormulaDataMutation } from './commands/mutations/set-numfmt-formula-data.mutation';
|
|
89
89
|
export type { ISetNumfmtFormulaDataMutationParams } from './commands/mutations/set-numfmt-formula-data.mutation';
|
|
90
90
|
export { isReferenceString } from './basics/regex';
|
|
91
|
+
export { matchRefDrawToken } from './basics/match-token';
|