@univerjs/engine-formula 0.4.0 → 0.4.1-experimental.20241023-bbb123f

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 (113) hide show
  1. package/lib/cjs/index.js +2 -2
  2. package/lib/es/index.js +2882 -883
  3. package/lib/types/basics/database.d.ts +31 -0
  4. package/lib/types/basics/inverted-index-cache.d.ts +7 -18
  5. package/lib/types/basics/math.d.ts +12 -0
  6. package/lib/types/basics/object-class-type.d.ts +17 -2
  7. package/lib/types/basics/regex.d.ts +19 -2
  8. package/lib/types/engine/analysis/__tests__/dependency.spec.d.ts +16 -0
  9. package/lib/types/engine/analysis/parser.d.ts +1 -2
  10. package/lib/types/engine/ast-node/base-ast-node-factory.d.ts +3 -2
  11. package/lib/types/engine/ast-node/base-ast-node.d.ts +2 -9
  12. package/lib/types/engine/ast-node/function-node.d.ts +1 -0
  13. package/lib/types/engine/ast-node/reference-node.d.ts +9 -2
  14. package/lib/types/engine/dependency/dependency-tree.d.ts +16 -8
  15. package/lib/types/engine/dependency/formula-dependency.d.ts +1 -0
  16. package/lib/types/engine/interpreter/interpreter.d.ts +3 -2
  17. package/lib/types/engine/reference-object/base-reference-object.d.ts +10 -0
  18. package/lib/types/engine/utils/ast-node-tool.d.ts +10 -0
  19. package/lib/types/engine/utils/char-kit.d.ts +5 -7
  20. package/lib/types/engine/utils/numfmt-kit.d.ts +14 -1
  21. package/lib/types/engine/utils/reference-cache.d.ts +3 -0
  22. package/lib/types/engine/value-object/array-value-object.d.ts +1 -0
  23. package/lib/types/engine/value-object/lambda-value-object.d.ts +2 -2
  24. package/lib/types/functions/base-function.d.ts +13 -5
  25. package/lib/types/functions/database/daverage/__tests__/index.spec.d.ts +16 -0
  26. package/lib/types/functions/database/daverage/index.d.ts +8 -0
  27. package/lib/types/functions/database/dcount/__tests__/index.spec.d.ts +16 -0
  28. package/lib/types/functions/database/dcount/index.d.ts +8 -0
  29. package/lib/types/functions/database/dcounta/__tests__/index.spec.d.ts +16 -0
  30. package/lib/types/functions/database/dcounta/index.d.ts +8 -0
  31. package/lib/types/functions/database/dget/__tests__/index.spec.d.ts +16 -0
  32. package/lib/types/functions/database/dget/index.d.ts +7 -0
  33. package/lib/types/functions/database/dmax/__tests__/index.spec.d.ts +16 -0
  34. package/lib/types/functions/database/dmax/index.d.ts +8 -0
  35. package/lib/types/functions/database/dmin/__tests__/index.spec.d.ts +16 -0
  36. package/lib/types/functions/database/dmin/index.d.ts +8 -0
  37. package/lib/types/functions/database/dproduct/__tests__/index.spec.d.ts +16 -0
  38. package/lib/types/functions/database/dproduct/index.d.ts +8 -0
  39. package/lib/types/functions/database/dstdev/__tests__/index.spec.d.ts +16 -0
  40. package/lib/types/functions/database/dstdev/index.d.ts +8 -0
  41. package/lib/types/functions/database/dstdevp/__tests__/index.spec.d.ts +16 -0
  42. package/lib/types/functions/database/dstdevp/index.d.ts +8 -0
  43. package/lib/types/functions/database/dsum/__tests__/index.spec.d.ts +16 -0
  44. package/lib/types/functions/database/dsum/index.d.ts +8 -0
  45. package/lib/types/functions/database/dvar/__tests__/index.spec.d.ts +16 -0
  46. package/lib/types/functions/database/dvar/index.d.ts +8 -0
  47. package/lib/types/functions/database/dvarp/__tests__/index.spec.d.ts +16 -0
  48. package/lib/types/functions/database/dvarp/index.d.ts +8 -0
  49. package/lib/types/functions/database/function-map.d.ts +3 -16
  50. package/lib/types/functions/financial/db/index.d.ts +1 -0
  51. package/lib/types/functions/financial/ddb/index.d.ts +1 -0
  52. package/lib/types/functions/financial/fv/index.d.ts +2 -1
  53. package/lib/types/functions/financial/ipmt/index.d.ts +2 -1
  54. package/lib/types/functions/financial/npv/index.d.ts +1 -0
  55. package/lib/types/functions/financial/pmt/index.d.ts +2 -1
  56. package/lib/types/functions/financial/ppmt/index.d.ts +2 -1
  57. package/lib/types/functions/financial/pv/index.d.ts +2 -1
  58. package/lib/types/functions/financial/sln/index.d.ts +1 -0
  59. package/lib/types/functions/financial/syd/index.d.ts +1 -0
  60. package/lib/types/functions/financial/tbillprice/index.d.ts +1 -0
  61. package/lib/types/functions/financial/vdb/index.d.ts +1 -0
  62. package/lib/types/functions/math/arabic/__tests__/index.spec.d.ts +16 -0
  63. package/lib/types/functions/math/arabic/index.d.ts +8 -0
  64. package/lib/types/functions/math/roman/__tests__/index.spec.d.ts +16 -0
  65. package/lib/types/functions/math/roman/index.d.ts +9 -0
  66. package/lib/types/functions/text/arraytotext/__test__/index.spec.d.ts +16 -0
  67. package/lib/types/functions/text/arraytotext/index.d.ts +9 -0
  68. package/lib/types/functions/text/asc/__test__/index.spec.d.ts +16 -0
  69. package/lib/types/functions/text/asc/index.d.ts +8 -0
  70. package/lib/types/functions/text/bahttext/__test__/index.spec.d.ts +16 -0
  71. package/lib/types/functions/text/bahttext/index.d.ts +9 -0
  72. package/lib/types/functions/text/char/__test__/index.spec.d.ts +16 -0
  73. package/lib/types/functions/text/char/index.d.ts +8 -0
  74. package/lib/types/functions/text/clean/__test__/index.spec.d.ts +16 -0
  75. package/lib/types/functions/text/clean/index.d.ts +8 -0
  76. package/lib/types/functions/text/code/__test__/index.spec.d.ts +16 -0
  77. package/lib/types/functions/text/code/index.d.ts +8 -0
  78. package/lib/types/functions/text/dbcs/__test__/index.spec.d.ts +16 -0
  79. package/lib/types/functions/text/dbcs/index.d.ts +8 -0
  80. package/lib/types/functions/text/dollar/__test__/index.spec.d.ts +16 -0
  81. package/lib/types/functions/text/dollar/index.d.ts +9 -0
  82. package/lib/types/functions/text/exact/__test__/index.spec.d.ts +16 -0
  83. package/lib/types/functions/text/exact/index.d.ts +8 -0
  84. package/lib/types/functions/text/fixed/__test__/index.spec.d.ts +16 -0
  85. package/lib/types/functions/text/fixed/index.d.ts +8 -0
  86. package/lib/types/functions/text/leftb/index.d.ts +1 -2
  87. package/lib/types/functions/text/numbervalue/__test__/index.spec.d.ts +16 -0
  88. package/lib/types/functions/text/numbervalue/index.d.ts +8 -0
  89. package/lib/types/functions/text/proper/__test__/index.spec.d.ts +16 -0
  90. package/lib/types/functions/text/proper/index.d.ts +8 -0
  91. package/lib/types/functions/text/right/__test__/index.spec.d.ts +16 -0
  92. package/lib/types/functions/text/right/index.d.ts +8 -0
  93. package/lib/types/functions/text/rightb/__test__/index.spec.d.ts +16 -0
  94. package/lib/types/functions/text/rightb/index.d.ts +8 -0
  95. package/lib/types/functions/text/substitute/__test__/index.spec.d.ts +16 -0
  96. package/lib/types/functions/text/substitute/index.d.ts +9 -0
  97. package/lib/types/functions/text/t/__test__/index.spec.d.ts +16 -0
  98. package/lib/types/functions/text/t/index.d.ts +7 -0
  99. package/lib/types/functions/text/unichar/__test__/index.spec.d.ts +16 -0
  100. package/lib/types/functions/text/unichar/index.d.ts +8 -0
  101. package/lib/types/functions/text/unicode/__test__/index.spec.d.ts +16 -0
  102. package/lib/types/functions/text/unicode/index.d.ts +8 -0
  103. package/lib/types/functions/text/value/__test__/index.spec.d.ts +16 -0
  104. package/lib/types/functions/text/value/index.d.ts +8 -0
  105. package/lib/types/functions/text/valuetotext/__test__/index.spec.d.ts +16 -0
  106. package/lib/types/functions/text/valuetotext/index.d.ts +8 -0
  107. package/lib/types/services/current-data.service.d.ts +5 -2
  108. package/lib/types/services/dependency-manager.service.d.ts +21 -15
  109. package/lib/types/services/runtime.service.d.ts +2 -0
  110. package/lib/umd/index.js +2 -2
  111. package/package.json +5 -4
  112. package/LICENSE +0 -176
  113. package/lib/types/engine/dependency/generate-tree-id.d.ts +0 -2
@@ -0,0 +1,31 @@
1
+ import { BaseValueObject, ErrorValueObject } from '../engine/value-object/base-value-object';
2
+ type DatabaseValueType = string | number | null;
3
+ export declare function checkDatabase(database: BaseValueObject): {
4
+ isError: boolean;
5
+ errorObject: ErrorValueObject;
6
+ databaseValues: DatabaseValueType[][];
7
+ } | {
8
+ isError: boolean;
9
+ errorObject: null;
10
+ databaseValues: DatabaseValueType[][];
11
+ };
12
+ export declare function checkField(field: BaseValueObject, database: DatabaseValueType[][]): {
13
+ isError: boolean;
14
+ errorObject: ErrorValueObject;
15
+ fieldIndex: number;
16
+ } | {
17
+ isError: boolean;
18
+ errorObject: null;
19
+ fieldIndex: number;
20
+ };
21
+ export declare function checkCriteria(criteria: BaseValueObject): {
22
+ isError: boolean;
23
+ errorObject: ErrorValueObject;
24
+ criteriaValues: DatabaseValueType[][];
25
+ } | {
26
+ isError: boolean;
27
+ errorObject: null;
28
+ criteriaValues: DatabaseValueType[][];
29
+ };
30
+ export declare function isCriteriaMatch(criteria: DatabaseValueType[][], database: DatabaseValueType[][], databaseRowIndex: number): boolean;
31
+ export {};
@@ -1,18 +1,4 @@
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
- */
1
+ import { NumericTuple } from '@flatten-js/interval-tree';
16
2
  export declare class InvertedIndexCache {
17
3
  /**
18
4
  * {
@@ -30,11 +16,14 @@ export declare class InvertedIndexCache {
30
16
  private _continueBuildingCache;
31
17
  set(unitId: string, sheetId: string, column: number, value: string | number | boolean | null, row: number): void;
32
18
  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
- getCellPosition(unitId: string, sheetId: string, column: number, value: string | number | boolean, startRow: number, endRow: number): number | undefined;
19
+ getCellPositions(unitId: string, sheetId: string, column: number, value: string | number | boolean, rowsInCache: NumericTuple[]): number[] | undefined;
35
20
  setContinueBuildingCache(unitId: string, sheetId: string, column: number, startRow: number, endRow: number): void;
36
21
  shouldContinueBuildingCache(unitId: string, sheetId: string, column: number, row: number): boolean;
37
- canUseCache(unitId: string, sheetId: string, column: number, rangeStartRow: number, rangeEndRow: number): boolean;
22
+ canUseCache(unitId: string, sheetId: string, column: number, rangeStartRow: number, rangeEndRow: number): {
23
+ rowsInCache: NumericTuple[];
24
+ rowsNotInCache: NumericTuple[];
25
+ };
38
26
  clear(): void;
27
+ private _handleNewInterval;
39
28
  }
40
29
  export declare const CELL_INVERTED_INDEX_CACHE: InvertedIndexCache;
@@ -19,3 +19,15 @@ export declare function calculateGcd(a: number, b: number): number;
19
19
  export declare function calculateLcm(a: number, b: number): number;
20
20
  export declare function calculateMdeterm(matrix: number[][]): number;
21
21
  export declare function calculateMinverse(matrix: number[][]): number[][] | null;
22
+ export declare const romanToArabicMap: Map<string, number>;
23
+ export declare const arabicToRomanMap: Map<number, string>;
24
+ /**
25
+ * form: A number specifying the type of roman numeral you want.
26
+ * The roman numeral style ranges from Classic to Simplified, becoming more concise as the value of form increases
27
+ * 0 Classic
28
+ * 1 More concise
29
+ * 2 More concise
30
+ * 3 More concise
31
+ * 4 Simplified
32
+ */
33
+ export declare const romanFormArray: number[][];
@@ -1,6 +1,21 @@
1
- import { Disposable } from '@univerjs/core';
2
- export declare class ObjectClassType extends Disposable {
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 declare class ObjectClassType {
3
17
  pattern: string;
18
+ dispose(): void;
4
19
  getPattern(): string;
5
20
  /**
6
21
  * Only used in NumberValueObject
@@ -14,20 +14,37 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export declare const UNIT_NAME_REGEX = "\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\]";
17
+ export declare const UNIT_NAME_REGEX_PRECOMPILING: RegExp;
17
18
  export declare const SHEET_NAME_REGEX = "((?![\\[\\]\\/?*\\\\]).)*!";
18
19
  export declare const ABSOLUTE_SYMBOL = "$";
19
20
  export declare const RANGE_SYMBOL = "\\s*?:\\s*?";
20
21
  export declare const UNIT_NAME_SHEET_NAME_REGEX = "'?(\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\])?(((?![\\[\\]\\/?*\\\\]).)*!)?'?";
21
22
  export declare const SIMPLE_SINGLE_RANGE_REGEX = "\\$?[A-Za-z]+\\$?[1-9][0-9]*";
22
23
  export declare const REFERENCE_MULTIPLE_RANGE_REGEX = "^(@)?'?(\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\])?(((?![\\[\\]\\/?*\\\\]).)*!)?'?\\$?[A-Za-z]+\\$?[1-9][0-9]*\\s*?:\\s*?\\$?[A-Za-z]+\\$?[1-9][0-9]*$";
24
+ export declare const REFERENCE_MULTIPLE_RANGE_REGEX_PRECOMPILING: RegExp;
23
25
  export declare const REFERENCE_SINGLE_RANGE_REGEX = "^'?(\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\])?(((?![\\[\\]\\/?*\\\\]).)*!)?'?\\s*?\\$?[A-Za-z]+\\$?[1-9][0-9]*(#)?$";
26
+ export declare const REFERENCE_SINGLE_RANGE_REGEX_PRECOMPILING: RegExp;
24
27
  export declare const REFERENCE_REGEX_ROW = "^'?(\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\])?(((?![\\[\\]\\/?*\\\\]).)*!)?'?\\$?[1-9][0-9]*\\s*?:\\s*?\\$?[1-9][0-9]*$";
28
+ export declare const REFERENCE_REGEX_ROW_PRECOMPILING: RegExp;
25
29
  export declare const REFERENCE_REGEX_COLUMN = "^'?(\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\])?(((?![\\[\\]\\/?*\\\\]).)*!)?'?\\$?[A-Za-z]+\\s*?:\\s*?\\$?[A-Za-z]+$";
30
+ export declare const REFERENCE_REGEX_COLUMN_PRECOMPILING: RegExp;
26
31
  export declare const REFERENCE_REGEX_SINGLE_ROW = "^'?(\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\])?(((?![\\[\\]\\/?*\\\\]).)*!)?'?\\s*?\\$?[1-9][0-9]*$";
32
+ export declare const REFERENCE_REGEX_SINGLE_ROW_PRECOMPILING: RegExp;
27
33
  export declare const REFERENCE_REGEX_SINGLE_COLUMN = "^'?(\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\])?(((?![\\[\\]\\/?*\\\\]).)*!)?'?\\s*?\\$?[A-Za-z]+$";
34
+ export declare const REFERENCE_REGEX_SINGLE_COLUMN_PRECOMPILING: RegExp;
28
35
  export declare const REFERENCE_TABLE_ALL_COLUMN_REGEX = "^(\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\])?((?![~!@#$%^&*()_+<>?:,./;\u2019\uFF0C\u3002\u3001\u2018\uFF1A\u201C\u300A\u300B\uFF1F~\uFF01@#\uFFE5%\u2026\u2026\uFF08\uFF09\u3010\u3011\\[\\]\\/\\\\]).)+$";
29
36
  export declare const REFERENCE_TABLE_SINGLE_COLUMN_REGEX = "^(\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\])?((?![~!@#$%^&*()_+<>?:,./;\u2019\uFF0C\u3002\u3001\u2018\uFF1A\u201C\u300A\u300B\uFF1F~\uFF01@#\uFFE5%\u2026\u2026\uFF08\uFF09\u3010\u3011\\[\\]\\/\\\\]).)+(\\[((?<!#).)*\\]|\\[\\[#.+\\]\\s*?,\\s*?\\[((?<!#).)*\\]\\])+$";
30
37
  export declare const REFERENCE_TABLE_MULTIPLE_COLUMN_REGEX = "^(\\[([^\\[\\]\\/?:\"<>|*\\\\]+)\\])?((?![~!@#$%^&*()_+<>?:,./;\u2019\uFF0C\u3002\u3001\u2018\uFF1A\u201C\u300A\u300B\uFF1F~\uFF01@#\uFFE5%\u2026\u2026\uFF08\uFF09\u3010\u3011\\[\\]\\/\\\\]).)+(\\[\\[((?<!#).)*\\]\\s*?:\\s*?\\[((?<!#).)*\\]\\])?$|^((?![~!@#$%^&*()_+<>?:,./;\u2019\uFF0C\u3002\u3001\u2018\uFF1A\u201C\u300A\u300B\uFF1F~\uFF01@#\uFFE5%\u2026\u2026\uFF08\uFF09\u3010\u3011\\[\\]\\/\\\\]).)+(\\[\\[#.+\\]\\s*?,\\s*?\\[((?<!#).)*\\]\\s*?:\\s*?\\[((?<!#).)*\\]\\])?$";
31
- export declare const $SUPER_TABLE_COLUMN_REGEX = "[.*?]";
32
- export declare const $ARRAY_VALUE_REGEX = "{.*?}";
38
+ export declare const SUPER_TABLE_COLUMN_REGEX = "[.*?]";
39
+ export declare const SUPER_TABLE_COLUMN_REGEX_PRECOMPILING: RegExp;
40
+ export declare const ARRAY_VALUE_REGEX = "{.*?}";
41
+ export declare const ARRAY_VALUE_REGEX_PRECOMPILING: RegExp;
42
+ export declare function regexTestSingeRange(token: string): boolean;
43
+ export declare function regexTestMultipleRange(token: string): boolean;
44
+ export declare function regexTestRow(token: string): boolean;
45
+ export declare function regexTestColumn(token: string): boolean;
46
+ export declare function regexTestSingleRow(token: string): boolean;
47
+ export declare function regexTestSingleColumn(token: string): boolean;
48
+ export declare function regexTestSuperTableColumn(token: string): boolean;
49
+ export declare function regexTestArrayValue(token: string): boolean;
33
50
  export declare function isReferenceString(refString: string): boolean;
@@ -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 {};
@@ -29,11 +29,10 @@ export declare class AstTreeBuilder extends Disposable {
29
29
  private _refOffsetY;
30
30
  constructor(_runtimeService: IFormulaRuntimeService, _astRootNodeFactory: AstRootNodeFactory, _functionNodeFactory: FunctionNodeFactory, _lambdaNodeFactory: LambdaNodeFactory, _lambdaParameterNodeFactory: LambdaParameterNodeFactory, _operatorNodeFactory: OperatorNodeFactory, _prefixNodeFactory: PrefixNodeFactory, _referenceNodeFactory: ReferenceNodeFactory, _suffixNodeFactory: SuffixNodeFactory, _unionNodeFactory: UnionNodeFactory, _valueNodeFactory: ValueNodeFactory);
31
31
  dispose(): void;
32
- parse(lexerNode: LexerNode, refOffsetX?: number, refOffsetY?: number): Nullable<BaseAstNode>;
32
+ parse(lexerNode: LexerNode): Nullable<BaseAstNode>;
33
33
  private _lambdaParameterHandler;
34
34
  private _changeLetToLambda;
35
35
  private _parse;
36
- private _setPrefixRefOffset;
37
36
  private _checkAstNode;
38
37
  private _initializeAstNode;
39
38
  }
@@ -1,9 +1,10 @@
1
- import { Nullable, Disposable } from '@univerjs/core';
1
+ import { Nullable } from '@univerjs/core';
2
2
  import { LexerNode } from '../analysis/lexer-node';
3
3
  import { BaseAstNode } from './base-ast-node';
4
4
  export declare const DEFAULT_AST_NODE_FACTORY_Z_INDEX = 100;
5
- export declare abstract class BaseAstNodeFactory extends Disposable {
5
+ export declare abstract class BaseAstNodeFactory {
6
6
  get zIndex(): number;
7
+ dispose(): void;
7
8
  create(param: LexerNode | string, currentRow?: number, currentColumn?: number): BaseAstNode;
8
9
  abstract checkAndCreateNodeType(param: LexerNode | string): Nullable<BaseAstNode>;
9
10
  }
@@ -1,4 +1,4 @@
1
- import { Nullable, Disposable } from '@univerjs/core';
1
+ import { Nullable } from '@univerjs/core';
2
2
  import { ErrorType } from '../../basics/error-type';
3
3
  import { FunctionVariantType } from '../reference-object/base-reference-object';
4
4
  import { AstNodePromiseType } from '../../basics/common';
@@ -10,7 +10,7 @@ interface IAstNodeNodeJson {
10
10
  nodeType: string;
11
11
  }
12
12
  export type LambdaPrivacyVarType = Map<string, Nullable<BaseAstNode>>;
13
- export declare class BaseAstNode extends Disposable {
13
+ export declare class BaseAstNode {
14
14
  private _token;
15
15
  private _children;
16
16
  private _definedNames;
@@ -19,8 +19,6 @@ export declare class BaseAstNode extends Disposable {
19
19
  private _calculateState;
20
20
  private _async;
21
21
  private _address;
22
- private _refOffsetX;
23
- private _refOffsetY;
24
22
  private _isForcedCalculateFunction;
25
23
  constructor(_token: string);
26
24
  dispose(): void;
@@ -42,11 +40,6 @@ export declare class BaseAstNode extends Disposable {
42
40
  setCalculated(): void;
43
41
  execute(): void;
44
42
  setNotEmpty(state?: boolean): void;
45
- setRefOffset(x?: number, y?: number): void;
46
- getRefOffset(): {
47
- x: number;
48
- y: number;
49
- };
50
43
  executeAsync(): Promise<AstNodePromiseType>;
51
44
  serialize(): IAstNodeNodeJson;
52
45
  hasDefinedName(definedName: string): boolean;
@@ -34,6 +34,7 @@ export declare class FunctionNode extends BaseAstNode {
34
34
  private _setDefinedNamesForFunction;
35
35
  private _setRefInfo;
36
36
  private _setRefData;
37
+ private _setLocale;
37
38
  }
38
39
  export declare class ErrorFunctionNode extends BaseAstNode {
39
40
  constructor(token?: string);
@@ -1,9 +1,9 @@
1
1
  import { IAccessor, Injector } from '@univerjs/core';
2
+ import { BaseReferenceObject } from '../reference-object/base-reference-object';
3
+ import { IFunctionService } from '../../services/function.service';
2
4
  import { IFormulaRuntimeService } from '../../services/runtime.service';
3
5
  import { ISuperTableService } from '../../services/super-table.service';
4
6
  import { LexerNode } from '../analysis/lexer-node';
5
- import { BaseReferenceObject } from '../reference-object/base-reference-object';
6
- import { IFunctionService } from '../../services/function.service';
7
7
  import { BaseAstNode } from './base-ast-node';
8
8
  import { BaseAstNodeFactory } from './base-ast-node-factory';
9
9
  import { NodeType } from './node-type';
@@ -12,9 +12,16 @@ export declare class ReferenceNode extends BaseAstNode {
12
12
  private _operatorString;
13
13
  private _referenceObject;
14
14
  private _isPrepareMerge;
15
+ private _refOffsetX;
16
+ private _refOffsetY;
15
17
  constructor(_accessor: IAccessor, _operatorString: string, _referenceObject: BaseReferenceObject, _isPrepareMerge?: boolean);
16
18
  get nodeType(): NodeType;
17
19
  execute(): void;
20
+ setRefOffset(x?: number, y?: number): void;
21
+ getRefOffset(): {
22
+ x: number;
23
+ y: number;
24
+ };
18
25
  }
19
26
  export declare class ReferenceNodeFactory extends BaseAstNodeFactory {
20
27
  private readonly _superTableService;
@@ -1,8 +1,8 @@
1
- import { IRange, IRTreeItem, IUnitRange, Nullable, Disposable } from '@univerjs/core';
1
+ import { IRange, IRTreeItem, IUnitRange, Nullable } from '@univerjs/core';
2
2
  import { IDirtyUnitSheetNameMap, IFeatureDirtyRangeType, IRuntimeUnitDataType, IUnitExcludedCell } from '../../basics/common';
3
3
  import { IFormulaDirtyData } from '../../services/current-data.service';
4
4
  import { IAllRuntimeData } from '../../services/runtime.service';
5
- import { BaseAstNode } from '../ast-node/base-ast-node';
5
+ import { IExecuteAstNodeData } from '../utils/ast-node-tool';
6
6
  export declare enum FDtreeStateType {
7
7
  DEFAULT = 0,
8
8
  ADDED = 1,
@@ -12,11 +12,11 @@ export declare enum FDtreeStateType {
12
12
  * A dependency tree, capable of calculating mutual dependencies,
13
13
  * is used to determine the order of formula calculations.
14
14
  */
15
- export declare class FormulaDependencyTree extends Disposable {
15
+ export declare class FormulaDependencyTree {
16
16
  treeId: string;
17
- node: Nullable<BaseAstNode>;
18
- children: Set<FormulaDependencyTree>;
19
- parents: Set<FormulaDependencyTree>;
17
+ nodeData: Nullable<IExecuteAstNodeData>;
18
+ children: Set<string>;
19
+ parents: Set<string>;
20
20
  formula: string;
21
21
  row: number;
22
22
  column: number;
@@ -29,13 +29,21 @@ export declare class FormulaDependencyTree extends Disposable {
29
29
  featureId: Nullable<string>;
30
30
  isCache: boolean;
31
31
  constructor(treeId?: string);
32
+ toJson(): {
33
+ formula: string;
34
+ row: number;
35
+ column: number;
36
+ subUnitId: string;
37
+ unitId: string;
38
+ formulaId: Nullable<string>;
39
+ featureId: Nullable<string>;
40
+ };
32
41
  getDirtyData: Nullable<(dirtyData: IFormulaDirtyData, runtimeData: IAllRuntimeData) => {
33
42
  runtimeCellData: IRuntimeUnitDataType;
34
43
  dirtyRanges: IFeatureDirtyRangeType;
35
44
  }>;
36
45
  private _state;
37
46
  dispose(): void;
38
- disposeWithChildren(): void;
39
47
  resetState(): void;
40
48
  setAdded(): void;
41
49
  isAdded(): boolean;
@@ -50,7 +58,7 @@ export declare class FormulaDependencyTree extends Disposable {
50
58
  * @param range
51
59
  */
52
60
  pushRangeList(ranges: IUnitRange[]): void;
53
- hasChildren(tree: FormulaDependencyTree): boolean;
61
+ hasChildren(treeId: string): boolean;
54
62
  toRTreeItem(): IRTreeItem;
55
63
  /**
56
64
  * Determine whether it is dependent on other trees.
@@ -29,6 +29,7 @@ export declare class FormulaDependencyGenerator extends Disposable {
29
29
  * @param formulaData
30
30
  */
31
31
  private _generateTreeList;
32
+ private _moveRangeList;
32
33
  private _registerFeatureFormulas;
33
34
  private _getFeatureFormulaTree;
34
35
  private _registerOtherFormulas;
@@ -1,13 +1,14 @@
1
1
  import { BaseAstNode } from '../ast-node/base-ast-node';
2
2
  import { FunctionVariantType } from '../reference-object/base-reference-object';
3
+ import { IExecuteAstNodeData } from '../utils/ast-node-tool';
3
4
  import { PreCalculateNodeType } from '../utils/node-type';
4
5
  import { Disposable } from '@univerjs/core';
5
6
  import { IFormulaRuntimeService } from '../../services/runtime.service';
6
7
  export declare class Interpreter extends Disposable {
7
8
  private readonly _runtimeService;
8
9
  constructor(_runtimeService: IFormulaRuntimeService);
9
- executeAsync(node: BaseAstNode): Promise<FunctionVariantType>;
10
- execute(node: BaseAstNode): FunctionVariantType;
10
+ executeAsync(nodeData: IExecuteAstNodeData): Promise<FunctionVariantType>;
11
+ execute(nodeData: IExecuteAstNodeData): FunctionVariantType;
11
12
  executePreCalculateNode(node: PreCalculateNodeType): import('@univerjs/core').Nullable<FunctionVariantType>;
12
13
  checkAsyncNode(node: BaseAstNode): boolean;
13
14
  private _checkAsyncNode;
@@ -39,6 +39,11 @@ export declare class BaseReferenceObject extends ObjectClassType {
39
39
  endRow: number;
40
40
  startColumn: number;
41
41
  endColumn: number;
42
+ rangeType?: import('@univerjs/core').RANGE_TYPE;
43
+ startAbsoluteRefType?: import('@univerjs/core').AbsoluteRefType;
44
+ endAbsoluteRefType?: import('@univerjs/core').AbsoluteRefType;
45
+ unitId?: string;
46
+ sheetId?: string;
42
47
  };
43
48
  isReferenceObject(): boolean;
44
49
  iterator(callback: (valueObject: Nullable<BaseValueObject>, rowIndex: number, columnIndex: number) => Nullable<boolean>): Nullable<boolean>;
@@ -115,6 +120,11 @@ export declare class BaseReferenceObject extends ObjectClassType {
115
120
  endRow: number;
116
121
  startColumn: number;
117
122
  endColumn: number;
123
+ rangeType?: import('@univerjs/core').RANGE_TYPE;
124
+ startAbsoluteRefType?: import('@univerjs/core').AbsoluteRefType;
125
+ endAbsoluteRefType?: import('@univerjs/core').AbsoluteRefType;
126
+ unitId?: string;
127
+ sheetId?: string;
118
128
  };
119
129
  sheetId: string;
120
130
  unitId: string;
@@ -1,3 +1,13 @@
1
1
  import { Nullable } from '@univerjs/core';
2
2
  import { BaseAstNode } from '../ast-node/base-ast-node';
3
+ export interface IExecuteAstNodeData {
4
+ node: BaseAstNode;
5
+ refOffsetX: number;
6
+ refOffsetY: number;
7
+ }
3
8
  export declare function getAstNodeTopParent(node: BaseAstNode): Nullable<BaseAstNode>;
9
+ export declare function generateExecuteAstNodeData(node: BaseAstNode, refOffsetX?: number, refOffsetY?: number): {
10
+ node: BaseAstNode;
11
+ refOffsetX: number;
12
+ refOffsetY: number;
13
+ };
@@ -14,12 +14,10 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  /**
17
- * Korean in Excel does not count as two characters. Here we calculate all Chinese, Japanese and Korean characters as two characters.
17
+ * excel logic is cofusing, so we use google sheet logic
18
18
  *
19
- * ā -> 1
20
- * -> 2
21
- *
22
- * @param str
23
- * @returns
19
+ * @param text
20
+ * @returns number
24
21
  */
25
- export declare function charLenByte(str: string): number;
22
+ export declare function charLenByte(text: string): number;
23
+ export declare function getCharLenByteInText(text: string, charIndex: number, direction?: 'ltr' | 'rtl'): number;
@@ -1,4 +1,4 @@
1
- import { ICellData, Nullable, Styles } from '@univerjs/core';
1
+ import { ICellData, Nullable, Styles, LocaleType } from '@univerjs/core';
2
2
  import { operatorToken } from '../../basics/token';
3
3
  /**
4
4
  * Handling number formats in styles
@@ -39,6 +39,7 @@ export declare function handleNumfmtInCell(oldCell: Nullable<ICellData>, cell: N
39
39
  * @returns
40
40
  */
41
41
  export declare function compareNumfmtPriority(oldPattern: string, pattern: string): string;
42
+ export declare function clearNumberFormatTypeCache(): void;
42
43
  /**
43
44
  * The number format of the formula inherits the number format of the referenced cell, usually taking the format of the cell at the front position, but some formats have higher priority, there are some special cases.
44
45
  *
@@ -60,3 +61,15 @@ export declare function compareNumfmtPriority(oldPattern: string, pattern: strin
60
61
  * @param nextPattern
61
62
  */
62
63
  export declare function comparePatternPriority(previousPattern: string, nextPattern: string, operator: operatorToken): string;
64
+ export declare function getCurrencyFormat(locale: LocaleType, numberDigits?: number): string;
65
+ export declare function applyCurrencyFormat(locale: LocaleType, number: number, numberDigits?: number): string;
66
+ export declare function stringIsNumberPattern(input: string): {
67
+ isNumberPattern: boolean;
68
+ value: number;
69
+ pattern: string;
70
+ } | {
71
+ isNumberPattern: boolean;
72
+ value?: undefined;
73
+ pattern?: undefined;
74
+ };
75
+ export declare function clearStringToNumberPatternCache(): void;
@@ -0,0 +1,3 @@
1
+ import { IUnitRangeName } from '@univerjs/core';
2
+ export declare function deserializeRangeWithSheetWithCache(refString: string): IUnitRangeName;
3
+ export declare function clearReferenceToRangeCache(): void;
@@ -219,6 +219,7 @@ export declare class ArrayValueObject extends BaseValueObject {
219
219
  private _transposeArray;
220
220
  private _batchOperator;
221
221
  private _batchOperatorValue;
222
+ private __batchOperatorRowValue;
222
223
  private _batchOperatorArray;
223
224
  private _checkArrayCalculateType;
224
225
  private _formatValue;
@@ -1,7 +1,7 @@
1
- import { AsyncObject, FunctionVariantType } from '../reference-object/base-reference-object';
2
- import { BaseValueObject } from './base-value-object';
3
1
  import { BaseAstNode } from '../ast-node/base-ast-node';
4
2
  import { Interpreter } from '../interpreter/interpreter';
3
+ import { FunctionVariantType, AsyncObject } from '../reference-object/base-reference-object';
4
+ import { BaseValueObject } from './base-value-object';
5
5
  export declare class LambdaValueObjectObject extends BaseValueObject {
6
6
  private _lambdaNode;
7
7
  private _interpreter;
@@ -1,18 +1,19 @@
1
- import { Disposable, IRange, Nullable } from '@univerjs/core';
2
- import { ArrayOrderSearchType, ArrayBinarySearchType } from '../engine/utils/compare';
3
- import { BaseValueObject, ErrorValueObject } from '../engine/value-object/base-value-object';
4
- import { PrimitiveValueType } from '../engine/value-object/primitive-object';
1
+ import { IRange, LocaleType, Nullable } from '@univerjs/core';
5
2
  import { IFunctionNames } from '../basics/function';
6
3
  import { BaseReferenceObject, FunctionVariantType, NodeValueType } from '../engine/reference-object/base-reference-object';
4
+ import { ArrayBinarySearchType, ArrayOrderSearchType } from '../engine/utils/compare';
7
5
  import { ArrayValueObject } from '../engine/value-object/array-value-object';
8
6
  import { IDefinedNameMapItem } from '../services/defined-names.service';
9
- export declare class BaseFunction extends Disposable {
7
+ import { BaseValueObject, ErrorValueObject } from '../engine/value-object/base-value-object';
8
+ import { PrimitiveValueType } from '../engine/value-object/primitive-object';
9
+ export declare class BaseFunction {
10
10
  private _name;
11
11
  private _unitId;
12
12
  private _subUnitId;
13
13
  private _row;
14
14
  private _column;
15
15
  private _definedNames;
16
+ private _locale;
16
17
  /**
17
18
  * Whether the function needs to expand the parameters
18
19
  */
@@ -21,6 +22,10 @@ export declare class BaseFunction extends Disposable {
21
22
  * Whether the function needs to pass in reference object
22
23
  */
23
24
  needsReferenceObject: boolean;
25
+ /**
26
+ * Whether the function needs handle locale
27
+ */
28
+ needsLocale: boolean;
24
29
  /**
25
30
  * Minimum number of parameters
26
31
  */
@@ -35,6 +40,7 @@ export declare class BaseFunction extends Disposable {
35
40
  get subUnitId(): Nullable<string>;
36
41
  get row(): number;
37
42
  get column(): number;
43
+ dispose(): void;
38
44
  /**
39
45
  * In Excel, to inject a defined name into a function that has positioning capabilities,
40
46
  * such as using the INDIRECT function to reference a named range,
@@ -43,6 +49,8 @@ export declare class BaseFunction extends Disposable {
43
49
  */
44
50
  getDefinedName(name: string): import('..').IDefinedNamesServiceParam | null;
45
51
  setDefinedNames(definedNames: IDefinedNameMapItem): void;
52
+ getLocale(): LocaleType;
53
+ setLocale(locale: LocaleType): void;
46
54
  isAsync(): boolean;
47
55
  isAddress(): boolean;
48
56
  isCustom(): boolean;
@@ -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,8 @@
1
+ import { BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
2
+ import { NumberValueObject } from '../../../engine/value-object/primitive-object';
3
+ import { BaseFunction } from '../../base-function';
4
+ export declare class Daverage extends BaseFunction {
5
+ minParams: number;
6
+ maxParams: number;
7
+ calculate(database: BaseValueObject, field: BaseValueObject, criteria: BaseValueObject): ErrorValueObject | NumberValueObject;
8
+ }
@@ -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,8 @@
1
+ import { BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
2
+ import { NumberValueObject } from '../../../engine/value-object/primitive-object';
3
+ import { BaseFunction } from '../../base-function';
4
+ export declare class Dcount extends BaseFunction {
5
+ minParams: number;
6
+ maxParams: number;
7
+ calculate(database: BaseValueObject, field: BaseValueObject, criteria: BaseValueObject): ErrorValueObject | NumberValueObject;
8
+ }
@@ -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,8 @@
1
+ import { BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
2
+ import { NumberValueObject } from '../../../engine/value-object/primitive-object';
3
+ import { BaseFunction } from '../../base-function';
4
+ export declare class Dcounta extends BaseFunction {
5
+ minParams: number;
6
+ maxParams: number;
7
+ calculate(database: BaseValueObject, field: BaseValueObject, criteria: BaseValueObject): ErrorValueObject | NumberValueObject;
8
+ }
@@ -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,7 @@
1
+ import { BaseValueObject } from '../../../engine/value-object/base-value-object';
2
+ import { BaseFunction } from '../../base-function';
3
+ export declare class Dget extends BaseFunction {
4
+ minParams: number;
5
+ maxParams: number;
6
+ calculate(database: BaseValueObject, field: BaseValueObject, criteria: BaseValueObject): BaseValueObject;
7
+ }