@univerjs/sheets-formula 0.10.5 → 0.10.6-experimental.20250903-f52e3bf

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/facade.js CHANGED
@@ -1,17 +1,18 @@
1
- import { debounce as m, LifecycleService as F, ILogService as h, IConfigService as S, LifecycleStages as _ } from "@univerjs/core";
2
- import { FUniver as d, FEnum as C } from "@univerjs/core/facade";
3
- import { SetFormulaCalculationStartMutation as g } from "@univerjs/engine-formula";
4
- import { IRegisterFunctionService as i, RegisterFunctionService as l, PLUGIN_CONFIG_KEY_BASE as u, CalculationMode as v } from "@univerjs/sheets-formula";
5
- import { FFormula as f } from "@univerjs/engine-formula/facade";
6
- class y extends d {
1
+ import { debounce as y, LifecycleService as D, ILogService as R, IConfigService as U, LifecycleStages as A } from "@univerjs/core";
2
+ import { FUniver as b, FEnum as L } from "@univerjs/core/facade";
3
+ import { SetFormulaCalculationStartMutation as j, FormulaDataModel as k, extractFormulaError as I } from "@univerjs/engine-formula";
4
+ import { IRegisterFunctionService as s, RegisterFunctionService as S, PLUGIN_CONFIG_KEY_BASE as v, CalculationMode as N } from "@univerjs/sheets-formula";
5
+ import { FFormula as w } from "@univerjs/engine-formula/facade";
6
+ import { FWorkbook as M, FRange as p } from "@univerjs/sheets/facade";
7
+ class z extends b {
7
8
  /**
8
9
  * Initialize the FUniver instance.
9
10
  * @ignore
10
11
  */
11
12
  _initialize() {
12
- this._debouncedFormulaCalculation = m(() => {
13
+ this._debouncedFormulaCalculation = y(() => {
13
14
  this._commandService.executeCommand(
14
- g.id,
15
+ j.id,
15
16
  {
16
17
  commands: [],
17
18
  forceCalculation: !0
@@ -22,23 +23,23 @@ class y extends d {
22
23
  );
23
24
  }, 10);
24
25
  }
25
- registerFunction(c) {
26
- let n = this._injector.get(i);
27
- n || (this._injector.add([i, { useClass: l }]), n = this._injector.get(i));
28
- const e = n.registerFunctions(c);
26
+ registerFunction(t) {
27
+ let r = this._injector.get(s);
28
+ r || (this._injector.add([s, { useClass: S }]), r = this._injector.get(s));
29
+ const e = r.registerFunctions(t);
29
30
  return this._debouncedFormulaCalculation(), e;
30
31
  }
31
32
  }
32
- d.extend(y);
33
- class j extends f {
33
+ b.extend(z);
34
+ class B extends w {
34
35
  /**
35
36
  * Initialize the FUniver instance.
36
37
  * @ignore
37
38
  */
38
39
  _initialize() {
39
- this._debouncedFormulaCalculation = m(() => {
40
+ this._debouncedFormulaCalculation = y(() => {
40
41
  this._commandService.executeCommand(
41
- g.id,
42
+ j.id,
42
43
  {
43
44
  commands: [],
44
45
  forceCalculation: !0
@@ -49,45 +50,90 @@ class j extends f {
49
50
  );
50
51
  }, 10);
51
52
  }
52
- setInitialFormulaComputing(c) {
53
- const e = this._injector.get(F).stage, t = this._injector.get(h), r = this._injector.get(S);
54
- e > _.Starting && t.warn("[FFormula]", "CalculationMode is called after the Starting lifecycle and will take effect the next time the Univer Sheet is constructed. If you want it to take effect when the Univer Sheet is initialized this time, consider calling it before the Ready lifecycle or using configuration.");
55
- const o = r.getConfig(u);
56
- if (!o) {
57
- r.setConfig(u, { initialFormulaComputing: c });
53
+ setInitialFormulaComputing(t) {
54
+ const e = this._injector.get(D).stage, o = this._injector.get(R), n = this._injector.get(U);
55
+ e > A.Starting && o.warn("[FFormula]", "CalculationMode is called after the Starting lifecycle and will take effect the next time the Univer Sheet is constructed. If you want it to take effect when the Univer Sheet is initialized this time, consider calling it before the Ready lifecycle or using configuration.");
56
+ const i = n.getConfig(v);
57
+ if (!i) {
58
+ n.setConfig(v, { initialFormulaComputing: t });
58
59
  return;
59
60
  }
60
- o.initialFormulaComputing = c;
61
+ i.initialFormulaComputing = t;
61
62
  }
62
- registerFunction(c, n, e) {
63
- var a;
64
- let t = this._injector.get(i);
65
- t || (this._injector.add([i, { useClass: l }]), t = this._injector.get(i));
66
- const r = {
67
- name: c,
68
- func: n,
69
- description: typeof e == "string" ? e : (a = e == null ? void 0 : e.description) != null ? a : "",
63
+ registerFunction(t, r, e) {
64
+ var c;
65
+ let o = this._injector.get(s);
66
+ o || (this._injector.add([s, { useClass: S }]), o = this._injector.get(s));
67
+ const n = {
68
+ name: t,
69
+ func: r,
70
+ description: typeof e == "string" ? e : (c = e == null ? void 0 : e.description) != null ? c : "",
70
71
  locales: typeof e == "object" ? e.locales : void 0
71
- }, o = t.registerFunction(r);
72
- return this._debouncedFormulaCalculation(), o;
72
+ }, i = o.registerFunction(n);
73
+ return this._debouncedFormulaCalculation(), i;
73
74
  }
74
- registerAsyncFunction(c, n, e) {
75
- var a;
76
- let t = this._injector.get(i);
77
- t || (this._injector.add([i, { useClass: l }]), t = this._injector.get(i));
78
- const r = {
79
- name: c,
80
- func: n,
81
- description: typeof e == "string" ? e : (a = e == null ? void 0 : e.description) != null ? a : "",
75
+ registerAsyncFunction(t, r, e) {
76
+ var c;
77
+ let o = this._injector.get(s);
78
+ o || (this._injector.add([s, { useClass: S }]), o = this._injector.get(s));
79
+ const n = {
80
+ name: t,
81
+ func: r,
82
+ description: typeof e == "string" ? e : (c = e == null ? void 0 : e.description) != null ? c : "",
82
83
  locales: typeof e == "object" ? e.locales : void 0
83
- }, o = t.registerAsyncFunction(r);
84
- return this._debouncedFormulaCalculation(), o;
84
+ }, i = o.registerAsyncFunction(n);
85
+ return this._debouncedFormulaCalculation(), i;
85
86
  }
86
87
  }
87
- f.extend(j);
88
- class b {
88
+ w.extend(B);
89
+ class G {
89
90
  get CalculationMode() {
90
- return v;
91
+ return N;
91
92
  }
92
93
  }
93
- C.extend(b);
94
+ L.extend(G);
95
+ class T extends M {
96
+ getAllFormulaError() {
97
+ const t = [], r = this._workbook, e = r.getUnitId(), o = r.getSheets(), n = this._injector.get(k).getArrayFormulaCellData();
98
+ return o.forEach((i) => {
99
+ var h;
100
+ const c = i.getName(), _ = i.getSheetId(), C = i.getCellMatrix(), m = ((h = n == null ? void 0 : n[e]) == null ? void 0 : h[_]) || {};
101
+ C.forValue((F, d, u) => {
102
+ var g;
103
+ if (!u) return;
104
+ const l = (g = m == null ? void 0 : m[F]) == null ? void 0 : g[d], a = I(u, !!l);
105
+ a && t.push({
106
+ sheetName: c,
107
+ row: F,
108
+ column: d,
109
+ formula: u.f || "",
110
+ errorType: a
111
+ });
112
+ });
113
+ }), t;
114
+ }
115
+ }
116
+ M.extend(T);
117
+ class V extends p {
118
+ getFormulaError() {
119
+ var d, u;
120
+ const t = [], r = this._workbook.getUnitId(), e = this._worksheet.getSheetId(), o = this._worksheet.getName(), n = this._workbook.getSheetBySheetId(e);
121
+ if (!n) return t;
122
+ const i = this._injector.get(k).getArrayFormulaCellData(), c = ((d = i == null ? void 0 : i[r]) == null ? void 0 : d[e]) || {}, _ = n.getCellMatrix(), { startRow: C, endRow: m, startColumn: h, endColumn: F } = this._range;
123
+ for (let l = C; l <= m; l++)
124
+ for (let a = h; a <= F; a++) {
125
+ const g = _.getValue(l, a);
126
+ if (!g) continue;
127
+ const E = (u = c == null ? void 0 : c[l]) == null ? void 0 : u[a], x = I(g, !!E);
128
+ x && t.push({
129
+ sheetName: o,
130
+ row: l,
131
+ column: a,
132
+ formula: g.f || "",
133
+ errorType: x
134
+ });
135
+ }
136
+ return t;
137
+ }
138
+ }
139
+ p.extend(V);