@univerjs/sheets 0.12.2 → 0.12.3-experimental.20251205-e439e48

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.
@@ -1,16 +1,17 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { FRange } from '../f-range';
3
3
  import { FWorksheet } from '../f-worksheet';
4
- import { ICellPermissionDebugInfo, IRangeProtectionOptions, IRangeProtectionRule, IWorksheetPermission, IWorksheetPermissionConfig, UnsubscribeFn, WorksheetMode, WorksheetPermissionSnapshot, WorksheetPermissionPoint } from './permission-types';
4
+ import { IRangeProtectionOptions, IWorksheetPermissionConfig, IWorksheetProtectionOptions, UnsubscribeFn, WorksheetMode, WorksheetPermissionSnapshot, WorksheetPermissionPoint } from './permission-types';
5
5
  import { IAuthzIoService, ICommandService, Injector, IPermissionService } from '@univerjs/core';
6
- import { RangeProtectionRuleModel, WorksheetProtectionPointModel } from '@univerjs/sheets';
6
+ import { RangeProtectionRuleModel, WorksheetProtectionPointModel, WorksheetProtectionRuleModel } from '@univerjs/sheets';
7
+ import { FRangeProtectionRule } from './f-range-protection-rule';
7
8
  /**
8
9
  * Implementation class for WorksheetPermission
9
10
  * Provides worksheet-level permission control
10
11
  *
11
12
  * @hideconstructor
12
13
  */
13
- export declare class FWorksheetPermission implements IWorksheetPermission {
14
+ export declare class FWorksheetPermission {
14
15
  private readonly _worksheet;
15
16
  private readonly _injector;
16
17
  private readonly _permissionService;
@@ -18,6 +19,7 @@ export declare class FWorksheetPermission implements IWorksheetPermission {
18
19
  private readonly _commandService;
19
20
  private readonly _rangeProtectionRuleModel;
20
21
  private readonly _worksheetProtectionPointModel;
22
+ private readonly _worksheetProtectionRuleModel;
21
23
  private readonly _permissionSubject;
22
24
  private readonly _rangeRulesSubject;
23
25
  /**
@@ -40,17 +42,18 @@ export declare class FWorksheetPermission implements IWorksheetPermission {
40
42
  */
41
43
  readonly rangeProtectionChange$: Observable<{
42
44
  type: 'add' | 'update' | 'delete';
43
- rules: IRangeProtectionRule[];
45
+ rules: FRangeProtectionRule[];
44
46
  }>;
45
47
  /**
46
48
  * Observable stream of current range protection rules list (BehaviorSubject)
47
49
  * Emits immediately on subscription with current rules, then auto-updates when rules change
48
50
  */
49
- readonly rangeProtectionRules$: Observable<IRangeProtectionRule[]>;
51
+ readonly rangeProtectionRules$: Observable<FRangeProtectionRule[]>;
50
52
  private readonly _unitId;
51
53
  private readonly _subUnitId;
52
54
  private readonly _subscriptions;
53
- constructor(_worksheet: FWorksheet, _injector: Injector, _permissionService: IPermissionService, _authzIoService: IAuthzIoService, _commandService: ICommandService, _rangeProtectionRuleModel: RangeProtectionRuleModel, _worksheetProtectionPointModel: WorksheetProtectionPointModel);
55
+ private readonly _fPermission;
56
+ constructor(_worksheet: FWorksheet, _injector: Injector, _permissionService: IPermissionService, _authzIoService: IAuthzIoService, _commandService: ICommandService, _rangeProtectionRuleModel: RangeProtectionRuleModel, _worksheetProtectionPointModel: WorksheetProtectionPointModel, _worksheetProtectionRuleModel: WorksheetProtectionRuleModel);
54
57
  /**
55
58
  * Create permission snapshot stream from IPermissionService
56
59
  * @private
@@ -88,8 +91,73 @@ export declare class FWorksheetPermission implements IWorksheetPermission {
88
91
  * Build range protection rules list
89
92
  */
90
93
  private _buildRangeProtectionRules;
94
+ /**
95
+ * Build Facade objects for all protection rules
96
+ */
97
+ private _buildProtectionRule;
98
+ /**
99
+ * Debug cell permission information.
100
+ * @param {number} row Row index.
101
+ * @param {number} col Column index.
102
+ * @returns {ICellPermissionDebugInfo | null} Debug information about which rules affect this cell, or null if no rules apply.
103
+ * @example
104
+ * ```ts
105
+ * const worksheet = univerAPI.getActiveWorkbook()?.getActiveSheet();
106
+ * const permission = worksheet?.getWorksheetPermission();
107
+ * const debugInfo = permission?.debugCellPermission(0, 0);
108
+ * console.log(debugInfo);
109
+ * ```
110
+ */
111
+ debugCellPermission(row: number, col: number): FRangeProtectionRule | undefined;
112
+ /**
113
+ * Create worksheet protection with collaborators support.
114
+ * This must be called before setting permission points for collaboration to work.
115
+ * @param {IWorksheetProtectionOptions} options Protection options including allowed users.
116
+ * @returns {Promise<string>} The permissionId for the created protection.
117
+ * @example
118
+ * ```ts
119
+ * const worksheet = univerAPI.getActiveWorkbook()?.getActiveSheet();
120
+ * const permission = worksheet?.getWorksheetPermission();
121
+ *
122
+ * // Create worksheet protection with collaborators
123
+ * const permissionId = await permission?.protect({
124
+ * allowedUsers: ['user1', 'user2'],
125
+ * name: 'My Worksheet Protection'
126
+ * });
127
+ *
128
+ * // Now set permission points
129
+ * await permission?.setMode('readOnly');
130
+ * ```
131
+ */
132
+ protect(options?: IWorksheetProtectionOptions): Promise<string>;
133
+ /**
134
+ * Remove worksheet protection.
135
+ * This deletes the protection rule and resets all permission points to allowed.
136
+ * @returns {Promise<void>} A promise that resolves when protection is removed.
137
+ * @example
138
+ * ```ts
139
+ * const worksheet = univerAPI.getActiveWorkbook()?.getActiveSheet();
140
+ * const permission = worksheet?.getWorksheetPermission();
141
+ * await permission?.unprotect();
142
+ * ```
143
+ */
144
+ unprotect(): Promise<void>;
145
+ /**
146
+ * Check if worksheet is currently protected.
147
+ * @returns {boolean} true if protected, false otherwise.
148
+ * @example
149
+ * ```ts
150
+ * const worksheet = univerAPI.getActiveWorkbook()?.getActiveSheet();
151
+ * const permission = worksheet?.getWorksheetPermission();
152
+ * if (permission?.isProtected()) {
153
+ * console.log('Worksheet is protected');
154
+ * }
155
+ * ```
156
+ */
157
+ isProtected(): boolean;
91
158
  /**
92
159
  * Set permission mode for the worksheet.
160
+ * Automatically creates worksheet protection if not already protected.
93
161
  * @param {WorksheetMode} mode The permission mode to set ('editable' | 'readOnly' | 'filterOnly' | 'commentOnly').
94
162
  * @returns {Promise<void>} A promise that resolves when the mode is set.
95
163
  * @example
@@ -173,22 +241,9 @@ export declare class FWorksheetPermission implements IWorksheetPermission {
173
241
  * ```
174
242
  */
175
243
  canViewCell(_row: number, _col: number): boolean;
176
- /**
177
- * Debug cell permission information.
178
- * @param {number} row Row index.
179
- * @param {number} col Column index.
180
- * @returns {ICellPermissionDebugInfo | null} Debug information about which rules affect this cell, or null if no rules apply.
181
- * @example
182
- * ```ts
183
- * const worksheet = univerAPI.getActiveWorkbook()?.getActiveSheet();
184
- * const permission = worksheet?.getWorksheetPermission();
185
- * const debugInfo = permission?.debugCellPermission(0, 0);
186
- * console.log(debugInfo);
187
- * ```
188
- */
189
- debugCellPermission(row: number, col: number): ICellPermissionDebugInfo | null;
190
244
  /**
191
245
  * Set a specific permission point for the worksheet.
246
+ * Automatically creates worksheet protection if not already protected.
192
247
  * @param {WorksheetPermissionPoint} point The permission point to set.
193
248
  * @param {boolean} value The value to set (true = allowed, false = denied).
194
249
  * @returns {Promise<void>} A promise that resolves when the point is set.
@@ -196,7 +251,7 @@ export declare class FWorksheetPermission implements IWorksheetPermission {
196
251
  * ```ts
197
252
  * const worksheet = univerAPI.getActiveWorkbook()?.getActiveSheet();
198
253
  * const permission = worksheet?.getWorksheetPermission();
199
- * await permission?.setPoint(WorksheetPermissionPoint.InsertRow, false);
254
+ * await permission?.setPoint(univerAPI.Enum.WorksheetPermissionPoint.InsertRow, false);
200
255
  * ```
201
256
  */
202
257
  setPoint(point: WorksheetPermissionPoint, value: boolean): Promise<void>;
@@ -208,7 +263,7 @@ export declare class FWorksheetPermission implements IWorksheetPermission {
208
263
  * ```ts
209
264
  * const worksheet = univerAPI.getActiveWorkbook()?.getActiveSheet();
210
265
  * const permission = worksheet?.getWorksheetPermission();
211
- * const canInsertRow = permission?.getPoint(WorksheetPermissionPoint.InsertRow);
266
+ * const canInsertRow = permission?.getPoint(univerAPI.Enum.WorksheetPermissionPoint.InsertRow);
212
267
  * console.log(canInsertRow);
213
268
  * ```
214
269
  */
@@ -236,8 +291,8 @@ export declare class FWorksheetPermission implements IWorksheetPermission {
236
291
  * await permission?.applyConfig({
237
292
  * mode: 'readOnly',
238
293
  * points: {
239
- * [WorksheetPermissionPoint.View]: true,
240
- * [WorksheetPermissionPoint.Edit]: false
294
+ * [univerAPI.Enum.WorksheetPermissionPoint.View]: true,
295
+ * [univerAPI.Enum.WorksheetPermissionPoint.Edit]: false
241
296
  * }
242
297
  * });
243
298
  * ```
@@ -246,7 +301,7 @@ export declare class FWorksheetPermission implements IWorksheetPermission {
246
301
  /**
247
302
  * Protect multiple ranges at once (batch operation).
248
303
  * @param {Array<{ ranges: FRange[]; options?: IRangeProtectionOptions }>} configs Array of protection configurations.
249
- * @returns {Promise<IRangeProtectionRule[]>} Array of created protection rules.
304
+ * @returns {Promise<FRangeProtectionRule[]>} Array of created protection rules.
250
305
  * @example
251
306
  * ```ts
252
307
  * const worksheet = univerAPI.getActiveWorkbook()?.getActiveSheet();
@@ -254,11 +309,11 @@ export declare class FWorksheetPermission implements IWorksheetPermission {
254
309
  * const rules = await permission?.protectRanges([
255
310
  * {
256
311
  * ranges: [worksheet.getRange('A1:B2')],
257
- * options: { name: 'Protected Area 1', allowEdit: false, allowView: true }
312
+ * options: { name: 'Protected Area 1', allowEdit: false, allowViewByOthers: true }
258
313
  * },
259
314
  * {
260
315
  * ranges: [worksheet.getRange('C3:D4')],
261
- * options: { name: 'Protected Area 2', allowEdit: true, allowView: false }
316
+ * options: { name: 'Protected Area 2', allowEdit: true, allowViewByOthers: false }
262
317
  * }
263
318
  * ]);
264
319
  * console.log(rules);
@@ -267,7 +322,7 @@ export declare class FWorksheetPermission implements IWorksheetPermission {
267
322
  protectRanges(configs: Array<{
268
323
  ranges: FRange[];
269
324
  options?: IRangeProtectionOptions;
270
- }>): Promise<IRangeProtectionRule[]>;
325
+ }>): Promise<FRangeProtectionRule[]>;
271
326
  /**
272
327
  * Determine view state from options
273
328
  * @private
@@ -302,7 +357,7 @@ export declare class FWorksheetPermission implements IWorksheetPermission {
302
357
  unprotectRules(ruleIds: string[]): Promise<void>;
303
358
  /**
304
359
  * List all range protection rules for the worksheet.
305
- * @returns {Promise<IRangeProtectionRule[]>} Array of protection rules.
360
+ * @returns {Promise<FRangeProtectionRule[]>} Array of protection rules.
306
361
  * @example
307
362
  * ```ts
308
363
  * const worksheet = univerAPI.getActiveWorkbook()?.getActiveSheet();
@@ -311,7 +366,7 @@ export declare class FWorksheetPermission implements IWorksheetPermission {
311
366
  * console.log(rules);
312
367
  * ```
313
368
  */
314
- listRangeProtectionRules(): Promise<IRangeProtectionRule[]>;
369
+ listRangeProtectionRules(): Promise<FRangeProtectionRule[]>;
315
370
  /**
316
371
  * Subscribe to permission changes (simplified interface for users not familiar with RxJS).
317
372
  * @param {Function} listener Callback function to be called when permissions change.
@@ -1,6 +1,5 @@
1
1
  import { IUser } from '@univerjs/protocol';
2
2
  import { Observable } from 'rxjs';
3
- import { FRange } from '../f-range';
4
3
  /**
5
4
  * ========================
6
5
  * Basic Types / Enums
@@ -165,6 +164,22 @@ export type RangePermissionSnapshot = Record<RangePermissionPoint, boolean>;
165
164
  * Unsubscribe function type
166
165
  */
167
166
  export type UnsubscribeFn = () => void;
167
+ /**
168
+ * ========================
169
+ * Worksheet Protection Configuration
170
+ * ========================
171
+ */
172
+ /**
173
+ * Worksheet protection options configuration
174
+ */
175
+ export interface IWorksheetProtectionOptions {
176
+ /** Whitelist of users allowed to edit; empty means only owner */
177
+ allowedUsers?: string[];
178
+ /** Protection name for UI display */
179
+ name?: string;
180
+ /** Custom metadata */
181
+ metadata?: Record<string, unknown>;
182
+ }
168
183
  /**
169
184
  * ========================
170
185
  * Range Protection Configuration and Rules
@@ -184,24 +199,6 @@ export interface IRangeProtectionOptions {
184
199
  /** Custom metadata (logs, tags, etc.) */
185
200
  metadata?: Record<string, unknown>;
186
201
  }
187
- /**
188
- * Range protection rule Facade
189
- * Encapsulates internal permissionId / ruleId
190
- */
191
- export interface IRangeProtectionRule {
192
- /** Internal rule id, for debugging/logging, generally not directly used by callers */
193
- readonly id: string;
194
- /** List of ranges covered by this rule */
195
- readonly ranges: FRange[];
196
- /** Current rule configuration */
197
- readonly options: IRangeProtectionOptions;
198
- /** Update protected ranges */
199
- updateRanges(ranges: FRange[]): Promise<void>;
200
- /** Partially update configuration */
201
- updateOptions(options: Partial<IRangeProtectionOptions>): Promise<void>;
202
- /** Delete current protection rule */
203
- remove(): Promise<void>;
204
- }
205
202
  /**
206
203
  * Cell permission debug rule information
207
204
  */
@@ -211,15 +208,6 @@ export interface ICellPermissionDebugRuleInfo {
211
208
  rangeRefs: string[];
212
209
  options: IRangeProtectionOptions;
213
210
  }
214
- /**
215
- * Cell permission debug information
216
- */
217
- export interface ICellPermissionDebugInfo {
218
- row: number;
219
- col: number;
220
- /** List of protection rules that apply */
221
- hitRules: ICellPermissionDebugRuleInfo[];
222
- }
223
211
  /**
224
212
  * ========================
225
213
  * Facade: WorkbookPermission
@@ -317,167 +305,12 @@ export interface IWorksheetPermissionConfig {
317
305
  options?: IRangeProtectionOptions;
318
306
  }>;
319
307
  }
320
- /**
321
- * Worksheet-level permission Facade interface
322
- */
323
- export interface IWorksheetPermission {
324
- /**
325
- * Set worksheet overall mode:
326
- * - 'readOnly' → Lock write-related points
327
- * - 'filterOnly' → Only enable Filter/Sort, close other write-related points
328
- * - 'commentOnly' → Close write, keep comment
329
- * - 'editable' → Most write-related points enabled
330
- */
331
- setMode(mode: WorksheetMode): Promise<void>;
332
- /** Shortcut: Read-only */
333
- setReadOnly(): Promise<void>;
334
- /** Shortcut: Editable */
335
- setEditable(): Promise<void>;
336
- /** Whether current user can "overall" edit this sheet (not considering local range protection) */
337
- canEdit(): boolean;
338
- /**
339
- * Cell-level high-level check (combines sheet-level & range-level rules)
340
- */
341
- canEditCell(row: number, col: number): boolean;
342
- canViewCell(row: number, col: number): boolean;
343
- /**
344
- * Debug use: View protection rule information for a specific cell
345
- */
346
- debugCellPermission(row: number, col: number): ICellPermissionDebugInfo | null;
347
- /**
348
- * Point operations (low-level)
349
- */
350
- setPoint(point: WorksheetPermissionPoint, value: boolean): Promise<void>;
351
- getPoint(point: WorksheetPermissionPoint): boolean;
352
- getSnapshot(): WorksheetPermissionSnapshot;
353
- /**
354
- * Batch apply permission configuration (for "configuration-driven" scenarios)
355
- * Internally uses Command to ensure undo/redo
356
- */
357
- applyConfig(config: IWorksheetPermissionConfig): Promise<void>;
358
- /**
359
- * Range protection management
360
- */
361
- /** Batch create multiple range protection rules (one-time operation, better performance) */
362
- protectRanges(configs: Array<{
363
- ranges: FRange[];
364
- options?: IRangeProtectionOptions;
365
- }>): Promise<IRangeProtectionRule[]>;
366
- /** Batch delete multiple protection rules */
367
- unprotectRules(ruleIds: string[]): Promise<void>;
368
- /**
369
- * List all range protection rules on current sheet
370
- */
371
- listRangeProtectionRules(): Promise<IRangeProtectionRule[]>;
372
- /**
373
- * ========================
374
- * RxJS Observable Reactive Interface
375
- * ========================
376
- */
377
- /**
378
- * Permission snapshot change stream (BehaviorSubject, immediately provides current state on subscription)
379
- * Triggers when any permission point changes
380
- */
381
- readonly permission$: Observable<WorksheetPermissionSnapshot>;
382
- /**
383
- * Single permission point change stream
384
- * For scenarios that only care about specific permission point changes
385
- */
386
- readonly pointChange$: Observable<{
387
- point: WorksheetPermissionPoint;
388
- value: boolean;
389
- oldValue: boolean;
390
- }>;
391
- /**
392
- * Range protection rule change stream (add, delete, update)
393
- */
394
- readonly rangeProtectionChange$: Observable<{
395
- type: 'add' | 'update' | 'delete';
396
- rules: IRangeProtectionRule[];
397
- }>;
398
- /**
399
- * Current all range protection rules list stream (BehaviorSubject)
400
- * Immediately provides current rule list on subscription, auto-updates when rules change
401
- */
402
- readonly rangeProtectionRules$: Observable<IRangeProtectionRule[]>;
403
- /**
404
- * Compatibility method: Simplified subscription (for users unfamiliar with RxJS)
405
- * Internally implemented based on permission$ Observable
406
- */
407
- subscribe(listener: (snapshot: WorksheetPermissionSnapshot) => void): UnsubscribeFn;
408
- }
409
308
  /**
410
309
  * ========================
411
310
  * Facade: RangePermission
412
311
  * ========================
413
312
  */
414
- /**
415
- * Range-level permission Facade interface
416
- */
417
- export interface IRangePermission {
418
- /**
419
- * Create protection rule on current range
420
- * - Default options.allowEdit = false → Treated as "locked"
421
- */
422
- protect(options?: IRangeProtectionOptions): Promise<IRangeProtectionRule>;
423
- /**
424
- * Remove all protection rules covered by current range
425
- * (Internally can calculate range → ruleId mapping)
426
- */
427
- unprotect(): Promise<void>;
428
- /**
429
- * Whether current range is in protected state (for current user)
430
- */
431
- isProtected(): boolean;
432
- /** Whether current user can edit this range (combines Worksheet / Workbook / Range levels) */
433
- canEdit(): boolean;
434
- /** Whether current user can view this range */
435
- canView(): boolean;
436
- /**
437
- * Range-level point reading (generally for debugging / advanced scenarios)
438
- * Usually only need Edit/View two points
439
- */
440
- getPoint(point: RangePermissionPoint): boolean;
441
- getSnapshot(): RangePermissionSnapshot;
442
- /**
443
- * Set a specific permission point for the range (low-level API for local runtime control)
444
- * @param {RangePermissionPoint} point The permission point to set
445
- * @param {boolean} value The value to set (true = allowed, false = denied)
446
- * @returns {Promise<void>} A promise that resolves when the point is set
447
- * @example
448
- * ```ts
449
- * const range = univerAPI.getActiveWorkbook()?.getActiveSheet()?.getRange('A1:B2');
450
- * const permission = range?.getRangePermission();
451
- * await permission?.setPoint(RangePermissionPoint.Edit, false); // Disable edit for current user
452
- * ```
453
- */
454
- setPoint(point: RangePermissionPoint, value: boolean): Promise<void>;
455
- /**
456
- * Get snapshot of all protection rules in current worksheet (can also proxy worksheet interface)
457
- */
458
- listRules(): Promise<IRangeProtectionRule[]>;
459
- /**
460
- * ========================
461
- * RxJS Observable Reactive Interface
462
- * ========================
463
- */
464
- /**
465
- * Permission snapshot change stream (BehaviorSubject, immediately provides current state on subscription)
466
- */
467
- readonly permission$: Observable<RangePermissionSnapshot>;
468
- /**
469
- * Protection state change stream
470
- */
471
- readonly protectionChange$: Observable<{
472
- type: 'protected';
473
- rule: IRangeProtectionRule;
474
- } | {
475
- type: 'unprotected';
476
- ruleId: string;
477
- }>;
478
- /**
479
- * Compatibility method: Simplified subscription (for users unfamiliar with RxJS)
480
- * Internally implemented based on permission$ Observable
481
- */
482
- subscribe(listener: (snapshot: RangePermissionSnapshot) => void): UnsubscribeFn;
313
+ export interface ICellPermissionDebugInfo {
314
+ permissionId: string;
315
+ ruleId: string;
483
316
  }
@@ -89,6 +89,7 @@ export { type IToggleCellCheckboxCommandParams, ToggleCellCheckboxCommand } from
89
89
  export { type IToggleGridlinesCommandParams, ToggleGridlinesCommand } from './commands/commands/toggle-gridlines.command';
90
90
  export { UnregisterWorksheetRangeThemeStyleCommand } from './commands/commands/unregister-range-theme.command';
91
91
  export type { IUnregisterWorksheetRangeThemeStyleCommandParams } from './commands/commands/unregister-range-theme.command';
92
+ export { countCells } from './commands/commands/util';
92
93
  export { alignToMergedCellsBorders, getCellAtRowCol, isSingleCellSelection, setEndForRange } from './commands/commands/utils/selection-utils';
93
94
  export { followSelectionOperation, getPrimaryForRange } from './commands/commands/utils/selection-utils';
94
95
  export { copyRangeStyles } from './commands/commands/utils/selection-utils';
@@ -99,6 +100,7 @@ export type { IAddRangeThemeMutationParams } from './commands/mutations/add-rang
99
100
  export { AddMergeUndoMutationFactory, AddWorksheetMergeMutation } from './commands/mutations/add-worksheet-merge.mutation';
100
101
  export { AddWorksheetProtectionMutation, type IAddWorksheetProtectionParams } from './commands/mutations/add-worksheet-protection.mutation';
101
102
  export { SetWorksheetRangeThemeStyleMutation, SetWorksheetRangeThemeStyleMutationFactory } from './commands/mutations/add-worksheet-range-theme.mutation';
103
+ export { CopyWorksheetEndMutation, type ICopyWorksheetEndMutationParams } from './commands/mutations/copy-worksheet-end.mutation';
102
104
  export { DeleteRangeProtectionMutation, FactoryDeleteRangeProtectionMutation, type IDeleteRangeProtectionMutationParams } from './commands/mutations/delete-range-protection.mutation';
103
105
  export { DeleteWorksheetProtectionMutation } from './commands/mutations/delete-worksheet-protection.mutation';
104
106
  export type { IDeleteWorksheetProtectionParams } from './commands/mutations/delete-worksheet-protection.mutation';
@@ -153,7 +155,7 @@ export { getInsertRangeMutations, getRemoveRangeMutations } from './commands/uti
153
155
  export { handleInsertRangeMutation } from './commands/utils/handle-range-mutation';
154
156
  export { type ISheetCommandSharedParams } from './commands/utils/interface';
155
157
  export { getSelectionsService } from './commands/utils/selection-command-util';
156
- export { type IUniverSheetsConfig } from './controllers/config.schema';
158
+ export { defaultLargeSheetOperationConfig, type ILargeSheetOperationConfig, type IUniverSheetsConfig, SHEETS_PLUGIN_CONFIG_KEY } from './controllers/config.schema';
157
159
  export { MAX_CELL_PER_SHEET_KEY } from './controllers/config/config';
158
160
  export { DefinedNameDataController } from './controllers/defined-name-data.controller';
159
161
  export { SCOPE_WORKBOOK_VALUE_DEFINED_NAME } from './controllers/defined-name-data.controller';
@@ -173,6 +175,7 @@ export type { IRangeThemeStyleItem } from './model/range-theme-util';
173
175
  export { UniverSheetsPlugin } from './plugin';
174
176
  export { BorderStyleManagerService, type IBorderInfo } from './services/border-style-manager.service';
175
177
  export { ExclusiveRangeService, IExclusiveRangeService } from './services/exclusive-range/exclusive-range-service';
178
+ export { SheetLazyExecuteScheduleService } from './services/lazy-execute-schedule.service';
176
179
  export { NumfmtService } from './services/numfmt/numfmt.service';
177
180
  export type { INumfmtItem, INumfmtItemWithCache } from './services/numfmt/type';
178
181
  export { INumfmtService } from './services/numfmt/type';
@@ -0,0 +1,47 @@
1
+ import { IMutationInfo, Disposable, ICommandService, IUniverInstanceService } from '@univerjs/core';
2
+ import { ISetRangeValuesMutationParams } from '../commands/mutations/set-range-values.mutation';
3
+ /**
4
+ * Service to schedule and execute remaining SetRangeValuesMutation tasks
5
+ * during browser idle time after a sheet copy operation.
6
+ *
7
+ * This improves user experience by:
8
+ * 1. Immediately showing the copied sheet with first chunk of data
9
+ * 2. Filling remaining data in background during idle time
10
+ * 3. Automatically canceling tasks if the sheet is deleted
11
+ * 4. Warning user if they try to close while tasks are pending
12
+ */
13
+ export declare class SheetLazyExecuteScheduleService extends Disposable {
14
+ private readonly _commandService;
15
+ private readonly _univerInstanceService;
16
+ private _tasks;
17
+ private _idleCallbackId;
18
+ private _beforeUnloadHandler;
19
+ constructor(_commandService: ICommandService, _univerInstanceService: IUniverInstanceService);
20
+ /**
21
+ * Check if there are any pending tasks
22
+ */
23
+ hasPendingTasks(): boolean;
24
+ /**
25
+ * Get the count of pending mutations across all tasks
26
+ */
27
+ getPendingMutationsCount(): number;
28
+ /**
29
+ * Schedule mutations to be executed during idle time
30
+ * @param unitId - The workbook unit ID
31
+ * @param subUnitId - The sheet ID (newly created sheet)
32
+ * @param mutations - Remaining SetRangeValuesMutation to execute
33
+ */
34
+ scheduleMutations(unitId: string, subUnitId: string, mutations: IMutationInfo<ISetRangeValuesMutationParams>[]): void;
35
+ /**
36
+ * Cancel scheduled mutations for a specific sheet
37
+ * Called when the sheet is deleted
38
+ */
39
+ cancelScheduledMutations(unitId: string, subUnitId: string): void;
40
+ private _cancelTask;
41
+ private _cancelAllTasks;
42
+ private _scheduleNextIdle;
43
+ private _processIdleTasks;
44
+ private _isSheetExist;
45
+ private _setupBeforeUnloadListener;
46
+ private _removeBeforeUnloadListener;
47
+ }