@univerjs/engine-formula 0.12.4-experimental.20251208-c4b8a44 → 0.12.4-experimental.20251210-8d33c6e
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 +189 -34
- package/lib/es/index.js +3268 -3179
- package/lib/facade.js +189 -34
- package/lib/index.js +3268 -3179
- 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/formula-dependency.d.ts +4 -0
- package/lib/types/facade/f-formula.d.ts +116 -2
- package/lib/types/index.d.ts +1 -1
- package/lib/types/services/calculate-formula.service.d.ts +10 -6
- package/lib/types/services/current-data.service.d.ts +3 -3
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IExecutionOptions, IMutation, Nullable } from '@univerjs/core';
|
|
1
|
+
import { IExecutionOptions, IMutation, IUnitRange, Nullable } from '@univerjs/core';
|
|
2
2
|
import { IFormulaExecuteResultMap, IFormulaStringMap, IRuntimeOtherUnitDataType, IRuntimeUnitDataPrimitiveType } from '../../basics/common';
|
|
3
3
|
import { IFormulaDependencyTreeFullJson, IFormulaDependencyTreeJson } from '../../engine/dependency/dependency-tree';
|
|
4
4
|
import { IFormulaDirtyData } from '../../services/current-data.service';
|
|
@@ -27,6 +27,13 @@ export interface ISetFormulaDependencyCalculationResultMutation {
|
|
|
27
27
|
export interface ISetCellFormulaDependencyCalculationResultMutation {
|
|
28
28
|
result: IFormulaDependencyTreeFullJson | undefined;
|
|
29
29
|
}
|
|
30
|
+
export interface ISetQueryFormulaDependencyMutation {
|
|
31
|
+
unitRanges: IUnitRange[];
|
|
32
|
+
isInRange?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface ISetQueryFormulaDependencyResultMutation {
|
|
35
|
+
result: IFormulaDependencyTreeJson[];
|
|
36
|
+
}
|
|
30
37
|
/**
|
|
31
38
|
* TODO: @DR-Univer
|
|
32
39
|
* Trigger the calculation of the formula and stop the formula
|
|
@@ -51,3 +58,5 @@ export declare const SetFormulaDependencyCalculationMutation: IMutation<{}>;
|
|
|
51
58
|
export declare const SetFormulaDependencyCalculationResultMutation: IMutation<ISetFormulaDependencyCalculationResultMutation>;
|
|
52
59
|
export declare const SetCellFormulaDependencyCalculationMutation: IMutation<ISetFormulaDependencyCalculationMutation>;
|
|
53
60
|
export declare const SetCellFormulaDependencyCalculationResultMutation: IMutation<ISetCellFormulaDependencyCalculationResultMutation>;
|
|
61
|
+
export declare const SetQueryFormulaDependencyMutation: IMutation<ISetQueryFormulaDependencyMutation>;
|
|
62
|
+
export declare const SetQueryFormulaDependencyResultMutation: IMutation<ISetQueryFormulaDependencyResultMutation>;
|
|
@@ -9,6 +9,7 @@ export declare class CalculateController extends Disposable {
|
|
|
9
9
|
private _initialize;
|
|
10
10
|
private _commandExecutedListener;
|
|
11
11
|
private _calculate;
|
|
12
|
+
private _queryFormulaDependencyJson;
|
|
12
13
|
private _generateAllDependencyTreeJson;
|
|
13
14
|
private _generateCellDependencyTreeJson;
|
|
14
15
|
private _calculateFormulaString;
|
|
@@ -18,6 +18,8 @@ export interface IFormulaDependencyGenerator {
|
|
|
18
18
|
generate(): Promise<IFormulaDependencyTree[]>;
|
|
19
19
|
getAllDependencyJson(): Promise<IFormulaDependencyTreeJson[]>;
|
|
20
20
|
getCellDependencyJson(unitId: string, sheetId: string, row: number, column: number): Promise<IFormulaDependencyTreeFullJson | undefined>;
|
|
21
|
+
getRangeDependents(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
22
|
+
getInRangeFormulas(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
21
23
|
}
|
|
22
24
|
export declare const IFormulaDependencyGenerator: import('@wendellhu/redi').IdentifierDecorator<IFormulaDependencyGenerator>;
|
|
23
25
|
export declare class FormulaDependencyGenerator extends Disposable {
|
|
@@ -125,4 +127,6 @@ export declare class FormulaDependencyGenerator extends Disposable {
|
|
|
125
127
|
protected _startFormulaDependencyTreeModel(): void;
|
|
126
128
|
getAllDependencyJson(): Promise<IFormulaDependencyTreeJson[]>;
|
|
127
129
|
getCellDependencyJson(unitId: string, sheetId: string, row: number, column: number): Promise<IFormulaDependencyTreeFullJson | undefined>;
|
|
130
|
+
getRangeDependents(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
131
|
+
getInRangeFormulas(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
128
132
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IDisposable, ICommandService, IConfigService, Injector } from '@univerjs/core';
|
|
2
|
-
import { FormulaExecutedStateType, IExecutionInProgressParams, IFormulaDependencyTreeFullJson, IFormulaDependencyTreeJson, IFormulaExecuteResultMap, IFormulaStringMap, ISequenceNode, LexerTreeBuilder } from '@univerjs/engine-formula';
|
|
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';
|
|
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.
|
|
@@ -146,6 +146,59 @@ export declare class FFormula extends FBase {
|
|
|
146
146
|
* ```
|
|
147
147
|
*/
|
|
148
148
|
setMaxIteration(maxIteration: number): void;
|
|
149
|
+
/**
|
|
150
|
+
* Listens for the moment when formula-calculation results are applied.
|
|
151
|
+
*
|
|
152
|
+
* This event fires after the engine completes a calculation cycle and
|
|
153
|
+
* dispatches a `SetFormulaCalculationResultMutation`.
|
|
154
|
+
* The callback is invoked during an idle frame to avoid blocking UI updates.
|
|
155
|
+
*
|
|
156
|
+
* @param {Function} callback - A function called with the calculation result payload
|
|
157
|
+
* once the result-application mutation is emitted.
|
|
158
|
+
* @returns {IDisposable} A disposable used to unsubscribe from the event.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```ts
|
|
162
|
+
* const formulaEngine = univerAPI.getFormula();
|
|
163
|
+
*
|
|
164
|
+
* const dispose = formulaEngine.calculationResultApplied((result) => {
|
|
165
|
+
* console.log('Calculation results applied:', result);
|
|
166
|
+
* });
|
|
167
|
+
*
|
|
168
|
+
* // Later…
|
|
169
|
+
* dispose.dispose();
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
calculationResultApplied(callback: (result: ISetFormulaCalculationResultMutation) => void): IDisposable;
|
|
173
|
+
/**
|
|
174
|
+
* Waits for formula-calculation results to be applied.
|
|
175
|
+
*
|
|
176
|
+
* This method resolves under three conditions:
|
|
177
|
+
* 1. A real calculation runs and the engine emits a "calculation started" signal,
|
|
178
|
+
* followed by a "calculation result applied" signal.
|
|
179
|
+
* 2. No calculation actually starts within 500 ms — the method assumes there is
|
|
180
|
+
* nothing to wait for and resolves automatically.
|
|
181
|
+
* 3. A global 30 s timeout triggers, in which case the promise rejects.
|
|
182
|
+
*
|
|
183
|
+
* The API internally listens to both “calculation in progress” events and
|
|
184
|
+
* “calculation result applied” events, ensuring it behaves correctly whether
|
|
185
|
+
* formulas are recalculated or skipped due to cache/state.
|
|
186
|
+
*
|
|
187
|
+
* @returns {Promise<void>} A promise that resolves when calculation results are applied
|
|
188
|
+
* or when no calculation occurs within the start-detection window.
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```ts
|
|
192
|
+
* const formulaEngine = univerAPI.getFormula();
|
|
193
|
+
*
|
|
194
|
+
* // Wait for formula updates to apply before reading values.
|
|
195
|
+
* await formulaEngine.onCalculationResultApplied();
|
|
196
|
+
*
|
|
197
|
+
* const value = sheet.getRange("C24").getValue();
|
|
198
|
+
* console.log("Updated value:", value);
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
onCalculationResultApplied(): Promise<void>;
|
|
149
202
|
/**
|
|
150
203
|
* Execute a batch of formulas asynchronously and receive computed results.
|
|
151
204
|
*
|
|
@@ -273,4 +326,65 @@ export declare class FFormula extends FBase {
|
|
|
273
326
|
row: number;
|
|
274
327
|
column: number;
|
|
275
328
|
}, callback: (result: IFormulaDependencyTreeFullJson | undefined) => void): void;
|
|
329
|
+
/**
|
|
330
|
+
* Retrieve the full dependency trees for all formulas that *depend on* the
|
|
331
|
+
* specified ranges. This triggers a local dependency-calculation command and
|
|
332
|
+
* invokes the callback once the calculation completes.
|
|
333
|
+
*
|
|
334
|
+
* @param unitRanges An array of workbook/sheet ranges to query. Each range
|
|
335
|
+
* includes:
|
|
336
|
+
* - `unitId` The workbook ID.
|
|
337
|
+
* - `sheetId` The sheet ID.
|
|
338
|
+
* - `range` The row/column boundaries.
|
|
339
|
+
*
|
|
340
|
+
* @param callback A function invoked with an array of `IFormulaDependencyTreeJson`
|
|
341
|
+
* results. Each entry represents a formula node and its parent/child
|
|
342
|
+
* relationships within the dependency graph.
|
|
343
|
+
*
|
|
344
|
+
* @example
|
|
345
|
+
* ```ts
|
|
346
|
+
* const formulaEngine = univerAPI.getFormula();
|
|
347
|
+
*
|
|
348
|
+
* // Query all formulas that depend on A1:B10 in Sheet1.
|
|
349
|
+
* formulaEngine.getRangeDependents(
|
|
350
|
+
* [{ unitId: 'workbook1', sheetId: 'sheet1', range: { startRow: 0, endRow: 9, startColumn: 0, endColumn: 1 } }],
|
|
351
|
+
* (result) => {
|
|
352
|
+
* console.log('Dependent formulas:', result);
|
|
353
|
+
* }
|
|
354
|
+
* );
|
|
355
|
+
* ```
|
|
356
|
+
*/
|
|
357
|
+
getRangeDependents(unitRanges: IUnitRange[], callback: (result: IFormulaDependencyTreeJson[]) => void): void;
|
|
358
|
+
/**
|
|
359
|
+
* Retrieve the dependency trees of all formulas *inside* the specified ranges.
|
|
360
|
+
* Unlike `getRangeDependents`, this API only returns formulas whose definitions
|
|
361
|
+
* physically reside within the queried ranges.
|
|
362
|
+
*
|
|
363
|
+
* Internally this triggers the same dependency-calculation command but with
|
|
364
|
+
* `isInRange = true`, and the callback is invoked when the results are ready.
|
|
365
|
+
*
|
|
366
|
+
* @param unitRanges An array of workbook/sheet ranges defining the lookup
|
|
367
|
+
* boundaries:
|
|
368
|
+
* - `unitId` The workbook ID.
|
|
369
|
+
* - `sheetId` The sheet ID.
|
|
370
|
+
* - `range` The zero-based grid range.
|
|
371
|
+
*
|
|
372
|
+
* @param callback Receives an array of `IFormulaDependencyTreeJson` describing
|
|
373
|
+
* every formula found in the provided ranges along with their parent/child
|
|
374
|
+
* relationships.
|
|
375
|
+
*
|
|
376
|
+
* @example
|
|
377
|
+
* ```ts
|
|
378
|
+
* const formulaEngine = univerAPI.getFormula();
|
|
379
|
+
*
|
|
380
|
+
* // Query all formulas that lie within A1:D20 in Sheet1.
|
|
381
|
+
* formulaEngine.getInRangeFormulas(
|
|
382
|
+
* [{ unitId: 'workbook1', sheetId: 'sheet1', range: { startRow: 0, endRow: 19, startColumn: 0, endColumn: 3 } }],
|
|
383
|
+
* (result) => {
|
|
384
|
+
* console.log('Formulas inside range:', result);
|
|
385
|
+
* }
|
|
386
|
+
* );
|
|
387
|
+
* ```
|
|
388
|
+
*/
|
|
389
|
+
getInRangeFormulas(unitRanges: IUnitRange[], callback: (result: IFormulaDependencyTreeJson[]) => void): void;
|
|
276
390
|
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export { type ISetArrayFormulaDataMutationParams, SetArrayFormulaDataMutation }
|
|
|
33
33
|
export { type ISetDefinedNameMutationParam, type ISetDefinedNameMutationSearchParam, RemoveDefinedNameMutation, SetDefinedNameMutation } from './commands/mutations/set-defined-name.mutation';
|
|
34
34
|
export { SetDefinedNameMutationFactory } from './commands/mutations/set-defined-name.mutation';
|
|
35
35
|
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, SetCellFormulaDependencyCalculationMutation, SetCellFormulaDependencyCalculationResultMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationResultMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation, SetFormulaDependencyCalculationMutation, SetFormulaDependencyCalculationResultMutation, SetFormulaStringBatchCalculationMutation, SetFormulaStringBatchCalculationResultMutation, } from './commands/mutations/set-formula-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
37
|
export { type ISetFormulaDataMutationParams, SetFormulaDataMutation } from './commands/mutations/set-formula-data.mutation';
|
|
38
38
|
export { type ISetImageFormulaDataMutationParams, SetImageFormulaDataMutation } from './commands/mutations/set-image-formula-data.mutation';
|
|
39
39
|
export { type IRemoveOtherFormulaMutationParams, type ISetOtherFormulaMutationParams, RemoveOtherFormulaMutation, SetOtherFormulaMutation } from './commands/mutations/set-other-formula.mutation';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { IUnitRange, Disposable, IConfigService } from '@univerjs/core';
|
|
1
2
|
import { Observable, Subject } from 'rxjs';
|
|
2
|
-
import {
|
|
3
|
+
import { IFeatureDirtyRangeType, IFormulaDatasetConfig, IFormulaExecuteResultMap, IFormulaStringMap, IRuntimeUnitDataType, IUnitRowData } from '../basics/common';
|
|
3
4
|
import { IFormulaDependencyTreeFullJson, IFormulaDependencyTreeJson } from '../engine/dependency/dependency-tree';
|
|
4
5
|
import { FunctionVariantType } from '../engine/reference-object/base-reference-object';
|
|
5
6
|
import { IAllRuntimeData, IExecutionInProgressParams, IFormulaRuntimeService } from './runtime.service';
|
|
6
|
-
import { Disposable, IConfigService } from '@univerjs/core';
|
|
7
7
|
import { Lexer } from '../engine/analysis/lexer';
|
|
8
8
|
import { AstTreeBuilder } from '../engine/analysis/parser';
|
|
9
9
|
import { IFormulaDependencyGenerator } from '../engine/dependency/formula-dependency';
|
|
@@ -20,9 +20,11 @@ export interface ICalculateFormulaService {
|
|
|
20
20
|
execute(formulaDatasetConfig: IFormulaDatasetConfig): Promise<void>;
|
|
21
21
|
stopFormulaExecution(): void;
|
|
22
22
|
calculate(formulaString: string, transformSuffix?: boolean): void;
|
|
23
|
-
executeFormulas(formulas: IFormulaStringMap,
|
|
24
|
-
getAllDependencyJson(): Promise<IFormulaDependencyTreeJson[]>;
|
|
25
|
-
getCellDependencyJson(unitId: string, sheetId: string, row: number, column: number): Promise<IFormulaDependencyTreeFullJson | undefined>;
|
|
23
|
+
executeFormulas(formulas: IFormulaStringMap, rowData?: IUnitRowData): Promise<IFormulaExecuteResultMap>;
|
|
24
|
+
getAllDependencyJson(rowData?: IUnitRowData): Promise<IFormulaDependencyTreeJson[]>;
|
|
25
|
+
getCellDependencyJson(unitId: string, sheetId: string, row: number, column: number, rowData?: IUnitRowData): Promise<IFormulaDependencyTreeFullJson | undefined>;
|
|
26
|
+
getRangeDependents(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
27
|
+
getInRangeFormulas(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
26
28
|
}
|
|
27
29
|
export declare const ICalculateFormulaService: import('@wendellhu/redi').IdentifierDecorator<ICalculateFormulaService>;
|
|
28
30
|
export declare class CalculateFormulaService extends Disposable implements ICalculateFormulaService {
|
|
@@ -57,8 +59,10 @@ export declare class CalculateFormulaService extends Disposable implements ICalc
|
|
|
57
59
|
private _executeStep;
|
|
58
60
|
private _getArrayFormulaDirtyRangeAndExcludedRange;
|
|
59
61
|
protected _apply(isArrayFormulaState?: boolean): Promise<IAllRuntimeData | undefined>;
|
|
60
|
-
executeFormulas(formulas: IFormulaStringMap,
|
|
62
|
+
executeFormulas(formulas: IFormulaStringMap, rowData?: IUnitRowData): Promise<IFormulaExecuteResultMap>;
|
|
61
63
|
calculate(formulaString: string): Promise<FunctionVariantType | undefined>;
|
|
62
64
|
getAllDependencyJson(): Promise<IFormulaDependencyTreeJson[]>;
|
|
63
65
|
getCellDependencyJson(unitId: string, sheetId: string, row: number, column: number): Promise<IFormulaDependencyTreeFullJson | undefined>;
|
|
66
|
+
getRangeDependents(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
67
|
+
getInRangeFormulas(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
|
|
64
68
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IUnitRange, LocaleType, Nullable, Disposable, IUniverInstanceService, LocaleService } from '@univerjs/core';
|
|
2
|
-
import { IArrayFormulaRangeType,
|
|
2
|
+
import { IArrayFormulaRangeType, IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefinedNameMap, IDirtyUnitSheetNameMap, IFormulaData, IFormulaDatasetConfig, IRuntimeUnitDataType, IUnitData, IUnitExcludedCell, IUnitRowData, IUnitSheetIdToNameMap, IUnitSheetNameMap, IUnitStylesData } from '../basics/common';
|
|
3
3
|
import { FormulaDataModel } from '../models/formula-data.model';
|
|
4
4
|
import { ISheetRowFilteredService } from './sheet-row-filtered.service';
|
|
5
5
|
export interface IFormulaDirtyData {
|
|
@@ -55,7 +55,7 @@ export interface IFormulaCurrentConfigService {
|
|
|
55
55
|
};
|
|
56
56
|
getFilteredOutRows(unitId: string, sheetId: string, startRow: number, endRow: number): number[];
|
|
57
57
|
setSheetNameMap(sheetIdToNameMap: IUnitSheetIdToNameMap): void;
|
|
58
|
-
loadDataLite(
|
|
58
|
+
loadDataLite(rowData?: IUnitRowData): void;
|
|
59
59
|
}
|
|
60
60
|
export declare class FormulaCurrentConfigService extends Disposable implements IFormulaCurrentConfigService {
|
|
61
61
|
private readonly _univerInstanceService;
|
|
@@ -114,7 +114,7 @@ export declare class FormulaCurrentConfigService extends Disposable implements I
|
|
|
114
114
|
};
|
|
115
115
|
getFilteredOutRows(unitId: string, sheetId: string, startRow: number, endRow: number): number[];
|
|
116
116
|
load(config: IFormulaDatasetConfig): void;
|
|
117
|
-
loadDataLite(
|
|
117
|
+
loadDataLite(rowData?: IUnitRowData): void;
|
|
118
118
|
getDirtyData(): IFormulaDirtyData;
|
|
119
119
|
loadDirtyRangesAndExcludedCell(dirtyRanges: IUnitRange[], excludedCell?: IUnitExcludedCell): void;
|
|
120
120
|
registerUnitData(unitData: IUnitData): void;
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(o,s){typeof exports=="object"&&typeof module<"u"?s(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"],s):(o=typeof globalThis<"u"?globalThis:o||self,s(o.UniverEngineFormulaFacade={},o.UniverCoreFacade,o.UniverCore,o.UniverEngineFormula,o.rxjs))})(this,(function(o,s,u,r,l){"use strict";var f=Object.getOwnPropertyDescriptor,C=(c,e,i,t)=>{for(var n=t>1?void 0:t?f(e,i):e,a=c.length-1,d;a>=0;a--)(d=c[a])&&(n=d(n)||n);return n},m=(c,e)=>(i,t)=>e(i,t,c);o.FFormula=class extends s.FBase{constructor(e,i,t,n){super(),this._commandService=e,this._injector=i,this._lexerTreeBuilder=t,this._configService=n,this._initialize()}_initialize(){}get lexerTreeBuilder(){return this._lexerTreeBuilder}moveFormulaRefOffset(e,i,t,n){return this._lexerTreeBuilder.moveFormulaRefOffset(e,i,t,n)}sequenceNodesBuilder(e){return this._lexerTreeBuilder.sequenceNodesBuilder(e)||[]}executeCalculation(){this._commandService.executeCommand(r.SetFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})}stopCalculation(){this._commandService.executeCommand(r.SetFormulaCalculationStopMutation.id,{})}calculationStart(e){return this._commandService.onCommandExecuted(i=>{if(i.id===r.SetFormulaCalculationStartMutation.id){const t=i.params;e(t.forceCalculation)}})}calculationEnd(e){return this._commandService.onCommandExecuted(i=>{if(i.id!==r.SetFormulaCalculationNotificationMutation.id)return;const t=i.params;t.functionsExecutedState!==void 0&&e(t.functionsExecutedState)})}whenComputingCompleteAsync(e){const i=this._injector.get(r.GlobalComputingStatusService);return i.computingStatus?Promise.resolve(!0):l.firstValueFrom(l.race(i.computingStatus$.pipe(l.filter(t=>t)),l.timer(e!=null?e:3e4).pipe(l.map(()=>!1))))}onCalculationEnd(){return new Promise((e,i)=>{const t=setTimeout(()=>{i(new Error("Calculation end timeout"))},3e4),n=this.calculationEnd(()=>{clearTimeout(t),n.dispose(),e()})})}calculationProcessing(e){return this._commandService.onCommandExecuted(i=>{if(i.id!==r.SetFormulaCalculationNotificationMutation.id)return;const t=i.params;t.stageInfo!==void 0&&e(t.stageInfo)})}setMaxIteration(e){this._configService.setConfig(r.ENGINE_FORMULA_CYCLE_REFERENCE_COUNT,e)}calculationResultApplied(e){return this._commandService.onCommandExecuted(i=>{if(i.id!==r.SetFormulaCalculationResultMutation.id)return;const t=i.params;t!==void 0&&requestIdleCallback(()=>{e(t)})})}onCalculationResultApplied(){return new Promise((e,i)=>{let t=!1,n=!1;const a=setTimeout(()=>{p(),i(new Error("Calculation end timeout"))},3e4),d=setTimeout(()=>{t||(p(),e())},500),v=this.calculationProcessing(()=>{t||(t=!0,clearTimeout(d))}),h=this.calculationResultApplied(()=>{n||(n=!0,p(),e())});function p(){clearTimeout(a),clearTimeout(d),v.dispose(),h.dispose()}})}executeFormulas(e,i){this._commandService.executeCommand(r.SetFormulaStringBatchCalculationMutation.id,{formulas:e},{onlyLocal:!0});const t=this._commandService.onCommandExecuted(n=>{if(n.id!==r.SetFormulaStringBatchCalculationResultMutation.id)return;const a=n.params;a.result!=null&&i(a.result),t.dispose()})}getAllDependencyTrees(e){this._commandService.executeCommand(r.SetFormulaDependencyCalculationMutation.id,void 0,{onlyLocal:!0});const i=this._commandService.onCommandExecuted(t=>{if(t.id!==r.SetFormulaDependencyCalculationResultMutation.id)return;const n=t.params;n.result!=null&&e(n.result),i.dispose()})}getCellDependencyTree(e,i){this._commandService.executeCommand(r.SetCellFormulaDependencyCalculationMutation.id,e,{onlyLocal:!0});const t=this._commandService.onCommandExecuted(n=>{if(n.id!==r.SetCellFormulaDependencyCalculationResultMutation.id)return;const a=n.params;a.result!==void 0&&i(a.result),t.dispose()})}getRangeDependents(e,i){this._commandService.executeCommand(r.SetQueryFormulaDependencyMutation.id,{unitRanges:e},{onlyLocal:!0});const t=this._commandService.onCommandExecuted(n=>{if(n.id!==r.SetQueryFormulaDependencyResultMutation.id)return;const a=n.params;a.result!=null&&i(a.result),t.dispose()})}getInRangeFormulas(e,i){this._commandService.executeCommand(r.SetQueryFormulaDependencyMutation.id,{unitRanges:e,isInRange:!0},{onlyLocal:!0});const t=this._commandService.onCommandExecuted(n=>{if(n.id!==r.SetQueryFormulaDependencyResultMutation.id)return;const a=n.params;a.result!=null&&i(a.result),t.dispose()})}},o.FFormula=C([m(0,u.Inject(u.ICommandService)),m(1,u.Inject(u.Injector)),m(2,u.Inject(r.LexerTreeBuilder)),m(3,u.IConfigService)],o.FFormula);class S extends s.FUniver{getFormula(){return this._injector.createInstance(o.FFormula)}}s.FUniver.extend(S),Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})}));
|