@univerjs/core 0.2.8 → 0.2.10

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.
Files changed (71) hide show
  1. package/lib/cjs/index.js +7 -9
  2. package/lib/es/index.js +220 -688
  3. package/lib/types/common/equal.d.ts +15 -3
  4. package/lib/types/common/interceptor.d.ts +1 -1
  5. package/lib/types/{types/interfaces/i-extra-model-data.d.ts → common/mixin.d.ts} +9 -11
  6. package/lib/types/common/unit.d.ts +2 -1
  7. package/lib/types/docs/data-model/document-data-model.d.ts +2 -3
  8. package/lib/types/index.d.ts +5 -9
  9. package/lib/types/services/authz-io/type.d.ts +2 -2
  10. package/lib/types/services/command/command.service.d.ts +111 -28
  11. package/lib/types/services/lifecycle/lifecycle.d.ts +5 -0
  12. package/lib/types/services/permission/type.d.ts +2 -2
  13. package/lib/types/services/resource-loader/resource-loader.service.d.ts +3 -5
  14. package/lib/types/services/resource-loader/type.d.ts +4 -6
  15. package/lib/types/services/resource-manager/resource-manager.service.d.ts +4 -4
  16. package/lib/types/services/resource-manager/type.d.ts +9 -5
  17. package/lib/types/services/undoredo/undoredo.service.d.ts +1 -1
  18. package/lib/types/shared/check-if-move.d.ts +1 -1
  19. package/lib/types/shared/color/color.d.ts +1 -1
  20. package/lib/types/shared/common.d.ts +2 -4
  21. package/lib/types/shared/numfmt.d.ts +2 -1
  22. package/lib/types/shared/object-matrix-query.d.ts +1 -1
  23. package/lib/types/shared/object-matrix.d.ts +1 -1
  24. package/lib/types/shared/range.d.ts +1 -1
  25. package/lib/types/shared/rectangle.d.ts +1 -1
  26. package/lib/types/shared/tools.d.ts +1 -2
  27. package/lib/types/shared/types/numfmt.type.d.ts +227 -0
  28. package/lib/types/shared/types.d.ts +7 -13
  29. package/lib/types/sheets/__tests__/create-core-test-bed.d.ts +1 -1
  30. package/lib/types/sheets/column-manager.d.ts +2 -2
  31. package/lib/types/sheets/empty-snapshot.d.ts +1 -1
  32. package/lib/types/sheets/range.d.ts +2 -1
  33. package/lib/types/sheets/row-manager.d.ts +1 -1
  34. package/lib/types/sheets/sheet-snapshot-utils.d.ts +1 -1
  35. package/lib/types/sheets/styles.d.ts +2 -1
  36. package/lib/types/sheets/typedef.d.ts +451 -0
  37. package/lib/types/sheets/util.d.ts +3 -0
  38. package/lib/types/sheets/view-model.d.ts +2 -2
  39. package/lib/types/sheets/workbook.d.ts +13 -4
  40. package/lib/types/sheets/worksheet.d.ts +11 -1
  41. package/lib/types/slides/slide-model.d.ts +0 -1
  42. package/lib/types/types/const/const.d.ts +4 -0
  43. package/lib/types/types/enum/locale-type.d.ts +3 -1
  44. package/lib/types/types/enum/text-style.d.ts +1 -1
  45. package/lib/types/types/interfaces/i-cell-custom-render.d.ts +2 -2
  46. package/lib/types/types/interfaces/i-data-validation.d.ts +1 -1
  47. package/lib/types/types/interfaces/i-document-data.d.ts +2 -4
  48. package/lib/types/types/interfaces/i-slide-data.d.ts +5 -3
  49. package/lib/types/types/interfaces/index.d.ts +0 -11
  50. package/lib/types/univer.d.ts +14 -2
  51. package/lib/umd/index.js +7 -9
  52. package/package.json +5 -5
  53. package/lib/types/common/type-util.d.ts +0 -16
  54. package/lib/types/common/type-utils.d.ts +0 -16
  55. package/lib/types/services/snapshot/__tests__/snapshot-mock.d.ts +0 -22
  56. package/lib/types/services/snapshot/snapshot-server.service.d.ts +0 -42
  57. package/lib/types/services/snapshot/snapshot-transform.d.ts +0 -31
  58. package/lib/types/services/snapshot/snapshot-utils.d.ts +0 -19
  59. package/lib/types/types/interfaces/i-cell-data.d.ts +0 -66
  60. package/lib/types/types/interfaces/i-column-data.d.ts +0 -14
  61. package/lib/types/types/interfaces/i-freeze.d.ts +0 -21
  62. package/lib/types/types/interfaces/i-range.d.ts +0 -208
  63. package/lib/types/types/interfaces/i-row-data.d.ts +0 -26
  64. package/lib/types/types/interfaces/i-selection-data.d.ts +0 -58
  65. package/lib/types/types/interfaces/i-service-data.d.ts +0 -17
  66. package/lib/types/types/interfaces/i-univer-data.d.ts +0 -13
  67. package/lib/types/types/interfaces/i-workbook-data.d.ts +0 -39
  68. package/lib/types/types/interfaces/i-worksheet-data.d.ts +0 -54
  69. package/lib/types/types/interfaces/i-worksheet-order-data.d.ts +0 -17
  70. /package/lib/types/services/{snapshot/__tests__/snapshot-transform.spec.d.ts → __tests__/resources.spec.d.ts} +0 -0
  71. /package/lib/types/{types/interfaces/__tests__/i-cell-data.spec.d.ts → sheets/__tests__/cell-data.spec.d.ts} +0 -0
@@ -1,4 +1,3 @@
1
- import { IRange, IUnitRange } from '../types/interfaces';
2
1
  /**
3
2
  * Copyright 2023-present DreamNum Inc.
4
3
  *
@@ -14,6 +13,19 @@ import { IRange, IUnitRange } from '../types/interfaces';
14
13
  * See the License for the specific language governing permissions and
15
14
  * limitations under the License.
16
15
  */
17
- export declare const isRangesEqual: (oldRanges: IRange[], ranges: IRange[]) => boolean;
18
- export declare const isUnitRangesEqual: (oldRanges: IUnitRange[], ranges: IUnitRange[]) => boolean;
16
+ /**
17
+ * Copyright 2023-present DreamNum Inc.
18
+ *
19
+ * Licensed under the Apache License, Version 2.0 (the "License");
20
+ * you may not use this file except in compliance with the License.
21
+ * You may obtain a copy of the License at
22
+ *
23
+ * http://www.apache.org/licenses/LICENSE-2.0
24
+ *
25
+ * Unless required by applicable law or agreed to in writing, software
26
+ * distributed under the License is distributed on an "AS IS" BASIS,
27
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28
+ * See the License for the specific language governing permissions and
29
+ * limitations under the License.
30
+ */
19
31
  export declare function shallowEqual(objA: any, objB: any): boolean;
@@ -1,4 +1,4 @@
1
- import { Nullable } from './type-util';
1
+ import { Nullable } from '../shared/types';
2
2
  export type InterceptorHandler<M = unknown, C = unknown> = (value: Nullable<M>, context: C, next: (value: Nullable<M>) => Nullable<M>) => Nullable<M>;
3
3
  export interface IInterceptor<M, C> {
4
4
  priority?: number;
@@ -13,15 +13,13 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export interface IExtraModelData {
17
- /**
18
- * should start renderLoop Immediately
19
- * default is true
20
- */
21
- shouldStartRenderingImmediately?: boolean;
22
- /**
23
- * HTML selector
24
- * default is null
25
- */
26
- container?: string;
16
+ interface IMixinProperty<T> {
17
+ [fnName: string]: (this: T, ...args: any[]) => any;
27
18
  }
19
+ /**
20
+ * Mixin some methods to targetObject as prototype, the static methods will not be mixed in
21
+ * @param {T} targetClassPrototype The target class to mixin
22
+ * @param {IMixinProperty<T>} mixin The mixin object which contains the methods to mixin.
23
+ */
24
+ export declare function mixinClass<T>(targetClassPrototype: T, mixin: IMixinProperty<T>): void;
25
+ export {};
@@ -3,9 +3,10 @@ import { Observable } from 'rxjs';
3
3
  import { Disposable } from '../shared';
4
4
  export { UniverType as UniverInstanceType } from '@univerjs/protocol';
5
5
  export type UnitType = UniverType | number;
6
- export declare abstract class UnitModel<_D = object, T extends UnitType = UnitType> extends Disposable {
6
+ export declare abstract class UnitModel<D = object, T extends UnitType = UnitType> extends Disposable {
7
7
  abstract readonly type: T;
8
8
  abstract getUnitId(): string;
9
9
  abstract name$: Observable<string>;
10
10
  abstract setName(name: string): void;
11
+ abstract getSnapshot(): D;
11
12
  }
@@ -1,6 +1,6 @@
1
1
  import { BehaviorSubject } from 'rxjs';
2
2
  import { Nullable } from '../../shared';
3
- import { IDocumentBody, IDocumentData, IDocumentRenderConfig, IDocumentStyle, IDrawings } from '../../types/interfaces/i-document-data';
3
+ import { IDocumentBody, IDocumentData, IDocumentRenderConfig, IDocumentStyle, IDrawings, IListData } from '../../types/interfaces/i-document-data';
4
4
  import { IPaddingData } from '../../types/interfaces/i-style-data';
5
5
  import { UnitModel, UniverInstanceType } from '../../common/unit';
6
6
  import { SliceBodyType } from './text-x/utils';
@@ -29,9 +29,8 @@ declare class DocumentDataModelSimple extends UnitModel<IDocumentData, UniverIns
29
29
  get zoomRatio(): number;
30
30
  resetDrawing(drawings: IDrawings, drawingsOrder: string[]): void;
31
31
  getBody(): IDocumentBody | undefined;
32
- getShouldRenderLoopImmediately(): boolean;
33
- getContainer(): string | undefined;
34
32
  getSnapshot(): IDocumentData;
33
+ getBulletPresetList(): Record<string, IListData>;
35
34
  updateDocumentId(unitId: string): void;
36
35
  updateDocumentRenderConfig(config: IDocumentRenderConfig): void;
37
36
  updateDocumentStyle(config: IDocumentStyle): void;
@@ -19,7 +19,7 @@ export { type UnitType, UnitModel, UniverInstanceType } from './common/unit';
19
19
  export { Registry, RegistryAsMap } from './common/registry';
20
20
  export { CustomCommandExecutionError } from './common/error';
21
21
  export { Univer } from './univer';
22
- export { shallowEqual, isRangesEqual, isUnitRangesEqual } from './common/equal';
22
+ export { shallowEqual } from './common/equal';
23
23
  export { isNumeric, isSafeNumeric } from './common/number';
24
24
  export { isBooleanString } from './common/boolean';
25
25
  export { dedupe, remove, rotate, groupBy, makeArray } from './common/array';
@@ -76,23 +76,18 @@ export * from './types/interfaces';
76
76
  export { UniverInstanceService } from './services/instance/instance.service';
77
77
  export { LifecycleInitializerService } from './services/lifecycle/lifecycle.service';
78
78
  export { ConfigService } from './services/config/config.service';
79
+ export { isRangesEqual, isUnitRangesEqual } from './sheets/util';
79
80
  export { Range } from './sheets/range';
80
81
  export { Styles } from './sheets/styles';
81
82
  export { DEFAULT_WORKSHEET_COLUMN_COUNT, DEFAULT_WORKSHEET_COLUMN_COUNT_KEY, DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY, DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY, DEFAULT_WORKSHEET_ROW_COUNT_KEY, DEFAULT_WORKSHEET_ROW_HEIGHT_KEY, DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY, DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT, DEFAULT_WORKSHEET_COLUMN_WIDTH, DEFAULT_WORKSHEET_ROW_COUNT, DEFAULT_WORKSHEET_ROW_HEIGHT, DEFAULT_WORKSHEET_ROW_TITLE_WIDTH, mergeWorksheetSnapshotWithDefault, } from './sheets/sheet-snapshot-utils';
82
83
  export { SheetViewModel } from './sheets/view-model';
84
+ export * from './sheets/typedef';
83
85
  export { getWorksheetUID, Workbook } from './sheets/workbook';
84
86
  export { Worksheet, extractPureTextFromCell } from './sheets/worksheet';
85
87
  export { SlideDataModel } from './slides/slide-model';
86
88
  export * from './types/const';
87
89
  export * from './types/enum';
88
90
  export * from './types/interfaces';
89
- export { ISnapshotServerService } from './services/snapshot/snapshot-server.service';
90
- export { transformSnapshotToWorkbookData, transformWorkbookDataToSnapshot, transformDocumentDataToSnapshot, transformSnapshotToDocumentData, generateTemporarySnap, generateTempDocumentSnapshot, } from './services/snapshot/snapshot-transform';
91
- export { textEncoder, textDecoder } from './services/snapshot/snapshot-utils';
92
- export { type ILogContext } from './services/log/context';
93
- export { b64DecodeUnicode, b64EncodeUnicode } from './shared/coder';
94
- export { ClientSnapshotServerService } from './services/snapshot/snapshot-server.service';
95
- export { getSheetBlocksFromSnapshot } from './services/snapshot/snapshot-transform';
96
91
  export { isBlackColor, isWhiteColor } from './shared/color/color-kit';
97
92
  export { cellToRange } from './shared/common';
98
93
  export type { IDataValidationRule, IDataValidationRuleBase, IDataValidationRuleInfo, IDataValidationRuleOptions, ISheetDataValidationRule } from './types/interfaces/i-data-validation';
@@ -102,7 +97,7 @@ export { DataValidationImeMode } from './types/enum/data-validation-ime-mode';
102
97
  export { DataValidationOperator } from './types/enum/data-validation-operator';
103
98
  export { DataValidationType } from './types/enum/data-validation-type';
104
99
  export { DataValidationStatus } from './types/enum/data-validation-status';
105
- export type { IPermissionTypes, WorkbookPermissionPointConstructor } from './services/permission/type';
100
+ export type { IPermissionTypes, WorkbookPermissionPointConstructor, WorkSheetPermissionPointConstructor, RangePermissionPointConstructor } from './services/permission/type';
106
101
  export { PermissionService } from './services/permission/permission.service';
107
102
  export { AuthzIoLocalService } from './services/authz-io/authz-io-local.service';
108
103
  export { IAuthzIoService } from './services/authz-io/type';
@@ -112,4 +107,5 @@ export { normalizeBody, getCustomRangeSlice, getCustomDecorationSlice } from './
112
107
  export { updateAttributeByDelete } from './docs/data-model/text-x/apply-utils/delete-apply';
113
108
  export { updateAttributeByInsert } from './docs/data-model/text-x/apply-utils/insert-apply';
114
109
  export { nameCharacterCheck } from './shared/name';
110
+ export { mixinClass } from './common/mixin';
115
111
  export * from './common/di';
@@ -1,5 +1,5 @@
1
- import { ILogContext } from '@univerjs/core';
2
1
  import { IAllowedRequest, IAllowedResponse, IBatchAllowedResponse, ICreateCollaboratorRequest, ICreateRequest, ICreateResponse, IDeleteCollaboratorRequest, IListCollaboratorRequest, IListCollaboratorResponse, IListPermPointRequest, IListPermPointResponse, IListRolesRequest, IListRolesResponse, IPutCollaboratorsRequest, IUpdateCollaboratorRequest, IUpdatePermPointRequest } from '@univerjs/protocol';
2
+ import { ILogContext } from '../log/context';
3
3
  export interface IAuthzIoService {
4
4
  create(config: ICreateRequest, context?: ILogContext): Promise<ICreateResponse['objectID']>;
5
5
  allowed(config: IAllowedRequest, context?: ILogContext): Promise<IAllowedResponse['actions']>;
@@ -16,4 +16,4 @@ export interface IAuthzIoService {
16
16
  createCollaborator(config: ICreateCollaboratorRequest, context?: ILogContext): Promise<void>;
17
17
  putCollaborators(config: IPutCollaboratorsRequest, context?: ILogContext): Promise<void>;
18
18
  }
19
- export declare const IAuthzIoService: import('@univerjs/core').IdentifierDecorator<IAuthzIoService>;
19
+ export declare const IAuthzIoService: import('../../common/di').IdentifierDecorator<IAuthzIoService>;
@@ -2,106 +2,192 @@ import { IAccessor, IDisposable, Injector } from '../../common/di';
2
2
  import { Disposable } from '../../shared/lifecycle';
3
3
  import { IContextService } from '../context/context.service';
4
4
  import { ILogService } from '../log/log.service';
5
+ /**
6
+ * The type of a command.
7
+ */
5
8
  export declare enum CommandType {
6
- /** Command could generate some operations or mutations. */
9
+ /**
10
+ * Responsible for creating, orchestrating, and executing MUTATION or OPERATION according to specific business
11
+ * logic. For example, a delete row COMMAND will generate a delete row MUTATION, an insert row MUTATION for undo,
12
+ * and a set cell content MUTATION.
13
+ */
7
14
  COMMAND = 0,
8
- /** An operation that do not require conflict resolve. */
15
+ /**
16
+ * MUTATION is the change made to the data saved to snapshot, such as inserting rows and columns,
17
+ * modifying cell content, modifying filter ranges, etc. If you want to add collaborative editing capabilities to
18
+ * Univer, it is the smallest unit of conflict resolution.
19
+ */
9
20
  OPERATION = 1,
10
- /** An operation that need to be resolved before applied on peer client. */
21
+ /**
22
+ * OPERATION is the change made to data that is not saved to snapshot, without conflict resolution,
23
+ * such as modifying scroll position, modifying sidebar state, etc.
24
+ */
11
25
  MUTATION = 2
12
26
  }
27
+ /**
28
+ * In Univer, all data modifications need to be executed through commands. The command-based approach can better track
29
+ * changes in values, implement functions such as undo, redo, and collaborative editing, handle complex associated
30
+ * logic between functions, etc.
31
+ *
32
+ * All commands should implements this interface or related {@link IMutation} or {@link IOperation} interface, and
33
+ * should be registered in the {@link ICommandService}.
34
+ */
13
35
  export interface ICommand<P extends object = object, R = boolean> {
14
36
  /**
15
- * ${businessName}.${type}.${name}
37
+ * Identifier of the command. It should be unique in the application unless it is a {@link IMultiCommand}.
38
+ * Its pattern should be like `<namespace>.<type>.<command-name>`.
39
+ *
40
+ * @example { id: 'sheet.command.set-selection-frozen' }
16
41
  */
17
42
  readonly id: string;
43
+ /**
44
+ * The type of the command.
45
+ */
18
46
  readonly type: CommandType;
19
- handler(accessor: IAccessor, params?: P, options?: IExecutionOptions): Promise<R> | R;
20
47
  /**
21
- * When this command is unregistered, this function would be called.
22
- *
23
- * @deprecated
48
+ * The handler of the command.
49
+ * @param accessor The accessor to the dependency injection container.
50
+ * @param params Params of the command. Params should be serializable.
51
+ * @param options Options of the command.
52
+ * @returns The result of the command. By default it should be a boolean value which indicates the command is
53
+ * executed successfully or not.
24
54
  */
25
- onDispose?: () => void;
55
+ handler(accessor: IAccessor, params?: P, options?: IExecutionOptions): Promise<R> | R;
26
56
  }
57
+ /**
58
+ * A command that may have multiple implementations. Each implementation should have different `priority`
59
+ * and `preconditions` callback to determine which implementation should be executed.
60
+ */
27
61
  export interface IMultiCommand<P extends object = object, R = boolean> extends ICommand<P, R> {
62
+ /** The name of the multi command. It should be unique in the application. */
28
63
  name: string;
64
+ /** @ignore */
29
65
  multi: true;
66
+ /** Priority of this implementation. Implementation with higher priority will be checked first. */
30
67
  priority: number;
68
+ /**
69
+ * A callback function that tells `ICommandService` if this implementation should be executed.
70
+ * @param contextService The context service.
71
+ * @returns If this implementation should be executed, return `true`, otherwise return `false`.
72
+ */
31
73
  preconditions?: (contextService: IContextService) => boolean;
32
74
  }
33
75
  export interface IMutationCommonParams {
76
+ /**
77
+ * It is used to indicate which {@link CommandType.COMMAND} triggers the mutation.
78
+ */
34
79
  trigger?: string;
35
80
  }
36
81
  /**
37
- * Mutation would change the model of Univer applications.
82
+ * {@link CommandType.MUTATION} should implement this interface.
38
83
  */
39
84
  export interface IMutation<P extends object, R = boolean> extends ICommand<P, R> {
40
85
  type: CommandType.MUTATION;
41
86
  /**
42
- * Mutations must be a sync process.
43
- * @param accessor
44
- * @param params Params of the mutation. A mutation must has params.
87
+ * The handler of the mutation.
88
+ * @param accessor The accessor to the dependency injection container.
89
+ * @param params Params of the mutation. Params should be serializable.
90
+ * @returns The result of the mutation. By default it should be a boolean value which indicates the mutation is
91
+ * executed successfully or not.
45
92
  */
46
93
  handler(accessor: IAccessor, params: P): R;
47
94
  }
48
95
  /**
49
- * Operation would change the state of Univer applications. State should only be in memory and does not
50
- * require conflicting resolution.
96
+ * {@link CommandType.OPERATION} should implement this interface.
51
97
  */
52
98
  export interface IOperation<P extends object = object, R = boolean> extends ICommand<P, R> {
53
99
  type: CommandType.OPERATION;
54
100
  /**
55
- * Operations must be a sync process.
56
- * @param accessor
57
- * @param params Params of the operation. A operation must has params.
101
+ * The handler of the operation.
102
+ * @param accessor The accessor to the dependency injection container.
103
+ * @param params Params of the operation. Params should be serializable.
104
+ * @returns The result of the operation. By default it should be a boolean value which indicates the operation is
105
+ * executed successfully or not.
58
106
  */
59
107
  handler(accessor: IAccessor, params: P): R;
60
108
  }
61
109
  /**
62
- * The command info, only a command id and responsible params
110
+ * This object represents an execution of a command.
63
111
  */
64
112
  export interface ICommandInfo<T extends object = object> {
113
+ /**
114
+ * Id of the command being executed.
115
+ */
65
116
  id: string;
117
+ /**
118
+ * Type of the command.
119
+ */
66
120
  type?: CommandType;
67
121
  /**
68
- * Args should be serializable.
122
+ * Parameters of this execution.
69
123
  */
70
124
  params?: T;
71
125
  }
126
+ /** This object represents an execution of a {@link CommandType.MUTATION} */
72
127
  export interface IMutationInfo<T extends object = object> {
73
128
  id: string;
74
129
  type?: CommandType.MUTATION;
75
130
  params: T;
76
131
  }
132
+ /** This object represents an execution of a {@link CommandType.OPERATION} */
77
133
  export interface IOperationInfo<T extends object = object> {
78
134
  id: string;
79
135
  type?: CommandType.OPERATION;
80
136
  params: T;
81
137
  }
82
138
  export interface IExecutionOptions {
83
- /** This mutation should only be executed on the local machine, and not synced to replicas. */
139
+ /** This mutation should only be executed on the local machine, and should not be synced to replicas. */
84
140
  onlyLocal?: boolean;
85
141
  /** This command is from collaboration peers. */
86
142
  fromCollab?: boolean;
143
+ /** @deprecated */
87
144
  fromChangeset?: boolean;
88
145
  [key: PropertyKey]: string | number | boolean | undefined;
89
146
  }
90
147
  export type CommandListener = (commandInfo: Readonly<ICommandInfo>, options?: IExecutionOptions) => void;
148
+ /**
149
+ * The identifier of the command service.
150
+ */
151
+ export declare const ICommandService: import('../../common/di').IdentifierDecorator<ICommandService>;
152
+ /**
153
+ * The service to register and execute commands.
154
+ */
91
155
  export interface ICommandService {
92
156
  /**
93
157
  * Check if a command is already registered at the current command service.
94
- *
95
158
  * @param commandId The id of the command.
159
+ * @returns If the command is registered, return `true`, otherwise return `false`.
96
160
  */
97
161
  hasCommand(commandId: string): boolean;
162
+ /**
163
+ * Register a command to the command service.
164
+ * @param command The command to register.
165
+ */
98
166
  registerCommand(command: ICommand<object, unknown>): IDisposable;
167
+ /**
168
+ * Register a command as a multi command.
169
+ * @param command The command to register as a multi command.
170
+ */
99
171
  registerMultipleCommand(command: ICommand<object, unknown>): IDisposable;
172
+ /**
173
+ * Execute a command with the given id and parameters.
174
+ * @param id Identifier of the command.
175
+ * @param params Parameters of this execution.
176
+ * @param options Options of this execution.
177
+ * @returns The result of the execution. It is a boolean value by default which indicates the command is executed.
178
+ */
100
179
  executeCommand<P extends object = object, R = boolean>(id: string, params?: P, options?: IExecutionOptions): Promise<R>;
101
- hasCommand(id: string): boolean;
180
+ /**
181
+ * Execute a command with the given id and parameters synchronously.
182
+ * @param id Identifier of the command.
183
+ * @param params Parameters of this execution.
184
+ * @param options Options of this execution.
185
+ * @returns The result of the execution. It is a boolean value by default which indicates the command is executed.
186
+ */
102
187
  syncExecuteCommand<P extends object = object, R = boolean>(id: string, params?: P, options?: IExecutionOptions): R;
103
188
  /**
104
189
  * Register a callback function that will be executed after a command is executed.
190
+ * @param listener
105
191
  */
106
192
  onCommandExecuted(listener: CommandListener): IDisposable;
107
193
  /**
@@ -110,11 +196,7 @@ export interface ICommandService {
110
196
  */
111
197
  beforeCommandExecuted(listener: CommandListener): IDisposable;
112
198
  }
113
- export declare const ICommandService: import('../../common/di').IdentifierDecorator<ICommandService>;
114
- /**
115
- * The registry of commands.
116
- */
117
- export declare class CommandRegistry {
199
+ declare class CommandRegistry {
118
200
  private readonly _commands;
119
201
  private readonly _commandTypes;
120
202
  registerCommand(command: ICommand): IDisposable;
@@ -149,3 +231,4 @@ export declare class CommandService extends Disposable implements ICommandServic
149
231
  }
150
232
  export declare function sequenceExecute(tasks: ICommandInfo[], commandService: ICommandService, options?: IExecutionOptions): import('../../common/sequence').ISequenceExecuteResult;
151
233
  export declare function sequenceExecuteAsync(tasks: ICommandInfo[], commandService: ICommandService, options?: IExecutionOptions): Promise<import('../../common/sequence').ISequenceExecuteResult>;
234
+ export {};
@@ -35,6 +35,8 @@ export declare const LifecycleToModules: Map<LifecycleStages, DependencyIdentifi
35
35
  * @param identifier The dependency identifier of the class. Usually, it is the class itself unless you bind this class
36
36
  * with another injection identifier.
37
37
  *
38
+ * @deprecated This API does not work as expected and will be removed in future versions. Please call
39
+ * `this._injector.get(YourDependency)` in plugins' lifecycle hooks instead.
38
40
  *
39
41
  * @example
40
42
  * // Ignore the `\` below. This is JSDoc's bug.
@@ -56,6 +58,9 @@ export declare function OnLifecycle(lifecycleStage: LifecycleStages, identifier:
56
58
  * @param identifier The dependencies' identifier. **Beware** that if the dependency (e.g. a class) is bound to an
57
59
  * identifier, you should register the identifier instead of the dependency itself.
58
60
  *
61
+ * @deprecated This API does not work as expected and will be removed in future versions. Please call
62
+ * `this._injector.get(YourDependency)` in plugins' lifecycle hooks instead.
63
+ *
59
64
  * @example
60
65
  * runOnLifecycle(LifecycleStages.Ready, MyService);
61
66
  *
@@ -1,7 +1,7 @@
1
1
  import { BehaviorSubject, Observable } from 'rxjs';
2
2
  import { UnitAction, UnitObject } from '@univerjs/protocol';
3
- import { Nullable } from '../../common/type-utils';
4
- import { IRange } from '../../types/interfaces';
3
+ import { IRange } from '../../sheets/typedef';
4
+ import { Nullable } from '../../shared/types';
5
5
  export declare enum PermissionStatus {
6
6
  INIT = "init",
7
7
  FETCHING = "fetching",
@@ -1,15 +1,13 @@
1
- import { Workbook } from '../../sheets/workbook';
2
- import { IWorkbookData } from '../../types/interfaces';
3
1
  import { IResourceManagerService } from '../resource-manager/type';
4
2
  import { IUniverInstanceService } from '../instance/instance.service';
5
3
  import { Disposable } from '../../shared/lifecycle';
6
- import { DocumentDataModel } from '../../docs';
7
4
  import { IResourceLoaderService } from './type';
8
5
  export declare class ResourceLoaderService extends Disposable implements IResourceLoaderService {
9
6
  private readonly _resourceManagerService;
10
7
  private readonly _univerInstanceService;
11
8
  constructor(_resourceManagerService: IResourceManagerService, _univerInstanceService: IUniverInstanceService);
12
9
  private _init;
13
- saveWorkbook: (workbook: Workbook) => IWorkbookData;
14
- saveDoc(doc: DocumentDataModel): import('../../types/interfaces').IDocumentData;
10
+ saveUnit<T = object>(unitId: string): ({
11
+ resources: import('../resource-manager/type').IResources;
12
+ } & T) | null;
15
13
  }
@@ -1,9 +1,7 @@
1
- import { Workbook } from '../../sheets/workbook';
2
- import { IWorkbookData } from '../../types/interfaces/i-workbook-data';
3
- import { IDocumentData } from '../../types/interfaces';
4
- import { DocumentDataModel } from '../../docs';
1
+ import { IResources } from '../resource-manager/type';
5
2
  export interface IResourceLoaderService {
6
- saveWorkbook: (workbook: Workbook) => IWorkbookData;
7
- saveDoc: (doc: DocumentDataModel) => IDocumentData;
3
+ saveUnit<T = object>(unitId: string): T & {
4
+ resources: IResources;
5
+ } | null;
8
6
  }
9
7
  export declare const IResourceLoaderService: import('../../common/di').IdentifierDecorator<IResourceLoaderService>;
@@ -1,21 +1,21 @@
1
1
  import { Disposable } from '../../shared/lifecycle';
2
- import { Resources } from '../../types/interfaces/i-workbook-data';
3
2
  import { UniverInstanceType } from '../../common/unit';
3
+ import { IResources } from '../resource-manager/type';
4
4
  import { IResourceHook, IResourceManagerService, IResourceName } from './type';
5
5
  export declare class ResourceManagerService extends Disposable implements IResourceManagerService {
6
6
  private _resourceMap;
7
7
  private _register$;
8
8
  register$: import('rxjs').Observable<IResourceHook<any>>;
9
9
  getAllResourceHooks(): IResourceHook<any>[];
10
- getResources(unitId: string): Resources;
11
- getResources(unitId: string, type: UniverInstanceType): Resources;
10
+ getResources(unitId: string): IResources;
11
+ getResources(unitId: string, type: UniverInstanceType): IResources;
12
12
  getResourcesByType(unitId: string, type: UniverInstanceType): {
13
13
  name: `SHEET_${string}_PLUGIN` | `DOC_${string}_PLUGIN`;
14
14
  data: string;
15
15
  }[];
16
16
  registerPluginResource<T = unknown>(hook: IResourceHook<T>): import('@wendellhu/redi').IDisposable;
17
17
  disposePluginResource(pluginName: IResourceName): void;
18
- loadResources(unitId: string, resources?: Resources): void;
18
+ loadResources(unitId: string, resources?: IResources): void;
19
19
  unloadResources(unitId: string): void;
20
20
  dispose(): void;
21
21
  }
@@ -1,7 +1,11 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { UniverInstanceType } from '@univerjs/core';
3
3
  import { IDisposable } from '../../common/di';
4
- import { Resources } from '../../types/interfaces/i-workbook-data';
4
+ export type IResources = Array<{
5
+ id?: string;
6
+ name: string;
7
+ data: string;
8
+ }>;
5
9
  type IBusinessName = 'SHEET' | 'DOC';
6
10
  export type IResourceName = `${IBusinessName}_${string}_PLUGIN`;
7
11
  export interface IResourceHook<T = any> {
@@ -20,10 +24,10 @@ export interface IResourceManagerService {
20
24
  /**
21
25
  * @deprecated You should get resource with type specified.
22
26
  */
23
- getResources(unitId: string): Resources;
24
- getResources(unitId: string, type: UniverInstanceType): Resources;
25
- getResourcesByType: (unitId: string, type: UniverInstanceType) => Resources;
26
- loadResources: (unitId: string, resources?: Resources) => void;
27
+ getResources(unitId: string): IResources;
28
+ getResources(unitId: string, type: UniverInstanceType): IResources;
29
+ getResourcesByType: (unitId: string, type: UniverInstanceType) => IResources;
30
+ loadResources: (unitId: string, resources?: IResources) => void;
27
31
  unloadResources(unitId: string): void;
28
32
  }
29
33
  export declare const IResourceManagerService: import('@univerjs/core').IdentifierDecorator<IResourceManagerService>;
@@ -4,7 +4,7 @@ import { Disposable } from '../../shared/lifecycle';
4
4
  import { IMutationInfo, CommandType, ICommandService } from '../command/command.service';
5
5
  import { IContextService } from '../context/context.service';
6
6
  import { IUniverInstanceService } from '../instance/instance.service';
7
- import { Nullable } from '../../common/type-util';
7
+ import { Nullable } from '../../shared/types';
8
8
  export interface IUndoRedoItem {
9
9
  /** unitID maps to unitId for UniverSheet / UniverDoc / UniverSlide */
10
10
  unitID: string;
@@ -1,5 +1,5 @@
1
- import { Nullable } from '../common/type-util';
2
1
  import { ITransformState } from '../types/interfaces/i-document-data';
2
+ import { Nullable } from './types';
3
3
  export declare const MOVE_BUFFER_VALUE = 2;
4
4
  export declare const ROTATE_BUFFER_VALUE = 1;
5
5
  export declare function checkIfMove(transform: Nullable<ITransformState>, previousTransform: Nullable<ITransformState>): boolean;
@@ -1,5 +1,5 @@
1
- import { Nullable } from '../../common/type-util';
2
1
  import { ColorType, ThemeColors, ThemeColorType } from '../../types/enum';
2
+ import { Nullable } from '../types';
3
3
  export declare class ColorBuilder {
4
4
  private _themeValue;
5
5
  private _themeColors;
@@ -1,7 +1,5 @@
1
- import { IRange } from '../types/interfaces';
2
- import { ICellData, ICellDataForSheetInterceptor } from '../types/interfaces/i-cell-data';
1
+ import { ICellData, ICellDataForSheetInterceptor, IRange, IRangeWithCoord, ISelectionCell, ISelectionCellWithMergeInfo } from '../sheets/typedef';
3
2
  import { IDocumentData } from '../types/interfaces/i-document-data';
4
- import { IRangeWithCoord, ISelectionCell, ISelectionCellWithMergeInfo } from '../types/interfaces/i-selection-data';
5
3
  import { IColorStyle, IStyleData } from '../types/interfaces/i-style-data';
6
4
  import { Nullable } from './types';
7
5
  export declare function makeCellToSelection(cellInfo: ISelectionCellWithMergeInfo): IRangeWithCoord;
@@ -28,7 +26,7 @@ export declare function isFormulaId(value: any): boolean;
28
26
  */
29
27
  export declare function handleStyleToString(style: IStyleData, isCell?: boolean): string;
30
28
  export declare function getBorderStyleType(type: string): number;
31
- export declare function getDocsUpdateBody(model: IDocumentData, segmentId?: string): import('../types/interfaces').IDocumentBody | undefined;
29
+ export declare function getDocsUpdateBody(model: IDocumentData, segmentId?: string): import('../types/interfaces/i-document-data').IDocumentBody | undefined;
32
30
  export declare function isValidRange(range: IRange): boolean;
33
31
  /**
34
32
  * Covert row/column to range object
@@ -1,2 +1,3 @@
1
- import { default as numfmt } from 'numfmt';
1
+ import { INumfmt } from './types/numfmt.type';
2
+ declare const numfmt: INumfmt;
2
3
  export { numfmt };
@@ -1,3 +1,3 @@
1
- import { IRange } from '../types/interfaces';
1
+ import { IRange } from '../sheets/typedef';
2
2
  import { ObjectMatrix } from './object-matrix';
3
3
  export declare function queryObjectMatrix<T>(matrix: ObjectMatrix<T>, match: (value: T) => boolean): IRange[];
@@ -1,4 +1,4 @@
1
- import { IRange } from '../types/interfaces/i-range';
1
+ import { IRange } from '../sheets/typedef';
2
2
  import { Nullable } from './types';
3
3
  /**
4
4
  * Object Matrix Primitive Type
@@ -1,2 +1,2 @@
1
- import { IRange } from '../types/interfaces/i-range';
1
+ import { IRange } from '../sheets/typedef';
2
2
  export declare function moveRangeByOffset(range: IRange, refOffsetX: number, refOffsetY: number, ignoreAbsolute?: boolean): IRange;
@@ -1,4 +1,4 @@
1
- import { IRange, IRectLTRB } from '../types/interfaces/i-range';
1
+ import { IRange, IRectLTRB } from '../sheets/typedef';
2
2
  import { Nullable } from './types';
3
3
  /**
4
4
  * This class provides a set of methods to calculate `IRange`.
@@ -1,4 +1,4 @@
1
- import { Class, IKeyValue } from './types';
1
+ import { IKeyValue } from './types';
2
2
  /**
3
3
  * Universal tool library
4
4
  */
@@ -23,7 +23,6 @@ export declare class Tools {
23
23
  static getValueType(value: any): string;
24
24
  static isDefine<T>(value?: T | void): value is T;
25
25
  static isBlank(value: any): boolean;
26
- static isAssignableFrom<T>(object: any, clazz: Class<T>): object is T;
27
26
  static isBoolean(value?: any): value is boolean;
28
27
  static isPlainObject(value: any): value is object;
29
28
  static isFunction(value?: any): value is boolean;