@univerjs/engine-formula 0.12.4-insiders.20251213-692494c → 0.13.0-insiders.20251215-64041bb
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 +155 -35
- package/lib/es/index.js +2572 -2576
- package/lib/facade.js +155 -35
- package/lib/index.js +2572 -2576
- package/lib/types/basics/common.d.ts +7 -0
- package/lib/types/basics/match-token.d.ts +1 -1
- package/lib/types/controller/config.schema.d.ts +1 -0
- package/lib/types/engine/analysis/lexer-tree-builder.d.ts +2 -1
- package/lib/types/engine/ast-node/reference-node.d.ts +0 -1
- package/lib/types/engine/dependency/formula-dependency.d.ts +3 -2
- package/lib/types/engine/utils/reference.d.ts +9 -0
- package/lib/types/engine/utils/sequence.d.ts +2 -1
- package/lib/types/facade/f-formula.d.ts +118 -2
- package/lib/types/index.d.ts +3 -3
- package/lib/types/services/calculate-formula.service.d.ts +1 -0
- package/lib/types/services/current-data.service.d.ts +1 -0
- package/lib/types/services/defined-names.service.d.ts +1 -0
- package/lib/types/services/runtime.service.d.ts +7 -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 +4 -4
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ICellData, IColumnData, IObjectArrayPrimitiveType, IObjectMatrixPrimitiveType, IRange, IRowData, IUnitRange, Nullable, ObjectMatrix, Styles } from '@univerjs/core';
|
|
2
|
+
import { sequenceNodeType } from '../engine/utils/sequence';
|
|
2
3
|
import { IImageFormulaInfo } from '../engine/value-object/primitive-object';
|
|
3
4
|
export declare const ERROR_VALUE_OBJECT_CLASS_TYPE = "errorValueObject";
|
|
4
5
|
export declare const ASYNC_OBJECT_CLASS_TYPE = "asyncObject";
|
|
@@ -206,9 +207,15 @@ export interface IFormulaDatasetConfig {
|
|
|
206
207
|
unitStylesData?: IUnitStylesData;
|
|
207
208
|
unitSheetNameMap?: IUnitSheetNameMap;
|
|
208
209
|
maxIteration?: number;
|
|
210
|
+
isCalculateTreeModel?: boolean;
|
|
209
211
|
rowData?: IUnitRowData;
|
|
210
212
|
}
|
|
211
213
|
export declare enum ConcatenateType {
|
|
212
214
|
FRONT = 0,
|
|
213
215
|
BACK = 1
|
|
214
216
|
}
|
|
217
|
+
export interface IExprTreeNode {
|
|
218
|
+
value: string;
|
|
219
|
+
children: IExprTreeNode[];
|
|
220
|
+
type?: sequenceNodeType;
|
|
221
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { compareToken, matchToken, operatorToken, prefixToken, suffixToken } from './token';
|
|
2
|
-
export declare const FORMULA_LEXER_TOKENS: (operatorToken | suffixToken | compareToken |
|
|
2
|
+
export declare const FORMULA_LEXER_TOKENS: (operatorToken | suffixToken | compareToken | prefixToken | matchToken)[];
|
|
3
3
|
export declare function isFormulaLexerToken(str: string): boolean;
|
|
4
4
|
export declare function includeFormulaLexerToken(str: string): boolean;
|
|
5
5
|
export declare function normalizeSheetName(sheetName: string): string;
|
|
@@ -4,6 +4,7 @@ import { BaseFunction } from '../functions/base-function';
|
|
|
4
4
|
export declare const ENGINE_FORMULA_PLUGIN_CONFIG_KEY = "engine-formula.config";
|
|
5
5
|
export declare const DEFAULT_CYCLE_REFERENCE_COUNT = 1;
|
|
6
6
|
export declare const ENGINE_FORMULA_CYCLE_REFERENCE_COUNT = "CYCLE_REFERENCE_COUNT";
|
|
7
|
+
export declare const ENGINE_FORMULA_RETURN_DEPENDENCY_TREE = "RETURN_DEPENDENCY_TREE";
|
|
7
8
|
export declare const configSymbol: unique symbol;
|
|
8
9
|
export interface IUniverEngineFormulaConfig {
|
|
9
10
|
notExecuteFormula?: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Nullable, AbsoluteRefType, Disposable } from '@univerjs/core';
|
|
2
|
-
import { IDirtyUnitSheetDefinedNameMap } from '../../basics/common';
|
|
2
|
+
import { IDirtyUnitSheetDefinedNameMap, IExprTreeNode, ISuperTable } from '../../basics/common';
|
|
3
3
|
import { IFunctionNames } from '../../basics/function';
|
|
4
4
|
import { IDefinedNamesServiceParam } from '../../services/defined-names.service';
|
|
5
5
|
import { ISequenceArray, ISequenceNode } from '../utils/sequence';
|
|
@@ -145,5 +145,6 @@ export declare class LexerTreeBuilder extends Disposable {
|
|
|
145
145
|
private _isScientificNotation;
|
|
146
146
|
private _addSequenceArray;
|
|
147
147
|
getNewFormulaWithPrefix(formulaString: string, hasFunction: (functionToken: IFunctionNames) => boolean): string | null;
|
|
148
|
+
getFormulaExprTree(formulaString: string, unitId: string, hasFunction: (functionToken: IFunctionNames) => boolean, getDefinedNameName: (unitId: string, name: string) => Nullable<IDefinedNamesServiceParam>, getTable: (unitId: string, tableName: string) => Nullable<ISuperTable>): IExprTreeNode | null;
|
|
148
149
|
}
|
|
149
150
|
export {};
|
|
@@ -36,7 +36,6 @@ export declare class ReferenceNodeFactory extends BaseAstNodeFactory {
|
|
|
36
36
|
private _getTableMap;
|
|
37
37
|
private _getNode;
|
|
38
38
|
private _getTableReferenceNode;
|
|
39
|
-
private _splitTableStructuredRef;
|
|
40
39
|
private _checkTokenIsTableReference;
|
|
41
40
|
private _checkParentIsUnionOperator;
|
|
42
41
|
}
|
|
@@ -15,7 +15,7 @@ import { AstTreeBuilder } from '../analysis/parser';
|
|
|
15
15
|
import { Interpreter } from '../interpreter/interpreter';
|
|
16
16
|
export declare function generateRandomDependencyTreeId(dependencyManagerService: IDependencyManagerService): number;
|
|
17
17
|
export interface IFormulaDependencyGenerator {
|
|
18
|
-
generate(): Promise<IFormulaDependencyTree[]>;
|
|
18
|
+
generate(isCalculateTreeModel?: boolean): Promise<IFormulaDependencyTree[]>;
|
|
19
19
|
getAllDependencyJson(): Promise<IFormulaDependencyTreeJson[]>;
|
|
20
20
|
getCellDependencyJson(unitId: string, sheetId: string, row: number, column: number): Promise<IFormulaDependencyTreeFullJson | undefined>;
|
|
21
21
|
getRangeDependents(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
@@ -36,7 +36,7 @@ export declare class FormulaDependencyGenerator extends Disposable {
|
|
|
36
36
|
protected _dependencyRTreeCacheForAddressFunction: RTree;
|
|
37
37
|
constructor(_currentConfigService: IFormulaCurrentConfigService, _runtimeService: IFormulaRuntimeService, _otherFormulaManagerService: IOtherFormulaManagerService, _featureCalculationManagerService: IFeatureCalculationManagerService, _interpreter: Interpreter, _astTreeBuilder: AstTreeBuilder, _lexer: Lexer, _dependencyManagerService: IDependencyManagerService, _lexerTreeBuilder: LexerTreeBuilder);
|
|
38
38
|
dispose(): void;
|
|
39
|
-
generate(): Promise<(FormulaDependencyTree | FormulaDependencyTreeVirtual)[]>;
|
|
39
|
+
generate(isCalculateTreeModel?: boolean): Promise<(FormulaDependencyTree | FormulaDependencyTreeVirtual)[]>;
|
|
40
40
|
private _dependencyFeatureCalculation;
|
|
41
41
|
private _clearFeatureCalculationNode;
|
|
42
42
|
/**
|
|
@@ -125,6 +125,7 @@ export declare class FormulaDependencyGenerator extends Disposable {
|
|
|
125
125
|
protected _getFormulaDependencyTreeModel(tree: IFormulaDependencyTree): FormulaDependencyTreeModel;
|
|
126
126
|
protected _endFormulaDependencyTreeModel(): void;
|
|
127
127
|
protected _startFormulaDependencyTreeModel(): void;
|
|
128
|
+
protected _getAllDependencyJson(treeList: IFormulaDependencyTree[]): IFormulaDependencyTreeJson[];
|
|
128
129
|
getAllDependencyJson(): Promise<IFormulaDependencyTreeJson[]>;
|
|
129
130
|
protected _setRealFormulaString(treeModel: FormulaDependencyTreeModel): void;
|
|
130
131
|
getCellDependencyJson(unitId: string, sheetId: string, row: number, column: number): Promise<IFormulaDependencyTreeFullJson | undefined>;
|
|
@@ -85,3 +85,12 @@ export declare function quoteSheetName(name: string): string;
|
|
|
85
85
|
* @returns Unquoted name
|
|
86
86
|
*/
|
|
87
87
|
export declare function unquoteSheetName(name: string): string;
|
|
88
|
+
export declare function splitTableStructuredRef(ref: string): {
|
|
89
|
+
tableName: string;
|
|
90
|
+
struct: string;
|
|
91
|
+
columnStruct?: undefined;
|
|
92
|
+
} | {
|
|
93
|
+
tableName: string;
|
|
94
|
+
columnStruct: string;
|
|
95
|
+
struct?: undefined;
|
|
96
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IDisposable, IUnitRange, ICommandService, IConfigService, Injector } from '@univerjs/core';
|
|
2
|
-
import { FormulaExecutedStateType, IExecutionInProgressParams, IFormulaDependencyTreeFullJson, IFormulaDependencyTreeJson, IFormulaExecuteResultMap, IFormulaStringMap, ISequenceNode, ISetFormulaCalculationResultMutation, LexerTreeBuilder } from '@univerjs/engine-formula';
|
|
2
|
+
import { FormulaExecutedStateType, IExecutionInProgressParams, IExprTreeNode, IFormulaDependencyTreeFullJson, IFormulaDependencyTreeJson, 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.
|
|
@@ -10,7 +10,10 @@ export declare class FFormula extends FBase {
|
|
|
10
10
|
protected readonly _injector: Injector;
|
|
11
11
|
private _lexerTreeBuilder;
|
|
12
12
|
protected readonly _configService: IConfigService;
|
|
13
|
-
|
|
13
|
+
private readonly _functionService;
|
|
14
|
+
private readonly _definedNamesService;
|
|
15
|
+
private readonly _superTableService;
|
|
16
|
+
constructor(_commandService: ICommandService, _injector: Injector, _lexerTreeBuilder: LexerTreeBuilder, _configService: IConfigService, _functionService: IFunctionService, _definedNamesService: IDefinedNamesService, _superTableService: ISuperTableService);
|
|
14
17
|
/**
|
|
15
18
|
* @ignore
|
|
16
19
|
*/
|
|
@@ -399,4 +402,117 @@ export declare class FFormula extends FBase {
|
|
|
399
402
|
* ```
|
|
400
403
|
*/
|
|
401
404
|
getInRangeFormulas(unitRanges: IUnitRange[], timeout?: number): Promise<IFormulaDependencyTreeJson[]>;
|
|
405
|
+
/**
|
|
406
|
+
* Enable or disable emitting formula dependency trees after each formula calculation.
|
|
407
|
+
*
|
|
408
|
+
* When enabled, the formula engine will emit the dependency trees produced by
|
|
409
|
+
* each completed formula calculation through the internal command system.
|
|
410
|
+
* Consumers can obtain the result by listening for the corresponding
|
|
411
|
+
* calculation-result command.
|
|
412
|
+
*
|
|
413
|
+
* When disabled, dependency trees will not be emitted.
|
|
414
|
+
*
|
|
415
|
+
* This option only controls whether dependency trees are exposed.
|
|
416
|
+
* It does not affect formula calculation behavior.
|
|
417
|
+
*
|
|
418
|
+
* @param {boolean} value
|
|
419
|
+
* Whether to emit formula dependency trees after calculation.
|
|
420
|
+
* - `true`: Emit dependency trees after each calculation.
|
|
421
|
+
* - `false`: Do not emit dependency trees (default behavior).
|
|
422
|
+
*
|
|
423
|
+
* @example
|
|
424
|
+
* ```ts
|
|
425
|
+
* const formulaEngine = univerAPI.getFormula();
|
|
426
|
+
*
|
|
427
|
+
* // Enable dependency tree emission
|
|
428
|
+
* formulaEngine.setFormulaReturnDependencyTree(true);
|
|
429
|
+
*
|
|
430
|
+
* // Listen for dependency trees produced by formula calculation
|
|
431
|
+
* const trees = await new Promise<IFormulaDependencyTreeJson[]>((resolve, reject) => {
|
|
432
|
+
* const timer = setTimeout(() => {
|
|
433
|
+
* disposable.dispose();
|
|
434
|
+
* reject(new Error('Timeout waiting for formula dependency trees'));
|
|
435
|
+
* }, 30_000);
|
|
436
|
+
*
|
|
437
|
+
* const disposable = commandService.onCommandExecuted((command) => {
|
|
438
|
+
* if (command.id !== SetFormulaDependencyCalculationResultMutation.id) {
|
|
439
|
+
* return;
|
|
440
|
+
* }
|
|
441
|
+
*
|
|
442
|
+
* clearTimeout(timer);
|
|
443
|
+
* disposable.dispose();
|
|
444
|
+
*
|
|
445
|
+
* const params = command.params as ISetFormulaDependencyCalculationResultMutation;
|
|
446
|
+
* resolve(params.result ?? []);
|
|
447
|
+
* });
|
|
448
|
+
* });
|
|
449
|
+
*
|
|
450
|
+
* console.log('Dependency trees:', trees);
|
|
451
|
+
* ```
|
|
452
|
+
*/
|
|
453
|
+
setFormulaReturnDependencyTree(value: boolean): void;
|
|
454
|
+
/**
|
|
455
|
+
* Parse a formula string and return its **formula expression tree**.
|
|
456
|
+
*
|
|
457
|
+
* This API analyzes the syntactic structure of a formula and builds an
|
|
458
|
+
* expression tree that reflects how the formula is composed (functions,
|
|
459
|
+
* operators, ranges, and nested expressions), without performing calculation
|
|
460
|
+
* or dependency evaluation.
|
|
461
|
+
*
|
|
462
|
+
* The returned tree is suitable for:
|
|
463
|
+
* - Formula structure visualization
|
|
464
|
+
* - Explaining complex formulas (e.g. LET / LAMBDA)
|
|
465
|
+
* - Debugging or inspecting formula composition
|
|
466
|
+
* - Building advanced formula tooling
|
|
467
|
+
*
|
|
468
|
+
* ---
|
|
469
|
+
*
|
|
470
|
+
* @example
|
|
471
|
+
* ```ts
|
|
472
|
+
* const formulaEngine = univerAPI.getFormula();
|
|
473
|
+
*
|
|
474
|
+
* const formula = '=LET(x,SUM(A1,B1,A1:B10),y,OFFSET(A1:B10,0,1),SUM(x,y)+x)+1';
|
|
475
|
+
*
|
|
476
|
+
* const exprTree = formulaEngine.getFormulaExpressTree(formula);
|
|
477
|
+
*
|
|
478
|
+
* console.log(exprTree);
|
|
479
|
+
* ```
|
|
480
|
+
*
|
|
481
|
+
* Example output (simplified):
|
|
482
|
+
*
|
|
483
|
+
* ```json
|
|
484
|
+
* {
|
|
485
|
+
* "value": "let(x,sum(A1,B1,A1:B10),y,offset(A1:B10,0,1),sum(x,y)+x)+1",
|
|
486
|
+
* "children": [
|
|
487
|
+
* {
|
|
488
|
+
* "value": "let(x,sum(A1,B1,A1:B10),y,offset(A1:B10,0,1),sum(x,y)+x)",
|
|
489
|
+
* "children": [
|
|
490
|
+
* {
|
|
491
|
+
* "value": "sum(A1,B1,A1:B10)",
|
|
492
|
+
* "children": [
|
|
493
|
+
* {
|
|
494
|
+
* "value": "A1:B10",
|
|
495
|
+
* "children": []
|
|
496
|
+
* }
|
|
497
|
+
* ]
|
|
498
|
+
* },
|
|
499
|
+
* {
|
|
500
|
+
* "value": "offset(A1:B10,0,1)",
|
|
501
|
+
* "children": [
|
|
502
|
+
* {
|
|
503
|
+
* "value": "A1:B10",
|
|
504
|
+
* "children": []
|
|
505
|
+
* }
|
|
506
|
+
* ]
|
|
507
|
+
* }
|
|
508
|
+
* ]
|
|
509
|
+
* }
|
|
510
|
+
* ]
|
|
511
|
+
* }
|
|
512
|
+
* ```
|
|
513
|
+
*
|
|
514
|
+
* @param formulaString The formula string to parse (with or without leading `=`)
|
|
515
|
+
* @returns A formula expression tree describing the hierarchical structure of the formula
|
|
516
|
+
*/
|
|
517
|
+
getFormulaExpressTree(formulaString: string, unitId: string): IExprTreeNode | null;
|
|
402
518
|
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
export type { IArrayFormulaEmbeddedMap, IArrayFormulaRangeType, IArrayFormulaUnitCellType, IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefinedNameMap, IDirtyUnitSheetNameMap, IFeatureDirtyRangeType, IFormulaData, IFormulaDataItem, IFormulaDatasetConfig, IFormulaExecuteResultMap, IFormulaStringMap, IRuntimeImageFormulaDataType, IRuntimeUnitDataType, ISheetData, IUnitData, IUnitImageFormulaDataType, IUnitSheetNameMap, } from './basics/common';
|
|
17
17
|
export { BooleanValue } from './basics/common';
|
|
18
18
|
export { type IOtherFormulaData } from './basics/common';
|
|
19
|
-
export {
|
|
19
|
+
export type { IExprTreeNode, ISuperTable, IUnitRowData } from './basics/common';
|
|
20
20
|
export { isInDirtyRange } from './basics/dirty';
|
|
21
21
|
export { ERROR_TYPE_SET, ErrorType } from './basics/error-type';
|
|
22
22
|
export { type ISheetFormulaError } from './basics/error-type';
|
|
@@ -40,7 +40,7 @@ export { type IRemoveOtherFormulaMutationParams, type ISetOtherFormulaMutationPa
|
|
|
40
40
|
export { RemoveSuperTableMutation, SetSuperTableMutation, SetSuperTableOptionMutation } from './commands/mutations/set-super-table.mutation';
|
|
41
41
|
export type { ISetSuperTableMutationParam, ISetSuperTableMutationSearchParam } from './commands/mutations/set-super-table.mutation';
|
|
42
42
|
export { CalculateController } from './controller/calculate.controller';
|
|
43
|
-
export { ENGINE_FORMULA_CYCLE_REFERENCE_COUNT, ENGINE_FORMULA_PLUGIN_CONFIG_KEY, type IUniverEngineFormulaConfig } from './controller/config.schema';
|
|
43
|
+
export { ENGINE_FORMULA_CYCLE_REFERENCE_COUNT, ENGINE_FORMULA_PLUGIN_CONFIG_KEY, ENGINE_FORMULA_RETURN_DEPENDENCY_TREE, type IUniverEngineFormulaConfig } from './controller/config.schema';
|
|
44
44
|
export { Lexer } from './engine/analysis/lexer';
|
|
45
45
|
export { LexerNode } from './engine/analysis/lexer-node';
|
|
46
46
|
export { LexerTreeBuilder } from './engine/analysis/lexer-tree-builder';
|
|
@@ -71,7 +71,7 @@ export { generateAstNode } from './engine/utils/generate-ast-node';
|
|
|
71
71
|
export { strip, stripErrorMargin } from './engine/utils/math-kit';
|
|
72
72
|
export { handleNumfmtInCell } from './engine/utils/numfmt-kit';
|
|
73
73
|
export { deserializeRangeForR1C1 } from './engine/utils/r1c1-reference';
|
|
74
|
-
export { deserializeRangeWithSheet, getAbsoluteRefTypeWithSingleString, getAbsoluteRefTypeWitString, getRangeWithRefsString, type IAbsoluteRefTypeForRange, isReferenceStrings, isReferenceStringWithEffectiveColumn, needsQuoting, quoteSheetName, serializeRange, serializeRangeToRefString, serializeRangeWithSheet, serializeRangeWithSpreadsheet, singleReferenceToGrid, unquoteSheetName, } from './engine/utils/reference';
|
|
74
|
+
export { deserializeRangeWithSheet, getAbsoluteRefTypeWithSingleString, getAbsoluteRefTypeWitString, getRangeWithRefsString, type IAbsoluteRefTypeForRange, isReferenceStrings, isReferenceStringWithEffectiveColumn, needsQuoting, quoteSheetName, serializeRange, serializeRangeToRefString, serializeRangeWithSheet, serializeRangeWithSpreadsheet, singleReferenceToGrid, splitTableStructuredRef, unquoteSheetName, } from './engine/utils/reference';
|
|
75
75
|
export { handleRefStringInfo } from './engine/utils/reference';
|
|
76
76
|
export { deserializeRangeWithSheetWithCache } from './engine/utils/reference-cache';
|
|
77
77
|
export { generateStringWithSequence, type ISequenceNode, sequenceNodeType } from './engine/utils/sequence';
|
|
@@ -40,6 +40,7 @@ export declare class CalculateFormulaService extends Disposable implements ICalc
|
|
|
40
40
|
protected readonly _executionCompleteListener$: Subject<IAllRuntimeData>;
|
|
41
41
|
readonly executionCompleteListener$: Observable<IAllRuntimeData>;
|
|
42
42
|
private _executeLock;
|
|
43
|
+
protected _isCalculateTreeModel: boolean;
|
|
43
44
|
constructor(_configService: IConfigService, _lexer: Lexer, _currentConfigService: IFormulaCurrentConfigService, _runtimeService: IFormulaRuntimeService, _formulaDependencyGenerator: IFormulaDependencyGenerator, _interpreter: Interpreter, _astTreeBuilder: AstTreeBuilder);
|
|
44
45
|
dispose(): void;
|
|
45
46
|
/**
|
|
@@ -11,6 +11,7 @@ export interface IFormulaDirtyData {
|
|
|
11
11
|
dirtyUnitOtherFormulaMap: IDirtyUnitOtherFormulaMap;
|
|
12
12
|
clearDependencyTreeCache: IDirtyUnitSheetNameMap;
|
|
13
13
|
maxIteration?: number;
|
|
14
|
+
isCalculateTreeModel?: boolean;
|
|
14
15
|
rowData?: IUnitRowData;
|
|
15
16
|
}
|
|
16
17
|
export interface IFormulaCurrentConfigService {
|
|
@@ -64,6 +64,7 @@ export declare class DefinedNamesService extends Disposable implements IDefinedN
|
|
|
64
64
|
getValueById(unitId: string, id: string): IDefinedNamesServiceParam;
|
|
65
65
|
hasDefinedName(unitId: string): boolean;
|
|
66
66
|
getAllDefinedNames(): IDefinedNameMap;
|
|
67
|
+
getDefinedNameByRefString(unitId: string, formulaOrRefString: string): IDefinedNamesServiceParam | undefined;
|
|
67
68
|
private _update;
|
|
68
69
|
private _updateCache;
|
|
69
70
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Nullable, Disposable } from '@univerjs/core';
|
|
2
2
|
import { IArrayFormulaEmbeddedMap, IArrayFormulaRangeType, IFeatureDirtyRangeType, IRuntimeImageFormulaDataType, IRuntimeOtherUnitDataType, IRuntimeUnitDataType } from '../basics/common';
|
|
3
3
|
import { BaseAstNode } from '../engine/ast-node/base-ast-node';
|
|
4
|
+
import { IFormulaDependencyTreeJson } from '../engine/dependency/dependency-tree';
|
|
4
5
|
import { FunctionVariantType } from '../engine/reference-object/base-reference-object';
|
|
5
6
|
import { IFormulaCurrentConfigService } from './current-data.service';
|
|
6
7
|
import { IHyperlinkEngineFormulaService } from './hyperlink-engine-formula.service';
|
|
@@ -40,6 +41,7 @@ export interface IAllRuntimeData {
|
|
|
40
41
|
runtimeFeatureCellData: {
|
|
41
42
|
[featureId: string]: IRuntimeUnitDataType;
|
|
42
43
|
};
|
|
44
|
+
dependencyTreeModelData: IFormulaDependencyTreeJson[];
|
|
43
45
|
}
|
|
44
46
|
export interface IExecutionInProgressParams {
|
|
45
47
|
totalFormulasToCalculate: number;
|
|
@@ -100,6 +102,8 @@ export interface IFormulaRuntimeService {
|
|
|
100
102
|
setUnitArrayFormulaEmbeddedMap(): void;
|
|
101
103
|
clearArrayObjectCache(): void;
|
|
102
104
|
getRuntimeImageFormulaData(): IRuntimeImageFormulaDataType[];
|
|
105
|
+
setDependencyTreeModelData(data: IFormulaDependencyTreeJson[]): void;
|
|
106
|
+
getDependencyTreeModelData(): IFormulaDependencyTreeJson[];
|
|
103
107
|
}
|
|
104
108
|
export declare class FormulaRuntimeService extends Disposable implements IFormulaRuntimeService {
|
|
105
109
|
private readonly _currentConfigService;
|
|
@@ -129,6 +133,7 @@ export declare class FormulaRuntimeService extends Disposable implements IFormul
|
|
|
129
133
|
private _completedArrayFormulasCount;
|
|
130
134
|
private _formulaCycleIndex;
|
|
131
135
|
private _isCycleDependency;
|
|
136
|
+
private _dependencyTreeModelData;
|
|
132
137
|
constructor(_currentConfigService: IFormulaCurrentConfigService, _hyperlinkEngineFormulaService: IHyperlinkEngineFormulaService);
|
|
133
138
|
get currentRow(): number;
|
|
134
139
|
get currentColumn(): number;
|
|
@@ -182,6 +187,8 @@ export declare class FormulaRuntimeService extends Disposable implements IFormul
|
|
|
182
187
|
[featureId: string]: IRuntimeUnitDataType;
|
|
183
188
|
};
|
|
184
189
|
setRuntimeFeatureCellData(featureId: string, featureData: IRuntimeUnitDataType): void;
|
|
190
|
+
setDependencyTreeModelData(data: IFormulaDependencyTreeJson[]): void;
|
|
191
|
+
getDependencyTreeModelData(): IFormulaDependencyTreeJson[];
|
|
185
192
|
getRuntimeImageFormulaData(): IRuntimeImageFormulaDataType[];
|
|
186
193
|
getAllRuntimeData(): IAllRuntimeData;
|
|
187
194
|
getRuntimeState(): IExecutionInProgressParams;
|
|
@@ -12,6 +12,7 @@ export interface ISuperTableService {
|
|
|
12
12
|
registerTableOptionMap(tableOption: string, tableOptionType: TableOptionType): void;
|
|
13
13
|
remove(unitId: string, tableName: string): void;
|
|
14
14
|
update$: Observable<unknown>;
|
|
15
|
+
getTable(unitId: string, tableName: string): Nullable<ISuperTable>;
|
|
15
16
|
}
|
|
16
17
|
export declare class SuperTableService extends Disposable implements ISuperTableService {
|
|
17
18
|
private _tableMap;
|
|
@@ -25,6 +26,7 @@ export declare class SuperTableService extends Disposable implements ISuperTable
|
|
|
25
26
|
getTableOptionMap(): Map<string, TableOptionType>;
|
|
26
27
|
registerTable(unitId: string, tableName: string, reference: ISuperTable): void;
|
|
27
28
|
registerTableOptionMap(tableOption: string, tableOptionType: TableOptionType): void;
|
|
29
|
+
getTable(unitId: string, tableName: string): Nullable<ISuperTable>;
|
|
28
30
|
private _update;
|
|
29
31
|
}
|
|
30
32
|
export declare const ISuperTableService: import('@wendellhu/redi').IdentifierDecorator<ISuperTableService>;
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(u,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):(u=typeof globalThis<"u"?globalThis:u||self,l(u.UniverEngineFormulaFacade={},u.UniverCoreFacade,u.UniverCore,u.UniverEngineFormula,u.rxjs))})(this,(function(u,l,m,n,f){"use strict";var v=Object.getOwnPropertyDescriptor,C=(p,e,t,i)=>{for(var r=i>1?void 0:i?v(e,t):e,o=p.length-1,a;o>=0;o--)(a=p[o])&&(r=a(r)||r);return r},d=(p,e)=>(t,i)=>e(t,i,p);u.FFormula=class extends l.FBase{constructor(e,t,i,r,o,a,s){super(),this._commandService=e,this._injector=t,this._lexerTreeBuilder=i,this._configService=r,this._functionService=o,this._definedNamesService=a,this._superTableService=s,this._initialize()}_initialize(){}get lexerTreeBuilder(){return this._lexerTreeBuilder}moveFormulaRefOffset(e,t,i,r){return this._lexerTreeBuilder.moveFormulaRefOffset(e,t,i,r)}sequenceNodesBuilder(e){return this._lexerTreeBuilder.sequenceNodesBuilder(e)||[]}executeCalculation(){this._commandService.executeCommand(n.SetFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})}stopCalculation(){this._commandService.executeCommand(n.SetFormulaCalculationStopMutation.id,{})}calculationStart(e){return this._commandService.onCommandExecuted(t=>{if(t.id===n.SetFormulaCalculationStartMutation.id){const i=t.params;e(i.forceCalculation)}})}calculationEnd(e){return this._commandService.onCommandExecuted(t=>{if(t.id!==n.SetFormulaCalculationNotificationMutation.id)return;const i=t.params;i.functionsExecutedState!==void 0&&e(i.functionsExecutedState)})}whenComputingCompleteAsync(e){const t=this._injector.get(n.GlobalComputingStatusService);return t.computingStatus?Promise.resolve(!0):f.firstValueFrom(f.race(t.computingStatus$.pipe(f.filter(i=>i)),f.timer(e!=null?e:3e4).pipe(f.map(()=>!1))))}onCalculationEnd(){return new Promise((e,t)=>{const i=setTimeout(()=>{t(new Error("Calculation end timeout"))},3e4),r=this.calculationEnd(()=>{clearTimeout(i),r.dispose(),e()})})}calculationProcessing(e){return this._commandService.onCommandExecuted(t=>{if(t.id!==n.SetFormulaCalculationNotificationMutation.id)return;const i=t.params;i.stageInfo!==void 0&&e(i.stageInfo)})}setMaxIteration(e){this._configService.setConfig(n.ENGINE_FORMULA_CYCLE_REFERENCE_COUNT,e)}calculationResultApplied(e){return this._commandService.onCommandExecuted(t=>{if(t.id!==n.SetFormulaCalculationResultMutation.id)return;const i=t.params;i!==void 0&&requestIdleCallback(()=>{e(i)})})}onCalculationResultApplied(){return new Promise((e,t)=>{let i=!1,r=!1;const o=setTimeout(()=>{S(),t(new Error("Calculation end timeout"))},3e4),a=setTimeout(()=>{i||(S(),e())},500),s=this.calculationProcessing(()=>{i||(i=!0,clearTimeout(a))}),c=this.calculationResultApplied(()=>{r||(r=!0,S(),e())});function S(){clearTimeout(o),clearTimeout(a),s.dispose(),c.dispose()}})}executeFormulas(e,t=3e4){return new Promise((i,r)=>{const o=this._commandService.onCommandExecuted(s=>{if(s.id!==n.SetFormulaStringBatchCalculationResultMutation.id)return;const c=s.params;clearTimeout(a),o.dispose(),c.result!=null?i(c.result):r(new Error("Formula batch calculation returned no result"))}),a=setTimeout(()=>{o.dispose(),r(new Error("Formula batch calculation timeout"))},t);this._commandService.executeCommand(n.SetFormulaStringBatchCalculationMutation.id,{formulas:e},{onlyLocal:!0})})}getAllDependencyTrees(e=3e4){return new Promise((t,i)=>{const r=this._commandService.onCommandExecuted(a=>{if(a.id!==n.SetFormulaDependencyCalculationResultMutation.id)return;const s=a.params;clearTimeout(o),r.dispose(),s.result!=null?t(s.result):t([])}),o=setTimeout(()=>{r.dispose(),i(new Error("Formula dependency calculation timeout"))},e);this._commandService.executeCommand(n.SetFormulaDependencyCalculationMutation.id,void 0,{onlyLocal:!0})})}getCellDependencyTree(e,t=3e4){return new Promise((i,r)=>{const o=this._commandService.onCommandExecuted(s=>{if(s.id!==n.SetCellFormulaDependencyCalculationResultMutation.id)return;const c=s.params;clearTimeout(a),o.dispose(),i(c.result)}),a=setTimeout(()=>{o.dispose(),r(new Error("Cell dependency calculation timeout"))},t);this._commandService.executeCommand(n.SetCellFormulaDependencyCalculationMutation.id,e,{onlyLocal:!0})})}getRangeDependents(e,t=3e4){return new Promise((i,r)=>{const o=this._commandService.onCommandExecuted(s=>{if(s.id!==n.SetQueryFormulaDependencyResultMutation.id)return;const c=s.params;clearTimeout(a),o.dispose(),c.result!=null?i(c.result):i([])}),a=setTimeout(()=>{o.dispose(),r(new Error("Range dependents calculation timeout"))},t);this._commandService.executeCommand(n.SetQueryFormulaDependencyMutation.id,{unitRanges:e},{onlyLocal:!0})})}getInRangeFormulas(e,t=3e4){return new Promise((i,r)=>{const o=this._commandService.onCommandExecuted(s=>{if(s.id!==n.SetQueryFormulaDependencyResultMutation.id)return;const c=s.params;clearTimeout(a),o.dispose(),c.result!=null?i(c.result):i([])}),a=setTimeout(()=>{o.dispose(),r(new Error("In-range formulas calculation timeout"))},t);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,t){return this._lexerTreeBuilder.getFormulaExprTree(e,t,this._functionService.hasExecutor.bind(this._functionService),this._definedNamesService.getValueByName.bind(this._definedNamesService),this._superTableService.getTable.bind(this._superTableService))}},u.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)],u.FFormula);class h extends l.FUniver{getFormula(){return this._injector.createInstance(u.FFormula)}}l.FUniver.extend(h),Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
|