@univerjs/sheets 0.22.1 → 0.23.0-insiders.20260522-e8f2a3b

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 CHANGED
@@ -3334,7 +3334,6 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
3334
3334
  * Sets the frozen state of the current sheet.
3335
3335
  * @param {IFreeze} freeze - the scrolling viewport start range and count of freezed rows and columns.
3336
3336
  * that means if you want to freeze the first 3 rows and 2 columns, you should set freeze as { startRow: 3, startColumn: 2, xSplit: 2, ySplit: 3 }
3337
- * @deprecated use `setFrozenRows` and `setFrozenColumns` instead.
3338
3337
  * @returns {FWorksheet} This worksheet instance for chaining
3339
3338
  * @example
3340
3339
  * ```typescript
@@ -3349,7 +3348,6 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
3349
3348
  * ```
3350
3349
  */
3351
3350
  setFreeze(freeze) {
3352
- this._logService.warn("setFreeze is deprecated, use setFrozenRows and setFrozenColumns instead");
3353
3351
  this._commandService.syncExecuteCommand(_univerjs_sheets.SetFrozenCommand.id, {
3354
3352
  ...freeze,
3355
3353
  unitId: this._workbook.getUnitId(),
@@ -3605,28 +3603,6 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
3605
3603
  return this._worksheet.getTabColor();
3606
3604
  }
3607
3605
  /**
3608
- * @deprecated use `univerAPI.addEvent(univerAPI.Event.SheetValueChanged, (params) => {})` instead
3609
- */
3610
- onCellDataChange(callback) {
3611
- return this._injector.get(_univerjs_core.ICommandService).onCommandExecuted((command) => {
3612
- if (command.id === _univerjs_sheets.SetRangeValuesMutation.id) {
3613
- const params = command.params;
3614
- if (params.unitId === this._workbook.getUnitId() && params.subUnitId === this._worksheet.getSheetId() && params.cellValue) callback(new _univerjs_core.ObjectMatrix(params.cellValue));
3615
- }
3616
- });
3617
- }
3618
- /**
3619
- * @deprecated use `univerAPI.addEvent(univerAPI.Event.BeforeSheetEditEnd, (params) => {})` instead
3620
- */
3621
- onBeforeCellDataChange(callback) {
3622
- return this._injector.get(_univerjs_core.ICommandService).beforeCommandExecuted((command) => {
3623
- if (command.id === _univerjs_sheets.SetRangeValuesMutation.id) {
3624
- const params = command.params;
3625
- if (params.unitId === this._workbook.getUnitId() && params.subUnitId === this._worksheet.getSheetId() && params.cellValue) callback(new _univerjs_core.ObjectMatrix(params.cellValue));
3626
- }
3627
- });
3628
- }
3629
- /**
3630
3606
  * Hides this sheet. Has no effect if the sheet is already hidden. If this method is called on the only visible sheet, it throws an exception.
3631
3607
  * @returns {FWorksheet} Returns the current worksheet instance for method chaining
3632
3608
  * @example
@@ -3822,7 +3798,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
3822
3798
  }
3823
3799
  /**
3824
3800
  * Returns a Range corresponding to the dimensions in which data is present.
3825
- * This is functionally equivalent to creating a Range bounded by A1 and (Sheet.getLastColumn(), Sheet.getLastRow()).
3801
+ * Empty cells with style or formatting will also be included in the data range. If there is no data on the sheet, returns a Range corresponding to the top-left cell of the sheet (A1).
3826
3802
  * @returns {FRange} The range of the data in the sheet.
3827
3803
  * @example
3828
3804
  * ```ts
@@ -3839,14 +3815,6 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
3839
3815
  return this.getRange(startRow, startColumn, endRow - startRow + 1, endColumn - startColumn + 1);
3840
3816
  }
3841
3817
  /**
3842
- * @deprecated use `getLastColumn` instead.
3843
- * Returns the column index of the last column that contains content.
3844
- * @returns {number} the column index of the last column that contains content.
3845
- */
3846
- getLastColumns() {
3847
- return this._worksheet.getLastColumnWithContent();
3848
- }
3849
- /**
3850
3818
  * Returns the column index of the last column that contains content.
3851
3819
  * @returns {number} the column index of the last column that contains content.
3852
3820
  * @example
@@ -3863,14 +3831,6 @@ let FWorksheet = _FWorksheet = class FWorksheet extends _univerjs_core_facade.FB
3863
3831
  return this._worksheet.getLastColumnWithContent();
3864
3832
  }
3865
3833
  /**
3866
- * @deprecated use `getLastRow` instead.
3867
- * Returns the row index of the last row that contains content.
3868
- * @returns {number} the row index of the last row that contains content.
3869
- */
3870
- getLastRows() {
3871
- return this._worksheet.getLastRowWithContent();
3872
- }
3873
- /**
3874
3834
  * Returns the row index of the last row that contains content.
3875
3835
  * @returns {number} the row index of the last row that contains content.
3876
3836
  * @example
package/lib/cjs/index.js CHANGED
@@ -235,9 +235,8 @@ let SheetInterceptorService = class SheetInterceptorService extends _univerjs_co
235
235
  _defineProperty(this, "_afterCommandInterceptors", []);
236
236
  _defineProperty(this, "_workbookDisposables", /* @__PURE__ */ new Map());
237
237
  _defineProperty(this, "_worksheetDisposables", /* @__PURE__ */ new Map());
238
- _defineProperty(this, "_interceptorsDirty", false);
239
238
  _defineProperty(this, "_composedInterceptorByKey", /* @__PURE__ */ new Map());
240
- _defineProperty(this, "_composedInterceptorsLengthByKey", /* @__PURE__ */ new Map());
239
+ _defineProperty(this, "_composedInterceptorVersion", 0);
241
240
  _defineProperty(this, "writeCellInterceptor", new _univerjs_core.InterceptorManager({
242
241
  BEFORE_CELL_EDIT,
243
242
  AFTER_CELL_EDIT,
@@ -272,6 +271,7 @@ let SheetInterceptorService = class SheetInterceptorService extends _univerjs_co
272
271
  this._worksheetDisposables.forEach((disposable) => disposable.dispose());
273
272
  this._worksheetDisposables.clear();
274
273
  this._interceptorsByName.clear();
274
+ this._composedInterceptorByKey.clear();
275
275
  }
276
276
  /**
277
277
  * Add a listener function to a specific command to add affiliated mutations. It should be called in controllers.
@@ -437,7 +437,7 @@ let SheetInterceptorService = class SheetInterceptorService extends _univerjs_co
437
437
  var _b$priority6, _a$priority6;
438
438
  return ((_b$priority6 = b.priority) !== null && _b$priority6 !== void 0 ? _b$priority6 : 0) - ((_a$priority6 = a.priority) !== null && _a$priority6 !== void 0 ? _a$priority6 : 0);
439
439
  });
440
- this._interceptorsDirty = true;
440
+ this._invalidateComposedInterceptors();
441
441
  if (key === INTERCEPTOR_POINT.CELL_CONTENT) {
442
442
  const JOINED_EFFECT = _univerjs_core.InterceptorEffectEnum.Style | _univerjs_core.InterceptorEffectEnum.Value;
443
443
  this._interceptorsByName.set(`${key}-${JOINED_EFFECT}`, sortedInterceptors);
@@ -449,27 +449,44 @@ let SheetInterceptorService = class SheetInterceptorService extends _univerjs_co
449
449
  (0, _univerjs_core.remove)(this._interceptorsByName.get(`${key}-${JOINED_EFFECT}`), interceptor);
450
450
  (0, _univerjs_core.remove)(this._interceptorsByName.get(`${key}-${_univerjs_core.InterceptorEffectEnum.Style}`), interceptor);
451
451
  (0, _univerjs_core.remove)(this._interceptorsByName.get(`${key}-${_univerjs_core.InterceptorEffectEnum.Value}`), interceptor);
452
+ this._invalidateComposedInterceptors();
452
453
  }));
453
454
  } else {
454
455
  this._interceptorsByName.set(key, sortedInterceptors);
455
- return this.disposeWithMe((0, _univerjs_core.toDisposable)(() => (0, _univerjs_core.remove)(this._interceptorsByName.get(key), interceptor)));
456
+ return this.disposeWithMe((0, _univerjs_core.toDisposable)(() => {
457
+ (0, _univerjs_core.remove)(this._interceptorsByName.get(key), interceptor);
458
+ this._invalidateComposedInterceptors();
459
+ }));
456
460
  }
457
461
  }
458
462
  fetchThroughInterceptors(name, effect, _key, filter) {
459
- var _this$_interceptorsBy;
460
463
  const byNamesKey = effect === void 0 ? name : `${name}-${effect}`;
461
464
  const key = _key !== null && _key !== void 0 ? _key : byNamesKey;
462
465
  let composed = this._composedInterceptorByKey.get(key);
463
- const composedInterceptorsLength = this._composedInterceptorsLengthByKey.get(key) || 0;
464
- if (!composed || !this._interceptorsDirty || composedInterceptorsLength !== (((_this$_interceptorsBy = this._interceptorsByName.get(byNamesKey)) === null || _this$_interceptorsBy === void 0 ? void 0 : _this$_interceptorsBy.length) || 0)) {
466
+ if (!composed) {
465
467
  let interceptors = this._interceptorsByName.get(byNamesKey);
466
468
  if (interceptors && filter) interceptors = interceptors.filter(filter);
467
469
  composed = (0, _univerjs_core.composeInterceptors)(interceptors || []);
468
470
  this._composedInterceptorByKey.set(key, composed);
469
- this._composedInterceptorsLengthByKey.set(key, (interceptors === null || interceptors === void 0 ? void 0 : interceptors.length) || 0);
470
471
  }
471
472
  return composed;
472
473
  }
474
+ _invalidateComposedInterceptors() {
475
+ this._composedInterceptorVersion += 1;
476
+ this._composedInterceptorByKey.clear();
477
+ }
478
+ _getCommonCellContentInterceptor(effect, cache) {
479
+ let composed = cache.get(effect);
480
+ if (!composed) {
481
+ composed = this.fetchThroughInterceptors(INTERCEPTOR_POINT.CELL_CONTENT, effect);
482
+ cache.set(effect, composed);
483
+ }
484
+ return composed;
485
+ }
486
+ _getCommonRowFilteredInterceptor(cache) {
487
+ if (!cache.interceptor) cache.interceptor = this.fetchThroughInterceptors(INTERCEPTOR_POINT.ROW_FILTERED);
488
+ return cache.interceptor;
489
+ }
473
490
  _interceptWorkbook(workbook) {
474
491
  const disposables = new _univerjs_core.DisposableCollection();
475
492
  const unitId = workbook.getUnitId();
@@ -478,10 +495,14 @@ let SheetInterceptorService = class SheetInterceptorService extends _univerjs_co
478
495
  const subUnitId = worksheet.getSheetId();
479
496
  worksheet.__interceptViewModel((viewModel) => {
480
497
  const sheetDisposables = new _univerjs_core.DisposableCollection();
498
+ const commonCellContentInterceptors = /* @__PURE__ */ new Map();
499
+ const commonRowFilteredInterceptor = { interceptor: null };
500
+ let commonCellContentInterceptorsVersion = -1;
501
+ let commonRowFilteredInterceptorVersion = -1;
481
502
  sheetInterceptorService._worksheetDisposables.set(getWorksheetDisposableID(unitId, worksheet), sheetDisposables);
482
503
  sheetDisposables.add(viewModel.registerCellContentInterceptor({ getCell(row, col, effect, key, filter) {
483
504
  const rawData = worksheet.getCellRaw(row, col);
484
- return sheetInterceptorService.fetchThroughInterceptors(INTERCEPTOR_POINT.CELL_CONTENT, effect, key, filter)(rawData, {
505
+ const context = {
485
506
  unitId,
486
507
  subUnitId,
487
508
  row,
@@ -489,10 +510,22 @@ let SheetInterceptorService = class SheetInterceptorService extends _univerjs_co
489
510
  worksheet,
490
511
  workbook,
491
512
  rawData
492
- });
513
+ };
514
+ if (key === void 0 && filter === void 0) {
515
+ if (commonCellContentInterceptorsVersion !== sheetInterceptorService._composedInterceptorVersion) {
516
+ commonCellContentInterceptors.clear();
517
+ commonCellContentInterceptorsVersion = sheetInterceptorService._composedInterceptorVersion;
518
+ }
519
+ return sheetInterceptorService._getCommonCellContentInterceptor(effect, commonCellContentInterceptors)(rawData, context);
520
+ }
521
+ return sheetInterceptorService.fetchThroughInterceptors(INTERCEPTOR_POINT.CELL_CONTENT, effect, key, filter)(rawData, context);
493
522
  } }));
494
523
  sheetDisposables.add(viewModel.registerRowFilteredInterceptor({ getRowFiltered(row) {
495
- return !!sheetInterceptorService.fetchThroughInterceptors(INTERCEPTOR_POINT.ROW_FILTERED)(false, {
524
+ if (commonRowFilteredInterceptorVersion !== sheetInterceptorService._composedInterceptorVersion) {
525
+ commonRowFilteredInterceptor.interceptor = null;
526
+ commonRowFilteredInterceptorVersion = sheetInterceptorService._composedInterceptorVersion;
527
+ }
528
+ return !!sheetInterceptorService._getCommonRowFilteredInterceptor(commonRowFilteredInterceptor)(false, {
496
529
  unitId,
497
530
  subUnitId,
498
531
  row,
@@ -18932,7 +18965,7 @@ let RangeProtectionCache = class RangeProtectionCache extends _univerjs_core.Dis
18932
18965
  });
18933
18966
  }
18934
18967
  _initUpdateCellInfoCache() {
18935
- this._permissionService.permissionPointUpdate$.pipe((0, rxjs.filter)((permission) => permission.type === _univerjs_protocol.UnitObject.SelectRange), (0, rxjs.map)((permission) => permission)).subscribe((permission) => {
18968
+ this.disposeWithMe(this._permissionService.permissionPointUpdate$.pipe((0, rxjs.filter)((permission) => permission.type === _univerjs_protocol.UnitObject.SelectRange), (0, rxjs.map)((permission) => permission)).subscribe((permission) => {
18936
18969
  const { subUnitId, unitId, permissionId } = permission;
18937
18970
  const ruleId = this._permissionIdCache.get(permissionId);
18938
18971
  if (!ruleId) return;
@@ -18943,8 +18976,8 @@ let RangeProtectionCache = class RangeProtectionCache extends _univerjs_core.Dis
18943
18976
  const { startRow, endRow, startColumn, endColumn } = range;
18944
18977
  for (let i = startRow; i <= endRow; i++) for (let j = startColumn; j <= endColumn; j++) cellInfoMap.delete(`${i}-${j}`);
18945
18978
  });
18946
- });
18947
- this._ruleModel.ruleChange$.subscribe((info) => {
18979
+ }));
18980
+ this.disposeWithMe(this._ruleModel.ruleChange$.subscribe((info) => {
18948
18981
  const { unitId, subUnitId } = info;
18949
18982
  const cellInfoMap = this._ensureCellInfoMap(unitId, subUnitId);
18950
18983
  info.rule.ranges.forEach((range) => {
@@ -18960,10 +18993,10 @@ let RangeProtectionCache = class RangeProtectionCache extends _univerjs_core.Dis
18960
18993
  });
18961
18994
  });
18962
18995
  }
18963
- });
18996
+ }));
18964
18997
  }
18965
18998
  _initUpdateCellRuleCache() {
18966
- this._ruleModel.ruleChange$.subscribe((ruleChange) => {
18999
+ this.disposeWithMe(this._ruleModel.ruleChange$.subscribe((ruleChange) => {
18967
19000
  const { type } = ruleChange;
18968
19001
  if (type === "add") this._addCellRuleCache(ruleChange);
18969
19002
  else if (type === "delete") this._deleteCellRuleCache(ruleChange);
@@ -18974,7 +19007,7 @@ let RangeProtectionCache = class RangeProtectionCache extends _univerjs_core.Dis
18974
19007
  });
18975
19008
  this._addCellRuleCache(ruleChange);
18976
19009
  }
18977
- });
19010
+ }));
18978
19011
  }
18979
19012
  _ensureRuleMap(unitId, subUnitId) {
18980
19013
  let subUnitMap = this._cellRuleCache.get(unitId);
@@ -19107,7 +19140,7 @@ let RangeProtectionCache = class RangeProtectionCache extends _univerjs_core.Dis
19107
19140
  });
19108
19141
  }
19109
19142
  _initUpdateRowColInfoCache() {
19110
- this._permissionService.permissionPointUpdate$.pipe((0, rxjs.filter)((permission) => permission.type === _univerjs_protocol.UnitObject.SelectRange), (0, rxjs.map)((permission) => permission)).subscribe({ next: (permission) => {
19143
+ this.disposeWithMe(this._permissionService.permissionPointUpdate$.pipe((0, rxjs.filter)((permission) => permission.type === _univerjs_protocol.UnitObject.SelectRange), (0, rxjs.map)((permission) => permission)).subscribe({ next: (permission) => {
19111
19144
  const { subUnitId, unitId, permissionId } = permission;
19112
19145
  const ruleId = this._permissionIdCache.get(permissionId);
19113
19146
  if (!ruleId) return;
@@ -19129,8 +19162,8 @@ let RangeProtectionCache = class RangeProtectionCache extends _univerjs_core.Dis
19129
19162
  }
19130
19163
  }
19131
19164
  });
19132
- } });
19133
- this._ruleModel.ruleChange$.subscribe((info) => {
19165
+ } }));
19166
+ this.disposeWithMe(this._ruleModel.ruleChange$.subscribe((info) => {
19134
19167
  if (info.type === "delete") {
19135
19168
  const { unitId, subUnitId, rule } = info;
19136
19169
  const rowInfoMap = this._ensureRowColInfoMap(unitId, subUnitId, "row");
@@ -19147,7 +19180,7 @@ let RangeProtectionCache = class RangeProtectionCache extends _univerjs_core.Dis
19147
19180
  }
19148
19181
  });
19149
19182
  }
19150
- });
19183
+ }));
19151
19184
  }
19152
19185
  getCellInfo(unitId, subUnitId, row, col) {
19153
19186
  var _this$_cellRuleCache$;
@@ -19190,7 +19223,7 @@ RangeProtectionCache = __decorate([
19190
19223
  //#endregion
19191
19224
  //#region package.json
19192
19225
  var name = "@univerjs/sheets";
19193
- var version = "0.22.1";
19226
+ var version = "0.23.0-insiders.20260522-e8f2a3b";
19194
19227
 
19195
19228
  //#endregion
19196
19229
  //#region src/controllers/active-worksheet.controller.ts
package/lib/es/facade.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { BooleanNumber, CanceledError, DEFAULT_STYLES, Dimension, Direction, HorizontalAlign, IAuthzIoService, ICommandService, ILogService, IPermissionService, IResourceLoaderService, IUniverInstanceService, Inject, Injector, LocaleService, ObjectMatrix, RANGE_TYPE, Rectangle, RedoCommand, RichTextValue, TextStyleValue, Tools, UndoCommand, UniverInstanceType, VerticalAlign, WrapStrategy, cellToRange, covertCellValue, covertCellValues, generateIntervalsByPoints, generateRandomId, isNullCell, mergeWorksheetSnapshotWithDefault, toDisposable } from "@univerjs/core";
2
2
  import { FBase, FBaseInitialable, FEnum, FEventName, FUniver } from "@univerjs/core/facade";
3
- import { AddRangeProtectionMutation, AddWorksheetProtectionMutation, AppendRowCommand, AutoFillCommand, COMMAND_LISTENER_VALUE_CHANGE, CancelFrozenCommand, ClearSelectionAllCommand, ClearSelectionContentCommand, ClearSelectionFormatCommand, CopySheetCommand, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, DeleteRangeProtectionMutation, DeleteWorksheetProtectionMutation, DeleteWorksheetRangeThemeStyleCommand, EditStateEnum, InsertColByRangeCommand, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, InsertRowByRangeCommand, InsertSheetCommand, MoveColsCommand, MoveRowsCommand, RangeProtectionPermissionDeleteProtectionPoint, RangeProtectionPermissionEditPoint, RangeProtectionPermissionManageCollaPoint, RangeProtectionPermissionViewPoint, RangeProtectionRuleModel, RangeThemeStyle, RegisterWorksheetRangeThemeStyleCommand, RemoveColByRangeCommand, RemoveDefinedNameCommand, RemoveRowByRangeCommand, RemoveSheetCommand, RemoveWorksheetMergeCommand, SCOPE_WORKBOOK_VALUE_DEFINED_NAME, SetBorderBasicCommand, SetColDataCommand, SetColHiddenCommand, SetColWidthCommand, SetDefinedNameCommand, SetFrozenCommand, SetGridlinesColorCommand, SetHorizontalTextAlignCommand, SetRangeCustomMetadataCommand, SetRangeProtectionMutation, SetRangeValuesCommand, SetRangeValuesMutation, SetRowDataCommand, SetRowHeightCommand, SetRowHiddenCommand, SetSelectionsOperation, SetSpecificColsVisibleCommand, SetSpecificRowsVisibleCommand, SetStyleCommand, SetTabColorCommand, SetTabColorMutation, SetTextRotationCommand, SetTextWrapCommand, SetVerticalTextAlignCommand, SetWorkbookNameCommand, SetWorksheetActiveOperation, SetWorksheetColumnCountCommand, SetWorksheetDefaultStyleMutation, SetWorksheetHideCommand, SetWorksheetHideMutation, SetWorksheetNameCommand, SetWorksheetOrderCommand, SetWorksheetOrderMutation, SetWorksheetRangeThemeStyleCommand, SetWorksheetRowCountCommand, SetWorksheetRowIsAutoHeightCommand, SetWorksheetRowIsAutoHeightMutation, SetWorksheetShowCommand, SheetRangeThemeService, SheetSkeletonChangeType, SheetValueChangeType, SheetsFreezeSyncController, SheetsSelectionsService, SplitDelimiterEnum, SplitTextToColumnsCommand, ToggleGridlinesCommand, UnitObject, UnregisterWorksheetRangeThemeStyleCommand, ViewStateEnum, WorkbookCommentPermission, WorkbookCopyPermission, WorkbookCopySheetPermission, WorkbookCreateProtectPermission, WorkbookCreateSheetPermission, WorkbookDeleteColumnPermission, WorkbookDeleteRowPermission, WorkbookDeleteSheetPermission, WorkbookDuplicatePermission, WorkbookEditablePermission, WorkbookExportPermission, WorkbookHideSheetPermission, WorkbookInsertColumnPermission, WorkbookInsertRowPermission, WorkbookManageCollaboratorPermission, WorkbookMoveSheetPermission, WorkbookPrintPermission, WorkbookRecoverHistoryPermission, WorkbookRenameSheetPermission, WorkbookSharePermission, WorkbookViewHistoryPermission, WorkbookViewPermission, WorksheetCopyPermission, WorksheetDeleteColumnPermission, WorksheetDeleteProtectionPermission, WorksheetDeleteRowPermission, WorksheetEditExtraObjectPermission, WorksheetEditPermission, WorksheetFilterPermission, WorksheetInsertColumnPermission, WorksheetInsertHyperlinkPermission, WorksheetInsertRowPermission, WorksheetManageCollaboratorPermission, WorksheetPivotTablePermission, WorksheetProtectionPointModel, WorksheetProtectionRuleModel, WorksheetSelectProtectedCellsPermission, WorksheetSelectUnProtectedCellsPermission, WorksheetSetCellStylePermission, WorksheetSetCellValuePermission, WorksheetSetColumnStylePermission, WorksheetSetRowStylePermission, WorksheetSortPermission, WorksheetViewPermission, addMergeCellsUtil, copyRangeStyles, getAddMergeMutationRangeByType, getAllWorksheetPermissionPoint, getAllWorksheetPermissionPointByPointPanel, getNextPrimaryCell, getPrimaryForRange, getValueChangedEffectedRange, validateDefinedName } from "@univerjs/sheets";
3
+ import { AddRangeProtectionMutation, AddWorksheetProtectionMutation, AppendRowCommand, AutoFillCommand, COMMAND_LISTENER_VALUE_CHANGE, CancelFrozenCommand, ClearSelectionAllCommand, ClearSelectionContentCommand, ClearSelectionFormatCommand, CopySheetCommand, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, DeleteRangeProtectionMutation, DeleteWorksheetProtectionMutation, DeleteWorksheetRangeThemeStyleCommand, EditStateEnum, InsertColByRangeCommand, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, InsertRowByRangeCommand, InsertSheetCommand, MoveColsCommand, MoveRowsCommand, RangeProtectionPermissionDeleteProtectionPoint, RangeProtectionPermissionEditPoint, RangeProtectionPermissionManageCollaPoint, RangeProtectionPermissionViewPoint, RangeProtectionRuleModel, RangeThemeStyle, RegisterWorksheetRangeThemeStyleCommand, RemoveColByRangeCommand, RemoveDefinedNameCommand, RemoveRowByRangeCommand, RemoveSheetCommand, RemoveWorksheetMergeCommand, SCOPE_WORKBOOK_VALUE_DEFINED_NAME, SetBorderBasicCommand, SetColDataCommand, SetColHiddenCommand, SetColWidthCommand, SetDefinedNameCommand, SetFrozenCommand, SetGridlinesColorCommand, SetHorizontalTextAlignCommand, SetRangeCustomMetadataCommand, SetRangeProtectionMutation, SetRangeValuesCommand, SetRowDataCommand, SetRowHeightCommand, SetRowHiddenCommand, SetSelectionsOperation, SetSpecificColsVisibleCommand, SetSpecificRowsVisibleCommand, SetStyleCommand, SetTabColorCommand, SetTabColorMutation, SetTextRotationCommand, SetTextWrapCommand, SetVerticalTextAlignCommand, SetWorkbookNameCommand, SetWorksheetActiveOperation, SetWorksheetColumnCountCommand, SetWorksheetDefaultStyleMutation, SetWorksheetHideCommand, SetWorksheetHideMutation, SetWorksheetNameCommand, SetWorksheetOrderCommand, SetWorksheetOrderMutation, SetWorksheetRangeThemeStyleCommand, SetWorksheetRowCountCommand, SetWorksheetRowIsAutoHeightCommand, SetWorksheetRowIsAutoHeightMutation, SetWorksheetShowCommand, SheetRangeThemeService, SheetSkeletonChangeType, SheetValueChangeType, SheetsFreezeSyncController, SheetsSelectionsService, SplitDelimiterEnum, SplitTextToColumnsCommand, ToggleGridlinesCommand, UnitObject, UnregisterWorksheetRangeThemeStyleCommand, ViewStateEnum, WorkbookCommentPermission, WorkbookCopyPermission, WorkbookCopySheetPermission, WorkbookCreateProtectPermission, WorkbookCreateSheetPermission, WorkbookDeleteColumnPermission, WorkbookDeleteRowPermission, WorkbookDeleteSheetPermission, WorkbookDuplicatePermission, WorkbookEditablePermission, WorkbookExportPermission, WorkbookHideSheetPermission, WorkbookInsertColumnPermission, WorkbookInsertRowPermission, WorkbookManageCollaboratorPermission, WorkbookMoveSheetPermission, WorkbookPrintPermission, WorkbookRecoverHistoryPermission, WorkbookRenameSheetPermission, WorkbookSharePermission, WorkbookViewHistoryPermission, WorkbookViewPermission, WorksheetCopyPermission, WorksheetDeleteColumnPermission, WorksheetDeleteProtectionPermission, WorksheetDeleteRowPermission, WorksheetEditExtraObjectPermission, WorksheetEditPermission, WorksheetFilterPermission, WorksheetInsertColumnPermission, WorksheetInsertHyperlinkPermission, WorksheetInsertRowPermission, WorksheetManageCollaboratorPermission, WorksheetPivotTablePermission, WorksheetProtectionPointModel, WorksheetProtectionRuleModel, WorksheetSelectProtectedCellsPermission, WorksheetSelectUnProtectedCellsPermission, WorksheetSetCellStylePermission, WorksheetSetCellValuePermission, WorksheetSetColumnStylePermission, WorksheetSetRowStylePermission, WorksheetSortPermission, WorksheetViewPermission, addMergeCellsUtil, copyRangeStyles, getAddMergeMutationRangeByType, getAllWorksheetPermissionPoint, getAllWorksheetPermissionPointByPointPanel, getNextPrimaryCell, getPrimaryForRange, getValueChangedEffectedRange, validateDefinedName } from "@univerjs/sheets";
4
4
  import { FormulaDataModel, IDefinedNamesService, IFunctionService, ISuperTableService, deserializeRangeWithSheet, serializeRange, serializeRangeWithSheet } from "@univerjs/engine-formula";
5
5
  import { ObjectScope, UnitAction, UnitObject as UnitObject$1, UnitRole } from "@univerjs/protocol";
6
6
 
@@ -3333,7 +3333,6 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
3333
3333
  * Sets the frozen state of the current sheet.
3334
3334
  * @param {IFreeze} freeze - the scrolling viewport start range and count of freezed rows and columns.
3335
3335
  * that means if you want to freeze the first 3 rows and 2 columns, you should set freeze as { startRow: 3, startColumn: 2, xSplit: 2, ySplit: 3 }
3336
- * @deprecated use `setFrozenRows` and `setFrozenColumns` instead.
3337
3336
  * @returns {FWorksheet} This worksheet instance for chaining
3338
3337
  * @example
3339
3338
  * ```typescript
@@ -3348,7 +3347,6 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
3348
3347
  * ```
3349
3348
  */
3350
3349
  setFreeze(freeze) {
3351
- this._logService.warn("setFreeze is deprecated, use setFrozenRows and setFrozenColumns instead");
3352
3350
  this._commandService.syncExecuteCommand(SetFrozenCommand.id, {
3353
3351
  ...freeze,
3354
3352
  unitId: this._workbook.getUnitId(),
@@ -3604,28 +3602,6 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
3604
3602
  return this._worksheet.getTabColor();
3605
3603
  }
3606
3604
  /**
3607
- * @deprecated use `univerAPI.addEvent(univerAPI.Event.SheetValueChanged, (params) => {})` instead
3608
- */
3609
- onCellDataChange(callback) {
3610
- return this._injector.get(ICommandService).onCommandExecuted((command) => {
3611
- if (command.id === SetRangeValuesMutation.id) {
3612
- const params = command.params;
3613
- if (params.unitId === this._workbook.getUnitId() && params.subUnitId === this._worksheet.getSheetId() && params.cellValue) callback(new ObjectMatrix(params.cellValue));
3614
- }
3615
- });
3616
- }
3617
- /**
3618
- * @deprecated use `univerAPI.addEvent(univerAPI.Event.BeforeSheetEditEnd, (params) => {})` instead
3619
- */
3620
- onBeforeCellDataChange(callback) {
3621
- return this._injector.get(ICommandService).beforeCommandExecuted((command) => {
3622
- if (command.id === SetRangeValuesMutation.id) {
3623
- const params = command.params;
3624
- if (params.unitId === this._workbook.getUnitId() && params.subUnitId === this._worksheet.getSheetId() && params.cellValue) callback(new ObjectMatrix(params.cellValue));
3625
- }
3626
- });
3627
- }
3628
- /**
3629
3605
  * Hides this sheet. Has no effect if the sheet is already hidden. If this method is called on the only visible sheet, it throws an exception.
3630
3606
  * @returns {FWorksheet} Returns the current worksheet instance for method chaining
3631
3607
  * @example
@@ -3821,7 +3797,7 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
3821
3797
  }
3822
3798
  /**
3823
3799
  * Returns a Range corresponding to the dimensions in which data is present.
3824
- * This is functionally equivalent to creating a Range bounded by A1 and (Sheet.getLastColumn(), Sheet.getLastRow()).
3800
+ * Empty cells with style or formatting will also be included in the data range. If there is no data on the sheet, returns a Range corresponding to the top-left cell of the sheet (A1).
3825
3801
  * @returns {FRange} The range of the data in the sheet.
3826
3802
  * @example
3827
3803
  * ```ts
@@ -3838,14 +3814,6 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
3838
3814
  return this.getRange(startRow, startColumn, endRow - startRow + 1, endColumn - startColumn + 1);
3839
3815
  }
3840
3816
  /**
3841
- * @deprecated use `getLastColumn` instead.
3842
- * Returns the column index of the last column that contains content.
3843
- * @returns {number} the column index of the last column that contains content.
3844
- */
3845
- getLastColumns() {
3846
- return this._worksheet.getLastColumnWithContent();
3847
- }
3848
- /**
3849
3817
  * Returns the column index of the last column that contains content.
3850
3818
  * @returns {number} the column index of the last column that contains content.
3851
3819
  * @example
@@ -3862,14 +3830,6 @@ let FWorksheet = _FWorksheet = class FWorksheet extends FBaseInitialable {
3862
3830
  return this._worksheet.getLastColumnWithContent();
3863
3831
  }
3864
3832
  /**
3865
- * @deprecated use `getLastRow` instead.
3866
- * Returns the row index of the last row that contains content.
3867
- * @returns {number} the row index of the last row that contains content.
3868
- */
3869
- getLastRows() {
3870
- return this._worksheet.getLastRowWithContent();
3871
- }
3872
- /**
3873
3833
  * Returns the row index of the last row that contains content.
3874
3834
  * @returns {number} the row index of the last row that contains content.
3875
3835
  * @example
package/lib/es/index.js CHANGED
@@ -234,9 +234,8 @@ let SheetInterceptorService = class SheetInterceptorService extends Disposable {
234
234
  _defineProperty(this, "_afterCommandInterceptors", []);
235
235
  _defineProperty(this, "_workbookDisposables", /* @__PURE__ */ new Map());
236
236
  _defineProperty(this, "_worksheetDisposables", /* @__PURE__ */ new Map());
237
- _defineProperty(this, "_interceptorsDirty", false);
238
237
  _defineProperty(this, "_composedInterceptorByKey", /* @__PURE__ */ new Map());
239
- _defineProperty(this, "_composedInterceptorsLengthByKey", /* @__PURE__ */ new Map());
238
+ _defineProperty(this, "_composedInterceptorVersion", 0);
240
239
  _defineProperty(this, "writeCellInterceptor", new InterceptorManager({
241
240
  BEFORE_CELL_EDIT,
242
241
  AFTER_CELL_EDIT,
@@ -271,6 +270,7 @@ let SheetInterceptorService = class SheetInterceptorService extends Disposable {
271
270
  this._worksheetDisposables.forEach((disposable) => disposable.dispose());
272
271
  this._worksheetDisposables.clear();
273
272
  this._interceptorsByName.clear();
273
+ this._composedInterceptorByKey.clear();
274
274
  }
275
275
  /**
276
276
  * Add a listener function to a specific command to add affiliated mutations. It should be called in controllers.
@@ -436,7 +436,7 @@ let SheetInterceptorService = class SheetInterceptorService extends Disposable {
436
436
  var _b$priority6, _a$priority6;
437
437
  return ((_b$priority6 = b.priority) !== null && _b$priority6 !== void 0 ? _b$priority6 : 0) - ((_a$priority6 = a.priority) !== null && _a$priority6 !== void 0 ? _a$priority6 : 0);
438
438
  });
439
- this._interceptorsDirty = true;
439
+ this._invalidateComposedInterceptors();
440
440
  if (key === INTERCEPTOR_POINT.CELL_CONTENT) {
441
441
  const JOINED_EFFECT = InterceptorEffectEnum.Style | InterceptorEffectEnum.Value;
442
442
  this._interceptorsByName.set(`${key}-${JOINED_EFFECT}`, sortedInterceptors);
@@ -448,27 +448,44 @@ let SheetInterceptorService = class SheetInterceptorService extends Disposable {
448
448
  remove(this._interceptorsByName.get(`${key}-${JOINED_EFFECT}`), interceptor);
449
449
  remove(this._interceptorsByName.get(`${key}-${InterceptorEffectEnum.Style}`), interceptor);
450
450
  remove(this._interceptorsByName.get(`${key}-${InterceptorEffectEnum.Value}`), interceptor);
451
+ this._invalidateComposedInterceptors();
451
452
  }));
452
453
  } else {
453
454
  this._interceptorsByName.set(key, sortedInterceptors);
454
- return this.disposeWithMe(toDisposable(() => remove(this._interceptorsByName.get(key), interceptor)));
455
+ return this.disposeWithMe(toDisposable(() => {
456
+ remove(this._interceptorsByName.get(key), interceptor);
457
+ this._invalidateComposedInterceptors();
458
+ }));
455
459
  }
456
460
  }
457
461
  fetchThroughInterceptors(name, effect, _key, filter) {
458
- var _this$_interceptorsBy;
459
462
  const byNamesKey = effect === void 0 ? name : `${name}-${effect}`;
460
463
  const key = _key !== null && _key !== void 0 ? _key : byNamesKey;
461
464
  let composed = this._composedInterceptorByKey.get(key);
462
- const composedInterceptorsLength = this._composedInterceptorsLengthByKey.get(key) || 0;
463
- if (!composed || !this._interceptorsDirty || composedInterceptorsLength !== (((_this$_interceptorsBy = this._interceptorsByName.get(byNamesKey)) === null || _this$_interceptorsBy === void 0 ? void 0 : _this$_interceptorsBy.length) || 0)) {
465
+ if (!composed) {
464
466
  let interceptors = this._interceptorsByName.get(byNamesKey);
465
467
  if (interceptors && filter) interceptors = interceptors.filter(filter);
466
468
  composed = composeInterceptors(interceptors || []);
467
469
  this._composedInterceptorByKey.set(key, composed);
468
- this._composedInterceptorsLengthByKey.set(key, (interceptors === null || interceptors === void 0 ? void 0 : interceptors.length) || 0);
469
470
  }
470
471
  return composed;
471
472
  }
473
+ _invalidateComposedInterceptors() {
474
+ this._composedInterceptorVersion += 1;
475
+ this._composedInterceptorByKey.clear();
476
+ }
477
+ _getCommonCellContentInterceptor(effect, cache) {
478
+ let composed = cache.get(effect);
479
+ if (!composed) {
480
+ composed = this.fetchThroughInterceptors(INTERCEPTOR_POINT.CELL_CONTENT, effect);
481
+ cache.set(effect, composed);
482
+ }
483
+ return composed;
484
+ }
485
+ _getCommonRowFilteredInterceptor(cache) {
486
+ if (!cache.interceptor) cache.interceptor = this.fetchThroughInterceptors(INTERCEPTOR_POINT.ROW_FILTERED);
487
+ return cache.interceptor;
488
+ }
472
489
  _interceptWorkbook(workbook) {
473
490
  const disposables = new DisposableCollection();
474
491
  const unitId = workbook.getUnitId();
@@ -477,10 +494,14 @@ let SheetInterceptorService = class SheetInterceptorService extends Disposable {
477
494
  const subUnitId = worksheet.getSheetId();
478
495
  worksheet.__interceptViewModel((viewModel) => {
479
496
  const sheetDisposables = new DisposableCollection();
497
+ const commonCellContentInterceptors = /* @__PURE__ */ new Map();
498
+ const commonRowFilteredInterceptor = { interceptor: null };
499
+ let commonCellContentInterceptorsVersion = -1;
500
+ let commonRowFilteredInterceptorVersion = -1;
480
501
  sheetInterceptorService._worksheetDisposables.set(getWorksheetDisposableID(unitId, worksheet), sheetDisposables);
481
502
  sheetDisposables.add(viewModel.registerCellContentInterceptor({ getCell(row, col, effect, key, filter) {
482
503
  const rawData = worksheet.getCellRaw(row, col);
483
- return sheetInterceptorService.fetchThroughInterceptors(INTERCEPTOR_POINT.CELL_CONTENT, effect, key, filter)(rawData, {
504
+ const context = {
484
505
  unitId,
485
506
  subUnitId,
486
507
  row,
@@ -488,10 +509,22 @@ let SheetInterceptorService = class SheetInterceptorService extends Disposable {
488
509
  worksheet,
489
510
  workbook,
490
511
  rawData
491
- });
512
+ };
513
+ if (key === void 0 && filter === void 0) {
514
+ if (commonCellContentInterceptorsVersion !== sheetInterceptorService._composedInterceptorVersion) {
515
+ commonCellContentInterceptors.clear();
516
+ commonCellContentInterceptorsVersion = sheetInterceptorService._composedInterceptorVersion;
517
+ }
518
+ return sheetInterceptorService._getCommonCellContentInterceptor(effect, commonCellContentInterceptors)(rawData, context);
519
+ }
520
+ return sheetInterceptorService.fetchThroughInterceptors(INTERCEPTOR_POINT.CELL_CONTENT, effect, key, filter)(rawData, context);
492
521
  } }));
493
522
  sheetDisposables.add(viewModel.registerRowFilteredInterceptor({ getRowFiltered(row) {
494
- return !!sheetInterceptorService.fetchThroughInterceptors(INTERCEPTOR_POINT.ROW_FILTERED)(false, {
523
+ if (commonRowFilteredInterceptorVersion !== sheetInterceptorService._composedInterceptorVersion) {
524
+ commonRowFilteredInterceptor.interceptor = null;
525
+ commonRowFilteredInterceptorVersion = sheetInterceptorService._composedInterceptorVersion;
526
+ }
527
+ return !!sheetInterceptorService._getCommonRowFilteredInterceptor(commonRowFilteredInterceptor)(false, {
495
528
  unitId,
496
529
  subUnitId,
497
530
  row,
@@ -18931,7 +18964,7 @@ let RangeProtectionCache = class RangeProtectionCache extends Disposable {
18931
18964
  });
18932
18965
  }
18933
18966
  _initUpdateCellInfoCache() {
18934
- this._permissionService.permissionPointUpdate$.pipe(filter((permission) => permission.type === UnitObject$1.SelectRange), map((permission) => permission)).subscribe((permission) => {
18967
+ this.disposeWithMe(this._permissionService.permissionPointUpdate$.pipe(filter((permission) => permission.type === UnitObject$1.SelectRange), map((permission) => permission)).subscribe((permission) => {
18935
18968
  const { subUnitId, unitId, permissionId } = permission;
18936
18969
  const ruleId = this._permissionIdCache.get(permissionId);
18937
18970
  if (!ruleId) return;
@@ -18942,8 +18975,8 @@ let RangeProtectionCache = class RangeProtectionCache extends Disposable {
18942
18975
  const { startRow, endRow, startColumn, endColumn } = range;
18943
18976
  for (let i = startRow; i <= endRow; i++) for (let j = startColumn; j <= endColumn; j++) cellInfoMap.delete(`${i}-${j}`);
18944
18977
  });
18945
- });
18946
- this._ruleModel.ruleChange$.subscribe((info) => {
18978
+ }));
18979
+ this.disposeWithMe(this._ruleModel.ruleChange$.subscribe((info) => {
18947
18980
  const { unitId, subUnitId } = info;
18948
18981
  const cellInfoMap = this._ensureCellInfoMap(unitId, subUnitId);
18949
18982
  info.rule.ranges.forEach((range) => {
@@ -18959,10 +18992,10 @@ let RangeProtectionCache = class RangeProtectionCache extends Disposable {
18959
18992
  });
18960
18993
  });
18961
18994
  }
18962
- });
18995
+ }));
18963
18996
  }
18964
18997
  _initUpdateCellRuleCache() {
18965
- this._ruleModel.ruleChange$.subscribe((ruleChange) => {
18998
+ this.disposeWithMe(this._ruleModel.ruleChange$.subscribe((ruleChange) => {
18966
18999
  const { type } = ruleChange;
18967
19000
  if (type === "add") this._addCellRuleCache(ruleChange);
18968
19001
  else if (type === "delete") this._deleteCellRuleCache(ruleChange);
@@ -18973,7 +19006,7 @@ let RangeProtectionCache = class RangeProtectionCache extends Disposable {
18973
19006
  });
18974
19007
  this._addCellRuleCache(ruleChange);
18975
19008
  }
18976
- });
19009
+ }));
18977
19010
  }
18978
19011
  _ensureRuleMap(unitId, subUnitId) {
18979
19012
  let subUnitMap = this._cellRuleCache.get(unitId);
@@ -19106,7 +19139,7 @@ let RangeProtectionCache = class RangeProtectionCache extends Disposable {
19106
19139
  });
19107
19140
  }
19108
19141
  _initUpdateRowColInfoCache() {
19109
- this._permissionService.permissionPointUpdate$.pipe(filter((permission) => permission.type === UnitObject$1.SelectRange), map((permission) => permission)).subscribe({ next: (permission) => {
19142
+ this.disposeWithMe(this._permissionService.permissionPointUpdate$.pipe(filter((permission) => permission.type === UnitObject$1.SelectRange), map((permission) => permission)).subscribe({ next: (permission) => {
19110
19143
  const { subUnitId, unitId, permissionId } = permission;
19111
19144
  const ruleId = this._permissionIdCache.get(permissionId);
19112
19145
  if (!ruleId) return;
@@ -19128,8 +19161,8 @@ let RangeProtectionCache = class RangeProtectionCache extends Disposable {
19128
19161
  }
19129
19162
  }
19130
19163
  });
19131
- } });
19132
- this._ruleModel.ruleChange$.subscribe((info) => {
19164
+ } }));
19165
+ this.disposeWithMe(this._ruleModel.ruleChange$.subscribe((info) => {
19133
19166
  if (info.type === "delete") {
19134
19167
  const { unitId, subUnitId, rule } = info;
19135
19168
  const rowInfoMap = this._ensureRowColInfoMap(unitId, subUnitId, "row");
@@ -19146,7 +19179,7 @@ let RangeProtectionCache = class RangeProtectionCache extends Disposable {
19146
19179
  }
19147
19180
  });
19148
19181
  }
19149
- });
19182
+ }));
19150
19183
  }
19151
19184
  getCellInfo(unitId, subUnitId, row, col) {
19152
19185
  var _this$_cellRuleCache$;
@@ -19189,7 +19222,7 @@ RangeProtectionCache = __decorate([
19189
19222
  //#endregion
19190
19223
  //#region package.json
19191
19224
  var name = "@univerjs/sheets";
19192
- var version = "0.22.1";
19225
+ var version = "0.23.0-insiders.20260522-e8f2a3b";
19193
19226
 
19194
19227
  //#endregion
19195
19228
  //#region src/controllers/active-worksheet.controller.ts