@univerjs/engine-formula 0.2.4-alpha.0 → 0.2.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 (103) hide show
  1. package/lib/cjs/index.js +1 -1
  2. package/lib/es/index.js +6825 -5368
  3. package/lib/types/basics/common.d.ts +2 -0
  4. package/lib/types/commands/mutations/set-feature-calculation.mutation.d.ts +6 -3
  5. package/lib/types/commands/mutations/set-formula-calculation.mutation.d.ts +4 -10
  6. package/lib/types/controller/set-dependency.controller.d.ts +4 -1
  7. package/lib/types/engine/dependency/dependency-tree.d.ts +4 -1
  8. package/lib/types/engine/dependency/formula-dependency.d.ts +1 -0
  9. package/lib/types/engine/value-object/array-value-object.d.ts +1 -0
  10. package/lib/types/engine/value-object/base-value-object.d.ts +1 -0
  11. package/lib/types/engine/value-object/primitive-object.d.ts +3 -0
  12. package/lib/types/functions/date/datedif/__tests__/index.spec.d.ts +16 -0
  13. package/lib/types/functions/date/datedif/index.d.ts +8 -0
  14. package/lib/types/functions/date/days/__tests__/index.spec.d.ts +16 -0
  15. package/lib/types/functions/date/days/index.d.ts +8 -0
  16. package/lib/types/functions/date/days360/__tests__/index.spec.d.ts +16 -0
  17. package/lib/types/functions/date/days360/index.d.ts +8 -0
  18. package/lib/types/functions/date/eomonth/__tests__/index.spec.d.ts +16 -0
  19. package/lib/types/functions/date/eomonth/index.d.ts +8 -0
  20. package/lib/types/functions/date/function-map.d.ts +1 -1
  21. package/lib/types/functions/date/isoweeknum/__tests__/index.spec.d.ts +16 -0
  22. package/lib/types/functions/date/isoweeknum/index.d.ts +9 -0
  23. package/lib/types/functions/date/weeknum/__tests__/index.spec.d.ts +16 -0
  24. package/lib/types/functions/date/weeknum/index.d.ts +9 -0
  25. package/lib/types/functions/date/yearfrac/__tests__/index.spec.d.ts +16 -0
  26. package/lib/types/functions/date/yearfrac/index.d.ts +8 -0
  27. package/lib/types/functions/information/cell/__tests__/index.spec.d.ts +16 -0
  28. package/lib/types/functions/information/cell/index.d.ts +12 -0
  29. package/lib/types/functions/information/error-type/__tests__/index.spec.d.ts +16 -0
  30. package/lib/types/functions/information/error-type/index.d.ts +10 -0
  31. package/lib/types/functions/information/function-map.d.ts +2 -1
  32. package/lib/types/functions/information/type/__tests__/index.spec.d.ts +16 -0
  33. package/lib/types/functions/information/type/index.d.ts +10 -0
  34. package/lib/types/functions/math/ceiling/__tests__/index.spec.d.ts +16 -0
  35. package/lib/types/functions/math/ceiling/index.d.ts +8 -0
  36. package/lib/types/functions/math/ceiling-math/__tests__/index.spec.d.ts +16 -0
  37. package/lib/types/functions/math/ceiling-math/index.d.ts +8 -0
  38. package/lib/types/functions/math/ceiling-precise/__tests__/index.spec.d.ts +16 -0
  39. package/lib/types/functions/math/ceiling-precise/index.d.ts +8 -0
  40. package/lib/types/functions/math/cosh/index.d.ts +1 -1
  41. package/lib/types/functions/math/decimal/__tests__/index.spec.d.ts +16 -0
  42. package/lib/types/functions/math/decimal/index.d.ts +9 -0
  43. package/lib/types/functions/math/degrees/__tests__/index.spec.d.ts +16 -0
  44. package/lib/types/functions/math/degrees/index.d.ts +9 -0
  45. package/lib/types/functions/math/even/__tests__/index.spec.d.ts +16 -0
  46. package/lib/types/functions/math/even/index.d.ts +9 -0
  47. package/lib/types/functions/math/exp/__tests__/index.spec.d.ts +16 -0
  48. package/lib/types/functions/math/exp/index.d.ts +8 -0
  49. package/lib/types/functions/math/floor/__tests__/index.spec.d.ts +16 -0
  50. package/lib/types/functions/math/floor/index.d.ts +8 -0
  51. package/lib/types/functions/math/floor-math/__tests__/index.spec.d.ts +16 -0
  52. package/lib/types/functions/math/floor-math/index.d.ts +8 -0
  53. package/lib/types/functions/math/floor-precise/__tests__/index.spec.d.ts +16 -0
  54. package/lib/types/functions/math/floor-precise/index.d.ts +8 -0
  55. package/lib/types/functions/math/function-map.d.ts +3 -2
  56. package/lib/types/functions/math/ln/__tests__/index.spec.d.ts +16 -0
  57. package/lib/types/functions/math/ln/index.d.ts +8 -0
  58. package/lib/types/functions/math/log/__tests__/index.spec.d.ts +16 -0
  59. package/lib/types/functions/math/log/index.d.ts +8 -0
  60. package/lib/types/functions/math/log10/__tests__/index.spec.d.ts +16 -0
  61. package/lib/types/functions/math/log10/index.d.ts +8 -0
  62. package/lib/types/functions/math/mround/__tests__/index.spec.d.ts +16 -0
  63. package/lib/types/functions/math/mround/index.d.ts +8 -0
  64. package/lib/types/functions/math/odd/__tests__/index.spec.d.ts +16 -0
  65. package/lib/types/functions/math/odd/index.d.ts +9 -0
  66. package/lib/types/functions/math/pi/__tests__/index.spec.d.ts +16 -0
  67. package/lib/types/functions/math/pi/index.d.ts +8 -0
  68. package/lib/types/functions/math/radians/__tests__/index.spec.d.ts +16 -0
  69. package/lib/types/functions/math/radians/index.d.ts +9 -0
  70. package/lib/types/functions/math/rand/__tests__/index.spec.d.ts +16 -0
  71. package/lib/types/functions/math/rand/index.d.ts +8 -0
  72. package/lib/types/functions/math/randarray/__tests__/index.spec.d.ts +16 -0
  73. package/lib/types/functions/math/randarray/index.d.ts +11 -0
  74. package/lib/types/functions/math/randbetween/__tests__/index.spec.d.ts +16 -0
  75. package/lib/types/functions/math/randbetween/index.d.ts +8 -0
  76. package/lib/types/functions/math/round/__tests__/index.spec.d.ts +16 -0
  77. package/lib/types/functions/math/round/index.d.ts +8 -0
  78. package/lib/types/functions/math/rounddown/__tests__/index.spec.d.ts +16 -0
  79. package/lib/types/functions/math/rounddown/index.d.ts +8 -0
  80. package/lib/types/functions/math/roundup/__tests__/index.spec.d.ts +16 -0
  81. package/lib/types/functions/math/roundup/index.d.ts +8 -0
  82. package/lib/types/functions/math/sec/__tests__/index.spec.d.ts +16 -0
  83. package/lib/types/functions/math/sec/index.d.ts +9 -0
  84. package/lib/types/functions/math/sech/__tests__/index.spec.d.ts +16 -0
  85. package/lib/types/functions/math/sech/index.d.ts +9 -0
  86. package/lib/types/functions/math/sqrt/__tests__/index.spec.d.ts +16 -0
  87. package/lib/types/functions/math/sqrt/index.d.ts +8 -0
  88. package/lib/types/functions/math/sqrtpi/__tests__/index.spec.d.ts +16 -0
  89. package/lib/types/functions/math/sqrtpi/index.d.ts +8 -0
  90. package/lib/types/functions/math/sumsq/__tests__/index.spec.d.ts +16 -0
  91. package/lib/types/functions/math/sumsq/index.d.ts +8 -0
  92. package/lib/types/functions/math/sumx2my2/__tests__/index.spec.d.ts +16 -0
  93. package/lib/types/functions/math/sumx2my2/index.d.ts +8 -0
  94. package/lib/types/functions/math/sumx2py2/__tests__/index.spec.d.ts +16 -0
  95. package/lib/types/functions/math/sumx2py2/index.d.ts +8 -0
  96. package/lib/types/functions/math/sumxmy2/__tests__/index.spec.d.ts +16 -0
  97. package/lib/types/functions/math/sumxmy2/index.d.ts +8 -0
  98. package/lib/types/index.d.ts +3 -3
  99. package/lib/types/services/current-data.service.d.ts +10 -0
  100. package/lib/types/services/dependency-manager.service.d.ts +15 -5
  101. package/lib/types/services/feature-calculation-manager.service.d.ts +18 -11
  102. package/lib/umd/index.js +1 -1
  103. package/package.json +6 -6
@@ -0,0 +1,8 @@
1
+ import { BaseValueObject } from '../../../engine/value-object/base-value-object';
2
+ import { BaseFunction } from '../../base-function';
3
+
4
+ export declare class Sumx2py2 extends BaseFunction {
5
+ minParams: number;
6
+ maxParams: number;
7
+ calculate(arrayX: BaseValueObject, arrayY: BaseValueObject): BaseValueObject;
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 } from '../../../engine/value-object/base-value-object';
2
+ import { BaseFunction } from '../../base-function';
3
+
4
+ export declare class Sumxmy2 extends BaseFunction {
5
+ minParams: number;
6
+ maxParams: number;
7
+ calculate(arrayX: BaseValueObject, arrayY: BaseValueObject): BaseValueObject;
8
+ }
@@ -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 type { IArrayFormulaRangeType, IArrayFormulaUnitCellType, IDirtyUnitFeatureMap, IDirtyUnitSheetNameMap, IFormulaData, IFormulaDataItem, IFormulaDatasetConfig, IRuntimeUnitDataType, ISheetData, IUnitData, IUnitSheetNameMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefinedNameMap, } from './basics/common';
16
+ export type { IArrayFormulaRangeType, IArrayFormulaUnitCellType, IDirtyUnitFeatureMap, IDirtyUnitSheetNameMap, IFormulaData, IFormulaDataItem, IFormulaDatasetConfig, IRuntimeUnitDataType, ISheetData, IUnitData, IUnitSheetNameMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefinedNameMap, IFeatureDirtyRangeType, } from './basics/common';
17
17
  export { isInDirtyRange } from './basics/dirty';
18
18
  export { ErrorType, ERROR_TYPE_SET } from './basics/error-type';
19
19
  export { FunctionType, type IFunctionInfo, type IFunctionParam } from './basics/function';
@@ -83,7 +83,7 @@ export { matchRefDrawToken } from './basics/match-token';
83
83
  export { IDefinedNamesService, DefinedNamesService, type IDefinedNamesServiceParam, type IDefinedNameMapItem } from './services/defined-names.service';
84
84
  export { isFormulaTransformable, transformFormula } from './engine/utils/relative-formula';
85
85
  export { IFormulaRuntimeService, FormulaRuntimeService } from './services/runtime.service';
86
- export { IFormulaCurrentConfigService, FormulaCurrentConfigService } from './services/current-data.service';
86
+ export { IFormulaCurrentConfigService, FormulaCurrentConfigService, type IFormulaDirtyData } from './services/current-data.service';
87
87
  export { IActiveDirtyManagerService } from './services/active-dirty-manager.service';
88
88
  export type { IRangeChange } from './models/formula-data.model';
89
89
  export { handleNumfmtInCell } from './engine/utils/numfmt-kit';
@@ -94,7 +94,7 @@ export { RegisterFunctionMutation } from './commands/mutations/register-function
94
94
  export { type ISetArrayFormulaDataMutationParams, SetArrayFormulaDataMutation } from './commands/mutations/set-array-formula-data.mutation';
95
95
  export { RemoveDefinedNameMutation, SetDefinedNameMutation, type ISetDefinedNameMutationSearchParam, type ISetDefinedNameMutationParam } from './commands/mutations/set-defined-name.mutation';
96
96
  export { RemoveFeatureCalculationMutation, SetFeatureCalculationMutation } from './commands/mutations/set-feature-calculation.mutation';
97
- export { SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, type ISetFormulaCalculationStartMutation, type ISetFormulaCalculationNotificationMutation, type ISetFormulaCalculationResultMutation, type IFormulaDirtyData, } from './commands/mutations/set-formula-calculation.mutation';
97
+ export { SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, type ISetFormulaCalculationStartMutation, type ISetFormulaCalculationNotificationMutation, type ISetFormulaCalculationResultMutation, } from './commands/mutations/set-formula-calculation.mutation';
98
98
  export { SetFormulaDataMutation, type ISetFormulaDataMutationParams } from './commands/mutations/set-formula-data.mutation';
99
99
  export { SetOtherFormulaMutation, RemoveOtherFormulaMutation, type ISetOtherFormulaMutationParams, type IRemoveOtherFormulaMutationParams } from './commands/mutations/set-other-formula.mutation';
100
100
  export { SetSuperTableMutation, RemoveSuperTableMutation, SetSuperTableOptionMutation } from './commands/mutations/set-super-table.mutation';
@@ -1,6 +1,14 @@
1
1
  import { IUnitRange, Nullable, Disposable, IUniverInstanceService } from '@univerjs/core';
2
2
  import { IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefinedNameMap, IDirtyUnitSheetNameMap, IFormulaData, IFormulaDatasetConfig, IRuntimeUnitDataType, IUnitData, IUnitExcludedCell, IUnitSheetNameMap, IUnitStylesData } from '../basics/common';
3
3
 
4
+ export interface IFormulaDirtyData {
5
+ forceCalculation: boolean;
6
+ dirtyRanges: IUnitRange[];
7
+ dirtyNameMap: IDirtyUnitSheetNameMap;
8
+ dirtyDefinedNameMap: IDirtyUnitSheetDefinedNameMap;
9
+ dirtyUnitFeatureMap: IDirtyUnitFeatureMap;
10
+ dirtyUnitOtherFormulaMap: IDirtyUnitOtherFormulaMap;
11
+ }
4
12
  export interface IFormulaCurrentConfigService {
5
13
  load(config: IFormulaDatasetConfig): void;
6
14
  getUnitData(): IUnitData;
@@ -27,6 +35,7 @@ export interface IFormulaCurrentConfigService {
27
35
  getExecuteSubUnitId(): Nullable<string>;
28
36
  setExecuteUnitId(unitId: string): void;
29
37
  setExecuteSubUnitId(subUnitId: string): void;
38
+ getDirtyData(): IFormulaDirtyData;
30
39
  }
31
40
  export declare class FormulaCurrentConfigService extends Disposable implements IFormulaCurrentConfigService {
32
41
  private readonly _univerInstanceService;
@@ -65,6 +74,7 @@ export declare class FormulaCurrentConfigService extends Disposable implements I
65
74
  getDirtyUnitOtherFormulaMap(): IDirtyUnitOtherFormulaMap;
66
75
  getSheetName(unitId: string, sheetId: string): string;
67
76
  load(config: IFormulaDatasetConfig): void;
77
+ getDirtyData(): IFormulaDirtyData;
68
78
  loadDirtyRangesAndExcludedCell(dirtyRanges: IUnitRange[], excludedCell?: IUnitExcludedCell): void;
69
79
  registerUnitData(unitData: IUnitData): void;
70
80
  registerFormulaData(formulaData: IFormulaData): void;
@@ -8,6 +8,13 @@ export interface IOtherFormulaDependencyParam {
8
8
  };
9
9
  }>;
10
10
  }
11
+ export interface IFeatureFormulaDependencyParam {
12
+ [unitId: string]: Nullable<{
13
+ [sheetId: string]: {
14
+ [featureId: string]: Nullable<FormulaDependencyTree>;
15
+ };
16
+ }>;
17
+ }
11
18
  export interface IFormulaDependencyParam {
12
19
  [unitId: string]: Nullable<{
13
20
  [sheetId: string]: ObjectMatrix<Nullable<FormulaDependencyTree>>;
@@ -22,8 +29,9 @@ export interface IDependencyManagerService {
22
29
  addOtherFormulaDependency(unitId: string, sheetId: string, formulaId: string, dependencyTree: FormulaDependencyTree): void;
23
30
  removeOtherFormulaDependency(unitId: string, sheetId: string, formulaId: string[]): void;
24
31
  hasOtherFormulaDependency(unitId: string, sheetId: string, formulaId: string): boolean;
25
- addFeatureFormulaDependency(featureId: string, dependencyTree: FormulaDependencyTree): void;
26
- removeFeatureFormulaDependency(featureId: string): void;
32
+ addFeatureFormulaDependency(unitId: string, sheetId: string, featureId: string, dependencyTree: FormulaDependencyTree): void;
33
+ removeFeatureFormulaDependency(unitId: string, sheetId: string, featureIds: string[]): void;
34
+ getFeatureFormulaDependency(unitId: string, sheetId: string, featureId: string): Nullable<FormulaDependencyTree>;
27
35
  hasFeatureFormulaDependency(unitId: string, sheetId: string, featureId: string): boolean;
28
36
  addFormulaDependency(unitId: string, sheetId: string, row: number, column: number, dependencyTree: FormulaDependencyTree): void;
29
37
  removeFormulaDependency(unitId: string, sheetId: string, row: number, column: number): void;
@@ -68,10 +76,12 @@ export declare class DependencyManagerService extends Disposable implements IDep
68
76
  reset(): void;
69
77
  addOtherFormulaDependency(unitId: string, sheetId: string, formulaId: string, dependencyTree: FormulaDependencyTree): void;
70
78
  removeOtherFormulaDependency(unitId: string, sheetId: string, formulaIds: string[]): void;
79
+ getOtherFormulaDependency(unitId: string, sheetId: string, formulaId: string): Nullable<FormulaDependencyTree>;
71
80
  hasOtherFormulaDependency(unitId: string, sheetId: string, formulaId: string): boolean;
72
- addFeatureFormulaDependency(featureId: string, dependencyTree: FormulaDependencyTree): void;
73
- removeFeatureFormulaDependency(featureId: string): void;
74
- hasFeatureFormulaDependency(featureId: string): boolean;
81
+ addFeatureFormulaDependency(unitId: string, sheetId: string, featureId: string, dependencyTree: FormulaDependencyTree): void;
82
+ removeFeatureFormulaDependency(unitId: string, sheetId: string, featureIds: string[]): void;
83
+ getFeatureFormulaDependency(unitId: string, sheetId: string, featureId: string): Nullable<FormulaDependencyTree>;
84
+ hasFeatureFormulaDependency(unitId: string, sheetId: string, featureId: string): boolean;
75
85
  addFormulaDependency(unitId: string, sheetId: string, row: number, column: number, dependencyTree: FormulaDependencyTree): void;
76
86
  removeFormulaDependency(unitId: string, sheetId: string, row: number, column: number): void;
77
87
  clearFormulaDependency(unitId: string, sheetId: string): void;
@@ -1,23 +1,28 @@
1
1
  import { IUnitRange, Nullable, Disposable } from '@univerjs/core';
2
+ import { Observable } from 'rxjs';
2
3
  import { IFeatureDirtyRangeType, IRuntimeUnitDataType } from '../basics/common';
4
+ import { IRemoveFeatureCalculationMutationParam } from '../commands/mutations/set-feature-calculation.mutation';
3
5
  import { FormulaDependencyTree } from '../engine/dependency/dependency-tree';
6
+ import { IAllRuntimeData } from './runtime.service';
7
+ import { IFormulaDirtyData } from './current-data.service';
4
8
 
5
9
  export interface IFeatureCalculationManagerParam {
6
10
  unitId: string;
7
11
  subUnitId: string;
8
12
  dependencyRanges: IUnitRange[];
9
- getDirtyData: (currentDependencyTree: FormulaDependencyTree) => {
13
+ getDirtyData: (tree: FormulaDependencyTree, dirtyData: IFormulaDirtyData, runtimeData: IAllRuntimeData) => {
10
14
  runtimeCellData: IRuntimeUnitDataType;
11
15
  dirtyRanges: IFeatureDirtyRangeType;
12
16
  };
13
17
  }
14
18
  export interface IFeatureCalculationManagerService {
15
19
  dispose(): void;
16
- remove(featureId: string): void;
17
- get(featureId: string): Nullable<IFeatureCalculationManagerParam>;
18
- has(featureId: string): boolean;
19
- register(featureId: string, referenceExecutor: IFeatureCalculationManagerParam): void;
20
- getReferenceExecutorMap(): Map<string, IFeatureCalculationManagerParam>;
20
+ remove(unitId: string, subUnitId: string, featureIds: string[]): void;
21
+ get(unitId: string, subUnitId: string, featureId: string): Nullable<IFeatureCalculationManagerParam>;
22
+ has(unitId: string, subUnitId: string, featureId: string): boolean;
23
+ register(unitId: string, subUnitId: string, featureId: string, referenceExecutor: IFeatureCalculationManagerParam): void;
24
+ getReferenceExecutorMap(): Map<string, Map<string, Map<string, IFeatureCalculationManagerParam>>>;
25
+ onChanged$: Observable<IRemoveFeatureCalculationMutationParam>;
21
26
  }
22
27
  /**
23
28
  * Passively marked as dirty, register the reference and execution actions of the feature plugin.
@@ -27,11 +32,13 @@ export interface IFeatureCalculationManagerService {
27
32
  */
28
33
  export declare class FeatureCalculationManagerService extends Disposable implements IFeatureCalculationManagerService {
29
34
  private _referenceExecutorMap;
35
+ private _onChanged$;
36
+ readonly onChanged$: Observable<IRemoveFeatureCalculationMutationParam>;
30
37
  dispose(): void;
31
- remove(featureId: string): void;
32
- get(featureId: string): IFeatureCalculationManagerParam | undefined;
33
- has(featureId: string): boolean;
34
- register(featureId: string, referenceExecutor: IFeatureCalculationManagerParam): void;
35
- getReferenceExecutorMap(): Map<string, IFeatureCalculationManagerParam>;
38
+ remove(unitId: string, subUnitId: string, featureIds: string[]): void;
39
+ get(unitId: string, subUnitId: string, featureId: string): IFeatureCalculationManagerParam | undefined;
40
+ has(unitId: string, subUnitId: string, featureId: string): boolean;
41
+ register(unitId: string, subUnitId: string, featureId: string, referenceExecutor: IFeatureCalculationManagerParam): void;
42
+ getReferenceExecutorMap(): Map<string, Map<string, Map<string, IFeatureCalculationManagerParam>>>;
36
43
  }
37
44
  export declare const IFeatureCalculationManagerService: import('@univerjs/core').IdentifierDecorator<FeatureCalculationManagerService>;