@univerjs/engine-formula 0.5.4 → 0.5.5-experimental.20250122-3362a4a
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 +57 -50
- package/lib/es/index.js +25073 -23679
- package/lib/types/facade/f-formula.d.ts +4 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +2 -2
- package/package.json +4 -4
- package/LICENSE +0 -176
package/lib/es/facade.js
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
3
|
+
import { Inject, ICommandService, Injector, FBase, IConfigService, FUniver } from "@univerjs/core";
|
|
4
|
+
import { LexerTreeBuilder, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation, SetFormulaCalculationNotificationMutation, ENGINE_FORMULA_CYCLE_REFERENCE_COUNT } from "@univerjs/engine-formula";
|
|
5
|
+
var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
6
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
7
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
8
|
+
return kind && result && __defProp2(target, key, result), result;
|
|
9
|
+
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), _a;
|
|
10
|
+
let FFormula = (_a = class extends FBase {
|
|
11
|
+
constructor(_commandService, _injector, _lexerTreeBuilder, _configService) {
|
|
12
|
+
super(), this._commandService = _commandService, this._injector = _injector, this._lexerTreeBuilder = _lexerTreeBuilder, this._configService = _configService, this._initialize();
|
|
11
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* @ignore
|
|
16
|
+
*/
|
|
12
17
|
_initialize() {
|
|
13
18
|
}
|
|
14
19
|
/**
|
|
@@ -28,8 +33,8 @@ let s = class extends C {
|
|
|
28
33
|
* const result = moveFormulaRefOffset('sum(a1,b2)',1,1)
|
|
29
34
|
* // result is 'sum(b2,c3)'
|
|
30
35
|
*/
|
|
31
|
-
moveFormulaRefOffset(
|
|
32
|
-
return this._lexerTreeBuilder.moveFormulaRefOffset(
|
|
36
|
+
moveFormulaRefOffset(formulaString, refOffsetX, refOffsetY, ignoreAbsolute) {
|
|
37
|
+
return this._lexerTreeBuilder.moveFormulaRefOffset(formulaString, refOffsetX, refOffsetY, ignoreAbsolute);
|
|
33
38
|
}
|
|
34
39
|
/**
|
|
35
40
|
* Resolves the formula string to a 'node' node
|
|
@@ -37,30 +42,30 @@ let s = class extends C {
|
|
|
37
42
|
* @returns {*} {((string | ISequenceNode)[])}
|
|
38
43
|
* @memberof FFormula
|
|
39
44
|
*/
|
|
40
|
-
sequenceNodesBuilder(
|
|
41
|
-
return this._lexerTreeBuilder.sequenceNodesBuilder(
|
|
45
|
+
sequenceNodesBuilder(formulaString) {
|
|
46
|
+
return this._lexerTreeBuilder.sequenceNodesBuilder(formulaString) || [];
|
|
42
47
|
}
|
|
43
48
|
/**
|
|
44
49
|
* Start the calculation of the formula.
|
|
45
50
|
*/
|
|
46
51
|
executeCalculation() {
|
|
47
|
-
this._commandService.executeCommand(
|
|
52
|
+
this._commandService.executeCommand(SetFormulaCalculationStartMutation.id, { commands: [], forceCalculation: !0 }, { onlyLocal: !0 });
|
|
48
53
|
}
|
|
49
54
|
/**
|
|
50
55
|
* Stop the calculation of the formula.
|
|
51
56
|
*/
|
|
52
57
|
stopCalculation() {
|
|
53
|
-
this._commandService.executeCommand(
|
|
58
|
+
this._commandService.executeCommand(SetFormulaCalculationStopMutation.id, {});
|
|
54
59
|
}
|
|
55
60
|
/**
|
|
56
61
|
* Listening calculation starts.
|
|
57
62
|
* @param callback
|
|
58
63
|
*/
|
|
59
|
-
calculationStart(
|
|
60
|
-
return this._commandService.onCommandExecuted((
|
|
61
|
-
if (
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
+
calculationStart(callback) {
|
|
65
|
+
return this._commandService.onCommandExecuted((command) => {
|
|
66
|
+
if (command.id === SetFormulaCalculationStartMutation.id) {
|
|
67
|
+
const params = command.params;
|
|
68
|
+
callback(params.forceCalculation);
|
|
64
69
|
}
|
|
65
70
|
});
|
|
66
71
|
}
|
|
@@ -68,20 +73,20 @@ let s = class extends C {
|
|
|
68
73
|
* Listening calculation ends.
|
|
69
74
|
* @param callback
|
|
70
75
|
*/
|
|
71
|
-
calculationEnd(
|
|
72
|
-
return this._commandService.onCommandExecuted((
|
|
73
|
-
if (
|
|
76
|
+
calculationEnd(callback) {
|
|
77
|
+
return this._commandService.onCommandExecuted((command) => {
|
|
78
|
+
if (command.id !== SetFormulaCalculationNotificationMutation.id)
|
|
74
79
|
return;
|
|
75
|
-
const
|
|
76
|
-
|
|
80
|
+
const params = command.params;
|
|
81
|
+
params.functionsExecutedState !== void 0 && callback(params.functionsExecutedState);
|
|
77
82
|
});
|
|
78
83
|
}
|
|
79
84
|
onCalculationEnd() {
|
|
80
|
-
return new Promise((
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
}, 3e4),
|
|
84
|
-
clearTimeout(
|
|
85
|
+
return new Promise((resolve, reject) => {
|
|
86
|
+
const timer = setTimeout(() => {
|
|
87
|
+
reject(new Error("Calculation end timeout"));
|
|
88
|
+
}, 3e4), disposable = this.calculationEnd(() => {
|
|
89
|
+
clearTimeout(timer), disposable.dispose(), resolve();
|
|
85
90
|
});
|
|
86
91
|
});
|
|
87
92
|
}
|
|
@@ -89,12 +94,12 @@ let s = class extends C {
|
|
|
89
94
|
* Listening calculation processing.
|
|
90
95
|
* @param callback
|
|
91
96
|
*/
|
|
92
|
-
calculationProcessing(
|
|
93
|
-
return this._commandService.onCommandExecuted((
|
|
94
|
-
if (
|
|
97
|
+
calculationProcessing(callback) {
|
|
98
|
+
return this._commandService.onCommandExecuted((command) => {
|
|
99
|
+
if (command.id !== SetFormulaCalculationNotificationMutation.id)
|
|
95
100
|
return;
|
|
96
|
-
const
|
|
97
|
-
|
|
101
|
+
const params = command.params;
|
|
102
|
+
params.stageInfo !== void 0 && callback(params.stageInfo);
|
|
98
103
|
});
|
|
99
104
|
}
|
|
100
105
|
/**
|
|
@@ -108,22 +113,24 @@ let s = class extends C {
|
|
|
108
113
|
* formulaEngine.setMaxIteration(5);
|
|
109
114
|
* ```
|
|
110
115
|
*/
|
|
111
|
-
setMaxIteration(
|
|
112
|
-
this._configService.setConfig(
|
|
116
|
+
setMaxIteration(maxIteration) {
|
|
117
|
+
this._configService.setConfig(ENGINE_FORMULA_CYCLE_REFERENCE_COUNT, maxIteration);
|
|
113
118
|
}
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
],
|
|
121
|
-
class
|
|
119
|
+
}, __name(_a, "FFormula"), _a);
|
|
120
|
+
FFormula = __decorateClass([
|
|
121
|
+
__decorateParam(0, Inject(ICommandService)),
|
|
122
|
+
__decorateParam(1, Inject(Injector)),
|
|
123
|
+
__decorateParam(2, Inject(LexerTreeBuilder)),
|
|
124
|
+
__decorateParam(3, IConfigService)
|
|
125
|
+
], FFormula);
|
|
126
|
+
const _FUniverEngineFormulaMixin = class _FUniverEngineFormulaMixin extends FUniver {
|
|
122
127
|
getFormula() {
|
|
123
|
-
return this._injector.createInstance(
|
|
128
|
+
return this._injector.createInstance(FFormula);
|
|
124
129
|
}
|
|
125
|
-
}
|
|
126
|
-
|
|
130
|
+
};
|
|
131
|
+
__name(_FUniverEngineFormulaMixin, "FUniverEngineFormulaMixin");
|
|
132
|
+
let FUniverEngineFormulaMixin = _FUniverEngineFormulaMixin;
|
|
133
|
+
FUniver.extend(FUniverEngineFormulaMixin);
|
|
127
134
|
export {
|
|
128
|
-
|
|
135
|
+
FFormula
|
|
129
136
|
};
|