@univerjs/core 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +9 -9
- package/lib/es/facade.js +380 -105
- package/lib/es/index.js +2509 -2556
- package/lib/types/facade/f-blob.d.ts +18 -18
- package/lib/types/facade/f-enum.d.ts +166 -2
- package/lib/types/facade/f-event-registry.d.ts +4 -3
- package/lib/types/facade/f-event.d.ts +41 -14
- package/lib/types/facade/f-hooks.d.ts +8 -8
- package/lib/types/facade/f-univer.d.ts +67 -8
- package/lib/types/facade/f-util.d.ts +22 -0
- package/lib/types/index.d.ts +2 -3
- package/lib/types/services/plugin/plugin.service.d.ts +49 -38
- package/lib/types/shared/generate.d.ts +5 -0
- package/lib/types/shared/rectangle.d.ts +1 -1
- package/lib/types/univer.d.ts +2 -2
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +9 -9
- package/package.json +4 -4
- package/lib/types/services/plugin/plugin.d.ts +0 -46
|
@@ -27,6 +27,11 @@ export declare class FUniver extends Disposable {
|
|
|
27
27
|
* @static
|
|
28
28
|
* @param {Univer | Injector} wrapped - The Univer instance or injector instance.
|
|
29
29
|
* @returns {FUniver} - The FUniver instance.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* const univerAPI = FUniver.newAPI(univer);
|
|
34
|
+
* ```
|
|
30
35
|
*/
|
|
31
36
|
static newAPI(wrapped: Univer | Injector): FUniver;
|
|
32
37
|
private [InitializerSymbol];
|
|
@@ -48,33 +53,59 @@ export declare class FUniver extends Disposable {
|
|
|
48
53
|
* Dispose the UniverSheet by the `unitId`. The UniverSheet would be unload from the application.
|
|
49
54
|
* @param unitId The unit id of the UniverSheet.
|
|
50
55
|
* @returns Whether the Univer instance is disposed successfully.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* const fWorkbook = univerAPI.getActiveWorkbook();
|
|
60
|
+
* const unitId = fWorkbook?.getId();
|
|
61
|
+
*
|
|
62
|
+
* if (unitId) {
|
|
63
|
+
* univerAPI.disposeUnit(unitId);
|
|
64
|
+
* }
|
|
65
|
+
* ```
|
|
51
66
|
*/
|
|
52
67
|
disposeUnit(unitId: string): boolean;
|
|
53
68
|
/**
|
|
54
69
|
* Get the current lifecycle stage.
|
|
55
70
|
* @returns {LifecycleStages} - The current lifecycle stage.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* const stage = univerAPI.getCurrentLifecycleStage();
|
|
75
|
+
* console.log(stage);
|
|
76
|
+
* ```
|
|
56
77
|
*/
|
|
57
78
|
getCurrentLifecycleStage(): LifecycleStages;
|
|
58
79
|
/**
|
|
59
80
|
* Undo an editing on the currently focused document.
|
|
60
81
|
* @returns {Promise<boolean>} undo result
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* univerAPI.undo();
|
|
86
|
+
* ```
|
|
61
87
|
*/
|
|
62
88
|
undo(): Promise<boolean>;
|
|
63
89
|
/**
|
|
64
90
|
* Redo an editing on the currently focused document.
|
|
65
91
|
* @returns {Promise<boolean>} redo result
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* univerAPI.redo();
|
|
96
|
+
* ```
|
|
66
97
|
*/
|
|
67
98
|
redo(): Promise<boolean>;
|
|
68
99
|
/**
|
|
69
100
|
* Register a callback that will be triggered before invoking a command.
|
|
70
|
-
* @deprecated use `addEvent(univerAPI.
|
|
101
|
+
* @deprecated use `univerAPI.addEvent(univerAPI.Event.BeforeCommandExecute, (event) => {})` instead.
|
|
71
102
|
* @param {CommandListener} callback The callback.
|
|
72
103
|
* @returns {IDisposable} The disposable instance.
|
|
73
104
|
*/
|
|
74
105
|
onBeforeCommandExecute(callback: CommandListener): IDisposable;
|
|
75
106
|
/**
|
|
76
107
|
* Register a callback that will be triggered when a command is invoked.
|
|
77
|
-
* @deprecated use `addEvent(univerAPI.
|
|
108
|
+
* @deprecated use `univerAPI.addEvent(univerAPI.Event.CommandExecuted, (event) => {})` instead.
|
|
78
109
|
* @param {CommandListener} callback The callback.
|
|
79
110
|
* @returns {IDisposable} The disposable instance.
|
|
80
111
|
*/
|
|
@@ -85,6 +116,14 @@ export declare class FUniver extends Disposable {
|
|
|
85
116
|
* @param params Parameters of this execution.
|
|
86
117
|
* @param options Options of this execution.
|
|
87
118
|
* @returns The result of the execution. It is a boolean value by default which indicates the command is executed.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```ts
|
|
122
|
+
* univerAPI.executeCommand('sheet.command.set-range-values', {
|
|
123
|
+
* value: { v: "Hello, Univer!" },
|
|
124
|
+
* range: { startRow: 0, startColumn: 0, endRow: 0, endColumn: 0 }
|
|
125
|
+
* });
|
|
126
|
+
* ```
|
|
88
127
|
*/
|
|
89
128
|
executeCommand<P extends object = object, R = boolean>(id: string, params?: P, options?: IExecutionOptions): Promise<R>;
|
|
90
129
|
/**
|
|
@@ -93,6 +132,14 @@ export declare class FUniver extends Disposable {
|
|
|
93
132
|
* @param params Parameters of this execution.
|
|
94
133
|
* @param options Options of this execution.
|
|
95
134
|
* @returns The result of the execution. It is a boolean value by default which indicates the command is executed.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```ts
|
|
138
|
+
* univerAPI.syncExecuteCommand('sheet.command.set-range-values', {
|
|
139
|
+
* value: { v: "Hello, Univer!" },
|
|
140
|
+
* range: { startRow: 0, startColumn: 0, endRow: 0, endColumn: 0 }
|
|
141
|
+
* });
|
|
142
|
+
* ```
|
|
96
143
|
*/
|
|
97
144
|
syncExecuteCommand<P extends object = object, R = boolean>(id: string, params?: P, options?: IExecutionOptions): R;
|
|
98
145
|
/**
|
|
@@ -111,9 +158,13 @@ export declare class FUniver extends Disposable {
|
|
|
111
158
|
* @returns {Disposable} The Disposable instance, for remove the listener
|
|
112
159
|
* @example
|
|
113
160
|
* ```ts
|
|
114
|
-
*
|
|
115
|
-
*
|
|
161
|
+
* // Add life cycle changed event listener
|
|
162
|
+
* const disposable = univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, (params) => {
|
|
163
|
+
* const { stage } = params;
|
|
164
|
+
* console.log('life cycle changed', params);
|
|
116
165
|
* });
|
|
166
|
+
*
|
|
167
|
+
* // Remove the event listener, use `disposable.dispose()`
|
|
117
168
|
* ```
|
|
118
169
|
*/
|
|
119
170
|
addEvent<T extends keyof IEventParamConfig>(event: T, callback: (params: IEventParamConfig[T]) => void): IDisposable;
|
|
@@ -124,7 +175,7 @@ export declare class FUniver extends Disposable {
|
|
|
124
175
|
* @returns {boolean} should cancel
|
|
125
176
|
* @example
|
|
126
177
|
* ```ts
|
|
127
|
-
* this.fireEvent(univerAPI.
|
|
178
|
+
* this.fireEvent(univerAPI.Event.LifeCycleChanged, params);
|
|
128
179
|
* ```
|
|
129
180
|
*/
|
|
130
181
|
protected fireEvent<T extends keyof IEventParamConfig>(event: T, params: IEventParamConfig[T]): boolean | undefined;
|
|
@@ -153,7 +204,9 @@ export declare class FUniver extends Disposable {
|
|
|
153
204
|
* @returns {RichTextBuilder} The new rich text instance
|
|
154
205
|
* @example
|
|
155
206
|
* ```ts
|
|
156
|
-
* const richText = univerAPI.newRichText();
|
|
207
|
+
* const richText = univerAPI.newRichText({ body: { dataStream: 'Hello World\r\n' } });
|
|
208
|
+
* const range = univerAPI.getActiveWorkbook().getActiveSheet().getRange('A1');
|
|
209
|
+
* range.setRichTextValueForCell(richText);
|
|
157
210
|
* ```
|
|
158
211
|
*/
|
|
159
212
|
newRichText(data?: IDocumentData): RichTextBuilder;
|
|
@@ -163,7 +216,9 @@ export declare class FUniver extends Disposable {
|
|
|
163
216
|
* @returns {RichTextValue} The new rich text value instance
|
|
164
217
|
* @example
|
|
165
218
|
* ```ts
|
|
166
|
-
* const richTextValue = univerAPI.newRichTextValue();
|
|
219
|
+
* const richTextValue = univerAPI.newRichTextValue({ body: { dataStream: 'Hello World\r\n' } });
|
|
220
|
+
* const range = univerAPI.getActiveWorkbook().getActiveSheet().getRange('A1');
|
|
221
|
+
* range.setRichTextValueForCell(richTextValue);
|
|
167
222
|
* ```
|
|
168
223
|
*/
|
|
169
224
|
newRichTextValue(data: IDocumentData): RichTextValue;
|
|
@@ -173,7 +228,11 @@ export declare class FUniver extends Disposable {
|
|
|
173
228
|
* @returns {ParagraphStyleBuilder} The new paragraph style instance
|
|
174
229
|
* @example
|
|
175
230
|
* ```ts
|
|
176
|
-
* const
|
|
231
|
+
* const richText = univerAPI.newRichText({ body: { dataStream: 'Hello World\r\n' } });
|
|
232
|
+
* const paragraphStyle = univerAPI.newParagraphStyle({ textStyle: { ff: 'Arial', fs: 12, it: univerAPI.Enum.BooleanNumber.TRUE, bl: univerAPI.Enum.BooleanNumber.TRUE } });
|
|
233
|
+
* richText.insertParagraph(paragraphStyle);
|
|
234
|
+
* const range = univerAPI.getActiveWorkbook().getActiveSheet().getRange('A1');
|
|
235
|
+
* range.setRichTextValueForCell(richText);
|
|
177
236
|
* ```
|
|
178
237
|
*/
|
|
179
238
|
newParagraphStyle(style?: IParagraphStyle): ParagraphStyleBuilder;
|
|
@@ -14,14 +14,36 @@ export declare class FUtil {
|
|
|
14
14
|
static extend(source: any): void;
|
|
15
15
|
/**
|
|
16
16
|
* Rectangle utils, including range operations likes merge, subtract, split
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const ranges = [
|
|
21
|
+
* { startRow: 0, startColumn: 0, endRow: 1, endColumn: 1 },
|
|
22
|
+
* { startRow: 1, startColumn: 1, endRow: 2, endColumn: 2 }
|
|
23
|
+
* ];
|
|
24
|
+
* const merged = univerAPI.Util.rectangle.mergeRanges(ranges);
|
|
25
|
+
* console.log(merged);
|
|
26
|
+
* ```
|
|
17
27
|
*/
|
|
18
28
|
get rectangle(): typeof Rectangle;
|
|
19
29
|
/**
|
|
20
30
|
* Number format utils, including parse and strigify about date, price, etc
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* const text = univerAPI.Util.numfmt.format('#,##0.00', 1234.567);
|
|
35
|
+
* console.log(text);
|
|
36
|
+
* ```
|
|
21
37
|
*/
|
|
22
38
|
get numfmt(): INumfmt;
|
|
23
39
|
/**
|
|
24
40
|
* common tools
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* const key = univerAPI.Util.tools.generateRandomId(6);
|
|
45
|
+
* console.log(key);
|
|
46
|
+
* ```
|
|
25
47
|
*/
|
|
26
48
|
get tools(): typeof Tools;
|
|
27
49
|
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -70,9 +70,8 @@ export { IPermissionService, PermissionStatus, } from './services/permission/typ
|
|
|
70
70
|
export type { IPermissionParam } from './services/permission/type';
|
|
71
71
|
export type { IPermissionPoint } from './services/permission/type';
|
|
72
72
|
export type { IPermissionTypes, RangePermissionPointConstructor, WorkbookPermissionPointConstructor, WorkSheetPermissionPointConstructor } from './services/permission/type';
|
|
73
|
-
export {
|
|
74
|
-
export
|
|
75
|
-
export { DependentOn, PluginService } from './services/plugin/plugin.service';
|
|
73
|
+
export type { PluginCtor } from './services/plugin/plugin.service.ts';
|
|
74
|
+
export { DependentOn, Plugin, PluginService } from './services/plugin/plugin.service';
|
|
76
75
|
export { type DependencyOverride, mergeOverrideWithDependencies } from './services/plugin/plugin-override';
|
|
77
76
|
export { IResourceLoaderService } from './services/resource-loader/type';
|
|
78
77
|
export { ResourceManagerService } from './services/resource-manager/resource-manager.service';
|
|
@@ -1,9 +1,37 @@
|
|
|
1
|
-
import { IDisposable, Injector } from '../../common/di';
|
|
2
|
-
import {
|
|
3
|
-
import { UniverInstanceType } from '../../common/unit';
|
|
1
|
+
import { Ctor, IDisposable, Injector } from '../../common/di';
|
|
2
|
+
import { UnitType } from '../../common/unit';
|
|
4
3
|
import { Disposable } from '../../shared/lifecycle';
|
|
5
4
|
import { LifecycleService } from '../lifecycle/lifecycle.service';
|
|
6
5
|
import { ILogService } from '../log/log.service';
|
|
6
|
+
export declare const DependentOnSymbol: unique symbol;
|
|
7
|
+
export type PluginCtor<T extends Plugin = Plugin> = Ctor<T> & {
|
|
8
|
+
type: UnitType;
|
|
9
|
+
pluginName: string;
|
|
10
|
+
[DependentOnSymbol]?: PluginCtor[];
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Plug-in base class, all plug-ins must inherit from this base class. Provide basic methods.
|
|
14
|
+
*/
|
|
15
|
+
export declare abstract class Plugin extends Disposable {
|
|
16
|
+
static pluginName: string;
|
|
17
|
+
static type: UnitType;
|
|
18
|
+
protected abstract _injector: Injector;
|
|
19
|
+
onStarting(): void;
|
|
20
|
+
onReady(): void;
|
|
21
|
+
onRendered(): void;
|
|
22
|
+
onSteady(): void;
|
|
23
|
+
getUnitType(): UnitType;
|
|
24
|
+
getPluginName(): string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Store plugin instances.
|
|
28
|
+
*/
|
|
29
|
+
export declare class PluginStore {
|
|
30
|
+
private readonly _plugins;
|
|
31
|
+
addPlugin(plugin: Plugin): void;
|
|
32
|
+
removePlugins(): Plugin[];
|
|
33
|
+
forEachPlugin(callback: (plugin: Plugin) => void): void;
|
|
34
|
+
}
|
|
7
35
|
/**
|
|
8
36
|
* Use this decorator to declare dependencies among plugins. If a dependent plugin is not registered yet,
|
|
9
37
|
* Univer will automatically register it with no configuration.
|
|
@@ -22,45 +50,28 @@ export declare function DependentOn(...plugins: PluginCtor<Plugin>[]): (target:
|
|
|
22
50
|
*/
|
|
23
51
|
export declare class PluginService implements IDisposable {
|
|
24
52
|
private readonly _injector;
|
|
25
|
-
private readonly
|
|
26
|
-
private readonly
|
|
53
|
+
private readonly _lifecycleService;
|
|
54
|
+
private readonly _logService;
|
|
55
|
+
private _pluginRegistry;
|
|
56
|
+
private readonly _pluginStore;
|
|
27
57
|
private readonly _seenPlugins;
|
|
28
|
-
|
|
58
|
+
private readonly _loadedPlugins;
|
|
59
|
+
private readonly _loadedPluginTypes;
|
|
60
|
+
constructor(_injector: Injector, _lifecycleService: LifecycleService, _logService: ILogService);
|
|
29
61
|
dispose(): void;
|
|
30
|
-
/**
|
|
62
|
+
/**
|
|
63
|
+
* Register a plugin into univer.
|
|
64
|
+
* @param {PluginCtor} ctor The plugin's constructor.
|
|
65
|
+
* @param {ConstructorParameters} [config] The configuration for the plugin.
|
|
66
|
+
*/
|
|
31
67
|
registerPlugin<T extends PluginCtor>(ctor: T, config?: ConstructorParameters<T>[0]): void;
|
|
32
|
-
|
|
33
|
-
private
|
|
34
|
-
private _immediateInitPlugin;
|
|
35
|
-
private _checkPluginSeen;
|
|
68
|
+
startPluginsForType(type: UnitType): void;
|
|
69
|
+
private _loadPluginsForType;
|
|
36
70
|
private _assertPluginValid;
|
|
37
|
-
private
|
|
38
|
-
private
|
|
39
|
-
private
|
|
40
|
-
private _flushPlugins;
|
|
41
|
-
}
|
|
42
|
-
export declare class PluginHolder extends Disposable {
|
|
43
|
-
private _checkPluginRegistered;
|
|
44
|
-
private _registerPlugin;
|
|
45
|
-
protected readonly _logService: ILogService;
|
|
46
|
-
protected readonly _injector: Injector;
|
|
47
|
-
protected readonly _lifecycleService: LifecycleService;
|
|
48
|
-
protected _started: boolean;
|
|
49
|
-
get started(): boolean;
|
|
50
|
-
private _warnedAboutOnStartingDeprecation;
|
|
51
|
-
/** Plugin constructors waiting to be initialized. */
|
|
52
|
-
protected readonly _pluginRegistry: PluginRegistry;
|
|
53
|
-
/** Stores initialized plugin instances. */
|
|
54
|
-
protected readonly _pluginStore: PluginStore;
|
|
55
|
-
/** Plugins instances as they are registered in batches. */
|
|
56
|
-
private readonly _pluginsInBatches;
|
|
57
|
-
constructor(_checkPluginRegistered: (pluginCtor: PluginCtor) => boolean, _registerPlugin: <T extends PluginCtor>(plugin: T, config?: ConstructorParameters<T>[0]) => void, _logService: ILogService, _injector: Injector, _lifecycleService: LifecycleService);
|
|
58
|
-
dispose(): void;
|
|
59
|
-
register<T extends PluginCtor<Plugin>>(pluginCtor: T, config?: ConstructorParameters<T>[0]): void;
|
|
60
|
-
immediateInitPlugin<T extends Plugin>(plugin: PluginCtor<T>): void;
|
|
61
|
-
start(): void;
|
|
62
|
-
flush(): void;
|
|
63
|
-
private _initPlugin;
|
|
71
|
+
private _flushTimerByType;
|
|
72
|
+
private _flushType;
|
|
73
|
+
private _loadFromPlugins;
|
|
64
74
|
protected _pluginsRunLifecycle(plugins: Plugin[]): void;
|
|
65
75
|
private _runStage;
|
|
76
|
+
private _initPlugin;
|
|
66
77
|
}
|
|
@@ -13,4 +13,9 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
/**
|
|
17
|
+
* Determine whether it is a pure number, "12" and "12e+3" are both true
|
|
18
|
+
* @param val The number or string to be judged
|
|
19
|
+
* @returns Result
|
|
20
|
+
*/
|
|
16
21
|
export declare function isRealNum(val: string | number | boolean): boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Nullable } from './types';
|
|
2
1
|
import { IRange, IRectLTRB } from '../sheets/typedef';
|
|
2
|
+
import { Nullable } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* This class provides a set of methods to calculate and manipulate rectangular ranges (IRange).
|
|
5
5
|
* A range represents a rectangular area in a grid, defined by start/end rows and columns.
|
package/lib/types/univer.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { IDisposable, Injector } from './common/di';
|
|
2
2
|
import { UnitModel, UnitType } from './common/unit';
|
|
3
3
|
import { LogLevel } from './services/log/log.service';
|
|
4
|
-
import { Plugin, PluginCtor } from './services/plugin/plugin';
|
|
5
4
|
import { DependencyOverride } from './services/plugin/plugin-override';
|
|
5
|
+
import { Plugin, PluginCtor } from './services/plugin/plugin.service';
|
|
6
6
|
import { IStyleSheet } from './services/theme/theme.service';
|
|
7
|
+
import { ILocales } from './shared';
|
|
7
8
|
import { IWorkbookData } from './sheets/typedef';
|
|
8
9
|
import { LocaleType } from './types/enum/locale-type';
|
|
9
10
|
import { IDocumentData, ISlideData } from './types/interfaces';
|
|
10
11
|
import { DocumentDataModel } from './docs/data-model/document-data-model';
|
|
11
|
-
import { ILocales } from './shared';
|
|
12
12
|
import { Workbook } from './sheets/workbook';
|
|
13
13
|
import { SlideDataModel } from './slides/slide-model';
|
|
14
14
|
export interface IUniverConfig {
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(c,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("@univerjs/core"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs"],n):(c=typeof globalThis<"u"?globalThis:c||self,n(c.UniverCoreFacade={},c.UniverCore,c.rxjs))})(this,function(c,n,p){"use strict";var N=Object.defineProperty;var A=(c,n,p)=>n in c?N(c,n,{enumerable:!0,configurable:!0,writable:!0,value:p}):c[n]=p;var h=(c,n,p)=>A(c,typeof n!="symbol"?n+"":n,p);class v extends n.Disposable{static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}}const C=Symbol("initializers");class j extends n.Disposable{constructor(t){super(),this._injector=t;const e=this,i=Object.getPrototypeOf(this)[C];i&&i.forEach(function(r){r.apply(e,[t])})}_initialize(t){}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{if(e==="_initialize"){let i=this.prototype[C];i||(i=[],this.prototype[C]=i),i.push(t.prototype._initialize)}else e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}}var B=Object.getOwnPropertyDescriptor,U=(a,t,e,i)=>{for(var r=i>1?void 0:i?B(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},O=(a,t)=>(e,i)=>t(e,i,a);c.FBlob=class extends v{constructor(t,e){super(),this._blob=t,this._injector=e}copyBlob(){return this._injector.createInstance(c.FBlob,this._blob)}getAs(t){const e=this.copyBlob();return e.setContentType(t),e}getDataAsString(t){return this._blob===null?Promise.resolve(""):t===void 0?this._blob.text():new Promise((e,i)=>{this._blob.arrayBuffer().then(r=>{const s=new TextDecoder(t).decode(r);e(s)}).catch(r=>{i(new Error(`Failed to read Blob as ArrayBuffer: ${r.message}`))})})}getBytes(){return this._blob?this._blob.arrayBuffer().then(t=>new Uint8Array(t)):Promise.reject(new Error("Blob is undefined or null."))}setBytes(t){return this._blob=new Blob([t]),this}setDataFromString(t,e){const i=e!=null?e:"text/plain",r=new Blob([t],{type:i});return this._blob=r,this}getContentType(){var t;return(t=this._blob)==null?void 0:t.type}setContentType(t){var e;return this._blob=(e=this._blob)==null?void 0:e.slice(0,this._blob.size,t),this}},c.FBlob=U([O(1,n.Inject(n.Injector))],c.FBlob);const y=class y{static get(){if(this._instance)return this._instance;const t=new y;return this._instance=t,t}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}constructor(){for(const t in y.prototype)this[t]=y.prototype[t]}get UniverInstanceType(){return n.UniverInstanceType}get LifecycleStages(){return n.LifecycleStages}get DataValidationType(){return n.DataValidationType}get DataValidationErrorStyle(){return n.DataValidationErrorStyle}get DataValidationRenderMode(){return n.DataValidationRenderMode}get DataValidationOperator(){return n.DataValidationOperator}get DataValidationStatus(){return n.DataValidationStatus}get CommandType(){return n.CommandType}get BaselineOffset(){return n.BaselineOffset}get BooleanNumber(){return n.BooleanNumber}get HorizontalAlign(){return n.HorizontalAlign}get TextDecoration(){return n.TextDecoration}get TextDirection(){return n.TextDirection}get VerticalAlign(){return n.VerticalAlign}get BorderType(){return n.BorderType}get BorderStyleTypes(){return n.BorderStyleTypes}get AutoFillSeries(){return n.AutoFillSeries}get ColorType(){return n.ColorType}get CommonHideTypes(){return n.CommonHideTypes}get CopyPasteType(){return n.CopyPasteType}get DeleteDirection(){return n.DeleteDirection}get DeveloperMetadataVisibility(){return n.DeveloperMetadataVisibility}get Dimension(){return n.Dimension}get Direction(){return n.Direction}get InterpolationPointType(){return n.InterpolationPointType}get LocaleType(){return n.LocaleType}get MentionType(){return n.MentionType}get ProtectionType(){return n.ProtectionType}get RelativeDate(){return n.RelativeDate}get SheetTypes(){return n.SheetTypes}get ThemeColorType(){return n.ThemeColorType}};h(y,"_instance");let f=y;const g=class g{static get(){if(this._instance)return this._instance;const t=new g;return this._instance=t,t}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}constructor(){for(const t in g.prototype)this[t]=g.prototype[t]}get DocCreated(){return"DocCreated"}get DocDisposed(){return"DocDisposed"}get LifeCycleChanged(){return"LifeCycleChanged"}get Redo(){return"Redo"}get Undo(){return"Undo"}get BeforeRedo(){return"BeforeRedo"}get BeforeUndo(){return"BeforeUndo"}get CommandExecuted(){return"CommandExecuted"}get BeforeCommandExecute(){return"BeforeCommandExecute"}};h(g,"_instance");let m=g;var P=Object.getOwnPropertyDescriptor,I=(a,t,e,i)=>{for(var r=i>1?void 0:i?P(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},R=(a,t)=>(e,i)=>t(e,i,a);c.FHooks=class extends v{constructor(t,e){super(),this._injector=t,this._lifecycleService=e}onStarting(t){return n.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===n.LifecycleStages.Starting)).subscribe(t))}onReady(t){return n.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===n.LifecycleStages.Ready)).subscribe(t))}onRendered(t){return n.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===n.LifecycleStages.Rendered)).subscribe(t))}onSteady(t){return n.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===n.LifecycleStages.Steady)).subscribe(t))}onBeforeUndo(t){return this._injector.get(n.ICommandService).beforeCommandExecuted(i=>{if(i.id===n.UndoCommand.id){const s=this._injector.get(n.IUndoRedoService).pitchTopUndoElement();s&&t(s)}})}onUndo(t){return this._injector.get(n.ICommandService).onCommandExecuted(i=>{if(i.id===n.UndoCommand.id){const s=this._injector.get(n.IUndoRedoService).pitchTopUndoElement();s&&t(s)}})}onBeforeRedo(t){return this._injector.get(n.ICommandService).beforeCommandExecuted(i=>{if(i.id===n.RedoCommand.id){const s=this._injector.get(n.IUndoRedoService).pitchTopRedoElement();s&&t(s)}})}onRedo(t){return this._injector.get(n.ICommandService).onCommandExecuted(i=>{if(i.id===n.RedoCommand.id){const s=this._injector.get(n.IUndoRedoService).pitchTopRedoElement();s&&t(s)}})}},c.FHooks=I([R(0,n.Inject(n.Injector)),R(1,n.Inject(n.LifecycleService))],c.FHooks);var x=Object.getOwnPropertyDescriptor,H=(a,t,e,i)=>{for(var r=i>1?void 0:i?x(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},F=(a,t)=>(e,i)=>t(e,i,a);let S=class extends j{constructor(a,t){super(t),this.doc=a}};S=H([F(1,n.Inject(n.Injector))],S);class V{constructor(){h(this,"_eventRegistry",new Map);h(this,"_eventHandlerMap",new Map);h(this,"_eventHandlerRegisted",new Map)}_ensureEventRegistry(t){return this._eventRegistry.has(t)||this._eventRegistry.set(t,new n.Registry),this._eventRegistry.get(t)}registerEventHandler(t,e){const i=this._eventHandlerMap.get(t);return i?i.add(e):this._eventHandlerMap.set(t,new Set([e])),this._ensureEventRegistry(t).getData().length&&this._initEventHandler(t),n.toDisposable(()=>{var r,s,o,d;(r=this._eventHandlerMap.get(t))==null||r.delete(e),(o=(s=this._eventHandlerRegisted.get(t))==null?void 0:s.get(e))==null||o.dispose(),(d=this._eventHandlerRegisted.get(t))==null||d.delete(e)})}removeEvent(t,e){const i=this._ensureEventRegistry(t);if(i.delete(e),i.getData().length===0){const r=this._eventHandlerRegisted.get(t);r==null||r.forEach(s=>s.dispose()),this._eventHandlerRegisted.delete(t)}}_initEventHandler(t){let e=this._eventHandlerRegisted.get(t);const i=this._eventHandlerMap.get(t);i&&(e||(e=new Map,this._eventHandlerRegisted.set(t,e),i==null||i.forEach(r=>{e==null||e.set(r,n.toDisposable(r()))})))}addEvent(t,e){return this._ensureEventRegistry(t).add(e),this._initEventHandler(t),n.toDisposable(()=>this.removeEvent(t,e))}fireEvent(t,e){var i;return(i=this._eventRegistry.get(t))==null||i.getData().forEach(r=>{r(e)}),e.cancel}}var M=Object.getOwnPropertyDescriptor,$=(a,t,e,i)=>{for(var r=i>1?void 0:i?M(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},w=(a,t)=>(e,i)=>t(e,i,a);let D=class extends v{constructor(a,t){super(),this._injector=a,this._userManagerService=t}getCurrentUser(){return this._userManagerService.getCurrentUser()}};D=$([w(0,n.Inject(n.Injector)),w(1,n.Inject(n.UserManagerService))],D);const b=class b{static get(){if(this._instance)return this._instance;const t=new b;return this._instance=t,t}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}get rectangle(){return n.Rectangle}get numfmt(){return n.numfmt}get tools(){return n.Tools}};h(b,"_instance");let _=b;var z=Object.getOwnPropertyDescriptor,L=(a,t,e,i)=>{for(var r=i>1?void 0:i?z(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},E=(a,t)=>(e,i)=>t(e,i,a);const T=Symbol("initializers");c.FUniver=class extends n.Disposable{constructor(e,i,r,s){super();h(this,"_eventRegistry",new V);h(this,"registerEventHandler",(e,i)=>this._eventRegistry.registerEventHandler(e,i));this._injector=e,this._commandService=i,this._univerInstanceService=r,this._lifecycleService=s,this.registerEventHandler(this.Event.LifeCycleChanged,()=>n.toDisposable(this._lifecycleService.lifecycle$.subscribe(d=>{this.fireEvent(this.Event.LifeCycleChanged,{stage:d})}))),this._initUnitEvent(this._injector),this._initBeforeCommandEvent(this._injector),this._initCommandEvent(this._injector),this._injector.onDispose(()=>{this.dispose()});const o=Object.getPrototypeOf(this)[T];if(o){const d=this;o.forEach(function(u){u.apply(d,[e])})}}static newAPI(e){return(e instanceof n.Univer?e.__getInjector():e).createInstance(c.FUniver)}_initialize(e){}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(i=>{if(i==="_initialize"){let r=this.prototype[T];r||(r=[],this.prototype[T]=r),r.push(e.prototype._initialize)}else i!=="constructor"&&(this.prototype[i]=e.prototype[i])}),Object.getOwnPropertyNames(e).forEach(i=>{i!=="prototype"&&i!=="name"&&i!=="length"&&(this[i]=e[i])})}_initCommandEvent(e){const i=e.get(n.ICommandService);this.registerEventHandler(this.Event.Redo,()=>i.onCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===n.RedoCommand.id){const l={id:s,type:o,params:d};this.fireEvent(this.Event.Redo,l)}})),this.registerEventHandler(this.Event.Undo,()=>i.onCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===n.UndoCommand.id){const l={id:s,type:o,params:d};this.fireEvent(this.Event.Undo,l)}})),this.registerEventHandler(this.Event.CommandExecuted,()=>i.onCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id!==n.RedoCommand.id&&r.id!==n.UndoCommand.id){const l={id:s,type:o,params:d};this.fireEvent(this.Event.CommandExecuted,l)}}))}_initBeforeCommandEvent(e){const i=e.get(n.ICommandService);this.registerEventHandler(this.Event.BeforeRedo,()=>i.beforeCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===n.RedoCommand.id){const l={id:s,type:o,params:d};if(this.fireEvent(this.Event.BeforeRedo,l),l.cancel)throw new n.CanceledError}})),this.registerEventHandler(this.Event.BeforeUndo,()=>i.beforeCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===n.UndoCommand.id){const l={id:s,type:o,params:d};if(this.fireEvent(this.Event.BeforeUndo,l),l.cancel)throw new n.CanceledError}})),this.registerEventHandler(this.Event.BeforeCommandExecute,()=>i.beforeCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id!==n.RedoCommand.id&&r.id!==n.UndoCommand.id){const l={id:s,type:o,params:d};if(this.fireEvent(this.Event.BeforeCommandExecute,l),l.cancel)throw new n.CanceledError}}))}_initUnitEvent(e){const i=e.get(n.IUniverInstanceService);this.registerEventHandler(this.Event.DocDisposed,()=>i.unitDisposed$.subscribe(r=>{r.type===n.UniverInstanceType.UNIVER_DOC&&this.fireEvent(this.Event.DocDisposed,{unitId:r.getUnitId(),unitType:r.type,snapshot:r.getSnapshot()})})),this.registerEventHandler(this.Event.DocCreated,()=>i.unitAdded$.subscribe(r=>{if(r.type===n.UniverInstanceType.UNIVER_DOC){const s=r,o=e.createInstance(S,s);this.fireEvent(this.Event.DocCreated,{unitId:r.getUnitId(),type:r.type,doc:o,unit:o})}}))}disposeUnit(e){return this._univerInstanceService.disposeUnit(e)}getCurrentLifecycleStage(){return this._injector.get(n.LifecycleService).stage}undo(){return this._commandService.executeCommand(n.UndoCommand.id)}redo(){return this._commandService.executeCommand(n.RedoCommand.id)}onBeforeCommandExecute(e){return this._commandService.beforeCommandExecuted((i,r)=>{e(i,r)})}onCommandExecuted(e){return this._commandService.onCommandExecuted((i,r)=>{e(i,r)})}executeCommand(e,i,r){return this._commandService.executeCommand(e,i,r)}syncExecuteCommand(e,i,r){return this._commandService.syncExecuteCommand(e,i,r)}getHooks(){return this._injector.createInstance(c.FHooks)}get Enum(){return f.get()}get Event(){return m.get()}get Util(){return _.get()}addEvent(e,i){if(!e||!i)throw new Error("Cannot add empty event");return this._eventRegistry.addEvent(e,i)}fireEvent(e,i){return this._eventRegistry.fireEvent(e,i)}getUserManager(){return this._injector.createInstance(D)}newBlob(){return this._injector.createInstance(c.FBlob)}newColor(){return new n.ColorBuilder}newRichText(e){return n.RichTextBuilder.create(e)}newRichTextValue(e){return n.RichTextValue.create(e)}newParagraphStyle(e){return n.ParagraphStyleBuilder.create(e)}newParagraphStyleValue(e){return n.ParagraphStyleValue.create(e)}newTextStyle(e){return n.TextStyleBuilder.create(e)}newTextStyleValue(e){return n.TextStyleValue.create(e)}newTextDecoration(e){return new n.TextDecorationBuilder(e)}},c.FUniver=L([E(0,n.Inject(n.Injector)),E(1,n.ICommandService),E(2,n.IUniverInstanceService),E(3,n.Inject(n.LifecycleService))],c.FUniver),c.FBase=v,c.FBaseInitialable=j,c.FEnum=f,c.FEventName=m,c.FUtil=_,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(c,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("@univerjs/core"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs"],n):(c=typeof globalThis<"u"?globalThis:c||self,n(c.UniverCoreFacade={},c.UniverCore,c.rxjs))})(this,function(c,n,p){"use strict";var N=Object.defineProperty;var A=(c,n,p)=>n in c?N(c,n,{enumerable:!0,configurable:!0,writable:!0,value:p}):c[n]=p;var h=(c,n,p)=>A(c,typeof n!="symbol"?n+"":n,p);class v extends n.Disposable{static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}}const S=Symbol("initializers");class j extends n.Disposable{constructor(t){super(),this._injector=t;const e=this,i=Object.getPrototypeOf(this)[S];i&&i.forEach(function(r){r.apply(e,[t])})}_initialize(t){}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{if(e==="_initialize"){let i=this.prototype[S];i||(i=[],this.prototype[S]=i),i.push(t.prototype._initialize)}else e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}}var B=Object.getOwnPropertyDescriptor,U=(a,t,e,i)=>{for(var r=i>1?void 0:i?B(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},O=(a,t)=>(e,i)=>t(e,i,a);c.FBlob=class extends v{constructor(t,e){super(),this._blob=t,this._injector=e}copyBlob(){return this._injector.createInstance(c.FBlob,this._blob)}getAs(t){const e=this.copyBlob();return e.setContentType(t),e}getDataAsString(t){return this._blob===null?Promise.resolve(""):t===void 0?this._blob.text():new Promise((e,i)=>{this._blob.arrayBuffer().then(r=>{const s=new TextDecoder(t).decode(r);e(s)}).catch(r=>{i(new Error(`Failed to read Blob as ArrayBuffer: ${r.message}`))})})}getBytes(){return this._blob?this._blob.arrayBuffer().then(t=>new Uint8Array(t)):Promise.reject(new Error("Blob is undefined or null."))}setBytes(t){return this._blob=new Blob([t]),this}setDataFromString(t,e){const i=e!=null?e:"text/plain",r=new Blob([t],{type:i});return this._blob=r,this}getContentType(){var t;return(t=this._blob)==null?void 0:t.type}setContentType(t){var e;return this._blob=(e=this._blob)==null?void 0:e.slice(0,this._blob.size,t),this}},c.FBlob=U([O(1,n.Inject(n.Injector))],c.FBlob);const y=class y{static get(){if(this._instance)return this._instance;const t=new y;return this._instance=t,t}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}constructor(){for(const t in y.prototype)this[t]=y.prototype[t]}get UniverInstanceType(){return n.UniverInstanceType}get LifecycleStages(){return n.LifecycleStages}get DataValidationType(){return n.DataValidationType}get DataValidationErrorStyle(){return n.DataValidationErrorStyle}get DataValidationRenderMode(){return n.DataValidationRenderMode}get DataValidationOperator(){return n.DataValidationOperator}get DataValidationStatus(){return n.DataValidationStatus}get CommandType(){return n.CommandType}get BaselineOffset(){return n.BaselineOffset}get BooleanNumber(){return n.BooleanNumber}get HorizontalAlign(){return n.HorizontalAlign}get TextDecoration(){return n.TextDecoration}get TextDirection(){return n.TextDirection}get VerticalAlign(){return n.VerticalAlign}get WrapStrategy(){return n.WrapStrategy}get BorderType(){return n.BorderType}get BorderStyleTypes(){return n.BorderStyleTypes}get AutoFillSeries(){return n.AutoFillSeries}get ColorType(){return n.ColorType}get CommonHideTypes(){return n.CommonHideTypes}get CopyPasteType(){return n.CopyPasteType}get DeleteDirection(){return n.DeleteDirection}get DeveloperMetadataVisibility(){return n.DeveloperMetadataVisibility}get Dimension(){return n.Dimension}get Direction(){return n.Direction}get InterpolationPointType(){return n.InterpolationPointType}get LocaleType(){return n.LocaleType}get MentionType(){return n.MentionType}get ProtectionType(){return n.ProtectionType}get RelativeDate(){return n.RelativeDate}get SheetTypes(){return n.SheetTypes}get ThemeColorType(){return n.ThemeColorType}};h(y,"_instance");let f=y;const g=class g{static get(){if(this._instance)return this._instance;const t=new g;return this._instance=t,t}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}constructor(){for(const t in g.prototype)this[t]=g.prototype[t]}get DocCreated(){return"DocCreated"}get DocDisposed(){return"DocDisposed"}get LifeCycleChanged(){return"LifeCycleChanged"}get Redo(){return"Redo"}get Undo(){return"Undo"}get BeforeRedo(){return"BeforeRedo"}get BeforeUndo(){return"BeforeUndo"}get CommandExecuted(){return"CommandExecuted"}get BeforeCommandExecute(){return"BeforeCommandExecute"}};h(g,"_instance");let m=g;var P=Object.getOwnPropertyDescriptor,I=(a,t,e,i)=>{for(var r=i>1?void 0:i?P(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},R=(a,t)=>(e,i)=>t(e,i,a);c.FHooks=class extends v{constructor(t,e){super(),this._injector=t,this._lifecycleService=e}onStarting(t){return n.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===n.LifecycleStages.Starting)).subscribe(t))}onReady(t){return n.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===n.LifecycleStages.Ready)).subscribe(t))}onRendered(t){return n.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===n.LifecycleStages.Rendered)).subscribe(t))}onSteady(t){return n.toDisposable(this._lifecycleService.lifecycle$.pipe(p.filter(e=>e===n.LifecycleStages.Steady)).subscribe(t))}onBeforeUndo(t){return this._injector.get(n.ICommandService).beforeCommandExecuted(i=>{if(i.id===n.UndoCommand.id){const s=this._injector.get(n.IUndoRedoService).pitchTopUndoElement();s&&t(s)}})}onUndo(t){return this._injector.get(n.ICommandService).onCommandExecuted(i=>{if(i.id===n.UndoCommand.id){const s=this._injector.get(n.IUndoRedoService).pitchTopUndoElement();s&&t(s)}})}onBeforeRedo(t){return this._injector.get(n.ICommandService).beforeCommandExecuted(i=>{if(i.id===n.RedoCommand.id){const s=this._injector.get(n.IUndoRedoService).pitchTopRedoElement();s&&t(s)}})}onRedo(t){return this._injector.get(n.ICommandService).onCommandExecuted(i=>{if(i.id===n.RedoCommand.id){const s=this._injector.get(n.IUndoRedoService).pitchTopRedoElement();s&&t(s)}})}},c.FHooks=I([R(0,n.Inject(n.Injector)),R(1,n.Inject(n.LifecycleService))],c.FHooks);var x=Object.getOwnPropertyDescriptor,H=(a,t,e,i)=>{for(var r=i>1?void 0:i?x(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},F=(a,t)=>(e,i)=>t(e,i,a);let C=class extends j{constructor(a,t){super(t),this.doc=a}};C=H([F(1,n.Inject(n.Injector))],C);class V{constructor(){h(this,"_eventRegistry",new Map);h(this,"_eventHandlerMap",new Map);h(this,"_eventHandlerRegisted",new Map)}_ensureEventRegistry(t){return this._eventRegistry.has(t)||this._eventRegistry.set(t,new n.Registry),this._eventRegistry.get(t)}registerEventHandler(t,e){const i=this._eventHandlerMap.get(t);return i?i.add(e):this._eventHandlerMap.set(t,new Set([e])),this._ensureEventRegistry(t).getData().length&&this._initEventHandler(t),n.toDisposable(()=>{var r,s,o,d;(r=this._eventHandlerMap.get(t))==null||r.delete(e),(o=(s=this._eventHandlerRegisted.get(t))==null?void 0:s.get(e))==null||o.dispose(),(d=this._eventHandlerRegisted.get(t))==null||d.delete(e)})}removeEvent(t,e){const i=this._ensureEventRegistry(t);if(i.delete(e),i.getData().length===0){const r=this._eventHandlerRegisted.get(t);r==null||r.forEach(s=>s.dispose()),this._eventHandlerRegisted.delete(t)}}_initEventHandler(t){let e=this._eventHandlerRegisted.get(t);const i=this._eventHandlerMap.get(t);i&&(e||(e=new Map,this._eventHandlerRegisted.set(t,e),i==null||i.forEach(r=>{e==null||e.set(r,n.toDisposable(r()))})))}addEvent(t,e){return this._ensureEventRegistry(t).add(e),this._initEventHandler(t),n.toDisposable(()=>this.removeEvent(t,e))}fireEvent(t,e){var i;return(i=this._eventRegistry.get(t))==null||i.getData().forEach(r=>{r(e)}),e.cancel}}var M=Object.getOwnPropertyDescriptor,$=(a,t,e,i)=>{for(var r=i>1?void 0:i?M(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},w=(a,t)=>(e,i)=>t(e,i,a);let D=class extends v{constructor(a,t){super(),this._injector=a,this._userManagerService=t}getCurrentUser(){return this._userManagerService.getCurrentUser()}};D=$([w(0,n.Inject(n.Injector)),w(1,n.Inject(n.UserManagerService))],D);const b=class b{static get(){if(this._instance)return this._instance;const t=new b;return this._instance=t,t}static extend(t){Object.getOwnPropertyNames(t.prototype).forEach(e=>{e!=="constructor"&&(this.prototype[e]=t.prototype[e])}),Object.getOwnPropertyNames(t).forEach(e=>{e!=="prototype"&&e!=="name"&&e!=="length"&&(this[e]=t[e])})}get rectangle(){return n.Rectangle}get numfmt(){return n.numfmt}get tools(){return n.Tools}};h(b,"_instance");let _=b;var z=Object.getOwnPropertyDescriptor,L=(a,t,e,i)=>{for(var r=i>1?void 0:i?z(t,e):t,s=a.length-1,o;s>=0;s--)(o=a[s])&&(r=o(r)||r);return r},E=(a,t)=>(e,i)=>t(e,i,a);const T=Symbol("initializers");c.FUniver=class extends n.Disposable{constructor(e,i,r,s){super();h(this,"_eventRegistry",new V);h(this,"registerEventHandler",(e,i)=>this._eventRegistry.registerEventHandler(e,i));this._injector=e,this._commandService=i,this._univerInstanceService=r,this._lifecycleService=s,this.registerEventHandler(this.Event.LifeCycleChanged,()=>n.toDisposable(this._lifecycleService.lifecycle$.subscribe(d=>{this.fireEvent(this.Event.LifeCycleChanged,{stage:d})}))),this._initUnitEvent(this._injector),this._initBeforeCommandEvent(this._injector),this._initCommandEvent(this._injector),this._injector.onDispose(()=>{this.dispose()});const o=Object.getPrototypeOf(this)[T];if(o){const d=this;o.forEach(function(u){u.apply(d,[e])})}}static newAPI(e){return(e instanceof n.Univer?e.__getInjector():e).createInstance(c.FUniver)}_initialize(e){}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(i=>{if(i==="_initialize"){let r=this.prototype[T];r||(r=[],this.prototype[T]=r),r.push(e.prototype._initialize)}else i!=="constructor"&&(this.prototype[i]=e.prototype[i])}),Object.getOwnPropertyNames(e).forEach(i=>{i!=="prototype"&&i!=="name"&&i!=="length"&&(this[i]=e[i])})}_initCommandEvent(e){const i=e.get(n.ICommandService);this.registerEventHandler(this.Event.Redo,()=>i.onCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===n.RedoCommand.id){const l={id:s,type:o,params:d};this.fireEvent(this.Event.Redo,l)}})),this.registerEventHandler(this.Event.Undo,()=>i.onCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===n.UndoCommand.id){const l={id:s,type:o,params:d};this.fireEvent(this.Event.Undo,l)}})),this.registerEventHandler(this.Event.CommandExecuted,()=>i.onCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id!==n.RedoCommand.id&&r.id!==n.UndoCommand.id){const l={id:s,type:o,params:d};this.fireEvent(this.Event.CommandExecuted,l)}}))}_initBeforeCommandEvent(e){const i=e.get(n.ICommandService);this.registerEventHandler(this.Event.BeforeRedo,()=>i.beforeCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===n.RedoCommand.id){const l={id:s,type:o,params:d};if(this.fireEvent(this.Event.BeforeRedo,l),l.cancel)throw new n.CanceledError}})),this.registerEventHandler(this.Event.BeforeUndo,()=>i.beforeCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id===n.UndoCommand.id){const l={id:s,type:o,params:d};if(this.fireEvent(this.Event.BeforeUndo,l),l.cancel)throw new n.CanceledError}})),this.registerEventHandler(this.Event.BeforeCommandExecute,()=>i.beforeCommandExecuted(r=>{const{id:s,type:o,params:d}=r;if(r.id!==n.RedoCommand.id&&r.id!==n.UndoCommand.id){const l={id:s,type:o,params:d};if(this.fireEvent(this.Event.BeforeCommandExecute,l),l.cancel)throw new n.CanceledError}}))}_initUnitEvent(e){const i=e.get(n.IUniverInstanceService);this.registerEventHandler(this.Event.DocDisposed,()=>i.unitDisposed$.subscribe(r=>{r.type===n.UniverInstanceType.UNIVER_DOC&&this.fireEvent(this.Event.DocDisposed,{unitId:r.getUnitId(),unitType:r.type,snapshot:r.getSnapshot()})})),this.registerEventHandler(this.Event.DocCreated,()=>i.unitAdded$.subscribe(r=>{if(r.type===n.UniverInstanceType.UNIVER_DOC){const s=r,o=e.createInstance(C,s);this.fireEvent(this.Event.DocCreated,{unitId:r.getUnitId(),type:r.type,doc:o,unit:o})}}))}disposeUnit(e){return this._univerInstanceService.disposeUnit(e)}getCurrentLifecycleStage(){return this._injector.get(n.LifecycleService).stage}undo(){return this._commandService.executeCommand(n.UndoCommand.id)}redo(){return this._commandService.executeCommand(n.RedoCommand.id)}onBeforeCommandExecute(e){return this._commandService.beforeCommandExecuted((i,r)=>{e(i,r)})}onCommandExecuted(e){return this._commandService.onCommandExecuted((i,r)=>{e(i,r)})}executeCommand(e,i,r){return this._commandService.executeCommand(e,i,r)}syncExecuteCommand(e,i,r){return this._commandService.syncExecuteCommand(e,i,r)}getHooks(){return this._injector.createInstance(c.FHooks)}get Enum(){return f.get()}get Event(){return m.get()}get Util(){return _.get()}addEvent(e,i){if(!e||!i)throw new Error("Cannot add empty event");return this._eventRegistry.addEvent(e,i)}fireEvent(e,i){return this._eventRegistry.fireEvent(e,i)}getUserManager(){return this._injector.createInstance(D)}newBlob(){return this._injector.createInstance(c.FBlob)}newColor(){return new n.ColorBuilder}newRichText(e){return n.RichTextBuilder.create(e)}newRichTextValue(e){return n.RichTextValue.create(e)}newParagraphStyle(e){return n.ParagraphStyleBuilder.create(e)}newParagraphStyleValue(e){return n.ParagraphStyleValue.create(e)}newTextStyle(e){return n.TextStyleBuilder.create(e)}newTextStyleValue(e){return n.TextStyleValue.create(e)}newTextDecoration(e){return new n.TextDecorationBuilder(e)}},c.FUniver=L([E(0,n.Inject(n.Injector)),E(1,n.ICommandService),E(2,n.IUniverInstanceService),E(3,n.Inject(n.LifecycleService))],c.FUniver),c.FBase=v,c.FBaseInitialable=j,c.FEnum=f,c.FEventName=m,c.FUtil=_,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|