@univerjs/engine-formula 0.12.4-experimental.20251208-c4b8a44 → 0.12.4-experimental.20251210-d708bff

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.
@@ -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 {
@@ -124,5 +126,8 @@ export declare class FormulaDependencyGenerator extends Disposable {
124
126
  protected _endFormulaDependencyTreeModel(): void;
125
127
  protected _startFormulaDependencyTreeModel(): void;
126
128
  getAllDependencyJson(): Promise<IFormulaDependencyTreeJson[]>;
129
+ protected _setRealFormulaString(treeModel: FormulaDependencyTreeModel): void;
127
130
  getCellDependencyJson(unitId: string, sheetId: string, row: number, column: number): Promise<IFormulaDependencyTreeFullJson | undefined>;
131
+ getRangeDependents(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
132
+ getInRangeFormulas(unitRanges: IUnitRange[]): Promise<IFormulaDependencyTreeJson[]>;
128
133
  }
@@ -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
  *
@@ -173,11 +226,13 @@ export declare class FFormula extends FBase {
173
226
  * Nested structure (unit → sheet → row → column) describing formulas and
174
227
  * their decomposed sub-expressions.
175
228
  *
176
- * @param {(result: IFormulaExecuteResultMap) => void} callback
177
- * Receives the computed value map mirroring the input structure.
229
+ * @param {number} [timeout]
230
+ * Optional timeout in milliseconds. If no result is received within this
231
+ * period, the promise will be rejected.
178
232
  *
179
- * @returns {IDisposable}
180
- * A disposer to stop listening for batch results.
233
+ * @returns {Promise<IFormulaExecuteResultMap>}
234
+ * A promise that resolves with the computed value map mirroring
235
+ * the input structure.
181
236
  *
182
237
  * @example
183
238
  * ```ts
@@ -209,34 +264,33 @@ export declare class FFormula extends FBase {
209
264
  * },
210
265
  * };
211
266
  *
212
- * const disposer = formulaEngine.executeFormulas(formulas, (result) => {
213
- * console.log(result);
214
- * });
215
- *
267
+ * const result = await formulaEngine.executeFormulas(formulas);
268
+ * console.log(result);
216
269
  * ```
217
270
  */
218
- executeFormulas(formulas: IFormulaStringMap, callback: (result: IFormulaExecuteResultMap) => void): void;
271
+ executeFormulas(formulas: IFormulaStringMap, timeout?: number): Promise<IFormulaExecuteResultMap>;
219
272
  /**
220
273
  * Retrieve all formula dependency trees that were produced during the latest
221
274
  * dependency-analysis run. This triggers a local dependency-calculation command
222
275
  * and returns the complete set of dependency trees once the calculation finishes.
223
276
  *
224
- * @param callback A function invoked with the resulting array of dependency trees.
277
+ * @param {number} [timeout]
278
+ * Optional timeout in milliseconds. If no result is received within this
279
+ * period, the promise will be rejected.
225
280
  *
226
- * @returns {IDisposable} An object that disposes the internal event listener.
281
+ * @returns {Promise<IFormulaDependencyTreeJson[]>}
282
+ * A promise that resolves with the array of dependency trees.
227
283
  *
228
284
  * @example
229
285
  * ```ts
230
286
  * const formulaEngine = univerAPI.getFormula();
231
287
  *
232
288
  * // Fetch all dependency trees generated for the current workbook.
233
- * const disposable = formulaEngine.getAllDependencyTrees((trees) => {
234
- * console.log('All dependency trees:', trees);
235
- * });
236
- *
289
+ * const trees = await formulaEngine.getAllDependencyTrees();
290
+ * console.log('All dependency trees:', trees);
237
291
  * ```
238
292
  */
239
- getAllDependencyTrees(callback: (result: IFormulaDependencyTreeJson[]) => void): void;
293
+ getAllDependencyTrees(timeout?: number): Promise<IFormulaDependencyTreeJson[]>;
240
294
  /**
241
295
  * Retrieve the dependency tree of a specific cell. This triggers a local
242
296
  * dependency-calculation command for the given unit, sheet, and cell location,
@@ -248,23 +302,27 @@ export declare class FFormula extends FBase {
248
302
  * - `row` The zero-based row index.
249
303
  * - `column` The zero-based column index.
250
304
  *
251
- * @param callback A function invoked with the resulting dependency tree or
252
- * `undefined` if no dependency tree exists for that cell.
305
+ * @param {number} [timeout]
306
+ * Optional timeout in milliseconds. If no result is received within this
307
+ * period, the promise will be rejected.
253
308
  *
254
- * @returns {IDisposable} An object that disposes the internal event listener.
309
+ * @returns {Promise<IFormulaDependencyTreeFullJson | undefined>}
310
+ * A promise that resolves with the dependency tree or `undefined`
311
+ * if no tree exists for that cell.
255
312
  *
256
313
  * @example
257
314
  * ```ts
258
315
  * const formulaEngine = univerAPI.getFormula();
259
316
  *
260
317
  * // Query the dependency tree for cell B2 in a specific sheet.
261
- * const disposable = formulaEngine.getCellDependencyTree(
262
- * { unitId: 'workbook1', sheetId: 'sheet1', row: 1, column: 1 },
263
- * (tree) => {
264
- * console.log('Cell dependency tree:', tree);
265
- * }
266
- * );
318
+ * const tree = await formulaEngine.getCellDependencyTree({
319
+ * unitId: 'workbook1',
320
+ * sheetId: 'sheet1',
321
+ * row: 1,
322
+ * column: 1,
323
+ * });
267
324
  *
325
+ * console.log('Cell dependency tree:', tree);
268
326
  * ```
269
327
  */
270
328
  getCellDependencyTree(param: {
@@ -272,5 +330,73 @@ export declare class FFormula extends FBase {
272
330
  sheetId: string;
273
331
  row: number;
274
332
  column: number;
275
- }, callback: (result: IFormulaDependencyTreeFullJson | undefined) => void): void;
333
+ }, timeout?: number): Promise<IFormulaDependencyTreeFullJson | undefined>;
334
+ /**
335
+ * Retrieve the full dependency trees for all formulas that *depend on* the
336
+ * specified ranges. This triggers a local dependency-calculation command and
337
+ * resolves once the calculation completes.
338
+ *
339
+ * @param unitRanges An array of workbook/sheet ranges to query. Each range
340
+ * includes:
341
+ * - `unitId` The workbook ID.
342
+ * - `sheetId` The sheet ID.
343
+ * - `range` The row/column boundaries.
344
+ *
345
+ * @param {number} [timeout]
346
+ * Optional timeout in milliseconds. If no result is received within this
347
+ * period, the promise will be rejected.
348
+ *
349
+ * @returns {Promise<IFormulaDependencyTreeJson[]>}
350
+ * A promise that resolves with an array of `IFormulaDependencyTreeJson`
351
+ * representing formulas and their relationships within the dependency graph.
352
+ *
353
+ * @example
354
+ * ```ts
355
+ * const formulaEngine = univerAPI.getFormula();
356
+ *
357
+ * // Query all formulas that depend on A1:B10 in Sheet1.
358
+ * const dependents = await formulaEngine.getRangeDependents([
359
+ * { unitId: 'workbook1', sheetId: 'sheet1', range: { startRow: 0, endRow: 9, startColumn: 0, endColumn: 1 } }
360
+ * ]);
361
+ *
362
+ * console.log('Dependent formulas:', dependents);
363
+ * ```
364
+ */
365
+ getRangeDependents(unitRanges: IUnitRange[], timeout?: number): Promise<IFormulaDependencyTreeJson[]>;
366
+ /**
367
+ * Retrieve the dependency trees of all formulas *inside* the specified ranges.
368
+ * Unlike `getRangeDependents`, this API only returns formulas whose definitions
369
+ * physically reside within the queried ranges.
370
+ *
371
+ * Internally this triggers the same dependency-calculation command but with
372
+ * `isInRange = true`, and the promise resolves when the results are ready.
373
+ *
374
+ * @param unitRanges An array of workbook/sheet ranges defining the lookup
375
+ * boundaries:
376
+ * - `unitId` The workbook ID.
377
+ * - `sheetId` The sheet ID.
378
+ * - `range` The zero-based grid range.
379
+ *
380
+ * @param {number} [timeout]
381
+ * Optional timeout in milliseconds. If no result is received within this
382
+ * period, the promise will be rejected.
383
+ *
384
+ * @returns {Promise<IFormulaDependencyTreeJson[]>}
385
+ * A promise that resolves with an array of `IFormulaDependencyTreeJson`
386
+ * describing every formula found in the provided ranges along with
387
+ * their parent/child relationships.
388
+ *
389
+ * @example
390
+ * ```ts
391
+ * const formulaEngine = univerAPI.getFormula();
392
+ *
393
+ * // Query all formulas that lie within A1:D20 in Sheet1.
394
+ * const formulasInRange = await formulaEngine.getInRangeFormulas([
395
+ * { unitId: 'workbook1', sheetId: 'sheet1', range: { startRow: 0, endRow: 19, startColumn: 0, endColumn: 3 } }
396
+ * ]);
397
+ *
398
+ * console.log('Formulas inside range:', formulasInRange);
399
+ * ```
400
+ */
401
+ getInRangeFormulas(unitRanges: IUnitRange[], timeout?: number): Promise<IFormulaDependencyTreeJson[]>;
276
402
  }
@@ -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 { IArrayFormulaRangeType, IArrayFormulaUnitCellType, IFeatureDirtyRangeType, IFormulaData, IFormulaDatasetConfig, IFormulaExecuteResultMap, IFormulaStringMap, IRuntimeUnitDataType, IUnitRowData } from '../basics/common';
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, formulaData: IFormulaData, arrayFormulaCellData: IArrayFormulaUnitCellType, arrayFormulaRange: IArrayFormulaRangeType, rowData: IUnitRowData): Promise<IFormulaExecuteResultMap>;
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, formulaData: IFormulaData, arrayFormulaCellData: IArrayFormulaUnitCellType, arrayFormulaRange: IArrayFormulaRangeType, rowData?: IUnitRowData): Promise<IFormulaExecuteResultMap>;
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, IArrayFormulaUnitCellType, IDirtyUnitFeatureMap, IDirtyUnitOtherFormulaMap, IDirtyUnitSheetDefinedNameMap, IDirtyUnitSheetNameMap, IFormulaData, IFormulaDatasetConfig, IRuntimeUnitDataType, IUnitData, IUnitExcludedCell, IUnitRowData, IUnitSheetIdToNameMap, IUnitSheetNameMap, IUnitStylesData } from '../basics/common';
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(formulaData: IFormulaData, arrayFormulaCellData: IArrayFormulaUnitCellType, arrayFormulaRange: IArrayFormulaRangeType, rowData?: IUnitRowData): void;
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(formulaData: IFormulaData, arrayFormulaCellData: IArrayFormulaUnitCellType, arrayFormulaRange: IArrayFormulaRangeType, rowData?: IUnitRowData): void;
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(a,u){typeof exports=="object"&&typeof module<"u"?u(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"],u):(a=typeof globalThis<"u"?globalThis:a||self,u(a.UniverEngineFormulaFacade={},a.UniverCoreFacade,a.UniverCore,a.UniverEngineFormula,a.rxjs))})(this,(function(a,u,c,n,l){"use strict";var f=Object.getOwnPropertyDescriptor,p=(s,e,t,i)=>{for(var r=i>1?void 0:i?f(e,t):e,o=s.length-1,m;o>=0;o--)(m=s[o])&&(r=m(r)||r);return r},d=(s,e)=>(t,i)=>e(t,i,s);a.FFormula=class extends u.FBase{constructor(e,t,i,r){super(),this._commandService=e,this._injector=t,this._lexerTreeBuilder=i,this._configService=r,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):l.firstValueFrom(l.race(t.computingStatus$.pipe(l.filter(i=>i)),l.timer(e!=null?e:3e4).pipe(l.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)}executeFormulas(e,t){this._commandService.executeCommand(n.SetFormulaStringBatchCalculationMutation.id,{formulas:e},{onlyLocal:!0});const i=this._commandService.onCommandExecuted(r=>{if(r.id!==n.SetFormulaStringBatchCalculationResultMutation.id)return;const o=r.params;o.result!=null&&t(o.result),i.dispose()})}getAllDependencyTrees(e){this._commandService.executeCommand(n.SetFormulaDependencyCalculationMutation.id,void 0,{onlyLocal:!0});const t=this._commandService.onCommandExecuted(i=>{if(i.id!==n.SetFormulaDependencyCalculationResultMutation.id)return;const r=i.params;r.result!=null&&e(r.result),t.dispose()})}getCellDependencyTree(e,t){this._commandService.executeCommand(n.SetCellFormulaDependencyCalculationMutation.id,e,{onlyLocal:!0});const i=this._commandService.onCommandExecuted(r=>{if(r.id!==n.SetCellFormulaDependencyCalculationResultMutation.id)return;const o=r.params;o.result!==void 0&&t(o.result),i.dispose()})}},a.FFormula=p([d(0,c.Inject(c.ICommandService)),d(1,c.Inject(c.Injector)),d(2,c.Inject(n.LexerTreeBuilder)),d(3,c.IConfigService)],a.FFormula);class v extends u.FUniver{getFormula(){return this._injector.createInstance(a.FFormula)}}u.FUniver.extend(v),Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(s,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):(s=typeof globalThis<"u"?globalThis:s||self,l(s.UniverEngineFormulaFacade={},s.UniverCoreFacade,s.UniverCore,s.UniverEngineFormula,s.rxjs))})(this,(function(s,l,d,n,p){"use strict";var S=Object.getOwnPropertyDescriptor,v=(m,e,i,t)=>{for(var r=t>1?void 0:t?S(e,i):e,o=m.length-1,a;o>=0;o--)(a=m[o])&&(r=a(r)||r);return r},f=(m,e)=>(i,t)=>e(i,t,m);s.FFormula=class extends l.FBase{constructor(e,i,t,r){super(),this._commandService=e,this._injector=i,this._lexerTreeBuilder=t,this._configService=r,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.SetFormulaCalculationStartMutation.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):p.firstValueFrom(p.race(i.computingStatus$.pipe(p.filter(t=>t)),p.timer(e!=null?e:3e4).pipe(p.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(()=>{C(),i(new Error("Calculation end timeout"))},3e4),a=setTimeout(()=>{t||(C(),e())},500),u=this.calculationProcessing(()=>{t||(t=!0,clearTimeout(a))}),c=this.calculationResultApplied(()=>{r||(r=!0,C(),e())});function C(){clearTimeout(o),clearTimeout(a),u.dispose(),c.dispose()}})}executeFormulas(e,i=3e4){return new Promise((t,r)=>{const o=this._commandService.onCommandExecuted(u=>{if(u.id!==n.SetFormulaStringBatchCalculationResultMutation.id)return;const c=u.params;clearTimeout(a),o.dispose(),c.result!=null?t(c.result):r(new Error("Formula batch calculation returned no result"))}),a=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(a=>{if(a.id!==n.SetFormulaDependencyCalculationResultMutation.id)return;const u=a.params;clearTimeout(o),r.dispose(),u.result!=null?i(u.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(u=>{if(u.id!==n.SetCellFormulaDependencyCalculationResultMutation.id)return;const c=u.params;clearTimeout(a),o.dispose(),t(c.result)}),a=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(u=>{if(u.id!==n.SetQueryFormulaDependencyResultMutation.id)return;const c=u.params;clearTimeout(a),o.dispose(),c.result!=null?t(c.result):t([])}),a=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(u=>{if(u.id!==n.SetQueryFormulaDependencyResultMutation.id)return;const c=u.params;clearTimeout(a),o.dispose(),c.result!=null?t(c.result):t([])}),a=setTimeout(()=>{o.dispose(),r(new Error("In-range formulas calculation timeout"))},i);this._commandService.executeCommand(n.SetQueryFormulaDependencyMutation.id,{unitRanges:e,isInRange:!0},{onlyLocal:!0})})}},s.FFormula=v([f(0,d.Inject(d.ICommandService)),f(1,d.Inject(d.Injector)),f(2,d.Inject(n.LexerTreeBuilder)),f(3,d.IConfigService)],s.FFormula);class h extends l.FUniver{getFormula(){return this._injector.createInstance(s.FFormula)}}l.FUniver.extend(h),Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})}));