@univerjs/engine-formula 0.1.3 → 0.1.5

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 (178) hide show
  1. package/lib/cjs/index.js +1 -1
  2. package/lib/es/index.js +4520 -3304
  3. package/lib/types/basics/calculate.d.ts +1 -15
  4. package/lib/types/basics/common.d.ts +16 -17
  5. package/lib/types/basics/date.d.ts +1 -1
  6. package/lib/types/basics/dirty.d.ts +2 -16
  7. package/lib/types/basics/format.d.ts +24 -0
  8. package/lib/types/basics/function.d.ts +18 -32
  9. package/lib/types/basics/inverted-index-cache.d.ts +2 -2
  10. package/lib/types/basics/match-token.d.ts +1 -15
  11. package/lib/types/basics/object-class-type.d.ts +6 -15
  12. package/lib/types/basics/runtime.d.ts +2 -16
  13. package/lib/types/commands/mutations/register-function.mutation.d.ts +2 -16
  14. package/lib/types/commands/mutations/set-array-formula-data.mutation.d.ts +4 -18
  15. package/lib/types/commands/mutations/set-defined-name.mutation.d.ts +2 -16
  16. package/lib/types/commands/mutations/set-feature-calculation.mutation.d.ts +3 -17
  17. package/lib/types/commands/mutations/set-formula-calculation.mutation.d.ts +5 -18
  18. package/lib/types/commands/mutations/set-formula-data.mutation.d.ts +3 -17
  19. package/lib/types/commands/mutations/set-numfmt-formula-data.mutation.d.ts +3 -17
  20. package/lib/types/commands/mutations/set-other-formula.mutation.d.ts +15 -19
  21. package/lib/types/commands/mutations/set-super-table.mutation.d.ts +4 -18
  22. package/lib/types/commands/mutations/unregister-function.mutation.d.ts +2 -16
  23. package/lib/types/controller/calculate.controller.d.ts +3 -17
  24. package/lib/types/controller/formula.controller.d.ts +5 -20
  25. package/lib/types/controller/register-function.controller.d.ts +3 -17
  26. package/lib/types/controller/set-defined-name.controller.d.ts +2 -16
  27. package/lib/types/controller/set-feature-calculation.controller.d.ts +2 -16
  28. package/lib/types/controller/set-other-formula.controller.d.ts +2 -16
  29. package/lib/types/controller/set-super-table.controller.d.ts +2 -16
  30. package/lib/types/engine/analysis/__tests__/create-command-test-bed.d.ts +11 -26
  31. package/lib/types/engine/analysis/lexer-node.d.ts +3 -17
  32. package/lib/types/engine/analysis/lexer-tree-builder.d.ts +5 -19
  33. package/lib/types/engine/analysis/lexer.d.ts +5 -19
  34. package/lib/types/engine/analysis/parser.d.ts +14 -29
  35. package/lib/types/engine/ast-node/ast-root-node.d.ts +4 -18
  36. package/lib/types/engine/ast-node/base-ast-node-factory.d.ts +3 -18
  37. package/lib/types/engine/ast-node/base-ast-node.d.ts +6 -21
  38. package/lib/types/engine/ast-node/function-node.d.ts +10 -24
  39. package/lib/types/engine/ast-node/lambda-node.d.ts +6 -20
  40. package/lib/types/engine/ast-node/lambda-parameter-node.d.ts +4 -19
  41. package/lib/types/engine/ast-node/null-node.d.ts +2 -16
  42. package/lib/types/engine/ast-node/operator-node.d.ts +6 -20
  43. package/lib/types/engine/ast-node/prefix-node.d.ts +8 -23
  44. package/lib/types/engine/ast-node/reference-node.d.ts +10 -25
  45. package/lib/types/engine/ast-node/suffix-node.d.ts +7 -22
  46. package/lib/types/engine/ast-node/union-node.d.ts +5 -19
  47. package/lib/types/engine/ast-node/value-node.d.ts +4 -18
  48. package/lib/types/engine/dependency/dependency-tree.d.ts +24 -23
  49. package/lib/types/engine/dependency/formula-dependency.d.ts +11 -31
  50. package/lib/types/engine/interpreter/interpreter.d.ts +6 -20
  51. package/lib/types/engine/reference-object/base-reference-object.d.ts +22 -32
  52. package/lib/types/engine/reference-object/cell-reference-object.d.ts +4 -18
  53. package/lib/types/engine/reference-object/column-reference-object.d.ts +2 -16
  54. package/lib/types/engine/reference-object/range-reference-object.d.ts +2 -16
  55. package/lib/types/engine/reference-object/row-reference-object.d.ts +2 -16
  56. package/lib/types/engine/reference-object/table-reference-object.d.ts +2 -17
  57. package/lib/types/engine/utils/array-object.d.ts +3 -17
  58. package/lib/types/engine/utils/ast-node-tool.d.ts +3 -17
  59. package/lib/types/engine/utils/cell.d.ts +2 -16
  60. package/lib/types/engine/utils/char-kit.d.ts +25 -0
  61. package/lib/types/engine/utils/compare.d.ts +1 -15
  62. package/lib/types/engine/utils/function-definition.d.ts +1 -15
  63. package/lib/types/engine/utils/node-type.d.ts +5 -19
  64. package/lib/types/engine/utils/object-compare.d.ts +2 -17
  65. package/lib/types/engine/utils/prefixHandler.d.ts +4 -18
  66. package/lib/types/engine/utils/r1c1-reference.d.ts +2 -16
  67. package/lib/types/engine/utils/reference.d.ts +3 -18
  68. package/lib/types/engine/utils/sequence.d.ts +2 -16
  69. package/lib/types/engine/utils/value-object.d.ts +6 -0
  70. package/lib/types/engine/{utils/object-covert.d.ts → value-object/__tests__/array-value-divided.spec.d.ts} +1 -3
  71. package/lib/types/engine/value-object/__tests__/array-value-minus.spec.d.ts +16 -0
  72. package/lib/types/engine/value-object/__tests__/array-value-multiply.spec.d.ts +16 -0
  73. package/lib/types/engine/value-object/__tests__/array-value-plus.spec.d.ts +16 -0
  74. package/lib/types/engine/value-object/array-value-object.d.ts +11 -26
  75. package/lib/types/engine/value-object/base-value-object.d.ts +12 -23
  76. package/lib/types/engine/value-object/cube-value-object.d.ts +4 -17
  77. package/lib/types/engine/value-object/lambda-value-object.d.ts +5 -18
  78. package/lib/types/engine/value-object/primitive-object.d.ts +26 -19
  79. package/lib/types/functions/__tests__/create-function-test-bed.d.ts +13 -26
  80. package/lib/types/functions/base-function.d.ts +10 -31
  81. package/lib/types/functions/compatibility/function-map.d.ts +2 -16
  82. package/lib/types/functions/date/date/index.d.ts +2 -16
  83. package/lib/types/functions/date/day/index.d.ts +2 -16
  84. package/lib/types/functions/date/edate/index.d.ts +2 -16
  85. package/lib/types/functions/date/function-map.d.ts +2 -16
  86. package/lib/types/functions/date/month/index.d.ts +2 -16
  87. package/lib/types/functions/date/today/index.d.ts +3 -18
  88. package/lib/types/functions/date/year/index.d.ts +2 -16
  89. package/lib/types/functions/information/function-map.d.ts +2 -16
  90. package/lib/types/functions/information/isblank/index.d.ts +2 -16
  91. package/lib/types/functions/information/iserr/index.d.ts +2 -16
  92. package/lib/types/functions/information/iserror/index.d.ts +2 -16
  93. package/lib/types/functions/information/islogical/index.d.ts +2 -16
  94. package/lib/types/functions/information/isna/index.d.ts +2 -16
  95. package/lib/types/functions/information/isnontext/index.d.ts +2 -16
  96. package/lib/types/functions/information/isnumber/index.d.ts +2 -16
  97. package/lib/types/functions/information/isref/index.d.ts +3 -17
  98. package/lib/types/functions/information/istext/index.d.ts +2 -16
  99. package/lib/types/functions/logical/and/index.d.ts +2 -16
  100. package/lib/types/functions/logical/function-map.d.ts +4 -18
  101. package/lib/types/functions/logical/if/index.d.ts +2 -16
  102. package/lib/types/functions/logical/iferror/index.d.ts +3 -17
  103. package/lib/types/functions/logical/lambda/index.d.ts +2 -16
  104. package/lib/types/functions/logical/makearray/index.d.ts +3 -17
  105. package/lib/types/functions/logical/or/__tests__/index.spec.d.ts +16 -0
  106. package/lib/types/functions/logical/or/index.d.ts +6 -0
  107. package/lib/types/functions/lookup/address/index.d.ts +2 -16
  108. package/lib/types/functions/lookup/column/index.d.ts +3 -17
  109. package/lib/types/functions/lookup/columns/index.d.ts +2 -16
  110. package/lib/types/functions/lookup/function-map.d.ts +12 -25
  111. package/lib/types/functions/lookup/hlookup/index.d.ts +2 -16
  112. package/lib/types/functions/lookup/index/index.d.ts +8 -15
  113. package/lib/types/functions/lookup/indirect/index.d.ts +3 -17
  114. package/lib/types/functions/lookup/lookup/index.d.ts +3 -17
  115. package/lib/types/functions/lookup/match/index.d.ts +3 -17
  116. package/lib/types/functions/lookup/offset/index.d.ts +5 -19
  117. package/lib/types/functions/lookup/row/index.d.ts +3 -17
  118. package/lib/types/functions/lookup/rows/index.d.ts +2 -16
  119. package/lib/types/functions/lookup/vlookup/index.d.ts +5 -17
  120. package/lib/types/functions/lookup/xlookup/index.d.ts +3 -17
  121. package/lib/types/functions/lookup/xmatch/index.d.ts +3 -17
  122. package/lib/types/functions/math/abs/index.d.ts +2 -16
  123. package/lib/types/functions/math/acos/index.d.ts +2 -16
  124. package/lib/types/functions/math/acosh/index.d.ts +2 -16
  125. package/lib/types/functions/math/acot/index.d.ts +2 -16
  126. package/lib/types/functions/math/function-map.d.ts +4 -18
  127. package/lib/types/functions/math/mod/index.d.ts +2 -16
  128. package/lib/types/functions/math/power/index.d.ts +2 -16
  129. package/lib/types/functions/math/product/index.d.ts +2 -16
  130. package/lib/types/functions/math/subtotal/index.d.ts +3 -17
  131. package/lib/types/functions/math/sum/index.d.ts +2 -16
  132. package/lib/types/functions/math/sumif/index.d.ts +2 -16
  133. package/lib/types/functions/math/sumifs/index.d.ts +3 -18
  134. package/lib/types/functions/meta/compare/index.d.ts +3 -17
  135. package/lib/types/functions/meta/cube/index.d.ts +2 -16
  136. package/lib/types/functions/meta/divided/index.d.ts +2 -16
  137. package/lib/types/functions/meta/function-map.d.ts +2 -16
  138. package/lib/types/functions/meta/minus/index.d.ts +2 -16
  139. package/lib/types/functions/meta/multiply/index.d.ts +2 -16
  140. package/lib/types/functions/meta/plus/index.d.ts +2 -16
  141. package/lib/types/functions/statistical/average/index.d.ts +2 -16
  142. package/lib/types/functions/statistical/count/index.d.ts +2 -16
  143. package/lib/types/functions/statistical/counta/index.d.ts +2 -16
  144. package/lib/types/functions/statistical/function-map.d.ts +2 -16
  145. package/lib/types/functions/statistical/max/index.d.ts +2 -16
  146. package/lib/types/functions/statistical/min/index.d.ts +2 -16
  147. package/lib/types/functions/statistical/stdev-p/index.d.ts +3 -17
  148. package/lib/types/functions/statistical/stdev-s/index.d.ts +3 -17
  149. package/lib/types/functions/statistical/stdeva/index.d.ts +3 -17
  150. package/lib/types/functions/statistical/stdevpa/index.d.ts +3 -17
  151. package/lib/types/functions/statistical/var-p/index.d.ts +3 -17
  152. package/lib/types/functions/statistical/var-s/index.d.ts +3 -17
  153. package/lib/types/functions/statistical/vara/index.d.ts +3 -17
  154. package/lib/types/functions/statistical/varpa/index.d.ts +3 -17
  155. package/lib/types/functions/text/concatenate/index.d.ts +2 -16
  156. package/lib/types/functions/text/function-map.d.ts +2 -16
  157. package/lib/types/functions/text/len/__test__/index.spec.d.ts +16 -0
  158. package/lib/types/functions/text/len/index.d.ts +7 -0
  159. package/lib/types/functions/text/lenb/__test__/index.spec.d.ts +16 -0
  160. package/lib/types/functions/text/lenb/index.d.ts +7 -0
  161. package/lib/types/functions/text/text/__test__/index.spec.d.ts +16 -0
  162. package/lib/types/functions/text/text/index.d.ts +6 -0
  163. package/lib/types/index.d.ts +8 -3
  164. package/lib/types/models/__tests__/create-command-test-bed.d.ts +10 -25
  165. package/lib/types/models/formula-data.model.d.ts +3 -18
  166. package/lib/types/plugin.d.ts +5 -20
  167. package/lib/types/services/active-dirty-manager.service.d.ts +34 -0
  168. package/lib/types/services/calculate-formula.service.d.ts +12 -27
  169. package/lib/types/services/current-data.service.d.ts +10 -19
  170. package/lib/types/services/defined-names.service.d.ts +3 -18
  171. package/lib/types/services/feature-calculation-manager.service.d.ts +5 -20
  172. package/lib/types/services/function.service.d.ts +5 -20
  173. package/lib/types/services/other-formula-manager.service.d.ts +8 -19
  174. package/lib/types/services/runtime.service.d.ts +6 -21
  175. package/lib/types/services/super-table.service.d.ts +4 -19
  176. package/lib/umd/index.js +1 -1
  177. package/package.json +12 -10
  178. /package/lib/types/engine/utils/__tests__/{object-covert.spec.d.ts → value-object.spec.d.ts} +0 -0
@@ -1,23 +1,9 @@
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 { IFunctionService } from '../../services/function.service';
17
- import { LexerNode } from '../analysis/lexer-node';
18
- import { BaseAstNode } from './base-ast-node';
19
- import { BaseAstNodeFactory } from './base-ast-node-factory';
20
1
  import { NodeType } from './node-type';
2
+ import { BaseAstNodeFactory } from './base-ast-node-factory';
3
+ import { BaseAstNode } from './base-ast-node';
4
+ import { LexerNode } from '../analysis/lexer-node';
5
+ import { IFunctionService } from '../../services/function.service';
6
+
21
7
  export declare class UnionNode extends BaseAstNode {
22
8
  private _operatorString;
23
9
  constructor(_operatorString: string);
@@ -1,22 +1,8 @@
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 { LexerNode } from '../analysis/lexer-node';
17
- import { BaseAstNode } from './base-ast-node';
18
- import { BaseAstNodeFactory } from './base-ast-node-factory';
19
1
  import { NodeType } from './node-type';
2
+ import { BaseAstNodeFactory } from './base-ast-node-factory';
3
+ import { BaseAstNode } from './base-ast-node';
4
+ import { LexerNode } from '../analysis/lexer-node';
5
+
20
6
  export declare class ValueNode extends BaseAstNode {
21
7
  private _operatorString;
22
8
  constructor(_operatorString: string);
@@ -1,27 +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
- import type { IRange, IUnitRange, Nullable } from '@univerjs/core';
17
- import { Disposable } from '@univerjs/core';
18
- import type { IDirtyUnitSheetNameMap, IFeatureDirtyRangeType, IRuntimeUnitDataType, IUnitExcludedCell } from '../../basics/common';
19
- import type { BaseAstNode } from '../ast-node/base-ast-node';
1
+ import { BaseAstNode } from '../ast-node/base-ast-node';
2
+ import { IDirtyUnitSheetNameMap, IFeatureDirtyRangeType, IRuntimeUnitDataType, IUnitExcludedCell } from '../../basics/common';
3
+ import { IRange, IUnitRange, Nullable, Disposable } from '@univerjs/core';
4
+
20
5
  export declare enum FDtreeStateType {
21
6
  DEFAULT = 0,
22
7
  ADDED = 1,
23
8
  SKIP = 2
24
9
  }
10
+ export interface IUnitRangeWithToken {
11
+ gridRange: IUnitRange;
12
+ token: string;
13
+ }
25
14
  /**
26
15
  * A dependency tree, capable of calculating mutual dependencies,
27
16
  * is used to determine the order of formula calculations.
@@ -37,7 +26,7 @@ export declare class FormulaDependencyTree extends Disposable {
37
26
  columnCount: number;
38
27
  subUnitId: string;
39
28
  unitId: string;
40
- rangeList: IUnitRange[];
29
+ rangeList: IUnitRangeWithToken[];
41
30
  formulaId: Nullable<string>;
42
31
  featureId: Nullable<string>;
43
32
  getDirtyData: Nullable<(tree: FormulaDependencyTree) => {
@@ -55,7 +44,6 @@ export declare class FormulaDependencyTree extends Disposable {
55
44
  * "Determine whether all ranges of the current node exist within the dirty area.
56
45
  * If they are within the dirty area, return true, indicating that this node needs to be calculated.
57
46
  * @param dependencyRangeList
58
- * @returns
59
47
  */
60
48
  dependencyRange(dependencyRangeList: Map<string, Map<string, IRange[]>>, dirtyUnitSheetNameMap: IDirtyUnitSheetNameMap, unitExcludedCell: Nullable<IUnitExcludedCell>): boolean;
61
49
  pushChildren(tree: FormulaDependencyTree): void;
@@ -63,12 +51,25 @@ export declare class FormulaDependencyTree extends Disposable {
63
51
  * Add the range corresponding to the current ast node.
64
52
  * @param range
65
53
  */
66
- pushRangeList(range: IUnitRange): void;
54
+ pushRangeList(range: IUnitRangeWithToken): void;
67
55
  /**
68
56
  * Determine whether it is dependent on other trees.
69
57
  * @param dependenceTree
70
- * @returns
71
58
  */
72
59
  dependency(dependenceTree: FormulaDependencyTree): boolean;
73
60
  private _pushParent;
74
61
  }
62
+ export declare class FormulaDependencyTreeCache extends Disposable {
63
+ private _cacheItems;
64
+ dispose(): void;
65
+ size(): number;
66
+ add(unitRangeWithToken: IUnitRangeWithToken, tree: FormulaDependencyTree): void;
67
+ clear(): void;
68
+ remove(token: string, tree: FormulaDependencyTree): void;
69
+ delete(token: string): void;
70
+ /**
71
+ * Determine whether range is dependent on other trees.
72
+ * @param dependenceTree
73
+ */
74
+ dependency(dependenceTree: FormulaDependencyTree): void;
75
+ }
@@ -1,29 +1,15 @@
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 { Disposable } from '@univerjs/core';
17
- import { FormulaAstLRU } from '../../basics/cache-lru';
18
- import { IFormulaCurrentConfigService } from '../../services/current-data.service';
19
- import { IFeatureCalculationManagerService } from '../../services/feature-calculation-manager.service';
20
- import { IOtherFormulaManagerService } from '../../services/other-formula-manager.service';
21
- import { IFormulaRuntimeService } from '../../services/runtime.service';
22
- import { Lexer } from '../analysis/lexer';
23
- import { AstTreeBuilder } from '../analysis/parser';
24
- import type { AstRootNode } from '../ast-node';
25
- import { Interpreter } from '../interpreter/interpreter';
26
1
  import { FormulaDependencyTree } from './dependency-tree';
2
+ import { Interpreter } from '../interpreter/interpreter';
3
+ import { AstRootNode } from '../ast-node';
4
+ import { AstTreeBuilder } from '../analysis/parser';
5
+ import { Lexer } from '../analysis/lexer';
6
+ import { IFormulaRuntimeService } from '../../services/runtime.service';
7
+ import { IOtherFormulaManagerService } from '../../services/other-formula-manager.service';
8
+ import { IFeatureCalculationManagerService } from '../../services/feature-calculation-manager.service';
9
+ import { IFormulaCurrentConfigService } from '../../services/current-data.service';
10
+ import { FormulaAstLRU } from '../../basics/cache-lru';
11
+ import { Disposable } from '@univerjs/core';
12
+
27
13
  export declare const FormulaASTCache: FormulaAstLRU<AstRootNode>;
28
14
  export declare class FormulaDependencyGenerator extends Disposable {
29
15
  private readonly _currentConfigService;
@@ -43,12 +29,10 @@ export declare class FormulaDependencyGenerator extends Disposable {
43
29
  /**
44
30
  * Generate nodes for the dependency tree, where each node contains all the reference data ranges included in each formula.
45
31
  * @param formulaData
46
- * @returns
47
32
  */
48
33
  private _generateTreeList;
49
34
  /**
50
35
  * Break down the dirty areas into ranges for subsequent matching.
51
- * @returns
52
36
  */
53
37
  private _updateRangeFlatten;
54
38
  private _generateAstNode;
@@ -61,26 +45,22 @@ export declare class FormulaDependencyGenerator extends Disposable {
61
45
  * Calculate the range required for collection in advance,
62
46
  * including references and location functions (such as OFFSET, INDIRECT, INDEX, etc.).
63
47
  * @param node
64
- * @returns
65
48
  */
66
49
  private _getRangeListByNode;
67
50
  /**
68
51
  * Build a formula dependency tree based on the dependency relationships.
69
52
  * @param treeList
70
- * @returns
71
53
  */
72
54
  private _getUpdateTreeListAndMakeDependency;
73
55
  /**
74
56
  * Determine whether all ranges of the current node exist within the dirty area.
75
57
  * If they are within the dirty area, return true, indicating that this node needs to be calculated.
76
58
  * @param tree
77
- * @returns
78
59
  */
79
60
  private _includeTree;
80
61
  /**
81
62
  * Generate the final formula calculation order array by traversing the dependency tree established via depth-first search.
82
63
  * @param treeList
83
- * @returns
84
64
  */
85
65
  private _calculateRunList;
86
66
  }
@@ -1,30 +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
- import { Disposable } from '@univerjs/core';
1
+ import { PreCalculateNodeType } from '../utils/node-type';
2
+ import { FunctionVariantType } from '../reference-object/base-reference-object';
3
+ import { BaseAstNode } from '../ast-node/base-ast-node';
17
4
  import { IFormulaRuntimeService } from '../../services/runtime.service';
18
- import type { BaseAstNode } from '../ast-node/base-ast-node';
19
- import type { FunctionVariantType } from '../reference-object/base-reference-object';
20
- import type { PreCalculateNodeType } from '../utils/node-type';
5
+ import { Disposable } from '@univerjs/core';
6
+
21
7
  export declare class Interpreter extends Disposable {
22
8
  private readonly _runtimeService;
23
9
  constructor(_runtimeService: IFormulaRuntimeService);
24
10
  dispose(): void;
25
11
  executeAsync(node: BaseAstNode): Promise<FunctionVariantType>;
26
12
  execute(node: BaseAstNode): FunctionVariantType;
27
- executePreCalculateNode(node: PreCalculateNodeType): import("@univerjs/core").Nullable<FunctionVariantType>;
13
+ executePreCalculateNode(node: PreCalculateNodeType): import('@univerjs/core').Nullable<FunctionVariantType>;
28
14
  checkAsyncNode(node: BaseAstNode): boolean;
29
15
  private _checkAsyncNode;
30
16
  private _executeAsync;
@@ -1,25 +1,11 @@
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 { ICellData, IRange, Nullable } from '@univerjs/core';
17
- import { FormulaAstLRU } from '../../basics/cache-lru';
18
- import type { INumfmtItemMap, IRuntimeUnitDataType, IUnitData, IUnitSheetNameMap } from '../../basics/common';
19
- import { ObjectClassType } from '../../basics/object-class-type';
1
+ import { NullValueObject, NumberValueObject } from '../value-object/primitive-object';
2
+ import { BaseValueObject, ErrorValueObject } from '../value-object/base-value-object';
20
3
  import { ArrayValueObject } from '../value-object/array-value-object';
21
- import { type BaseValueObject, ErrorValueObject } from '../value-object/base-value-object';
22
- import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../value-object/primitive-object';
4
+ import { ObjectClassType } from '../../basics/object-class-type';
5
+ import { INumfmtItemMap, IRuntimeUnitDataType, IUnitData, IUnitSheetNameMap } from '../../basics/common';
6
+ import { FormulaAstLRU } from '../../basics/cache-lru';
7
+ import { ICellData, IRange, Nullable } from '@univerjs/core';
8
+
23
9
  export type NodeValueType = BaseValueObject | BaseReferenceObject | AsyncObject | AsyncArrayObject;
24
10
  export type FunctionVariantType = BaseValueObject | BaseReferenceObject;
25
11
  export declare const FORMULA_REF_TO_ARRAY_CACHE: FormulaAstLRU<ArrayValueObject>;
@@ -41,6 +27,8 @@ export declare class BaseReferenceObject extends ObjectClassType {
41
27
  private _refOffsetY;
42
28
  constructor(_token: string);
43
29
  dispose(): void;
30
+ getToken(): string;
31
+ setToken(token: string): void;
44
32
  isExceedRange(): boolean;
45
33
  setRefOffset(x?: number, y?: number): void;
46
34
  getRefOffset(): {
@@ -55,7 +43,7 @@ export declare class BaseReferenceObject extends ObjectClassType {
55
43
  };
56
44
  isReferenceObject(): boolean;
57
45
  iterator(callback: (valueObject: Nullable<BaseValueObject>, rowIndex: number, columnIndex: number) => Nullable<boolean>): Nullable<boolean>;
58
- getFirstCell(): ErrorValueObject | NullValueObject | NumberValueObject | StringValueObject | BooleanValueObject | ArrayValueObject;
46
+ getFirstCell(): ErrorValueObject | NullValueObject | NumberValueObject | import('../value-object/primitive-object').BooleanValueObject | import('../value-object/primitive-object').StringValueObject | ArrayValueObject;
59
47
  getRangeData(): IRange;
60
48
  setRangeData(range: IRange): void;
61
49
  getUnitId(): string;
@@ -87,10 +75,12 @@ export declare class BaseReferenceObject extends ObjectClassType {
87
75
  }): void;
88
76
  getNumfmtItemData(): INumfmtItemMap;
89
77
  setNumfmtItemData(numfmtItemData: INumfmtItemMap): void;
78
+ getActiveSheetRowCount(): number;
79
+ getActiveSheetColumnCount(): number;
90
80
  getRowCount(): number;
91
81
  getColumnCount(): number;
92
- getRowData(): import("@univerjs/core").IObjectArrayPrimitiveType<Partial<import("@univerjs/core").IRowData>>;
93
- getColumnData(): import("@univerjs/core").IObjectArrayPrimitiveType<Partial<import("@univerjs/core").IColumnData>>;
82
+ getRowData(): import('@univerjs/core').IObjectArrayPrimitiveType<Partial<import("@univerjs/core").IRowData>>;
83
+ getColumnData(): import('@univerjs/core').IObjectArrayPrimitiveType<Partial<import("@univerjs/core").IColumnData>>;
94
84
  isCell(): boolean;
95
85
  isColumn(): boolean;
96
86
  isRow(): boolean;
@@ -98,16 +88,16 @@ export declare class BaseReferenceObject extends ObjectClassType {
98
88
  isTable(): boolean;
99
89
  unionBy(referenceObject: BaseReferenceObject): NodeValueType;
100
90
  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;
104
- getCurrentActiveSheetData(): import("../../basics/common").ISheetItem;
105
- getCurrentRuntimeSheetData(): import("@univerjs/core").ObjectMatrix<Nullable<ICellData>> | undefined;
106
- getCurrentActiveArrayFormulaCellData(): import("@univerjs/core").ObjectMatrix<Nullable<ICellData>> | undefined;
107
- getCurrentRuntimeActiveArrayFormulaCellData(): import("@univerjs/core").ObjectMatrix<Nullable<ICellData>> | undefined;
91
+ getCellValueObject(cell: ICellData): ErrorValueObject | NullValueObject | NumberValueObject | import('../value-object/primitive-object').BooleanValueObject | import('../value-object/primitive-object').StringValueObject | ArrayValueObject;
92
+ getCellByRow(row: number): ErrorValueObject | NullValueObject | NumberValueObject | import('../value-object/primitive-object').BooleanValueObject | import('../value-object/primitive-object').StringValueObject | ArrayValueObject;
93
+ getCellByColumn(column: number): ErrorValueObject | NullValueObject | NumberValueObject | import('../value-object/primitive-object').BooleanValueObject | import('../value-object/primitive-object').StringValueObject | ArrayValueObject;
94
+ getCurrentActiveSheetData(): import('../../basics/common').ISheetItem;
95
+ getCurrentRuntimeSheetData(): import('@univerjs/core').ObjectMatrix<Nullable<ICellData>> | undefined;
96
+ getCurrentActiveArrayFormulaCellData(): import('@univerjs/core').ObjectMatrix<Nullable<ICellData>> | undefined;
97
+ getCurrentRuntimeActiveArrayFormulaCellData(): import('@univerjs/core').ObjectMatrix<Nullable<ICellData>> | undefined;
108
98
  getCellData(row: number, column: number): ICellData;
109
99
  getRuntimeFeatureCellValue(row: number, column: number): ICellData | undefined;
110
- getCellByPosition(row?: number, column?: number): ErrorValueObject | NullValueObject | NumberValueObject | StringValueObject | BooleanValueObject | ArrayValueObject;
100
+ getCellByPosition(row?: number, column?: number): ErrorValueObject | NullValueObject | NumberValueObject | import('../value-object/primitive-object').BooleanValueObject | import('../value-object/primitive-object').StringValueObject | ArrayValueObject;
111
101
  toArrayValueObject(useCache?: boolean): ArrayValueObject;
112
102
  toUnitRange(): {
113
103
  range: {
@@ -1,22 +1,8 @@
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 { IRange } from '@univerjs/core';
17
- import { ErrorValueObject } from '../value-object/base-value-object';
18
- import { BaseReferenceObject } from './base-reference-object';
19
1
  import { RangeReferenceObject } from './range-reference-object';
2
+ import { BaseReferenceObject } from './base-reference-object';
3
+ import { ErrorValueObject } from '../value-object/base-value-object';
4
+ import { IRange } from '@univerjs/core';
5
+
20
6
  export declare class CellReferenceObject extends BaseReferenceObject {
21
7
  constructor(token: string);
22
8
  isCell(): boolean;
@@ -1,20 +1,6 @@
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 { ErrorValueObject } from '../value-object/base-value-object';
17
1
  import { BaseReferenceObject } from './base-reference-object';
2
+ import { ErrorValueObject } from '../value-object/base-value-object';
3
+
18
4
  export declare class ColumnReferenceObject extends BaseReferenceObject {
19
5
  constructor(token: string);
20
6
  isColumn(): boolean;
@@ -1,20 +1,6 @@
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 { IRange, Nullable } from '@univerjs/core';
17
1
  import { BaseReferenceObject } from './base-reference-object';
2
+ import { IRange, Nullable } from '@univerjs/core';
3
+
18
4
  export declare class RangeReferenceObject extends BaseReferenceObject {
19
5
  constructor(range: IRange, forcedSheetId?: Nullable<string>, forcedUnitId?: string);
20
6
  isRange(): boolean;
@@ -1,20 +1,6 @@
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 { ErrorValueObject } from '../value-object/base-value-object';
17
1
  import { BaseReferenceObject } from './base-reference-object';
2
+ import { ErrorValueObject } from '../value-object/base-value-object';
3
+
18
4
  export declare class RowReferenceObject extends BaseReferenceObject {
19
5
  constructor(token: string);
20
6
  isRow(): boolean;
@@ -1,21 +1,6 @@
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 { ISuperTable } from '../../basics/common';
17
- import { TableOptionType } from '../../basics/common';
18
1
  import { BaseReferenceObject } from './base-reference-object';
2
+ import { ISuperTable, TableOptionType } from '../../basics/common';
3
+
19
4
  export declare class TableReferenceObject extends BaseReferenceObject {
20
5
  private _tableData;
21
6
  private _columnDataString;
@@ -1,19 +1,5 @@
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 { BaseValueObject } from '../value-object/base-value-object';
16
2
  import { ArrayValueObject } from '../value-object/array-value-object';
17
- import type { BaseValueObject } from '../value-object/base-value-object';
3
+
18
4
  export declare function expandArrayValueObject(rowCount: number, columnCount: number, valueObject: BaseValueObject, defaultValue?: BaseValueObject): ArrayValueObject;
19
- export declare function createNewArray(result: BaseValueObject[][], rowCount: number, columnCount: number): ArrayValueObject;
5
+ export declare function createNewArray(result: BaseValueObject[][], rowCount: number, columnCount: number, unitId?: string, sheetId?: string): ArrayValueObject;
@@ -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
- */
16
- import type { Nullable } from '@univerjs/core';
17
- import type { BaseAstNode } from '../ast-node/base-ast-node';
1
+ import { BaseAstNode } from '../ast-node/base-ast-node';
2
+ import { Nullable } from '@univerjs/core';
3
+
18
4
  export declare function getAstNodeTopParent(node: BaseAstNode): Nullable<BaseAstNode>;
@@ -1,17 +1,3 @@
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 { ICellData, Nullable } from '@univerjs/core';
1
+ import { ICellData, Nullable } from '@univerjs/core';
2
+
17
3
  export declare function getCellValue(cell: Nullable<ICellData>): string | number | true;
@@ -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;
@@ -1,19 +1,5 @@
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
1
  import { compareToken } from '../../basics/token';
2
+
17
3
  export declare enum ArrayBinarySearchType {
18
4
  MIN = 0,
19
5
  MAX = 1
@@ -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
- */
16
1
  import { LexerNode } from '../analysis/lexer-node';
2
+
17
3
  export declare function isFirstChildParameter(lexerNode: LexerNode | string): boolean;
18
4
  export declare function isChildRunTimeParameter(lexerNode: LexerNode | string): boolean;
@@ -1,20 +1,6 @@
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 { PrefixNode } from '../ast-node/prefix-node';
17
- import type { ReferenceNode } from '../ast-node/reference-node';
18
- import type { SuffixNode } from '../ast-node/suffix-node';
19
- import type { UnionNode } from '../ast-node/union-node';
1
+ import { UnionNode } from '../ast-node/union-node';
2
+ import { SuffixNode } from '../ast-node/suffix-node';
3
+ import { ReferenceNode } from '../ast-node/reference-node';
4
+ import { PrefixNode } from '../ast-node/prefix-node';
5
+
20
6
  export type PreCalculateNodeType = ReferenceNode | UnionNode | PrefixNode | SuffixNode;