@univerjs/engine-formula 0.1.3 → 0.1.4

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.
Files changed (39) hide show
  1. package/lib/cjs/index.js +1 -1
  2. package/lib/es/index.js +4219 -3167
  3. package/lib/types/basics/common.d.ts +5 -0
  4. package/lib/types/basics/date.d.ts +1 -1
  5. package/lib/types/basics/format.d.ts +24 -0
  6. package/lib/types/basics/inverted-index-cache.d.ts +2 -2
  7. package/lib/types/basics/object-class-type.d.ts +4 -0
  8. package/lib/types/engine/dependency/dependency-tree.d.ts +20 -4
  9. package/lib/types/engine/dependency/formula-dependency.d.ts +0 -6
  10. package/lib/types/engine/reference-object/base-reference-object.d.ts +8 -6
  11. package/lib/types/engine/utils/char-kit.d.ts +25 -0
  12. package/lib/types/engine/utils/object-compare.d.ts +0 -1
  13. package/lib/types/engine/utils/reference.d.ts +1 -1
  14. package/lib/types/engine/value-object/__tests__/array-value-divided.spec.d.ts +16 -0
  15. package/lib/types/engine/value-object/__tests__/array-value-minus.spec.d.ts +16 -0
  16. package/lib/types/engine/value-object/__tests__/array-value-multiply.spec.d.ts +16 -0
  17. package/lib/types/engine/value-object/__tests__/array-value-plus.spec.d.ts +16 -0
  18. package/lib/types/engine/value-object/array-value-object.d.ts +7 -7
  19. package/lib/types/engine/value-object/base-value-object.d.ts +8 -4
  20. package/lib/types/engine/value-object/cube-value-object.d.ts +1 -0
  21. package/lib/types/engine/value-object/lambda-value-object.d.ts +1 -0
  22. package/lib/types/engine/value-object/primitive-object.d.ts +25 -4
  23. package/lib/types/functions/base-function.d.ts +4 -9
  24. package/lib/types/functions/logical/or/__tests__/index.spec.d.ts +16 -0
  25. package/lib/types/functions/logical/or/index.d.ts +20 -0
  26. package/lib/types/functions/lookup/function-map.d.ts +1 -4
  27. package/lib/types/functions/lookup/index/index.d.ts +11 -2
  28. package/lib/types/functions/lookup/offset/index.d.ts +2 -2
  29. package/lib/types/functions/text/len/__test__/index.spec.d.ts +16 -0
  30. package/lib/types/functions/text/len/index.d.ts +21 -0
  31. package/lib/types/functions/text/lenb/__test__/index.spec.d.ts +16 -0
  32. package/lib/types/functions/text/lenb/index.d.ts +21 -0
  33. package/lib/types/functions/text/text/__test__/index.spec.d.ts +16 -0
  34. package/lib/types/functions/text/text/index.d.ts +20 -0
  35. package/lib/types/index.d.ts +3 -0
  36. package/lib/types/plugin.d.ts +1 -1
  37. package/lib/types/services/current-data.service.d.ts +3 -0
  38. package/lib/umd/index.js +1 -1
  39. package/package.json +10 -8
@@ -65,6 +65,11 @@ export interface IUnitSheetNameMap {
65
65
  [sheetName: string]: string;
66
66
  }>;
67
67
  }
68
+ export interface IUnitSheetIdToNameMap {
69
+ [unitId: string]: Nullable<{
70
+ [sheetId: string]: string;
71
+ }>;
72
+ }
68
73
  export interface IDirtyUnitSheetNameMap {
69
74
  [unitId: string]: Nullable<{
70
75
  [sheetId: string]: string;
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export declare const DEFFAULT_DATE_FORMAT = "yyyy-mm-dd;@";
16
+ export declare const DEFAULT_DATE_FORMAT = "yyyy/mm/dd;@";
17
17
  /**
18
18
  * Excel stores dates as sequential serial numbers so they can be used in calculations. By default, January 1, 1900 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,447 days after January 1, 1900.
19
19
  *
@@ -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
+ /**
17
+ * covert number to preview string by pattern
18
+ * @TODODushusir: Internationalization, reuse with numfmt
19
+ *
20
+ * @param pattern
21
+ * @param value
22
+ * @returns
23
+ */
24
+ export declare const getFormatPreview: (pattern: string, value: number) => any;
@@ -29,8 +29,8 @@ export declare class InvertedIndexCache {
29
29
  private _cache;
30
30
  private _continueBuildingCache;
31
31
  set(unitId: string, sheetId: string, column: number, value: string | number | boolean | null, row: number): void;
32
- getCellValuePositions(unitId: string, sheetId: string, column: number): Map<string | number | boolean | null, number[]> | undefined;
33
- getCellPositions(unitId: string, sheetId: string, column: number, value: string | number | boolean): number[] | undefined;
32
+ getCellValuePositions(unitId: string, sheetId: string, column: number): Map<string | number | boolean | null, Set<number>> | undefined;
33
+ getCellPositions(unitId: string, sheetId: string, column: number, value: string | number | boolean): Set<number> | undefined;
34
34
  getCellPosition(unitId: string, sheetId: string, column: number, value: string | number | boolean, startRow: number, endRow: number): number | undefined;
35
35
  setContinueBuildingCache(unitId: string, sheetId: string, column: number, startRow: number, endRow: number): void;
36
36
  shouldContinueBuildingCache(unitId: string, sheetId: string, column: number, row: number): boolean;
@@ -17,6 +17,10 @@ import { Disposable } from '@univerjs/core';
17
17
  export declare class ObjectClassType extends Disposable {
18
18
  pattern: string;
19
19
  getPattern(): string;
20
+ /**
21
+ * Only used in NumberValueObject
22
+ * @param pattern
23
+ */
20
24
  setPattern(pattern: string): void;
21
25
  isError(): boolean;
22
26
  isAsyncObject(): boolean;
@@ -22,6 +22,10 @@ export declare enum FDtreeStateType {
22
22
  ADDED = 1,
23
23
  SKIP = 2
24
24
  }
25
+ export interface IUnitRangeWithToken {
26
+ gridRange: IUnitRange;
27
+ token: string;
28
+ }
25
29
  /**
26
30
  * A dependency tree, capable of calculating mutual dependencies,
27
31
  * is used to determine the order of formula calculations.
@@ -37,7 +41,7 @@ export declare class FormulaDependencyTree extends Disposable {
37
41
  columnCount: number;
38
42
  subUnitId: string;
39
43
  unitId: string;
40
- rangeList: IUnitRange[];
44
+ rangeList: IUnitRangeWithToken[];
41
45
  formulaId: Nullable<string>;
42
46
  featureId: Nullable<string>;
43
47
  getDirtyData: Nullable<(tree: FormulaDependencyTree) => {
@@ -55,7 +59,6 @@ export declare class FormulaDependencyTree extends Disposable {
55
59
  * "Determine whether all ranges of the current node exist within the dirty area.
56
60
  * If they are within the dirty area, return true, indicating that this node needs to be calculated.
57
61
  * @param dependencyRangeList
58
- * @returns
59
62
  */
60
63
  dependencyRange(dependencyRangeList: Map<string, Map<string, IRange[]>>, dirtyUnitSheetNameMap: IDirtyUnitSheetNameMap, unitExcludedCell: Nullable<IUnitExcludedCell>): boolean;
61
64
  pushChildren(tree: FormulaDependencyTree): void;
@@ -63,12 +66,25 @@ export declare class FormulaDependencyTree extends Disposable {
63
66
  * Add the range corresponding to the current ast node.
64
67
  * @param range
65
68
  */
66
- pushRangeList(range: IUnitRange): void;
69
+ pushRangeList(range: IUnitRangeWithToken): void;
67
70
  /**
68
71
  * Determine whether it is dependent on other trees.
69
72
  * @param dependenceTree
70
- * @returns
71
73
  */
72
74
  dependency(dependenceTree: FormulaDependencyTree): boolean;
73
75
  private _pushParent;
74
76
  }
77
+ export declare class FormulaDependencyTreeCache extends Disposable {
78
+ private _cacheItems;
79
+ dispose(): void;
80
+ size(): number;
81
+ add(unitRangeWithToken: IUnitRangeWithToken, tree: FormulaDependencyTree): void;
82
+ clear(): void;
83
+ remove(token: string, tree: FormulaDependencyTree): void;
84
+ delete(token: string): void;
85
+ /**
86
+ * Determine whether range is dependent on other trees.
87
+ * @param dependenceTree
88
+ */
89
+ dependency(dependenceTree: FormulaDependencyTree): void;
90
+ }
@@ -43,12 +43,10 @@ export declare class FormulaDependencyGenerator extends Disposable {
43
43
  /**
44
44
  * Generate nodes for the dependency tree, where each node contains all the reference data ranges included in each formula.
45
45
  * @param formulaData
46
- * @returns
47
46
  */
48
47
  private _generateTreeList;
49
48
  /**
50
49
  * Break down the dirty areas into ranges for subsequent matching.
51
- * @returns
52
50
  */
53
51
  private _updateRangeFlatten;
54
52
  private _generateAstNode;
@@ -61,26 +59,22 @@ export declare class FormulaDependencyGenerator extends Disposable {
61
59
  * Calculate the range required for collection in advance,
62
60
  * including references and location functions (such as OFFSET, INDIRECT, INDEX, etc.).
63
61
  * @param node
64
- * @returns
65
62
  */
66
63
  private _getRangeListByNode;
67
64
  /**
68
65
  * Build a formula dependency tree based on the dependency relationships.
69
66
  * @param treeList
70
- * @returns
71
67
  */
72
68
  private _getUpdateTreeListAndMakeDependency;
73
69
  /**
74
70
  * Determine whether all ranges of the current node exist within the dirty area.
75
71
  * If they are within the dirty area, return true, indicating that this node needs to be calculated.
76
72
  * @param tree
77
- * @returns
78
73
  */
79
74
  private _includeTree;
80
75
  /**
81
76
  * Generate the final formula calculation order array by traversing the dependency tree established via depth-first search.
82
77
  * @param treeList
83
- * @returns
84
78
  */
85
79
  private _calculateRunList;
86
80
  }
@@ -19,7 +19,7 @@ import type { INumfmtItemMap, IRuntimeUnitDataType, IUnitData, IUnitSheetNameMap
19
19
  import { ObjectClassType } from '../../basics/object-class-type';
20
20
  import { ArrayValueObject } from '../value-object/array-value-object';
21
21
  import { type BaseValueObject, ErrorValueObject } from '../value-object/base-value-object';
22
- import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../value-object/primitive-object';
22
+ import { NullValueObject, NumberValueObject } from '../value-object/primitive-object';
23
23
  export type NodeValueType = BaseValueObject | BaseReferenceObject | AsyncObject | AsyncArrayObject;
24
24
  export type FunctionVariantType = BaseValueObject | BaseReferenceObject;
25
25
  export declare const FORMULA_REF_TO_ARRAY_CACHE: FormulaAstLRU<ArrayValueObject>;
@@ -41,6 +41,8 @@ export declare class BaseReferenceObject extends ObjectClassType {
41
41
  private _refOffsetY;
42
42
  constructor(_token: string);
43
43
  dispose(): void;
44
+ getToken(): string;
45
+ setToken(token: string): void;
44
46
  isExceedRange(): boolean;
45
47
  setRefOffset(x?: number, y?: number): void;
46
48
  getRefOffset(): {
@@ -55,7 +57,7 @@ export declare class BaseReferenceObject extends ObjectClassType {
55
57
  };
56
58
  isReferenceObject(): boolean;
57
59
  iterator(callback: (valueObject: Nullable<BaseValueObject>, rowIndex: number, columnIndex: number) => Nullable<boolean>): Nullable<boolean>;
58
- getFirstCell(): ErrorValueObject | NullValueObject | NumberValueObject | StringValueObject | BooleanValueObject | ArrayValueObject;
60
+ getFirstCell(): ErrorValueObject | NullValueObject | NumberValueObject | import("../value-object/primitive-object").BooleanValueObject | import("../value-object/primitive-object").StringValueObject | ArrayValueObject;
59
61
  getRangeData(): IRange;
60
62
  setRangeData(range: IRange): void;
61
63
  getUnitId(): string;
@@ -98,16 +100,16 @@ export declare class BaseReferenceObject extends ObjectClassType {
98
100
  isTable(): boolean;
99
101
  unionBy(referenceObject: BaseReferenceObject): NodeValueType;
100
102
  unionRange(rangeData1: IRange, rangeData2: IRange): IRange;
101
- getCellValueObject(cell: ICellData): ErrorValueObject | NullValueObject | NumberValueObject | StringValueObject | BooleanValueObject | ArrayValueObject;
102
- getCellByRow(row: number): ErrorValueObject | NullValueObject | NumberValueObject | StringValueObject | BooleanValueObject | ArrayValueObject;
103
- getCellByColumn(column: number): ErrorValueObject | NullValueObject | NumberValueObject | StringValueObject | BooleanValueObject | ArrayValueObject;
103
+ getCellValueObject(cell: ICellData): ErrorValueObject | NullValueObject | NumberValueObject | import("../value-object/primitive-object").BooleanValueObject | import("../value-object/primitive-object").StringValueObject | ArrayValueObject;
104
+ getCellByRow(row: number): ErrorValueObject | NullValueObject | NumberValueObject | import("../value-object/primitive-object").BooleanValueObject | import("../value-object/primitive-object").StringValueObject | ArrayValueObject;
105
+ getCellByColumn(column: number): ErrorValueObject | NullValueObject | NumberValueObject | import("../value-object/primitive-object").BooleanValueObject | import("../value-object/primitive-object").StringValueObject | ArrayValueObject;
104
106
  getCurrentActiveSheetData(): import("../../basics/common").ISheetItem;
105
107
  getCurrentRuntimeSheetData(): import("@univerjs/core").ObjectMatrix<Nullable<ICellData>> | undefined;
106
108
  getCurrentActiveArrayFormulaCellData(): import("@univerjs/core").ObjectMatrix<Nullable<ICellData>> | undefined;
107
109
  getCurrentRuntimeActiveArrayFormulaCellData(): import("@univerjs/core").ObjectMatrix<Nullable<ICellData>> | undefined;
108
110
  getCellData(row: number, column: number): ICellData;
109
111
  getRuntimeFeatureCellValue(row: number, column: number): ICellData | undefined;
110
- getCellByPosition(row?: number, column?: number): ErrorValueObject | NullValueObject | NumberValueObject | StringValueObject | BooleanValueObject | ArrayValueObject;
112
+ getCellByPosition(row?: number, column?: number): ErrorValueObject | NullValueObject | NumberValueObject | import("../value-object/primitive-object").BooleanValueObject | import("../value-object/primitive-object").StringValueObject | ArrayValueObject;
111
113
  toArrayValueObject(useCache?: boolean): ArrayValueObject;
112
114
  toUnitRange(): {
113
115
  range: {
@@ -0,0 +1,25 @@
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
+ /**
17
+ * Korean in Excel does not count as two characters. Here we calculate all Chinese, Japanese and Korean characters as two characters.
18
+ *
19
+ * ā -> 1
20
+ * ー -> 2
21
+ *
22
+ * @param str
23
+ * @returns
24
+ */
25
+ export declare function charLenByte(str: string): number;
@@ -27,6 +27,5 @@ export declare function valueObjectCompare(range: BaseValueObject, criteria: Bas
27
27
  * Find the Boolean intersection of two ArrayValueObjects
28
28
  * @param valueObject1
29
29
  * @param valueObject2
30
- * @returns
31
30
  */
32
31
  export declare function booleanObjectIntersection(valueObject1: BaseValueObject, valueObject2: BaseValueObject): BaseValueObject;
@@ -58,7 +58,7 @@ export declare function deserializeRangeWithSheet(refString: string): IUnitRange
58
58
  * Determine whether the sheet name needs to be wrapped in quotes
59
59
  * Excel will quote the worksheet name if any of the following is true:
60
60
  * - It contains any space or punctuation characters, such as ()$,;-{}"'()【】“”‘’%… and many more
61
- * - It is a valid cell reference in A1 notation, e.g. B1048576 is quoted, B1048577 is not
61
+ * - It is a valid cell reference in A1 notation, e.g. B1048576 is quoted
62
62
  * - It is a valid cell reference in R1C1 notation, e.g. RC, RC2, R5C, R-4C, RC-8, R, C
63
63
  * - It starts with a non-letter, e.g. 99, 1.5, 12a, 💩a
64
64
  * - Excel will not quote worksheet names if they only contain non-punctuation, non-letter characters in non-initial positions. For example, a💩 remains unquoted.*
@@ -0,0 +1,16 @@
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
+ export {};
@@ -0,0 +1,16 @@
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
+ export {};
@@ -0,0 +1,16 @@
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
+ export {};
@@ -0,0 +1,16 @@
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
+ export {};
@@ -16,13 +16,14 @@
16
16
  import type { Nullable } from '@univerjs/core';
17
17
  import { compareToken } from '../../basics/token';
18
18
  import { ArrayBinarySearchType, ArrayOrderSearchType } from '../utils/compare';
19
- import type { callbackMapFnType, callbackProductFnType, IArrayValueObject } from './base-value-object';
19
+ import type { callbackMapFnType, IArrayValueObject } from './base-value-object';
20
20
  import { BaseValueObject, ErrorValueObject } from './base-value-object';
21
21
  import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from './primitive-object';
22
22
  export declare function fromObjectToString(array: IArrayValueObject): string;
23
23
  export declare function transformToValueObject(array?: Array<Array<number | string | boolean | null>>): BaseValueObject[][];
24
- export declare function transformToValue(array?: BaseValueObject[][]): (string | number | boolean | null)[][];
24
+ export declare function transformToValue(array?: Nullable<BaseValueObject>[][]): (string | number | boolean | null)[][];
25
25
  export declare class ArrayValueObject extends BaseValueObject {
26
+ static create(rawValue: string | IArrayValueObject): ArrayValueObject;
26
27
  private _values;
27
28
  private _rowCount;
28
29
  private _columnCount;
@@ -47,12 +48,12 @@ export declare class ArrayValueObject extends BaseValueObject {
47
48
  getSheetId(): string;
48
49
  getCurrentRow(): number;
49
50
  getCurrentColumn(): number;
50
- getArrayValue(): BaseValueObject[][];
51
+ getArrayValue(): Nullable<BaseValueObject>[][];
51
52
  setArrayValue(value: BaseValueObject[][]): void;
52
53
  isArray(): boolean;
53
- get(row: number, column: number): BaseValueObject;
54
+ get(row: number, column: number): BaseValueObject | null;
54
55
  getRealValue(row: number, column: number): BaseValueObject | null;
55
- set(row: number, column: number, value: BaseValueObject): void;
56
+ set(row: number, column: number, value: Nullable<BaseValueObject>): void;
56
57
  getRangePosition(): {
57
58
  startRow: number;
58
59
  endRow: number;
@@ -133,7 +134,6 @@ export declare class ArrayValueObject extends BaseValueObject {
133
134
  compare(valueObject: BaseValueObject, operator: compareToken): BaseValueObject;
134
135
  concatenateFront(valueObject: BaseValueObject): BaseValueObject;
135
136
  concatenateBack(valueObject: BaseValueObject): BaseValueObject;
136
- product(valueObject: BaseValueObject, callbackFn: callbackProductFnType): BaseValueObject;
137
137
  map(callbackFn: callbackMapFnType): BaseValueObject;
138
138
  mapValue(callbackFn: callbackMapFnType): BaseValueObject;
139
139
  pow(valueObject: BaseValueObject): BaseValueObject;
@@ -210,5 +210,5 @@ export declare class ArrayValueObject extends BaseValueObject {
210
210
  private _createNewArray;
211
211
  }
212
212
  export declare class ValueObjectFactory {
213
- static create(rawValue: string | number | boolean | null): ErrorValueObject | NullValueObject | NumberValueObject | StringValueObject | BooleanValueObject | ArrayValueObject;
213
+ static create(rawValue: string | number | boolean | null): ErrorValueObject | NullValueObject | NumberValueObject | BooleanValueObject | StringValueObject | ArrayValueObject;
214
214
  }
@@ -13,14 +13,15 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import type { Nullable } from '@univerjs/core';
17
+ import { FormulaAstLRU } from '../../basics/cache-lru';
16
18
  import { ConcatenateType } from '../../basics/common';
17
19
  import { ErrorType } from '../../basics/error-type';
18
20
  import { ObjectClassType } from '../../basics/object-class-type';
19
21
  import { compareToken } from '../../basics/token';
20
22
  export type callbackMapFnType = (currentValue: BaseValueObject, row: number, column: number) => BaseValueObject;
21
- export type callbackProductFnType = (currentValue: BaseValueObject, operationValue: BaseValueObject) => BaseValueObject;
22
23
  export interface IArrayValueObject {
23
- calculateValueList: BaseValueObject[][];
24
+ calculateValueList: Nullable<BaseValueObject>[][];
24
25
  rowCount: number;
25
26
  columnCount: number;
26
27
  unitId: string;
@@ -43,7 +44,7 @@ export declare class BaseValueObject extends ObjectClassType {
43
44
  unitId: string;
44
45
  };
45
46
  getValue(): string | number | boolean;
46
- getArrayValue(): BaseValueObject[][];
47
+ getArrayValue(): Nullable<BaseValueObject>[][];
47
48
  setValue(value: string | number | boolean): void;
48
49
  setArrayValue(value: BaseValueObject[][]): void;
49
50
  isCube(): boolean;
@@ -79,7 +80,6 @@ export declare class BaseValueObject extends ObjectClassType {
79
80
  * @returns
80
81
  */
81
82
  mapValue(callbackFn: callbackMapFnType): BaseValueObject;
82
- product(valueObject: BaseValueObject, callbackFn: callbackProductFnType): BaseValueObject;
83
83
  compare(valueObject: BaseValueObject, operator: compareToken): BaseValueObject;
84
84
  isEqual(valueObject: BaseValueObject): BaseValueObject;
85
85
  isNotEqual(valueObject: BaseValueObject): BaseValueObject;
@@ -148,10 +148,14 @@ export declare class BaseValueObject extends ObjectClassType {
148
148
  floorInverse(valueObject: BaseValueObject): BaseValueObject;
149
149
  ceil(valueObject: BaseValueObject): BaseValueObject;
150
150
  ceilInverse(valueObject: BaseValueObject): BaseValueObject;
151
+ convertToNumberObjectValue(): BaseValueObject;
152
+ convertToBooleanObjectValue(): BaseValueObject;
151
153
  }
154
+ export declare const ErrorValueObjectCache: FormulaAstLRU<ErrorValueObject>;
152
155
  export declare class ErrorValueObject extends BaseValueObject {
153
156
  private _errorType;
154
157
  private _errorContent;
158
+ static create(errorType: ErrorType, errorContent?: string): ErrorValueObject;
155
159
  constructor(_errorType: ErrorType, _errorContent?: string);
156
160
  getValue(): ErrorType;
157
161
  getErrorType(): ErrorType;
@@ -17,6 +17,7 @@ import type { ArrayValueObject } from './array-value-object';
17
17
  import { BaseValueObject } from './base-value-object';
18
18
  import { NumberValueObject } from './primitive-object';
19
19
  export declare class CubeValueObject extends BaseValueObject {
20
+ static create(values: ArrayValueObject[]): CubeValueObject;
20
21
  isCube(): boolean;
21
22
  private _values;
22
23
  constructor(values: ArrayValueObject[]);
@@ -21,6 +21,7 @@ export declare class LambdaValueObjectObject extends BaseValueObject {
21
21
  private _lambdaNode;
22
22
  private _interpreter;
23
23
  private _lambdaPrivacyVarKeys;
24
+ static create(lambdaNode: BaseAstNode, interpreter: Interpreter, lambdaPrivacyVarKeys: string[]): LambdaValueObjectObject;
24
25
  private _lambdaPrivacyValueMap;
25
26
  constructor(_lambdaNode: BaseAstNode, _interpreter: Interpreter, _lambdaPrivacyVarKeys: string[]);
26
27
  isLambda(): boolean;
@@ -14,9 +14,12 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { compareToken } from '../../basics/token';
17
- import { BaseValueObject } from './base-value-object';
17
+ import { FormulaAstLRU } from '../../basics/cache-lru';
18
+ import { BaseValueObject, ErrorValueObject } from './base-value-object';
18
19
  export type PrimitiveValueType = string | boolean | number | null;
19
20
  export declare class NullValueObject extends BaseValueObject {
21
+ private static _instance;
22
+ static create(): NullValueObject;
20
23
  isNull(): boolean;
21
24
  plus(valueObject: BaseValueObject): BaseValueObject;
22
25
  minus(valueObject: BaseValueObject): BaseValueObject;
@@ -52,10 +55,15 @@ export declare class NullValueObject extends BaseValueObject {
52
55
  round(valueObject: BaseValueObject): BaseValueObject;
53
56
  floor(valueObject: BaseValueObject): BaseValueObject;
54
57
  ceil(valueObject: BaseValueObject): BaseValueObject;
58
+ convertToNumberObjectValue(): NumberValueObject;
59
+ convertToBooleanObjectValue(): BooleanValueObject;
55
60
  }
56
61
  export declare class BooleanValueObject extends BaseValueObject {
57
62
  private _value;
58
- constructor(rawValue: string | number | boolean, isForce?: boolean);
63
+ private static _instanceTrue;
64
+ private static _instanceFalse;
65
+ static create(value: boolean): BooleanValueObject;
66
+ constructor(rawValue: boolean);
59
67
  getValue(): boolean;
60
68
  isBoolean(): boolean;
61
69
  getNegative(): BaseValueObject;
@@ -90,10 +98,14 @@ export declare class BooleanValueObject extends BaseValueObject {
90
98
  round(valueObject: BaseValueObject): BaseValueObject;
91
99
  floor(valueObject: BaseValueObject): BaseValueObject;
92
100
  ceil(valueObject: BaseValueObject): BaseValueObject;
101
+ convertToNumberObjectValue(): ErrorValueObject | NumberValueObject;
102
+ convertToBooleanObjectValue(): this;
93
103
  }
104
+ export declare const NumberValueObjectCache: FormulaAstLRU<NumberValueObject>;
94
105
  export declare class NumberValueObject extends BaseValueObject {
95
106
  private _value;
96
- constructor(rawValue: string | number | boolean, isForce?: boolean);
107
+ static create(value: number, pattern?: string): NumberValueObject;
108
+ constructor(rawValue: number);
97
109
  getValue(): number;
98
110
  setValue(value: number): void;
99
111
  isNumber(): boolean;
@@ -134,16 +146,25 @@ export declare class NumberValueObject extends BaseValueObject {
134
146
  round(valueObject: BaseValueObject): BaseValueObject;
135
147
  floor(valueObject: BaseValueObject): BaseValueObject;
136
148
  ceil(valueObject: BaseValueObject): BaseValueObject;
149
+ convertToNumberObjectValue(): this;
150
+ convertToBooleanObjectValue(): BooleanValueObject;
137
151
  private _compareInfinity;
138
152
  }
153
+ export declare const StringValueObjectCache: FormulaAstLRU<StringValueObject>;
139
154
  export declare class StringValueObject extends BaseValueObject {
140
155
  private _value;
141
- constructor(rawValue: string | number | boolean, isForce?: boolean);
156
+ static create(value: string): StringValueObject;
157
+ constructor(rawValue: string);
142
158
  getValue(): string;
143
159
  isString(): boolean;
144
160
  concatenateFront(valueObject: BaseValueObject): BaseValueObject;
145
161
  concatenateBack(valueObject: BaseValueObject): BaseValueObject;
146
162
  compare(valueObject: BaseValueObject, operator: compareToken): BaseValueObject;
147
163
  compareBy(value: string | number | boolean, operator: compareToken): BaseValueObject;
164
+ convertToNumberObjectValue(): ErrorValueObject | NumberValueObject;
165
+ convertToBooleanObjectValue(): BooleanValueObject;
148
166
  private _checkWildcard;
149
167
  }
168
+ export declare function createBooleanValueObjectByRawValue(rawValue: string | number | boolean): BooleanValueObject;
169
+ export declare function createStringValueObjectByRawValue(rawValue: string | number | boolean): StringValueObject;
170
+ export declare function createNumberValueObjectByRawValue(rawValue: string | number | boolean): ErrorValueObject | NumberValueObject;
@@ -13,10 +13,10 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { Nullable } from '@univerjs/core';
16
+ import type { IRange, Nullable } from '@univerjs/core';
17
17
  import { Disposable } from '@univerjs/core';
18
18
  import type { IFunctionNames } from '../basics/function';
19
- import type { FunctionVariantType, NodeValueType } from '../engine/reference-object/base-reference-object';
19
+ import type { BaseReferenceObject, FunctionVariantType, NodeValueType } from '../engine/reference-object/base-reference-object';
20
20
  import type { ArrayBinarySearchType } from '../engine/utils/compare';
21
21
  import { ArrayOrderSearchType } from '../engine/utils/compare';
22
22
  import type { ArrayValueObject } from '../engine/value-object/array-value-object';
@@ -54,7 +54,6 @@ export declare class BaseFunction extends Disposable {
54
54
  * For instance, The column number (starting with 1 for the left-most column of table_array) that contains the return value.
55
55
  * https://support.microsoft.com/en-us/office/vlookup-function-0bbc8083-26fe-4963-8ab8-93a18ad188a1
56
56
  * @param indexNum
57
- * @returns
58
57
  */
59
58
  getIndexNumValue(indexNum: BaseValueObject, defaultValue?: number): number | ErrorValueObject;
60
59
  /**
@@ -68,28 +67,24 @@ export declare class BaseFunction extends Disposable {
68
67
  * If a1 is FALSE, ref_text is interpreted as an R1C1-style reference.
69
68
  * https://support.microsoft.com/zh-cn/office/indirect-%E5%87%BD%E6%95%B0-474b3a3a-8a26-4f44-b491-92b6306fa261
70
69
  * @param logicValueObject
71
- * @returns
72
70
  */
73
71
  getZeroOrOneByOneDefault(logicValueObject?: BaseValueObject): number | undefined;
74
72
  /**
75
73
  * A logical value that specifies 1/TRUE , 0/FALSE, -1, default 1.
76
74
  * The difference from getZeroOrOneByOneDefault is that we need to get -1
77
75
  * @param logicValueObject
78
- * @returns
79
76
  */
80
77
  getMatchTypeValue(logicValueObject?: BaseValueObject): number | undefined;
81
78
  binarySearch(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, searchType?: ArrayBinarySearchType): BaseValueObject;
82
79
  equalSearch(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, isFirst?: boolean): BaseValueObject;
83
80
  fuzzySearch(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, isFirst?: boolean): BaseValueObject;
84
81
  orderSearch(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, searchType?: ArrayOrderSearchType, isDesc?: boolean): BaseValueObject;
85
- /**
86
- * @param axis 0 row, 1 column
87
- * @returns
88
- */
89
82
  binarySearchExpand(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, axis?: number, searchType?: ArrayBinarySearchType): ErrorValueObject | ArrayValueObject | undefined;
90
83
  equalSearchExpand(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, isFirst?: boolean, axis?: number): ErrorValueObject | ArrayValueObject | undefined;
91
84
  fuzzySearchExpand(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, isFirst?: boolean, axis?: number): ErrorValueObject | ArrayValueObject | undefined;
92
85
  orderSearchExpand(value: BaseValueObject, searchArray: ArrayValueObject, resultArray: ArrayValueObject, searchType?: ArrayOrderSearchType, isDesc?: boolean, axis?: number): ErrorValueObject | ArrayValueObject | undefined;
93
86
  flattenArray(variants: BaseValueObject[], ignoreLogicalValuesAndText?: boolean): ArrayValueObject | BaseValueObject;
94
87
  private _includingLogicalValuesAndText;
88
+ createReferenceObject(reference: BaseReferenceObject, range: IRange): ErrorValueObject | BaseReferenceObject;
89
+ private _setReferenceDefault;
95
90
  }
@@ -0,0 +1,16 @@
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
+ export {};
@@ -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 Or extends BaseFunction {
19
+ calculate(...logicalValues: BaseValueObject[]): BaseValueObject;
20
+ }
@@ -13,14 +13,11 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { Address } from './address';
17
16
  import { Column } from './column';
18
17
  import { FUNCTION_NAMES_LOOKUP } from './function-names';
19
- import { Indirect } from './indirect';
20
18
  import { Lookup } from './lookup';
21
19
  import { Match } from './match';
22
20
  import { Offset } from './offset';
23
21
  import { Xlookup } from './xlookup';
24
22
  import { Xmatch } from './xmatch';
25
- import { Index } from './index';
26
- export declare const functionLookup: ((FUNCTION_NAMES_LOOKUP | typeof Address)[] | (FUNCTION_NAMES_LOOKUP | typeof Column)[] | (FUNCTION_NAMES_LOOKUP | typeof Index)[] | (FUNCTION_NAMES_LOOKUP | typeof Indirect)[] | (FUNCTION_NAMES_LOOKUP | typeof Offset)[] | (FUNCTION_NAMES_LOOKUP | typeof Lookup)[] | (FUNCTION_NAMES_LOOKUP | typeof Match)[] | (FUNCTION_NAMES_LOOKUP | typeof Xlookup)[] | (FUNCTION_NAMES_LOOKUP | typeof Xmatch)[])[];
23
+ export declare const functionLookup: ((FUNCTION_NAMES_LOOKUP | typeof Column)[] | (FUNCTION_NAMES_LOOKUP | typeof Offset)[] | (FUNCTION_NAMES_LOOKUP | typeof Lookup)[] | (FUNCTION_NAMES_LOOKUP | typeof Match)[] | (FUNCTION_NAMES_LOOKUP | typeof Xlookup)[] | (FUNCTION_NAMES_LOOKUP | typeof Xmatch)[])[];