@univerjs/core 0.12.3 → 0.12.4

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.
@@ -54,7 +54,7 @@ export { composeBody, getBodySlice, getCustomBlockSlice, getCustomDecorationSlic
54
54
  export { EventState, EventSubject, fromEventSubject, type IEventObserver } from './observer/observable';
55
55
  export { AuthzIoLocalService } from './services/authz-io/authz-io-local.service';
56
56
  export { IAuthzIoService } from './services/authz-io/type';
57
- export { type CommandListener, CommandService, CommandType, type ICommand, type ICommandInfo, ICommandService, type IExecutionOptions, type IMultiCommand, type IMutation, type IMutationCommonParams, type IMutationInfo, type IOperation, type IOperationInfo, NilCommand, sequenceExecute, sequenceExecuteAsync, } from './services/command/command.service';
57
+ export { COMMAND_LOG_EXECUTION_CONFIG_KEY, type CommandListener, CommandService, CommandType, type ICommand, type ICommandInfo, ICommandService, type IExecutionOptions, type IMultiCommand, type IMutation, type IMutationCommonParams, type IMutationInfo, type IOperation, type IOperationInfo, NilCommand, sequenceExecute, sequenceExecuteAsync, } from './services/command/command.service';
58
58
  export { IConfigService } from './services/config/config.service';
59
59
  export { ConfigService } from './services/config/config.service';
60
60
  export * from './services/context/context';
@@ -96,6 +96,7 @@ export { afterTime, bufferDebounceTime, convertObservableToBehaviorSubject, from
96
96
  export { textDiff } from './shared/text-diff';
97
97
  export { awaitTime, delayAnimationFrame } from './shared/timer';
98
98
  export { isNodeEnv } from './shared/tools';
99
+ export * from './sheets/clone';
99
100
  export { Range } from './sheets/range';
100
101
  export { getCellCoordByIndexSimple, getCellPositionByIndexSimple, getCellWithCoordByIndexCore, SheetSkeleton } from './sheets/sheet-skeleton';
101
102
  export type { IGetRowColByPosOptions } from './sheets/sheet-skeleton';
@@ -1,7 +1,14 @@
1
1
  import { IAccessor, IDisposable, Injector } from '../../common/di';
2
2
  import { Disposable } from '../../shared/lifecycle';
3
+ import { IConfigService } from '../config/config.service';
3
4
  import { IContextService } from '../context/context.service';
4
5
  import { ILogService } from '../log/log.service';
6
+ /**
7
+ * The config key for enabling command execution logging.
8
+ * Set via `logCommandExecution` in `IUniverConfig` when calling `new Univer()`.
9
+ * @default true
10
+ */
11
+ export declare const COMMAND_LOG_EXECUTION_CONFIG_KEY = "command.logExecution";
5
12
  /**
6
13
  * The type of a command.
7
14
  */
@@ -77,6 +84,15 @@ export interface IMutationCommonParams {
77
84
  * It is used to indicate which {@link CommandType.COMMAND} triggers the mutation.
78
85
  */
79
86
  trigger?: string;
87
+ /**
88
+ * Mark this mutation as a split chunk from a large mutation.
89
+ * When collaboration layer encounters this flag, it will send this mutation
90
+ * in a separate changeset to avoid oversized payloads.
91
+ *
92
+ * This is typically set by operations that split large data (e.g., copy worksheet,
93
+ * paste large ranges) into smaller chunks for better network transmission.
94
+ */
95
+ __splitChunk__?: boolean;
80
96
  }
81
97
  /**
82
98
  * {@link CommandType.MUTATION} should implement this interface.
@@ -142,6 +158,11 @@ export interface IExecutionOptions {
142
158
  fromCollab?: boolean;
143
159
  /** @deprecated */
144
160
  fromChangeset?: boolean;
161
+ /**
162
+ * This mutation should be synced to changeset but not executed locally.
163
+ * The actual execution will be handled asynchronously via onlyLocal.
164
+ */
165
+ syncOnly?: boolean;
145
166
  [key: PropertyKey]: string | number | boolean | undefined;
146
167
  }
147
168
  export type CommandListener = (commandInfo: Readonly<ICommandInfo>, options?: IExecutionOptions) => void;
@@ -192,6 +213,7 @@ export interface ICommandService {
192
213
  syncExecuteCommand<P extends object = object, R = boolean>(id: string, params?: P, options?: IExecutionOptions): R;
193
214
  /**
194
215
  * Register a callback function that will be executed after a command is executed.
216
+ * Note: This will NOT be called for commands with syncOnly option.
195
217
  * @param listener
196
218
  */
197
219
  onCommandExecuted(listener: CommandListener): IDisposable;
@@ -200,6 +222,13 @@ export interface ICommandService {
200
222
  * @param listener
201
223
  */
202
224
  beforeCommandExecuted(listener: CommandListener): IDisposable;
225
+ /**
226
+ * Register a callback function specifically for collaboration sync.
227
+ * This will only be called for mutations (not commands/operations) that need to be synced,
228
+ * including syncOnly mutations.
229
+ * @param listener
230
+ */
231
+ onMutationExecutedForCollab(listener: CommandListener): IDisposable;
203
232
  }
204
233
  declare class CommandRegistry {
205
234
  private readonly _commands;
@@ -214,13 +243,15 @@ export declare const NilCommand: ICommand;
214
243
  export declare class CommandService extends Disposable implements ICommandService {
215
244
  private readonly _injector;
216
245
  private readonly _logService;
246
+ private readonly _configService;
217
247
  protected readonly _commandRegistry: CommandRegistry;
218
248
  private readonly _beforeCommandExecutionListeners;
219
249
  private readonly _commandExecutedListeners;
250
+ private readonly _collabMutationListeners;
220
251
  private _multiCommandDisposables;
221
252
  private _commandExecutingLevel;
222
253
  private _commandExecutionStack;
223
- constructor(_injector: Injector, _logService: ILogService);
254
+ constructor(_injector: Injector, _logService: ILogService, _configService: IConfigService);
224
255
  dispose(): void;
225
256
  hasCommand(commandId: string): boolean;
226
257
  registerCommand(command: ICommand): IDisposable;
@@ -228,6 +259,7 @@ export declare class CommandService extends Disposable implements ICommandServic
228
259
  registerMultipleCommand(command: ICommand): IDisposable;
229
260
  beforeCommandExecuted(listener: CommandListener): IDisposable;
230
261
  onCommandExecuted(listener: (commandInfo: ICommandInfo) => void): IDisposable;
262
+ onMutationExecutedForCollab(listener: CommandListener): IDisposable;
231
263
  executeCommand<P extends object = object, R = boolean>(id: string, params?: P, options?: IExecutionOptions): Promise<R>;
232
264
  syncExecuteCommand<P extends object = object, R = boolean>(id: string, params?: P | undefined, options?: IExecutionOptions): R;
233
265
  private _pushCommandExecutionStack;
@@ -0,0 +1,38 @@
1
+ import { IObjectMatrixPrimitiveType, Nullable } from '../shared';
2
+ import { ICellData, ICellDataWithSpanAndDisplay, IWorksheetData } from './typedef';
3
+ /**
4
+ * Fast clone for primitive values and simple objects.
5
+ * Avoids type checking overhead when we know the structure.
6
+ */
7
+ export declare function cloneValue<T>(value: T): T;
8
+ /**
9
+ * Fast clone for ICellData. Optimized for the known structure.
10
+ * @param cell - The cell data to clone
11
+ * @returns A deep clone of the cell data
12
+ */
13
+ export declare function cloneCellData(cell: Nullable<ICellData>): Nullable<ICellData>;
14
+ /**
15
+ * Fast clone for ICellDataWithSpanAndDisplay. Optimized for the known structure.
16
+ * This extends cloneCellData with additional span and display properties.
17
+ * @param cell - The cell data with span and display info to clone
18
+ * @returns A deep clone of the cell data
19
+ */
20
+ export declare function cloneCellDataWithSpanAndDisplay(cell: Nullable<ICellDataWithSpanAndDisplay>): Nullable<ICellDataWithSpanAndDisplay>;
21
+ /**
22
+ * Fast clone for cell data matrix. Optimized for sparse matrix structure.
23
+ * @param cellData - The cell data matrix to clone
24
+ * @returns A deep clone of the cell data matrix
25
+ */
26
+ export declare function cloneCellDataMatrix(cellData: IObjectMatrixPrimitiveType<ICellData>): IObjectMatrixPrimitiveType<ICellData>;
27
+ /**
28
+ * Optimized deep clone specifically for IWorksheetData.
29
+ * This is significantly faster than generic deepClone because:
30
+ * 1. No recursive type checking - we know the structure
31
+ * 2. Direct property access instead of Object.keys iteration for known properties
32
+ * 3. Specialized handlers for cellData matrix (the largest data)
33
+ * 4. Primitive values copied directly without cloning
34
+ *
35
+ * @param worksheet - The worksheet data to clone
36
+ * @returns A deep clone of the worksheet data
37
+ */
38
+ export declare function cloneWorksheetData(worksheet: IWorksheetData): IWorksheetData;
@@ -33,6 +33,11 @@ export interface IUniverConfig {
33
33
  * The log level of the Univer instance.
34
34
  */
35
35
  logLevel?: LogLevel;
36
+ /**
37
+ * Whether to enable logging for command execution.
38
+ * @default false
39
+ */
40
+ logCommandExecution?: boolean;
36
41
  /**
37
42
  * The override dependencies of the Univer instance.
38
43
  */