@univerjs/engine-formula 0.25.0-insiders.20260623-012b5a8 → 0.25.1

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/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
package/lib/cjs/facade.js CHANGED
@@ -4,7 +4,7 @@ let _univerjs_core = require("@univerjs/core");
4
4
  let _univerjs_engine_formula = require("@univerjs/engine-formula");
5
5
  let rxjs = require("rxjs");
6
6
 
7
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
7
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
8
8
  function __decorateParam(paramIndex, decorator) {
9
9
  return function(target, key) {
10
10
  decorator(target, key, paramIndex);
@@ -12,7 +12,7 @@ function __decorateParam(paramIndex, decorator) {
12
12
  }
13
13
 
14
14
  //#endregion
15
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
15
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
16
16
  function __decorate(decorators, target, key, desc) {
17
17
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
18
18
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
package/lib/cjs/index.js CHANGED
@@ -42,7 +42,7 @@ let BooleanValue = /* @__PURE__ */ function(BooleanValue) {
42
42
  }({});
43
43
 
44
44
  //#endregion
45
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/typeof.js
45
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
46
46
  function _typeof(o) {
47
47
  "@babel/helpers - typeof";
48
48
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -53,7 +53,7 @@ function _typeof(o) {
53
53
  }
54
54
 
55
55
  //#endregion
56
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPrimitive.js
56
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
57
57
  function toPrimitive(t, r) {
58
58
  if ("object" != _typeof(t) || !t) return t;
59
59
  var e = t[Symbol.toPrimitive];
@@ -66,14 +66,14 @@ function toPrimitive(t, r) {
66
66
  }
67
67
 
68
68
  //#endregion
69
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/toPropertyKey.js
69
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
70
70
  function toPropertyKey(t) {
71
71
  var i = toPrimitive(t, "string");
72
72
  return "symbol" == _typeof(i) ? i : i + "";
73
73
  }
74
74
 
75
75
  //#endregion
76
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/defineProperty.js
76
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
77
77
  function _defineProperty(e, r, t) {
78
78
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
79
79
  value: t,
@@ -268,7 +268,7 @@ let compareToken = /* @__PURE__ */ function(compareToken) {
268
268
  compareToken["LESS_THAN_OR_EQUAL"] = "<=";
269
269
  return compareToken;
270
270
  }({});
271
- const OPERATOR_TOKEN_PRIORITY = /* @__PURE__ */ new Map([
271
+ const OPERATOR_TOKEN_PRIORITY = new Map([
272
272
  ["<>", 4],
273
273
  ["<", 4],
274
274
  [">=", 4],
@@ -283,7 +283,7 @@ const OPERATOR_TOKEN_PRIORITY = /* @__PURE__ */ new Map([
283
283
  ["^", 0]
284
284
  ]);
285
285
  const OPERATOR_TOKEN_SET = new Set(OPERATOR_TOKEN_PRIORITY.keys());
286
- const OPERATOR_TOKEN_COMPARE_SET = /* @__PURE__ */ new Set([
286
+ const OPERATOR_TOKEN_COMPARE_SET = new Set([
287
287
  "=",
288
288
  "<>",
289
289
  ">",
@@ -309,7 +309,7 @@ let suffixToken = /* @__PURE__ */ function(suffixToken) {
309
309
  suffixToken["POUND"] = "#";
310
310
  return suffixToken;
311
311
  }({});
312
- const SUFFIX_TOKEN_SET = /* @__PURE__ */ new Set(["%", "#"]);
312
+ const SUFFIX_TOKEN_SET = new Set(["%", "#"]);
313
313
  let prefixToken = /* @__PURE__ */ function(prefixToken) {
314
314
  prefixToken["AT"] = "@";
315
315
  prefixToken["MINUS"] = "-";
@@ -1349,7 +1349,7 @@ function normalizeSheetName(sheetName) {
1349
1349
  function matchRefDrawToken(char) {
1350
1350
  return isFormulaLexerToken(char) && char !== "}" && char !== ")" && char !== "'" && char !== "\"" || char === " ";
1351
1351
  }
1352
- const TOKEN_CANNOT_BE_AT_END_SET = /* @__PURE__ */ new Set([
1352
+ const TOKEN_CANNOT_BE_AT_END_SET = new Set([
1353
1353
  "+",
1354
1354
  "-",
1355
1355
  "*",
@@ -1371,7 +1371,7 @@ const TOKEN_CANNOT_BE_AT_END_SET = /* @__PURE__ */ new Set([
1371
1371
  function isTokenCannotBeAtEnd(token) {
1372
1372
  return TOKEN_CANNOT_BE_AT_END_SET.has(token);
1373
1373
  }
1374
- const TOKEN_CANNOT_PRECEDE_SUFFIX_TOKEN_SET = /* @__PURE__ */ new Set([
1374
+ const TOKEN_CANNOT_PRECEDE_SUFFIX_TOKEN_SET = new Set([
1375
1375
  "+",
1376
1376
  "-",
1377
1377
  "*",
@@ -1542,7 +1542,7 @@ const DEFAULT_TOKEN_TYPE_LAMBDA_OMIT_PARAMETER = "LO_1";
1542
1542
  const DEFAULT_TOKEN_LET_FUNCTION_NAME = "LET";
1543
1543
  const DEFAULT_TOKEN_LAMBDA_FUNCTION_NAME = "LAMBDA";
1544
1544
  const DEFAULT_TOKEN_CUBE_FUNCTION_NAME = "CUBE";
1545
- const FORCED_RECALCULATION_FUNCTION_NAME = /* @__PURE__ */ new Set([
1545
+ const FORCED_RECALCULATION_FUNCTION_NAME = new Set([
1546
1546
  "RAND",
1547
1547
  "RANDBETWEEN",
1548
1548
  "NOW",
@@ -1877,7 +1877,7 @@ function splitTableStructuredRef(ref) {
1877
1877
  }
1878
1878
 
1879
1879
  //#endregion
1880
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
1880
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
1881
1881
  function __decorateParam(paramIndex, decorator) {
1882
1882
  return function(target, key) {
1883
1883
  decorator(target, key, paramIndex);
@@ -1885,7 +1885,7 @@ function __decorateParam(paramIndex, decorator) {
1885
1885
  }
1886
1886
 
1887
1887
  //#endregion
1888
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
1888
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
1889
1889
  function __decorate(decorators, target, key, desc) {
1890
1890
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1891
1891
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -3029,7 +3029,7 @@ let FUNCTION_NAMES_WEB = /* @__PURE__ */ function(FUNCTION_NAMES_WEB) {
3029
3029
 
3030
3030
  //#endregion
3031
3031
  //#region src/functions/new-excel-functions.ts
3032
- const NEW_EXCEL_FUNCTIONS = /* @__PURE__ */ new Set([
3032
+ const NEW_EXCEL_FUNCTIONS = new Set([
3033
3033
  "ACOT",
3034
3034
  "ACOTH",
3035
3035
  "ARABIC",
@@ -4939,54 +4939,15 @@ let FormulaDataModel = class FormulaDataModel extends _univerjs_core.Disposable
4939
4939
  getFormulaData() {
4940
4940
  const formulaData = {};
4941
4941
  const allSheets = this._univerInstanceService.getAllUnitsForType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
4942
- for (let i = 0; i < allSheets.length; i++) {
4943
- const workbook = allSheets[i];
4942
+ if (allSheets.length === 0) return formulaData;
4943
+ allSheets.forEach((workbook) => {
4944
4944
  const unitId = workbook.getUnitId();
4945
4945
  formulaData[unitId] = {};
4946
- const worksheets = workbook.getSheets();
4947
- for (let j = 0; j < worksheets.length; j++) {
4948
- const worksheet = worksheets[j];
4946
+ workbook.getSheets().forEach((worksheet) => {
4949
4947
  const cellMatrix = worksheet.getCellMatrix();
4950
4948
  initSheetFormulaData(formulaData, unitId, worksheet.getSheetId(), cellMatrix);
4951
- }
4952
- }
4953
- const allBases = this._univerInstanceService.getAllUnitsForType(_univerjs_core.UniverInstanceType.UNIVER_BASE);
4954
- for (let i = 0; i < allBases.length; i++) {
4955
- const base = allBases[i];
4956
- const snapshot = base.getSnapshot();
4957
- const unitId = base.getUnitId();
4958
- formulaData[unitId] = {};
4959
- const tables = Object.values(snapshot.tables);
4960
- for (let j = 0; j < tables.length; j++) {
4961
- const table = tables[j];
4962
- if (table.deleted) continue;
4963
- const tableFormulaData = {};
4964
- const recordOrder = table.recordOrder;
4965
- if (!recordOrder) {
4966
- formulaData[unitId][table.id] = tableFormulaData;
4967
- continue;
4968
- }
4969
- for (let row = 0; row < recordOrder.length; row++) {
4970
- const recordId = recordOrder[row];
4971
- const record = table.records[recordId];
4972
- if (!record || record.deleted) continue;
4973
- for (let col = 0; col < table.fieldOrder.length; col++) {
4974
- var _field$config$formula, _field$config, _row, _tableFormulaData$_ro;
4975
- const fieldId = table.fieldOrder[col];
4976
- const field = table.fields[fieldId];
4977
- if (!field || field.deleted || field.type !== "formula") continue;
4978
- const formula = String((_field$config$formula = (_field$config = field.config) === null || _field$config === void 0 ? void 0 : _field$config.formula) !== null && _field$config$formula !== void 0 ? _field$config$formula : "").trim();
4979
- if (!formula) continue;
4980
- (_tableFormulaData$_ro = tableFormulaData[_row = row]) !== null && _tableFormulaData$_ro !== void 0 || (tableFormulaData[_row] = {});
4981
- tableFormulaData[row][col] = {
4982
- f: normalizeBaseFormulaForEngine(formula, table, snapshot),
4983
- si: field.id
4984
- };
4985
- }
4986
- }
4987
- formulaData[unitId][table.id] = tableFormulaData;
4988
- }
4989
- }
4949
+ });
4950
+ });
4990
4951
  return formulaData;
4991
4952
  }
4992
4953
  getSheetFormulaData(unitId, sheetId) {
@@ -5090,33 +5051,6 @@ let FormulaDataModel = class FormulaDataModel extends _univerjs_core.Disposable
5090
5051
  unitStylesData[unitId] = workbook.getStyles();
5091
5052
  unitSheetNameMap[unitId] = sheetNameMap;
5092
5053
  }
5093
- const unitAllBases = this._univerInstanceService.getAllUnitsForType(_univerjs_core.UniverInstanceType.UNIVER_BASE);
5094
- for (const base of unitAllBases) {
5095
- const snapshot = base.getSnapshot();
5096
- const unitId = base.getUnitId();
5097
- const baseData = {};
5098
- const tableNameMap = {};
5099
- for (const table of Object.values(snapshot.tables).filter((item) => !item.deleted)) {
5100
- var _table$recordOrder$fi, _table$recordOrder;
5101
- baseData[table.id] = {
5102
- cellData: new _univerjs_core.ObjectMatrix(buildBaseRuntimeCellData(table)),
5103
- rowCount: (_table$recordOrder$fi = (_table$recordOrder = table.recordOrder) === null || _table$recordOrder === void 0 ? void 0 : _table$recordOrder.filter((recordId) => {
5104
- var _table$records$record;
5105
- return !((_table$records$record = table.records[recordId]) === null || _table$records$record === void 0 ? void 0 : _table$records$record.deleted);
5106
- }).length) !== null && _table$recordOrder$fi !== void 0 ? _table$recordOrder$fi : 0,
5107
- columnCount: table.fieldOrder.filter((fieldId) => {
5108
- var _table$fields$fieldId;
5109
- return !((_table$fields$fieldId = table.fields[fieldId]) === null || _table$fields$fieldId === void 0 ? void 0 : _table$fields$fieldId.deleted);
5110
- }).length,
5111
- rowData: {},
5112
- columnData: {}
5113
- };
5114
- tableNameMap[table.name] = table.id;
5115
- }
5116
- allUnitData[unitId] = baseData;
5117
- unitStylesData[unitId] = new _univerjs_core.Styles();
5118
- unitSheetNameMap[unitId] = tableNameMap;
5119
- }
5120
5054
  return {
5121
5055
  allUnitData,
5122
5056
  unitStylesData,
@@ -5405,131 +5339,6 @@ function initSheetFormulaData(formulaData, unitId, sheetId, cellMatrix) {
5405
5339
  const newSheetFormulaData = sheetFormulaDataMatrix.getMatrix();
5406
5340
  return { [unitId]: { [sheetId]: newSheetFormulaData } };
5407
5341
  }
5408
- const BASE_LEGACY_FIELD_REF_PATTERN = /\{([^}]+)\}/g;
5409
- const BASE_TABLE_FIELD_REF_PATTERN = /\b([A-Z_]\w*)\[([^\]]+)\]/gi;
5410
- const BASE_BRACKET_FIELD_REF_PATTERN = /(^|[^A-Za-z0-9_\]\[])\[([^\]]+)\]/g;
5411
- function normalizeBaseFormulaForEngine(formula, currentTable, snapshot) {
5412
- const refs = [];
5413
- const hold = (ref) => {
5414
- return `__BASE_FORMULA_REF_${refs.push(ref) - 1}__`;
5415
- };
5416
- return formula.replace(BASE_LEGACY_FIELD_REF_PATTERN, (_match, fieldName) => hold(createEngineThisRowRef(currentTable, fieldName, snapshot))).replace(BASE_TABLE_FIELD_REF_PATTERN, (_match, sourceTableName, fieldName) => {
5417
- const targetTable = resolveBaseFormulaTable(sourceTableName, currentTable, snapshot);
5418
- return targetTable ? hold(createEngineThisRowRef(targetTable, fieldName, snapshot)) : `${sourceTableName}[${fieldName}]`;
5419
- }).replace(BASE_BRACKET_FIELD_REF_PATTERN, (_match, prefix, fieldName) => `${prefix}${hold(createEngineThisRowRef(currentTable, fieldName, snapshot))}`).replace(/__BASE_FORMULA_REF_(\d+)__/g, (_match, index) => {
5420
- var _refs$Number;
5421
- return (_refs$Number = refs[Number(index)]) !== null && _refs$Number !== void 0 ? _refs$Number : "";
5422
- });
5423
- }
5424
- function createEngineThisRowRef(table, fieldName, snapshot) {
5425
- return `${getEngineBaseTableName(table, snapshot)}[[#This Row],[${fieldName}]]`;
5426
- }
5427
- function getEngineBaseTableName(table, snapshot) {
5428
- const tables = Object.values(snapshot.tables);
5429
- let sameNameCount = 0;
5430
- for (let i = 0; i < tables.length; i++) {
5431
- const item = tables[i];
5432
- if (!item.deleted && item.name === table.name) {
5433
- sameNameCount++;
5434
- if (sameNameCount > 1) break;
5435
- }
5436
- }
5437
- return sameNameCount === 1 ? table.name : table.id;
5438
- }
5439
- function buildBaseRuntimeCellData(table) {
5440
- const cellData = { ...table.cellData };
5441
- const fieldOrder = [];
5442
- for (let i = 0; i < table.fieldOrder.length; i++) {
5443
- const fieldId = table.fieldOrder[i];
5444
- if (table.fields[fieldId] && !table.fields[fieldId].deleted) fieldOrder.push(fieldId);
5445
- }
5446
- let recordOrder;
5447
- if (table.recordOrder) {
5448
- recordOrder = [];
5449
- for (let i = 0; i < table.recordOrder.length; i++) {
5450
- const recordId = table.recordOrder[i];
5451
- if (table.records[recordId] && !table.records[recordId].deleted) recordOrder.push(recordId);
5452
- }
5453
- } else {
5454
- var _table$records;
5455
- const allRecords = Object.values((_table$records = table.records) !== null && _table$records !== void 0 ? _table$records : {});
5456
- const records = [];
5457
- for (let i = 0; i < allRecords.length; i++) {
5458
- const record = allRecords[i];
5459
- if (!record.deleted) records.push(record);
5460
- }
5461
- records.sort((a, b) => a.orderKey.localeCompare(b.orderKey));
5462
- recordOrder = [];
5463
- for (let i = 0; i < records.length; i++) {
5464
- const record = records[i];
5465
- recordOrder.push(record.id);
5466
- }
5467
- }
5468
- for (let row = 0; row < recordOrder.length; row++) {
5469
- const recordId = recordOrder[row];
5470
- const record = table.records[recordId];
5471
- if (!record || record.deleted) continue;
5472
- cellData[row] = { ...cellData[row] };
5473
- for (let col = 0; col < fieldOrder.length; col++) {
5474
- var _record$values;
5475
- const fieldId = fieldOrder[col];
5476
- if (!Object.prototype.hasOwnProperty.call((_record$values = record.values) !== null && _record$values !== void 0 ? _record$values : {}, fieldId)) continue;
5477
- cellData[row][col] = toBaseRuntimeCellData(record.values[fieldId], table.fields[fieldId]);
5478
- }
5479
- }
5480
- return cellData;
5481
- }
5482
- function toBaseRuntimeCellData(value, field) {
5483
- if (isBaseCellData(value)) return normalizeBaseCellData(value);
5484
- if ((field === null || field === void 0 ? void 0 : field.type) === "attachment") return {
5485
- v: "",
5486
- t: _univerjs_core.CellValueType.STRING
5487
- };
5488
- if (Array.isArray(value)) return {
5489
- v: value.join(", "),
5490
- t: _univerjs_core.CellValueType.STRING
5491
- };
5492
- if ((field === null || field === void 0 ? void 0 : field.type) === "link" && value && typeof value === "object") {
5493
- var _ref, _link$text;
5494
- const link = value;
5495
- return {
5496
- v: String((_ref = (_link$text = link.text) !== null && _link$text !== void 0 ? _link$text : link.url) !== null && _ref !== void 0 ? _ref : ""),
5497
- t: _univerjs_core.CellValueType.STRING
5498
- };
5499
- }
5500
- if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") return {
5501
- v: value,
5502
- t: inferBaseRuntimeCellType(value)
5503
- };
5504
- return {
5505
- v: null,
5506
- t: null
5507
- };
5508
- }
5509
- function normalizeBaseCellData(cell) {
5510
- var _cell$v;
5511
- const type = inferBaseRuntimeCellType((_cell$v = cell.v) !== null && _cell$v !== void 0 ? _cell$v : null);
5512
- return {
5513
- ...cell,
5514
- t: type
5515
- };
5516
- }
5517
- function inferBaseRuntimeCellType(value) {
5518
- if (typeof value === "number") return _univerjs_core.CellValueType.NUMBER;
5519
- if (typeof value === "boolean") return _univerjs_core.CellValueType.BOOLEAN;
5520
- if (typeof value === "string") return _univerjs_core.CellValueType.STRING;
5521
- return null;
5522
- }
5523
- function isBaseCellData(value) {
5524
- return !!value && typeof value === "object" && (Object.prototype.hasOwnProperty.call(value, "v") || Object.prototype.hasOwnProperty.call(value, "t") || Object.prototype.hasOwnProperty.call(value, "p") || Object.prototype.hasOwnProperty.call(value, "f") || Object.prototype.hasOwnProperty.call(value, "si"));
5525
- }
5526
- function resolveBaseFormulaTable(tableName, currentTable, snapshot) {
5527
- if (!tableName || tableName === "table" || tableName === currentTable.id || tableName === currentTable.name) return currentTable;
5528
- const byId = snapshot.tables[tableName];
5529
- if (byId && !byId.deleted) return byId;
5530
- const matches = Object.values(snapshot.tables).filter((table) => !table.deleted && table.name === tableName);
5531
- return matches.length === 1 ? matches[0] : void 0;
5532
- }
5533
5342
 
5534
5343
  //#endregion
5535
5344
  //#region src/services/sheet-row-filtered.service.ts
@@ -5784,13 +5593,10 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends _uni
5784
5593
  });
5785
5594
  }
5786
5595
  _loadSheetData() {
5787
- var _workbook$getUnitId, _worksheet$getSheetId;
5788
5596
  const workbook = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
5789
5597
  const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getActiveSheet();
5790
- const base = workbook ? null : this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_BASE);
5791
- const table = base ? getFirstLiveBaseTable(base.getSnapshot().tables, base.getSnapshot().tableOrder) : null;
5792
- this._executeUnitId = (_workbook$getUnitId = workbook === null || workbook === void 0 ? void 0 : workbook.getUnitId()) !== null && _workbook$getUnitId !== void 0 ? _workbook$getUnitId : base === null || base === void 0 ? void 0 : base.getUnitId();
5793
- this._executeSubUnitId = (_worksheet$getSheetId = worksheet === null || worksheet === void 0 ? void 0 : worksheet.getSheetId()) !== null && _worksheet$getSheetId !== void 0 ? _worksheet$getSheetId : table === null || table === void 0 ? void 0 : table.id;
5598
+ this._executeUnitId = workbook === null || workbook === void 0 ? void 0 : workbook.getUnitId();
5599
+ this._executeSubUnitId = worksheet === null || worksheet === void 0 ? void 0 : worksheet.getSheetId();
5794
5600
  return this._formulaDataModel.getCalculateData();
5795
5601
  }
5796
5602
  /**
@@ -5821,14 +5627,6 @@ FormulaCurrentConfigService = __decorate([
5821
5627
  __decorateParam(2, (0, _univerjs_core.Inject)(FormulaDataModel)),
5822
5628
  __decorateParam(3, (0, _univerjs_core.Inject)(ISheetRowFilteredService))
5823
5629
  ], FormulaCurrentConfigService);
5824
- function getFirstLiveBaseTable(tables, tableOrder) {
5825
- var _Object$values$find;
5826
- for (const tableId of tableOrder) {
5827
- const table = tables[tableId];
5828
- if (table && !table.deleted) return table;
5829
- }
5830
- return (_Object$values$find = Object.values(tables).find((table) => !table.deleted)) !== null && _Object$values$find !== void 0 ? _Object$values$find : null;
5831
- }
5832
5630
  const IFormulaCurrentConfigService = (0, _univerjs_core.createIdentifier)("univer.formula.current-data.service");
5833
5631
 
5834
5632
  //#endregion
@@ -6000,7 +5798,7 @@ function clearNumberFormatTypeCache() {
6000
5798
  /**
6001
5799
  * Get the currency symbol based on the locale
6002
5800
  */
6003
- const localeCurrencySymbolMap = /* @__PURE__ */ new Map([
5801
+ const localeCurrencySymbolMap = new Map([
6004
5802
  [_univerjs_core.LocaleType.EN_US, "$"],
6005
5803
  [_univerjs_core.LocaleType.RU_RU, "₽"],
6006
5804
  [_univerjs_core.LocaleType.VI_VN, "₫"],
@@ -9958,7 +9756,7 @@ const IFormulaRuntimeService = (0, _univerjs_core.createIdentifier)("univer.form
9958
9756
 
9959
9757
  //#endregion
9960
9758
  //#region src/engine/ast-node/node-type.ts
9961
- const NODE_ORDER_MAP = /* @__PURE__ */ new Map([
9759
+ const NODE_ORDER_MAP = new Map([
9962
9760
  [1, 7],
9963
9761
  [2, 9],
9964
9762
  [3, 8],
@@ -15719,7 +15517,7 @@ function getMatrixSumProductOfCols(matrix, startCol, endCol, row1, row2) {
15719
15517
  for (let i = startCol; i < endCol; i++) sum += matrix[row1][i] * matrix[row2][i];
15720
15518
  return sum;
15721
15519
  }
15722
- const romanToArabicMap = /* @__PURE__ */ new Map([
15520
+ const romanToArabicMap = new Map([
15723
15521
  ["I", 1],
15724
15522
  ["V", 5],
15725
15523
  ["X", 10],
@@ -15728,7 +15526,7 @@ const romanToArabicMap = /* @__PURE__ */ new Map([
15728
15526
  ["D", 500],
15729
15527
  ["M", 1e3]
15730
15528
  ]);
15731
- const arabicToRomanMap = /* @__PURE__ */ new Map([
15529
+ const arabicToRomanMap = new Map([
15732
15530
  [1, "I"],
15733
15531
  [4, "IV"],
15734
15532
  [5, "V"],
@@ -27118,7 +26916,7 @@ var ErrorType$1 = class extends BaseFunction {
27118
26916
  super(..._args);
27119
26917
  _defineProperty(this, "minParams", 1);
27120
26918
  _defineProperty(this, "maxParams", 1);
27121
- _defineProperty(this, "_errorTypeValueMap", /* @__PURE__ */ new Map([
26919
+ _defineProperty(this, "_errorTypeValueMap", new Map([
27122
26920
  ["#NULL!", 1],
27123
26921
  ["#DIV/0!", 2],
27124
26922
  ["#VALUE!", 3],
@@ -40670,7 +40468,7 @@ function getObjectValue(result, isUseStrip = false) {
40670
40468
  //#endregion
40671
40469
  //#region package.json
40672
40470
  var name = "@univerjs/engine-formula";
40673
- var version = "0.25.0-insiders.20260623-012b5a8";
40471
+ var version = "0.25.1";
40674
40472
 
40675
40473
  //#endregion
40676
40474
  //#region src/services/global-computing-status.service.ts
package/lib/es/facade.js CHANGED
@@ -3,7 +3,7 @@ import { ICommandService, IConfigService, Inject, Injector } from "@univerjs/cor
3
3
  import { ENGINE_FORMULA_CYCLE_REFERENCE_COUNT, ENGINE_FORMULA_RETURN_DEPENDENCY_TREE, GlobalComputingStatusService, IDefinedNamesService, IFunctionService, ISuperTableService, LexerTreeBuilder, SetCellFormulaDependencyCalculationMutation, SetCellFormulaDependencyCalculationResultMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation, SetFormulaDependencyCalculationMutation, SetFormulaDependencyCalculationResultMutation, SetFormulaStringBatchCalculationMutation, SetFormulaStringBatchCalculationResultMutation, SetQueryFormulaDependencyAllMutation, SetQueryFormulaDependencyAllResultMutation, SetQueryFormulaDependencyMutation, SetQueryFormulaDependencyResultMutation, SetTriggerFormulaCalculationStartMutation } from "@univerjs/engine-formula";
4
4
  import { filter, firstValueFrom, map, race, timer } from "rxjs";
5
5
 
6
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorateParam.js
6
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
7
7
  function __decorateParam(paramIndex, decorator) {
8
8
  return function(target, key) {
9
9
  decorator(target, key, paramIndex);
@@ -11,7 +11,7 @@ function __decorateParam(paramIndex, decorator) {
11
11
  }
12
12
 
13
13
  //#endregion
14
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/decorate.js
14
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
15
15
  function __decorate(decorators, target, key, desc) {
16
16
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
17
17
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);