@univerjs/engine-formula 0.15.2 → 0.15.3-insiders.20260131-b9b8805
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 +76 -154
- package/lib/es/index.js +2265 -2214
- package/lib/facade.js +76 -154
- package/lib/index.js +2265 -2214
- package/lib/types/engine/reference-object/base-reference-object.d.ts +13 -5
- package/lib/types/facade/f-formula.d.ts +1 -54
- package/lib/types/functions/column-like-functions.d.ts +2 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +5 -5
- package/LICENSE +0 -176
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ICellData, IRange, Nullable } from '@univerjs/core';
|
|
2
|
-
import { IRuntimeUnitDataType, IUnitData, IUnitSheetNameMap, IUnitStylesData } from '../../basics/common';
|
|
1
|
+
import { ICellData, IRange, Nullable, ObjectMatrix } from '@univerjs/core';
|
|
2
|
+
import { IArrayFormulaRangeType, IRuntimeUnitDataType, IUnitData, IUnitSheetNameMap, IUnitStylesData } from '../../basics/common';
|
|
3
3
|
import { BaseValueObject } from '../value-object/base-value-object';
|
|
4
4
|
import { FormulaAstLRU } from '../../basics/cache-lru';
|
|
5
5
|
import { ObjectClassType } from '../../basics/object-class-type';
|
|
@@ -20,7 +20,9 @@ export declare class BaseReferenceObject extends ObjectClassType {
|
|
|
20
20
|
private _forcedUnitId;
|
|
21
21
|
private _runtimeData;
|
|
22
22
|
private _arrayFormulaCellData;
|
|
23
|
+
private _arrayFormulaRange;
|
|
23
24
|
private _runtimeArrayFormulaCellData;
|
|
25
|
+
private _runtimeArrayFormulaRange;
|
|
24
26
|
private _runtimeFeatureCellData;
|
|
25
27
|
private _refOffsetX;
|
|
26
28
|
private _refOffsetY;
|
|
@@ -65,8 +67,12 @@ export declare class BaseReferenceObject extends ObjectClassType {
|
|
|
65
67
|
setRuntimeData(runtimeData: IRuntimeUnitDataType): void;
|
|
66
68
|
getArrayFormulaCellData(): IRuntimeUnitDataType;
|
|
67
69
|
setArrayFormulaCellData(unitData: IRuntimeUnitDataType): void;
|
|
70
|
+
getArrayFormulaRange(): IArrayFormulaRangeType;
|
|
71
|
+
setArrayFormulaRange(rangeData: IArrayFormulaRangeType): void;
|
|
68
72
|
getRuntimeArrayFormulaCellData(): IRuntimeUnitDataType;
|
|
69
73
|
setRuntimeArrayFormulaCellData(unitData: IRuntimeUnitDataType): void;
|
|
74
|
+
getRuntimeArrayFormulaRange(): IArrayFormulaRangeType;
|
|
75
|
+
setRuntimeArrayFormulaRange(rangeData: IArrayFormulaRangeType): void;
|
|
70
76
|
getRuntimeFeatureCellData(): {
|
|
71
77
|
[featureId: string]: IRuntimeUnitDataType;
|
|
72
78
|
};
|
|
@@ -95,9 +101,11 @@ export declare class BaseReferenceObject extends ObjectClassType {
|
|
|
95
101
|
getCellByColumn(column: number): BaseValueObject;
|
|
96
102
|
getCurrentActiveSheetData(): import('../../basics/common').ISheetItem;
|
|
97
103
|
getCurrentStylesData(): import('@univerjs/core').Styles;
|
|
98
|
-
getCurrentRuntimeSheetData():
|
|
99
|
-
getCurrentActiveArrayFormulaCellData():
|
|
100
|
-
getCurrentRuntimeActiveArrayFormulaCellData():
|
|
104
|
+
getCurrentRuntimeSheetData(): ObjectMatrix<Nullable<ICellData>> | undefined;
|
|
105
|
+
getCurrentActiveArrayFormulaCellData(): ObjectMatrix<Nullable<ICellData>> | undefined;
|
|
106
|
+
getCurrentRuntimeActiveArrayFormulaCellData(): ObjectMatrix<Nullable<ICellData>> | undefined;
|
|
107
|
+
getCurrentActiveArrayFormulaRange(): import('@univerjs/core').IObjectMatrixPrimitiveType<IRange> | undefined;
|
|
108
|
+
getCurrentRuntimeActiveArrayFormulaRange(): import('@univerjs/core').IObjectMatrixPrimitiveType<IRange> | undefined;
|
|
101
109
|
getCellData(row: number, column: number): Nullable<ICellData>;
|
|
102
110
|
getRuntimeFeatureCellValue(row: number, column: number): ICellData | undefined;
|
|
103
111
|
getCellByPosition(rowRaw?: number, columnRaw?: number): BaseValueObject;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IDisposable, IUnitRange, ICommandService, IConfigService, Injector } from '@univerjs/core';
|
|
2
|
-
import { FormulaExecutedStateType, IExecutionInProgressParams, IExprTreeNode, IFormulaDependencyTreeFullJson, IFormulaDependencyTreeJson, IFormulaDependentsAndInRangeResults, IFormulaExecuteResultMap, IFormulaStringMap, ISequenceNode,
|
|
2
|
+
import { FormulaExecutedStateType, IExecutionInProgressParams, IExprTreeNode, IFormulaDependencyTreeFullJson, IFormulaDependencyTreeJson, IFormulaDependentsAndInRangeResults, IFormulaExecuteResultMap, IFormulaStringMap, ISequenceNode, 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.
|
|
@@ -136,59 +136,6 @@ export declare class FFormula extends FBase {
|
|
|
136
136
|
* ```
|
|
137
137
|
*/
|
|
138
138
|
setMaxIteration(maxIteration: number): void;
|
|
139
|
-
/**
|
|
140
|
-
* Listens for the moment when formula-calculation results are applied.
|
|
141
|
-
*
|
|
142
|
-
* This event fires after the engine completes a calculation cycle and
|
|
143
|
-
* dispatches a `SetFormulaCalculationResultMutation`.
|
|
144
|
-
* The callback is invoked during an idle frame to avoid blocking UI updates.
|
|
145
|
-
*
|
|
146
|
-
* @param {Function} callback - A function called with the calculation result payload
|
|
147
|
-
* once the result-application mutation is emitted.
|
|
148
|
-
* @returns {IDisposable} A disposable used to unsubscribe from the event.
|
|
149
|
-
*
|
|
150
|
-
* @example
|
|
151
|
-
* ```ts
|
|
152
|
-
* const formulaEngine = univerAPI.getFormula();
|
|
153
|
-
*
|
|
154
|
-
* const dispose = formulaEngine.calculationResultApplied((result) => {
|
|
155
|
-
* console.log('Calculation results applied:', result);
|
|
156
|
-
* });
|
|
157
|
-
*
|
|
158
|
-
* // Later…
|
|
159
|
-
* dispose.dispose();
|
|
160
|
-
* ```
|
|
161
|
-
*/
|
|
162
|
-
calculationResultApplied(callback: (result: ISetFormulaCalculationResultMutation) => void): IDisposable;
|
|
163
|
-
/**
|
|
164
|
-
* Waits for formula-calculation results to be applied.
|
|
165
|
-
*
|
|
166
|
-
* This method resolves under three conditions:
|
|
167
|
-
* 1. A real calculation runs and the engine emits a "calculation started" signal,
|
|
168
|
-
* followed by a "calculation result applied" signal.
|
|
169
|
-
* 2. No calculation actually starts within 500 ms — the method assumes there is
|
|
170
|
-
* nothing to wait for and resolves automatically.
|
|
171
|
-
* 3. A global 30 s timeout triggers, in which case the promise rejects.
|
|
172
|
-
*
|
|
173
|
-
* The API internally listens to both “calculation in progress” events and
|
|
174
|
-
* “calculation result applied” events, ensuring it behaves correctly whether
|
|
175
|
-
* formulas are recalculated or skipped due to cache/state.
|
|
176
|
-
*
|
|
177
|
-
* @returns {Promise<void>} A promise that resolves when calculation results are applied
|
|
178
|
-
* or when no calculation occurs within the start-detection window.
|
|
179
|
-
*
|
|
180
|
-
* @example
|
|
181
|
-
* ```ts
|
|
182
|
-
* const formulaEngine = univerAPI.getFormula();
|
|
183
|
-
*
|
|
184
|
-
* // Wait for formula updates to apply before reading values.
|
|
185
|
-
* await formulaEngine.onCalculationResultApplied();
|
|
186
|
-
*
|
|
187
|
-
* const value = sheet.getRange("C24").getValue();
|
|
188
|
-
* console.log("Updated value:", value);
|
|
189
|
-
* ```
|
|
190
|
-
*/
|
|
191
|
-
onCalculationResultApplied(): Promise<void>;
|
|
192
139
|
/**
|
|
193
140
|
* Execute a batch of formulas asynchronously and receive computed results.
|
|
194
141
|
*
|
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,r,S){"use strict";var f=Object.getOwnPropertyDescriptor,v=(p,e,t,i)=>{for(var n=i>1?void 0:i?f(e,t):e,o=p.length-1,s;o>=0;o--)(s=p[o])&&(n=s(n)||n);return n},d=(p,e)=>(t,i)=>e(t,i,p);u.FFormula=class extends l.FBase{constructor(e,t,i,n,o,s,a){super(),this._commandService=e,this._injector=t,this._lexerTreeBuilder=i,this._configService=n,this._functionService=o,this._definedNamesService=s,this._superTableService=a,this._initialize()}_initialize(){}get lexerTreeBuilder(){return this._lexerTreeBuilder}moveFormulaRefOffset(e,t,i,n){return this._lexerTreeBuilder.moveFormulaRefOffset(e,t,i,n)}sequenceNodesBuilder(e){return this._lexerTreeBuilder.sequenceNodesBuilder(e)||[]}executeCalculation(){this._commandService.executeCommand(r.SetTriggerFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})}stopCalculation(){this._commandService.executeCommand(r.SetFormulaCalculationStopMutation.id,{})}calculationStart(e){return this._commandService.onCommandExecuted(t=>{if(t.id===r.SetFormulaCalculationStartMutation.id){const i=t.params;e(i.forceCalculation)}})}calculationEnd(e){return this._commandService.onCommandExecuted(t=>{if(t.id!==r.SetFormulaCalculationNotificationMutation.id)return;const i=t.params;i.functionsExecutedState!==void 0&&e(i.functionsExecutedState)})}whenComputingCompleteAsync(e){const t=this._injector.get(r.GlobalComputingStatusService);return t.computingStatus?Promise.resolve(!0):S.firstValueFrom(S.race(t.computingStatus$.pipe(S.filter(i=>i)),S.timer(e!=null?e:3e4).pipe(S.map(()=>!1))))}onCalculationEnd(){return new Promise((e,t)=>{const i=setTimeout(()=>{t(new Error("Calculation end timeout"))},3e4),n=this.calculationEnd(()=>{clearTimeout(i),n.dispose(),e()})})}calculationProcessing(e){return this._commandService.onCommandExecuted(t=>{if(t.id!==r.SetFormulaCalculationNotificationMutation.id)return;const i=t.params;i.stageInfo!==void 0&&e(i.stageInfo)})}setMaxIteration(e){this._configService.setConfig(r.ENGINE_FORMULA_CYCLE_REFERENCE_COUNT,e)}executeFormulas(e,t=3e4){return new Promise((i,n)=>{const o=this._commandService.onCommandExecuted(a=>{if(a.id!==r.SetFormulaStringBatchCalculationResultMutation.id)return;const c=a.params;clearTimeout(s),o.dispose(),c.result!=null?i(c.result):n(new Error("Formula batch calculation returned no result"))}),s=setTimeout(()=>{o.dispose(),n(new Error("Formula batch calculation timeout"))},t);this._commandService.executeCommand(r.SetFormulaStringBatchCalculationMutation.id,{formulas:e},{onlyLocal:!0})})}getAllDependencyTrees(e=3e4){return new Promise((t,i)=>{const n=this._commandService.onCommandExecuted(s=>{if(s.id!==r.SetFormulaDependencyCalculationResultMutation.id)return;const a=s.params;clearTimeout(o),n.dispose(),a.result!=null?t(a.result):t([])}),o=setTimeout(()=>{n.dispose(),i(new Error("Formula dependency calculation timeout"))},e);this._commandService.executeCommand(r.SetFormulaDependencyCalculationMutation.id,void 0,{onlyLocal:!0})})}getCellDependencyTree(e,t=3e4){return new Promise((i,n)=>{const o=this._commandService.onCommandExecuted(a=>{if(a.id!==r.SetCellFormulaDependencyCalculationResultMutation.id)return;const c=a.params;clearTimeout(s),o.dispose(),i(c.result)}),s=setTimeout(()=>{o.dispose(),n(new Error("Cell dependency calculation timeout"))},t);this._commandService.executeCommand(r.SetCellFormulaDependencyCalculationMutation.id,e,{onlyLocal:!0})})}getRangeDependents(e,t=3e4){return new Promise((i,n)=>{const o=this._commandService.onCommandExecuted(a=>{if(a.id!==r.SetQueryFormulaDependencyResultMutation.id)return;const c=a.params;clearTimeout(s),o.dispose(),c.result!=null?i(c.result):i([])}),s=setTimeout(()=>{o.dispose(),n(new Error("Range dependents calculation timeout"))},t);this._commandService.executeCommand(r.SetQueryFormulaDependencyMutation.id,{unitRanges:e},{onlyLocal:!0})})}getInRangeFormulas(e,t=3e4){return new Promise((i,n)=>{const o=this._commandService.onCommandExecuted(a=>{if(a.id!==r.SetQueryFormulaDependencyResultMutation.id)return;const c=a.params;clearTimeout(s),o.dispose(),c.result!=null?i(c.result):i([])}),s=setTimeout(()=>{o.dispose(),n(new Error("In-range formulas calculation timeout"))},t);this._commandService.executeCommand(r.SetQueryFormulaDependencyMutation.id,{unitRanges:e,isInRange:!0},{onlyLocal:!0})})}setFormulaReturnDependencyTree(e){this._configService.setConfig(r.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))}getRangeDependentsAndInRangeFormulas(e,t=3e4){return new Promise((i,n)=>{const o=this._commandService.onCommandExecuted(a=>{if(a.id!==r.SetQueryFormulaDependencyAllResultMutation.id)return;const c=a.params;clearTimeout(s),o.dispose(),c.result!=null?i(c.result):i({dependents:[],inRanges:[]})}),s=setTimeout(()=>{o.dispose(),n(new Error("Range dependents calculation timeout"))},t);this._commandService.executeCommand(r.SetQueryFormulaDependencyAllMutation.id,{unitRanges:e},{onlyLocal:!0})})}},u.FFormula=v([d(0,m.Inject(m.ICommandService)),d(1,m.Inject(m.Injector)),d(2,m.Inject(r.LexerTreeBuilder)),d(3,m.IConfigService),d(4,r.IFunctionService),d(5,r.IDefinedNamesService),d(6,r.ISuperTableService)],u.FFormula);class _ extends l.FUniver{getFormula(){return this._injector.createInstance(u.FFormula)}}l.FUniver.extend(_),Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
|