@univerjs/engine-formula 0.25.0 → 1.0.0-alpha.0
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 +2 -2
- package/lib/cjs/index.js +228 -26
- package/lib/es/facade.js +2 -2
- package/lib/es/index.js +229 -27
- package/lib/facade.js +2 -2
- package/lib/index.js +229 -27
- package/lib/types/index.d.ts +40 -25
- package/lib/umd/index.js +2 -2
- package/package.json +5 -5
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.
|
|
7
|
+
//#region \0@oxc-project+runtime@0.137.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.
|
|
15
|
+
//#region \0@oxc-project+runtime@0.137.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.
|
|
45
|
+
//#region \0@oxc-project+runtime@0.137.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.
|
|
56
|
+
//#region \0@oxc-project+runtime@0.137.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.
|
|
69
|
+
//#region \0@oxc-project+runtime@0.137.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.
|
|
76
|
+
//#region \0@oxc-project+runtime@0.137.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 = new Map([
|
|
271
|
+
const OPERATOR_TOKEN_PRIORITY = /* @__PURE__ */ new Map([
|
|
272
272
|
["<>", 4],
|
|
273
273
|
["<", 4],
|
|
274
274
|
[">=", 4],
|
|
@@ -283,7 +283,7 @@ const OPERATOR_TOKEN_PRIORITY = 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 = new Set([
|
|
286
|
+
const OPERATOR_TOKEN_COMPARE_SET = /* @__PURE__ */ 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 = new Set(["%", "#"]);
|
|
312
|
+
const SUFFIX_TOKEN_SET = /* @__PURE__ */ 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 = new Set([
|
|
1352
|
+
const TOKEN_CANNOT_BE_AT_END_SET = /* @__PURE__ */ new Set([
|
|
1353
1353
|
"+",
|
|
1354
1354
|
"-",
|
|
1355
1355
|
"*",
|
|
@@ -1371,7 +1371,7 @@ const TOKEN_CANNOT_BE_AT_END_SET = 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 = new Set([
|
|
1374
|
+
const TOKEN_CANNOT_PRECEDE_SUFFIX_TOKEN_SET = /* @__PURE__ */ 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 = new Set([
|
|
1545
|
+
const FORCED_RECALCULATION_FUNCTION_NAME = /* @__PURE__ */ 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.
|
|
1880
|
+
//#region \0@oxc-project+runtime@0.137.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.
|
|
1888
|
+
//#region \0@oxc-project+runtime@0.137.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 = new Set([
|
|
3032
|
+
const NEW_EXCEL_FUNCTIONS = /* @__PURE__ */ new Set([
|
|
3033
3033
|
"ACOT",
|
|
3034
3034
|
"ACOTH",
|
|
3035
3035
|
"ARABIC",
|
|
@@ -4939,15 +4939,54 @@ 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
|
-
|
|
4943
|
-
|
|
4942
|
+
for (let i = 0; i < allSheets.length; i++) {
|
|
4943
|
+
const workbook = allSheets[i];
|
|
4944
4944
|
const unitId = workbook.getUnitId();
|
|
4945
4945
|
formulaData[unitId] = {};
|
|
4946
|
-
workbook.getSheets()
|
|
4946
|
+
const worksheets = workbook.getSheets();
|
|
4947
|
+
for (let j = 0; j < worksheets.length; j++) {
|
|
4948
|
+
const worksheet = worksheets[j];
|
|
4947
4949
|
const cellMatrix = worksheet.getCellMatrix();
|
|
4948
4950
|
initSheetFormulaData(formulaData, unitId, worksheet.getSheetId(), cellMatrix);
|
|
4949
|
-
}
|
|
4950
|
-
}
|
|
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
|
+
}
|
|
4951
4990
|
return formulaData;
|
|
4952
4991
|
}
|
|
4953
4992
|
getSheetFormulaData(unitId, sheetId) {
|
|
@@ -5051,6 +5090,33 @@ let FormulaDataModel = class FormulaDataModel extends _univerjs_core.Disposable
|
|
|
5051
5090
|
unitStylesData[unitId] = workbook.getStyles();
|
|
5052
5091
|
unitSheetNameMap[unitId] = sheetNameMap;
|
|
5053
5092
|
}
|
|
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
|
+
}
|
|
5054
5120
|
return {
|
|
5055
5121
|
allUnitData,
|
|
5056
5122
|
unitStylesData,
|
|
@@ -5339,6 +5405,131 @@ function initSheetFormulaData(formulaData, unitId, sheetId, cellMatrix) {
|
|
|
5339
5405
|
const newSheetFormulaData = sheetFormulaDataMatrix.getMatrix();
|
|
5340
5406
|
return { [unitId]: { [sheetId]: newSheetFormulaData } };
|
|
5341
5407
|
}
|
|
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
|
+
}
|
|
5342
5533
|
|
|
5343
5534
|
//#endregion
|
|
5344
5535
|
//#region src/services/sheet-row-filtered.service.ts
|
|
@@ -5593,10 +5784,13 @@ let FormulaCurrentConfigService = class FormulaCurrentConfigService extends _uni
|
|
|
5593
5784
|
});
|
|
5594
5785
|
}
|
|
5595
5786
|
_loadSheetData() {
|
|
5787
|
+
var _workbook$getUnitId, _worksheet$getSheetId;
|
|
5596
5788
|
const workbook = this._univerInstanceService.getCurrentUnitOfType(_univerjs_core.UniverInstanceType.UNIVER_SHEET);
|
|
5597
5789
|
const worksheet = workbook === null || workbook === void 0 ? void 0 : workbook.getActiveSheet();
|
|
5598
|
-
|
|
5599
|
-
|
|
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;
|
|
5600
5794
|
return this._formulaDataModel.getCalculateData();
|
|
5601
5795
|
}
|
|
5602
5796
|
/**
|
|
@@ -5627,6 +5821,14 @@ FormulaCurrentConfigService = __decorate([
|
|
|
5627
5821
|
__decorateParam(2, (0, _univerjs_core.Inject)(FormulaDataModel)),
|
|
5628
5822
|
__decorateParam(3, (0, _univerjs_core.Inject)(ISheetRowFilteredService))
|
|
5629
5823
|
], 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
|
+
}
|
|
5630
5832
|
const IFormulaCurrentConfigService = (0, _univerjs_core.createIdentifier)("univer.formula.current-data.service");
|
|
5631
5833
|
|
|
5632
5834
|
//#endregion
|
|
@@ -5798,7 +6000,7 @@ function clearNumberFormatTypeCache() {
|
|
|
5798
6000
|
/**
|
|
5799
6001
|
* Get the currency symbol based on the locale
|
|
5800
6002
|
*/
|
|
5801
|
-
const localeCurrencySymbolMap = new Map([
|
|
6003
|
+
const localeCurrencySymbolMap = /* @__PURE__ */ new Map([
|
|
5802
6004
|
[_univerjs_core.LocaleType.EN_US, "$"],
|
|
5803
6005
|
[_univerjs_core.LocaleType.RU_RU, "₽"],
|
|
5804
6006
|
[_univerjs_core.LocaleType.VI_VN, "₫"],
|
|
@@ -9756,7 +9958,7 @@ const IFormulaRuntimeService = (0, _univerjs_core.createIdentifier)("univer.form
|
|
|
9756
9958
|
|
|
9757
9959
|
//#endregion
|
|
9758
9960
|
//#region src/engine/ast-node/node-type.ts
|
|
9759
|
-
const NODE_ORDER_MAP = new Map([
|
|
9961
|
+
const NODE_ORDER_MAP = /* @__PURE__ */ new Map([
|
|
9760
9962
|
[1, 7],
|
|
9761
9963
|
[2, 9],
|
|
9762
9964
|
[3, 8],
|
|
@@ -15517,7 +15719,7 @@ function getMatrixSumProductOfCols(matrix, startCol, endCol, row1, row2) {
|
|
|
15517
15719
|
for (let i = startCol; i < endCol; i++) sum += matrix[row1][i] * matrix[row2][i];
|
|
15518
15720
|
return sum;
|
|
15519
15721
|
}
|
|
15520
|
-
const romanToArabicMap = new Map([
|
|
15722
|
+
const romanToArabicMap = /* @__PURE__ */ new Map([
|
|
15521
15723
|
["I", 1],
|
|
15522
15724
|
["V", 5],
|
|
15523
15725
|
["X", 10],
|
|
@@ -15526,7 +15728,7 @@ const romanToArabicMap = new Map([
|
|
|
15526
15728
|
["D", 500],
|
|
15527
15729
|
["M", 1e3]
|
|
15528
15730
|
]);
|
|
15529
|
-
const arabicToRomanMap = new Map([
|
|
15731
|
+
const arabicToRomanMap = /* @__PURE__ */ new Map([
|
|
15530
15732
|
[1, "I"],
|
|
15531
15733
|
[4, "IV"],
|
|
15532
15734
|
[5, "V"],
|
|
@@ -26916,7 +27118,7 @@ var ErrorType$1 = class extends BaseFunction {
|
|
|
26916
27118
|
super(..._args);
|
|
26917
27119
|
_defineProperty(this, "minParams", 1);
|
|
26918
27120
|
_defineProperty(this, "maxParams", 1);
|
|
26919
|
-
_defineProperty(this, "_errorTypeValueMap", new Map([
|
|
27121
|
+
_defineProperty(this, "_errorTypeValueMap", /* @__PURE__ */ new Map([
|
|
26920
27122
|
["#NULL!", 1],
|
|
26921
27123
|
["#DIV/0!", 2],
|
|
26922
27124
|
["#VALUE!", 3],
|
|
@@ -40468,7 +40670,7 @@ function getObjectValue(result, isUseStrip = false) {
|
|
|
40468
40670
|
//#endregion
|
|
40469
40671
|
//#region package.json
|
|
40470
40672
|
var name = "@univerjs/engine-formula";
|
|
40471
|
-
var version = "0.
|
|
40673
|
+
var version = "1.0.0-alpha.0";
|
|
40472
40674
|
|
|
40473
40675
|
//#endregion
|
|
40474
40676
|
//#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.
|
|
6
|
+
//#region \0@oxc-project+runtime@0.137.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.
|
|
14
|
+
//#region \0@oxc-project+runtime@0.137.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);
|