@univerjs/core 0.1.6 → 0.1.8
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/index.js +8 -8
- package/lib/es/index.js +5162 -5004
- package/lib/types/common/boolean.d.ts +16 -0
- package/lib/types/common/const.d.ts +2 -0
- package/lib/types/common/interceptor.d.ts +2 -2
- package/lib/types/common/number.d.ts +17 -0
- package/lib/types/{basics/index.d.ts → common/set.d.ts} +7 -5
- package/lib/types/common/type-util.d.ts +16 -0
- package/lib/types/common/unit.d.ts +9 -0
- package/lib/types/docs/data-model/document-data-model.d.ts +4 -1
- package/lib/types/index.d.ts +22 -10
- package/lib/types/services/command/command.service.d.ts +10 -1
- package/lib/types/services/context/context.d.ts +1 -0
- package/lib/types/services/floating-object/floating-object-manager.service.d.ts +1 -1
- package/lib/types/services/instance/instance.service.d.ts +71 -94
- package/lib/types/services/lifecycle/lifecycle.service.d.ts +2 -2
- package/lib/types/services/permission/permission.service.d.ts +0 -1
- package/lib/types/services/permission/univer.permission.service.d.ts +2 -2
- package/lib/types/services/plugin/plugin-holder.d.ts +25 -0
- package/lib/types/services/plugin/plugin-override.d.ts +8 -0
- package/lib/types/{plugin → services/plugin}/plugin.d.ts +11 -16
- package/lib/types/services/plugin/plugin.service.d.ts +24 -0
- package/lib/types/services/resource-loader/resource-loader.service.d.ts +14 -0
- package/lib/types/services/resource-loader/type.d.ts +7 -0
- package/lib/types/services/resource-manager/resource-manager.service.d.ts +11 -17
- package/lib/types/services/resource-manager/type.d.ts +15 -18
- package/lib/types/services/undoredo/undoredo.service.d.ts +2 -2
- package/lib/types/shared/__tests__/ref-alias.spec.d.ts +16 -0
- package/lib/types/shared/clipboard.d.ts +5 -0
- package/lib/types/shared/color/color.d.ts +1 -1
- package/lib/types/shared/common.d.ts +10 -0
- package/lib/types/shared/index.d.ts +2 -0
- package/lib/types/shared/lifecycle.d.ts +8 -3
- package/lib/types/shared/range.d.ts +3 -0
- package/lib/types/sheets/__tests__/create-core-test-bed.d.ts +2 -2
- package/lib/types/sheets/column-manager.d.ts +1 -1
- package/lib/types/sheets/row-manager.d.ts +4 -2
- package/lib/types/sheets/view-model.d.ts +18 -10
- package/lib/types/sheets/workbook.d.ts +3 -2
- package/lib/types/sheets/worksheet.d.ts +33 -8
- package/lib/types/slides/{domain/slide-model.d.ts → slide-model.d.ts} +7 -5
- package/lib/types/types/enum/index.d.ts +0 -1
- package/lib/types/types/interfaces/i-cell-custom-render.d.ts +2 -0
- package/lib/types/types/interfaces/i-cell-data.d.ts +4 -0
- package/lib/types/types/interfaces/i-range.d.ts +3 -0
- package/lib/types/types/interfaces/i-style-data.d.ts +6 -0
- package/lib/types/types/interfaces/i-univer-data.d.ts +2 -13
- package/lib/types/univer.d.ts +43 -0
- package/lib/umd/index.js +9 -9
- package/package.json +10 -10
- package/lib/types/basics/plugin-holder.d.ts +0 -16
- package/lib/types/basics/univer-doc.d.ts +0 -16
- package/lib/types/basics/univer-sheet.d.ts +0 -16
- package/lib/types/basics/univer-slide.d.ts +0 -16
- package/lib/types/basics/univer.d.ts +0 -46
- package/lib/types/slides/domain/index.d.ts +0 -16
- package/lib/types/types/enum/condition-type.d.ts +0 -49
- /package/lib/types/{basics → common}/registry.d.ts +0 -0
- /package/lib/types/shared/{__test__ → __tests__}/common.spec.d.ts +0 -0
- /package/lib/types/shared/{__test__ → __tests__}/object-matrix.spec.d.ts +0 -0
- /package/lib/types/shared/{__test__/rectangle.spec.d.ts → __tests__/range.spec.d.ts} +0 -0
- /package/lib/types/shared/{__test__/ref-alias.spec.d.ts → __tests__/rectangle.spec.d.ts} +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isBooleanString(str: string): boolean;
|
|
@@ -16,3 +16,5 @@
|
|
|
16
16
|
export declare const DOCS_NORMAL_EDITOR_UNIT_ID_KEY = "__defaultDocumentNormalEditorSpecialUnitId_20231006__";
|
|
17
17
|
export declare const DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY = "__defaultDocumentFormulaBarEditorSpecialUnitId_20231012__";
|
|
18
18
|
export declare const DEFAULT_EMPTY_DOCUMENT_VALUE = "\r\n";
|
|
19
|
+
export declare function createInternalEditorID(id: string): string;
|
|
20
|
+
export declare function isInternalEditorID(id: string): boolean;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Nullable } from './type-
|
|
1
|
+
import { Nullable } from './type-util';
|
|
2
2
|
|
|
3
3
|
export type InterceptorHandler<M = unknown, C = unknown> = (value: Nullable<M>, context: C, next: (value: Nullable<M>) => Nullable<M>) => Nullable<M>;
|
|
4
4
|
export interface IInterceptor<M, C> {
|
|
5
5
|
priority?: number;
|
|
6
6
|
handler: InterceptorHandler<M, C>;
|
|
7
7
|
}
|
|
8
|
-
export declare
|
|
8
|
+
export declare function createInterceptorKey<T, C>(key: string): IInterceptor<T, C>;
|
|
9
9
|
export type IComposeInterceptors<T = any, C = any> = (interceptors: Array<IInterceptor<T, C>>) => (initValue: Nullable<T>, initContext: C) => Nullable<T>;
|
|
10
10
|
/**
|
|
11
11
|
* A helper to compose a certain type of interceptors.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isNumeric(str: string): boolean;
|
|
17
|
+
export declare function isSafeNumeric(str: string): boolean;
|
|
@@ -13,8 +13,10 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Merge the second set to the first set.
|
|
18
|
+
* @param s1 the first set
|
|
19
|
+
* @param s2 the second set
|
|
20
|
+
* @returns the merged set
|
|
21
|
+
*/
|
|
22
|
+
export declare function mergeSets<T>(s1: Set<T>, s2: Set<T>): Set<T>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export type Nullable<T> = T | null | undefined | void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Disposable } from '../shared';
|
|
2
|
+
import { UniverType } from '@univerjs/protocol';
|
|
3
|
+
|
|
4
|
+
export { UniverType as UniverInstanceType } from '@univerjs/protocol';
|
|
5
|
+
export type UnitType = UniverType | number;
|
|
6
|
+
export declare abstract class UnitModel<_D = object, T extends UnitType = UnitType> extends Disposable {
|
|
7
|
+
abstract readonly type: T;
|
|
8
|
+
abstract getUnitId(): string;
|
|
9
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TextXAction } from './action-types';
|
|
2
|
+
import { UnitModel, UniverInstanceType } from '../../common/unit';
|
|
2
3
|
import { IPaddingData } from '../../types/interfaces/i-style-data';
|
|
3
4
|
import { IDocumentBody, IDocumentData, IDocumentRenderConfig, IDocumentStyle } from '../../types/interfaces/i-document-data';
|
|
4
5
|
import { Nullable } from '../../shared';
|
|
@@ -13,7 +14,9 @@ interface IDrawingUpdateConfig {
|
|
|
13
14
|
height: number;
|
|
14
15
|
width: number;
|
|
15
16
|
}
|
|
16
|
-
declare class DocumentDataModelSimple {
|
|
17
|
+
declare class DocumentDataModelSimple extends UnitModel<IDocumentData, UniverInstanceType.UNIVER_DOC> {
|
|
18
|
+
type: UniverInstanceType.UNIVER_DOC;
|
|
19
|
+
getUnitId(): string;
|
|
17
20
|
snapshot: IDocumentData;
|
|
18
21
|
constructor(snapshot: Partial<IDocumentData>);
|
|
19
22
|
get drawings(): import('../../types/interfaces/i-document-data').IDrawings | undefined;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -13,10 +13,16 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
export { type UnitType, UnitModel, UniverInstanceType } from './common/unit';
|
|
17
|
+
export { Registry, RegistryAsMap } from './common/registry';
|
|
18
|
+
export { Univer } from './univer';
|
|
19
|
+
export { PluginHolder } from './services/plugin/plugin-holder';
|
|
16
20
|
export { shallowEqual, isRangesEqual, isUnitRangesEqual } from './common/equal';
|
|
17
|
-
export
|
|
21
|
+
export { isNumeric, isSafeNumeric } from './common/number';
|
|
22
|
+
export { isBooleanString } from './common/boolean';
|
|
18
23
|
export { dedupe, remove, rotate, groupBy } from './common/array';
|
|
19
|
-
export {
|
|
24
|
+
export { mergeSets } from './common/set';
|
|
25
|
+
export { DEFAULT_EMPTY_DOCUMENT_VALUE, DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, createInternalEditorID, isInternalEditorID, } from './common/const';
|
|
20
26
|
export { throttle } from './common/function';
|
|
21
27
|
export { MemoryCursor } from './common/memory-cursor';
|
|
22
28
|
export { requestImmediateMacroTask } from './common/request-immediate-macro-task';
|
|
@@ -29,7 +35,8 @@ export { getBodySlice, composeBody } from './docs/data-model/text-x/utils';
|
|
|
29
35
|
export { TextX } from './docs/data-model/text-x/text-x';
|
|
30
36
|
export { replaceInDocumentBody } from './docs/data-model/replacement';
|
|
31
37
|
export * from './observer';
|
|
32
|
-
export { Plugin
|
|
38
|
+
export { Plugin } from './services/plugin/plugin';
|
|
39
|
+
export { PluginService } from './services/plugin/plugin.service';
|
|
33
40
|
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';
|
|
34
41
|
export { IConfigService } from './services/config/config.service';
|
|
35
42
|
export * from './services/context/context';
|
|
@@ -37,16 +44,17 @@ export { ContextService, IContextService } from './services/context/context.serv
|
|
|
37
44
|
export { ErrorService, type IError } from './services/error/error.service';
|
|
38
45
|
export type { IOffset, IScale, ISize, ITransformState } from './services/floating-object/floating-object-interfaces';
|
|
39
46
|
export { DEFAULT_DOCUMENT_SUB_COMPONENT_ID, FloatingObjectManagerService, type IFloatingObjectManagerParam, type IFloatingObjectManagerSearchItemParam, IFloatingObjectManagerService, } from './services/floating-object/floating-object-manager.service';
|
|
40
|
-
export { IUniverInstanceService
|
|
47
|
+
export { IUniverInstanceService } from './services/instance/instance.service';
|
|
41
48
|
export { LifecycleStages, OnLifecycle, runOnLifecycle } from './services/lifecycle/lifecycle';
|
|
42
49
|
export { LifecycleService } from './services/lifecycle/lifecycle.service';
|
|
43
50
|
export { ILocalStorageService } from './services/local-storage/local-storage.service';
|
|
44
51
|
export { LocaleService } from './services/locale/locale.service';
|
|
45
52
|
export { DesktopLogService, ILogService, LogLevel } from './services/log/log.service';
|
|
46
53
|
export { IPermissionService, PermissionService, UniverEditablePermission, UniverEditablePermissionPoint, UniverPermissionService, } from './services/permission';
|
|
54
|
+
export { IResourceLoaderService } from './services/resource-loader/type';
|
|
47
55
|
export { ResourceManagerService } from './services/resource-manager/resource-manager.service';
|
|
48
56
|
export type { IResourceHook } from './services/resource-manager/type';
|
|
49
|
-
export { IResourceManagerService
|
|
57
|
+
export { IResourceManagerService } from './services/resource-manager/type';
|
|
50
58
|
export { type IStyleSheet, ThemeService } from './services/theme/theme.service';
|
|
51
59
|
export { type IUndoRedoCommandInfos, type IUndoRedoCommandInfosByInterceptor, type IUndoRedoItem, IUndoRedoService, type IUndoRedoStatus, LocalUndoRedoService, RedoCommand, UndoCommand, RedoCommandId, UndoCommandId, } from './services/undoredo/undoredo.service';
|
|
52
60
|
export * from './shared';
|
|
@@ -54,20 +62,24 @@ export { fromCallback } from './shared/rxjs';
|
|
|
54
62
|
export type { IComposeInterceptors, IInterceptor, InterceptorHandler } from './common/interceptor';
|
|
55
63
|
export { composeInterceptors, createInterceptorKey, InterceptorManager } from './common/interceptor';
|
|
56
64
|
export { normalizeTextRuns } from './docs/data-model/apply-utils/common';
|
|
57
|
-
export type { PluginCtor } from './plugin/plugin';
|
|
65
|
+
export type { PluginCtor } from './services/plugin/plugin';
|
|
66
|
+
export { type DependencyOverride, mergeOverrideWithDependencies } from './services/plugin/plugin-override';
|
|
67
|
+
export * from './types/const';
|
|
68
|
+
export * from './types/enum';
|
|
69
|
+
export * from './types/interfaces';
|
|
70
|
+
export { UniverInstanceService } from './services/instance/instance.service';
|
|
71
|
+
export { LifecycleInitializerService } from './services/lifecycle/lifecycle.service';
|
|
72
|
+
export { ConfigService } from './services/config/config.service';
|
|
58
73
|
export { Range } from './sheets/range';
|
|
59
74
|
export { Styles } from './sheets/styles';
|
|
60
75
|
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';
|
|
61
76
|
export { SheetViewModel } from './sheets/view-model';
|
|
62
77
|
export { getWorksheetUID, Workbook } from './sheets/workbook';
|
|
63
78
|
export { Worksheet, extractPureTextFromCell } from './sheets/worksheet';
|
|
64
|
-
export
|
|
79
|
+
export { SlideDataModel } from './slides/slide-model';
|
|
65
80
|
export * from './types/const';
|
|
66
81
|
export * from './types/enum';
|
|
67
82
|
export * from './types/interfaces';
|
|
68
|
-
export { UniverInstanceService } from './services/instance/instance.service';
|
|
69
|
-
export { LifecycleInitializerService } from './services/lifecycle/lifecycle.service';
|
|
70
|
-
export { ConfigService } from './services/config/config.service';
|
|
71
83
|
export { ISnapshotServerService } from './services/snapshot/snapshot-server.service';
|
|
72
84
|
export { transformSnapshotToWorkbookData, transformWorkbookDataToSnapshot, transformDocumentDataToSnapshot, transformSnapshotToDocumentData, generateTemporarySnap, } from './services/snapshot/snapshot-transform';
|
|
73
85
|
export { textEncoder, textDecoder } from './services/snapshot/snapshot-utils';
|
|
@@ -88,9 +88,16 @@ export interface IExecutionOptions {
|
|
|
88
88
|
}
|
|
89
89
|
export type CommandListener = (commandInfo: Readonly<ICommandInfo>, options?: IExecutionOptions) => void;
|
|
90
90
|
export interface ICommandService {
|
|
91
|
+
/**
|
|
92
|
+
* Check if a command is already registered at the current command service.
|
|
93
|
+
*
|
|
94
|
+
* @param commandId The id of the command.
|
|
95
|
+
*/
|
|
96
|
+
hasCommand(commandId: string): boolean;
|
|
91
97
|
registerCommand(command: ICommand<object, unknown>): IDisposable;
|
|
92
98
|
registerMultipleCommand(command: ICommand<object, unknown>): IDisposable;
|
|
93
99
|
executeCommand<P extends object = object, R = boolean>(id: string, params?: P, options?: IExecutionOptions): Promise<R>;
|
|
100
|
+
hasCommand(id: string): boolean;
|
|
94
101
|
syncExecuteCommand<P extends object = object, R = boolean>(id: string, params?: P, options?: IExecutionOptions): R;
|
|
95
102
|
/**
|
|
96
103
|
* Register a callback function that will be executed after a command is executed.
|
|
@@ -109,8 +116,10 @@ export declare const ICommandService: import('@wendellhu/redi').IdentifierDecora
|
|
|
109
116
|
export declare class CommandRegistry {
|
|
110
117
|
private readonly _commands;
|
|
111
118
|
registerCommand(command: ICommand): IDisposable;
|
|
119
|
+
hasCommand(id: string): boolean;
|
|
112
120
|
getCommand(id: string): [ICommand] | null;
|
|
113
121
|
}
|
|
122
|
+
export declare const NilCommand: ICommand;
|
|
114
123
|
export declare class CommandService implements ICommandService {
|
|
115
124
|
private readonly _injector;
|
|
116
125
|
private readonly _logService;
|
|
@@ -121,6 +130,7 @@ export declare class CommandService implements ICommandService {
|
|
|
121
130
|
private _commandExecutingLevel;
|
|
122
131
|
private _commandExecutionStack;
|
|
123
132
|
constructor(_injector: Injector, _logService: ILogService);
|
|
133
|
+
hasCommand(commandId: string): boolean;
|
|
124
134
|
registerCommand(command: ICommand): IDisposable;
|
|
125
135
|
registerMultipleCommand(command: ICommand): IDisposable;
|
|
126
136
|
beforeCommandExecuted(listener: CommandListener): IDisposable;
|
|
@@ -135,4 +145,3 @@ export declare class CommandService implements ICommandService {
|
|
|
135
145
|
}
|
|
136
146
|
export declare function sequenceExecute(tasks: ICommandInfo[], commandService: ICommandService, options?: IExecutionOptions): import('../../common/sequence').ISequenceExecuteResult;
|
|
137
147
|
export declare function sequenceExecuteAsync(tasks: ICommandInfo[], commandService: ICommandService, options?: IExecutionOptions): Promise<import('../../common/sequence').ISequenceExecuteResult>;
|
|
138
|
-
export declare const NilCommand: ICommand;
|
|
@@ -20,6 +20,7 @@ export declare const FOCUSING_SLIDE = "FOCUSING_SLIDE";
|
|
|
20
20
|
export declare const FOCUSING_EDITOR_BUT_HIDDEN = "FOCUSING_EDITOR_BUT_HIDDEN";
|
|
21
21
|
export declare const EDITOR_ACTIVATED = "EDITOR_ACTIVATED";
|
|
22
22
|
export declare const FOCUSING_EDITOR_INPUT_FORMULA = "FOCUSING_EDITOR_INPUT_FORMULA";
|
|
23
|
+
/** The focusing state of the formula editor (Fx bar). */
|
|
23
24
|
export declare const FOCUSING_FORMULA_EDITOR = "FOCUSING_FORMULA_EDITOR";
|
|
24
25
|
export declare const FOCUSING_UNIVER_EDITOR = "FOCUSING_UNIVER_EDITOR";
|
|
25
26
|
export declare const FOCUSING_EDITOR_STANDALONE = "FOCUSING_EDITOR_INPUT_FORMULA";
|
|
@@ -1,113 +1,90 @@
|
|
|
1
|
+
import { UnitModel, UnitType, UniverInstanceType } from '../../common/unit';
|
|
1
2
|
import { IContextService } from '../context/context.service';
|
|
2
|
-
import { IDocumentData, ISlideData, IWorkbookData } from '../../types/interfaces';
|
|
3
|
-
import { SlideDataModel } from '../../slides/domain/slide-model';
|
|
4
3
|
import { Workbook } from '../../sheets/workbook';
|
|
5
4
|
import { Disposable } from '../../shared/lifecycle';
|
|
6
5
|
import { Nullable } from '../../shared';
|
|
7
6
|
import { DocumentDataModel } from '../../docs/data-model/document-data-model';
|
|
8
7
|
import { Observable } from 'rxjs';
|
|
8
|
+
import { IDisposable, Injector } from '@wendellhu/redi';
|
|
9
9
|
|
|
10
|
-
export declare enum UniverInstanceType {
|
|
11
|
-
UNKNOWN = 0,
|
|
12
|
-
DOC = 1,
|
|
13
|
-
SHEET = 2,
|
|
14
|
-
SLIDE = 3
|
|
15
|
-
}
|
|
16
|
-
export interface IUniverHandler {
|
|
17
|
-
createUniverDoc(data: Partial<IDocumentData>): DocumentDataModel;
|
|
18
|
-
createUniverSheet(data: Partial<IWorkbookData>): Workbook;
|
|
19
|
-
createUniverSlide(data: Partial<ISlideData>): SlideDataModel;
|
|
20
|
-
}
|
|
21
10
|
/**
|
|
22
|
-
* IUniverInstanceService holds all the current univer instances
|
|
23
|
-
*
|
|
11
|
+
* IUniverInstanceService holds all the current univer instances and provides a set of
|
|
12
|
+
* methods to add and remove univer instances.
|
|
13
|
+
*
|
|
14
|
+
* It also manages the focused univer instance.
|
|
24
15
|
*/
|
|
25
16
|
export interface IUniverInstanceService {
|
|
17
|
+
/** Omits value when a new UnitModel is created. */
|
|
18
|
+
unitAdded$: Observable<UnitModel>;
|
|
19
|
+
/** Subscribe to curtain type of units' creation. */
|
|
20
|
+
getTypeOfUnitAdded$<T extends UnitModel>(type: UnitType): Observable<T>;
|
|
21
|
+
/** @interal */
|
|
22
|
+
__addUnit(unit: UnitModel): void;
|
|
23
|
+
/** Omits value when a UnitModel is disposed. */
|
|
24
|
+
unitDisposed$: Observable<UnitModel>;
|
|
25
|
+
/** Subscribe to curtain type of units' disposing. */
|
|
26
|
+
getTypeOfUnitDisposed$<T extends UnitModel>(type: UnitType): Observable<T>;
|
|
26
27
|
focused$: Observable<Nullable<string>>;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
createDoc(data: Partial<IDocumentData>): DocumentDataModel;
|
|
39
|
-
createSheet(data: Partial<IWorkbookData>): Workbook;
|
|
40
|
-
createSlide(data: Partial<ISlideData>): SlideDataModel;
|
|
28
|
+
focusUnit(unitId: string | null): void;
|
|
29
|
+
getFocusedUnit(): Nullable<UnitModel>;
|
|
30
|
+
getCurrentUnitForType<T extends UnitModel>(type: UnitType): Nullable<T>;
|
|
31
|
+
setCurrentUnitForType(unitId: string): void;
|
|
32
|
+
getCurrentTypeOfUnit$<T extends UnitModel>(type: UnitType): Observable<Nullable<T>>;
|
|
33
|
+
/** Create a unit with snapshot info. */
|
|
34
|
+
createUnit<T, U extends UnitModel>(type: UnitType, data: Partial<T>): U;
|
|
35
|
+
/** Dispose a unit */
|
|
36
|
+
disposeUnit(unitId: string): boolean;
|
|
37
|
+
registerCtorForType<T extends UnitModel>(type: UnitType, ctor: new (...args: any[]) => T): IDisposable;
|
|
38
|
+
/** @deprecated */
|
|
41
39
|
changeDoc(unitId: string, doc: DocumentDataModel): void;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
setCurrentUniverSheetInstance(id: string): void;
|
|
52
|
-
setCurrentUniverDocInstance(id: string): void;
|
|
53
|
-
setCurrentUniverSlideInstance(id: string): void;
|
|
54
|
-
getAllUniverSheetsInstance(): Workbook[];
|
|
55
|
-
getAllUniverDocsInstance(): DocumentDataModel[];
|
|
56
|
-
getAllUniverSlidesInstance(): SlideDataModel[];
|
|
57
|
-
getDocumentType(unitId: string): UniverInstanceType;
|
|
58
|
-
disposeDocument(unitId: string): boolean;
|
|
40
|
+
getUnit<T extends UnitModel>(id: string, type?: UnitType): Nullable<T>;
|
|
41
|
+
getAllUnitsForType<T>(type: UnitType): T[];
|
|
42
|
+
getUnitType(unitId: string): UnitType;
|
|
43
|
+
/** @deprecated */
|
|
44
|
+
getUniverSheetInstance(unitId: string): Nullable<Workbook>;
|
|
45
|
+
/** @deprecated */
|
|
46
|
+
getUniverDocInstance(unitId: string): Nullable<DocumentDataModel>;
|
|
47
|
+
/** @deprecated */
|
|
48
|
+
getCurrentUniverDocInstance(): Nullable<DocumentDataModel>;
|
|
59
49
|
}
|
|
60
50
|
export declare const IUniverInstanceService: import('@wendellhu/redi').IdentifierDecorator<IUniverInstanceService>;
|
|
61
51
|
export declare class UniverInstanceService extends Disposable implements IUniverInstanceService {
|
|
62
|
-
private readonly
|
|
52
|
+
private readonly _injector;
|
|
63
53
|
private readonly _contextService;
|
|
64
|
-
private
|
|
65
|
-
|
|
66
|
-
readonly focused$: Observable<Nullable<string>>;
|
|
67
|
-
private readonly _currentSheet$;
|
|
68
|
-
readonly currentSheet$: Observable<Nullable<Workbook>>;
|
|
69
|
-
private readonly _currentDoc$;
|
|
70
|
-
readonly currentDoc$: Observable<Nullable<DocumentDataModel>>;
|
|
71
|
-
private readonly _currentSlide$;
|
|
72
|
-
readonly currentSlide$: Observable<Nullable<SlideDataModel>>;
|
|
73
|
-
private readonly _sheetAdded$;
|
|
74
|
-
readonly sheetAdded$: Observable<Workbook>;
|
|
75
|
-
private readonly _docAdded$;
|
|
76
|
-
readonly docAdded$: Observable<DocumentDataModel>;
|
|
77
|
-
private readonly _slideAdded$;
|
|
78
|
-
readonly slideAdded$: Observable<SlideDataModel>;
|
|
79
|
-
private readonly _sheetDisposed$;
|
|
80
|
-
readonly sheetDisposed$: Observable<Workbook>;
|
|
81
|
-
private readonly _docDisposed$;
|
|
82
|
-
readonly docDisposed$: Observable<DocumentDataModel>;
|
|
83
|
-
private readonly _slideDisposed$;
|
|
84
|
-
readonly slideDisposed$: Observable<SlideDataModel>;
|
|
85
|
-
private readonly _sheets;
|
|
86
|
-
private readonly _docs;
|
|
87
|
-
private readonly _slides;
|
|
88
|
-
constructor(_handler: IUniverHandler, _contextService: IContextService);
|
|
54
|
+
private readonly _unitsByType;
|
|
55
|
+
constructor(_injector: Injector, _contextService: IContextService);
|
|
89
56
|
dispose(): void;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
57
|
+
private _createHandler;
|
|
58
|
+
__setCreateHandler(handler: (type: UnitType, data: unknown, ctor: new (...args: any[]) => UnitModel) => UnitModel): void;
|
|
59
|
+
createUnit<T, U extends UnitModel>(type: UnitType, data: T): U;
|
|
60
|
+
private readonly _ctorByType;
|
|
61
|
+
registerCtorForType<T extends UnitModel>(type: UnitType, ctor: new () => T): IDisposable;
|
|
62
|
+
private readonly _currentUnits$;
|
|
63
|
+
readonly currentUnits$: Observable<{
|
|
64
|
+
[type: number]: Nullable<UnitModel<object, number>>;
|
|
65
|
+
}>;
|
|
66
|
+
getCurrentTypeOfUnit$<T>(type: number): Observable<Nullable<T>>;
|
|
67
|
+
getCurrentUnitForType<T>(type: UnitType): Nullable<T>;
|
|
68
|
+
setCurrentUnitForType(unitId: string): void;
|
|
69
|
+
private readonly _unitAdded$;
|
|
70
|
+
readonly unitAdded$: Observable<UnitModel<object, number>>;
|
|
71
|
+
getTypeOfUnitAdded$<T extends UnitModel<object, number>>(type: UnitType): Observable<T>;
|
|
72
|
+
__addUnit(unit: UnitModel): void;
|
|
73
|
+
private _unitDisposed$;
|
|
74
|
+
unitDisposed$: Observable<UnitModel<object, number>>;
|
|
75
|
+
getTypeOfUnitDisposed$<T extends UnitModel<object, number>>(type: UniverInstanceType): Observable<T>;
|
|
76
|
+
getUnit<T extends UnitModel = UnitModel>(id: string, type?: UnitType): Nullable<T>;
|
|
77
|
+
getCurrentUniverDocInstance(): Nullable<DocumentDataModel>;
|
|
78
|
+
getUniverDocInstance(unitId: string): Nullable<DocumentDataModel>;
|
|
79
|
+
getUniverSheetInstance(unitId: string): Nullable<Workbook>;
|
|
80
|
+
getAllUnitsForType<T>(type: UnitType): T[];
|
|
94
81
|
changeDoc(unitId: string, doc: DocumentDataModel): void;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
setCurrentUniverSheetInstance(id: string): void;
|
|
104
|
-
setCurrentUniverSlideInstance(id: string): void;
|
|
105
|
-
setCurrentUniverDocInstance(id: string): void;
|
|
106
|
-
getCurrentUniverSheetInstance(): Workbook;
|
|
107
|
-
getCurrentUniverDocInstance(): DocumentDataModel;
|
|
108
|
-
getCurrentUniverSlideInstance(): SlideDataModel;
|
|
109
|
-
focusUniverInstance(id: string | null): void;
|
|
110
|
-
getFocusedUniverInstance(): Nullable<Workbook | DocumentDataModel | SlideDataModel>;
|
|
111
|
-
getDocumentType(unitId: string): UniverInstanceType;
|
|
112
|
-
disposeDocument(unitId: string): boolean;
|
|
82
|
+
private readonly _focused$;
|
|
83
|
+
readonly focused$: Observable<Nullable<string>>;
|
|
84
|
+
get focused(): Nullable<UnitModel>;
|
|
85
|
+
focusUnit(id: string | null): void;
|
|
86
|
+
getFocusedUnit(): Nullable<UnitModel>;
|
|
87
|
+
getUnitType(unitId: string): UniverInstanceType;
|
|
88
|
+
disposeUnit(unitId: string): boolean;
|
|
89
|
+
private _getUnitById;
|
|
113
90
|
}
|
|
@@ -13,6 +13,7 @@ export declare class LifecycleService extends Disposable {
|
|
|
13
13
|
private readonly _logService;
|
|
14
14
|
private _lifecycle$;
|
|
15
15
|
readonly lifecycle$: Observable<LifecycleStages>;
|
|
16
|
+
private _lock;
|
|
16
17
|
constructor(_logService: ILogService);
|
|
17
18
|
get stage(): LifecycleStages;
|
|
18
19
|
set stage(stage: LifecycleStages);
|
|
@@ -34,8 +35,7 @@ export declare class LifecycleService extends Disposable {
|
|
|
34
35
|
export declare class LifecycleInitializerService extends Disposable {
|
|
35
36
|
private _lifecycleService;
|
|
36
37
|
private readonly _injector;
|
|
37
|
-
private
|
|
38
|
+
private _seenTokens;
|
|
38
39
|
constructor(_lifecycleService: LifecycleService, _injector: Injector);
|
|
39
|
-
start(): void;
|
|
40
40
|
initModulesOnStage(stage: LifecycleStages): void;
|
|
41
41
|
}
|
|
@@ -18,7 +18,6 @@ export declare class PermissionService extends Disposable implements IPermission
|
|
|
18
18
|
private _univerInstanceService;
|
|
19
19
|
private _permissionPointMap;
|
|
20
20
|
constructor(_resourceManagerService: IResourceManagerService, _univerInstanceService: IUniverInstanceService);
|
|
21
|
-
private _init;
|
|
22
21
|
private _toJson;
|
|
23
22
|
private _parseJson;
|
|
24
23
|
deletePermissionPoint: (unitID: string, id: string) => void;
|
|
@@ -7,6 +7,6 @@ export declare class UniverPermissionService extends Disposable {
|
|
|
7
7
|
private _univerInstanceService;
|
|
8
8
|
constructor(_permissionService: IPermissionService, _univerInstanceService: IUniverInstanceService);
|
|
9
9
|
private _init;
|
|
10
|
-
getEditable(
|
|
11
|
-
setEditable(
|
|
10
|
+
getEditable(unitId?: string | undefined): any;
|
|
11
|
+
setEditable(unitId: string, v: boolean): void;
|
|
12
12
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Plugin, PluginCtor, PluginRegistry, PluginStore } from './plugin';
|
|
2
|
+
import { ILogService } from '../log/log.service';
|
|
3
|
+
import { Disposable } from '../../shared/lifecycle';
|
|
4
|
+
import { LifecycleInitializerService, LifecycleService } from '../lifecycle/lifecycle.service';
|
|
5
|
+
import { LifecycleStages } from '../lifecycle/lifecycle';
|
|
6
|
+
import { Injector } from '@wendellhu/redi';
|
|
7
|
+
|
|
8
|
+
export declare class PluginHolder extends Disposable {
|
|
9
|
+
protected readonly _logService: ILogService;
|
|
10
|
+
protected readonly _injector: Injector;
|
|
11
|
+
protected readonly _lifecycleService: LifecycleService;
|
|
12
|
+
protected readonly _lifecycleInitializerService: LifecycleInitializerService;
|
|
13
|
+
protected _started: boolean;
|
|
14
|
+
get started(): boolean;
|
|
15
|
+
protected readonly _pluginRegistered: Set<string>;
|
|
16
|
+
protected readonly _pluginStore: PluginStore;
|
|
17
|
+
protected readonly _pluginRegistry: PluginRegistry;
|
|
18
|
+
constructor(_logService: ILogService, _injector: Injector, _lifecycleService: LifecycleService, _lifecycleInitializerService: LifecycleInitializerService);
|
|
19
|
+
dispose(): void;
|
|
20
|
+
registerPlugin<T extends PluginCtor<Plugin>>(pluginCtor: T, config?: ConstructorParameters<T>[0]): void;
|
|
21
|
+
start(): void;
|
|
22
|
+
flush(): void;
|
|
23
|
+
protected _pluginsRunLifecycle(plugins: Plugin[], lifecycle: LifecycleStages): void;
|
|
24
|
+
protected _initPlugin<T extends Plugin>(plugin: PluginCtor<T>, options: any): Plugin;
|
|
25
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Dependency, DependencyItem, IdentifierDecorator } from '@wendellhu/redi';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Overrides the dependencies definited in the plugin. Only dependencies that are identified by `IdentifierDecorator` can be overridden.
|
|
5
|
+
* If you override a dependency with `null`, the original dependency will be removed.
|
|
6
|
+
*/
|
|
7
|
+
export type DependencyOverride = [identifier: IdentifierDecorator<any>, DependencyItem<any> | null][];
|
|
8
|
+
export declare function mergeOverrideWithDependencies(dependencies: Dependency[], override?: DependencyOverride): Dependency[];
|
|
@@ -1,28 +1,23 @@
|
|
|
1
|
+
import { UniverInstanceType } from '../../common/unit';
|
|
2
|
+
import { Disposable } from '../../shared';
|
|
1
3
|
import { Ctor, Injector } from '@wendellhu/redi';
|
|
2
4
|
|
|
3
5
|
export type PluginCtor<T extends Plugin> = Ctor<T> & {
|
|
4
|
-
type:
|
|
6
|
+
type: UniverInstanceType;
|
|
7
|
+
pluginName: string;
|
|
5
8
|
};
|
|
6
|
-
/** Plugin types for different kinds of business. */
|
|
7
|
-
export declare enum PluginType {
|
|
8
|
-
Univer = 0,
|
|
9
|
-
Doc = 1,
|
|
10
|
-
Sheet = 2,
|
|
11
|
-
Slide = 3
|
|
12
|
-
}
|
|
13
9
|
/**
|
|
14
10
|
* Plug-in base class, all plug-ins must inherit from this base class. Provide basic methods.
|
|
15
11
|
*/
|
|
16
|
-
export declare abstract class Plugin {
|
|
17
|
-
static
|
|
12
|
+
export declare abstract class Plugin extends Disposable {
|
|
13
|
+
static pluginName: string;
|
|
14
|
+
static type: UniverInstanceType;
|
|
18
15
|
protected abstract _injector: Injector;
|
|
19
|
-
private _name;
|
|
20
|
-
protected constructor(name: string);
|
|
21
16
|
onStarting(injector: Injector): void;
|
|
22
17
|
onReady(): void;
|
|
23
18
|
onRendered(): void;
|
|
24
19
|
onSteady(): void;
|
|
25
|
-
|
|
20
|
+
getUniverInstanceType(): UniverInstanceType;
|
|
26
21
|
getPluginName(): string;
|
|
27
22
|
}
|
|
28
23
|
interface IPluginRegistryItem {
|
|
@@ -42,9 +37,9 @@ export declare class PluginStore {
|
|
|
42
37
|
* Store plugin registry items.
|
|
43
38
|
*/
|
|
44
39
|
export declare class PluginRegistry {
|
|
45
|
-
private
|
|
40
|
+
private _pluginsRegistered;
|
|
46
41
|
registerPlugin(pluginCtor: PluginCtor<any>, options: any): void;
|
|
47
|
-
getRegisterPlugins(
|
|
48
|
-
|
|
42
|
+
getRegisterPlugins(): IPluginRegistryItem[];
|
|
43
|
+
removePlugins(): void;
|
|
49
44
|
}
|
|
50
45
|
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Plugin, PluginCtor } from './plugin';
|
|
2
|
+
import { PluginHolder } from './plugin-holder';
|
|
3
|
+
import { UnitType, UniverInstanceType } from '../../common/unit';
|
|
4
|
+
import { IDisposable, Injector } from '@wendellhu/redi';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* This service manages plugin registration.
|
|
8
|
+
*/
|
|
9
|
+
export declare class PluginService implements IDisposable {
|
|
10
|
+
private readonly _injector;
|
|
11
|
+
private readonly _pluginHolderForUniver;
|
|
12
|
+
private readonly _pluginHoldersForTypes;
|
|
13
|
+
constructor(_injector: Injector);
|
|
14
|
+
dispose(): void;
|
|
15
|
+
/** Register a plugin into univer. */
|
|
16
|
+
registerPlugin<T extends PluginCtor<Plugin>>(plugin: T, config?: ConstructorParameters<T>[0]): void;
|
|
17
|
+
startPluginForType(type: UniverInstanceType): void;
|
|
18
|
+
_ensurePluginHolderForType(type: UnitType): PluginHolder;
|
|
19
|
+
private _assertPluginValid;
|
|
20
|
+
private _flushTimer?;
|
|
21
|
+
private _scheduleInitPlugin;
|
|
22
|
+
private _clearFlushTimer;
|
|
23
|
+
private _flushPlugins;
|
|
24
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IResourceLoaderService } from './type';
|
|
2
|
+
import { Disposable } from '../../shared/lifecycle';
|
|
3
|
+
import { IUniverInstanceService } from '../instance/instance.service';
|
|
4
|
+
import { IResourceManagerService } from '../resource-manager/type';
|
|
5
|
+
import { IWorkbookData } from '../../types/interfaces';
|
|
6
|
+
import { Workbook } from '../../sheets/workbook';
|
|
7
|
+
|
|
8
|
+
export declare class ResourceLoaderService extends Disposable implements IResourceLoaderService {
|
|
9
|
+
private readonly _resourceManagerService;
|
|
10
|
+
private readonly _univerInstanceService;
|
|
11
|
+
constructor(_resourceManagerService: IResourceManagerService, _univerInstanceService: IUniverInstanceService);
|
|
12
|
+
private _init;
|
|
13
|
+
saveWorkbook: (workbook: Workbook) => IWorkbookData;
|
|
14
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IWorkbookData } from '../../types/interfaces/i-workbook-data';
|
|
2
|
+
import { Workbook } from '../../sheets/workbook';
|
|
3
|
+
|
|
4
|
+
export interface IResourceLoaderService {
|
|
5
|
+
saveWorkbook: (workbook: Workbook) => IWorkbookData;
|
|
6
|
+
}
|
|
7
|
+
export declare const IResourceLoaderService: import('@wendellhu/redi').IdentifierDecorator<IResourceLoaderService>;
|