@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/es/facade.js CHANGED
@@ -1,14 +1,19 @@
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
- let s = class extends C {
9
- constructor(e, t, r, i) {
10
- super(), this._commandService = e, this._injector = t, this._lexerTreeBuilder = r, this._configService = i, this._initialize();
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(e, t, r, i) {
32
- return this._lexerTreeBuilder.moveFormulaRefOffset(e, t, r, i);
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(e) {
41
- return this._lexerTreeBuilder.sequenceNodesBuilder(e) || [];
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(l.id, { commands: [], forceCalculation: !0 }, { onlyLocal: !0 });
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(p.id, {});
58
+ this._commandService.executeCommand(SetFormulaCalculationStopMutation.id, {});
54
59
  }
55
60
  /**
56
61
  * Listening calculation starts.
57
62
  * @param callback
58
63
  */
59
- calculationStart(e) {
60
- return this._commandService.onCommandExecuted((t) => {
61
- if (t.id === l.id) {
62
- const r = t.params;
63
- e(r.forceCalculation);
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(e) {
72
- return this._commandService.onCommandExecuted((t) => {
73
- if (t.id !== d.id)
76
+ calculationEnd(callback) {
77
+ return this._commandService.onCommandExecuted((command) => {
78
+ if (command.id !== SetFormulaCalculationNotificationMutation.id)
74
79
  return;
75
- const r = t.params;
76
- r.functionsExecutedState !== void 0 && e(r.functionsExecutedState);
80
+ const params = command.params;
81
+ params.functionsExecutedState !== void 0 && callback(params.functionsExecutedState);
77
82
  });
78
83
  }
79
84
  onCalculationEnd() {
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();
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(e) {
93
- return this._commandService.onCommandExecuted((t) => {
94
- if (t.id !== d.id)
97
+ calculationProcessing(callback) {
98
+ return this._commandService.onCommandExecuted((command) => {
99
+ if (command.id !== SetFormulaCalculationNotificationMutation.id)
95
100
  return;
96
- const r = t.params;
97
- r.stageInfo !== void 0 && e(r.stageInfo);
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(e) {
112
- this._configService.setConfig(S, e);
116
+ setMaxIteration(maxIteration) {
117
+ this._configService.setConfig(ENGINE_FORMULA_CYCLE_REFERENCE_COUNT, maxIteration);
113
118
  }
114
- };
115
- s = F([
116
- o(0, u(f)),
117
- o(1, u(_)),
118
- o(2, u(x)),
119
- o(3, v)
120
- ], s);
121
- class g extends m {
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(s);
128
+ return this._injector.createInstance(FFormula);
124
129
  }
125
- }
126
- m.extend(g);
130
+ };
131
+ __name(_FUniverEngineFormulaMixin, "FUniverEngineFormulaMixin");
132
+ let FUniverEngineFormulaMixin = _FUniverEngineFormulaMixin;
133
+ FUniver.extend(FUniverEngineFormulaMixin);
127
134
  export {
128
- s as FFormula
135
+ FFormula
129
136
  };