@univerjs/sheets-formula 1.4.0 → 1.5.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/README.md +19 -7
- package/lib/cjs/index.js +200 -132
- package/lib/cjs/{worker-Ds9TzMsD.js → remote-register-function.service-D0P1G4Uh.js} +24 -60
- package/lib/cjs/worker.js +45 -2
- package/lib/es/index.js +111 -37
- package/lib/es/{worker-m5XIUFq5.js → remote-register-function.service-CaKs4mpz.js} +14 -56
- package/lib/es/worker.js +44 -1
- package/lib/index.js +111 -37
- package/lib/{worker-m5XIUFq5.js → remote-register-function.service-CaKs4mpz.js} +14 -56
- package/lib/types/controllers/trigger-calculation.controller.d.ts +2 -0
- package/lib/types/index.d.ts +0 -3
- package/lib/types/services/formula-ref-range.service.d.ts +8 -0
- package/lib/umd/index.js +1 -1
- package/lib/worker.js +44 -1
- package/package.json +10 -10
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as version, c as __decorateParam, f as defaultPluginBaseConfig, i as name, l as CalculationMode, n as RemoteRegisterFunctionService, o as _defineProperty, r as RemoteRegisterFunctionServiceName, s as __decorate, t as IRemoteRegisterFunctionService, u as PLUGIN_CONFIG_KEY_BASE } from "./remote-register-function.service-CaKs4mpz.js";
|
|
2
2
|
import { AbsoluteRefType, BooleanNumber, BuildTextUtils, CellValueType, CommandType, DependentOn, Direction, Disposable, DisposableCollection, DrawingTypeEnum, ICommandService, IConfigService, ILogService, IUndoRedoService, IUniverInstanceService, ImageSourceType, Inject, Injector, InterceptorEffectEnum, LocaleService, ObjectMatrix, Plugin, PositionedObjectLayoutType, RANGE_TYPE, Range, Rectangle, Tools, UniverInstanceType, WrapTextType, cellToRange, createDocumentModelWithStyle, generateRandomId, getIntersectRange, isFormulaId, isFormulaString, isNodeEnv, isRealNum, merge, moveRangeByOffset, sequenceExecute, toDisposable, touchDependencies } from "@univerjs/core";
|
|
3
3
|
import { AUTO_FILL_APPLY_TYPE, AUTO_FILL_DATA_TYPE, ClearSelectionFormatCommand, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, EffectRefRangId, IAutoFillService, INTERCEPTOR_POINT, InsertColCommand, InsertColMutation, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, InsertRowCommand, InsertRowMutation, InsertSheetMutation, InterceptCellContentPriority, MoveColsCommand, MoveColsMutation, MoveRangeCommand, MoveRangeMutation, MoveRowsCommand, MoveRowsMutation, RefRangeService, RemoveColCommand, RemoveColMutation, RemoveDefinedNameCommand, RemoveRowCommand, RemoveRowMutation, RemoveSheetCommand, RemoveSheetMutation, ReorderRangeCommand, ReorderRangeMutation, SCOPE_WORKBOOK_VALUE_DEFINED_NAME, SetBorderCommand, SetDefinedNameCommand, SetRangeCustomMetadataCommand, SetRangeValuesCommand, SetRangeValuesMutation, SetRowHiddenMutation, SetRowVisibleMutation, SetStyleCommand, SetWorkbookCalculationSettingsMutation, SetWorkbookNameCommand, SetWorksheetActiveOperation, SetWorksheetColumnCountMutation, SetWorksheetNameCommand, SetWorksheetOrderMutation, SetWorksheetRowCountMutation, SheetInterceptorService, UniverSheetsPlugin, getSeparateEffectedRangesOnCommand, getSheetCommandTarget, handleCommonDefaultRangeChangeWithEffectRefCommands, handleDefaultRangeChangeWithEffectRefCommands, handleDeleteRangeMoveLeft, handleDeleteRangeMoveUp, handleIRemoveCol, handleIRemoveRow, handleInsertCol, handleInsertRangeMoveDown, handleInsertRangeMoveRight, handleInsertRow, handleMoveCols, handleMoveRange, handleMoveRows, runRefRangeMutations } from "@univerjs/sheets";
|
|
4
4
|
import { AstTreeBuilder, ENGINE_FORMULA_RETURN_DEPENDENCY_TREE, ErrorType, FormulaCalculationSessionService, FormulaDataModel, FormulaExecuteStageType, FormulaExecutedStateType, FormulaResultApplicationType, FunctionType, IActiveDirtyManagerService, IDefinedNamesService, IDescriptionService, IFormulaCurrentConfigService, ISuperTableService, Interpreter, Lexer, LexerTreeBuilder, RemoveDefinedNameMutation, RemoveSuperTableMutation, SetArrayFormulaDataMutation, SetDefinedNameMutation, SetFormulaCalculationNotificationMutation, SetFormulaCalculationStartMutation, SetFormulaCalculationStopMutation, SetFormulaDataMutation, SetFormulaStringBatchCalculationMutation, SetImageFormulaDataMutation, SetSuperTableMutation, SetTriggerFormulaCalculationStartMutation, UniverFormulaEnginePlugin, deserializeRangeWithSheetWithCache, generateExecuteAstNodeData, generateStringWithSequence, getObjectValue, refactorFormulaUnitQualifier, sequenceNodeType, serializeRange, serializeRangeToRefString, serializeRangeWithSheet, serializeRangeWithSpreadsheet, splitTableStructuredRef, stripErrorMargin } from "@univerjs/engine-formula";
|
|
@@ -442,6 +442,12 @@ let TriggerCalculationController = class TriggerCalculationController extends Di
|
|
|
442
442
|
_initialExecuteFormulaProcessListener() {
|
|
443
443
|
let startDependencyTimer = null;
|
|
444
444
|
let calculationProcessCount = 0;
|
|
445
|
+
this.disposeWithMe(() => {
|
|
446
|
+
if (startDependencyTimer !== null) {
|
|
447
|
+
clearTimeout(startDependencyTimer);
|
|
448
|
+
startDependencyTimer = null;
|
|
449
|
+
}
|
|
450
|
+
});
|
|
445
451
|
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
446
452
|
if (command.id === SetFormulaCalculationStopMutation.id) this.clearProgress();
|
|
447
453
|
if (command.id !== SetFormulaCalculationNotificationMutation.id) return;
|
|
@@ -460,43 +466,11 @@ let TriggerCalculationController = class TriggerCalculationController extends Di
|
|
|
460
466
|
startDependencyTimer = null;
|
|
461
467
|
this._startProgress();
|
|
462
468
|
}, 1e3);
|
|
463
|
-
} else
|
|
464
|
-
this._executionInProgressParams = params.stageInfo;
|
|
465
|
-
if (startDependencyTimer === null) {
|
|
466
|
-
const calculating = this._localeService.t("sheets-formula.progress.calculating");
|
|
467
|
-
this._calculateProgress(calculating);
|
|
468
|
-
}
|
|
469
|
-
} else if (stage === FormulaExecuteStageType.START_DEPENDENCY_ARRAY_FORMULA) {
|
|
470
|
-
this._executionInProgressParams = params.stageInfo;
|
|
471
|
-
if (startDependencyTimer === null) {
|
|
472
|
-
const arrayAnalysis = this._localeService.t("sheets-formula.progress.array-analysis");
|
|
473
|
-
this._calculateProgress(arrayAnalysis);
|
|
474
|
-
}
|
|
475
|
-
} else if (stage === FormulaExecuteStageType.CURRENTLY_CALCULATING_ARRAY_FORMULA) {
|
|
476
|
-
this._executionInProgressParams = params.stageInfo;
|
|
477
|
-
if (startDependencyTimer === null) {
|
|
478
|
-
const arrayCalculation = this._localeService.t("sheets-formula.progress.array-calculation");
|
|
479
|
-
this._calculateProgress(arrayCalculation);
|
|
480
|
-
}
|
|
481
|
-
}
|
|
469
|
+
} else this._updateCalculationProgress(params.stageInfo, startDependencyTimer === null);
|
|
482
470
|
} else {
|
|
483
471
|
const state = params.functionsExecutedState;
|
|
484
|
-
|
|
485
|
-
calculationProcessCount
|
|
486
|
-
switch (state) {
|
|
487
|
-
case FormulaExecutedStateType.NOT_EXECUTED:
|
|
488
|
-
result = "No tasks are being executed anymore";
|
|
489
|
-
break;
|
|
490
|
-
case FormulaExecutedStateType.STOP_EXECUTION:
|
|
491
|
-
result = "The execution of the formula has been stopped";
|
|
492
|
-
calculationProcessCount = 0;
|
|
493
|
-
break;
|
|
494
|
-
case FormulaExecutedStateType.SUCCESS:
|
|
495
|
-
result = "Formula calculation succeeded";
|
|
496
|
-
if (calculationProcessCount === 0 || calculationProcessCount === -1) result += `. Total time consumed: ${performance.now() - this._startExecutionTime} ms`;
|
|
497
|
-
break;
|
|
498
|
-
case FormulaExecutedStateType.INITIAL: result = "Waiting for calculation";
|
|
499
|
-
}
|
|
472
|
+
calculationProcessCount = state === FormulaExecutedStateType.STOP_EXECUTION ? 0 : calculationProcessCount - 1;
|
|
473
|
+
const result = this._getCalculationResultMessage(state, calculationProcessCount);
|
|
500
474
|
if (calculationProcessCount === 0 || calculationProcessCount === -1) {
|
|
501
475
|
if (startDependencyTimer) {
|
|
502
476
|
clearTimeout(startDependencyTimer);
|
|
@@ -512,6 +486,34 @@ let TriggerCalculationController = class TriggerCalculationController extends Di
|
|
|
512
486
|
}
|
|
513
487
|
}));
|
|
514
488
|
}
|
|
489
|
+
_updateCalculationProgress(stageInfo, showProgress) {
|
|
490
|
+
let label;
|
|
491
|
+
switch (stageInfo.stage) {
|
|
492
|
+
case FormulaExecuteStageType.CURRENTLY_CALCULATING:
|
|
493
|
+
label = "sheets-formula.progress.calculating";
|
|
494
|
+
break;
|
|
495
|
+
case FormulaExecuteStageType.START_DEPENDENCY_ARRAY_FORMULA:
|
|
496
|
+
label = "sheets-formula.progress.array-analysis";
|
|
497
|
+
break;
|
|
498
|
+
case FormulaExecuteStageType.CURRENTLY_CALCULATING_ARRAY_FORMULA:
|
|
499
|
+
label = "sheets-formula.progress.array-calculation";
|
|
500
|
+
break;
|
|
501
|
+
default: return;
|
|
502
|
+
}
|
|
503
|
+
this._executionInProgressParams = stageInfo;
|
|
504
|
+
if (showProgress) this._calculateProgress(this._localeService.t(label));
|
|
505
|
+
}
|
|
506
|
+
_getCalculationResultMessage(state, calculationProcessCount) {
|
|
507
|
+
switch (state) {
|
|
508
|
+
case FormulaExecutedStateType.NOT_EXECUTED: return "No tasks are being executed anymore";
|
|
509
|
+
case FormulaExecutedStateType.STOP_EXECUTION: return "The execution of the formula has been stopped";
|
|
510
|
+
case FormulaExecutedStateType.SUCCESS:
|
|
511
|
+
if (calculationProcessCount === 0 || calculationProcessCount === -1) return `Formula calculation succeeded. Total time consumed: ${performance.now() - this._startExecutionTime} ms`;
|
|
512
|
+
return "Formula calculation succeeded";
|
|
513
|
+
case FormulaExecutedStateType.INITIAL: return "Waiting for calculation";
|
|
514
|
+
default: return "";
|
|
515
|
+
}
|
|
516
|
+
}
|
|
515
517
|
_initialExecuteFormula() {
|
|
516
518
|
const calculationMode = this._getCalculationMode();
|
|
517
519
|
if (calculationMode !== 2) {
|
|
@@ -2127,12 +2129,15 @@ let UpdateFormulaController = class UpdateFormulaController extends Disposable {
|
|
|
2127
2129
|
if (formulaDataKeys.length === 0) return { newFormulaData: {} };
|
|
2128
2130
|
const newFormulaData = Object.create(null);
|
|
2129
2131
|
const inCrossSheetCutRangeNewFormulas = [];
|
|
2132
|
+
const { type, unitId: affectedUnitId, sheetId: affectedSheetId } = formulaReferenceMoveParam;
|
|
2133
|
+
const isRemovingSheet = type === 13;
|
|
2130
2134
|
for (const unitId of formulaDataKeys) {
|
|
2131
2135
|
const sheetData = formulaData[unitId];
|
|
2132
2136
|
if (sheetData == null) continue;
|
|
2133
2137
|
const sheetDataKeys = Object.keys(sheetData);
|
|
2134
2138
|
if (!Tools.isDefine(newFormulaData[unitId])) newFormulaData[unitId] = Object.create(null);
|
|
2135
2139
|
for (const sheetId of sheetDataKeys) {
|
|
2140
|
+
if (isRemovingSheet && unitId === affectedUnitId && sheetId === affectedSheetId) continue;
|
|
2136
2141
|
const matrixData = new ObjectMatrix(sheetData[sheetId] || {});
|
|
2137
2142
|
const newFormulaDataItem = new ObjectMatrix();
|
|
2138
2143
|
const context = {
|
|
@@ -3119,6 +3124,38 @@ SuperTableController = __decorate([
|
|
|
3119
3124
|
], SuperTableController);
|
|
3120
3125
|
|
|
3121
3126
|
// src/services/formula-ref-range.service.ts
|
|
3127
|
+
/**
|
|
3128
|
+
* An inserted row or column that lands inside a registered range stays part of that range, the
|
|
3129
|
+
* same way {@link handleCommonDefaultRangeChangeWithEffectRefCommands} expands a range when the
|
|
3130
|
+
* insertion happens inside it. `registerRangeFormula` splits a range into the segments that are
|
|
3131
|
+
* affected by a command, and an inserted block is not part of any segment, so it has to be
|
|
3132
|
+
* collected separately, otherwise the inserted cells would silently drop out of the range.
|
|
3133
|
+
*/
|
|
3134
|
+
function getInsertedBlocks(command, ranges) {
|
|
3135
|
+
const params = command.params;
|
|
3136
|
+
if (!(params === null || params === void 0 ? void 0 : params.range)) return [];
|
|
3137
|
+
switch (command.id) {
|
|
3138
|
+
case EffectRefRangId.InsertRowCommandId: {
|
|
3139
|
+
const { startRow, endRow } = params.range;
|
|
3140
|
+
return ranges.filter((range) => startRow > range.startRow && startRow <= range.endRow).map((range) => ({
|
|
3141
|
+
startRow,
|
|
3142
|
+
endRow,
|
|
3143
|
+
startColumn: range.startColumn,
|
|
3144
|
+
endColumn: range.endColumn
|
|
3145
|
+
}));
|
|
3146
|
+
}
|
|
3147
|
+
case EffectRefRangId.InsertColCommandId: {
|
|
3148
|
+
const { startColumn, endColumn } = params.range;
|
|
3149
|
+
return ranges.filter((range) => startColumn > range.startColumn && startColumn <= range.endColumn).map((range) => ({
|
|
3150
|
+
startRow: range.startRow,
|
|
3151
|
+
endRow: range.endRow,
|
|
3152
|
+
startColumn,
|
|
3153
|
+
endColumn
|
|
3154
|
+
}));
|
|
3155
|
+
}
|
|
3156
|
+
default: return [];
|
|
3157
|
+
}
|
|
3158
|
+
}
|
|
3122
3159
|
function getFormulaKeyOffset(lexerTreeBuilder, formulaString, refOffsetX, refOffsetY) {
|
|
3123
3160
|
const sequenceNodes = lexerTreeBuilder.sequenceNodesBuilder(formulaString);
|
|
3124
3161
|
if (sequenceNodes == null) return formulaString;
|
|
@@ -3267,6 +3304,8 @@ let FormulaRefRangeService = class FormulaRefRangeService extends Disposable {
|
|
|
3267
3304
|
const disposableCollection = new DisposableCollection();
|
|
3268
3305
|
const formulaDeps = formulas.map((formula) => this._getFormulaDependcy(unitId, subUnitId, formula, oldRanges));
|
|
3269
3306
|
const handleRangeChange = (commandInfo) => {
|
|
3307
|
+
const wholeRangeResult = this._transformWholeRangeFormulas(unitId, subUnitId, oldRanges, formulas, commandInfo);
|
|
3308
|
+
if (wholeRangeResult) return callback(wholeRangeResult);
|
|
3270
3309
|
const effectedRanges = getSeparateEffectedRangesOnCommand(this._injector, commandInfo);
|
|
3271
3310
|
if (!effectedRanges) return {
|
|
3272
3311
|
undos: [],
|
|
@@ -3358,6 +3397,7 @@ let FormulaRefRangeService = class FormulaRefRangeService extends Disposable {
|
|
|
3358
3397
|
if (keyMap.has(item.key)) keyMap.get(item.key).push(item);
|
|
3359
3398
|
else keyMap.set(item.key, [item]);
|
|
3360
3399
|
}
|
|
3400
|
+
this._appendInsertedBlockItems(keyMap, commandInfo, oldRanges, formulas, oldRanges[0], originKey);
|
|
3361
3401
|
const res = [];
|
|
3362
3402
|
const keys = Array.from(keyMap.keys());
|
|
3363
3403
|
for (let i = keys.length - 1; i >= 0; i--) {
|
|
@@ -3391,6 +3431,40 @@ let FormulaRefRangeService = class FormulaRefRangeService extends Disposable {
|
|
|
3391
3431
|
});
|
|
3392
3432
|
return disposableCollection;
|
|
3393
3433
|
}
|
|
3434
|
+
/**
|
|
3435
|
+
* A whole column/row/sheet range keeps its anchor, so it is adjusted as a single range:
|
|
3436
|
+
* segmenting it would both split the rule and drop the range type.
|
|
3437
|
+
*
|
|
3438
|
+
* @returns the single rule range to apply, or `undefined` when the regular segmentation applies
|
|
3439
|
+
*/
|
|
3440
|
+
_transformWholeRangeFormulas(unitId, subUnitId, oldRanges, formulas, commandInfo) {
|
|
3441
|
+
var _oldRanges$;
|
|
3442
|
+
const ruleRangeType = ((_oldRanges$ = oldRanges[0]) === null || _oldRanges$ === void 0 ? void 0 : _oldRanges$.rangeType) ?? RANGE_TYPE.NORMAL;
|
|
3443
|
+
if (ruleRangeType === RANGE_TYPE.NORMAL || !oldRanges.every((range) => range.rangeType === ruleRangeType)) return;
|
|
3444
|
+
const ranges = handleCommonDefaultRangeChangeWithEffectRefCommands(oldRanges[0], commandInfo);
|
|
3445
|
+
if (!ranges.length) return [];
|
|
3446
|
+
return [{
|
|
3447
|
+
formulas: formulas.map((formula) => isFormulaString(formula) ? this.transformFormulaByEffectCommand(unitId, subUnitId, formula, commandInfo) : formula),
|
|
3448
|
+
ranges
|
|
3449
|
+
}];
|
|
3450
|
+
}
|
|
3451
|
+
_appendInsertedBlockItems(keyMap, commandInfo, oldRanges, formulas, origin, originKey) {
|
|
3452
|
+
for (const block of getInsertedBlocks(commandInfo, oldRanges)) {
|
|
3453
|
+
const offsetRow = block.startRow - origin.startRow;
|
|
3454
|
+
const offsetColumn = block.startColumn - origin.startColumn;
|
|
3455
|
+
const item = {
|
|
3456
|
+
formulas: formulas.map((formula) => ({
|
|
3457
|
+
newFormula: isFormulaString(formula) ? this._lexerTreeBuilder.moveFormulaRefOffset(formula, offsetColumn, offsetRow) : formula,
|
|
3458
|
+
orginFormula: formula
|
|
3459
|
+
})),
|
|
3460
|
+
ranges: [block],
|
|
3461
|
+
key: originKey
|
|
3462
|
+
};
|
|
3463
|
+
const items = keyMap.get(item.key);
|
|
3464
|
+
if (items) items.push(item);
|
|
3465
|
+
else keyMap.set(item.key, [item]);
|
|
3466
|
+
}
|
|
3467
|
+
}
|
|
3394
3468
|
};
|
|
3395
3469
|
FormulaRefRangeService = __decorate([
|
|
3396
3470
|
__decorateParam(0, Inject(RefRangeService)),
|
|
@@ -3492,4 +3566,4 @@ function calculateFormula(inject, formulaString, unitId, sheetData) {
|
|
|
3492
3566
|
return getObjectValue(result);
|
|
3493
3567
|
}
|
|
3494
3568
|
|
|
3495
|
-
export { CalculationMode, FormulaAutoFillController, FormulaRefRangeService, FormulaReorderController, IRemoteRegisterFunctionService, ImageFormulaCellInterceptorController, InsertFunctionCommand, PLUGIN_CONFIG_KEY_BASE, RemoteRegisterFunctionService, TriggerCalculationController, UnitQualifierRenameController,
|
|
3569
|
+
export { CalculationMode, FormulaAutoFillController, FormulaRefRangeService, FormulaReorderController, IRemoteRegisterFunctionService, ImageFormulaCellInterceptorController, InsertFunctionCommand, PLUGIN_CONFIG_KEY_BASE, RemoteRegisterFunctionService, TriggerCalculationController, UnitQualifierRenameController, UniverSheetsFormulaPlugin, UpdateDefinedNameController, UpdateFormulaController, calculateFormula, collectUnitQualifierFormulaPatches };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createIdentifier } from "@univerjs/core";
|
|
2
2
|
import { IFunctionService } from "@univerjs/engine-formula";
|
|
3
|
-
import { IRPCChannelService, fromModule } from "@univerjs/rpc";
|
|
4
|
-
import { UniverFormulaEnginePlugin as UniverFormulaEnginePlugin$1 } from "@univerjs/engine-formula/worker";
|
|
5
3
|
|
|
6
4
|
// src/config/config.ts
|
|
7
5
|
/**
|
|
@@ -37,14 +35,14 @@ const defaultPluginRemoteConfig = {};
|
|
|
37
35
|
const PLUGIN_CONFIG_KEY_MOBILE = "sheets-formula.mobile.config";
|
|
38
36
|
const configSymbolMobile = Symbol(PLUGIN_CONFIG_KEY_MOBILE);
|
|
39
37
|
|
|
40
|
-
// \0@oxc-project+runtime@0.
|
|
38
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
|
|
41
39
|
function __decorateParam(paramIndex, decorator) {
|
|
42
40
|
return function(target, key) {
|
|
43
41
|
decorator(target, key, paramIndex);
|
|
44
42
|
};
|
|
45
43
|
}
|
|
46
44
|
|
|
47
|
-
// \0@oxc-project+runtime@0.
|
|
45
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
|
|
48
46
|
function __decorate(decorators, target, key, desc) {
|
|
49
47
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
50
48
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -52,7 +50,7 @@ function __decorate(decorators, target, key, desc) {
|
|
|
52
50
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
53
51
|
}
|
|
54
52
|
|
|
55
|
-
// \0@oxc-project+runtime@0.
|
|
53
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
|
|
56
54
|
function _typeof(o) {
|
|
57
55
|
"@babel/helpers - typeof";
|
|
58
56
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -62,25 +60,25 @@ function _typeof(o) {
|
|
|
62
60
|
}, _typeof(o);
|
|
63
61
|
}
|
|
64
62
|
|
|
65
|
-
// \0@oxc-project+runtime@0.
|
|
66
|
-
function toPrimitive(t,
|
|
63
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
|
|
64
|
+
function toPrimitive(t, e) {
|
|
67
65
|
if ("object" != _typeof(t) || !t) return t;
|
|
68
|
-
var
|
|
69
|
-
if (void 0 !==
|
|
70
|
-
var i =
|
|
66
|
+
var r;
|
|
67
|
+
if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
|
|
68
|
+
var i = r.call(t, e || "default");
|
|
71
69
|
if ("object" != _typeof(i)) return i;
|
|
72
70
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
73
71
|
}
|
|
74
|
-
return ("string" ===
|
|
72
|
+
return ("string" === e ? String : Number)(t);
|
|
75
73
|
}
|
|
76
74
|
|
|
77
|
-
// \0@oxc-project+runtime@0.
|
|
75
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
|
|
78
76
|
function toPropertyKey(t) {
|
|
79
77
|
var i = toPrimitive(t, "string");
|
|
80
78
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
81
79
|
}
|
|
82
80
|
|
|
83
|
-
// \0@oxc-project+runtime@0.
|
|
81
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
|
|
84
82
|
function _defineProperty(e, r, t) {
|
|
85
83
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
86
84
|
value: t,
|
|
@@ -92,7 +90,7 @@ function _defineProperty(e, r, t) {
|
|
|
92
90
|
|
|
93
91
|
// package.json
|
|
94
92
|
var name = "@univerjs/sheets-formula";
|
|
95
|
-
var version = "1.
|
|
93
|
+
var version = "1.5.0";
|
|
96
94
|
|
|
97
95
|
// src/services/remote/remote-register-function.service.ts
|
|
98
96
|
/**
|
|
@@ -134,44 +132,4 @@ function rejectRemoteCustomFunctionRegistration(serializedFuncs) {
|
|
|
134
132
|
throw new Error("Remote custom function registration is disabled because function deserialization over RPC is unsafe.");
|
|
135
133
|
}
|
|
136
134
|
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
140
|
-
*
|
|
141
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
142
|
-
* you may not use this file except in compliance with the License.
|
|
143
|
-
* You may obtain a copy of the License at
|
|
144
|
-
*
|
|
145
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
146
|
-
*
|
|
147
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
148
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
149
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
150
|
-
* See the License for the specific language governing permissions and
|
|
151
|
-
* limitations under the License.
|
|
152
|
-
*/
|
|
153
|
-
let UniverRemoteSheetsFormulaPlugin = class UniverRemoteSheetsFormulaPlugin extends Plugin {
|
|
154
|
-
constructor(_config = defaultPluginRemoteConfig, _injector, _configService) {
|
|
155
|
-
super();
|
|
156
|
-
this._config = _config;
|
|
157
|
-
this._injector = _injector;
|
|
158
|
-
this._configService = _configService;
|
|
159
|
-
const { ...rest } = merge({}, defaultPluginRemoteConfig, this._config);
|
|
160
|
-
this._configService.setConfig(PLUGIN_CONFIG_KEY_REMOTE, rest);
|
|
161
|
-
}
|
|
162
|
-
onStarting() {
|
|
163
|
-
this._injector.add([RemoteRegisterFunctionService]);
|
|
164
|
-
this._injector.get(IRPCChannelService).registerChannel(RemoteRegisterFunctionServiceName, fromModule(this._injector.get(RemoteRegisterFunctionService)));
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
_defineProperty(UniverRemoteSheetsFormulaPlugin, "pluginName", "SHEET_FORMULA_REMOTE_PLUGIN");
|
|
168
|
-
_defineProperty(UniverRemoteSheetsFormulaPlugin, "packageName", name);
|
|
169
|
-
_defineProperty(UniverRemoteSheetsFormulaPlugin, "version", version);
|
|
170
|
-
_defineProperty(UniverRemoteSheetsFormulaPlugin, "type", UniverInstanceType.UNIVER_SHEET);
|
|
171
|
-
UniverRemoteSheetsFormulaPlugin = __decorate([
|
|
172
|
-
DependentOn(UniverFormulaEnginePlugin$1),
|
|
173
|
-
__decorateParam(1, Inject(Injector)),
|
|
174
|
-
__decorateParam(2, IConfigService)
|
|
175
|
-
], UniverRemoteSheetsFormulaPlugin);
|
|
176
|
-
|
|
177
|
-
export { name as a, __decorate as c, PLUGIN_CONFIG_KEY_BASE as d, defaultPluginBaseConfig as f, RemoteRegisterFunctionServiceName as i, __decorateParam as l, IRemoteRegisterFunctionService as n, version as o, RemoteRegisterFunctionService as r, _defineProperty as s, UniverRemoteSheetsFormulaPlugin as t, CalculationMode as u };
|
|
135
|
+
export { version as a, __decorateParam as c, PLUGIN_CONFIG_KEY_REMOTE as d, defaultPluginBaseConfig as f, name as i, CalculationMode as l, RemoteRegisterFunctionService as n, _defineProperty as o, defaultPluginRemoteConfig as p, RemoteRegisterFunctionServiceName as r, __decorate as s, IRemoteRegisterFunctionService as t, PLUGIN_CONFIG_KEY_BASE as u };
|
|
@@ -49,6 +49,8 @@ export declare class TriggerCalculationController extends Disposable {
|
|
|
49
49
|
private _getCalculationMode;
|
|
50
50
|
private _commandExecutedListener;
|
|
51
51
|
private _initialExecuteFormulaProcessListener;
|
|
52
|
+
private _updateCalculationProgress;
|
|
53
|
+
private _getCalculationResultMessage;
|
|
52
54
|
private _initialExecuteFormula;
|
|
53
55
|
private _getDirtyDataByCalculationMode;
|
|
54
56
|
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -28,6 +28,3 @@ export { UniverSheetsFormulaPlugin } from './plugin';
|
|
|
28
28
|
export { FormulaRefRangeService } from './services/formula-ref-range.service';
|
|
29
29
|
export { IRemoteRegisterFunctionService, RemoteRegisterFunctionService, } from './services/remote/remote-register-function.service';
|
|
30
30
|
export { calculateFormula } from './util/calculate';
|
|
31
|
-
export {
|
|
32
|
-
/** @deprecated Import from '@univerjs/sheets-formula/worker' instead. This root export will be removed in the next release. */
|
|
33
|
-
UniverRemoteSheetsFormulaPlugin, } from './worker';
|
|
@@ -40,4 +40,12 @@ export declare class FormulaRefRangeService extends Disposable {
|
|
|
40
40
|
registerFormula(unitId: string, subUnitId: string, formula: string, callback: FormulaChangeCallback): IDisposable;
|
|
41
41
|
private _getFormulaDependcy;
|
|
42
42
|
registerRangeFormula(unitId: string, subUnitId: string, oldRanges: IRange[], formulas: string[], callback: RangeFormulaChangeCallback): IDisposable;
|
|
43
|
+
/**
|
|
44
|
+
* A whole column/row/sheet range keeps its anchor, so it is adjusted as a single range:
|
|
45
|
+
* segmenting it would both split the rule and drop the range type.
|
|
46
|
+
*
|
|
47
|
+
* @returns the single rule range to apply, or `undefined` when the regular segmentation applies
|
|
48
|
+
*/
|
|
49
|
+
private _transformWholeRangeFormulas;
|
|
50
|
+
private _appendInsertedBlockItems;
|
|
43
51
|
}
|