@univerjs/sheets-formula 0.10.6 → 0.10.7

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,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);
package/lib/es/index.js CHANGED
@@ -15599,8 +15599,8 @@ let Mt = class {
15599
15599
  getSearchListByNameFirstLetter(a) {
15600
15600
  const e = [], n = this._functionService.getDescriptions(), i = a.toLocaleUpperCase().trim();
15601
15601
  return n.forEach((r) => {
15602
- const { functionName: o, abstract: u } = r;
15603
- o.toLocaleUpperCase().indexOf(i) === 0 && e.push({ name: o, desc: u });
15602
+ const { functionName: o, abstract: u, functionType: f } = r;
15603
+ o.toLocaleUpperCase().indexOf(i) === 0 && e.push({ name: o, desc: u, functionType: f });
15604
15604
  }), e;
15605
15605
  }
15606
15606
  getSearchListByType(a) {
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);
package/lib/index.js CHANGED
@@ -15599,8 +15599,8 @@ let Mt = class {
15599
15599
  getSearchListByNameFirstLetter(a) {
15600
15600
  const e = [], n = this._functionService.getDescriptions(), i = a.toLocaleUpperCase().trim();
15601
15601
  return n.forEach((r) => {
15602
- const { functionName: o, abstract: u } = r;
15603
- o.toLocaleUpperCase().indexOf(i) === 0 && e.push({ name: o, desc: u });
15602
+ const { functionName: o, abstract: u, functionType: f } = r;
15603
+ o.toLocaleUpperCase().indexOf(i) === 0 && e.push({ name: o, desc: u, functionType: f });
15604
15604
  }), e;
15605
15605
  }
15606
15606
  getSearchListByType(a) {
@@ -0,0 +1,30 @@
1
+ import { ISheetFormulaError } from '@univerjs/engine-formula';
2
+ import { FRange } from '@univerjs/sheets/facade';
3
+ /**
4
+ * @ignore
5
+ */
6
+ export interface IFRangeEngineFormulaMixin {
7
+ /**
8
+ * Get formula errors in the current range
9
+ * @returns {ISheetFormulaError[]} Array of formula errors in the range
10
+ * @example
11
+ * ```typescript
12
+ * const range = univerAPI.getActiveWorkbook()
13
+ * .getActiveSheet()
14
+ * .getRange('A1:B10');
15
+ * const errors = range.getFormulaError();
16
+ * console.log('Formula errors in range:', errors);
17
+ * ```
18
+ */
19
+ getFormulaError(): ISheetFormulaError[];
20
+ }
21
+ /**
22
+ * @ignore
23
+ */
24
+ export declare class FRangeEngineFormulaMixin extends FRange implements IFRangeEngineFormulaMixin {
25
+ getFormulaError(): ISheetFormulaError[];
26
+ }
27
+ declare module '@univerjs/sheets/facade' {
28
+ interface FRange extends IFRangeEngineFormulaMixin {
29
+ }
30
+ }
@@ -0,0 +1,25 @@
1
+ import { ISheetFormulaError } from '@univerjs/engine-formula';
2
+ import { FWorkbook } from '@univerjs/sheets/facade';
3
+ /**
4
+ * @ignore
5
+ */
6
+ export interface IFWorkbookEngineFormulaMixin {
7
+ /**
8
+ * Get all formula errors in the workbook
9
+ * @returns {ISheetFormulaError[]} Array of formula errors
10
+ * @example
11
+ * ```typescript
12
+ * const fWorkbook = univerAPI.getActiveWorkbook();
13
+ * const errors = fWorkbook.getAllFormulaError();
14
+ * console.log('Formula errors:', errors);
15
+ * ```
16
+ */
17
+ getAllFormulaError(): ISheetFormulaError[];
18
+ }
19
+ export declare class FWorkbookEngineFormulaMixin extends FWorkbook implements IFWorkbookEngineFormulaMixin {
20
+ getAllFormulaError(): ISheetFormulaError[];
21
+ }
22
+ declare module '@univerjs/sheets/facade' {
23
+ interface FWorkbook extends IFWorkbookEngineFormulaMixin {
24
+ }
25
+ }
@@ -16,5 +16,7 @@
16
16
  import './f-univer';
17
17
  import './f-formula';
18
18
  import './f-enum';
19
+ import './f-workbook';
20
+ import './f-range';
19
21
  export type * from './f-formula';
20
22
  export type * from './f-univer';
@@ -22,7 +22,8 @@ export { TriggerCalculationController } from './controllers/trigger-calculation.
22
22
  export { UpdateDefinedNameController } from './controllers/update-defined-name.controller';
23
23
  export { UpdateFormulaController } from './controllers/update-formula.controller';
24
24
  export { UniverRemoteSheetsFormulaPlugin, UniverSheetsFormulaPlugin } from './plugin';
25
- export { DescriptionService, IDescriptionService, type ISearchItem } from './services/description.service';
25
+ export { DescriptionService, IDescriptionService } from './services/description.service';
26
+ export type { ISearchItem, ISearchItemWithType } from './services/description.service';
26
27
  export type { IFormulaInfo, IOtherFormulaResult } from './services/formula-common';
27
28
  export { FormulaRefRangeService } from './services/formula-ref-range.service';
28
29
  export type { IRegisterAsyncFunction, IRegisterFunction, ISingleFunctionRegisterParams } from './services/register-function.service';
@@ -1,9 +1,12 @@
1
1
  import { IDisposable, IConfigService, LocaleService } from '@univerjs/core';
2
- import { IFunctionInfo, IFunctionNames, IFunctionService } from '@univerjs/engine-formula';
2
+ import { IFunctionInfo, IFunctionNames, FunctionType, IFunctionService } from '@univerjs/engine-formula';
3
3
  export interface ISearchItem {
4
4
  name: string;
5
5
  desc: string;
6
6
  }
7
+ export interface ISearchItemWithType extends ISearchItem {
8
+ functionType: FunctionType;
9
+ }
7
10
  export interface IDescriptionService {
8
11
  /**
9
12
  * get all descriptions
@@ -26,7 +29,7 @@ export interface IDescriptionService {
26
29
  * @param searchText
27
30
  * @returns
28
31
  */
29
- getSearchListByNameFirstLetter(searchText: string): ISearchItem[];
32
+ getSearchListByNameFirstLetter(searchText: string): ISearchItemWithType[];
30
33
  /**
31
34
  * get search list by type, if type is -1, return all
32
35
  * @param type
@@ -71,7 +74,7 @@ export declare class DescriptionService implements IDescriptionService, IDisposa
71
74
  hasFunction(searchText: string): boolean;
72
75
  getFunctionInfo(searchText: string): IFunctionInfo | undefined;
73
76
  getSearchListByName(searchText: string): ISearchItem[];
74
- getSearchListByNameFirstLetter(searchText: string): ISearchItem[];
77
+ getSearchListByNameFirstLetter(searchText: string): ISearchItemWithType[];
75
78
  getSearchListByType(type: number): ISearchItem[];
76
79
  registerDescriptions(description: IFunctionInfo[]): IDisposable;
77
80
  unregisterDescriptions(functionNames: string[]): void;
package/lib/umd/facade.js CHANGED
@@ -1 +1 @@
1
- (function(t,o){typeof exports=="object"&&typeof module<"u"?o(require("@univerjs/core"),require("@univerjs/core/facade"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula"),require("@univerjs/engine-formula/facade")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/core/facade","@univerjs/engine-formula","@univerjs/sheets-formula","@univerjs/engine-formula/facade"],o):(t=typeof globalThis<"u"?globalThis:t||self,o(t.UniverCore,t.UniverCoreFacade,t.UniverEngineFormula,t.UniverSheetsFormula,t.UniverEngineFormulaFacade))})(this,(function(t,o,l,i,d){"use strict";class f extends o.FUniver{_initialize(){this._debouncedFormulaCalculation=t.debounce(()=>{this._commandService.executeCommand(l.SetFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})},10)}registerFunction(r){let c=this._injector.get(i.IRegisterFunctionService);c||(this._injector.add([i.IRegisterFunctionService,{useClass:i.RegisterFunctionService}]),c=this._injector.get(i.IRegisterFunctionService));const e=c.registerFunctions(r);return this._debouncedFormulaCalculation(),e}}o.FUniver.extend(f);class v extends d.FFormula{_initialize(){this._debouncedFormulaCalculation=t.debounce(()=>{this._commandService.executeCommand(l.SetFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})},10)}setInitialFormulaComputing(r){const e=this._injector.get(t.LifecycleService).stage,n=this._injector.get(t.ILogService),u=this._injector.get(t.IConfigService);e>t.LifecycleStages.Starting&&n.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.");const a=u.getConfig(i.PLUGIN_CONFIG_KEY_BASE);if(!a){u.setConfig(i.PLUGIN_CONFIG_KEY_BASE,{initialFormulaComputing:r});return}a.initialFormulaComputing=r}registerFunction(r,c,e){var s;let n=this._injector.get(i.IRegisterFunctionService);n||(this._injector.add([i.IRegisterFunctionService,{useClass:i.RegisterFunctionService}]),n=this._injector.get(i.IRegisterFunctionService));const u={name:r,func:c,description:typeof e=="string"?e:(s=e==null?void 0:e.description)!=null?s:"",locales:typeof e=="object"?e.locales:void 0},a=n.registerFunction(u);return this._debouncedFormulaCalculation(),a}registerAsyncFunction(r,c,e){var s;let n=this._injector.get(i.IRegisterFunctionService);n||(this._injector.add([i.IRegisterFunctionService,{useClass:i.RegisterFunctionService}]),n=this._injector.get(i.IRegisterFunctionService));const u={name:r,func:c,description:typeof e=="string"?e:(s=e==null?void 0:e.description)!=null?s:"",locales:typeof e=="object"?e.locales:void 0},a=n.registerAsyncFunction(u);return this._debouncedFormulaCalculation(),a}}d.FFormula.extend(v);class S{get CalculationMode(){return i.CalculationMode}}o.FEnum.extend(S)}));
1
+ (function(t,l){typeof exports=="object"&&typeof module<"u"?l(require("@univerjs/core"),require("@univerjs/core/facade"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula"),require("@univerjs/engine-formula/facade"),require("@univerjs/sheets/facade")):typeof define=="function"&&define.amd?define(["@univerjs/core","@univerjs/core/facade","@univerjs/engine-formula","@univerjs/sheets-formula","@univerjs/engine-formula/facade","@univerjs/sheets/facade"],l):(t=typeof globalThis<"u"?globalThis:t||self,l(t.UniverCore,t.UniverCoreFacade,t.UniverEngineFormula,t.UniverSheetsFormula,t.UniverEngineFormulaFacade,t.UniverSheetsFacade))})(this,(function(t,l,g,i,x,m){"use strict";class k extends l.FUniver{_initialize(){this._debouncedFormulaCalculation=t.debounce(()=>{this._commandService.executeCommand(g.SetFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})},10)}registerFunction(n){let c=this._injector.get(i.IRegisterFunctionService);c||(this._injector.add([i.IRegisterFunctionService,{useClass:i.RegisterFunctionService}]),c=this._injector.get(i.IRegisterFunctionService));const e=c.registerFunctions(n);return this._debouncedFormulaCalculation(),e}}l.FUniver.extend(k);class R extends x.FFormula{_initialize(){this._debouncedFormulaCalculation=t.debounce(()=>{this._commandService.executeCommand(g.SetFormulaCalculationStartMutation.id,{commands:[],forceCalculation:!0},{onlyLocal:!0})},10)}setInitialFormulaComputing(n){const e=this._injector.get(t.LifecycleService).stage,o=this._injector.get(t.ILogService),s=this._injector.get(t.IConfigService);e>t.LifecycleStages.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.");const r=s.getConfig(i.PLUGIN_CONFIG_KEY_BASE);if(!r){s.setConfig(i.PLUGIN_CONFIG_KEY_BASE,{initialFormulaComputing:n});return}r.initialFormulaComputing=n}registerFunction(n,c,e){var a;let o=this._injector.get(i.IRegisterFunctionService);o||(this._injector.add([i.IRegisterFunctionService,{useClass:i.RegisterFunctionService}]),o=this._injector.get(i.IRegisterFunctionService));const s={name:n,func:c,description:typeof e=="string"?e:(a=e==null?void 0:e.description)!=null?a:"",locales:typeof e=="object"?e.locales:void 0},r=o.registerFunction(s);return this._debouncedFormulaCalculation(),r}registerAsyncFunction(n,c,e){var a;let o=this._injector.get(i.IRegisterFunctionService);o||(this._injector.add([i.IRegisterFunctionService,{useClass:i.RegisterFunctionService}]),o=this._injector.get(i.IRegisterFunctionService));const s={name:n,func:c,description:typeof e=="string"?e:(a=e==null?void 0:e.description)!=null?a:"",locales:typeof e=="object"?e.locales:void 0},r=o.registerAsyncFunction(s);return this._debouncedFormulaCalculation(),r}}x.FFormula.extend(R);class b{get CalculationMode(){return i.CalculationMode}}l.FEnum.extend(b);class E extends m.FWorkbook{getAllFormulaError(){const n=[],c=this._workbook,e=c.getUnitId(),o=c.getSheets(),s=this._injector.get(g.FormulaDataModel).getArrayFormulaCellData();return o.forEach(r=>{var C;const a=r.getName(),j=r.getSheetId(),I=r.getCellMatrix(),F=((C=s==null?void 0:s[e])==null?void 0:C[j])||{};I.forValue((_,h,f)=>{var v;if(!f)return;const d=(v=F==null?void 0:F[_])==null?void 0:v[h],u=g.extractFormulaError(f,!!d);u&&n.push({sheetName:a,row:_,column:h,formula:f.f||"",errorType:u})})}),n}}m.FWorkbook.extend(E);class U extends m.FRange{getFormulaError(){var h,f;const n=[],c=this._workbook.getUnitId(),e=this._worksheet.getSheetId(),o=this._worksheet.getName(),s=this._workbook.getSheetBySheetId(e);if(!s)return n;const r=this._injector.get(g.FormulaDataModel).getArrayFormulaCellData(),a=((h=r==null?void 0:r[c])==null?void 0:h[e])||{},j=s.getCellMatrix(),{startRow:I,endRow:F,startColumn:C,endColumn:_}=this._range;for(let d=I;d<=F;d++)for(let u=C;u<=_;u++){const v=j.getValue(d,u);if(!v)continue;const M=(f=a==null?void 0:a[d])==null?void 0:f[u],y=g.extractFormulaError(v,!!M);y&&n.push({sheetName:o,row:d,column:u,formula:v.f||"",errorType:y})}return n}}m.FRange.extend(U)}));