@univerjs/engine-formula 0.5.3 → 0.5.4
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 +70 -37
- package/lib/es/index.js +2950 -3015
- package/lib/types/engine/utils/generate-ast-node.d.ts +2 -0
- package/lib/types/engine/utils/reference.d.ts +4 -0
- package/lib/types/engine/value-object/lambda-value-object.d.ts +6 -0
- package/lib/types/engine/value-object/primitive-object.d.ts +2 -1
- package/lib/types/facade/f-formula.d.ts +29 -2
- package/lib/types/functions/base-function.d.ts +2 -2
- package/lib/types/index.d.ts +2 -2
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +2 -2
- package/package.json +5 -5
package/lib/es/facade.js
CHANGED
|
@@ -1,16 +1,45 @@
|
|
|
1
|
-
import { Inject as u, ICommandService as
|
|
2
|
-
import { SetFormulaCalculationStartMutation as l, SetFormulaCalculationStopMutation as p, SetFormulaCalculationNotificationMutation as
|
|
3
|
-
var
|
|
4
|
-
for (var n =
|
|
5
|
-
(
|
|
6
|
-
return
|
|
7
|
-
},
|
|
1
|
+
import { Inject as u, ICommandService as f, Injector as _, FBase as C, IConfigService as v, FUniver as m } from "@univerjs/core";
|
|
2
|
+
import { LexerTreeBuilder as x, SetFormulaCalculationStartMutation as l, SetFormulaCalculationStopMutation as p, SetFormulaCalculationNotificationMutation as d, ENGINE_FORMULA_CYCLE_REFERENCE_COUNT as S } from "@univerjs/engine-formula";
|
|
3
|
+
var h = Object.defineProperty, E = Object.getOwnPropertyDescriptor, F = (e, t, r, i) => {
|
|
4
|
+
for (var n = i > 1 ? void 0 : i ? E(t, r) : t, a = e.length - 1, c; a >= 0; a--)
|
|
5
|
+
(c = e[a]) && (n = (i ? c(t, r, n) : c(n)) || n);
|
|
6
|
+
return i && n && h(t, r, n), n;
|
|
7
|
+
}, o = (e, t) => (r, i) => t(r, i, e);
|
|
8
8
|
let s = class extends C {
|
|
9
|
-
constructor(t,
|
|
10
|
-
super(), this._commandService =
|
|
9
|
+
constructor(e, t, r, i) {
|
|
10
|
+
super(), this._commandService = e, this._injector = t, this._lexerTreeBuilder = r, this._configService = i, this._initialize();
|
|
11
11
|
}
|
|
12
12
|
_initialize() {
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* The tree builder for formula string.
|
|
16
|
+
* @type {LexerTreeBuilder}
|
|
17
|
+
*/
|
|
18
|
+
get lexerTreeBuilder() {
|
|
19
|
+
return this._lexerTreeBuilder;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Offsets the formula
|
|
23
|
+
* @param {string} formulaString
|
|
24
|
+
* @param {number} refOffsetX
|
|
25
|
+
* @param {number} refOffsetY
|
|
26
|
+
* @param {boolean} [ignoreAbsolute] default is false
|
|
27
|
+
* @example
|
|
28
|
+
* const result = moveFormulaRefOffset('sum(a1,b2)',1,1)
|
|
29
|
+
* // result is 'sum(b2,c3)'
|
|
30
|
+
*/
|
|
31
|
+
moveFormulaRefOffset(e, t, r, i) {
|
|
32
|
+
return this._lexerTreeBuilder.moveFormulaRefOffset(e, t, r, i);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Resolves the formula string to a 'node' node
|
|
36
|
+
* @param {string} formulaString
|
|
37
|
+
* @returns {*} {((string | ISequenceNode)[])}
|
|
38
|
+
* @memberof FFormula
|
|
39
|
+
*/
|
|
40
|
+
sequenceNodesBuilder(e) {
|
|
41
|
+
return this._lexerTreeBuilder.sequenceNodesBuilder(e) || [];
|
|
42
|
+
}
|
|
14
43
|
/**
|
|
15
44
|
* Start the calculation of the formula.
|
|
16
45
|
*/
|
|
@@ -25,44 +54,47 @@ let s = class extends C {
|
|
|
25
54
|
}
|
|
26
55
|
/**
|
|
27
56
|
* Listening calculation starts.
|
|
57
|
+
* @param callback
|
|
28
58
|
*/
|
|
29
|
-
calculationStart(
|
|
30
|
-
return this._commandService.onCommandExecuted((
|
|
31
|
-
if (
|
|
32
|
-
const
|
|
33
|
-
|
|
59
|
+
calculationStart(e) {
|
|
60
|
+
return this._commandService.onCommandExecuted((t) => {
|
|
61
|
+
if (t.id === l.id) {
|
|
62
|
+
const r = t.params;
|
|
63
|
+
e(r.forceCalculation);
|
|
34
64
|
}
|
|
35
65
|
});
|
|
36
66
|
}
|
|
37
67
|
/**
|
|
38
68
|
* Listening calculation ends.
|
|
69
|
+
* @param callback
|
|
39
70
|
*/
|
|
40
|
-
calculationEnd(
|
|
41
|
-
return this._commandService.onCommandExecuted((
|
|
42
|
-
if (
|
|
71
|
+
calculationEnd(e) {
|
|
72
|
+
return this._commandService.onCommandExecuted((t) => {
|
|
73
|
+
if (t.id !== d.id)
|
|
43
74
|
return;
|
|
44
|
-
const
|
|
45
|
-
|
|
75
|
+
const r = t.params;
|
|
76
|
+
r.functionsExecutedState !== void 0 && e(r.functionsExecutedState);
|
|
46
77
|
});
|
|
47
78
|
}
|
|
48
79
|
onCalculationEnd() {
|
|
49
|
-
return new Promise((
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
}, 3e4),
|
|
53
|
-
clearTimeout(
|
|
80
|
+
return new Promise((e, t) => {
|
|
81
|
+
const r = setTimeout(() => {
|
|
82
|
+
t(new Error("Calculation end timeout"));
|
|
83
|
+
}, 3e4), i = this.calculationEnd(() => {
|
|
84
|
+
clearTimeout(r), i.dispose(), e();
|
|
54
85
|
});
|
|
55
86
|
});
|
|
56
87
|
}
|
|
57
88
|
/**
|
|
58
89
|
* Listening calculation processing.
|
|
90
|
+
* @param callback
|
|
59
91
|
*/
|
|
60
|
-
calculationProcessing(
|
|
61
|
-
return this._commandService.onCommandExecuted((
|
|
62
|
-
if (
|
|
92
|
+
calculationProcessing(e) {
|
|
93
|
+
return this._commandService.onCommandExecuted((t) => {
|
|
94
|
+
if (t.id !== d.id)
|
|
63
95
|
return;
|
|
64
|
-
const
|
|
65
|
-
|
|
96
|
+
const r = t.params;
|
|
97
|
+
r.stageInfo !== void 0 && e(r.stageInfo);
|
|
66
98
|
});
|
|
67
99
|
}
|
|
68
100
|
/**
|
|
@@ -76,21 +108,22 @@ let s = class extends C {
|
|
|
76
108
|
* formulaEngine.setMaxIteration(5);
|
|
77
109
|
* ```
|
|
78
110
|
*/
|
|
79
|
-
setMaxIteration(
|
|
80
|
-
this._configService.setConfig(S,
|
|
111
|
+
setMaxIteration(e) {
|
|
112
|
+
this._configService.setConfig(S, e);
|
|
81
113
|
}
|
|
82
114
|
};
|
|
83
|
-
s =
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
115
|
+
s = F([
|
|
116
|
+
o(0, u(f)),
|
|
117
|
+
o(1, u(_)),
|
|
118
|
+
o(2, u(x)),
|
|
119
|
+
o(3, v)
|
|
87
120
|
], s);
|
|
88
|
-
class
|
|
121
|
+
class g extends m {
|
|
89
122
|
getFormula() {
|
|
90
123
|
return this._injector.createInstance(s);
|
|
91
124
|
}
|
|
92
125
|
}
|
|
93
|
-
|
|
126
|
+
m.extend(g);
|
|
94
127
|
export {
|
|
95
128
|
s as FFormula
|
|
96
129
|
};
|