@univerjs/engine-formula 0.3.0 → 0.4.0-alpha.0

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 (47) hide show
  1. package/lib/cjs/index.js +2 -2
  2. package/lib/es/index.js +22119 -21333
  3. package/lib/types/basics/common.d.ts +2 -0
  4. package/lib/types/basics/match-token.d.ts +4 -0
  5. package/lib/types/basics/token-type.d.ts +1 -0
  6. package/lib/types/basics/token.d.ts +2 -1
  7. package/lib/types/commands/mutations/set-defined-name.mutation.d.ts +8 -1
  8. package/lib/types/commands/mutations/set-formula-calculation.mutation.d.ts +1 -1
  9. package/lib/types/commands/mutations/set-formula-data.mutation.d.ts +4 -1
  10. package/lib/types/controller/calculate.controller.d.ts +3 -4
  11. package/lib/types/controller/set-dependency.controller.d.ts +1 -0
  12. package/lib/types/controller/set-other-formula.controller.d.ts +1 -1
  13. package/lib/types/engine/analysis/lexer-tree-builder.d.ts +20 -3
  14. package/lib/types/engine/analysis/parser.d.ts +2 -1
  15. package/lib/types/engine/ast-node/base-ast-node.d.ts +4 -1
  16. package/lib/types/engine/ast-node/function-node.d.ts +9 -3
  17. package/lib/types/engine/ast-node/lambda-node.d.ts +0 -1
  18. package/lib/types/engine/ast-node/lambda-parameter-node.d.ts +1 -1
  19. package/lib/types/engine/dependency/dependency-tree.d.ts +12 -51
  20. package/lib/types/engine/dependency/formula-dependency.d.ts +10 -4
  21. package/lib/types/engine/dependency/generate-tree-id.d.ts +2 -0
  22. package/lib/types/engine/interpreter/interpreter.d.ts +2 -2
  23. package/lib/types/engine/reference-object/base-reference-object.d.ts +2 -2
  24. package/lib/types/engine/utils/check-variant-error.d.ts +9 -0
  25. package/lib/types/engine/utils/prefixHandler.d.ts +1 -1
  26. package/lib/types/engine/utils/reference.d.ts +1 -0
  27. package/lib/types/engine/utils/regexp-check.d.ts +22 -0
  28. package/lib/types/engine/utils/update-lambda-statement.d.ts +3 -0
  29. package/lib/types/engine/value-object/array-value-object.d.ts +1 -1
  30. package/lib/types/functions/text/function-names.d.ts +3 -0
  31. package/lib/types/functions/text/regexextract/__test__/index.spec.d.ts +16 -0
  32. package/lib/types/functions/text/regexextract/index.d.ts +7 -0
  33. package/lib/types/functions/text/regexmatch/__test__/index.spec.d.ts +16 -0
  34. package/lib/types/functions/text/regexmatch/index.d.ts +7 -0
  35. package/lib/types/functions/text/regexreplace/__test__/index.spec.d.ts +16 -0
  36. package/lib/types/functions/text/regexreplace/index.d.ts +7 -0
  37. package/lib/types/index.d.ts +42 -42
  38. package/lib/types/models/formula-data.model.d.ts +2 -2
  39. package/lib/types/plugin.d.ts +3 -1
  40. package/lib/types/services/active-dirty-manager.service.d.ts +1 -0
  41. package/lib/types/services/calculate-formula.service.d.ts +2 -2
  42. package/lib/types/services/current-data.service.d.ts +8 -1
  43. package/lib/types/services/defined-names.service.d.ts +5 -2
  44. package/lib/types/services/dependency-manager.service.d.ts +34 -10
  45. package/lib/types/services/runtime.service.d.ts +12 -0
  46. package/lib/umd/index.js +2 -2
  47. package/package.json +9 -10
@@ -14,6 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export type { IArrayFormulaRangeType, IArrayFormulaUnitCellType, IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefinedNameMap, IDirtyUnitSheetNameMap, IFeatureDirtyRangeType, IFormulaData, IFormulaDataItem, IFormulaDatasetConfig, IRuntimeUnitDataType, ISheetData, IUnitData, IUnitSheetNameMap, } from './basics/common';
17
+ export { BooleanValue } from './basics/common';
17
18
  export { isInDirtyRange } from './basics/dirty';
18
19
  export { ERROR_TYPE_SET, ErrorType } from './basics/error-type';
19
20
  export { FunctionType, type IFunctionInfo, type IFunctionParam } from './basics/function';
@@ -21,28 +22,56 @@ export { type IFunctionNames } from './basics/function';
21
22
  export { includeFormulaLexerToken, isFormulaLexerToken, normalizeSheetName } from './basics/match-token';
22
23
  export { convertUnitDataToRuntime } from './basics/runtime';
23
24
  export { compareToken, matchToken, operatorToken } from './basics/token';
25
+ export { matchRefDrawToken } from './basics/match-token';
26
+ export { isReferenceString } from './basics/regex';
27
+ export { RegisterFunctionMutation } from './commands/mutations/register-function.mutation';
28
+ export { type ISetArrayFormulaDataMutationParams, SetArrayFormulaDataMutation } from './commands/mutations/set-array-formula-data.mutation';
29
+ export { type ISetDefinedNameMutationParam, type ISetDefinedNameMutationSearchParam, RemoveDefinedNameMutation, SetDefinedNameMutation } from './commands/mutations/set-defined-name.mutation';
30
+ export { SetDefinedNameMutationFactory } from './commands/mutations/set-defined-name.mutation';
31
+ export { RemoveFeatureCalculationMutation, SetFeatureCalculationMutation } from './commands/mutations/set-feature-calculation.mutation';
32
+ export { type ISetFormulaCalculationNotificationMutation, type ISetFormulaCalculationResultMutation, type ISetFormulaCalculationStartMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation, } from './commands/mutations/set-formula-calculation.mutation';
33
+ export { type ISetFormulaDataMutationParams, SetFormulaDataMutation } from './commands/mutations/set-formula-data.mutation';
34
+ export { type IRemoveOtherFormulaMutationParams, type ISetOtherFormulaMutationParams, RemoveOtherFormulaMutation, SetOtherFormulaMutation } from './commands/mutations/set-other-formula.mutation';
35
+ export { RemoveSuperTableMutation, SetSuperTableMutation, SetSuperTableOptionMutation } from './commands/mutations/set-super-table.mutation';
36
+ export { CalculateController } from './controller/calculate.controller';
37
+ export { SetDefinedNameController } from './controller/set-defined-name.controller';
38
+ export { Lexer } from './engine/analysis/lexer';
24
39
  export { LexerNode } from './engine/analysis/lexer-node';
25
40
  export { LexerTreeBuilder } from './engine/analysis/lexer-tree-builder';
41
+ export { AstTreeBuilder } from './engine/analysis/parser';
42
+ export { AstRootNodeFactory } from './engine/ast-node/ast-root-node';
43
+ export { FunctionNodeFactory } from './engine/ast-node/function-node';
44
+ export { LambdaNodeFactory } from './engine/ast-node/lambda-node';
45
+ export { LambdaParameterNodeFactory } from './engine/ast-node/lambda-parameter-node';
46
+ export { OperatorNodeFactory } from './engine/ast-node/operator-node';
47
+ export { PrefixNodeFactory } from './engine/ast-node/prefix-node';
48
+ export { ReferenceNodeFactory } from './engine/ast-node/reference-node';
49
+ export { SuffixNodeFactory } from './engine/ast-node/suffix-node';
50
+ export { UnionNodeFactory } from './engine/ast-node/union-node';
51
+ export { ValueNodeFactory } from './engine/ast-node/value-node';
52
+ export { FormulaDependencyGenerator } from './engine/dependency/formula-dependency';
53
+ export { Interpreter } from './engine/interpreter/interpreter';
26
54
  export { BaseReferenceObject, type FunctionVariantType } from './engine/reference-object/base-reference-object';
55
+ export { AsyncArrayObject, AsyncObject } from './engine/reference-object/base-reference-object';
27
56
  export { RangeReferenceObject } from './engine/reference-object/range-reference-object';
57
+ export { strip, stripErrorMargin } from './engine/utils/math-kit';
58
+ export { handleNumfmtInCell } from './engine/utils/numfmt-kit';
28
59
  export { deserializeRangeForR1C1 } from './engine/utils/r1c1-reference';
29
60
  export { deserializeRangeWithSheet, getAbsoluteRefTypeWithSingleString, getAbsoluteRefTypeWitString, getRangeWithRefsString, type IAbsoluteRefTypeForRange, isReferenceStrings, isReferenceStringWithEffectiveColumn, serializeRange, serializeRangeToRefString, serializeRangeWithSheet, serializeRangeWithSpreadsheet, singleReferenceToGrid, } from './engine/utils/reference';
61
+ export { handleRefStringInfo } from './engine/utils/reference';
30
62
  export { generateStringWithSequence, type ISequenceNode, sequenceNodeType } from './engine/utils/sequence';
31
63
  export { ArrayValueObject, ValueObjectFactory } from './engine/value-object/array-value-object';
32
64
  export { BaseValueObject, ErrorValueObject } from './engine/value-object/base-value-object';
33
- export { BooleanValue } from './basics/common';
34
65
  export type { PrimitiveValueType } from './engine/value-object/primitive-object';
35
- export { NumberValueObject } from './engine/value-object/primitive-object';
36
- export { BooleanValueObject } from './engine/value-object/primitive-object';
37
- export { NullValueObject, StringValueObject } from './engine/value-object/primitive-object';
66
+ export { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from './engine/value-object/primitive-object';
38
67
  export { functionArray } from './functions/array/function-map';
39
68
  export { FUNCTION_NAMES_ARRAY } from './functions/array/function-names';
40
69
  export { BaseFunction } from './functions/base-function';
41
- export { CustomFunction } from './functions/custom-function';
42
70
  export { functionCompatibility } from './functions/compatibility/function-map';
43
71
  export { FUNCTION_NAMES_COMPATIBILITY } from './functions/compatibility/function-names';
44
72
  export { functionCube } from './functions/cube/function-map';
45
73
  export { FUNCTION_NAMES_CUBE } from './functions/cube/function-names';
74
+ export { CustomFunction } from './functions/custom-function';
46
75
  export { functionDatabase } from './functions/database/function-map';
47
76
  export { FUNCTION_NAMES_DATABASE } from './functions/database/function-names';
48
77
  export { functionDate } from './functions/date/function-map';
@@ -70,50 +99,21 @@ export { functionWeb } from './functions/web/function-map';
70
99
  export { FUNCTION_NAMES_WEB } from './functions/web/function-names';
71
100
  export { FormulaDataModel } from './models/formula-data.model';
72
101
  export { initSheetFormulaData } from './models/formula-data.model';
102
+ export type { IRangeChange } from './models/formula-data.model';
73
103
  export { UniverFormulaEnginePlugin } from './plugin';
104
+ export { IActiveDirtyManagerService } from './services/active-dirty-manager.service';
105
+ export { ActiveDirtyManagerService } from './services/active-dirty-manager.service';
74
106
  export { CalculateFormulaService } from './services/calculate-formula.service';
75
- export { FeatureCalculationManagerService, IFeatureCalculationManagerService, } from './services/feature-calculation-manager.service';
107
+ export { FormulaCurrentConfigService, IFormulaCurrentConfigService, type IFormulaDirtyData } from './services/current-data.service';
108
+ export { DefinedNamesService, type IDefinedNameMapItem, IDefinedNamesService, type IDefinedNamesServiceParam } from './services/defined-names.service';
109
+ export { IDependencyManagerService } from './services/dependency-manager.service';
110
+ export { DependencyManagerService } from './services/dependency-manager.service';
111
+ export { FeatureCalculationManagerService, IFeatureCalculationManagerService } from './services/feature-calculation-manager.service';
76
112
  export { FunctionService } from './services/function.service';
77
113
  export { IFunctionService } from './services/function.service';
78
114
  export { IOtherFormulaManagerService, OtherFormulaManagerService } from './services/other-formula-manager.service';
79
115
  export { FormulaExecuteStageType, type IExecutionInProgressParams } from './services/runtime.service';
80
116
  export { FormulaExecutedStateType, type IAllRuntimeData } from './services/runtime.service';
81
- export { isReferenceString } from './basics/regex';
82
- export { matchRefDrawToken } from './basics/match-token';
83
- export { DefinedNamesService, type IDefinedNameMapItem, IDefinedNamesService, type IDefinedNamesServiceParam } from './services/defined-names.service';
84
117
  export { FormulaRuntimeService, IFormulaRuntimeService } from './services/runtime.service';
85
- export { FormulaCurrentConfigService, IFormulaCurrentConfigService, type IFormulaDirtyData } from './services/current-data.service';
86
- export { IActiveDirtyManagerService } from './services/active-dirty-manager.service';
87
- export { ActiveDirtyManagerService } from './services/active-dirty-manager.service';
88
- export type { IRangeChange } from './models/formula-data.model';
89
- export { handleNumfmtInCell } from './engine/utils/numfmt-kit';
90
- export { AsyncArrayObject } from './engine/reference-object/base-reference-object';
91
- export { strip, stripErrorMargin } from './engine/utils/math-kit';
92
- export { AsyncObject } from './engine/reference-object/base-reference-object';
93
- export { Lexer } from './engine/analysis/lexer';
94
- export { FormulaDependencyGenerator } from './engine/dependency/formula-dependency';
95
118
  export { ISuperTableService } from './services/super-table.service';
96
119
  export { SuperTableService } from './services/super-table.service';
97
- export { Interpreter } from './engine/interpreter/interpreter';
98
- export { AstTreeBuilder } from './engine/analysis/parser';
99
- export { AstRootNodeFactory } from './engine/ast-node/ast-root-node';
100
- export { FunctionNodeFactory } from './engine/ast-node/function-node';
101
- export { LambdaNodeFactory } from './engine/ast-node/lambda-node';
102
- export { LambdaParameterNodeFactory } from './engine/ast-node/lambda-parameter-node';
103
- export { OperatorNodeFactory } from './engine/ast-node/operator-node';
104
- export { PrefixNodeFactory } from './engine/ast-node/prefix-node';
105
- export { ReferenceNodeFactory } from './engine/ast-node/reference-node';
106
- export { SuffixNodeFactory } from './engine/ast-node/suffix-node';
107
- export { UnionNodeFactory } from './engine/ast-node/union-node';
108
- export { ValueNodeFactory } from './engine/ast-node/value-node';
109
- export { IDependencyManagerService } from './services/dependency-manager.service';
110
- export { DependencyManagerService } from './services/dependency-manager.service';
111
- export { CalculateController } from './controller/calculate.controller';
112
- export { RegisterFunctionMutation } from './commands/mutations/register-function.mutation';
113
- export { type ISetArrayFormulaDataMutationParams, SetArrayFormulaDataMutation } from './commands/mutations/set-array-formula-data.mutation';
114
- export { type ISetDefinedNameMutationParam, type ISetDefinedNameMutationSearchParam, RemoveDefinedNameMutation, SetDefinedNameMutation, } from './commands/mutations/set-defined-name.mutation';
115
- export { RemoveFeatureCalculationMutation, SetFeatureCalculationMutation } from './commands/mutations/set-feature-calculation.mutation';
116
- export { type ISetFormulaCalculationNotificationMutation, type ISetFormulaCalculationResultMutation, type ISetFormulaCalculationStartMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation, } from './commands/mutations/set-formula-calculation.mutation';
117
- export { type ISetFormulaDataMutationParams, SetFormulaDataMutation } from './commands/mutations/set-formula-data.mutation';
118
- export { type IRemoveOtherFormulaMutationParams, type ISetOtherFormulaMutationParams, RemoveOtherFormulaMutation, SetOtherFormulaMutation, } from './commands/mutations/set-other-formula.mutation';
119
- export { RemoveSuperTableMutation, SetSuperTableMutation, SetSuperTableOptionMutation, } from './commands/mutations/set-super-table.mutation';
@@ -1,7 +1,7 @@
1
- import { Disposable, IUniverInstanceService, ObjectMatrix, ICellData, IObjectMatrixPrimitiveType, IRange, Nullable } from '@univerjs/core';
2
- import { LexerTreeBuilder } from '../engine/analysis/lexer-tree-builder';
1
+ import { ICellData, IObjectMatrixPrimitiveType, IRange, Nullable, Disposable, IUniverInstanceService, ObjectMatrix } from '@univerjs/core';
3
2
  import { IArrayFormulaRangeType, IArrayFormulaUnitCellType, IFormulaData, IFormulaDataItem, IRuntimeUnitDataType, IUnitData, IUnitSheetNameMap } from '../basics/common';
4
3
  import { IFormulaIdMap } from './utils/formula-data-util';
4
+ import { LexerTreeBuilder } from '../engine/analysis/lexer-tree-builder';
5
5
  export interface IRangeChange {
6
6
  oldCell: IRange;
7
7
  newCell: IRange | null;
@@ -1,5 +1,5 @@
1
- import { IConfigService, Injector, Plugin } from '@univerjs/core';
2
1
  import { IUniverEngineFormulaConfig } from './controller/config.schema';
2
+ import { IConfigService, Injector, Plugin } from '@univerjs/core';
3
3
  export declare class UniverFormulaEnginePlugin extends Plugin {
4
4
  private readonly _config;
5
5
  protected _injector: Injector;
@@ -7,5 +7,7 @@ export declare class UniverFormulaEnginePlugin extends Plugin {
7
7
  static pluginName: string;
8
8
  constructor(_config: Partial<IUniverEngineFormulaConfig> | undefined, _injector: Injector, _configService: IConfigService);
9
9
  onStarting(): void;
10
+ onReady(): void;
11
+ onRendered(): void;
10
12
  private _initialize;
11
13
  }
@@ -8,6 +8,7 @@ export interface IDirtyConversionManagerParams {
8
8
  dirtyDefinedNameMap?: IDirtyUnitSheetDefinedNameMap;
9
9
  dirtyUnitFeatureMap?: IDirtyUnitFeatureMap;
10
10
  dirtyUnitOtherFormulaMap?: IDirtyUnitOtherFormulaMap;
11
+ clearDependencyTreeCache?: IDirtyUnitSheetNameMap;
11
12
  };
12
13
  }
13
14
  export interface IActiveDirtyManagerService {
@@ -1,12 +1,12 @@
1
- import { Disposable, IConfigService } from '@univerjs/core';
2
1
  import { IFeatureDirtyRangeType, IFormulaDatasetConfig, IRuntimeUnitDataType } from '../basics/common';
2
+ import { IAllRuntimeData, IExecutionInProgressParams, IFormulaRuntimeService } from './runtime.service';
3
+ import { Disposable, IConfigService } from '@univerjs/core';
3
4
  import { Lexer } from '../engine/analysis/lexer';
4
5
  import { AstTreeBuilder } from '../engine/analysis/parser';
5
6
  import { ErrorNode } from '../engine/ast-node/base-ast-node';
6
7
  import { FormulaDependencyGenerator } from '../engine/dependency/formula-dependency';
7
8
  import { Interpreter } from '../engine/interpreter/interpreter';
8
9
  import { IFormulaCurrentConfigService } from './current-data.service';
9
- import { IAllRuntimeData, IExecutionInProgressParams, IFormulaRuntimeService } from './runtime.service';
10
10
  export declare const DEFAULT_CYCLE_REFERENCE_COUNT = 1;
11
11
  export declare const CYCLE_REFERENCE_COUNT = "cycleReferenceCount";
12
12
  export declare const EVERY_N_FUNCTION_EXECUTION_PAUSE = 100;
@@ -1,5 +1,5 @@
1
1
  import { IUnitRange, Nullable, Disposable, IUniverInstanceService } from '@univerjs/core';
2
- import { IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefinedNameMap, IDirtyUnitSheetNameMap, IFormulaData, IFormulaDatasetConfig, IRuntimeUnitDataType, IUnitData, IUnitExcludedCell, IUnitSheetNameMap, IUnitStylesData } from '../basics/common';
2
+ import { IArrayFormulaRangeType, IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefinedNameMap, IDirtyUnitSheetNameMap, IFormulaData, IFormulaDatasetConfig, IRuntimeUnitDataType, IUnitData, IUnitExcludedCell, IUnitSheetNameMap, IUnitStylesData } from '../basics/common';
3
3
  export interface IFormulaDirtyData {
4
4
  forceCalculation: boolean;
5
5
  dirtyRanges: IUnitRange[];
@@ -7,6 +7,7 @@ export interface IFormulaDirtyData {
7
7
  dirtyDefinedNameMap: IDirtyUnitSheetDefinedNameMap;
8
8
  dirtyUnitFeatureMap: IDirtyUnitFeatureMap;
9
9
  dirtyUnitOtherFormulaMap: IDirtyUnitOtherFormulaMap;
10
+ clearDependencyTreeCache: IDirtyUnitSheetNameMap;
10
11
  }
11
12
  export interface IFormulaCurrentConfigService {
12
13
  load(config: IFormulaDatasetConfig): void;
@@ -28,6 +29,7 @@ export interface IFormulaCurrentConfigService {
28
29
  getExcludedRange(): Nullable<IUnitExcludedCell>;
29
30
  loadDirtyRangesAndExcludedCell(dirtyRanges: IUnitRange[], excludedCell?: IUnitExcludedCell): void;
30
31
  getArrayFormulaCellData(): IRuntimeUnitDataType;
32
+ getArrayFormulaRange(): IArrayFormulaRangeType;
31
33
  getSheetName(unitId: string, sheetId: string): string;
32
34
  getDirtyUnitOtherFormulaMap(): IDirtyUnitOtherFormulaMap;
33
35
  getExecuteUnitId(): Nullable<string>;
@@ -35,15 +37,18 @@ export interface IFormulaCurrentConfigService {
35
37
  setExecuteUnitId(unitId: string): void;
36
38
  setExecuteSubUnitId(subUnitId: string): void;
37
39
  getDirtyData(): IFormulaDirtyData;
40
+ getClearDependencyTreeCache(): IDirtyUnitSheetNameMap;
38
41
  }
39
42
  export declare class FormulaCurrentConfigService extends Disposable implements IFormulaCurrentConfigService {
40
43
  private readonly _univerInstanceService;
41
44
  private _unitData;
42
45
  private _unitStylesData;
43
46
  private _arrayFormulaCellData;
47
+ private _arrayFormulaRange;
44
48
  private _formulaData;
45
49
  private _sheetNameMap;
46
50
  private _forceCalculate;
51
+ private _clearDependencyTreeCache;
47
52
  private _dirtyRanges;
48
53
  private _dirtyNameMap;
49
54
  private _dirtyDefinedNameMap;
@@ -64,6 +69,7 @@ export declare class FormulaCurrentConfigService extends Disposable implements I
64
69
  getUnitStylesData(): IUnitStylesData;
65
70
  getFormulaData(): IFormulaData;
66
71
  getArrayFormulaCellData(): IRuntimeUnitDataType;
72
+ getArrayFormulaRange(): IArrayFormulaRangeType;
67
73
  getSheetNameMap(): IUnitSheetNameMap;
68
74
  isForceCalculate(): boolean;
69
75
  getDirtyRanges(): IUnitRange[];
@@ -72,6 +78,7 @@ export declare class FormulaCurrentConfigService extends Disposable implements I
72
78
  getDirtyUnitFeatureMap(): IDirtyUnitFeatureMap;
73
79
  getDirtyUnitOtherFormulaMap(): IDirtyUnitOtherFormulaMap;
74
80
  getSheetName(unitId: string, sheetId: string): string;
81
+ getClearDependencyTreeCache(): IDirtyUnitSheetNameMap;
75
82
  load(config: IFormulaDatasetConfig): void;
76
83
  getDirtyData(): IFormulaDirtyData;
77
84
  loadDirtyRangesAndExcludedCell(dirtyRanges: IUnitRange[], excludedCell?: IUnitExcludedCell): void;
@@ -1,4 +1,4 @@
1
- import { IUnitRange, Nullable, Disposable } from '@univerjs/core';
1
+ import { IUnitRange, Nullable, Worksheet, Disposable, IUniverInstanceService } from '@univerjs/core';
2
2
  import { Observable } from 'rxjs';
3
3
  export interface IDefinedNamesServiceParam {
4
4
  id: string;
@@ -33,8 +33,10 @@ export interface IDefinedNamesService {
33
33
  update$: Observable<unknown>;
34
34
  focusRange$: Observable<IDefinedNamesServiceFocusParam>;
35
35
  focusRange(unitId: string, id: string): void;
36
+ getWorksheetByRef(unitId: string, ref: string): Nullable<Worksheet>;
36
37
  }
37
38
  export declare class DefinedNamesService extends Disposable implements IDefinedNamesService {
39
+ private readonly _univerInstanceService;
38
40
  private _definedNameMap;
39
41
  private readonly _update$;
40
42
  readonly update$: Observable<unknown>;
@@ -43,8 +45,9 @@ export declare class DefinedNamesService extends Disposable implements IDefinedN
43
45
  readonly currentRange$: Observable<IUnitRange>;
44
46
  private readonly _focusRange$;
45
47
  readonly focusRange$: Observable<IDefinedNamesServiceFocusParam>;
46
- constructor();
48
+ constructor(_univerInstanceService: IUniverInstanceService);
47
49
  dispose(): void;
50
+ getWorksheetByRef(unitId: string, ref: string): Nullable<Worksheet>;
48
51
  focusRange(unitId: string, id: string): void;
49
52
  setCurrentRange(range: IUnitRange): void;
50
53
  getCurrentRange(): IUnitRange;
@@ -1,5 +1,5 @@
1
- import { Disposable, ObjectMatrix, Nullable } from '@univerjs/core';
2
- import { FormulaDependencyTreeCache, FormulaDependencyTree } from '../engine/dependency/dependency-tree';
1
+ import { IRTreeItem, IUnitRange, Nullable, Disposable, ObjectMatrix } from '@univerjs/core';
2
+ import { FormulaDependencyTree } from '../engine/dependency/dependency-tree';
3
3
  export interface IOtherFormulaDependencyParam {
4
4
  [unitId: string]: Nullable<{
5
5
  [sheetId: string]: {
@@ -22,20 +22,26 @@ export interface IFormulaDependencyParam {
22
22
  export interface IDependencyManagerService {
23
23
  dispose(): void;
24
24
  getAllTree(): FormulaDependencyTree[];
25
- buildDependencyTree(shouldBeBuildTrees: FormulaDependencyTree[] | FormulaDependencyTreeCache, dependencyTrees?: FormulaDependencyTree[]): FormulaDependencyTree[];
25
+ buildDependencyTree(shouldBeBuildTrees: FormulaDependencyTree[], dependencyTrees?: FormulaDependencyTree[]): FormulaDependencyTree[];
26
26
  clearDependencyForTree(shouldBeClearTree: Nullable<FormulaDependencyTree>): void;
27
27
  reset(): void;
28
28
  addOtherFormulaDependency(unitId: string, sheetId: string, formulaId: string, dependencyTree: FormulaDependencyTree): void;
29
29
  removeOtherFormulaDependency(unitId: string, sheetId: string, formulaId: string[]): void;
30
- hasOtherFormulaDependency(unitId: string, sheetId: string, formulaId: string): boolean;
30
+ getOtherFormulaDependency(unitId: string, sheetId: string, formulaId: string): Nullable<FormulaDependencyTree>;
31
31
  addFeatureFormulaDependency(unitId: string, sheetId: string, featureId: string, dependencyTree: FormulaDependencyTree): void;
32
32
  removeFeatureFormulaDependency(unitId: string, sheetId: string, featureIds: string[]): void;
33
33
  getFeatureFormulaDependency(unitId: string, sheetId: string, featureId: string): Nullable<FormulaDependencyTree>;
34
- hasFeatureFormulaDependency(unitId: string, sheetId: string, featureId: string): boolean;
35
34
  addFormulaDependency(unitId: string, sheetId: string, row: number, column: number, dependencyTree: FormulaDependencyTree): void;
36
35
  removeFormulaDependency(unitId: string, sheetId: string, row: number, column: number): void;
37
- hasFormulaDependency(unitId: string, sheetId: string, row: number, column: number): boolean;
36
+ getFormulaDependency(unitId: string, sheetId: string, row: number, column: number): Nullable<FormulaDependencyTree>;
37
+ removeFormulaDependencyByDefinedName(unitId: string, definedName: string): void;
38
38
  clearFormulaDependency(unitId: string, sheetId?: string): void;
39
+ addDependencyRTreeCache(tree: FormulaDependencyTree): void;
40
+ searchDependency(search: IUnitRange[]): Map<string, IRTreeItem>;
41
+ hasTreeIdInCache(treeId: string): boolean;
42
+ clearDependencyAll(): void;
43
+ clearOtherFormulaDependency(unitId: string, sheetId?: string): void;
44
+ clearFeatureFormulaDependency(unitId: string, sheetId?: string): void;
39
45
  }
40
46
  /**
41
47
  * Passively marked as dirty, register the reference and execution actions of the feature plugin.
@@ -47,20 +53,28 @@ export declare class DependencyManagerService extends Disposable implements IDep
47
53
  private _otherFormulaData;
48
54
  private _featureFormulaData;
49
55
  private _formulaData;
56
+ private _dependencyRTreeCache;
57
+ private _dependencyTreeIdsCache;
50
58
  dispose(): void;
51
59
  /**
52
60
  * Get all FormulaDependencyTree from _otherFormulaData, _featureFormulaData, _formulaData
53
61
  * return FormulaDependencyTree[]
54
62
  */
55
63
  getAllTree(): FormulaDependencyTree[];
56
- buildDependencyTree(shouldBeBuildTrees: FormulaDependencyTree[] | FormulaDependencyTreeCache, dependencyTrees?: FormulaDependencyTree[]): FormulaDependencyTree[];
57
- private _buildDependencyTreeWithCache;
64
+ buildDependencyTree(shouldBeBuildTrees: FormulaDependencyTree[], dependencyTrees?: FormulaDependencyTree[]): FormulaDependencyTree[];
65
+ searchDependency(search: IUnitRange[]): Map<string, IRTreeItem>;
58
66
  /**
59
67
  * Build the dependency relationship between the trees.
60
68
  * @param allTrees all FormulaDependencyTree
61
69
  * @param shouldBeBuildTrees FormulaDependencyTree[] | FormulaDependencyTreeCache
62
70
  */
63
71
  private _buildDependencyTree;
72
+ /**
73
+ * Build the reverse dependency relationship between the trees.
74
+ * @param allTrees
75
+ * @param dependencyTrees
76
+ */
77
+ private _buildReverseDependency;
64
78
  /**
65
79
  * Clear the dependency relationship of the tree.
66
80
  * establish the relationship between the parent and the child.
@@ -72,13 +86,23 @@ export declare class DependencyManagerService extends Disposable implements IDep
72
86
  removeOtherFormulaDependency(unitId: string, sheetId: string, formulaIds: string[]): void;
73
87
  getOtherFormulaDependency(unitId: string, sheetId: string, formulaId: string): Nullable<FormulaDependencyTree>;
74
88
  hasOtherFormulaDependency(unitId: string, sheetId: string, formulaId: string): boolean;
89
+ clearOtherFormulaDependency(unitId: string, sheetId?: string): void;
75
90
  addFeatureFormulaDependency(unitId: string, sheetId: string, featureId: string, dependencyTree: FormulaDependencyTree): void;
76
91
  removeFeatureFormulaDependency(unitId: string, sheetId: string, featureIds: string[]): void;
92
+ clearFeatureFormulaDependency(unitId: string, sheetId?: string): void;
77
93
  getFeatureFormulaDependency(unitId: string, sheetId: string, featureId: string): Nullable<FormulaDependencyTree>;
78
- hasFeatureFormulaDependency(unitId: string, sheetId: string, featureId: string): boolean;
79
94
  addFormulaDependency(unitId: string, sheetId: string, row: number, column: number, dependencyTree: FormulaDependencyTree): void;
80
95
  removeFormulaDependency(unitId: string, sheetId: string, row: number, column: number): void;
81
96
  clearFormulaDependency(unitId: string, sheetId?: string): void;
82
- hasFormulaDependency(unitId: string, sheetId: string, row: number, column: number): boolean;
97
+ clearDependencyAll(): void;
98
+ getFormulaDependency(unitId: string, sheetId: string, row: number, column: number): Nullable<Nullable<FormulaDependencyTree>>;
99
+ addDependencyRTreeCache(tree: FormulaDependencyTree): void;
100
+ private _addTreeIdToCache;
101
+ private _removeTreeIdFromCache;
102
+ private _clearTreeIdCache;
103
+ hasTreeIdInCache(treeId: string): boolean;
104
+ private _removeDependencyRTreeCacheById;
105
+ private _removeDependencyRTreeCache;
106
+ removeFormulaDependencyByDefinedName(unitId: string, definedName: string): void;
83
107
  }
84
108
  export declare const IDependencyManagerService: import('@wendellhu/redi').IdentifierDecorator<DependencyManagerService>;
@@ -175,6 +175,18 @@ export declare class FormulaRuntimeService extends Disposable implements IFormul
175
175
  getRuntimeState(): IExecutionInProgressParams;
176
176
  private _checkIfArrayFormulaRangeHasData;
177
177
  private _getRuntimeFeatureCellValue;
178
+ private _arrayCellHasData;
179
+ /**
180
+ * If the current array formula in the extended area intersects with the existing array formula, a #SPILL! error will be reported. Note that if other array formulas are already #SPILL!, they will not conflict with the current array formula
181
+ * @param formulaUnitId
182
+ * @param formulaSheetId
183
+ * @param formulaRow
184
+ * @param formulaColumn
185
+ * @param r
186
+ * @param c
187
+ * @returns
188
+ */
189
+ private _isInOtherArrayFormulaRange;
178
190
  private _isInArrayFormulaRange;
179
191
  private _checkIfArrayFormulaExceeded;
180
192
  private _isInDirtyRange;