@univerjs/engine-formula 0.13.0-insiders.20251216-1519cb7 → 0.13.0-insiders.20251218-2062647
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.
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/es/facade.js +99 -37
- package/lib/es/index.js +3313 -3090
- package/lib/facade.js +99 -37
- package/lib/index.js +3313 -3090
- package/lib/types/basics/common.d.ts +1 -0
- package/lib/types/commands/mutations/formula.mutation.d.ts +9 -0
- package/lib/types/commands/mutations/set-formula-calculation.mutation.d.ts +10 -1
- package/lib/types/controller/calculate.controller.d.ts +1 -0
- package/lib/types/engine/dependency/dependency-tree.d.ts +4 -0
- package/lib/types/engine/dependency/formula-dependency.d.ts +5 -1
- package/lib/types/facade/f-formula.d.ts +47 -1
- package/lib/types/index.d.ts +6 -2
- package/lib/types/services/active-dirty-manager.service.d.ts +1 -0
- package/lib/types/services/calculate-formula.service.d.ts +3 -1
- package/lib/types/services/formula-common.d.ts +18 -0
- package/lib/types/services/register-other-formula.service.d.ts +40 -0
- package/lib/types/services/super-table.service.d.ts +2 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IMutation } from '@univerjs/core';
|
|
2
|
+
export interface IOtherFormulaMarkDirtyParams {
|
|
3
|
+
[unitId: string]: {
|
|
4
|
+
[sunUnitId: string]: {
|
|
5
|
+
[formulaId: string]: boolean;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export declare const OtherFormulaMarkDirty: IMutation<IOtherFormulaMarkDirtyParams>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IExecutionOptions, IMutation, IUnitRange, Nullable } from '@univerjs/core';
|
|
2
2
|
import { IFormulaExecuteResultMap, IFormulaStringMap, IRuntimeOtherUnitDataType, IRuntimeUnitDataPrimitiveType } from '../../basics/common';
|
|
3
|
-
import { IFormulaDependencyTreeFullJson, IFormulaDependencyTreeJson } from '../../engine/dependency/dependency-tree';
|
|
3
|
+
import { IFormulaDependencyTreeFullJson, IFormulaDependencyTreeJson, IFormulaDependentsAndInRangeResults } from '../../engine/dependency/dependency-tree';
|
|
4
4
|
import { IFormulaDirtyData } from '../../services/current-data.service';
|
|
5
5
|
import { FormulaExecutedStateType, IExecutionInProgressParams } from '../../services/runtime.service';
|
|
6
6
|
export interface ISetFormulaCalculationStartMutation extends IFormulaDirtyData {
|
|
@@ -34,11 +34,18 @@ export interface ISetQueryFormulaDependencyMutation {
|
|
|
34
34
|
export interface ISetQueryFormulaDependencyResultMutation {
|
|
35
35
|
result: IFormulaDependencyTreeJson[];
|
|
36
36
|
}
|
|
37
|
+
export interface ISetQueryFormulaDependencyAllMutation {
|
|
38
|
+
unitRanges: IUnitRange[];
|
|
39
|
+
}
|
|
40
|
+
export interface ISetQueryFormulaDependencyAllResultMutation {
|
|
41
|
+
result: IFormulaDependentsAndInRangeResults;
|
|
42
|
+
}
|
|
37
43
|
/**
|
|
38
44
|
* TODO: @DR-Univer
|
|
39
45
|
* Trigger the calculation of the formula and stop the formula
|
|
40
46
|
*/
|
|
41
47
|
export declare const SetFormulaCalculationStartMutation: IMutation<ISetFormulaCalculationStartMutation>;
|
|
48
|
+
export declare const SetTriggerFormulaCalculationStartMutation: IMutation<ISetFormulaCalculationStartMutation>;
|
|
42
49
|
export declare const SetFormulaStringBatchCalculationMutation: IMutation<ISetFormulaStringBatchCalculationMutation>;
|
|
43
50
|
export declare const SetFormulaStringBatchCalculationResultMutation: IMutation<ISetFormulaStringBatchCalculationResultMutation>;
|
|
44
51
|
export interface ISetFormulaCalculationStopMutation {
|
|
@@ -60,3 +67,5 @@ export declare const SetCellFormulaDependencyCalculationMutation: IMutation<ISet
|
|
|
60
67
|
export declare const SetCellFormulaDependencyCalculationResultMutation: IMutation<ISetCellFormulaDependencyCalculationResultMutation>;
|
|
61
68
|
export declare const SetQueryFormulaDependencyMutation: IMutation<ISetQueryFormulaDependencyMutation>;
|
|
62
69
|
export declare const SetQueryFormulaDependencyResultMutation: IMutation<ISetQueryFormulaDependencyResultMutation>;
|
|
70
|
+
export declare const SetQueryFormulaDependencyAllMutation: IMutation<ISetQueryFormulaDependencyAllMutation>;
|
|
71
|
+
export declare const SetQueryFormulaDependencyAllResultMutation: IMutation<ISetQueryFormulaDependencyAllResultMutation>;
|
|
@@ -10,6 +10,7 @@ export declare class CalculateController extends Disposable {
|
|
|
10
10
|
private _commandExecutedListener;
|
|
11
11
|
private _calculate;
|
|
12
12
|
private _queryFormulaDependencyJson;
|
|
13
|
+
private _queryFormulaDependencyAllJson;
|
|
13
14
|
private _generateAllDependencyTreeJson;
|
|
14
15
|
private _generateCellDependencyTreeJson;
|
|
15
16
|
private _calculateFormulaString;
|
|
@@ -138,6 +138,10 @@ export interface IFormulaDependencyTreeFullJson extends IFormulaDependencyTreeJs
|
|
|
138
138
|
children: IFormulaDependencyTreeJson[];
|
|
139
139
|
parents: IFormulaDependencyTreeJson[];
|
|
140
140
|
}
|
|
141
|
+
export interface IFormulaDependentsAndInRangeResults {
|
|
142
|
+
dependents: IFormulaDependencyTreeJson[];
|
|
143
|
+
inRanges: IFormulaDependencyTreeJson[];
|
|
144
|
+
}
|
|
141
145
|
export declare class FormulaDependencyTreeModel {
|
|
142
146
|
children: Set<FormulaDependencyTreeModel>;
|
|
143
147
|
parents: Set<FormulaDependencyTreeModel>;
|
|
@@ -4,7 +4,7 @@ import { IFeatureCalculationManagerParam, IFeatureCalculationManagerService } fr
|
|
|
4
4
|
import { FunctionNode } from '../ast-node';
|
|
5
5
|
import { BaseAstNode } from '../ast-node/base-ast-node';
|
|
6
6
|
import { IExecuteAstNodeData } from '../utils/ast-node-tool';
|
|
7
|
-
import { IFormulaDependencyTree, IFormulaDependencyTreeFullJson, IFormulaDependencyTreeJson, FormulaDependencyTree, FormulaDependencyTreeModel, FormulaDependencyTreeVirtual } from './dependency-tree';
|
|
7
|
+
import { IFormulaDependencyTree, IFormulaDependencyTreeFullJson, IFormulaDependencyTreeJson, IFormulaDependentsAndInRangeResults, FormulaDependencyTree, FormulaDependencyTreeModel, FormulaDependencyTreeVirtual } from './dependency-tree';
|
|
8
8
|
import { IFormulaCurrentConfigService } from '../../services/current-data.service';
|
|
9
9
|
import { IDependencyManagerService } from '../../services/dependency-manager.service';
|
|
10
10
|
import { IOtherFormulaManagerService } from '../../services/other-formula-manager.service';
|
|
@@ -20,6 +20,7 @@ export interface IFormulaDependencyGenerator {
|
|
|
20
20
|
getCellDependencyJson(unitId: string, sheetId: string, row: number, column: number): Promise<IFormulaDependencyTreeFullJson | undefined>;
|
|
21
21
|
getRangeDependents(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
22
22
|
getInRangeFormulas(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
23
|
+
getRangeDependentsAndInRangeFormulas(unitRanges: IUnitRange[]): Promise<IFormulaDependentsAndInRangeResults>;
|
|
23
24
|
}
|
|
24
25
|
export declare const IFormulaDependencyGenerator: import('@wendellhu/redi').IdentifierDecorator<IFormulaDependencyGenerator>;
|
|
25
26
|
export declare class FormulaDependencyGenerator extends Disposable {
|
|
@@ -129,6 +130,9 @@ export declare class FormulaDependencyGenerator extends Disposable {
|
|
|
129
130
|
getAllDependencyJson(): Promise<IFormulaDependencyTreeJson[]>;
|
|
130
131
|
protected _setRealFormulaString(treeModel: FormulaDependencyTreeModel): void;
|
|
131
132
|
getCellDependencyJson(unitId: string, sheetId: string, row: number, column: number): Promise<IFormulaDependencyTreeFullJson | undefined>;
|
|
133
|
+
protected _getRangeDependents(unitRanges: IUnitRange[]): IFormulaDependencyTreeJson[];
|
|
132
134
|
getRangeDependents(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
135
|
+
protected _getInRangeFormulas(unitRanges: IUnitRange[], treeList: IFormulaDependencyTree[]): IFormulaDependencyTreeJson[];
|
|
133
136
|
getInRangeFormulas(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
137
|
+
getRangeDependentsAndInRangeFormulas(unitRanges: IUnitRange[]): Promise<IFormulaDependentsAndInRangeResults>;
|
|
134
138
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IDisposable, IUnitRange, ICommandService, IConfigService, Injector } from '@univerjs/core';
|
|
2
|
-
import { FormulaExecutedStateType, IExecutionInProgressParams, IExprTreeNode, IFormulaDependencyTreeFullJson, IFormulaDependencyTreeJson, IFormulaExecuteResultMap, IFormulaStringMap, ISequenceNode, ISetFormulaCalculationResultMutation, IDefinedNamesService, IFunctionService, ISuperTableService, LexerTreeBuilder } from '@univerjs/engine-formula';
|
|
2
|
+
import { FormulaExecutedStateType, IExecutionInProgressParams, IExprTreeNode, IFormulaDependencyTreeFullJson, IFormulaDependencyTreeJson, IFormulaDependentsAndInRangeResults, IFormulaExecuteResultMap, IFormulaStringMap, ISequenceNode, ISetFormulaCalculationResultMutation, IDefinedNamesService, IFunctionService, ISuperTableService, LexerTreeBuilder } from '@univerjs/engine-formula';
|
|
3
3
|
import { FBase } from '@univerjs/core/facade';
|
|
4
4
|
/**
|
|
5
5
|
* This interface class provides methods to modify the behavior of the operation formula.
|
|
@@ -515,4 +515,50 @@ export declare class FFormula extends FBase {
|
|
|
515
515
|
* @returns A formula expression tree describing the hierarchical structure of the formula
|
|
516
516
|
*/
|
|
517
517
|
getFormulaExpressTree(formulaString: string, unitId: string): IExprTreeNode | null;
|
|
518
|
+
/**
|
|
519
|
+
* Retrieve **both**:
|
|
520
|
+
* 1) the full dependency trees of all formulas that **depend on** the specified ranges, and
|
|
521
|
+
* 2) the dependency trees of all formulas that **physically reside inside** the specified ranges.
|
|
522
|
+
*
|
|
523
|
+
* This is a convenience API that combines the behaviors of
|
|
524
|
+
* `getRangeDependents` and `getInRangeFormulas` into a single call.
|
|
525
|
+
*
|
|
526
|
+
* Internally, it triggers a local dependency-calculation command once and
|
|
527
|
+
* resolves when both result sets are available, avoiding duplicate
|
|
528
|
+
* calculations and event listeners.
|
|
529
|
+
*
|
|
530
|
+
* @param unitRanges An array of workbook/sheet ranges to query. Each range
|
|
531
|
+
* includes:
|
|
532
|
+
* - `unitId` The workbook ID.
|
|
533
|
+
* - `sheetId` The sheet ID.
|
|
534
|
+
* - `range` The zero-based row/column boundaries.
|
|
535
|
+
*
|
|
536
|
+
* @param {number} [timeout]
|
|
537
|
+
* Optional timeout in milliseconds. If the dependency calculation does
|
|
538
|
+
* not complete within this period, the promise will be rejected.
|
|
539
|
+
*
|
|
540
|
+
* @returns {Promise<IFormulaDependentsAndInRangeResults>}
|
|
541
|
+
* A promise that resolves with an object containing:
|
|
542
|
+
* - `dependents`: Dependency trees of all formulas that depend on the
|
|
543
|
+
* specified ranges (upstream consumers).
|
|
544
|
+
* - `inRanges`: Dependency trees of all formulas whose definitions
|
|
545
|
+
* are located inside the specified ranges.
|
|
546
|
+
*
|
|
547
|
+
* @example
|
|
548
|
+
* ```ts
|
|
549
|
+
* const formulaEngine = univerAPI.getFormula();
|
|
550
|
+
*
|
|
551
|
+
* const result = await formulaEngine.getRangeDependentsAndInRangeFormulas([
|
|
552
|
+
* {
|
|
553
|
+
* unitId: 'workbook1',
|
|
554
|
+
* sheetId: 'sheet1',
|
|
555
|
+
* range: { startRow: 0, endRow: 9, startColumn: 0, endColumn: 1 },
|
|
556
|
+
* },
|
|
557
|
+
* ]);
|
|
558
|
+
*
|
|
559
|
+
* console.log('Dependent formulas:', result.dependents);
|
|
560
|
+
* console.log('Formulas inside range:', result.inRanges);
|
|
561
|
+
* ```
|
|
562
|
+
*/
|
|
563
|
+
getRangeDependentsAndInRangeFormulas(unitRanges: IUnitRange[], timeout?: number): Promise<IFormulaDependentsAndInRangeResults>;
|
|
518
564
|
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -28,12 +28,13 @@ export { isReferenceString } from './basics/regex';
|
|
|
28
28
|
export { convertUnitDataToRuntime } from './basics/runtime';
|
|
29
29
|
export { compareToken, matchToken, OPERATOR_TOKEN_SET, operatorToken, prefixToken, SUFFIX_TOKEN_SET } from './basics/token';
|
|
30
30
|
export { DEFAULT_TOKEN_LAMBDA_FUNCTION_NAME, DEFAULT_TOKEN_LET_FUNCTION_NAME, DEFAULT_TOKEN_TYPE_LAMBDA_PARAMETER, DEFAULT_TOKEN_TYPE_PARAMETER, DEFAULT_TOKEN_TYPE_ROOT } from './basics/token-type';
|
|
31
|
+
export { OtherFormulaMarkDirty } from './commands/mutations/formula.mutation';
|
|
31
32
|
export { RegisterFunctionMutation } from './commands/mutations/register-function.mutation';
|
|
32
33
|
export { type ISetArrayFormulaDataMutationParams, SetArrayFormulaDataMutation } from './commands/mutations/set-array-formula-data.mutation';
|
|
33
34
|
export { type ISetDefinedNameMutationParam, type ISetDefinedNameMutationSearchParam, RemoveDefinedNameMutation, SetDefinedNameMutation } from './commands/mutations/set-defined-name.mutation';
|
|
34
35
|
export { SetDefinedNameMutationFactory } from './commands/mutations/set-defined-name.mutation';
|
|
35
36
|
export { RemoveFeatureCalculationMutation, SetFeatureCalculationMutation } from './commands/mutations/set-feature-calculation.mutation';
|
|
36
|
-
export { type ISetCellFormulaDependencyCalculationResultMutation, type ISetFormulaCalculationNotificationMutation, type ISetFormulaCalculationResultMutation, type ISetFormulaCalculationStartMutation, type ISetFormulaDependencyCalculationMutation, type ISetFormulaDependencyCalculationResultMutation, type ISetFormulaStringBatchCalculationResultMutation, type ISetQueryFormulaDependencyResultMutation, SetCellFormulaDependencyCalculationMutation, SetCellFormulaDependencyCalculationResultMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation, SetFormulaDependencyCalculationMutation, SetFormulaDependencyCalculationResultMutation, SetFormulaStringBatchCalculationMutation, SetFormulaStringBatchCalculationResultMutation, SetQueryFormulaDependencyMutation, SetQueryFormulaDependencyResultMutation, } from './commands/mutations/set-formula-calculation.mutation';
|
|
37
|
+
export { type ISetCellFormulaDependencyCalculationResultMutation, type ISetFormulaCalculationNotificationMutation, type ISetFormulaCalculationResultMutation, type ISetFormulaCalculationStartMutation, type ISetFormulaDependencyCalculationMutation, type ISetFormulaDependencyCalculationResultMutation, type ISetFormulaStringBatchCalculationResultMutation, type ISetQueryFormulaDependencyAllResultMutation, type ISetQueryFormulaDependencyResultMutation, SetCellFormulaDependencyCalculationMutation, SetCellFormulaDependencyCalculationResultMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation, SetFormulaDependencyCalculationMutation, SetFormulaDependencyCalculationResultMutation, SetFormulaStringBatchCalculationMutation, SetFormulaStringBatchCalculationResultMutation, SetQueryFormulaDependencyAllMutation, SetQueryFormulaDependencyAllResultMutation, SetQueryFormulaDependencyMutation, SetQueryFormulaDependencyResultMutation, SetTriggerFormulaCalculationStartMutation, } from './commands/mutations/set-formula-calculation.mutation';
|
|
37
38
|
export { type ISetFormulaDataMutationParams, SetFormulaDataMutation } from './commands/mutations/set-formula-data.mutation';
|
|
38
39
|
export { type ISetImageFormulaDataMutationParams, SetImageFormulaDataMutation } from './commands/mutations/set-image-formula-data.mutation';
|
|
39
40
|
export { type IRemoveOtherFormulaMutationParams, type ISetOtherFormulaMutationParams, RemoveOtherFormulaMutation, SetOtherFormulaMutation } from './commands/mutations/set-other-formula.mutation';
|
|
@@ -56,7 +57,7 @@ export { ReferenceNodeFactory } from './engine/ast-node/reference-node';
|
|
|
56
57
|
export { SuffixNodeFactory } from './engine/ast-node/suffix-node';
|
|
57
58
|
export { UnionNodeFactory } from './engine/ast-node/union-node';
|
|
58
59
|
export { ValueNodeFactory } from './engine/ast-node/value-node';
|
|
59
|
-
export { FormulaDependencyTree, FormulaDependencyTreeModel, type IFormulaDependencyTree, type IFormulaDependencyTreeFullJson, type IFormulaDependencyTreeJson } from './engine/dependency/dependency-tree';
|
|
60
|
+
export { FormulaDependencyTree, FormulaDependencyTreeModel, type IFormulaDependencyTree, type IFormulaDependencyTreeFullJson, type IFormulaDependencyTreeJson, type IFormulaDependentsAndInRangeResults } from './engine/dependency/dependency-tree';
|
|
60
61
|
export { FormulaDependencyTreeType } from './engine/dependency/dependency-tree';
|
|
61
62
|
export { FormulaDependencyTreeVirtual } from './engine/dependency/dependency-tree';
|
|
62
63
|
export { FormulaDependencyGenerator, IFormulaDependencyGenerator } from './engine/dependency/formula-dependency';
|
|
@@ -129,11 +130,14 @@ export { DependencyManagerService } from './services/dependency-manager.service'
|
|
|
129
130
|
export { DependencyManagerBaseService } from './services/dependency-manager.service';
|
|
130
131
|
export { FeatureCalculationManagerService, IFeatureCalculationManagerService } from './services/feature-calculation-manager.service';
|
|
131
132
|
export type { IFeatureCalculationManagerParam } from './services/feature-calculation-manager.service';
|
|
133
|
+
export type { IFormulaInfo, IOtherFormulaResult } from './services/formula-common';
|
|
134
|
+
export { FormulaResultStatus } from './services/formula-common';
|
|
132
135
|
export { FunctionService } from './services/function.service';
|
|
133
136
|
export { IFunctionService } from './services/function.service';
|
|
134
137
|
export { GlobalComputingStatusService } from './services/global-computing-status.service';
|
|
135
138
|
export { HyperlinkEngineFormulaService, IHyperlinkEngineFormulaService } from './services/hyperlink-engine-formula.service';
|
|
136
139
|
export { IOtherFormulaManagerService, OtherFormulaManagerService } from './services/other-formula-manager.service';
|
|
140
|
+
export { OtherFormulaBizType, RegisterOtherFormulaService } from './services/register-other-formula.service';
|
|
137
141
|
export { FormulaExecutedStateType, FormulaExecuteStageType, FormulaRuntimeService, type IAllRuntimeData, type IExecutionInProgressParams, IFormulaRuntimeService } from './services/runtime.service';
|
|
138
142
|
export { ISheetRowFilteredService, SheetRowFilteredService } from './services/sheet-row-filtered.service';
|
|
139
143
|
export { ISuperTableService } from './services/super-table.service';
|
|
@@ -3,6 +3,7 @@ import { IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefined
|
|
|
3
3
|
export interface IDirtyConversionManagerParams {
|
|
4
4
|
commandId: string;
|
|
5
5
|
getDirtyData: (command: ICommandInfo) => {
|
|
6
|
+
forceCalculation?: boolean;
|
|
6
7
|
dirtyRanges?: IUnitRange[];
|
|
7
8
|
dirtyNameMap?: IDirtyUnitSheetNameMap;
|
|
8
9
|
dirtyDefinedNameMap?: IDirtyUnitSheetDefinedNameMap;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IUnitRange, Disposable, IConfigService } from '@univerjs/core';
|
|
2
2
|
import { Observable, Subject } from 'rxjs';
|
|
3
3
|
import { IFeatureDirtyRangeType, IFormulaDatasetConfig, IFormulaExecuteResultMap, IFormulaStringMap, IRuntimeUnitDataType, IUnitRowData } from '../basics/common';
|
|
4
|
-
import { IFormulaDependencyTreeFullJson, IFormulaDependencyTreeJson } from '../engine/dependency/dependency-tree';
|
|
4
|
+
import { IFormulaDependencyTreeFullJson, IFormulaDependencyTreeJson, IFormulaDependentsAndInRangeResults } from '../engine/dependency/dependency-tree';
|
|
5
5
|
import { FunctionVariantType } from '../engine/reference-object/base-reference-object';
|
|
6
6
|
import { IAllRuntimeData, IExecutionInProgressParams, IFormulaRuntimeService } from './runtime.service';
|
|
7
7
|
import { Lexer } from '../engine/analysis/lexer';
|
|
@@ -25,6 +25,7 @@ export interface ICalculateFormulaService {
|
|
|
25
25
|
getCellDependencyJson(unitId: string, sheetId: string, row: number, column: number, rowData?: IUnitRowData): Promise<IFormulaDependencyTreeFullJson | undefined>;
|
|
26
26
|
getRangeDependents(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
27
27
|
getInRangeFormulas(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
28
|
+
getDependentsAndInRangeFormulas(unitRanges: IUnitRange[]): Promise<IFormulaDependentsAndInRangeResults>;
|
|
28
29
|
}
|
|
29
30
|
export declare const ICalculateFormulaService: import('@wendellhu/redi').IdentifierDecorator<ICalculateFormulaService>;
|
|
30
31
|
export declare class CalculateFormulaService extends Disposable implements ICalculateFormulaService {
|
|
@@ -66,4 +67,5 @@ export declare class CalculateFormulaService extends Disposable implements ICalc
|
|
|
66
67
|
getCellDependencyJson(unitId: string, sheetId: string, row: number, column: number): Promise<IFormulaDependencyTreeFullJson | undefined>;
|
|
67
68
|
getRangeDependents(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
68
69
|
getInRangeFormulas(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
70
|
+
getDependentsAndInRangeFormulas(unitRanges: IUnitRange[]): Promise<IFormulaDependentsAndInRangeResults>;
|
|
69
71
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ICellData, IObjectMatrixPrimitiveType, Nullable } from '@univerjs/core';
|
|
2
|
+
export declare enum FormulaResultStatus {
|
|
3
|
+
NOT_REGISTER = 1,
|
|
4
|
+
SUCCESS = 2,
|
|
5
|
+
WAIT = 3,
|
|
6
|
+
ERROR = 4
|
|
7
|
+
}
|
|
8
|
+
export interface IOtherFormulaResult {
|
|
9
|
+
result?: IObjectMatrixPrimitiveType<Nullable<ICellData>[][]>;
|
|
10
|
+
status: FormulaResultStatus;
|
|
11
|
+
formulaId: string;
|
|
12
|
+
callbacks: Set<(value: IObjectMatrixPrimitiveType<Nullable<ICellData>[][]>) => void>;
|
|
13
|
+
extra?: Record<string, any>;
|
|
14
|
+
}
|
|
15
|
+
export interface IFormulaInfo {
|
|
16
|
+
id: string;
|
|
17
|
+
text: string;
|
|
18
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { IRange, Nullable, Disposable, ICommandService, LifecycleService } from '@univerjs/core';
|
|
2
|
+
import { IOtherFormulaResult } from './formula-common';
|
|
3
|
+
import { BehaviorSubject } from 'rxjs';
|
|
4
|
+
import { IActiveDirtyManagerService } from './active-dirty-manager.service';
|
|
5
|
+
export declare enum OtherFormulaBizType {
|
|
6
|
+
DEFAULT = "default",
|
|
7
|
+
DATA_VALIDATION = "dv",
|
|
8
|
+
DATA_VALIDATION_CUSTOM = "dv-custom",
|
|
9
|
+
CONDITIONAL_FORMATTING = "cf",
|
|
10
|
+
DOC = "doc",
|
|
11
|
+
SLIDE = "slide"
|
|
12
|
+
}
|
|
13
|
+
export declare class RegisterOtherFormulaService extends Disposable {
|
|
14
|
+
private readonly _commandService;
|
|
15
|
+
private _activeDirtyManagerService;
|
|
16
|
+
private readonly _lifecycleService;
|
|
17
|
+
private _formulaCacheMap;
|
|
18
|
+
private _formulaChangeWithRange$;
|
|
19
|
+
formulaChangeWithRange$: import('rxjs').Observable<{
|
|
20
|
+
unitId: string;
|
|
21
|
+
subUnitId: string;
|
|
22
|
+
formulaText: string;
|
|
23
|
+
formulaId: string;
|
|
24
|
+
ranges: IRange[];
|
|
25
|
+
}>;
|
|
26
|
+
private _formulaResult$;
|
|
27
|
+
formulaResult$: import('rxjs').Observable<Record<string, Record<string, IOtherFormulaResult[]>>>;
|
|
28
|
+
calculateStarted$: BehaviorSubject<boolean>;
|
|
29
|
+
constructor(_commandService: ICommandService, _activeDirtyManagerService: IActiveDirtyManagerService, _lifecycleService: LifecycleService);
|
|
30
|
+
dispose(): void;
|
|
31
|
+
private _ensureCacheMap;
|
|
32
|
+
private _createFormulaId;
|
|
33
|
+
private _initFormulaRegister;
|
|
34
|
+
private _initFormulaCalculationResultChange;
|
|
35
|
+
registerFormulaWithRange(unitId: string, subUnitId: string, formulaText: string, ranges?: IRange[], extra?: Record<string, any>, bizType?: OtherFormulaBizType, bizId?: string): string;
|
|
36
|
+
deleteFormula(unitId: string, subUnitId: string, formulaIdList: string[]): void;
|
|
37
|
+
getFormulaValue(unitId: string, subUnitId: string, formulaId: string): Promise<Nullable<IOtherFormulaResult>>;
|
|
38
|
+
getFormulaValueSync(unitId: string, subUnitId: string, formulaId: string): Nullable<IOtherFormulaResult>;
|
|
39
|
+
markFormulaDirty(unitId: string, subUnitId: string, formulaId: string): void;
|
|
40
|
+
}
|
|
@@ -13,6 +13,7 @@ export interface ISuperTableService {
|
|
|
13
13
|
remove(unitId: string, tableName: string): void;
|
|
14
14
|
update$: Observable<unknown>;
|
|
15
15
|
getTable(unitId: string, tableName: string): Nullable<ISuperTable>;
|
|
16
|
+
hasTable(unitId: string, tableName: string): boolean;
|
|
16
17
|
}
|
|
17
18
|
export declare class SuperTableService extends Disposable implements ISuperTableService {
|
|
18
19
|
private _tableMap;
|
|
@@ -27,6 +28,7 @@ export declare class SuperTableService extends Disposable implements ISuperTable
|
|
|
27
28
|
registerTable(unitId: string, tableName: string, reference: ISuperTable): void;
|
|
28
29
|
registerTableOptionMap(tableOption: string, tableOptionType: TableOptionType): void;
|
|
29
30
|
getTable(unitId: string, tableName: string): Nullable<ISuperTable>;
|
|
31
|
+
hasTable(unitId: string, tableName: string): boolean;
|
|
30
32
|
private _update;
|
|
31
33
|
}
|
|
32
34
|
export declare const ISuperTableService: import('@wendellhu/redi').IdentifierDecorator<ISuperTableService>;
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(c,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("@univerjs/core/facade"),require("@univerjs/core"),require("@univerjs/engine-formula"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core/facade","@univerjs/core","@univerjs/engine-formula","rxjs"],l):(c=typeof globalThis<"u"?globalThis:c||self,l(c.UniverEngineFormulaFacade={},c.UniverCoreFacade,c.UniverCore,c.UniverEngineFormula,c.rxjs))})(this,(function(c,l,m,n,f){"use strict";var v=Object.getOwnPropertyDescriptor,C=(p,e,i,t)=>{for(var r=t>1?void 0:t?v(e,i):e,o=p.length-1,s;o>=0;o--)(s=p[o])&&(r=s(r)||r);return r},d=(p,e)=>(i,t)=>e(i,t,p);c.FFormula=class extends l.FBase{constructor(e,i,t,r,o,s,a){super(),this._commandService=e,this._injector=i,this._lexerTreeBuilder=t,this._configService=r,this._functionService=o,this._definedNamesService=s,this._superTableService=a,this._initialize()}_initialize(){}get lexerTreeBuilder(){return this._lexerTreeBuilder}moveFormulaRefOffset(e,i,t,r){return this._lexerTreeBuilder.moveFormulaRefOffset(e,i,t,r)}sequenceNodesBuilder(e){return this._lexerTreeBuilder.sequenceNodesBuilder(e)||[]}executeCalculation(){this._commandService.executeCommand(n.SetTriggerFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})}stopCalculation(){this._commandService.executeCommand(n.SetFormulaCalculationStopMutation.id,{})}calculationStart(e){return this._commandService.onCommandExecuted(i=>{if(i.id===n.SetFormulaCalculationStartMutation.id){const t=i.params;e(t.forceCalculation)}})}calculationEnd(e){return this._commandService.onCommandExecuted(i=>{if(i.id!==n.SetFormulaCalculationNotificationMutation.id)return;const t=i.params;t.functionsExecutedState!==void 0&&e(t.functionsExecutedState)})}whenComputingCompleteAsync(e){const i=this._injector.get(n.GlobalComputingStatusService);return i.computingStatus?Promise.resolve(!0):f.firstValueFrom(f.race(i.computingStatus$.pipe(f.filter(t=>t)),f.timer(e!=null?e:3e4).pipe(f.map(()=>!1))))}onCalculationEnd(){return new Promise((e,i)=>{const t=setTimeout(()=>{i(new Error("Calculation end timeout"))},3e4),r=this.calculationEnd(()=>{clearTimeout(t),r.dispose(),e()})})}calculationProcessing(e){return this._commandService.onCommandExecuted(i=>{if(i.id!==n.SetFormulaCalculationNotificationMutation.id)return;const t=i.params;t.stageInfo!==void 0&&e(t.stageInfo)})}setMaxIteration(e){this._configService.setConfig(n.ENGINE_FORMULA_CYCLE_REFERENCE_COUNT,e)}calculationResultApplied(e){return this._commandService.onCommandExecuted(i=>{if(i.id!==n.SetFormulaCalculationResultMutation.id)return;const t=i.params;t!==void 0&&requestIdleCallback(()=>{e(t)})})}onCalculationResultApplied(){return new Promise((e,i)=>{let t=!1,r=!1;const o=setTimeout(()=>{S(),i(new Error("Calculation end timeout"))},3e4),s=setTimeout(()=>{t||(S(),e())},500),a=this.calculationProcessing(()=>{t||(t=!0,clearTimeout(s))}),u=this.calculationResultApplied(()=>{r||(r=!0,S(),e())});function S(){clearTimeout(o),clearTimeout(s),a.dispose(),u.dispose()}})}executeFormulas(e,i=3e4){return new Promise((t,r)=>{const o=this._commandService.onCommandExecuted(a=>{if(a.id!==n.SetFormulaStringBatchCalculationResultMutation.id)return;const u=a.params;clearTimeout(s),o.dispose(),u.result!=null?t(u.result):r(new Error("Formula batch calculation returned no result"))}),s=setTimeout(()=>{o.dispose(),r(new Error("Formula batch calculation timeout"))},i);this._commandService.executeCommand(n.SetFormulaStringBatchCalculationMutation.id,{formulas:e},{onlyLocal:!0})})}getAllDependencyTrees(e=3e4){return new Promise((i,t)=>{const r=this._commandService.onCommandExecuted(s=>{if(s.id!==n.SetFormulaDependencyCalculationResultMutation.id)return;const a=s.params;clearTimeout(o),r.dispose(),a.result!=null?i(a.result):i([])}),o=setTimeout(()=>{r.dispose(),t(new Error("Formula dependency calculation timeout"))},e);this._commandService.executeCommand(n.SetFormulaDependencyCalculationMutation.id,void 0,{onlyLocal:!0})})}getCellDependencyTree(e,i=3e4){return new Promise((t,r)=>{const o=this._commandService.onCommandExecuted(a=>{if(a.id!==n.SetCellFormulaDependencyCalculationResultMutation.id)return;const u=a.params;clearTimeout(s),o.dispose(),t(u.result)}),s=setTimeout(()=>{o.dispose(),r(new Error("Cell dependency calculation timeout"))},i);this._commandService.executeCommand(n.SetCellFormulaDependencyCalculationMutation.id,e,{onlyLocal:!0})})}getRangeDependents(e,i=3e4){return new Promise((t,r)=>{const o=this._commandService.onCommandExecuted(a=>{if(a.id!==n.SetQueryFormulaDependencyResultMutation.id)return;const u=a.params;clearTimeout(s),o.dispose(),u.result!=null?t(u.result):t([])}),s=setTimeout(()=>{o.dispose(),r(new Error("Range dependents calculation timeout"))},i);this._commandService.executeCommand(n.SetQueryFormulaDependencyMutation.id,{unitRanges:e},{onlyLocal:!0})})}getInRangeFormulas(e,i=3e4){return new Promise((t,r)=>{const o=this._commandService.onCommandExecuted(a=>{if(a.id!==n.SetQueryFormulaDependencyResultMutation.id)return;const u=a.params;clearTimeout(s),o.dispose(),u.result!=null?t(u.result):t([])}),s=setTimeout(()=>{o.dispose(),r(new Error("In-range formulas calculation timeout"))},i);this._commandService.executeCommand(n.SetQueryFormulaDependencyMutation.id,{unitRanges:e,isInRange:!0},{onlyLocal:!0})})}setFormulaReturnDependencyTree(e){this._configService.setConfig(n.ENGINE_FORMULA_RETURN_DEPENDENCY_TREE,e)}getFormulaExpressTree(e,i){return this._lexerTreeBuilder.getFormulaExprTree(e,i,this._functionService.hasExecutor.bind(this._functionService),this._definedNamesService.getValueByName.bind(this._definedNamesService),this._superTableService.getTable.bind(this._superTableService))}getRangeDependentsAndInRangeFormulas(e,i=3e4){return new Promise((t,r)=>{const o=this._commandService.onCommandExecuted(a=>{if(a.id!==n.SetQueryFormulaDependencyAllResultMutation.id)return;const u=a.params;clearTimeout(s),o.dispose(),u.result!=null?t(u.result):t({dependents:[],inRanges:[]})}),s=setTimeout(()=>{o.dispose(),r(new Error("Range dependents calculation timeout"))},i);this._commandService.executeCommand(n.SetQueryFormulaDependencyAllMutation.id,{unitRanges:e},{onlyLocal:!0})})}},c.FFormula=C([d(0,m.Inject(m.ICommandService)),d(1,m.Inject(m.Injector)),d(2,m.Inject(n.LexerTreeBuilder)),d(3,m.IConfigService),d(4,n.IFunctionService),d(5,n.IDefinedNamesService),d(6,n.ISuperTableService)],c.FFormula);class h extends l.FUniver{getFormula(){return this._injector.createInstance(c.FFormula)}}l.FUniver.extend(h),Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
|