@univerjs/engine-formula 0.5.1 → 0.5.2
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 +2 -2
- package/lib/es/facade.js +47 -32
- package/lib/es/index.js +3148 -2981
- package/lib/types/basics/common.d.ts +1 -0
- package/lib/types/controller/config.schema.d.ts +2 -0
- package/lib/types/engine/analysis/lexer-tree-builder.d.ts +1 -1
- package/lib/types/engine/dependency/dependency-tree.d.ts +3 -1
- package/lib/types/engine/dependency/formula-dependency.d.ts +20 -1
- package/lib/types/engine/utils/value-object.d.ts +0 -1
- package/lib/types/facade/f-formula.d.ts +15 -2
- package/lib/types/functions/lookup/choose/index.d.ts +0 -1
- package/lib/types/functions/math/function-map.d.ts +2 -2
- package/lib/types/functions/math/product/index.d.ts +0 -1
- package/lib/types/functions/math/sumifs/index.d.ts +1 -1
- package/lib/types/index.d.ts +1 -2
- package/lib/types/services/calculate-formula.service.d.ts +0 -1
- package/lib/types/services/current-data.service.d.ts +1 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +2 -2
- package/package.json +6 -6
- package/lib/types/controller/set-defined-name.controller.d.ts +0 -9
package/lib/es/facade.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { Inject as
|
|
2
|
-
import { SetFormulaCalculationStartMutation as
|
|
3
|
-
var
|
|
4
|
-
for (var
|
|
5
|
-
(
|
|
6
|
-
return
|
|
7
|
-
},
|
|
8
|
-
let
|
|
9
|
-
constructor(t, e) {
|
|
10
|
-
super(), this._commandService = t, this._injector = e;
|
|
1
|
+
import { Inject as u, ICommandService as f, Injector as C, FBase as _, IConfigService as v, FUniver as d } from "@univerjs/core";
|
|
2
|
+
import { SetFormulaCalculationStartMutation as l, SetFormulaCalculationStopMutation as p, SetFormulaCalculationNotificationMutation as m, ENGINE_FORMULA_CYCLE_REFERENCE_COUNT as S } from "@univerjs/engine-formula";
|
|
3
|
+
var E = Object.defineProperty, x = Object.getOwnPropertyDescriptor, h = (t, e, o, a) => {
|
|
4
|
+
for (var i = a > 1 ? void 0 : a ? x(e, o) : e, n = t.length - 1, r; n >= 0; n--)
|
|
5
|
+
(r = t[n]) && (i = (a ? r(e, o, i) : r(i)) || i);
|
|
6
|
+
return a && i && E(e, o, i), i;
|
|
7
|
+
}, c = (t, e) => (o, a) => e(o, a, t);
|
|
8
|
+
let s = class extends _ {
|
|
9
|
+
constructor(t, e, o) {
|
|
10
|
+
super(), this._commandService = t, this._injector = e, this._configService = o;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* Start the calculation of the formula.
|
|
14
14
|
*/
|
|
15
15
|
executeCalculation() {
|
|
16
|
-
this._commandService.executeCommand(
|
|
16
|
+
this._commandService.executeCommand(l.id, { commands: [], forceCalculation: !0 }, { onlyLocal: !0 });
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Stop the calculation of the formula.
|
|
20
20
|
*/
|
|
21
21
|
stopCalculation() {
|
|
22
|
-
this._commandService.executeCommand(
|
|
22
|
+
this._commandService.executeCommand(p.id, {});
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Listening calculation starts.
|
|
26
26
|
*/
|
|
27
27
|
calculationStart(t) {
|
|
28
28
|
return this._commandService.onCommandExecuted((e) => {
|
|
29
|
-
if (e.id ===
|
|
30
|
-
const
|
|
31
|
-
t(
|
|
29
|
+
if (e.id === l.id) {
|
|
30
|
+
const o = e.params;
|
|
31
|
+
t(o.forceCalculation);
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
}
|
|
@@ -37,18 +37,18 @@ let c = class extends v {
|
|
|
37
37
|
*/
|
|
38
38
|
calculationEnd(t) {
|
|
39
39
|
return this._commandService.onCommandExecuted((e) => {
|
|
40
|
-
if (e.id !==
|
|
40
|
+
if (e.id !== m.id)
|
|
41
41
|
return;
|
|
42
|
-
const
|
|
43
|
-
|
|
42
|
+
const o = e.params;
|
|
43
|
+
o.functionsExecutedState !== void 0 && t(o.functionsExecutedState);
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
onCalculationEnd() {
|
|
47
47
|
return new Promise((t, e) => {
|
|
48
|
-
const
|
|
48
|
+
const o = setTimeout(() => {
|
|
49
49
|
e(new Error("Calculation end timeout"));
|
|
50
|
-
}, 3e4),
|
|
51
|
-
clearTimeout(
|
|
50
|
+
}, 3e4), a = this.calculationEnd(() => {
|
|
51
|
+
clearTimeout(o), a.dispose(), t();
|
|
52
52
|
});
|
|
53
53
|
});
|
|
54
54
|
}
|
|
@@ -57,23 +57,38 @@ let c = class extends v {
|
|
|
57
57
|
*/
|
|
58
58
|
calculationProcessing(t) {
|
|
59
59
|
return this._commandService.onCommandExecuted((e) => {
|
|
60
|
-
if (e.id !==
|
|
60
|
+
if (e.id !== m.id)
|
|
61
61
|
return;
|
|
62
|
-
const
|
|
63
|
-
|
|
62
|
+
const o = e.params;
|
|
63
|
+
o.stageInfo !== void 0 && t(o.stageInfo);
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* When a formula contains a circular reference, set the maximum number of iterations for the formula calculation.
|
|
68
|
+
* @param maxIteration The maximum number of iterations. The default value is 1.
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* // Set the maximum number of iterations for the formula calculation to 5.
|
|
72
|
+
* // The default value is 1.
|
|
73
|
+
* const formulaEngine = univerAPI.getFormula();
|
|
74
|
+
* formulaEngine.setMaxIteration(5);
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
setMaxIteration(t) {
|
|
78
|
+
this._configService.setConfig(S, t);
|
|
79
|
+
}
|
|
66
80
|
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
81
|
+
s = h([
|
|
82
|
+
c(0, u(f)),
|
|
83
|
+
c(1, u(C)),
|
|
84
|
+
c(2, v)
|
|
85
|
+
], s);
|
|
86
|
+
class F extends d {
|
|
72
87
|
getFormula() {
|
|
73
|
-
return this._injector.createInstance(
|
|
88
|
+
return this._injector.createInstance(s);
|
|
74
89
|
}
|
|
75
90
|
}
|
|
76
|
-
d.extend(
|
|
91
|
+
d.extend(F);
|
|
77
92
|
export {
|
|
78
|
-
|
|
93
|
+
s as FFormula
|
|
79
94
|
};
|